@neovici/cosmoz-tabs 8.3.0 → 8.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/next/use-tabs.d.ts +7 -2
- package/src/next/use-tabs.js +5 -0
package/package.json
CHANGED
package/src/next/use-tabs.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export type RenderTabs<T extends Tab> = Pick<
|
|
|
31
31
|
|
|
32
32
|
export declare const useTabs: <T extends Tab, P extends Options>(
|
|
33
33
|
tabs: T[],
|
|
34
|
-
opts?: P
|
|
34
|
+
opts?: P,
|
|
35
35
|
) => Result<T>;
|
|
36
36
|
|
|
37
37
|
export interface RenderOptions<T extends RenderTab> {
|
|
@@ -41,5 +41,10 @@ export interface RenderOptions<T extends RenderTab> {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export declare const renderTabs: <T extends Tab>(
|
|
44
|
-
opts: RenderTabs<T
|
|
44
|
+
opts: RenderTabs<T>,
|
|
45
45
|
) => unknown;
|
|
46
|
+
|
|
47
|
+
export declare const renderActivated: <T extends Tab, R>(
|
|
48
|
+
opts: RenderTabs<T>,
|
|
49
|
+
render: (t: T & { isActive: boolean }) => R,
|
|
50
|
+
) => R[];
|
package/src/next/use-tabs.js
CHANGED
|
@@ -61,3 +61,8 @@ export const renderTabs = ({ tabs, active, onActivate }) =>
|
|
|
61
61
|
>${tab.content ?? title}</cosmoz-tab-next
|
|
62
62
|
>`;
|
|
63
63
|
});
|
|
64
|
+
|
|
65
|
+
export const renderActivated = ({ tabs, active, activated }, render) =>
|
|
66
|
+
tabs
|
|
67
|
+
.filter((t) => activated.includes(t.name))
|
|
68
|
+
.map((tab) => render({ ...tab, isActive: active.name === tab.name }));
|