{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "period-tabs",
  "type": "registry:component",
  "title": "Period selector",
  "description": "Give a report a clear time range without taking attention away from the numbers.",
  "categories": [
    "navigation"
  ],
  "dependencies": [
    "@radix-ui/react-tabs"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/registry/overtrue/period-tabs.tsx",
      "type": "registry:component",
      "target": "components/overtrue/period-tabs.tsx",
      "content": "/** Adapted from dashboardcn (MIT), copyright 2026 dashboardcn contributors.\n * Source: https://github.com/NoahGdev/dashboardcn/tree/b1ffacbca0f7a0be60135c8665b9e8c267205c48\n *\n * MIT License\n *\n * Copyright (c) 2026 dashboardcn contributors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n *\n * ---\n *\n * Portions of this project are derived from shadcn/ui and shadcn/registry-template\n * (https://github.com/shadcn-ui/ui), Copyright (c) 2023 shadcn, licensed under the\n * MIT License. The notice above applies to those portions as well.\n */\n\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"@/lib/utils\";\nimport { Tabs, TabsList, TabsTrigger } from \"./analytics-tabs\";\n\nexport interface PeriodOption {\n  value: string;\n  label: string;\n}\n\nexport const defaultPeriods: PeriodOption[] = [\n  { value: \"week\", label: \"Week\" },\n  { value: \"month\", label: \"Month\" },\n  { value: \"year\", label: \"Year\" },\n];\n\nexport interface PeriodTabsProps extends Omit<\n  React.ComponentProps<typeof Tabs>,\n  \"children\"\n> {\n  options?: PeriodOption[];\n  size?: \"sm\" | \"default\";\n  /** Slide a single pill between tabs instead of swapping backgrounds. */\n  animated?: boolean;\n}\n\ninterface IndicatorRect {\n  left: number;\n  top: number;\n  width: number;\n  height: number;\n}\n\n// The raised pill shared by the static active tab and the sliding indicator.\nconst pill =\n  \"bg-card shadow-[0_1px_2px_rgb(0_0_0/0.08),0_0_0_1px_rgb(0_0_0/0.04)] dark:bg-foreground/10 dark:shadow-[inset_0_1px_0_rgb(255_255_255/0.07),0_1px_2px_rgb(0_0_0/0.5),0_6px_18px_-10px_color-mix(in_oklab,var(--color-primary)_70%,transparent)]\";\n\n/** Small segmented control for switching a chart's time range. */\nfunction PeriodTabs({\n  options = defaultPeriods,\n  size = \"sm\",\n  animated = false,\n  className,\n  value,\n  defaultValue,\n  onValueChange,\n  ...props\n}: PeriodTabsProps) {\n  const listRef = React.useRef<HTMLDivElement>(null);\n  const [internalValue, setInternalValue] = React.useState(\n    defaultValue ?? options[0]?.value,\n  );\n  const active = value ?? internalValue;\n  const [rect, setRect] = React.useState<IndicatorRect | null>(null);\n  // The first placement snaps into place; later changes glide.\n  const [glide, setGlide] = React.useState(false);\n\n  const measure = React.useCallback(() => {\n    const list = listRef.current;\n    if (!list) return;\n    const trigger = list.querySelector<HTMLElement>('[data-state=\"active\"]');\n    if (!trigger) return;\n    const next = {\n      left: trigger.offsetLeft,\n      top: trigger.offsetTop,\n      width: trigger.offsetWidth,\n      height: trigger.offsetHeight,\n    };\n    setRect((current) =>\n      current &&\n      current.left === next.left &&\n      current.top === next.top &&\n      current.width === next.width &&\n      current.height === next.height\n        ? current\n        : next,\n    );\n  }, []);\n\n  React.useLayoutEffect(() => {\n    if (!animated) return;\n    measure();\n  }, [animated, active, options, size, measure]);\n\n  React.useEffect(() => {\n    if (!animated || !listRef.current) return;\n    const observer = new ResizeObserver(measure);\n    observer.observe(listRef.current);\n    const frame = requestAnimationFrame(() => setGlide(true));\n    return () => {\n      observer.disconnect();\n      cancelAnimationFrame(frame);\n    };\n  }, [animated, measure]);\n\n  return (\n    <Tabs\n      data-slot=\"period-tabs\"\n      className={cn(\"w-fit\", className)}\n      value={value}\n      defaultValue={defaultValue ?? options[0]?.value}\n      onValueChange={(next) => {\n        setInternalValue(next);\n        onValueChange?.(next);\n      }}\n      {...props}\n    >\n      <div ref={listRef}>\n        <TabsList\n          data-animated={animated || undefined}\n          className={cn(\n            \"relative isolate h-9 gap-0.5 rounded-xl bg-muted/60 p-1 text-muted-foreground shadow-[inset_0_0_0_1px_color-mix(in_oklab,var(--color-border)_70%,transparent)] dark:bg-muted/40\",\n            size === \"sm\" &&\n              \"h-8 rounded-[10px] p-1 group-data-[orientation=horizontal]/tabs:h-8\",\n          )}\n        >\n          {animated && rect ? (\n            <span\n              aria-hidden\n              data-slot=\"period-tabs-indicator\"\n              className={cn(\n                \"pointer-events-none absolute top-0 left-0 -z-10\",\n                size === \"sm\" ? \"rounded-md\" : \"rounded-lg\",\n                pill,\n                glide &&\n                  \"transition-[translate,width,height] duration-[350ms] ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none\",\n              )}\n              style={{\n                width: rect.width,\n                height: rect.height,\n                translate: `${rect.left}px ${rect.top}px`,\n              }}\n            />\n          ) : null}\n          {options.map((option) => (\n            <TabsTrigger\n              key={option.value}\n              value={option.value}\n              className={cn(\n                \"h-7 rounded-lg border-0 px-3 text-[13px] font-medium text-muted-foreground tabular-nums transition-[color,background-color,box-shadow] duration-150 hover:text-foreground focus-visible:outline-0 focus-visible:ring-2 focus-visible:ring-primary/30 motion-reduce:transition-none data-[state=active]:text-foreground\",\n                size === \"sm\" && \"h-6 rounded-md px-2.5 text-xs\",\n                animated\n                  ? \"data-[state=active]:bg-transparent data-[state=active]:shadow-none group-data-[variant=default]/tabs-list:data-[state=active]:shadow-none dark:data-[state=active]:border-transparent dark:data-[state=active]:bg-transparent\"\n                  : cn(\n                      \"data-[state=active]:bg-card data-[state=active]:shadow-[0_1px_2px_rgb(0_0_0/0.08),0_0_0_1px_rgb(0_0_0/0.04)]\",\n                      \"dark:data-[state=active]:border-transparent dark:data-[state=active]:bg-foreground/10 dark:data-[state=active]:shadow-[inset_0_1px_0_rgb(255_255_255/0.07),0_1px_2px_rgb(0_0_0/0.5),0_6px_18px_-10px_color-mix(in_oklab,var(--color-primary)_70%,transparent)]\",\n                    ),\n              )}\n            >\n              {option.label}\n            </TabsTrigger>\n          ))}\n        </TabsList>\n      </div>\n    </Tabs>\n  );\n}\n\nexport { PeriodTabs };\n"
    },
    {
      "path": "src/registry/overtrue/analytics-tabs.tsx",
      "type": "registry:component",
      "target": "components/overtrue/analytics-tabs.tsx",
      "content": "\"use client\";\nimport type { ComponentProps } from \"react\";\nimport * as TabsPrimitive from \"@radix-ui/react-tabs\";\nimport { cn } from \"@/lib/utils\";\n\nexport function Tabs({\n  className,\n  ...props\n}: ComponentProps<typeof TabsPrimitive.Root>) {\n  return (\n    <TabsPrimitive.Root\n      data-slot=\"tabs\"\n      className={cn(\"group/tabs flex flex-col gap-2\", className)}\n      {...props}\n    />\n  );\n}\nexport function TabsList({\n  className,\n  ...props\n}: ComponentProps<typeof TabsPrimitive.List>) {\n  return (\n    <TabsPrimitive.List\n      data-slot=\"tabs-list\"\n      data-variant=\"default\"\n      className={cn(\n        \"group/tabs-list inline-flex h-9 w-fit items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\nexport function TabsTrigger({\n  className,\n  ...props\n}: ComponentProps<typeof TabsPrimitive.Trigger>) {\n  return (\n    <TabsPrimitive.Trigger\n      data-slot=\"tabs-trigger\"\n      className={cn(\n        \"inline-flex h-7 items-center justify-center rounded-md px-3 text-sm font-medium whitespace-nowrap transition-colors focus-visible:outline-2 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-card data-[state=active]:text-foreground data-[state=active]:shadow-sm\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n"
    }
  ],
  "docs": "Documentation: https://ui.overtrue.xyz/components/period-tabs. Requires an initialized shadcn/ui project with Tailwind CSS v4."
}
