diff --git a/src/next/use-tabs.d.ts b/src/next/use-tabs.d.ts index d21daad..7a658ac 100644 --- a/src/next/use-tabs.d.ts +++ b/src/next/use-tabs.d.ts @@ -31,7 +31,7 @@ export type RenderTabs = Pick< export declare const useTabs: ( tabs: T[], - opts?: P + opts?: P, ) => Result; export interface RenderOptions { @@ -41,5 +41,10 @@ export interface RenderOptions { } export declare const renderTabs: ( - opts: RenderTabs + opts: RenderTabs, ) => unknown; + +export declare const renderActivated: ( + opts: RenderTabs, + render: (t: T & { isActive: boolean }) => R, +) => R[]; diff --git a/src/next/use-tabs.js b/src/next/use-tabs.js index 264383e..a2d710a 100644 --- a/src/next/use-tabs.js +++ b/src/next/use-tabs.js @@ -61,3 +61,8 @@ export const renderTabs = ({ tabs, active, onActivate }) => >${tab.content ?? title}`; }); + +export const renderActivated = ({ tabs, active, activated }, render) => + tabs + .filter((t) => activated.includes(t.name)) + .map((tab) => render({ ...tab, isActive: active.name === tab.name }));