mirror of https://github.com/buster-so/buster.git
disabled state for select multiple
This commit is contained in:
parent
bc3014f3d4
commit
2b3aff1903
|
@ -116,7 +116,7 @@ const DatasetListContainer: React.FC<{
|
||||||
selectedDatasets: string[];
|
selectedDatasets: string[];
|
||||||
setSelectedDatasets: React.Dispatch<React.SetStateAction<string[]>>;
|
setSelectedDatasets: React.Dispatch<React.SetStateAction<string[]>>;
|
||||||
}> = React.memo(({ selectedDatasets, setSelectedDatasets }) => {
|
}> = React.memo(({ selectedDatasets, setSelectedDatasets }) => {
|
||||||
const { data: datasetsList, isLoading } = useGetDatasets();
|
const { data: datasetsList, isLoading, isFetched } = useGetDatasets();
|
||||||
|
|
||||||
const onChange = useMemoizedFn((v: string[]) => {
|
const onChange = useMemoizedFn((v: string[]) => {
|
||||||
setSelectedDatasets(v);
|
setSelectedDatasets(v);
|
||||||
|
@ -134,6 +134,7 @@ const DatasetListContainer: React.FC<{
|
||||||
return (
|
return (
|
||||||
<SelectMultiple
|
<SelectMultiple
|
||||||
items={selectOptions}
|
items={selectOptions}
|
||||||
|
disabled={!isFetched}
|
||||||
onSelect={onChange}
|
onSelect={onChange}
|
||||||
placeholder="Select a dataset"
|
placeholder="Select a dataset"
|
||||||
value={selectedDatasets}
|
value={selectedDatasets}
|
||||||
|
|
|
@ -16,6 +16,7 @@ interface SelectMultipleProps extends VariantProps<typeof selectVariants> {
|
||||||
className?: string;
|
className?: string;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
value: string[];
|
value: string[];
|
||||||
|
disabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SelectMultiple: React.FC<SelectMultipleProps> = React.memo(
|
export const SelectMultiple: React.FC<SelectMultipleProps> = React.memo(
|
||||||
|
@ -26,7 +27,8 @@ export const SelectMultiple: React.FC<SelectMultipleProps> = React.memo(
|
||||||
placeholder = 'Select items...',
|
placeholder = 'Select items...',
|
||||||
size = 'default',
|
size = 'default',
|
||||||
variant = 'default',
|
variant = 'default',
|
||||||
value
|
value,
|
||||||
|
disabled
|
||||||
}) => {
|
}) => {
|
||||||
const selectedRecord = useMemo(() => {
|
const selectedRecord = useMemo(() => {
|
||||||
return itemsProp.reduce<Record<string, boolean>>((acc, item) => {
|
return itemsProp.reduce<Record<string, boolean>>((acc, item) => {
|
||||||
|
@ -80,6 +82,7 @@ export const SelectMultiple: React.FC<SelectMultipleProps> = React.memo(
|
||||||
selectVariants({ variant, size }),
|
selectVariants({ variant, size }),
|
||||||
'relative overflow-hidden pr-0',
|
'relative overflow-hidden pr-0',
|
||||||
selectedItems.length > 0 && 'pl-1!',
|
selectedItems.length > 0 && 'pl-1!',
|
||||||
|
disabled && 'cursor-not-allowed opacity-80',
|
||||||
className
|
className
|
||||||
)}>
|
)}>
|
||||||
<div className="scrollbar-hide flex h-full flex-nowrap items-center gap-1 overflow-x-auto">
|
<div className="scrollbar-hide flex h-full flex-nowrap items-center gap-1 overflow-x-auto">
|
||||||
|
|
Loading…
Reference in New Issue