mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-25 20:40:36 +03:00
B: Fix combo-box for release
This commit is contained in:
parent
017d8b3273
commit
3a54bf7108
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -21,6 +21,9 @@
|
|||
"changeProcessCWD": true
|
||||
}
|
||||
],
|
||||
"tailwindCSS.experimental.classRegex": [
|
||||
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"]
|
||||
],
|
||||
"stylelint.enable": true,
|
||||
"autopep8.args": [
|
||||
"--max-line-length",
|
||||
|
|
2
rsconcept/frontend/package-lock.json
generated
2
rsconcept/frontend/package-lock.json
generated
|
@ -11,10 +11,8 @@
|
|||
"@dagrejs/dagre": "^1.1.4",
|
||||
"@hookform/resolvers": "^5.0.1",
|
||||
"@lezer/lr": "^1.4.2",
|
||||
"@radix-ui/react-dialog": "^1.1.7",
|
||||
"@radix-ui/react-popover": "^1.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-devtools": "^5.72.2",
|
||||
"@tanstack/react-table": "^8.21.2",
|
||||
|
|
|
@ -17,10 +17,8 @@
|
|||
"@dagrejs/dagre": "^1.1.4",
|
||||
"@hookform/resolvers": "^5.0.1",
|
||||
"@lezer/lr": "^1.4.2",
|
||||
"@radix-ui/react-dialog": "^1.1.7",
|
||||
"@radix-ui/react-popover": "^1.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-devtools": "^5.72.2",
|
||||
"@tanstack/react-table": "^8.21.2",
|
||||
|
|
|
@ -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 };
|
|
@ -5,11 +5,9 @@ import { ChevronDownIcon } from 'lucide-react';
|
|||
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
import { MiniButton } from '../control';
|
||||
import { IconRemove } from '../icons';
|
||||
import { type Styling } from '../props';
|
||||
|
||||
import { Button } from './button';
|
||||
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from './command';
|
||||
import { Popover, PopoverContent, PopoverTrigger } from './popover';
|
||||
|
||||
|
@ -64,7 +62,7 @@ export function ComboBox<Option>({
|
|||
setOpen(false);
|
||||
}
|
||||
|
||||
function handleClear(event: React.MouseEvent<HTMLButtonElement>) {
|
||||
function handleClear(event: React.MouseEvent<SVGElement>) {
|
||||
event.stopPropagation();
|
||||
handleChangeValue(null);
|
||||
}
|
||||
|
@ -72,18 +70,19 @@ export function ComboBox<Option>({
|
|||
return (
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
<button
|
||||
id={id}
|
||||
ref={triggerRef}
|
||||
variant='ghost'
|
||||
role='combobox'
|
||||
aria-expanded={open}
|
||||
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',
|
||||
!noBorder && 'border',
|
||||
noBorder && 'rounded-md',
|
||||
!value && 'text-muted-foreground hover:text-muted-foreground',
|
||||
!value && 'text-muted-foreground',
|
||||
className
|
||||
)}
|
||||
style={style}
|
||||
|
@ -92,16 +91,14 @@ export function ComboBox<Option>({
|
|||
<span className='truncate'>{value ? labelValueFunc(value) : placeholder}</span>
|
||||
<ChevronDownIcon className={cn('text-muted-foreground', clearable && !!value && 'opacity-0')} />
|
||||
{clearable && !!value ? (
|
||||
<MiniButton
|
||||
noHover
|
||||
title='Очистить'
|
||||
aria-label='Очистить'
|
||||
className='absolute right-2 text-muted-foreground hover:text-warn-600'
|
||||
icon={<IconRemove size='1rem' />}
|
||||
<IconRemove
|
||||
tabIndex={-1}
|
||||
size='1rem'
|
||||
className='absolute pointer-events-auto right-3 text-muted-foreground hover:text-warn-600'
|
||||
onClick={handleClear}
|
||||
/>
|
||||
) : null}
|
||||
</Button>
|
||||
</button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent sideOffset={-1} className='p-0' style={{ width: popoverWidth }}>
|
||||
<Command>
|
||||
|
|
Loading…
Reference in New Issue
Block a user