refactor: migrate frontend from shadcn/Tailwind to Mantine v9
Reescribe todos los componentes UI para usar Mantine v9 en lugar de shadcn/Tailwind. Elimina cn(), CVA, components.json, theme_provider custom y globals.css con Tailwind. Añade 25+ componentes nuevos (AppShell, AuthForm, DatePickerInput, Dropzone, etc.) y MantineProvider como wrapper estándar del sistema de temas. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { cn } from "../core/cn"
|
||||
import { ChevronDown } from "lucide-react"
|
||||
import { NativeSelect } from '@mantine/core'
|
||||
|
||||
export interface SimpleSelectOption {
|
||||
value: string
|
||||
@@ -23,69 +19,55 @@ interface SimpleSelectProps {
|
||||
options: SimpleSelectOptions
|
||||
placeholder?: string
|
||||
disabled?: boolean
|
||||
size?: "sm" | "default"
|
||||
size?: 'sm' | 'default'
|
||||
className?: string
|
||||
}
|
||||
|
||||
function isGrouped(
|
||||
options: SimpleSelectOptions,
|
||||
): options is SimpleSelectGroup[] {
|
||||
return options.length > 0 && "group" in options[0]
|
||||
return options.length > 0 && options[0] != null && 'group' in options[0]
|
||||
}
|
||||
|
||||
function toMantineData(options: SimpleSelectOptions, placeholder?: string) {
|
||||
const data: Array<{ value: string; label: string; disabled?: boolean } | { group: string; items: Array<{ value: string; label: string; disabled?: boolean }> }> = []
|
||||
|
||||
if (placeholder) {
|
||||
data.push({ value: '', label: placeholder, disabled: true })
|
||||
}
|
||||
|
||||
if (isGrouped(options)) {
|
||||
for (const g of options) {
|
||||
data.push({ group: g.group, items: g.items })
|
||||
}
|
||||
} else {
|
||||
for (const item of options) {
|
||||
data.push(item)
|
||||
}
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
function SimpleSelect({
|
||||
value,
|
||||
onValueChange,
|
||||
options,
|
||||
placeholder = "Select...",
|
||||
placeholder = 'Select...',
|
||||
disabled = false,
|
||||
size = "default",
|
||||
size = 'default',
|
||||
className,
|
||||
}: SimpleSelectProps) {
|
||||
return (
|
||||
<div className={cn("relative", className)}>
|
||||
<select
|
||||
value={value}
|
||||
onChange={(e) => onValueChange(e.target.value)}
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"flex w-full appearance-none items-center rounded-lg border border-input bg-transparent px-2.5 pr-8 text-sm transition-colors outline-none",
|
||||
"focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50",
|
||||
"disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
|
||||
size === "sm" ? "h-7 text-xs px-2" : "h-8 py-1",
|
||||
)}
|
||||
>
|
||||
{placeholder && !value && (
|
||||
<option value="" disabled>
|
||||
{placeholder}
|
||||
</option>
|
||||
)}
|
||||
{isGrouped(options)
|
||||
? options.map((g) => (
|
||||
<optgroup key={g.group} label={g.group}>
|
||||
{g.items.map((item) => (
|
||||
<option
|
||||
key={item.value}
|
||||
value={item.value}
|
||||
disabled={item.disabled}
|
||||
>
|
||||
{item.label}
|
||||
</option>
|
||||
))}
|
||||
</optgroup>
|
||||
))
|
||||
: (options as SimpleSelectOption[]).map((item) => (
|
||||
<option
|
||||
key={item.value}
|
||||
value={item.value}
|
||||
disabled={item.disabled}
|
||||
>
|
||||
{item.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<ChevronDown className="pointer-events-none absolute right-2 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" />
|
||||
</div>
|
||||
<NativeSelect
|
||||
value={value}
|
||||
onChange={(e) => onValueChange(e.currentTarget.value)}
|
||||
data={toMantineData(options, !value ? placeholder : undefined)}
|
||||
disabled={disabled}
|
||||
size={size === 'sm' ? 'xs' : 'sm'}
|
||||
className={className}
|
||||
styles={{ input: { cursor: 'pointer' } }}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user