Made tab family's options function optional

This commit is contained in:
thepaperpilot 2022-04-16 18:38:12 -05:00
parent 9c2dcddcbe
commit ba7f877581

View file

@ -92,7 +92,7 @@ export type GenericTabFamily = Replace<
export function createTabFamily<T extends TabFamilyOptions>( export function createTabFamily<T extends TabFamilyOptions>(
tabs: Record<string, () => TabButtonOptions>, tabs: Record<string, () => TabButtonOptions>,
optionsFunc: OptionsFunc<T, TabFamily<T>, BaseTabFamily> optionsFunc?: OptionsFunc<T, TabFamily<T>, BaseTabFamily>
): TabFamily<T> { ): TabFamily<T> {
if (Object.keys(tabs).length === 0) { if (Object.keys(tabs).length === 0) {
console.warn("Cannot create tab family with 0 tabs"); console.warn("Cannot create tab family with 0 tabs");
@ -100,7 +100,7 @@ export function createTabFamily<T extends TabFamilyOptions>(
} }
return createLazyProxy(persistent => { return createLazyProxy(persistent => {
const tabFamily = Object.assign(persistent, optionsFunc()); const tabFamily = Object.assign(persistent, optionsFunc?.());
tabFamily.id = getUniqueID("tabFamily-"); tabFamily.id = getUniqueID("tabFamily-");
tabFamily.type = TabFamilyType; tabFamily.type = TabFamilyType;