import { Tabs as Kobalte } from "@kobalte/core/tabs" import { Show, splitProps, type JSX } from "solid-js" import type { ComponentProps, ParentProps, Component } from "solid-js" import "./tabs-v2.css" export interface TabsV2Props extends ComponentProps { variant?: "normal" | "pill" | "settings" orientation?: "horizontal" | "vertical" } export interface TabsV2ListProps extends ComponentProps {} export interface TabsV2TriggerProps extends ComponentProps { onMiddleClick?: () => void /** Optional subtext shown beside the primary content (muted style) */ subtext?: JSX.Element | string } export interface TabsV2CloseButtonProps extends ComponentProps<"div"> {} export interface TabsV2ContentProps extends ComponentProps {} function TabsV2Root(props: TabsV2Props) { const [split, rest] = splitProps(props, ["class", "classList", "variant", "orientation"]) return ( ) } function TabsV2List(props: TabsV2ListProps) { const [split, rest] = splitProps(props, ["class", "classList"]) return ( ) } function TabsV2Trigger(props: ParentProps) { const [split, rest] = splitProps(props, ["class", "classList", "children", "onMiddleClick", "subtext"]) return (
{ if (e.button === 1 && split.onMiddleClick) { e.preventDefault() } }} onAuxClick={(e) => { if (e.button === 1 && split.onMiddleClick) { e.preventDefault() split.onMiddleClick() } }} > {split.children} {(subtext) => ( {subtext()} )}
) } function TabsV2CloseButton(props: TabsV2CloseButtonProps) { const [split, rest] = splitProps(props, ["class", "classList", "onClick"]) return (
{ e.preventDefault() e.stopPropagation() if (typeof split.onClick === "function") { split.onClick(e) } }} onMouseDown={(e) => { e.preventDefault() e.stopPropagation() }} >
) } function TabsV2Content(props: ParentProps) { const [split, rest] = splitProps(props, ["class", "classList", "children"]) return ( {split.children} ) } const TabsV2SectionTitle: Component = (props) => { return
{props.children}
} export const TabsV2 = Object.assign(TabsV2Root, { List: TabsV2List, Trigger: TabsV2Trigger, CloseButton: TabsV2CloseButton, Content: TabsV2Content, SectionTitle: TabsV2SectionTitle, })