1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-23 22:25:56 -04:00

New: Improve 'Select All' in Library Import

Closes #7909
This commit is contained in:
Mark McDowall
2025-10-25 16:13:31 -07:00
parent 08f0a5a960
commit 910b85f37d
32 changed files with 666 additions and 439 deletions
+35
View File
@@ -0,0 +1,35 @@
import React, { createContext, PropsWithChildren } from 'react';
import useSelectStore, {
Id,
SelectStoreModel,
} from 'App/Select/useSelectStore';
interface SelectProviderProps<T extends SelectStoreModel<Id>>
extends PropsWithChildren {
items: Array<T>;
}
const SelectContext = createContext<
ReturnType<typeof useSelectStore> | undefined
>(undefined);
export function SelectProvider<T extends SelectStoreModel<Id>>({
items,
children,
}: SelectProviderProps<T>) {
const value = useSelectStore<T>(items);
return (
<SelectContext.Provider value={value}>{children}</SelectContext.Provider>
);
}
export function useSelect<T extends SelectStoreModel<Id>>() {
const context = React.useContext(SelectContext);
if (context === undefined) {
throw new Error('useSelect must be used within a SelectProvider');
}
return context as ReturnType<typeof useSelectStore<T>>;
}