{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "search-dialog-default",
  "title": "Default search dialog",
  "description": "DefaultSearchDialog: the search dialog for Fumadocs' built-in search server (createFromSource), with tag filters and default links. RootProvider loads it by default.",
  "dependencies": [
    "fumadocs-core@^16.17.8"
  ],
  "registryDependencies": [
    "@docscn/search-dialog",
    "@docscn/search-context"
  ],
  "files": [
    {
      "path": "registry/base/docs/components/dialog/search-default.tsx",
      "content": "// Adapted from Fumadocs UI (https://github.com/fuma-nama/fumadocs)\n// Copyright (c) 2023 Fuma, MIT License\n\"use client\";\n\nimport type { SortedResult } from \"fumadocs-core/search\";\nimport { useFetchSearch } from \"fumadocs-core/search/client\";\nimport { useOnChange } from \"fumadocs-core/utils/use-on-change\";\nimport { type ReactNode, useMemo, useState } from \"react\";\nimport { useI18n } from \"../../contexts/i18n\";\nimport type { SearchLink, TagItem } from \"../../contexts/search\";\nimport {\n  SearchDialog,\n  SearchDialogClose,\n  SearchDialogContent,\n  SearchDialogFooter,\n  SearchDialogHeader,\n  SearchDialogIcon,\n  SearchDialogInput,\n  SearchDialogList,\n  SearchDialogOverlay,\n  type SharedProps,\n  TagsList,\n  TagsListItem,\n} from \"./search\";\n\nexport interface DefaultSearchDialogProps extends SharedProps {\n  links?: SearchLink[];\n\n  defaultTag?: string;\n  tags?: TagItem[];\n\n  /**\n   * Search API URL\n   */\n  api?: string;\n\n  /**\n   * The debounced delay for performing a search.\n   */\n  delayMs?: number;\n\n  footer?: ReactNode;\n\n  /**\n   * Allow to clear tag filters\n   *\n   * @defaultValue false\n   */\n  allowClear?: boolean;\n}\n\nexport default function DefaultSearchDialog({\n  defaultTag,\n  tags = [],\n  api,\n  delayMs,\n  allowClear = false,\n  links = [],\n  footer,\n  ...props\n}: DefaultSearchDialogProps) {\n  const { locale } = useI18n();\n  const [tag, setTag] = useState(defaultTag);\n  const search = useFetchSearch({ api, locale, tag, delayMs });\n  const defaultItems = useMemo<SortedResult[] | null>(() => {\n    if (links.length === 0) return null;\n    return links.map(([name, link]) => ({\n      type: \"page\",\n      id: name,\n      content: name,\n      url: link,\n    }));\n  }, [links]);\n\n  useOnChange(defaultTag, (v) => {\n    setTag(v);\n  });\n\n  return (\n    <SearchDialog {...search} {...props}>\n      <SearchDialogOverlay />\n      <SearchDialogContent>\n        <SearchDialogHeader>\n          <SearchDialogIcon />\n          <SearchDialogInput />\n          <SearchDialogClose />\n        </SearchDialogHeader>\n        <SearchDialogList defaultItems={defaultItems} />\n        <SearchDialogFooter>\n          {tags.length > 0 && (\n            <TagsList tag={tag} onTagChange={setTag} allowClear={allowClear}>\n              {tags.map((tag) => (\n                <TagsListItem key={tag.value} value={tag.value}>\n                  {tag.name}\n                </TagsListItem>\n              ))}\n            </TagsList>\n          )}\n          {footer}\n        </SearchDialogFooter>\n      </SearchDialogContent>\n    </SearchDialog>\n  );\n}\n\nexport { DefaultSearchDialog };\n",
      "type": "registry:component",
      "target": "@components/docs/components/dialog/search-default.tsx"
    }
  ],
  "type": "registry:component"
}