This commit is contained in:
Qing
2023-12-13 22:56:09 +08:00
parent 354a1280a4
commit 142aa64cc6
19 changed files with 360 additions and 181 deletions

View File

@@ -52,8 +52,12 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
const Comp = asChild ? Slot : "button"
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
className={cn(
buttonVariants({ variant, size, className }),
"outline-none cursor-default"
)}
ref={ref}
tabIndex={-1}
{...props}
/>
)

View File

@@ -37,7 +37,8 @@ const DialogContent = React.forwardRef<
ref={ref}
className={cn(
"fixed left-[50%] top-[50%] z-50 flex flex-col w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
className
className,
"outline-none"
)}
onCloseAutoFocus={(event) => event.preventDefault()}
{...props}

View File

@@ -71,8 +71,8 @@ const DropdownMenuContent = React.forwardRef<
"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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className
)}
{...props}
onCloseAutoFocus={(e) => e.preventDefault()}
{...props}
/>
</DropdownMenuPrimitive.Portal>
))

View File

@@ -1,12 +1,23 @@
import * as React from "react"
import { FocusEvent } from "react"
import { cn } from "@/lib/utils"
import { useStore } from "@/lib/states"
export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {}
const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, type, ...props }, ref) => {
const updateAppState = useStore((state) => state.updateAppState)
const handleOnFocus = (evt: FocusEvent<any>) => {
updateAppState({ disableShortCuts: true })
}
const handleOnBlur = (evt: FocusEvent<any>) => {
updateAppState({ disableShortCuts: false })
}
return (
<input
type={type}
@@ -16,6 +27,9 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
)}
ref={ref}
autoComplete="off"
tabIndex={-1}
onFocus={handleOnFocus}
onBlur={handleOnBlur}
{...props}
/>
)

View File

@@ -8,14 +8,19 @@ const labelVariants = cva(
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
)
interface LabelProps {
disabled?: boolean
}
const Label = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
VariantProps<typeof labelVariants>
>(({ className, ...props }, ref) => (
VariantProps<typeof labelVariants> &
LabelProps
>(({ className, disabled, ...props }, ref) => (
<LabelPrimitive.Root
ref={ref}
className={cn(labelVariants(), className)}
className={cn(labelVariants(), className, disabled ? "opacity-50" : "")}
{...props}
/>
))

View File

@@ -1,6 +1,5 @@
import * as React from "react"
import * as SheetPrimitive from "@radix-ui/react-dialog"
import { Cross2Icon } from "@radix-ui/react-icons"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"
@@ -29,7 +28,7 @@ const SheetOverlay = React.forwardRef<
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName
const sheetVariants = cva(
"fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
"fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:duration-300",
{
variants: {
side: {
@@ -63,10 +62,6 @@ const SheetContent = React.forwardRef<
{...props}
>
{children}
<SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
<Cross2Icon className="h-4 w-4" />
<span className="sr-only">Close</span>
</SheetPrimitive.Close>
</SheetPrimitive.Content>
</SheetPortal>
))