torch-glare 2.1.0 → 2.1.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/apps/lib/components/Badge.tsx +34 -137
- package/apps/lib/components/BadgeField.tsx +4 -4
- package/apps/lib/components/DataViews/ARCHITECTURE.md +439 -0
- package/apps/lib/components/DataViews/DataViewsConfigPanel.tsx +416 -0
- package/apps/lib/components/DataViews/DataViewsHeader.tsx +126 -0
- package/apps/lib/components/DataViews/DataViewsLayout.tsx +300 -0
- package/apps/lib/components/DataViews/FilterPanel.tsx +324 -0
- package/apps/lib/components/DataViews/InboxView.tsx +514 -0
- package/apps/lib/components/DataViews/KanbanView.tsx +242 -0
- package/apps/lib/components/DataViews/PanelControls.tsx +80 -0
- package/apps/lib/components/DataViews/SettingsPanel.tsx +285 -0
- package/apps/lib/components/DataViews/TableView.tsx +232 -0
- package/apps/lib/components/DataViews/TreeView.tsx +363 -0
- package/apps/lib/components/DataViews/badgeAdapter.ts +45 -0
- package/apps/lib/components/DataViews/fieldRenderers.tsx +334 -0
- package/apps/lib/components/DataViews/filters/DateRangePopover.tsx +113 -0
- package/apps/lib/components/DataViews/filters/PresetChips.tsx +45 -0
- package/apps/lib/components/DataViews/filters/RangeSliderWithInputs.tsx +154 -0
- package/apps/lib/components/DataViews/index.ts +30 -0
- package/apps/lib/components/DataViews/tree/TreeDrawer.tsx +54 -0
- package/apps/lib/components/DataViews/tree/TreeSidebar.tsx +77 -0
- package/apps/lib/components/DataViews/types.ts +177 -0
- package/apps/lib/components/TreeFolder/TreeFolder.tsx +387 -0
- package/apps/lib/components/TreeFolder/TreeFolderBreadcrumb.tsx +80 -0
- package/apps/lib/components/TreeFolder/TreeFolderRow.tsx +235 -0
- package/apps/lib/components/TreeFolder/TreeFolderStyles.tsx +60 -0
- package/apps/lib/components/TreeFolder/icons.tsx +63 -0
- package/apps/lib/components/TreeFolder/index.ts +17 -0
- package/apps/lib/components/TreeFolder/treeFolderUtils.ts +114 -0
- package/apps/lib/components/TreeFolder/types.ts +68 -0
- package/apps/lib/components/TreeFolder/useTreeFolderDnD.ts +261 -0
- package/apps/lib/hooks/useDataViewsState.ts +169 -0
- package/apps/lib/hooks/useIsMobile.ts +21 -0
- package/apps/lib/utils/dataViews/columnUtils.ts +130 -0
- package/apps/lib/utils/dataViews/fieldUtils.ts +198 -0
- package/apps/lib/utils/dataViews/nestedDataUtils.tsx +364 -0
- package/apps/lib/utils/dataViews/pathUtils.ts +132 -0
- package/apps/lib/utils/dataViews/rangeUtils.ts +225 -0
- package/apps/lib/utils/dataViews/treeUtils.ts +403 -0
- package/dist/bin/index.js +3 -3
- package/dist/bin/index.js.map +1 -1
- package/dist/src/commands/add.d.ts.map +1 -1
- package/dist/src/commands/add.js +29 -6
- package/dist/src/commands/add.js.map +1 -1
- package/dist/src/commands/utils.d.ts.map +1 -1
- package/dist/src/commands/utils.js +22 -2
- package/dist/src/commands/utils.js.map +1 -1
- package/dist/src/shared/copyComponentsRecursively.d.ts.map +1 -1
- package/dist/src/shared/copyComponentsRecursively.js +8 -1
- package/dist/src/shared/copyComponentsRecursively.js.map +1 -1
- package/dist/src/shared/getDependenciesAndInstallNestedComponents.d.ts +18 -4
- package/dist/src/shared/getDependenciesAndInstallNestedComponents.d.ts.map +1 -1
- package/dist/src/shared/getDependenciesAndInstallNestedComponents.js +110 -40
- package/dist/src/shared/getDependenciesAndInstallNestedComponents.js.map +1 -1
- package/docs/components/badge-field.md +21 -21
- package/docs/components/badge.md +156 -483
- package/docs/components/form-stepper.md +244 -0
- package/docs/components/stepper.md +215 -0
- package/docs/components/timeline.md +248 -0
- package/docs/reference/components.md +8 -7
- package/docs/reference/types.md +34 -26
- package/docs/tutorials/theming-basics.md +30 -27
- package/package.json +1 -1
- /package/docs/components/{labeled-checkbox.md → labeled-check-box.md} +0 -0
- /package/docs/components/{tree-dropdown.md → tree-drop-down.md} +0 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: FormStepper
|
|
3
|
+
description: Pill-shaped multi-step indicator for forms and wizards. Three semantic step types (default, success, negative) with resting, hover, selected, and selected-hover states. Full LTR and RTL support.
|
|
4
|
+
component: true
|
|
5
|
+
group: Forms
|
|
6
|
+
keywords: [form-stepper, stepper, wizard, steps, pill, multi-step, form, indicator, RTL]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# FormStepper
|
|
10
|
+
|
|
11
|
+
A pill-shaped multi-step indicator for forms and wizards. Each step renders a circular indicator and a label inside a pill. Selection swaps the pill background to black with a white label; hover deepens the shadow on selected pills and grows the label gap on non-selected ones. The status badge on the indicator switches the visual to `success` (green check) or `negative` (red info).
|
|
12
|
+
|
|
13
|
+
The component is composed of `FormStepper`, `FormStep`, `FormStepIndicator`, and `FormStepLabel`.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx torch-glare@latest add FormStepper
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Imports
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import {
|
|
25
|
+
FormStepper,
|
|
26
|
+
FormStep,
|
|
27
|
+
FormStepIndicator,
|
|
28
|
+
FormStepLabel,
|
|
29
|
+
} from '@/components/FormStepper'
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Basic Usage
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { useState } from 'react'
|
|
36
|
+
import {
|
|
37
|
+
FormStepper,
|
|
38
|
+
FormStep,
|
|
39
|
+
FormStepIndicator,
|
|
40
|
+
FormStepLabel,
|
|
41
|
+
} from '@/components/FormStepper'
|
|
42
|
+
|
|
43
|
+
export function BasicFormStepper() {
|
|
44
|
+
const [activeStep, setActiveStep] = useState(0)
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<FormStepper activeStep={activeStep}>
|
|
48
|
+
<FormStep index={0} type="success" onClick={() => setActiveStep(0)}>
|
|
49
|
+
<FormStepIndicator />
|
|
50
|
+
<FormStepLabel>Account</FormStepLabel>
|
|
51
|
+
</FormStep>
|
|
52
|
+
<FormStep index={1} type="default" onClick={() => setActiveStep(1)}>
|
|
53
|
+
<FormStepIndicator />
|
|
54
|
+
<FormStepLabel>Profile</FormStepLabel>
|
|
55
|
+
</FormStep>
|
|
56
|
+
<FormStep index={2} type="negative" onClick={() => setActiveStep(2)}>
|
|
57
|
+
<FormStepIndicator />
|
|
58
|
+
<FormStepLabel>Payment</FormStepLabel>
|
|
59
|
+
</FormStep>
|
|
60
|
+
<FormStep index={3} type="default" onClick={() => setActiveStep(3)}>
|
|
61
|
+
<FormStepIndicator />
|
|
62
|
+
<FormStepLabel>Confirm</FormStepLabel>
|
|
63
|
+
</FormStep>
|
|
64
|
+
</FormStepper>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`FormStepper.activeStep` drives which pill renders selected — each `FormStep` auto-selects when its `index` matches. Pass `selected` on a step to override the match.
|
|
70
|
+
|
|
71
|
+
## Examples
|
|
72
|
+
|
|
73
|
+
### Step Types
|
|
74
|
+
|
|
75
|
+
Three semantic types. `success` and `negative` add a small status badge on the indicator (check / info icon) and use filled colors when selected. `default` uses a gray ring at rest, blue ring on hover, and a solid blue fill when selected.
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
export function StepTypes() {
|
|
79
|
+
return (
|
|
80
|
+
<FormStepper>
|
|
81
|
+
<FormStep index={0} type="default" selected={false}>
|
|
82
|
+
<FormStepIndicator />
|
|
83
|
+
<FormStepLabel>Default</FormStepLabel>
|
|
84
|
+
</FormStep>
|
|
85
|
+
<FormStep index={1} type="success" selected={false}>
|
|
86
|
+
<FormStepIndicator />
|
|
87
|
+
<FormStepLabel>Success</FormStepLabel>
|
|
88
|
+
</FormStep>
|
|
89
|
+
<FormStep index={2} type="negative" selected={false}>
|
|
90
|
+
<FormStepIndicator />
|
|
91
|
+
<FormStepLabel>Negative</FormStepLabel>
|
|
92
|
+
</FormStep>
|
|
93
|
+
</FormStepper>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Selected state
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
export function SelectedSteps() {
|
|
102
|
+
return (
|
|
103
|
+
<FormStepper>
|
|
104
|
+
<FormStep index={0} type="default" selected>
|
|
105
|
+
<FormStepIndicator />
|
|
106
|
+
<FormStepLabel>Default</FormStepLabel>
|
|
107
|
+
</FormStep>
|
|
108
|
+
<FormStep index={1} type="success" selected>
|
|
109
|
+
<FormStepIndicator />
|
|
110
|
+
<FormStepLabel>Success</FormStepLabel>
|
|
111
|
+
</FormStep>
|
|
112
|
+
<FormStep index={2} type="negative" selected>
|
|
113
|
+
<FormStepIndicator />
|
|
114
|
+
<FormStepLabel>Negative</FormStepLabel>
|
|
115
|
+
</FormStep>
|
|
116
|
+
</FormStepper>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### RTL direction
|
|
122
|
+
|
|
123
|
+
The pill, label spacing, and indicator badge all flip under `dir="rtl"`.
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
export function RTLFormStepper() {
|
|
127
|
+
return (
|
|
128
|
+
<div dir="rtl">
|
|
129
|
+
<FormStepper>
|
|
130
|
+
<FormStep index={0} type="default" selected>
|
|
131
|
+
<FormStepIndicator />
|
|
132
|
+
<FormStepLabel>افتراضي</FormStepLabel>
|
|
133
|
+
</FormStep>
|
|
134
|
+
<FormStep index={1} type="success">
|
|
135
|
+
<FormStepIndicator />
|
|
136
|
+
<FormStepLabel>نجاح</FormStepLabel>
|
|
137
|
+
</FormStep>
|
|
138
|
+
<FormStep index={2} type="negative">
|
|
139
|
+
<FormStepIndicator />
|
|
140
|
+
<FormStepLabel>خطأ</FormStepLabel>
|
|
141
|
+
</FormStep>
|
|
142
|
+
</FormStepper>
|
|
143
|
+
</div>
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Custom badge icon
|
|
149
|
+
|
|
150
|
+
`FormStepIndicator.badgeIcon` overrides the default check / info icon for `success` / `negative` types.
|
|
151
|
+
|
|
152
|
+
```tsx
|
|
153
|
+
<FormStep index={0} type="success" selected>
|
|
154
|
+
<FormStepIndicator badgeIcon={<i className="ri-shield-check-line" />} />
|
|
155
|
+
<FormStepLabel>Verified</FormStepLabel>
|
|
156
|
+
</FormStep>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Custom indicator content
|
|
160
|
+
|
|
161
|
+
Children of `FormStepIndicator` replace the auto-rendered step number.
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
<FormStep index={0} type="default" selected>
|
|
165
|
+
<FormStepIndicator>
|
|
166
|
+
<i className="ri-user-line" />
|
|
167
|
+
</FormStepIndicator>
|
|
168
|
+
<FormStepLabel>Account</FormStepLabel>
|
|
169
|
+
</FormStep>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## API Reference
|
|
173
|
+
|
|
174
|
+
### FormStepper
|
|
175
|
+
|
|
176
|
+
| Prop | Type | Default | Description |
|
|
177
|
+
| ------------ | ------------------------------- | ------- | ----------------------------------------------------------------- |
|
|
178
|
+
| `activeStep` | `number` | `0` | Zero-based index of the currently selected step. |
|
|
179
|
+
| `theme` | `'dark' \| 'light' \| 'default'` | — | Theme override applied via `data-theme`. |
|
|
180
|
+
| `className` | `string` | — | Extra classes merged onto the root `<div>`. |
|
|
181
|
+
|
|
182
|
+
Standard `HTMLAttributes<HTMLDivElement>` are forwarded.
|
|
183
|
+
|
|
184
|
+
### FormStep
|
|
185
|
+
|
|
186
|
+
| Prop | Type | Default | Description |
|
|
187
|
+
| ----------- | --------------------------------------- | ----------- | -------------------------------------------------------------------------- |
|
|
188
|
+
| `index` | `number` | `0` | Zero-based step index. Matched against `FormStepper.activeStep`. |
|
|
189
|
+
| `type` | `'default' \| 'success' \| 'negative'` | `'default'` | Visual type. `success` and `negative` add a status badge on the indicator. |
|
|
190
|
+
| `selected` | `boolean` | — | Force the selected state, overriding the index/`activeStep` match. |
|
|
191
|
+
| `className` | `string` | — | Extra classes merged onto the pill root. |
|
|
192
|
+
|
|
193
|
+
Standard `HTMLAttributes<HTMLDivElement>` (minus `type`) are forwarded — typical use is `onClick` for navigation.
|
|
194
|
+
|
|
195
|
+
### FormStepIndicator
|
|
196
|
+
|
|
197
|
+
| Prop | Type | Default | Description |
|
|
198
|
+
| ----------- | ----------- | ------- | ----------------------------------------------------------------------------- |
|
|
199
|
+
| `badgeIcon` | `ReactNode` | — | Override the default badge icon (check for `success`, info for `negative`). |
|
|
200
|
+
| `children` | `ReactNode` | — | Replaces the auto-rendered step number. |
|
|
201
|
+
| `className` | `string` | — | Extra classes merged onto the indicator `<div>`. |
|
|
202
|
+
|
|
203
|
+
### FormStepLabel
|
|
204
|
+
|
|
205
|
+
Forwards `HTMLAttributes<HTMLDivElement>`. Color and label spacing follow the parent `FormStep` selection state.
|
|
206
|
+
|
|
207
|
+
## Styling
|
|
208
|
+
|
|
209
|
+
- Pill height: `28px`, fully rounded, `2px` inner padding.
|
|
210
|
+
- Indicator: `24×24px` circle, `border-[3px]` for `default`, solid fill for `success`/`negative`.
|
|
211
|
+
- Status badge: `15×15px` circle pinned to the top-right of the indicator (top-left under RTL), with `border` matching the page background.
|
|
212
|
+
- Selection: `bg-[#000000]` pill with `text-[#FFFFFF]` label and a `0 0 32px 2px rgba(0,0,0,0.05)` shadow that deepens on hover.
|
|
213
|
+
- Non-selected hover: `bg-[#FFFFFF]` pill, label gap grows from `6px` to `9px`, ring color flips to `#004699`.
|
|
214
|
+
|
|
215
|
+
## TypeScript Types
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
type FormStepperType = 'default' | 'success' | 'negative'
|
|
219
|
+
|
|
220
|
+
interface FormStepperProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
221
|
+
activeStep?: number
|
|
222
|
+
theme?: 'dark' | 'light' | 'default'
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
interface FormStepProps
|
|
226
|
+
extends Omit<React.HTMLAttributes<HTMLDivElement>, 'type'> {
|
|
227
|
+
index?: number
|
|
228
|
+
type?: FormStepperType
|
|
229
|
+
selected?: boolean
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Accessibility
|
|
234
|
+
|
|
235
|
+
- Each `FormStep` is a focusable interactive surface — attach `onClick` and (if needed) `role="button"` plus `tabIndex={0}` for keyboard navigation.
|
|
236
|
+
- The status badge is `aria-hidden`; the meaning should be carried by the label text (e.g. `"Payment — error"`).
|
|
237
|
+
- Color is never the sole signal for `success`/`negative` — pair with text or an off-screen description.
|
|
238
|
+
|
|
239
|
+
## Best Practices
|
|
240
|
+
|
|
241
|
+
1. Drive selection with `activeStep` from the parent form state — avoid setting `selected` per step manually.
|
|
242
|
+
2. Use `success` only for *completed and validated* steps, `negative` only for *failed* steps. Default = pending or current.
|
|
243
|
+
3. Keep labels short — the pill grows by `~3px` on hover, and long labels make that animation jittery.
|
|
244
|
+
4. Wire `onClick` for non-linear navigation (jump-to-step). For strict wizards, omit `onClick` on future steps.
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Stepper
|
|
3
|
+
description: Generic horizontal/vertical stepper with pending, active, completed, and error states. Composed of Stepper, Step, StepIndicator, StepConnector, StepLabel, and StepDescription.
|
|
4
|
+
component: true
|
|
5
|
+
group: Forms
|
|
6
|
+
keywords: [stepper, steps, wizard, progress, multi-step, vertical, horizontal]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Stepper
|
|
10
|
+
|
|
11
|
+
A generic step-progress component for wizards, onboarding flows, and multi-section forms. Each step has four states — `pending`, `active`, `completed`, `error` — derived automatically from `activeStep` or set explicitly per `Step`.
|
|
12
|
+
|
|
13
|
+
The component is composed of `Stepper`, `Step`, `StepIndicator`, `StepConnector`, `StepLabel`, and `StepDescription`. Compare to [`FormStepper`](./form-stepper.md), which is a pill-shaped variant with no connector line.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx torch-glare@latest add Stepper
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Imports
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import {
|
|
25
|
+
Stepper,
|
|
26
|
+
Step,
|
|
27
|
+
StepIndicator,
|
|
28
|
+
StepConnector,
|
|
29
|
+
StepLabel,
|
|
30
|
+
StepDescription,
|
|
31
|
+
} from '@/components/Stepper'
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Basic Usage
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { useState } from 'react'
|
|
38
|
+
import {
|
|
39
|
+
Stepper,
|
|
40
|
+
Step,
|
|
41
|
+
StepIndicator,
|
|
42
|
+
StepConnector,
|
|
43
|
+
StepLabel,
|
|
44
|
+
} from '@/components/Stepper'
|
|
45
|
+
|
|
46
|
+
export function BasicStepper() {
|
|
47
|
+
const [activeStep, setActiveStep] = useState(1)
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Stepper activeStep={activeStep}>
|
|
51
|
+
<Step index={0}>
|
|
52
|
+
<StepIndicator />
|
|
53
|
+
<StepLabel>Account</StepLabel>
|
|
54
|
+
</Step>
|
|
55
|
+
<StepConnector />
|
|
56
|
+
<Step index={1}>
|
|
57
|
+
<StepIndicator />
|
|
58
|
+
<StepLabel>Profile</StepLabel>
|
|
59
|
+
</Step>
|
|
60
|
+
<StepConnector />
|
|
61
|
+
<Step index={2}>
|
|
62
|
+
<StepIndicator />
|
|
63
|
+
<StepLabel>Confirm</StepLabel>
|
|
64
|
+
</Step>
|
|
65
|
+
</Stepper>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
State derivation: `index < activeStep` → `completed`, `index === activeStep` → `active`, otherwise `pending`. Pass `isCompleted`, `isActive`, or `isError` on a `Step` to override.
|
|
71
|
+
|
|
72
|
+
## Examples
|
|
73
|
+
|
|
74
|
+
### Vertical orientation with descriptions
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
<Stepper orientation="vertical" activeStep={1}>
|
|
78
|
+
<Step index={0}>
|
|
79
|
+
<StepIndicator />
|
|
80
|
+
<div>
|
|
81
|
+
<StepLabel>Create account</StepLabel>
|
|
82
|
+
<StepDescription>Email and password.</StepDescription>
|
|
83
|
+
</div>
|
|
84
|
+
</Step>
|
|
85
|
+
<StepConnector />
|
|
86
|
+
<Step index={1}>
|
|
87
|
+
<StepIndicator />
|
|
88
|
+
<div>
|
|
89
|
+
<StepLabel>Verify email</StepLabel>
|
|
90
|
+
<StepDescription>Check your inbox for a code.</StepDescription>
|
|
91
|
+
</div>
|
|
92
|
+
</Step>
|
|
93
|
+
<StepConnector />
|
|
94
|
+
<Step index={2}>
|
|
95
|
+
<StepIndicator />
|
|
96
|
+
<div>
|
|
97
|
+
<StepLabel>Done</StepLabel>
|
|
98
|
+
<StepDescription>You're all set.</StepDescription>
|
|
99
|
+
</div>
|
|
100
|
+
</Step>
|
|
101
|
+
</Stepper>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Error state
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
<Stepper activeStep={2}>
|
|
108
|
+
<Step index={0}>
|
|
109
|
+
<StepIndicator />
|
|
110
|
+
<StepLabel>Account</StepLabel>
|
|
111
|
+
</Step>
|
|
112
|
+
<StepConnector />
|
|
113
|
+
<Step index={1} isError>
|
|
114
|
+
<StepIndicator />
|
|
115
|
+
<StepLabel>Payment</StepLabel>
|
|
116
|
+
</Step>
|
|
117
|
+
<StepConnector />
|
|
118
|
+
<Step index={2}>
|
|
119
|
+
<StepIndicator />
|
|
120
|
+
<StepLabel>Confirm</StepLabel>
|
|
121
|
+
</Step>
|
|
122
|
+
</Stepper>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`StepIndicator` auto-renders a check icon for `completed`, a close icon for `error`, and the step number otherwise. Override via `icon`, `completedIcon`, or `errorIcon`.
|
|
126
|
+
|
|
127
|
+
### Custom indicators
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
<Step index={0} isCompleted>
|
|
131
|
+
<StepIndicator
|
|
132
|
+
completedIcon={<i className="ri-shield-check-line" />}
|
|
133
|
+
errorIcon={<i className="ri-shield-cross-line" />}
|
|
134
|
+
/>
|
|
135
|
+
<StepLabel>Verified</StepLabel>
|
|
136
|
+
</Step>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Sizes
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
<Stepper size="S" activeStep={1}> {/* 22px indicators */} </Stepper>
|
|
143
|
+
<Stepper size="M" activeStep={1}> {/* 28px — default */} </Stepper>
|
|
144
|
+
<Stepper size="L" activeStep={1}> {/* 34px */} </Stepper>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## API Reference
|
|
148
|
+
|
|
149
|
+
### Stepper
|
|
150
|
+
|
|
151
|
+
| Prop | Type | Default | Description |
|
|
152
|
+
| ------------- | --------------------------------- | -------------- | ---------------------------------------------------- |
|
|
153
|
+
| `activeStep` | `number` | `0` | Zero-based index of the active step. |
|
|
154
|
+
| `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | Layout direction. |
|
|
155
|
+
| `size` | `'S' \| 'M' \| 'L'` | `'M'` | Indicator size for all children. |
|
|
156
|
+
| `theme` | `'dark' \| 'light' \| 'default'` | — | Theme override applied via `data-theme`. |
|
|
157
|
+
|
|
158
|
+
### Step
|
|
159
|
+
|
|
160
|
+
| Prop | Type | Default | Description |
|
|
161
|
+
| ------------- | --------- | ------- | ------------------------------------------------------------ |
|
|
162
|
+
| `index` | `number` | `0` | Zero-based step index. Compared with `Stepper.activeStep`. |
|
|
163
|
+
| `isActive` | `boolean` | — | Force the active state. |
|
|
164
|
+
| `isCompleted` | `boolean` | — | Force the completed state. |
|
|
165
|
+
| `isError` | `boolean` | — | Force the error state. Overrides active and completed. |
|
|
166
|
+
|
|
167
|
+
### StepIndicator
|
|
168
|
+
|
|
169
|
+
| Prop | Type | Default | Description |
|
|
170
|
+
| --------------- | ----------- | ------- | ------------------------------------------------- |
|
|
171
|
+
| `icon` | `ReactNode` | — | Replaces the step number for the pending state. |
|
|
172
|
+
| `completedIcon` | `ReactNode` | — | Replaces the default check icon when completed. |
|
|
173
|
+
| `errorIcon` | `ReactNode` | — | Replaces the default close icon on error. |
|
|
174
|
+
|
|
175
|
+
### StepConnector
|
|
176
|
+
|
|
177
|
+
The line between steps. No props beyond standard HTML attributes — orientation comes from the parent `Stepper`.
|
|
178
|
+
|
|
179
|
+
### StepLabel / StepDescription
|
|
180
|
+
|
|
181
|
+
Forward `HTMLAttributes<HTMLDivElement>`. Their colors follow the parent `Step` state automatically.
|
|
182
|
+
|
|
183
|
+
## Styling
|
|
184
|
+
|
|
185
|
+
- Default state: `bg-background-presentation-action-disabled`, gray border, disabled foreground.
|
|
186
|
+
- Active: blue informational background + focus ring.
|
|
187
|
+
- Completed: green success background and ring; check icon.
|
|
188
|
+
- Error: red negative background and ring; close icon.
|
|
189
|
+
- Connectors: `2px` line, gray when pending, focus-blue when the preceding step is completed.
|
|
190
|
+
|
|
191
|
+
## TypeScript Types
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
import type { VariantProps } from 'class-variance-authority'
|
|
195
|
+
import type { stepperStyles, stepIndicatorStyles } from '@/components/Stepper'
|
|
196
|
+
|
|
197
|
+
type StepperVariants = VariantProps<typeof stepperStyles>
|
|
198
|
+
// { orientation?: 'horizontal' | 'vertical' }
|
|
199
|
+
|
|
200
|
+
type IndicatorVariants = VariantProps<typeof stepIndicatorStyles>
|
|
201
|
+
// { state?: 'pending' | 'active' | 'completed' | 'error'; size?: 'S' | 'M' | 'L' }
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Accessibility
|
|
205
|
+
|
|
206
|
+
- Wrap the stepper in a `<nav aria-label="Progress">` when it represents real navigation.
|
|
207
|
+
- Use `aria-current="step"` on the active step's container when steps are interactive.
|
|
208
|
+
- Don't rely on color alone for error — pair with `StepDescription` or an off-screen message.
|
|
209
|
+
|
|
210
|
+
## Best Practices
|
|
211
|
+
|
|
212
|
+
1. Use `Stepper` when you need a connector line + numbered/iconified steps. Use `FormStepper` when you want pill-shaped buttons without a line.
|
|
213
|
+
2. Keep `Step` count to 3–5 horizontal, 3–7 vertical. Beyond that, switch to a checklist or summary.
|
|
214
|
+
3. Drive state from `activeStep` in the parent — only fall back to `isActive`/`isCompleted` for non-linear flows.
|
|
215
|
+
4. Provide a `StepDescription` only on vertical steppers — descriptions wrap horizontal layouts awkwardly.
|