{"version":3,"sources":["../../src/components/tabs.tsx"],"sourcesContent":["import {\n  ComponentProps,\n  createContext,\n  forwardRef,\n  ForwardRefExoticComponent,\n  FunctionComponent,\n  JSXElementConstructor,\n  LegacyRef,\n  ReactElement,\n  ReactNode,\n  useContext,\n} from \"react\";\nimport * as TabsPrimitive from \"@radix-ui/react-tabs\";\nimport { clx } from \"../utils\";\nimport { cva } from \"class-variance-authority\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\n/*========================================================================================================================*/\n\ninterface TabsProps extends ComponentProps<typeof TabsPrimitive.Root> {\n  variant?: \"pill\" | \"enclosed\" | \"line\";\n  size?: \"small\" | \"medium\";\n}\n\nconst TabsContext = createContext<TabsProps>({\n  variant: \"line\",\n  size: \"small\",\n});\n\n/*========================================================================================================================*/\n\nconst Tabs: ForwardRefExoticComponent<TabsProps> = forwardRef((props, ref) => (\n  <TabsContext.Provider value={props}>\n    <TabsPrimitive.Root ref={ref} {...props} />\n  </TabsContext.Provider>\n));\nTabs.displayName = TabsPrimitive.Root.displayName;\n\n/*========================================================================================================================*/\n\nconst tabs_list_cva = cva(\n  \"relative flex flex-row items-center space-x-1 justify-start font-medium py-1\",\n  {\n    variants: {\n      variant: {\n        pill: \"bg-transparent rounded-full\",\n        enclosed: \"bg-bg-washed rounded-md\",\n        line: \"before:h-[1px] before:absolute before:-bottom-[9px] before:bg-otl-gray-200 before:left-0 before:right-0\",\n      },\n      width: {\n        full: \"w-full\",\n        fit: \"w-fit\",\n      },\n    },\n    defaultVariants: {\n      variant: \"line\",\n    },\n  },\n);\n\ninterface TabsListProps extends ComponentProps<typeof TabsPrimitive.List> {\n  width?: \"fit\" | \"full\";\n}\n\nconst TabsList: ForwardRefExoticComponent<TabsListProps> = forwardRef(\n  ({ className, width = \"fit\", ...props }, ref) => {\n    const { variant } = useContext(TabsContext);\n\n    return (\n      <TabsPrimitive.List\n        ref={ref}\n        className={tabs_list_cva({ variant, width, className })}\n        {...props}\n      />\n    );\n  },\n);\nTabsList.displayName = TabsPrimitive.List.displayName;\n\n/*========================================================================================================================*/\n\nconst tabs_trigger_cva = cva(\n  [\n    \"relative flex gap-1 items-center text-txt-black-500 hover:text-txt-black-900 data-[state=active]:text-txt-black-900 outline-none border border-transparent\",\n    \"focus:ring-2 focus:ring-fr-primary space\",\n  ],\n  {\n    variants: {\n      variant: {\n        pill: [\n          \"bg-transparent data-[state=active]:bg-bg-washed-active transition-colors rounded-full\",\n        ],\n        enclosed: [\n          \"data-[state=active]:bg-bg-dialog-active rounded-md transition-[border] data-[state=active]:border-otl-gray-200\",\n          // \"before:h-auto before:w-[1px] before:content-[''] before:absolute before:-left-1 before:bg-otl-gray-300 before:first-of-type:hidden\",\n        ],\n        line: \"rounded-md before:h-0.5 before:content-[''] before:absolute before:-bottom-2.5 before:left-0 before:right-0 before:data-[state=active]:bg-primary-600 before:transition-all before:duration-200\",\n      },\n      size: {\n        small: \"text-body-sm py-1.5 px-2.5\",\n        medium: \"text-body-md py-2 px-3\",\n      },\n    },\n    compoundVariants: [\n      {\n        variant: \"enclosed\",\n        size: \"small\",\n        className: \"before:py-2\",\n      },\n      {\n        variant: \"enclosed\",\n        size: \"medium\",\n        className: \"before:py-2.5\",\n      },\n      {\n        variant: \"line\",\n        size: \"small\",\n        className: \"before:mx-2.5\",\n      },\n      {\n        variant: \"line\",\n        size: \"medium\",\n        className: \"before:mx-3\",\n      },\n    ],\n    defaultVariants: {\n      variant: \"line\",\n      size: \"small\",\n    },\n  },\n);\n\nconst TabsTrigger: ForwardRefExoticComponent<\n  ComponentProps<typeof TabsPrimitive.TabsTrigger>\n> = forwardRef(({ className, ...props }, ref) => {\n  const { variant, size } = useContext(TabsContext);\n  return (\n    <TabsPrimitive.Trigger\n      ref={ref}\n      className={tabs_trigger_cva({ variant, size, className })}\n      {...props}\n    />\n  );\n});\nTabsTrigger.displayName = TabsPrimitive.Trigger.displayName;\n\n/*========================================================================================================================*/\n\nconst tab_icon_cva = cva(\n  \"block shrink-0 stroke-inherit text-inherit stroke-[1.5px]\",\n  {\n    variants: {\n      size: {\n        small: \"size-4\",\n        medium: \"size-5\",\n      },\n    },\n    defaultVariants: {\n      size: \"small\",\n    },\n  },\n);\n\ninterface TabsIconProps {\n  children: ReactElement<any, string | JSXElementConstructor<any>>;\n}\n\nconst TabsIcon: FunctionComponent<TabsIconProps> = ({ children }) => {\n  const { size } = useContext(TabsContext);\n\n  return <Slot className={clx(tab_icon_cva({ size }))}>{children}</Slot>;\n};\n\nTabsIcon.displayName = \"TabsIcon\";\n/*========================================================================================================================*/\n\ninterface TabsCounterProps extends ComponentProps<\"span\"> {\n  children: ReactNode;\n  ref?: LegacyRef<HTMLSpanElement>;\n}\n\nconst TabsCounter: ForwardRefExoticComponent<TabsCounterProps> = forwardRef(\n  ({ children, ...props }, ref) => {\n    const { size } = useContext(TabsContext);\n    return (\n      <span\n        ref={ref}\n        className={clx(\n          size === \"medium\" && \"text-body-md\",\n          size === \"small\" && \"text-body-sm\",\n          \"text-txt-primary\",\n        )}\n        {...props}\n      >\n        {children}\n      </span>\n    );\n  },\n);\n\nTabsCounter.displayName = \"TabsCounter\";\n\n/*========================================================================================================================*/\n\nconst TabsContent: ForwardRefExoticComponent<\n  ComponentProps<typeof TabsPrimitive.Content>\n> = forwardRef(({ className, ...props }, ref) => (\n  <TabsPrimitive.Content\n    ref={ref}\n    className={clx(\"text-txt-black-700\", className)}\n    {...props}\n  />\n));\n\nTabsContent.displayName = TabsPrimitive.Content.displayName;\n\n/*========================================================================================================================*/\n\nexport { Tabs, TabsIcon, TabsCounter, TabsList, TabsTrigger, TabsContent };\n"],"mappings":"kGAAA,OAEE,iBAAAA,EACA,cAAAC,EAOA,cAAAC,MACK,QACP,UAAYC,MAAmB,uBAE/B,OAAS,OAAAC,MAAW,2BACpB,OAAS,QAAAC,MAAY,uBAkBjB,cAAAC,MAAA,oBATJ,IAAMC,EAAcC,EAAyB,CAC3C,QAAS,OACT,KAAM,OACR,CAAC,EAIKC,EAA6CC,EAAW,CA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4B,UAAQ","names":["createContext","forwardRef","useContext","TabsPrimitive","cva","Slot","jsx","TabsContext","createContext","Tabs","forwardRef","props","ref","__spreadValues","tabs_list_cva","cva","TabsList","_a","_b","className","width","__objRest","variant","useContext","tabs_trigger_cva","TabsTrigger","size","tab_icon_cva","TabsIcon","children","Slot","clx","TabsCounter","__spreadProps","TabsContent"]}