B: Fix combo-box for release

This commit is contained in:
Ivan 2025-04-11 21:45:05 +03:00
parent e03f9e747e
commit e7ee9d9667
5 changed files with 14 additions and 67 deletions

View File

@ -21,6 +21,9 @@
"changeProcessCWD": true "changeProcessCWD": true
} }
], ],
"tailwindCSS.experimental.classRegex": [
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"]
],
"stylelint.enable": true, "stylelint.enable": true,
"autopep8.args": [ "autopep8.args": [
"--max-line-length", "--max-line-length",

View File

@ -11,10 +11,8 @@
"@dagrejs/dagre": "^1.1.4", "@dagrejs/dagre": "^1.1.4",
"@hookform/resolvers": "^5.0.1", "@hookform/resolvers": "^5.0.1",
"@lezer/lr": "^1.4.2", "@lezer/lr": "^1.4.2",
"@radix-ui/react-dialog": "^1.1.7",
"@radix-ui/react-popover": "^1.1.7", "@radix-ui/react-popover": "^1.1.7",
"@radix-ui/react-select": "^2.1.7", "@radix-ui/react-select": "^2.1.7",
"@radix-ui/react-slot": "^1.2.0",
"@tanstack/react-query": "^5.72.2", "@tanstack/react-query": "^5.72.2",
"@tanstack/react-query-devtools": "^5.72.2", "@tanstack/react-query-devtools": "^5.72.2",
"@tanstack/react-table": "^8.21.2", "@tanstack/react-table": "^8.21.2",

View File

@ -17,10 +17,8 @@
"@dagrejs/dagre": "^1.1.4", "@dagrejs/dagre": "^1.1.4",
"@hookform/resolvers": "^5.0.1", "@hookform/resolvers": "^5.0.1",
"@lezer/lr": "^1.4.2", "@lezer/lr": "^1.4.2",
"@radix-ui/react-dialog": "^1.1.7",
"@radix-ui/react-popover": "^1.1.7", "@radix-ui/react-popover": "^1.1.7",
"@radix-ui/react-select": "^2.1.7", "@radix-ui/react-select": "^2.1.7",
"@radix-ui/react-slot": "^1.2.0",
"@tanstack/react-query": "^5.72.2", "@tanstack/react-query": "^5.72.2",
"@tanstack/react-query-devtools": "^5.72.2", "@tanstack/react-query-devtools": "^5.72.2",
"@tanstack/react-table": "^8.21.2", "@tanstack/react-table": "^8.21.2",

View File

@ -1,49 +0,0 @@
import { Slot } from '@radix-ui/react-slot';
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '@/lib/utils';
const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 cursor-pointer disabled:cursor-auto whitespace-nowrap font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
{
variants: {
variant: {
default: 'bg-primary text-primary-foreground shadow-xs 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',
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',
ghost: 'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
link: 'text-primary underline-offset-4 hover:underline'
},
size: {
default: 'h-9 px-4 py-2 has-[>svg]:px-3',
sm: 'h-8 gap-1.5 px-3 has-[>svg]:px-2.5',
lg: 'h-10 px-6 has-[>svg]:px-4',
icon: 'size-9'
}
},
defaultVariants: {
variant: 'default',
size: 'default'
}
}
);
function Button({
className,
variant,
size,
asChild = false,
...props
}: React.ComponentProps<'button'> &
VariantProps<typeof buttonVariants> & {
asChild?: boolean;
}) {
const Comp = asChild ? Slot : 'button';
return <Comp data-slot='button' className={cn(buttonVariants({ variant, size, className }))} {...props} />;
}
export { Button, buttonVariants };

View File

@ -5,11 +5,9 @@ import { ChevronDownIcon } from 'lucide-react';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
import { MiniButton } from '../control';
import { IconRemove } from '../icons'; import { IconRemove } from '../icons';
import { type Styling } from '../props'; import { type Styling } from '../props';
import { Button } from './button';
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from './command'; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from './command';
import { Popover, PopoverContent, PopoverTrigger } from './popover'; import { Popover, PopoverContent, PopoverTrigger } from './popover';
@ -64,7 +62,7 @@ export function ComboBox<Option>({
setOpen(false); setOpen(false);
} }
function handleClear(event: React.MouseEvent<HTMLButtonElement>) { function handleClear(event: React.MouseEvent<SVGElement>) {
event.stopPropagation(); event.stopPropagation();
handleChangeValue(null); handleChangeValue(null);
} }
@ -72,18 +70,19 @@ export function ComboBox<Option>({
return ( return (
<Popover open={open} onOpenChange={setOpen}> <Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild> <PopoverTrigger asChild>
<Button <button
id={id} id={id}
ref={triggerRef} ref={triggerRef}
variant='ghost'
role='combobox' role='combobox'
aria-expanded={open} aria-expanded={open}
className={cn( className={cn(
'relative justify-between font-normal bg-input hover:bg-input', 'relative h-9',
'inline-flex gap-2 px-3 py-2 items-center justify-between bg-input cursor-pointer disabled:cursor-auto whitespace-nowrap outline-none focus-visible:border-ring focus-visible:ring-ring focus-visible:ring-[3px] aria-invalid:ring-destructive aria-invalid:border-destructive',
"[&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0",
open && 'cursor-auto', open && 'cursor-auto',
!noBorder && 'border', !noBorder && 'border',
noBorder && 'rounded-md', noBorder && 'rounded-md',
!value && 'text-muted-foreground hover:text-muted-foreground', !value && 'text-muted-foreground',
className className
)} )}
style={style} style={style}
@ -92,16 +91,14 @@ export function ComboBox<Option>({
<span className='truncate'>{value ? labelValueFunc(value) : placeholder}</span> <span className='truncate'>{value ? labelValueFunc(value) : placeholder}</span>
<ChevronDownIcon className={cn('text-muted-foreground', clearable && !!value && 'opacity-0')} /> <ChevronDownIcon className={cn('text-muted-foreground', clearable && !!value && 'opacity-0')} />
{clearable && !!value ? ( {clearable && !!value ? (
<MiniButton <IconRemove
noHover tabIndex={-1}
title='Очистить' size='1rem'
aria-label='Очистить' className='absolute pointer-events-auto right-3 text-muted-foreground hover:text-warn-600'
className='absolute right-2 text-muted-foreground hover:text-warn-600'
icon={<IconRemove size='1rem' />}
onClick={handleClear} onClick={handleClear}
/> />
) : null} ) : null}
</Button> </button>
</PopoverTrigger> </PopoverTrigger>
<PopoverContent sideOffset={-1} className='p-0' style={{ width: popoverWidth }}> <PopoverContent sideOffset={-1} className='p-0' style={{ width: popoverWidth }}>
<Command> <Command>