260703_01_FST: First Commit
This commit is contained in:
66
.tooling/components/ui/command.tsx
Normal file
66
.tooling/components/ui/command.tsx
Normal file
@@ -0,0 +1,66 @@
|
||||
import type { HTMLAttributes, InputHTMLAttributes } from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export interface CommandProps extends HTMLAttributes<HTMLDivElement> {
|
||||
shouldFilter?: boolean;
|
||||
}
|
||||
|
||||
export function Command({ className, shouldFilter, ...props }: CommandProps) {
|
||||
return <div data-should-filter={shouldFilter} className={cn(className)} {...props} />;
|
||||
}
|
||||
|
||||
export interface CommandInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "onValueChange"> {
|
||||
onValueChange?: (value: string) => void;
|
||||
}
|
||||
|
||||
export function CommandInput({ className, onValueChange, onChange, ...props }: CommandInputProps) {
|
||||
return (
|
||||
<input
|
||||
className={cn(className)}
|
||||
onChange={(e) => {
|
||||
onValueChange?.(e.target.value);
|
||||
onChange?.(e);
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function CommandList({ className, ...props }: HTMLAttributes<HTMLDivElement>) {
|
||||
return <div className={cn(className)} {...props} />;
|
||||
}
|
||||
|
||||
export function CommandEmpty({ className, ...props }: HTMLAttributes<HTMLDivElement>) {
|
||||
return <div className={cn(className)} {...props} />;
|
||||
}
|
||||
|
||||
export interface CommandGroupProps extends HTMLAttributes<HTMLDivElement> {
|
||||
heading?: string;
|
||||
}
|
||||
|
||||
export function CommandGroup({ className, heading, ...props }: CommandGroupProps) {
|
||||
return <div data-heading={heading} className={cn(className)} {...props} />;
|
||||
}
|
||||
|
||||
export interface CommandItemProps extends Omit<HTMLAttributes<HTMLDivElement>, "onSelect"> {
|
||||
value?: string;
|
||||
disabled?: boolean;
|
||||
onSelect?: (value: string) => void;
|
||||
}
|
||||
|
||||
export function CommandItem({ className, value, disabled, onSelect, ...props }: CommandItemProps) {
|
||||
return (
|
||||
<div
|
||||
role="option"
|
||||
data-value={value}
|
||||
aria-disabled={disabled}
|
||||
onClick={() => !disabled && onSelect?.(value ?? "")}
|
||||
className={cn(className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function CommandSeparator({ className, ...props }: HTMLAttributes<HTMLDivElement>) {
|
||||
return <div role="separator" className={cn(className)} {...props} />;
|
||||
}
|
||||
Reference in New Issue
Block a user