Database diagrams editor that allows you to visualize and design your DB with a single query.
TypeScript databasedbdb-migrationeditorerdmariadbmssqlmysqlpostgresqlreactreact-flowschema-migrationssqlsqlitetypescriptvisualizationxyflow
fix console warning
Guy Ben-Aharon12d3a0e54e6b
diff --git a/src/components/combobox/combobox.tsx b/src/components/combobox/combobox.tsxindex 2a5fc17f..b2b5cbba 100644--- a/src/components/combobox/combobox.tsx+++ b/src/components/combobox/combobox.tsx@@ -37,158 +37,168 @@ interface ComboboxProps {popoverClassName?: string;}-export function Combobox({- options,- selected,- className,- placeholder,- mode = 'single',- emptyText,- onChange,- onCreate,- popoverClassName,-}: ComboboxProps) {- const [open, setOpen] = React.useState(false);- const [query, setQuery] = React.useState<string>('');+export const Combobox = React.forwardRef<HTMLDivElement, ComboboxProps>(+ (+ {+ options,+ selected,+ className,+ placeholder,+ mode = 'single',+ emptyText,+ onChange,+ onCreate,+ popoverClassName,+ },+ ref+ ) => {+ const [open, setOpen] = React.useState(false);+ const [query, setQuery] = React.useState<string>('');- return (- <div className={cn('block', className)}>- <Popover open={open} onOpenChange={setOpen}>- <PopoverTrigger asChild>- <Button- key={'combobox-trigger'}- type="button"- variant="outline"- role="combobox"- aria-expanded={open}- className="w-full justify-between h-auto"+ return (+ <div className={cn('block', className)} ref={ref}>+ <Popover open={open} onOpenChange={setOpen}>+ <PopoverTrigger asChild>+ <Button+ key={'combobox-trigger'}+ type="button"+ variant="outline"+ role="combobox"+ aria-expanded={open}+ className="w-full justify-between h-auto"+ >+ {selected && selected.length > 0 ? (+ <div className="relative mr-auto flex flex-grow flex-wrap items-center overflow-hidden">+ <span className="overflow-hidden whitespace-nowrap text-ellipsis">+ {mode === 'multiple' &&+ Array.isArray(selected)+ ? selected+ .map(+ (selectedValue: string) =>+ options.find(+ (item) =>+ item.value ===+ selectedValue+ )?.label+ )+ .join(', ')+ : mode === 'single' &&+ options.find(+ (item) =>+ item.value === selected+ )?.label}+ </span>+ </div>+ ) : (+ <div className="font-normal text-gray-500">+ {placeholder ?? 'Select Item...'}+ </div>+ )}+ <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />+ </Button>+ </PopoverTrigger>+ <PopoverContent+ className={cn('w-40 max-w-sm p-0', popoverClassName)}>- {selected && selected.length > 0 ? (- <div className="relative mr-auto flex flex-grow flex-wrap items-center overflow-hidden">- <span className="overflow-hidden whitespace-nowrap text-ellipsis">- {mode === 'multiple' &&- Array.isArray(selected)- ? selected- .map(- (selectedValue: string) =>- options.find(- (item) =>- item.value ===- selectedValue- )?.label- )- .join(', ')- : mode === 'single' &&- options.find(- (item) => item.value === selected- )?.label}- </span>- </div>- ) : (- <div className="font-normal text-gray-500">- {placeholder ?? 'Select Item...'}- </div>- )}- <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />- </Button>- </PopoverTrigger>- <PopoverContent- className={cn('w-40 max-w-sm p-0', popoverClassName)}- >- <Command- filter={(value, search) => {- if (value.includes(search)) return 1;- return 0;- }}- // shouldFilter={true}- >- <CommandInput- placeholder={placeholder ?? 'Cari Item...'}- value={query}- onValueChange={(value: string) => setQuery(value)}- />- {onCreate ? (- <CommandEmpty- onClick={() => {- if (onCreate) {- onCreate(query);- setQuery('');- }- }}- className="flex cursor-pointer items-center justify-center gap-1 italic"- >- <p>Create: </p>- <p className="block max-w-48 truncate font-semibold text-primary">- {query}- </p>- </CommandEmpty>- ) : (- <CommandEmpty>- {emptyText ?? 'No option found.'}- </CommandEmpty>- )}+ <Command+ filter={(value, search) => {+ if (value.includes(search)) return 1;+ return 0;+ }}+ // shouldFilter={true}+ >+ <CommandInput+ placeholder={placeholder ?? 'Cari Item...'}+ value={query}+ onValueChange={(value: string) =>+ setQuery(value)+ }+ />+ {onCreate ? (+ <CommandEmpty+ onClick={() => {+ if (onCreate) {+ onCreate(query);+ setQuery('');+ }+ }}+ className="flex cursor-pointer items-center justify-center gap-1 italic"+ >+ <p>Create: </p>+ <p className="block max-w-48 truncate font-semibold text-primary">+ {query}+ </p>+ </CommandEmpty>+ ) : (+ <CommandEmpty>+ {emptyText ?? 'No option found.'}+ </CommandEmpty>+ )}- <ScrollArea>- <div className="max-h-80">- <CommandGroup>- <CommandList>- {options.map((option) => (- <CommandItem- key={option.label}- value={option.label}- onSelect={() => {- if (onChange) {- if (- mode ===- 'multiple' &&- Array.isArray(- selected- )- ) {- onChange(- selected.includes(- option.value+ <ScrollArea>+ <div className="max-h-80">+ <CommandGroup>+ <CommandList>+ {options.map((option) => (+ <CommandItem+ key={option.label}+ value={option.label}+ onSelect={() => {+ if (onChange) {+ if (+ mode ===+ 'multiple' &&+ Array.isArray(+ selected)- ? selected.filter(- (- item- ) =>- item !==- option.value- )- : [- ...selected,- option.value,- ]- );- } else {- onChange(- option.value- );+ ) {+ onChange(+ selected.includes(+ option.value+ )+ ? selected.filter(+ (+ item+ ) =>+ item !==+ option.value+ )+ : [+ ...selected,+ option.value,+ ]+ );+ } else {+ onChange(+ option.value+ );+ }}- }- }}- >- <Check- className={cn(- 'mr-2 h-4 w-4',- selected.includes(- option.value- )- ? 'opacity-100'- : 'opacity-0'- )}- />- {option.label}- </CommandItem>- ))}- </CommandList>- </CommandGroup>- </div>- </ScrollArea>- </Command>- </PopoverContent>- </Popover>- </div>- );-}+ }}+ >+ <Check+ className={cn(+ 'mr-2 h-4 w-4',+ selected.includes(+ option.value+ )+ ? 'opacity-100'+ : 'opacity-0'+ )}+ />+ {option.label}+ </CommandItem>+ ))}+ </CommandList>+ </CommandGroup>+ </div>+ </ScrollArea>+ </Command>+ </PopoverContent>+ </Popover>+ </div>+ );+ }+);++Combobox.displayName = 'Combobox';diff --git a/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-field/table-field.tsx b/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-field/table-field.tsxindex 8e69f46e..d712b7a8 100644--- a/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-field/table-field.tsx+++ b/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-field/table-field.tsx@@ -56,20 +56,22 @@ export const TableField: React.FC<TableFieldProps> = ({}/><Tooltip>- <TooltipTrigger className="flex h-8 !w-5/12">- <Combobox- className="flex h-8 w-full"- mode="single"- options={dataFieldOptions}- placeholder="Type"- selected={field.type}- onChange={(value) =>- updateField({- type: value as FieldType,- })- }- emptyText="No types found."- />+ <TooltipTrigger className="flex h-8 !w-5/12" asChild>+ <span>+ <Combobox+ className="flex h-8 w-full"+ mode="single"+ options={dataFieldOptions}+ placeholder="Type"+ selected={field.type}+ onChange={(value) =>+ updateField({+ type: value as FieldType,+ })+ }+ emptyText="No types found."+ />+ </span></TooltipTrigger><TooltipContent>{field.type}</TooltipContent></Tooltip>