XspecT 0.4.0__py3-none-any.whl → 0.5.0__py3-none-any.whl
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.
Potentially problematic release.
This version of XspecT might be problematic. Click here for more details.
- xspect/classify.py +32 -0
- xspect/file_io.py +3 -9
- xspect/filter_sequences.py +56 -0
- xspect/main.py +52 -30
- xspect/mlst_feature/mlst_helper.py +102 -13
- xspect/mlst_feature/pub_mlst_handler.py +32 -6
- xspect/model_management.py +1 -15
- xspect/models/probabilistic_filter_mlst_model.py +160 -32
- xspect/models/probabilistic_filter_model.py +1 -0
- xspect/models/result.py +18 -6
- xspect/ncbi.py +8 -6
- xspect/train.py +13 -5
- xspect/web.py +173 -0
- xspect/xspect-web/.gitignore +24 -0
- xspect/xspect-web/README.md +54 -0
- xspect/xspect-web/components.json +21 -0
- xspect/xspect-web/dist/assets/index-CMG4V7fZ.js +290 -0
- xspect/xspect-web/dist/assets/index-jIKg1HIy.css +1 -0
- xspect/xspect-web/dist/index.html +14 -0
- xspect/xspect-web/dist/vite.svg +1 -0
- xspect/xspect-web/eslint.config.js +28 -0
- xspect/xspect-web/index.html +13 -0
- xspect/xspect-web/package-lock.json +6865 -0
- xspect/xspect-web/package.json +58 -0
- xspect/xspect-web/pnpm-lock.yaml +4317 -0
- xspect/xspect-web/public/vite.svg +1 -0
- xspect/xspect-web/src/App.tsx +29 -0
- xspect/xspect-web/src/api.tsx +62 -0
- xspect/xspect-web/src/assets/react.svg +1 -0
- xspect/xspect-web/src/components/classification-form.tsx +284 -0
- xspect/xspect-web/src/components/classify.tsx +18 -0
- xspect/xspect-web/src/components/data-table.tsx +78 -0
- xspect/xspect-web/src/components/dropdown-checkboxes.tsx +63 -0
- xspect/xspect-web/src/components/dropdown-slider.tsx +42 -0
- xspect/xspect-web/src/components/filter-form.tsx +423 -0
- xspect/xspect-web/src/components/filter.tsx +15 -0
- xspect/xspect-web/src/components/header.tsx +46 -0
- xspect/xspect-web/src/components/landing.tsx +7 -0
- xspect/xspect-web/src/components/models-details.tsx +138 -0
- xspect/xspect-web/src/components/models.tsx +53 -0
- xspect/xspect-web/src/components/result-chart.tsx +44 -0
- xspect/xspect-web/src/components/result.tsx +155 -0
- xspect/xspect-web/src/components/spinner.tsx +30 -0
- xspect/xspect-web/src/components/ui/accordion.tsx +64 -0
- xspect/xspect-web/src/components/ui/button.tsx +59 -0
- xspect/xspect-web/src/components/ui/card.tsx +92 -0
- xspect/xspect-web/src/components/ui/chart.tsx +351 -0
- xspect/xspect-web/src/components/ui/command.tsx +175 -0
- xspect/xspect-web/src/components/ui/dialog.tsx +135 -0
- xspect/xspect-web/src/components/ui/dropdown-menu.tsx +255 -0
- xspect/xspect-web/src/components/ui/file-upload.tsx +1459 -0
- xspect/xspect-web/src/components/ui/form.tsx +165 -0
- xspect/xspect-web/src/components/ui/input.tsx +21 -0
- xspect/xspect-web/src/components/ui/label.tsx +24 -0
- xspect/xspect-web/src/components/ui/navigation-menu.tsx +168 -0
- xspect/xspect-web/src/components/ui/popover.tsx +46 -0
- xspect/xspect-web/src/components/ui/select.tsx +183 -0
- xspect/xspect-web/src/components/ui/separator.tsx +26 -0
- xspect/xspect-web/src/components/ui/slider.tsx +61 -0
- xspect/xspect-web/src/components/ui/switch.tsx +29 -0
- xspect/xspect-web/src/components/ui/table.tsx +113 -0
- xspect/xspect-web/src/components/ui/tabs.tsx +64 -0
- xspect/xspect-web/src/index.css +120 -0
- xspect/xspect-web/src/lib/utils.ts +6 -0
- xspect/xspect-web/src/main.tsx +10 -0
- xspect/xspect-web/src/types.tsx +34 -0
- xspect/xspect-web/src/utils.tsx +6 -0
- xspect/xspect-web/src/vite-env.d.ts +1 -0
- xspect/xspect-web/tsconfig.app.json +32 -0
- xspect/xspect-web/tsconfig.json +13 -0
- xspect/xspect-web/tsconfig.node.json +24 -0
- xspect/xspect-web/vite.config.ts +24 -0
- {xspect-0.4.0.dist-info → xspect-0.5.0.dist-info}/METADATA +7 -8
- xspect-0.5.0.dist-info/RECORD +85 -0
- {xspect-0.4.0.dist-info → xspect-0.5.0.dist-info}/WHEEL +1 -1
- xspect/fastapi.py +0 -102
- xspect-0.4.0.dist-info/RECORD +0 -24
- {xspect-0.4.0.dist-info → xspect-0.5.0.dist-info}/entry_points.txt +0 -0
- {xspect-0.4.0.dist-info → xspect-0.5.0.dist-info}/licenses/LICENSE +0 -0
- {xspect-0.4.0.dist-info → xspect-0.5.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as RechartsPrimitive from "recharts"
|
|
3
|
+
|
|
4
|
+
import { cn } from "@/lib/utils"
|
|
5
|
+
|
|
6
|
+
// Format: { THEME_NAME: CSS_SELECTOR }
|
|
7
|
+
const THEMES = { light: "", dark: ".dark" } as const
|
|
8
|
+
|
|
9
|
+
export type ChartConfig = {
|
|
10
|
+
[k in string]: {
|
|
11
|
+
label?: React.ReactNode
|
|
12
|
+
icon?: React.ComponentType
|
|
13
|
+
} & (
|
|
14
|
+
| { color?: string; theme?: never }
|
|
15
|
+
| { color?: never; theme: Record<keyof typeof THEMES, string> }
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type ChartContextProps = {
|
|
20
|
+
config: ChartConfig
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const ChartContext = React.createContext<ChartContextProps | null>(null)
|
|
24
|
+
|
|
25
|
+
function useChart() {
|
|
26
|
+
const context = React.useContext(ChartContext)
|
|
27
|
+
|
|
28
|
+
if (!context) {
|
|
29
|
+
throw new Error("useChart must be used within a <ChartContainer />")
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return context
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function ChartContainer({
|
|
36
|
+
id,
|
|
37
|
+
className,
|
|
38
|
+
children,
|
|
39
|
+
config,
|
|
40
|
+
...props
|
|
41
|
+
}: React.ComponentProps<"div"> & {
|
|
42
|
+
config: ChartConfig
|
|
43
|
+
children: React.ComponentProps<
|
|
44
|
+
typeof RechartsPrimitive.ResponsiveContainer
|
|
45
|
+
>["children"]
|
|
46
|
+
}) {
|
|
47
|
+
const uniqueId = React.useId()
|
|
48
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<ChartContext.Provider value={{ config }}>
|
|
52
|
+
<div
|
|
53
|
+
data-slot="chart"
|
|
54
|
+
data-chart={chartId}
|
|
55
|
+
className={cn(
|
|
56
|
+
"[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
|
57
|
+
className
|
|
58
|
+
)}
|
|
59
|
+
{...props}
|
|
60
|
+
>
|
|
61
|
+
<ChartStyle id={chartId} config={config} />
|
|
62
|
+
<RechartsPrimitive.ResponsiveContainer>
|
|
63
|
+
{children}
|
|
64
|
+
</RechartsPrimitive.ResponsiveContainer>
|
|
65
|
+
</div>
|
|
66
|
+
</ChartContext.Provider>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
|
|
71
|
+
const colorConfig = Object.entries(config).filter(
|
|
72
|
+
([, config]) => config.theme || config.color
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
if (!colorConfig.length) {
|
|
76
|
+
return null
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<style
|
|
81
|
+
dangerouslySetInnerHTML={{
|
|
82
|
+
__html: Object.entries(THEMES)
|
|
83
|
+
.map(
|
|
84
|
+
([theme, prefix]) => `
|
|
85
|
+
${prefix} [data-chart=${id}] {
|
|
86
|
+
${colorConfig
|
|
87
|
+
.map(([key, itemConfig]) => {
|
|
88
|
+
const color =
|
|
89
|
+
itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||
|
|
90
|
+
itemConfig.color
|
|
91
|
+
return color ? ` --color-${key}: ${color};` : null
|
|
92
|
+
})
|
|
93
|
+
.join("\n")}
|
|
94
|
+
}
|
|
95
|
+
`
|
|
96
|
+
)
|
|
97
|
+
.join("\n"),
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const ChartTooltip = RechartsPrimitive.Tooltip
|
|
104
|
+
|
|
105
|
+
function ChartTooltipContent({
|
|
106
|
+
active,
|
|
107
|
+
payload,
|
|
108
|
+
className,
|
|
109
|
+
indicator = "dot",
|
|
110
|
+
hideLabel = false,
|
|
111
|
+
hideIndicator = false,
|
|
112
|
+
label,
|
|
113
|
+
labelFormatter,
|
|
114
|
+
labelClassName,
|
|
115
|
+
formatter,
|
|
116
|
+
color,
|
|
117
|
+
nameKey,
|
|
118
|
+
labelKey,
|
|
119
|
+
}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
|
|
120
|
+
React.ComponentProps<"div"> & {
|
|
121
|
+
hideLabel?: boolean
|
|
122
|
+
hideIndicator?: boolean
|
|
123
|
+
indicator?: "line" | "dot" | "dashed"
|
|
124
|
+
nameKey?: string
|
|
125
|
+
labelKey?: string
|
|
126
|
+
}) {
|
|
127
|
+
const { config } = useChart()
|
|
128
|
+
|
|
129
|
+
const tooltipLabel = React.useMemo(() => {
|
|
130
|
+
if (hideLabel || !payload?.length) {
|
|
131
|
+
return null
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const [item] = payload
|
|
135
|
+
const key = `${labelKey || item?.dataKey || item?.name || "value"}`
|
|
136
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
137
|
+
const value =
|
|
138
|
+
!labelKey && typeof label === "string"
|
|
139
|
+
? config[label as keyof typeof config]?.label || label
|
|
140
|
+
: itemConfig?.label
|
|
141
|
+
|
|
142
|
+
if (labelFormatter) {
|
|
143
|
+
return (
|
|
144
|
+
<div className={cn("font-medium", labelClassName)}>
|
|
145
|
+
{labelFormatter(value, payload)}
|
|
146
|
+
</div>
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (!value) {
|
|
151
|
+
return null
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return <div className={cn("font-medium", labelClassName)}>{value}</div>
|
|
155
|
+
}, [
|
|
156
|
+
label,
|
|
157
|
+
labelFormatter,
|
|
158
|
+
payload,
|
|
159
|
+
hideLabel,
|
|
160
|
+
labelClassName,
|
|
161
|
+
config,
|
|
162
|
+
labelKey,
|
|
163
|
+
])
|
|
164
|
+
|
|
165
|
+
if (!active || !payload?.length) {
|
|
166
|
+
return null
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const nestLabel = payload.length === 1 && indicator !== "dot"
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<div
|
|
173
|
+
className={cn(
|
|
174
|
+
"border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl",
|
|
175
|
+
className
|
|
176
|
+
)}
|
|
177
|
+
>
|
|
178
|
+
{!nestLabel ? tooltipLabel : null}
|
|
179
|
+
<div className="grid gap-1.5">
|
|
180
|
+
{payload.map((item, index) => {
|
|
181
|
+
const key = `${nameKey || item.name || item.dataKey || "value"}`
|
|
182
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
183
|
+
const indicatorColor = color || item.payload.fill || item.color
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<div
|
|
187
|
+
key={item.dataKey}
|
|
188
|
+
className={cn(
|
|
189
|
+
"[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
|
|
190
|
+
indicator === "dot" && "items-center"
|
|
191
|
+
)}
|
|
192
|
+
>
|
|
193
|
+
{formatter && item?.value !== undefined && item.name ? (
|
|
194
|
+
formatter(item.value, item.name, item, index, item.payload)
|
|
195
|
+
) : (
|
|
196
|
+
<>
|
|
197
|
+
{itemConfig?.icon ? (
|
|
198
|
+
<itemConfig.icon />
|
|
199
|
+
) : (
|
|
200
|
+
!hideIndicator && (
|
|
201
|
+
<div
|
|
202
|
+
className={cn(
|
|
203
|
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
|
204
|
+
{
|
|
205
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
206
|
+
"w-1": indicator === "line",
|
|
207
|
+
"w-0 border-[1.5px] border-dashed bg-transparent":
|
|
208
|
+
indicator === "dashed",
|
|
209
|
+
"my-0.5": nestLabel && indicator === "dashed",
|
|
210
|
+
}
|
|
211
|
+
)}
|
|
212
|
+
style={
|
|
213
|
+
{
|
|
214
|
+
"--color-bg": indicatorColor,
|
|
215
|
+
"--color-border": indicatorColor,
|
|
216
|
+
} as React.CSSProperties
|
|
217
|
+
}
|
|
218
|
+
/>
|
|
219
|
+
)
|
|
220
|
+
)}
|
|
221
|
+
<div
|
|
222
|
+
className={cn(
|
|
223
|
+
"flex flex-1 justify-between leading-none",
|
|
224
|
+
nestLabel ? "items-end" : "items-center"
|
|
225
|
+
)}
|
|
226
|
+
>
|
|
227
|
+
<div className="grid gap-1.5">
|
|
228
|
+
{nestLabel ? tooltipLabel : null}
|
|
229
|
+
<span className="text-muted-foreground">
|
|
230
|
+
{itemConfig?.label || item.name}
|
|
231
|
+
</span>
|
|
232
|
+
</div>
|
|
233
|
+
{item.value && (
|
|
234
|
+
<span className="text-foreground font-mono font-medium tabular-nums">
|
|
235
|
+
{item.value.toLocaleString()}
|
|
236
|
+
</span>
|
|
237
|
+
)}
|
|
238
|
+
</div>
|
|
239
|
+
</>
|
|
240
|
+
)}
|
|
241
|
+
</div>
|
|
242
|
+
)
|
|
243
|
+
})}
|
|
244
|
+
</div>
|
|
245
|
+
</div>
|
|
246
|
+
)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const ChartLegend = RechartsPrimitive.Legend
|
|
250
|
+
|
|
251
|
+
function ChartLegendContent({
|
|
252
|
+
className,
|
|
253
|
+
hideIcon = false,
|
|
254
|
+
payload,
|
|
255
|
+
verticalAlign = "bottom",
|
|
256
|
+
nameKey,
|
|
257
|
+
}: React.ComponentProps<"div"> &
|
|
258
|
+
Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {
|
|
259
|
+
hideIcon?: boolean
|
|
260
|
+
nameKey?: string
|
|
261
|
+
}) {
|
|
262
|
+
const { config } = useChart()
|
|
263
|
+
|
|
264
|
+
if (!payload?.length) {
|
|
265
|
+
return null
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return (
|
|
269
|
+
<div
|
|
270
|
+
className={cn(
|
|
271
|
+
"flex items-center justify-center gap-4",
|
|
272
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
273
|
+
className
|
|
274
|
+
)}
|
|
275
|
+
>
|
|
276
|
+
{payload.map((item) => {
|
|
277
|
+
const key = `${nameKey || item.dataKey || "value"}`
|
|
278
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key)
|
|
279
|
+
|
|
280
|
+
return (
|
|
281
|
+
<div
|
|
282
|
+
key={item.value}
|
|
283
|
+
className={cn(
|
|
284
|
+
"[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"
|
|
285
|
+
)}
|
|
286
|
+
>
|
|
287
|
+
{itemConfig?.icon && !hideIcon ? (
|
|
288
|
+
<itemConfig.icon />
|
|
289
|
+
) : (
|
|
290
|
+
<div
|
|
291
|
+
className="h-2 w-2 shrink-0 rounded-[2px]"
|
|
292
|
+
style={{
|
|
293
|
+
backgroundColor: item.color,
|
|
294
|
+
}}
|
|
295
|
+
/>
|
|
296
|
+
)}
|
|
297
|
+
{itemConfig?.label}
|
|
298
|
+
</div>
|
|
299
|
+
)
|
|
300
|
+
})}
|
|
301
|
+
</div>
|
|
302
|
+
)
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Helper to extract item config from a payload.
|
|
306
|
+
function getPayloadConfigFromPayload(
|
|
307
|
+
config: ChartConfig,
|
|
308
|
+
payload: unknown,
|
|
309
|
+
key: string
|
|
310
|
+
) {
|
|
311
|
+
if (typeof payload !== "object" || payload === null) {
|
|
312
|
+
return undefined
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const payloadPayload =
|
|
316
|
+
"payload" in payload &&
|
|
317
|
+
typeof payload.payload === "object" &&
|
|
318
|
+
payload.payload !== null
|
|
319
|
+
? payload.payload
|
|
320
|
+
: undefined
|
|
321
|
+
|
|
322
|
+
let configLabelKey: string = key
|
|
323
|
+
|
|
324
|
+
if (
|
|
325
|
+
key in payload &&
|
|
326
|
+
typeof payload[key as keyof typeof payload] === "string"
|
|
327
|
+
) {
|
|
328
|
+
configLabelKey = payload[key as keyof typeof payload] as string
|
|
329
|
+
} else if (
|
|
330
|
+
payloadPayload &&
|
|
331
|
+
key in payloadPayload &&
|
|
332
|
+
typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
|
|
333
|
+
) {
|
|
334
|
+
configLabelKey = payloadPayload[
|
|
335
|
+
key as keyof typeof payloadPayload
|
|
336
|
+
] as string
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return configLabelKey in config
|
|
340
|
+
? config[configLabelKey]
|
|
341
|
+
: config[key as keyof typeof config]
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export {
|
|
345
|
+
ChartContainer,
|
|
346
|
+
ChartTooltip,
|
|
347
|
+
ChartTooltipContent,
|
|
348
|
+
ChartLegend,
|
|
349
|
+
ChartLegendContent,
|
|
350
|
+
ChartStyle,
|
|
351
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { Command as CommandPrimitive } from "cmdk"
|
|
3
|
+
import { SearchIcon } from "lucide-react"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
import {
|
|
7
|
+
Dialog,
|
|
8
|
+
DialogContent,
|
|
9
|
+
DialogDescription,
|
|
10
|
+
DialogHeader,
|
|
11
|
+
DialogTitle,
|
|
12
|
+
} from "@/components/ui/dialog"
|
|
13
|
+
|
|
14
|
+
function Command({
|
|
15
|
+
className,
|
|
16
|
+
...props
|
|
17
|
+
}: React.ComponentProps<typeof CommandPrimitive>) {
|
|
18
|
+
return (
|
|
19
|
+
<CommandPrimitive
|
|
20
|
+
data-slot="command"
|
|
21
|
+
className={cn(
|
|
22
|
+
"bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
|
|
23
|
+
className
|
|
24
|
+
)}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function CommandDialog({
|
|
31
|
+
title = "Command Palette",
|
|
32
|
+
description = "Search for a command to run...",
|
|
33
|
+
children,
|
|
34
|
+
...props
|
|
35
|
+
}: React.ComponentProps<typeof Dialog> & {
|
|
36
|
+
title?: string
|
|
37
|
+
description?: string
|
|
38
|
+
}) {
|
|
39
|
+
return (
|
|
40
|
+
<Dialog {...props}>
|
|
41
|
+
<DialogHeader className="sr-only">
|
|
42
|
+
<DialogTitle>{title}</DialogTitle>
|
|
43
|
+
<DialogDescription>{description}</DialogDescription>
|
|
44
|
+
</DialogHeader>
|
|
45
|
+
<DialogContent className="overflow-hidden p-0">
|
|
46
|
+
<Command className="[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
|
|
47
|
+
{children}
|
|
48
|
+
</Command>
|
|
49
|
+
</DialogContent>
|
|
50
|
+
</Dialog>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function CommandInput({
|
|
55
|
+
className,
|
|
56
|
+
...props
|
|
57
|
+
}: React.ComponentProps<typeof CommandPrimitive.Input>) {
|
|
58
|
+
return (
|
|
59
|
+
<div
|
|
60
|
+
data-slot="command-input-wrapper"
|
|
61
|
+
className="flex h-9 items-center gap-2 border-b px-3"
|
|
62
|
+
>
|
|
63
|
+
<SearchIcon className="size-4 shrink-0 opacity-50" />
|
|
64
|
+
<CommandPrimitive.Input
|
|
65
|
+
data-slot="command-input"
|
|
66
|
+
className={cn(
|
|
67
|
+
"placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
|
|
68
|
+
className
|
|
69
|
+
)}
|
|
70
|
+
{...props}
|
|
71
|
+
/>
|
|
72
|
+
</div>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function CommandList({
|
|
77
|
+
className,
|
|
78
|
+
...props
|
|
79
|
+
}: React.ComponentProps<typeof CommandPrimitive.List>) {
|
|
80
|
+
return (
|
|
81
|
+
<CommandPrimitive.List
|
|
82
|
+
data-slot="command-list"
|
|
83
|
+
className={cn(
|
|
84
|
+
"max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
|
|
85
|
+
className
|
|
86
|
+
)}
|
|
87
|
+
{...props}
|
|
88
|
+
/>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function CommandEmpty({
|
|
93
|
+
...props
|
|
94
|
+
}: React.ComponentProps<typeof CommandPrimitive.Empty>) {
|
|
95
|
+
return (
|
|
96
|
+
<CommandPrimitive.Empty
|
|
97
|
+
data-slot="command-empty"
|
|
98
|
+
className="py-6 text-center text-sm"
|
|
99
|
+
{...props}
|
|
100
|
+
/>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function CommandGroup({
|
|
105
|
+
className,
|
|
106
|
+
...props
|
|
107
|
+
}: React.ComponentProps<typeof CommandPrimitive.Group>) {
|
|
108
|
+
return (
|
|
109
|
+
<CommandPrimitive.Group
|
|
110
|
+
data-slot="command-group"
|
|
111
|
+
className={cn(
|
|
112
|
+
"text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
|
|
113
|
+
className
|
|
114
|
+
)}
|
|
115
|
+
{...props}
|
|
116
|
+
/>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function CommandSeparator({
|
|
121
|
+
className,
|
|
122
|
+
...props
|
|
123
|
+
}: React.ComponentProps<typeof CommandPrimitive.Separator>) {
|
|
124
|
+
return (
|
|
125
|
+
<CommandPrimitive.Separator
|
|
126
|
+
data-slot="command-separator"
|
|
127
|
+
className={cn("bg-border -mx-1 h-px", className)}
|
|
128
|
+
{...props}
|
|
129
|
+
/>
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function CommandItem({
|
|
134
|
+
className,
|
|
135
|
+
...props
|
|
136
|
+
}: React.ComponentProps<typeof CommandPrimitive.Item>) {
|
|
137
|
+
return (
|
|
138
|
+
<CommandPrimitive.Item
|
|
139
|
+
data-slot="command-item"
|
|
140
|
+
className={cn(
|
|
141
|
+
"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
142
|
+
className
|
|
143
|
+
)}
|
|
144
|
+
{...props}
|
|
145
|
+
/>
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function CommandShortcut({
|
|
150
|
+
className,
|
|
151
|
+
...props
|
|
152
|
+
}: React.ComponentProps<"span">) {
|
|
153
|
+
return (
|
|
154
|
+
<span
|
|
155
|
+
data-slot="command-shortcut"
|
|
156
|
+
className={cn(
|
|
157
|
+
"text-muted-foreground ml-auto text-xs tracking-widest",
|
|
158
|
+
className
|
|
159
|
+
)}
|
|
160
|
+
{...props}
|
|
161
|
+
/>
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export {
|
|
166
|
+
Command,
|
|
167
|
+
CommandDialog,
|
|
168
|
+
CommandInput,
|
|
169
|
+
CommandList,
|
|
170
|
+
CommandEmpty,
|
|
171
|
+
CommandGroup,
|
|
172
|
+
CommandItem,
|
|
173
|
+
CommandShortcut,
|
|
174
|
+
CommandSeparator,
|
|
175
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog"
|
|
5
|
+
import { XIcon } from "lucide-react"
|
|
6
|
+
|
|
7
|
+
import { cn } from "@/lib/utils"
|
|
8
|
+
|
|
9
|
+
function Dialog({
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
|
12
|
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function DialogTrigger({
|
|
16
|
+
...props
|
|
17
|
+
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
|
18
|
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function DialogPortal({
|
|
22
|
+
...props
|
|
23
|
+
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
|
24
|
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function DialogClose({
|
|
28
|
+
...props
|
|
29
|
+
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
|
30
|
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function DialogOverlay({
|
|
34
|
+
className,
|
|
35
|
+
...props
|
|
36
|
+
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
|
37
|
+
return (
|
|
38
|
+
<DialogPrimitive.Overlay
|
|
39
|
+
data-slot="dialog-overlay"
|
|
40
|
+
className={cn(
|
|
41
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
42
|
+
className
|
|
43
|
+
)}
|
|
44
|
+
{...props}
|
|
45
|
+
/>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function DialogContent({
|
|
50
|
+
className,
|
|
51
|
+
children,
|
|
52
|
+
...props
|
|
53
|
+
}: React.ComponentProps<typeof DialogPrimitive.Content>) {
|
|
54
|
+
return (
|
|
55
|
+
<DialogPortal data-slot="dialog-portal">
|
|
56
|
+
<DialogOverlay />
|
|
57
|
+
<DialogPrimitive.Content
|
|
58
|
+
data-slot="dialog-content"
|
|
59
|
+
className={cn(
|
|
60
|
+
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
|
|
61
|
+
className
|
|
62
|
+
)}
|
|
63
|
+
{...props}
|
|
64
|
+
>
|
|
65
|
+
{children}
|
|
66
|
+
<DialogPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4">
|
|
67
|
+
<XIcon />
|
|
68
|
+
<span className="sr-only">Close</span>
|
|
69
|
+
</DialogPrimitive.Close>
|
|
70
|
+
</DialogPrimitive.Content>
|
|
71
|
+
</DialogPortal>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
76
|
+
return (
|
|
77
|
+
<div
|
|
78
|
+
data-slot="dialog-header"
|
|
79
|
+
className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
|
|
80
|
+
{...props}
|
|
81
|
+
/>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
86
|
+
return (
|
|
87
|
+
<div
|
|
88
|
+
data-slot="dialog-footer"
|
|
89
|
+
className={cn(
|
|
90
|
+
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
91
|
+
className
|
|
92
|
+
)}
|
|
93
|
+
{...props}
|
|
94
|
+
/>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function DialogTitle({
|
|
99
|
+
className,
|
|
100
|
+
...props
|
|
101
|
+
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
|
102
|
+
return (
|
|
103
|
+
<DialogPrimitive.Title
|
|
104
|
+
data-slot="dialog-title"
|
|
105
|
+
className={cn("text-lg leading-none font-semibold", className)}
|
|
106
|
+
{...props}
|
|
107
|
+
/>
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function DialogDescription({
|
|
112
|
+
className,
|
|
113
|
+
...props
|
|
114
|
+
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
|
115
|
+
return (
|
|
116
|
+
<DialogPrimitive.Description
|
|
117
|
+
data-slot="dialog-description"
|
|
118
|
+
className={cn("text-muted-foreground text-sm", className)}
|
|
119
|
+
{...props}
|
|
120
|
+
/>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export {
|
|
125
|
+
Dialog,
|
|
126
|
+
DialogClose,
|
|
127
|
+
DialogContent,
|
|
128
|
+
DialogDescription,
|
|
129
|
+
DialogFooter,
|
|
130
|
+
DialogHeader,
|
|
131
|
+
DialogOverlay,
|
|
132
|
+
DialogPortal,
|
|
133
|
+
DialogTitle,
|
|
134
|
+
DialogTrigger,
|
|
135
|
+
}
|