@umituz/web-dashboard 11.11.0 → 11.13.0
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/package.json +17 -1
- package/src/domains/activity/activity.css +229 -0
- package/src/domains/activity/components/ActivityFeed.test.tsx +61 -0
- package/src/domains/activity/components/ActivityFeed.tsx +132 -0
- package/src/domains/activity/components/ActivityTimeline.tsx +127 -0
- package/src/domains/activity/components/index.ts +2 -0
- package/src/domains/activity/index.ts +3 -0
- package/src/domains/activity/types.ts +59 -0
- package/src/domains/activity/utils.ts +73 -0
- package/src/domains/filters/components/DataToolbar.test.tsx +65 -0
- package/src/domains/filters/components/DataToolbar.tsx +119 -0
- package/src/domains/filters/components/index.ts +1 -0
- package/src/domains/filters/filters.css +128 -0
- package/src/domains/filters/index.ts +2 -0
- package/src/domains/filters/types.ts +48 -0
- package/src/domains/kanban/components/KanbanBoard.test.tsx +226 -0
- package/src/domains/kanban/components/KanbanBoard.tsx +135 -0
- package/src/domains/kanban/components/KanbanCard.tsx +160 -0
- package/src/domains/kanban/components/KanbanColumn.tsx +163 -0
- package/src/domains/kanban/components/KanbanPage.test.tsx +115 -0
- package/src/domains/kanban/components/KanbanPage.tsx +91 -0
- package/src/domains/kanban/components/index.ts +4 -0
- package/src/domains/kanban/index.ts +12 -0
- package/src/domains/kanban/kanban.css +406 -0
- package/src/domains/kanban/types.ts +103 -0
- package/src/domains/pages/components/DetailPage.test.tsx +96 -0
- package/src/domains/pages/components/DetailPage.tsx +227 -0
- package/src/domains/pages/components/index.ts +1 -0
- package/src/domains/pages/types.ts +60 -0
- package/src/domains/stepper/components/Stepper.test.tsx +71 -0
- package/src/domains/stepper/components/Stepper.tsx +74 -0
- package/src/domains/stepper/components/Wizard.tsx +84 -0
- package/src/domains/stepper/components/index.ts +2 -0
- package/src/domains/stepper/index.ts +2 -0
- package/src/domains/stepper/stepper.css +145 -0
- package/src/domains/stepper/types.ts +38 -0
- package/src/index.ts +4 -0
- package/src/styles/dashboard.css +1 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import { ArrowLeft } from 'lucide-react';
|
|
4
|
+
import { Link } from 'react-router';
|
|
5
|
+
import { Button } from '@umituz/web-design-system/atoms';
|
|
6
|
+
import { EmptyState } from '@umituz/web-design-system/organisms';
|
|
7
|
+
import { cn } from '@umituz/web-design-system/utils';
|
|
8
|
+
import type {
|
|
9
|
+
DetailPageKpi,
|
|
10
|
+
DetailPageMetaItem,
|
|
11
|
+
DetailPageNotFoundConfig,
|
|
12
|
+
DetailPageProps,
|
|
13
|
+
DetailPageTab,
|
|
14
|
+
} from '../types';
|
|
15
|
+
|
|
16
|
+
function SafeBackLink({ href, label = 'Back' }: { href: string; label?: string }) {
|
|
17
|
+
try {
|
|
18
|
+
return (
|
|
19
|
+
<Link
|
|
20
|
+
to={href}
|
|
21
|
+
className="inline-flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors mb-3"
|
|
22
|
+
>
|
|
23
|
+
<ArrowLeft size={13} aria-hidden="true" />
|
|
24
|
+
<span>{label}</span>
|
|
25
|
+
</Link>
|
|
26
|
+
);
|
|
27
|
+
} catch {
|
|
28
|
+
return (
|
|
29
|
+
<a
|
|
30
|
+
href={href}
|
|
31
|
+
className="inline-flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors mb-3"
|
|
32
|
+
>
|
|
33
|
+
<ArrowLeft size={13} aria-hidden="true" />
|
|
34
|
+
<span>{label}</span>
|
|
35
|
+
</a>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function renderMetaItem(item: DetailPageMetaItem | ReactNode, index: number) {
|
|
41
|
+
if (item && typeof item === 'object' && 'value' in item && !('type' in (item as object))) {
|
|
42
|
+
const m = item as DetailPageMetaItem;
|
|
43
|
+
return (
|
|
44
|
+
<span key={index} className="inline-flex items-center gap-1.5 text-xs text-muted-foreground">
|
|
45
|
+
{m.icon && <span aria-hidden="true">{m.icon}</span>}
|
|
46
|
+
{m.label && <span>{m.label}:</span>}
|
|
47
|
+
<strong className="font-semibold text-foreground">{m.value}</strong>
|
|
48
|
+
</span>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
return (
|
|
52
|
+
<span key={index} className="text-xs text-muted-foreground">
|
|
53
|
+
{item as ReactNode}
|
|
54
|
+
</span>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function renderKpi(kpi: DetailPageKpi, index: number) {
|
|
59
|
+
return (
|
|
60
|
+
<div
|
|
61
|
+
key={index}
|
|
62
|
+
className="flex flex-col gap-1 p-4 rounded-xl border border-line-border bg-card"
|
|
63
|
+
>
|
|
64
|
+
<span className="text-xs text-muted-foreground font-medium">{kpi.label}</span>
|
|
65
|
+
<div className="flex items-baseline gap-2">
|
|
66
|
+
<span className="text-2xl font-bold tracking-tight text-foreground">{kpi.value}</span>
|
|
67
|
+
{kpi.delta && (
|
|
68
|
+
<span
|
|
69
|
+
className={cn(
|
|
70
|
+
'text-xs font-semibold',
|
|
71
|
+
kpi.delta.direction === 'up' && 'text-emerald-600',
|
|
72
|
+
kpi.delta.direction === 'down' && 'text-rose-600',
|
|
73
|
+
kpi.delta.direction === 'flat' && 'text-muted-foreground',
|
|
74
|
+
)}
|
|
75
|
+
>
|
|
76
|
+
{kpi.delta.value}
|
|
77
|
+
</span>
|
|
78
|
+
)}
|
|
79
|
+
</div>
|
|
80
|
+
{kpi.hint && <span className="text-2xs text-muted-foreground">{kpi.hint}</span>}
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function DetailPage<T = unknown>({
|
|
86
|
+
backTo,
|
|
87
|
+
title,
|
|
88
|
+
kicker,
|
|
89
|
+
badge,
|
|
90
|
+
description,
|
|
91
|
+
meta,
|
|
92
|
+
actions,
|
|
93
|
+
notice,
|
|
94
|
+
kpis,
|
|
95
|
+
tabs,
|
|
96
|
+
activeTab,
|
|
97
|
+
defaultTab,
|
|
98
|
+
onTabChange,
|
|
99
|
+
sidebar,
|
|
100
|
+
children,
|
|
101
|
+
notFound,
|
|
102
|
+
className,
|
|
103
|
+
}: DetailPageProps<T>) {
|
|
104
|
+
const [internalTab, setInternalTab] = useState<string>(() => {
|
|
105
|
+
if (activeTab !== undefined) return activeTab;
|
|
106
|
+
if (defaultTab !== undefined) return defaultTab;
|
|
107
|
+
return tabs?.[0]?.id ?? '';
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
if (notFound) {
|
|
111
|
+
const conf: DetailPageNotFoundConfig = typeof notFound === 'object' ? notFound : {};
|
|
112
|
+
return (
|
|
113
|
+
<div className={cn('flex w-full flex-col gap-6', className)}>
|
|
114
|
+
{backTo && <SafeBackLink href={backTo.href} label={backTo.label} />}
|
|
115
|
+
<EmptyState
|
|
116
|
+
title={conf.title ?? 'Record not found'}
|
|
117
|
+
description={conf.description ?? "This item doesn't exist or may have been deleted."}
|
|
118
|
+
action={
|
|
119
|
+
conf.backHref ? (
|
|
120
|
+
<Button to={conf.backHref} variant="secondary">
|
|
121
|
+
{conf.backLabel ?? 'Back'}
|
|
122
|
+
</Button>
|
|
123
|
+
) : backTo ? (
|
|
124
|
+
<Button to={backTo.href} variant="secondary">
|
|
125
|
+
{backTo.label ?? 'Back'}
|
|
126
|
+
</Button>
|
|
127
|
+
) : undefined
|
|
128
|
+
}
|
|
129
|
+
/>
|
|
130
|
+
</div>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const currentTabId = activeTab !== undefined ? activeTab : internalTab;
|
|
135
|
+
|
|
136
|
+
function handleTabSelect(id: string) {
|
|
137
|
+
if (activeTab === undefined) {
|
|
138
|
+
setInternalTab(id);
|
|
139
|
+
}
|
|
140
|
+
onTabChange?.(id);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const activeTabObj = tabs?.find((t) => t.id === currentTabId);
|
|
144
|
+
const mainContent = activeTabObj?.content ?? children;
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
<div className={cn('flex w-full flex-col gap-6', className)}>
|
|
148
|
+
{backTo && <SafeBackLink href={backTo.href} label={backTo.label} />}
|
|
149
|
+
|
|
150
|
+
<header className="flex flex-col gap-3">
|
|
151
|
+
{kicker && <div className="text-xs font-semibold tracking-wider uppercase text-muted-foreground">{kicker}</div>}
|
|
152
|
+
|
|
153
|
+
<div className="flex flex-wrap items-start justify-between gap-4">
|
|
154
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
155
|
+
<h1 className="text-2xl font-bold tracking-tight text-foreground">{title}</h1>
|
|
156
|
+
{badge}
|
|
157
|
+
</div>
|
|
158
|
+
{actions && <div className="flex flex-wrap items-center gap-2">{actions}</div>}
|
|
159
|
+
</div>
|
|
160
|
+
|
|
161
|
+
{description && <p className="text-sm text-muted-foreground leading-relaxed max-w-3xl">{description}</p>}
|
|
162
|
+
|
|
163
|
+
{meta && meta.length > 0 && (
|
|
164
|
+
<div className="flex flex-wrap items-center gap-x-4 gap-y-2 pt-1 border-t border-line-border/60">
|
|
165
|
+
{meta.map(renderMetaItem)}
|
|
166
|
+
</div>
|
|
167
|
+
)}
|
|
168
|
+
</header>
|
|
169
|
+
|
|
170
|
+
{notice}
|
|
171
|
+
|
|
172
|
+
{kpis && kpis.length > 0 && (
|
|
173
|
+
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
|
174
|
+
{kpis.map(renderKpi)}
|
|
175
|
+
</div>
|
|
176
|
+
)}
|
|
177
|
+
|
|
178
|
+
{tabs && tabs.length > 0 && (
|
|
179
|
+
<nav className="flex gap-2 border-b border-line-border pb-px" role="tablist">
|
|
180
|
+
{tabs.map((tab: DetailPageTab) => {
|
|
181
|
+
const isSelected = tab.id === currentTabId;
|
|
182
|
+
return (
|
|
183
|
+
<button
|
|
184
|
+
key={tab.id}
|
|
185
|
+
type="button"
|
|
186
|
+
role="tab"
|
|
187
|
+
aria-selected={isSelected}
|
|
188
|
+
disabled={tab.disabled}
|
|
189
|
+
onClick={() => handleTabSelect(tab.id)}
|
|
190
|
+
className={cn(
|
|
191
|
+
'inline-flex items-center gap-2 px-3.5 py-2 text-sm font-medium border-b-2 -mb-px transition-colors',
|
|
192
|
+
isSelected
|
|
193
|
+
? 'border-primary text-foreground'
|
|
194
|
+
: 'border-transparent text-muted-foreground hover:text-foreground hover:border-line-border',
|
|
195
|
+
tab.disabled && 'opacity-50 cursor-not-allowed',
|
|
196
|
+
)}
|
|
197
|
+
>
|
|
198
|
+
{tab.icon && <span aria-hidden="true">{tab.icon}</span>}
|
|
199
|
+
<span>{tab.label}</span>
|
|
200
|
+
{tab.count !== undefined && (
|
|
201
|
+
<span
|
|
202
|
+
className={cn(
|
|
203
|
+
'px-1.5 py-0.5 text-2xs font-semibold rounded-full',
|
|
204
|
+
isSelected ? 'bg-primary/10 text-primary' : 'bg-muted text-muted-foreground',
|
|
205
|
+
)}
|
|
206
|
+
>
|
|
207
|
+
{tab.count}
|
|
208
|
+
</span>
|
|
209
|
+
)}
|
|
210
|
+
{tab.badge}
|
|
211
|
+
</button>
|
|
212
|
+
);
|
|
213
|
+
})}
|
|
214
|
+
</nav>
|
|
215
|
+
)}
|
|
216
|
+
|
|
217
|
+
{sidebar ? (
|
|
218
|
+
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6 items-start">
|
|
219
|
+
<div className="lg:col-span-2 flex flex-col gap-6">{mainContent}</div>
|
|
220
|
+
<aside className="flex flex-col gap-6">{sidebar}</aside>
|
|
221
|
+
</div>
|
|
222
|
+
) : (
|
|
223
|
+
<div className="flex flex-col gap-6">{mainContent}</div>
|
|
224
|
+
)}
|
|
225
|
+
</div>
|
|
226
|
+
);
|
|
227
|
+
}
|
|
@@ -47,3 +47,63 @@ export const defaultListPageLabels: ListPageLabels = {
|
|
|
47
47
|
filterAll: 'All',
|
|
48
48
|
countShown: (shown, total) => `${shown} of ${total}`,
|
|
49
49
|
};
|
|
50
|
+
|
|
51
|
+
export interface DetailPageKpi {
|
|
52
|
+
readonly label: string;
|
|
53
|
+
readonly value: ReactNode;
|
|
54
|
+
readonly hint?: ReactNode;
|
|
55
|
+
readonly delta?: {
|
|
56
|
+
readonly value: ReactNode;
|
|
57
|
+
readonly direction?: 'up' | 'down' | 'flat';
|
|
58
|
+
};
|
|
59
|
+
readonly tone?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'neutral';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface DetailPageTab {
|
|
63
|
+
readonly id: string;
|
|
64
|
+
readonly label: ReactNode;
|
|
65
|
+
readonly count?: number;
|
|
66
|
+
readonly badge?: ReactNode;
|
|
67
|
+
readonly icon?: ReactNode;
|
|
68
|
+
readonly content?: ReactNode;
|
|
69
|
+
readonly disabled?: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface DetailPageMetaItem {
|
|
73
|
+
readonly label?: ReactNode;
|
|
74
|
+
readonly value: ReactNode;
|
|
75
|
+
readonly icon?: ReactNode;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface DetailPageBackTo {
|
|
79
|
+
readonly href: string;
|
|
80
|
+
readonly label?: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface DetailPageNotFoundConfig {
|
|
84
|
+
readonly title?: string;
|
|
85
|
+
readonly description?: string;
|
|
86
|
+
readonly backHref?: string;
|
|
87
|
+
readonly backLabel?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface DetailPageProps<T = unknown> {
|
|
91
|
+
readonly backTo?: DetailPageBackTo;
|
|
92
|
+
readonly title: ReactNode;
|
|
93
|
+
readonly kicker?: ReactNode;
|
|
94
|
+
readonly badge?: ReactNode;
|
|
95
|
+
readonly description?: ReactNode;
|
|
96
|
+
readonly meta?: readonly (DetailPageMetaItem | ReactNode)[];
|
|
97
|
+
readonly actions?: ReactNode;
|
|
98
|
+
readonly notice?: ReactNode;
|
|
99
|
+
readonly kpis?: readonly DetailPageKpi[];
|
|
100
|
+
readonly tabs?: readonly DetailPageTab[];
|
|
101
|
+
readonly activeTab?: string;
|
|
102
|
+
readonly defaultTab?: string;
|
|
103
|
+
readonly onTabChange?: (tabId: string) => void;
|
|
104
|
+
readonly sidebar?: ReactNode;
|
|
105
|
+
readonly children?: ReactNode;
|
|
106
|
+
readonly notFound?: boolean | DetailPageNotFoundConfig;
|
|
107
|
+
readonly payload?: T;
|
|
108
|
+
readonly className?: string;
|
|
109
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import { Stepper } from './Stepper';
|
|
4
|
+
import { Wizard } from './Wizard';
|
|
5
|
+
|
|
6
|
+
describe('Stepper', () => {
|
|
7
|
+
it('renders steps with numbers and labels', () => {
|
|
8
|
+
render(
|
|
9
|
+
<Stepper
|
|
10
|
+
steps={['General', 'Settings', 'Review']}
|
|
11
|
+
currentStep={1}
|
|
12
|
+
/>,
|
|
13
|
+
);
|
|
14
|
+
expect(screen.getByText('General')).toBeTruthy();
|
|
15
|
+
expect(screen.getByText('Settings')).toBeTruthy();
|
|
16
|
+
expect(screen.getByText('Review')).toBeTruthy();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('triggers onStepClick when clickable is true and previous step is clicked', () => {
|
|
20
|
+
const handleClick = vi.fn();
|
|
21
|
+
render(
|
|
22
|
+
<Stepper
|
|
23
|
+
steps={['Step 1', 'Step 2', 'Step 3']}
|
|
24
|
+
currentStep={2}
|
|
25
|
+
clickable={true}
|
|
26
|
+
onStepClick={handleClick}
|
|
27
|
+
/>,
|
|
28
|
+
);
|
|
29
|
+
fireEvent.click(screen.getByText('Step 1'));
|
|
30
|
+
expect(handleClick).toHaveBeenCalledWith(0);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('Wizard', () => {
|
|
35
|
+
it('navigates next and back', () => {
|
|
36
|
+
const handleStepChange = vi.fn();
|
|
37
|
+
render(
|
|
38
|
+
<Wizard
|
|
39
|
+
steps={['Info', 'Billing', 'Confirmation']}
|
|
40
|
+
currentStep={1}
|
|
41
|
+
onStepChange={handleStepChange}
|
|
42
|
+
>
|
|
43
|
+
<div>Billing Form</div>
|
|
44
|
+
</Wizard>,
|
|
45
|
+
);
|
|
46
|
+
expect(screen.getByText('Billing Form')).toBeTruthy();
|
|
47
|
+
|
|
48
|
+
fireEvent.click(screen.getByText('Back'));
|
|
49
|
+
expect(handleStepChange).toHaveBeenCalledWith(0);
|
|
50
|
+
|
|
51
|
+
fireEvent.click(screen.getByText('Next'));
|
|
52
|
+
expect(handleStepChange).toHaveBeenCalledWith(2);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('triggers onFinish on the last step', () => {
|
|
56
|
+
const handleFinish = vi.fn();
|
|
57
|
+
const handleStepChange = vi.fn();
|
|
58
|
+
render(
|
|
59
|
+
<Wizard
|
|
60
|
+
steps={['Info', 'Review']}
|
|
61
|
+
currentStep={1}
|
|
62
|
+
onStepChange={handleStepChange}
|
|
63
|
+
onFinish={handleFinish}
|
|
64
|
+
>
|
|
65
|
+
<div>Review Step</div>
|
|
66
|
+
</Wizard>,
|
|
67
|
+
);
|
|
68
|
+
fireEvent.click(screen.getByText('Finish'));
|
|
69
|
+
expect(handleFinish).toHaveBeenCalled();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Check, X } from 'lucide-react';
|
|
2
|
+
import { cn } from '@umituz/web-design-system/utils';
|
|
3
|
+
import type { StepItem, StepperProps } from '../types';
|
|
4
|
+
|
|
5
|
+
function normalizeStep(step: StepItem | string, index: number): StepItem {
|
|
6
|
+
if (typeof step === 'string') {
|
|
7
|
+
return { id: `step-${index}`, label: step };
|
|
8
|
+
}
|
|
9
|
+
return step;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function Stepper({
|
|
13
|
+
steps,
|
|
14
|
+
currentStep,
|
|
15
|
+
failStep,
|
|
16
|
+
orientation = 'horizontal',
|
|
17
|
+
clickable = false,
|
|
18
|
+
onStepClick,
|
|
19
|
+
className,
|
|
20
|
+
}: StepperProps) {
|
|
21
|
+
return (
|
|
22
|
+
<div
|
|
23
|
+
className={cn(
|
|
24
|
+
'udb-stepper',
|
|
25
|
+
`udb-stepper--${orientation}`,
|
|
26
|
+
className,
|
|
27
|
+
)}
|
|
28
|
+
role="list"
|
|
29
|
+
aria-label="Progress steps"
|
|
30
|
+
>
|
|
31
|
+
{steps.map((rawStep, i) => {
|
|
32
|
+
const step = normalizeStep(rawStep, i);
|
|
33
|
+
const state =
|
|
34
|
+
failStep === i ? 'fail' : i < currentStep ? 'done' : i === currentStep ? 'current' : 'pending';
|
|
35
|
+
const isClickable = clickable && !step.disabled && i <= currentStep;
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
key={step.id}
|
|
40
|
+
className={cn(
|
|
41
|
+
'udb-step',
|
|
42
|
+
`udb-step--${state}`,
|
|
43
|
+
isClickable && 'udb-step--clickable',
|
|
44
|
+
)}
|
|
45
|
+
onClick={() => {
|
|
46
|
+
if (isClickable && onStepClick) {
|
|
47
|
+
onStepClick(i);
|
|
48
|
+
}
|
|
49
|
+
}}
|
|
50
|
+
role="listitem"
|
|
51
|
+
aria-current={state === 'current' ? 'step' : undefined}
|
|
52
|
+
>
|
|
53
|
+
{i > 0 && <span className="udb-step__connector" aria-hidden="true" />}
|
|
54
|
+
<div className="udb-step__node" aria-hidden="true">
|
|
55
|
+
{state === 'done' ? (
|
|
56
|
+
<Check size={13} strokeWidth={2.5} />
|
|
57
|
+
) : state === 'fail' ? (
|
|
58
|
+
<X size={13} strokeWidth={2.5} />
|
|
59
|
+
) : step.icon ? (
|
|
60
|
+
step.icon
|
|
61
|
+
) : (
|
|
62
|
+
<span>{i + 1}</span>
|
|
63
|
+
)}
|
|
64
|
+
</div>
|
|
65
|
+
<div className="udb-step__content">
|
|
66
|
+
<span className="udb-step__label">{step.label}</span>
|
|
67
|
+
{step.description && <span className="udb-step__desc">{step.description}</span>}
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
})}
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Button } from '@umituz/web-design-system/atoms';
|
|
2
|
+
import { cn } from '@umituz/web-design-system/utils';
|
|
3
|
+
import { Stepper } from './Stepper';
|
|
4
|
+
import type { WizardProps } from '../types';
|
|
5
|
+
|
|
6
|
+
export function Wizard({
|
|
7
|
+
title,
|
|
8
|
+
description,
|
|
9
|
+
steps,
|
|
10
|
+
currentStep,
|
|
11
|
+
onStepChange,
|
|
12
|
+
onFinish,
|
|
13
|
+
onCancel,
|
|
14
|
+
orientation = 'horizontal',
|
|
15
|
+
isNextDisabled = false,
|
|
16
|
+
isSubmitting = false,
|
|
17
|
+
nextLabel = 'Next',
|
|
18
|
+
backLabel = 'Back',
|
|
19
|
+
finishLabel = 'Finish',
|
|
20
|
+
children,
|
|
21
|
+
className,
|
|
22
|
+
}: WizardProps) {
|
|
23
|
+
const isFirst = currentStep === 0;
|
|
24
|
+
const isLast = currentStep === steps.length - 1;
|
|
25
|
+
|
|
26
|
+
function handleBack() {
|
|
27
|
+
if (!isFirst) {
|
|
28
|
+
onStepChange(currentStep - 1);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function handleNext() {
|
|
33
|
+
if (isLast) {
|
|
34
|
+
onFinish?.();
|
|
35
|
+
} else {
|
|
36
|
+
onStepChange(currentStep + 1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className={cn('udb-wizard', className)}>
|
|
42
|
+
{(title || description) && (
|
|
43
|
+
<header className="flex flex-col gap-1">
|
|
44
|
+
{title && <h2 className="text-xl font-bold tracking-tight text-foreground">{title}</h2>}
|
|
45
|
+
{description && <p className="text-sm text-muted-foreground">{description}</p>}
|
|
46
|
+
</header>
|
|
47
|
+
)}
|
|
48
|
+
|
|
49
|
+
<Stepper
|
|
50
|
+
steps={steps}
|
|
51
|
+
currentStep={currentStep}
|
|
52
|
+
orientation={orientation}
|
|
53
|
+
clickable={true}
|
|
54
|
+
onStepClick={onStepChange}
|
|
55
|
+
/>
|
|
56
|
+
|
|
57
|
+
<div className="udb-wizard__body">{children}</div>
|
|
58
|
+
|
|
59
|
+
<footer className="udb-wizard__footer">
|
|
60
|
+
<div>
|
|
61
|
+
{onCancel && (
|
|
62
|
+
<Button variant="ghost" onClick={onCancel} disabled={isSubmitting}>
|
|
63
|
+
Cancel
|
|
64
|
+
</Button>
|
|
65
|
+
)}
|
|
66
|
+
</div>
|
|
67
|
+
<div className="flex items-center gap-2">
|
|
68
|
+
{!isFirst && (
|
|
69
|
+
<Button variant="secondary" onClick={handleBack} disabled={isSubmitting}>
|
|
70
|
+
{backLabel}
|
|
71
|
+
</Button>
|
|
72
|
+
)}
|
|
73
|
+
<Button
|
|
74
|
+
variant="primary"
|
|
75
|
+
onClick={handleNext}
|
|
76
|
+
disabled={isNextDisabled || isSubmitting}
|
|
77
|
+
>
|
|
78
|
+
{isSubmitting ? 'Saving…' : isLast ? finishLabel : nextLabel}
|
|
79
|
+
</Button>
|
|
80
|
+
</div>
|
|
81
|
+
</footer>
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
.udb-stepper {
|
|
2
|
+
display: flex;
|
|
3
|
+
width: 100%;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.udb-stepper--horizontal {
|
|
7
|
+
flex-direction: row;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: space-between;
|
|
10
|
+
gap: 12px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.udb-stepper--vertical {
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
gap: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.udb-step {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
gap: 10px;
|
|
22
|
+
position: relative;
|
|
23
|
+
flex: 1;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.udb-stepper--vertical .udb-step {
|
|
27
|
+
flex: none;
|
|
28
|
+
padding-bottom: 24px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.udb-stepper--vertical .udb-step:last-child {
|
|
32
|
+
padding-bottom: 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.udb-step__node {
|
|
36
|
+
display: inline-flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
width: 28px;
|
|
40
|
+
height: 28px;
|
|
41
|
+
border-radius: 9999px;
|
|
42
|
+
border: 2px solid var(--line-border, rgba(0, 0, 0, 0.15));
|
|
43
|
+
background: var(--surface, #ffffff);
|
|
44
|
+
color: var(--text-tertiary, #94a3b8);
|
|
45
|
+
font-size: 12px;
|
|
46
|
+
font-weight: 700;
|
|
47
|
+
flex-shrink: 0;
|
|
48
|
+
transition: all 0.2s ease;
|
|
49
|
+
z-index: 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.udb-step--current .udb-step__node {
|
|
53
|
+
border-color: var(--signal-600, #3b82f6);
|
|
54
|
+
background: var(--signal-600, #3b82f6);
|
|
55
|
+
color: #ffffff;
|
|
56
|
+
box-shadow: 0 0 0 3px color-mix(in oklab, var(--signal-600, #3b82f6) 20%, transparent);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.udb-step--done .udb-step__node {
|
|
60
|
+
border-color: var(--signal-600, #3b82f6);
|
|
61
|
+
background: var(--signal-600, #3b82f6);
|
|
62
|
+
color: #ffffff;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.udb-step--fail .udb-step__node {
|
|
66
|
+
border-color: #ef4444;
|
|
67
|
+
background: #ef4444;
|
|
68
|
+
color: #ffffff;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.udb-step__content {
|
|
72
|
+
display: flex;
|
|
73
|
+
flex-direction: column;
|
|
74
|
+
gap: 2px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.udb-step__label {
|
|
78
|
+
font-size: 13px;
|
|
79
|
+
font-weight: 600;
|
|
80
|
+
color: var(--text-secondary, #475569);
|
|
81
|
+
transition: color 0.2s ease;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.udb-step--current .udb-step__label {
|
|
85
|
+
color: var(--text-primary, #0f172a);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.udb-step--done .udb-step__label {
|
|
89
|
+
color: var(--text-primary, #0f172a);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.udb-step__desc {
|
|
93
|
+
font-size: 11px;
|
|
94
|
+
color: var(--text-tertiary, #94a3b8);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.udb-step__connector {
|
|
98
|
+
position: absolute;
|
|
99
|
+
background: var(--line-border, rgba(0, 0, 0, 0.1));
|
|
100
|
+
z-index: 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.udb-stepper--horizontal .udb-step__connector {
|
|
104
|
+
top: 14px;
|
|
105
|
+
left: calc(-50% + 14px);
|
|
106
|
+
right: calc(50% + 14px);
|
|
107
|
+
height: 2px;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.udb-stepper--vertical .udb-step__connector {
|
|
111
|
+
left: 13px;
|
|
112
|
+
top: 30px;
|
|
113
|
+
bottom: 0;
|
|
114
|
+
width: 2px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.udb-step--clickable {
|
|
118
|
+
cursor: pointer;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.udb-step--clickable:hover .udb-step__node {
|
|
122
|
+
border-color: var(--signal-600, #3b82f6);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.udb-wizard {
|
|
126
|
+
display: flex;
|
|
127
|
+
flex-direction: column;
|
|
128
|
+
gap: 24px;
|
|
129
|
+
width: 100%;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.udb-wizard__body {
|
|
133
|
+
display: flex;
|
|
134
|
+
flex-direction: column;
|
|
135
|
+
min-height: 200px;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.udb-wizard__footer {
|
|
139
|
+
display: flex;
|
|
140
|
+
align-items: center;
|
|
141
|
+
justify-content: space-between;
|
|
142
|
+
gap: 12px;
|
|
143
|
+
padding-top: 16px;
|
|
144
|
+
border-top: 1px solid var(--line-border, rgba(0, 0, 0, 0.08));
|
|
145
|
+
}
|