{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "year-field",
  "type": "registry:ui",
  "title": "Year Field",
  "dependencies": [
    "@base-ui-next/react",
    "class-variance-authority"
  ],
  "registryDependencies": [
    "https://hamur.dev/r/react/utils.json",
    "https://hamur.dev/r/react/button.json"
  ],
  "files": [
    {
      "path": "react/year-field.tsx",
      "content": "'use client'\n\nimport type * as React from 'react' // base-ui-next/ui year-field@0.1.1\nimport { YearField as YearFieldPrimitive } from '@base-ui-next/react/year-field'\nimport type { VariantProps } from 'class-variance-authority'\nimport { cn } from '@/lib/utils'\nimport { buttonVariants } from '@/components/ui/button'\n\nconst yearFieldClassName =\n  'flex h-9 w-fit max-w-full min-w-0 items-center rounded-md border border-input px-2 shadow-xs transition-[color,box-shadow] outline-none data-focused:border-ring data-focused:ring-3 data-focused:ring-ring/50 data-invalid:border-destructive data-invalid:ring-3 data-invalid:ring-destructive/20 data-invalid:data-focused:border-destructive data-invalid:data-focused:ring-destructive/20 data-disabled:cursor-not-allowed data-disabled:opacity-50 dark:bg-input/30 dark:data-invalid:border-destructive/50 dark:data-invalid:ring-destructive/40 dark:data-invalid:data-focused:border-destructive/50 dark:data-invalid:data-focused:ring-destructive/40'\n\n/** The segments' row; a literal between them is a muted `span`. */\nconst yearFieldInputClassName = 'flex min-w-0 items-center'\n\n/** One editable segment is an `input` as wide as its digits; its placeholder is the dimmed text. */\nconst yearFieldSegmentClassName =\n  'h-7 w-[calc(2ch+--spacing(1))] min-w-0 rounded-sm bg-transparent px-0.5 py-0 text-center text-base tabular-nums caret-transparent outline-none selection:bg-transparent placeholder:text-muted-foreground read-only:cursor-default focus:bg-accent focus:text-accent-foreground focus:placeholder:text-accent-foreground disabled:cursor-not-allowed data-placeholder:text-muted-foreground data-invalid:text-destructive data-invalid:underline data-invalid:decoration-dashed data-invalid:underline-offset-4 data-[type=dayPeriod]:w-[calc(3ch+--spacing(1))] data-[type=literal]:w-auto data-[type=literal]:px-0 data-[type=literal]:text-muted-foreground data-[type=millisecond]:w-[calc(3ch+--spacing(1))] data-[type=year]:w-[calc(4ch+--spacing(1))] md:text-sm'\n\n/** A ghost icon button at the box's end, hidden while no segment has a value. */\nconst yearFieldClearClassName =\n  'ms-auto -me-1.5 size-6 text-muted-foreground data-empty:invisible'\n\ntype ButtonVariants = VariantProps<typeof buttonVariants>\n\n// lucide's icons, inline and hidden from assistive technology (10 · As built, BN-309).\nfunction SvgIcon({ children, ...props }: React.ComponentProps<'svg'>) {\n  return (\n    <svg\n      xmlns=\"http://www.w3.org/2000/svg\"\n      viewBox=\"0 0 24 24\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth=\"2\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      aria-hidden=\"true\"\n      {...props}\n    >\n      {children}\n    </svg>\n  )\n}\n\n// No shadcn item: one name per Base UI part (docs/design/log/month-year-picker.md).\nfunction YearField({ className, ...props }: YearFieldPrimitive.Root.Props) {\n  return (\n    <YearFieldPrimitive.Root\n      data-slot=\"year-field\"\n      className={cn(yearFieldClassName, className)}\n      {...props}\n    />\n  )\n}\n\n/** Without children it renders every segment, styled, in the locale's order. */\nfunction YearFieldInput({ className, children, ...props }: YearFieldPrimitive.Input.Props) {\n  return (\n    <YearFieldPrimitive.Input\n      data-slot=\"year-field-input\"\n      className={cn(yearFieldInputClassName, className)}\n      {...props}\n    >\n      {children ??\n        (({ segments }) =>\n          segments.map((segment) => <YearFieldSegment key={segment.index} segment={segment} />))}\n    </YearFieldPrimitive.Input>\n  )\n}\n\nfunction YearFieldSegment({ className, ...props }: YearFieldPrimitive.Segment.Props) {\n  return (\n    <YearFieldPrimitive.Segment\n      data-slot=\"year-field-segment\"\n      className={cn(yearFieldSegmentClassName, className)}\n      {...props}\n    />\n  )\n}\n\n/** A ghost icon button with lucide's X; Base UI names it \"Clear\" whatever its content. */\nfunction YearFieldClear({\n  className,\n  children,\n  variant = 'ghost',\n  size = 'icon-xs',\n  ...props\n}: YearFieldPrimitive.Clear.Props & ButtonVariants) {\n  return (\n    <YearFieldPrimitive.Clear\n      data-slot=\"year-field-clear\"\n      className={cn(buttonVariants({ variant, size }), yearFieldClearClassName, className)}\n      {...props}\n    >\n      {children ?? (\n        <SvgIcon>\n          <path d=\"M18 6 6 18\" />\n          <path d=\"m6 6 12 12\" />\n        </SvgIcon>\n      )}\n    </YearFieldPrimitive.Clear>\n  )\n}\n\nexport { YearField, YearFieldClear, YearFieldInput, YearFieldSegment }\n",
      "type": "registry:ui",
      "target": "@ui/year-field.tsx"
    }
  ],
  "meta": {
    "baseUiNext": {
      "version": "0.1.1",
      "hash": "565b8c43c9ccf0aff72e09f7e32acd3916782a2fd28396717e5ce6ead68c3466",
      "files": {
        "@ui/year-field.tsx": "3da47c79ef4ac7e4b746b30d90f164ab1bd665ba8b6f52d4d54b11561b6fbe19"
      }
    }
  }
}
