{"name":"otp-field","type":"registry:ui","files":[{"path":"otp-field.tsx","type":"registry:ui","content":"\"use client\"\n\nimport * as React from \"react\"\nimport { OTPField as OTPFieldPrimitive } from \"@base-ui/react/otp-field\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype OTPFieldSize = \"sm\" | \"default\" | \"lg\"\n\nconst OTPFieldSizeContext = React.createContext<OTPFieldSize>(\"default\")\n\nfunction OTPField({\n  className,\n  children,\n  length,\n  size = \"default\",\n  ...props\n}: OTPFieldPrimitive.Root.Props & {\n  size?: OTPFieldSize\n}) {\n  return (\n    <OTPFieldSizeContext.Provider value={size}>\n      <OTPFieldPrimitive.Root\n        data-slot=\"otp-field\"\n        data-size={size}\n        length={length}\n        className={cn(\n          \"flex w-fit items-center gap-[var(--hui-space-2)] data-disabled:cursor-not-allowed\",\n          className\n        )}\n        {...props}\n      >\n        {/* With no children, render one slot per character. The first slot\n            takes the field label; the rest name their position. */}\n        {children ??\n          Array.from({ length }, (_, index) => (\n            <OTPFieldInput\n              key={index}\n              aria-label={\n                index === 0 ? undefined : `Character ${index + 1} of ${length}`\n              }\n            />\n          ))}\n      </OTPFieldPrimitive.Root>\n    </OTPFieldSizeContext.Provider>\n  )\n}\n\nfunction OTPFieldInput({ className, ...props }: OTPFieldPrimitive.Input.Props) {\n  const size = React.useContext(OTPFieldSizeContext)\n\n  return (\n    <OTPFieldPrimitive.Input\n      data-hui=\"\"\n      data-slot=\"otp-field-input\"\n      className={cn(\n        // Each slot is a square Input: same edge, fill, focus ring, and\n        // invalid and disabled states, sized by the control height so it\n        // lines up with buttons and inputs in the same row.\n        \"relative m-0 box-border\",\n        // Base UI selects a slot's character on focus so typing replaces it.\n        // The selection stays, but it is painted transparent: the focus ring\n        // already marks the active slot, and a highlight block reads as noise.\n        // !important beats an app's unlayered ::selection color rule.\n        \"selection:bg-transparent! selection:text-[var(--hui-color-foreground-base-primary)]!\",\n        \"aspect-square size-[var(--hui-density-control-height,36px)] min-w-0 rounded-[var(--hui-radius-2)] border-[0.5px] border-[var(--hui-color-border-field,var(--hui-color-border-base-tertiary))] bg-[var(--hui-color-background-field,var(--hui-color-background-base-primary))] p-0 text-center text-[var(--hui-color-foreground-base-primary)] tabular-nums caret-[var(--hui-color-border-accent-emphasis)] outline-none [font-size:var(--hui-font-size-regular)] [font-weight:var(--hui-font-weight-medium)] [line-height:var(--hui-line-height-regular)] motion-safe:[transition:var(--hui-transition-interactive)]\",\n        \"placeholder:text-[var(--hui-color-foreground-base-tertiary)]\",\n        \"not-focus:not-data-disabled:not-data-invalid:not-aria-invalid:not-read-only:hover:border-[var(--hui-color-border-field-hover,var(--hui-color-border-field,var(--hui-color-border-base-tertiary)))]\",\n        \"focus:z-1 focus:border-[var(--hui-color-border-accent-emphasis)] focus:outline-2 focus:outline-solid focus:outline-transparent focus:shadow-[var(--hui-focus-ring-field)] focus:outline-offset-[var(--hui-focus-ring-offset-inset-border)]\",\n        \"data-invalid:border-[var(--hui-color-border-danger-emphasis)] data-invalid:focus:border-[var(--hui-color-border-danger-emphasis-hover)] data-invalid:focus:shadow-[var(--hui-focus-ring-field-danger)] aria-invalid:border-[var(--hui-color-border-danger-emphasis)] aria-invalid:focus:border-[var(--hui-color-border-danger-emphasis-hover)] aria-invalid:focus:shadow-[var(--hui-focus-ring-field-danger)]\",\n        \"read-only:bg-[var(--hui-color-background-base-secondary)] data-disabled:cursor-not-allowed data-disabled:border-[var(--hui-color-border-base-primary)] data-disabled:bg-[var(--hui-color-background-base-secondary)] data-disabled:text-[var(--hui-color-foreground-base-tertiary)]\",\n        \"forced-colors:border-[CanvasText] forced-colors:focus:outline-[Highlight]\",\n        size === \"sm\" &&\n          \"size-[var(--hui-control-height-sm,var(--hui-space-8))] [font-size:var(--hui-font-size-control,13px)] [line-height:var(--hui-line-height-control,16px)]\",\n        size === \"lg\" &&\n          \"size-[var(--hui-control-height-lg,44px)] rounded-[var(--hui-radius-3)] [font-size:var(--hui-font-size-large)] [line-height:var(--hui-line-height-large)]\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction OTPFieldGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"otp-field-group\"\n      className={cn(\n        // Joined slots share one hairline edge: inner corners square off and\n        // each slot overlaps its neighbour's border. The focused slot rises\n        // above its neighbours so its ring is never clipped.\n        \"flex items-center *:data-[slot=otp-field-input]:rounded-none *:data-[slot=otp-field-input]:not-first:-ms-[0.5px] *:data-[slot=otp-field-input]:first:rounded-s-[var(--hui-radius-2)] *:data-[slot=otp-field-input]:last:rounded-e-[var(--hui-radius-2)] in-data-[size=lg]:*:data-[slot=otp-field-input]:first:rounded-s-[var(--hui-radius-3)] in-data-[size=lg]:*:data-[slot=otp-field-input]:last:rounded-e-[var(--hui-radius-3)]\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction OTPFieldSeparator({\n  className,\n  children,\n  ...props\n}: React.ComponentProps<typeof OTPFieldPrimitive.Separator>) {\n  return (\n    <OTPFieldPrimitive.Separator\n      data-slot=\"otp-field-separator\"\n      orientation=\"vertical\"\n      className={cn(\n        \"flex shrink-0 items-center justify-center text-[var(--hui-color-foreground-base-tertiary)]\",\n        className\n      )}\n      {...props}\n    >\n      {children ?? (\n        <span\n          aria-hidden=\"true\"\n          className=\"block h-[1.5px] w-[var(--hui-space-3)] rounded-[var(--hui-radius-full)] bg-current forced-colors:bg-[CanvasText]\"\n        />\n      )}\n    </OTPFieldPrimitive.Separator>\n  )\n}\n\nexport {\n  OTPField,\n  OTPField as InputOTP,\n  OTPFieldInput,\n  OTPFieldInput as InputOTPSlot,\n  OTPFieldGroup,\n  OTPFieldGroup as InputOTPGroup,\n  OTPFieldSeparator,\n  OTPFieldSeparator as InputOTPSeparator,\n}\n","target":"components/ui/otp-field.tsx"}],"dependencies":["@base-ui/react"]}