ui-arreya-components 0.0.14 → 0.0.15
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/styles.css +1 -1
- package/dist/ui.cjs.js +62 -185
- package/dist/ui.es.js +6605 -24381
- package/dist/ui.umd.js +63 -186
- package/package.json +2 -2
- package/scripts/template.sh +5 -5
- package/src/components/feature/header.stories.tsx +1 -1
- package/src/components/feature/header.tsx +6 -5
- package/src/components/index.ts +1 -0
- package/src/components/ui/index.ts +1 -0
- package/src/components/ui/input.tsx +1 -1
- package/src/components/ui/sheet.tsx +2 -0
- package/src/components/ui/sonner.tsx +2 -2
- package/src/index.css +8 -124
- package/src/index.ts +51 -51
- package/tailwind.config.js +2 -0
- package/.github/workflows/npm-publish.yml +0 -35
- package/scripts/build-index-ts.sh +0 -16
- package/src/components/feature/graph-card.stories.tsx +0 -138
- package/src/components/feature/graph-card.tsx +0 -113
- package/src/components/feature/search-bar.stories.tsx +0 -35
- package/src/components/feature/search-bar.tsx +0 -141
- package/src/components/feature/wizard.stories.tsx +0 -199
- package/src/components/feature/wizard.tsx +0 -278
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import React, { useState, createContext, useContext } from "react"
|
|
4
|
-
import { cn } from "@/lib/utils"
|
|
5
|
-
import { Check, ChevronRight } from 'lucide-react'
|
|
6
|
-
import { Button } from "@/components/ui/button"
|
|
7
|
-
|
|
8
|
-
// Types
|
|
9
|
-
export type WizardStepStatus = "upcoming" | "current" | "completed"
|
|
10
|
-
|
|
11
|
-
export interface WizardStep {
|
|
12
|
-
id: string
|
|
13
|
-
title: string
|
|
14
|
-
description?: string
|
|
15
|
-
optional?: boolean
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface WizardContextValue {
|
|
19
|
-
currentStepIndex: number
|
|
20
|
-
steps: WizardStep[]
|
|
21
|
-
goToStep: (index: number) => void
|
|
22
|
-
nextStep: () => void
|
|
23
|
-
prevStep: () => void
|
|
24
|
-
isFirstStep: boolean
|
|
25
|
-
isLastStep: boolean
|
|
26
|
-
getStepStatus: (index: number) => WizardStepStatus
|
|
27
|
-
completeWizard: () => void
|
|
28
|
-
isComplete: boolean
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Context
|
|
32
|
-
const WizardContext = createContext<WizardContextValue | undefined>(undefined)
|
|
33
|
-
|
|
34
|
-
export function useWizard() {
|
|
35
|
-
const context = useContext(WizardContext)
|
|
36
|
-
if (!context) {
|
|
37
|
-
throw new Error("useWizard must be used within a WizardProvider")
|
|
38
|
-
}
|
|
39
|
-
return context
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Provider Component
|
|
43
|
-
interface WizardProviderProps {
|
|
44
|
-
steps: WizardStep[]
|
|
45
|
-
children: React.ReactNode
|
|
46
|
-
onComplete?: () => void
|
|
47
|
-
initialStep?: number
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function WizardProvider({
|
|
51
|
-
steps,
|
|
52
|
-
children,
|
|
53
|
-
onComplete,
|
|
54
|
-
initialStep = 0,
|
|
55
|
-
}: WizardProviderProps) {
|
|
56
|
-
const [currentStepIndex, setCurrentStepIndex] = useState(initialStep)
|
|
57
|
-
const [isComplete, setIsComplete] = useState(false)
|
|
58
|
-
|
|
59
|
-
const goToStep = (index: number) => {
|
|
60
|
-
if (index >= 0 && index < steps.length) {
|
|
61
|
-
setCurrentStepIndex(index)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const nextStep = () => {
|
|
66
|
-
if (currentStepIndex < steps.length - 1) {
|
|
67
|
-
setCurrentStepIndex(currentStepIndex + 1)
|
|
68
|
-
} else {
|
|
69
|
-
completeWizard()
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const prevStep = () => {
|
|
74
|
-
if (currentStepIndex > 0) {
|
|
75
|
-
setCurrentStepIndex(currentStepIndex - 1)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const completeWizard = () => {
|
|
80
|
-
setIsComplete(true)
|
|
81
|
-
onComplete?.()
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const getStepStatus = (index: number): WizardStepStatus => {
|
|
85
|
-
if (isComplete) return "completed"
|
|
86
|
-
if (index < currentStepIndex) return "completed"
|
|
87
|
-
if (index === currentStepIndex) return "current"
|
|
88
|
-
return "upcoming"
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const value = {
|
|
92
|
-
currentStepIndex,
|
|
93
|
-
steps,
|
|
94
|
-
goToStep,
|
|
95
|
-
nextStep,
|
|
96
|
-
prevStep,
|
|
97
|
-
isFirstStep: currentStepIndex === 0,
|
|
98
|
-
isLastStep: currentStepIndex === steps.length - 1,
|
|
99
|
-
getStepStatus,
|
|
100
|
-
completeWizard,
|
|
101
|
-
isComplete,
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return <WizardContext.Provider value={value}>{children}</WizardContext.Provider>
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Wizard Component
|
|
108
|
-
interface WizardProps extends WizardProviderProps {
|
|
109
|
-
className?: string
|
|
110
|
-
showStepIndicator?: boolean
|
|
111
|
-
navigationPosition?: "top" | "bottom" | "both"
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export function Wizard({
|
|
115
|
-
steps,
|
|
116
|
-
children,
|
|
117
|
-
onComplete,
|
|
118
|
-
initialStep = 0,
|
|
119
|
-
className,
|
|
120
|
-
showStepIndicator = true,
|
|
121
|
-
navigationPosition = "bottom",
|
|
122
|
-
}: WizardProps) {
|
|
123
|
-
return (
|
|
124
|
-
<WizardProvider steps={steps} onComplete={onComplete} initialStep={initialStep}>
|
|
125
|
-
<div className={cn("w-full", className)}>
|
|
126
|
-
{(navigationPosition === "top" || navigationPosition === "both") && (
|
|
127
|
-
<WizardNavigation className="mb-6" />
|
|
128
|
-
)}
|
|
129
|
-
|
|
130
|
-
{showStepIndicator && <WizardStepIndicator className="mb-8" />}
|
|
131
|
-
|
|
132
|
-
<div className="wizard-content">{children}</div>
|
|
133
|
-
|
|
134
|
-
{(navigationPosition === "bottom" || navigationPosition === "both") && (
|
|
135
|
-
<WizardNavigation className="mt-6" />
|
|
136
|
-
)}
|
|
137
|
-
</div>
|
|
138
|
-
</WizardProvider>
|
|
139
|
-
)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Step Indicator Component
|
|
143
|
-
interface WizardStepIndicatorProps {
|
|
144
|
-
className?: string
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export function WizardStepIndicator({ className }: WizardStepIndicatorProps) {
|
|
148
|
-
const { steps, currentStepIndex, getStepStatus, goToStep } = useWizard()
|
|
149
|
-
|
|
150
|
-
return (
|
|
151
|
-
<div className={cn("w-full", className)}>
|
|
152
|
-
<div className="relative flex w-full justify-between">
|
|
153
|
-
{/* Progress Bar */}
|
|
154
|
-
<div className="absolute top-1/2 h-0.5 w-full -translate-y-1/2 bg-muted">
|
|
155
|
-
<div
|
|
156
|
-
className="h-full bg-primary transition-all duration-300 ease-in-out"
|
|
157
|
-
style={{ width: `${(currentStepIndex / (steps.length - 1)) * 100}%` }}
|
|
158
|
-
/>
|
|
159
|
-
</div>
|
|
160
|
-
|
|
161
|
-
{/* Step Indicators */}
|
|
162
|
-
{steps.map((step, index) => {
|
|
163
|
-
const status = getStepStatus(index)
|
|
164
|
-
return (
|
|
165
|
-
<div key={step.id} className="relative z-10 flex flex-col items-center">
|
|
166
|
-
<button
|
|
167
|
-
onClick={() => {
|
|
168
|
-
if (status === "completed") {
|
|
169
|
-
goToStep(index)
|
|
170
|
-
}
|
|
171
|
-
}}
|
|
172
|
-
disabled={status === "upcoming"}
|
|
173
|
-
className={cn(
|
|
174
|
-
"flex h-8 w-8 items-center justify-center rounded-full border-2 text-sm font-medium transition-colors",
|
|
175
|
-
status === "completed" && "border-primary bg-primary text-primary-foreground hover:bg-primary/90",
|
|
176
|
-
status === "current" && "border-primary bg-background text-primary",
|
|
177
|
-
status === "upcoming" && "border-muted bg-background text-muted-foreground"
|
|
178
|
-
)}
|
|
179
|
-
aria-current={status === "current" ? "step" : undefined}
|
|
180
|
-
>
|
|
181
|
-
{status === "completed" ? <Check className="h-4 w-4" /> : index + 1}
|
|
182
|
-
</button>
|
|
183
|
-
<div className="mt-2 text-center">
|
|
184
|
-
<div
|
|
185
|
-
className={cn(
|
|
186
|
-
"text-xs font-medium",
|
|
187
|
-
status === "completed" && "text-primary",
|
|
188
|
-
status === "current" && "text-primary",
|
|
189
|
-
status === "upcoming" && "text-muted-foreground"
|
|
190
|
-
)}
|
|
191
|
-
>
|
|
192
|
-
{step.title}
|
|
193
|
-
</div>
|
|
194
|
-
{step.description && (
|
|
195
|
-
<div className="mt-0.5 text-xs text-muted-foreground">
|
|
196
|
-
{step.description}
|
|
197
|
-
</div>
|
|
198
|
-
)}
|
|
199
|
-
</div>
|
|
200
|
-
</div>
|
|
201
|
-
)
|
|
202
|
-
})}
|
|
203
|
-
</div>
|
|
204
|
-
</div>
|
|
205
|
-
)
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// Navigation Component
|
|
209
|
-
interface WizardNavigationProps {
|
|
210
|
-
className?: string
|
|
211
|
-
showCancel?: boolean
|
|
212
|
-
onCancel?: () => void
|
|
213
|
-
nextLabel?: string
|
|
214
|
-
backLabel?: string
|
|
215
|
-
completeLabel?: string
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
export function WizardNavigation({
|
|
219
|
-
className,
|
|
220
|
-
showCancel = false,
|
|
221
|
-
onCancel,
|
|
222
|
-
nextLabel = "Next",
|
|
223
|
-
backLabel = "Back",
|
|
224
|
-
completeLabel = "Complete",
|
|
225
|
-
}: WizardNavigationProps) {
|
|
226
|
-
const { nextStep, prevStep, isFirstStep, isLastStep, completeWizard } = useWizard()
|
|
227
|
-
|
|
228
|
-
return (
|
|
229
|
-
<div className={cn("flex items-center justify-between", className)}>
|
|
230
|
-
<div>
|
|
231
|
-
{!isFirstStep && (
|
|
232
|
-
<Button variant="outline" onClick={prevStep}>
|
|
233
|
-
{backLabel}
|
|
234
|
-
</Button>
|
|
235
|
-
)}
|
|
236
|
-
{showCancel && isFirstStep && (
|
|
237
|
-
<Button variant="outline" onClick={onCancel}>
|
|
238
|
-
Cancel
|
|
239
|
-
</Button>
|
|
240
|
-
)}
|
|
241
|
-
</div>
|
|
242
|
-
<Button onClick={isLastStep ? completeWizard : nextStep}>
|
|
243
|
-
{isLastStep ? completeLabel : nextLabel}
|
|
244
|
-
{!isLastStep && <ChevronRight className="ml-1 h-4 w-4" />}
|
|
245
|
-
</Button>
|
|
246
|
-
</div>
|
|
247
|
-
)
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// Step Component
|
|
251
|
-
interface WizardStepContentProps {
|
|
252
|
-
stepId: string
|
|
253
|
-
children: React.ReactNode
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
export function WizardStepContent({ stepId, children }: WizardStepContentProps) {
|
|
257
|
-
const { steps, currentStepIndex, isComplete } = useWizard()
|
|
258
|
-
const currentStep = steps[currentStepIndex]
|
|
259
|
-
|
|
260
|
-
if (isComplete) return null
|
|
261
|
-
if (currentStep.id !== stepId) return null
|
|
262
|
-
|
|
263
|
-
return <>{children}</>
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// Completion Component
|
|
267
|
-
interface WizardCompletionProps {
|
|
268
|
-
children: React.ReactNode
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
export function WizardCompletion({ children }: WizardCompletionProps) {
|
|
272
|
-
const { isComplete } = useWizard()
|
|
273
|
-
|
|
274
|
-
if (!isComplete) return null
|
|
275
|
-
|
|
276
|
-
return <>{children}</>
|
|
277
|
-
}
|
|
278
|
-
|