From 3dbca394bd4bfae4f481cfdc70d3724baa89e180 Mon Sep 17 00:00:00 2001 From: david Date: Tue, 14 Oct 2025 15:49:25 +0200 Subject: [PATCH] =?UTF-8?q?Actualizaci=C3=B3n=20shadcn/ui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/shadcn-ui/package.json | 7 +- .../shadcn-ui/src/components/button-group.tsx | 83 ++++++ packages/shadcn-ui/src/components/button.tsx | 9 +- packages/shadcn-ui/src/components/empty.tsx | 153 +++++------ packages/shadcn-ui/src/components/field.tsx | 242 ++++++++++++++++++ .../shadcn-ui/src/components/input-group.tsx | 170 ++++++++++++ packages/shadcn-ui/src/components/input.tsx | 10 +- packages/shadcn-ui/src/components/item.tsx | 193 ++++++++++++++ packages/shadcn-ui/src/components/kbd.tsx | 28 ++ packages/shadcn-ui/src/components/label.tsx | 19 +- .../shadcn-ui/src/components/separator.tsx | 17 +- packages/shadcn-ui/src/components/spinner.tsx | 16 ++ pnpm-lock.yaml | 2 +- 13 files changed, 843 insertions(+), 106 deletions(-) create mode 100644 packages/shadcn-ui/src/components/button-group.tsx create mode 100644 packages/shadcn-ui/src/components/field.tsx create mode 100644 packages/shadcn-ui/src/components/input-group.tsx create mode 100644 packages/shadcn-ui/src/components/item.tsx create mode 100644 packages/shadcn-ui/src/components/kbd.tsx create mode 100644 packages/shadcn-ui/src/components/spinner.tsx diff --git a/packages/shadcn-ui/package.json b/packages/shadcn-ui/package.json index ad0c1dcd..e8ee9268 100644 --- a/packages/shadcn-ui/package.json +++ b/packages/shadcn-ui/package.json @@ -10,7 +10,10 @@ "./components": "./src/components/index.tsx", "./components/*": "./src/components/*.tsx", "./lib/*": "./src/lib/*.ts", - "./hooks/*": ["./src/hooks/*.ts", "./src/hooks/*/index.ts"] + "./hooks/*": [ + "./src/hooks/*.ts", + "./src/hooks/*/index.ts" + ] }, "scripts": { "lint": "biome lint --fix", @@ -52,7 +55,7 @@ "@radix-ui/react-radio-group": "^1.3.6", "@radix-ui/react-scroll-area": "^1.2.8", "@radix-ui/react-select": "^2.2.4", - "@radix-ui/react-separator": "^1.1.6", + "@radix-ui/react-separator": "^1.1.7", "@radix-ui/react-slider": "^1.3.4", "@radix-ui/react-slot": "^1.2.3", "@radix-ui/react-switch": "^1.2.4", diff --git a/packages/shadcn-ui/src/components/button-group.tsx b/packages/shadcn-ui/src/components/button-group.tsx new file mode 100644 index 00000000..94bd11b9 --- /dev/null +++ b/packages/shadcn-ui/src/components/button-group.tsx @@ -0,0 +1,83 @@ +import { Slot } from "@radix-ui/react-slot" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@repo/shadcn-ui/lib/utils" +import { Separator } from "@repo/shadcn-ui/components/separator" + +const buttonGroupVariants = cva( + "flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2", + { + variants: { + orientation: { + horizontal: + "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none", + vertical: + "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none", + }, + }, + defaultVariants: { + orientation: "horizontal", + }, + } +) + +function ButtonGroup({ + className, + orientation, + ...props +}: React.ComponentProps<"div"> & VariantProps) { + return ( +
+ ) +} + +function ButtonGroupText({ + className, + asChild = false, + ...props +}: React.ComponentProps<"div"> & { + asChild?: boolean +}) { + const Comp = asChild ? Slot : "div" + + return ( + + ) +} + +function ButtonGroupSeparator({ + className, + orientation = "vertical", + ...props +}: React.ComponentProps) { + return ( + + ) +} + +export { + ButtonGroup, + ButtonGroupSeparator, + ButtonGroupText, + buttonGroupVariants, +} diff --git a/packages/shadcn-ui/src/components/button.tsx b/packages/shadcn-ui/src/components/button.tsx index fe7cecd7..5f0ae60e 100644 --- a/packages/shadcn-ui/src/components/button.tsx +++ b/packages/shadcn-ui/src/components/button.tsx @@ -9,14 +9,13 @@ const buttonVariants = cva( { variants: { variant: { - default: - "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90", + default: "bg-primary text-primary-foreground hover:bg-primary/90", destructive: - "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60", + "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60", outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50", secondary: - "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80", + "bg-secondary text-secondary-foreground hover:bg-secondary/80", ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50", link: "text-primary underline-offset-4 hover:underline", @@ -26,6 +25,8 @@ const buttonVariants = cva( sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5", lg: "h-10 rounded-md px-6 has-[>svg]:px-4", icon: "size-9", + "icon-sm": "size-8", + "icon-lg": "size-10", }, }, defaultVariants: { diff --git a/packages/shadcn-ui/src/components/empty.tsx b/packages/shadcn-ui/src/components/empty.tsx index 1b31b6ce..953d8818 100644 --- a/packages/shadcn-ui/src/components/empty.tsx +++ b/packages/shadcn-ui/src/components/empty.tsx @@ -1,101 +1,104 @@ -import { type VariantProps, cva } from "class-variance-authority" -import { cn } from '../lib/utils.ts' - +import { cva, type VariantProps } from "class-variance-authority" +import { cn } from "@repo/shadcn-ui/lib/utils" function Empty({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) + return ( +
+ ) } function EmptyHeader({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) + return ( +
+ ) } const emptyMediaVariants = cva( - "flex shrink-0 items-center justify-center mb-2 [&_svg]:pointer-events-none [&_svg]:shrink-0", - { - variants: { - variant: { - default: "bg-transparent", - icon: "bg-muted text-foreground flex size-10 shrink-0 items-center justify-center rounded-lg [&_svg:not([class*='size-'])]:size-6", - }, - }, - defaultVariants: { - variant: "default", - }, - } + "flex shrink-0 items-center justify-center mb-2 [&_svg]:pointer-events-none [&_svg]:shrink-0", + { + variants: { + variant: { + default: "bg-transparent", + icon: "bg-muted text-foreground flex size-10 shrink-0 items-center justify-center rounded-lg [&_svg:not([class*='size-'])]:size-6", + }, + }, + defaultVariants: { + variant: "default", + }, + } ) function EmptyMedia({ - className, - variant = "default", - ...props + className, + variant = "default", + ...props }: React.ComponentProps<"div"> & VariantProps) { - return ( -
- ) + return ( +
+ ) } function EmptyTitle({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) + return ( +
+ ) } function EmptyDescription({ className, ...props }: React.ComponentProps<"p">) { - return ( -
a:hover]:text-primary text-sm/relaxed [&>a]:underline [&>a]:underline-offset-4", - className - )} - {...props} - /> - ) + return ( +
a:hover]:text-primary text-sm/relaxed [&>a]:underline [&>a]:underline-offset-4", + className + )} + {...props} + /> + ) } function EmptyContent({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) + return ( +
+ ) } export { - Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle + Empty, + EmptyHeader, + EmptyTitle, + EmptyDescription, + EmptyContent, + EmptyMedia, } - diff --git a/packages/shadcn-ui/src/components/field.tsx b/packages/shadcn-ui/src/components/field.tsx new file mode 100644 index 00000000..10edb764 --- /dev/null +++ b/packages/shadcn-ui/src/components/field.tsx @@ -0,0 +1,242 @@ +import { useMemo } from "react" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@repo/shadcn-ui/lib/utils" +import { Label } from "@repo/shadcn-ui/components/label" +import { Separator } from "@repo/shadcn-ui/components/separator" + +function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) { + return ( +
[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3", + className + )} + {...props} + /> + ) +} + +function FieldLegend({ + className, + variant = "legend", + ...props +}: React.ComponentProps<"legend"> & { variant?: "legend" | "label" }) { + return ( + + ) +} + +function FieldGroup({ className, ...props }: React.ComponentProps<"div">) { + return ( +
[data-slot=field-group]]:gap-4", + className + )} + {...props} + /> + ) +} + +const fieldVariants = cva( + "group/field flex w-full gap-3 data-[invalid=true]:text-destructive", + { + variants: { + orientation: { + vertical: ["flex-col [&>*]:w-full [&>.sr-only]:w-auto"], + horizontal: [ + "flex-row items-center", + "[&>[data-slot=field-label]]:flex-auto", + "has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px", + ], + responsive: [ + "flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto", + "@md/field-group:[&>[data-slot=field-label]]:flex-auto", + "@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px", + ], + }, + }, + defaultVariants: { + orientation: "vertical", + }, + } +) + +function Field({ + className, + orientation = "vertical", + ...props +}: React.ComponentProps<"div"> & VariantProps) { + return ( +
+ ) +} + +function FieldContent({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function FieldLabel({ + className, + ...props +}: React.ComponentProps) { + return ( +