This commit is contained in:
kolaflash
2025-12-31 17:31:21 +01:00
parent 71d0007f08
commit bc6a826ebc
3 changed files with 43 additions and 19 deletions
+13 -1
View File
@@ -23,6 +23,16 @@ export type ItemHandler = (list: Array<ListItem>, index: number) => void;
export type Direction = "default" | "asc" | "desc";
export function mapActiveItem(
items: Array<ListItem>,
index: number,
): Array<ListItem> {
return items.map((item, idx) => ({
...item,
isActive: idx === index,
}));
}
function useDirection(
signal: Signal<Direction>,
): [Accessor<Direction>, (forcedDirection?: Direction) => Direction] {
@@ -136,7 +146,9 @@ export const ItemList: Component<{
classList={{
active: item.isActive,
}}
onClick={() => props.handler(items(), index())}
onClick={() => {
props.handler(items(), index());
}}
>
{item.label}
</li>