{
  "name": "cai-ui-sdk-search-field",
  "type": "registry:ui",
  "description": "Canadian AI search field using Vercel UI SDK focus recovery and state",
  "dependencies": [
    "@ui-sdk/core@0.1.0-beta.1",
    "@ui-sdk/react@0.1.0-beta.1"
  ],
  "files": [
    {
      "path": "components/ui/cai-ui-sdk-search-field.tsx",
      "content": "\"use client\"\n\n// Opt-in example built from Vercel UI SDK behaviors.\n// Source: https://github.com/vercel-labs/ui (Apache-2.0).\n// Retain the existing Canadian AI theme; UI SDK owns interaction behavior.\nimport * as React from \"react\"\nimport { createFocusRecovery, definePrimitive } from \"@ui-sdk/core\"\nimport { createParts } from \"@ui-sdk/react/primitive\"\nimport { X } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst searchField = definePrimitive({\n  name: \"cai-ui-sdk-search-field\",\n  state: () => ({ value: \"\" }),\n  api: (context) => ({\n    set: (value: string) => context.store.set({ value }),\n    recovery: createFocusRecovery({\n      fallback: () => context.element(\"input\"),\n    }),\n  }),\n  slots: (slot) => ({\n    input: slot({\n      attrs: (state) => ({ value: state.value }),\n      on: {\n        input: (event, { api }) =>\n          api.set((event.target as HTMLInputElement).value),\n      },\n    }),\n    clear: slot({\n      present: (state) => state.value !== \"\",\n      attrs: () => ({ type: \"button\" }),\n      press: ({ api }) => api.set(\"\"),\n      bind: (element, part) => part.api.recovery.bind(element, part),\n    }),\n  }),\n})\n\nconst parts = createParts(searchField, { input: \"input\", clear: \"button\" })\n\ntype CaiUiSdkSearchFieldProps = React.ComponentProps<typeof parts.Root> & {\n  className?: string\n}\n\n/** A Canadian AI-styled search input with UI SDK state and focus recovery. */\nfunction CaiUiSdkSearchField({\n  className,\n  children,\n  ...props\n}: CaiUiSdkSearchFieldProps) {\n  return (\n    <parts.Root {...props}>\n      <div\n        data-slot=\"cai-ui-sdk-search-field\"\n        className={cn(\n          \"border-input bg-background text-foreground focus-within:border-ring focus-within:ring-ring/50 flex h-10 items-center gap-2 border px-3 text-sm transition-colors focus-within:ring-[3px]\",\n          className,\n        )}\n      >\n        {children}\n      </div>\n    </parts.Root>\n  )\n}\n\n/** Give this input an accessible name with aria-label or an associated label. */\nfunction CaiUiSdkSearchFieldInput({\n  className,\n  ...props\n}: React.ComponentProps<typeof parts.Input>) {\n  return (\n    <parts.Input\n      data-slot=\"cai-ui-sdk-search-field-input\"\n      type=\"search\"\n      className={cn(\n        \"placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent outline-none disabled:cursor-not-allowed disabled:opacity-50\",\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction CaiUiSdkSearchFieldClear({\n  className,\n  children,\n  ...props\n}: React.ComponentProps<typeof parts.Clear>) {\n  return (\n    <parts.Clear\n      data-slot=\"cai-ui-sdk-search-field-clear\"\n      type=\"button\"\n      aria-label=\"Clear search\"\n      className={cn(\n        \"text-muted-foreground hover:text-foreground focus-visible:ring-ring/50 flex size-7 shrink-0 items-center justify-center outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50\",\n        className,\n      )}\n      {...props}\n    >\n      {children ?? <X aria-hidden=\"true\" className=\"size-4\" />}\n    </parts.Clear>\n  )\n}\n\nexport {\n  CaiUiSdkSearchField,\n  CaiUiSdkSearchFieldInput,\n  CaiUiSdkSearchFieldClear,\n}\n",
      "type": "registry:ui"
    }
  ]
}