{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "modal-12",
  "title": "Recent searches",
  "description": "A search with scoped filter pills and a history of recent searches you prune one by one or all at once",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/dialog.json",
    "https://ui.ndekocode.dev/r/dropdown-menu.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/input.json",
    "https://ui.ndekocode.dev/r/kbd.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/modal/modal-12.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  ArrowUpRightIcon,\n  ChevronDownIcon,\n  CircleDashedIcon,\n  FolderIcon,\n  HistoryIcon,\n  LayersIcon,\n  SearchIcon,\n  UserIcon,\n  XIcon,\n  type Icon,\n} from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport {\n  DropdownMenu,\n  DropdownMenuContent,\n  DropdownMenuRadioGroup,\n  DropdownMenuRadioItem,\n  DropdownMenuTrigger,\n} from '@/registry/ndeko/ui/dropdown-menu';\nimport { Input } from '@/registry/ndeko/ui/input';\nimport { Kbd } from '@/registry/ndeko/ui/kbd';\n\nimport {\n  ModalDescription,\n  ModalHeader,\n  ModalPreview,\n  ModalTitle,\n} from './_parts/modal-frame';\nimport { rowVariantsOf } from './_parts/motion';\nimport { Swap } from './_parts/swap';\n\ntype FilterKey = 'status' | 'assignee' | 'project';\n\ntype FilterOption = { value: string; label: string };\n\ntype Filters = Record<FilterKey, string | null>;\n\ntype RecentSearch = { id: string; text: string; scope: string };\n\ntype Suggestion = {\n  id: string;\n  label: string;\n  line: string;\n  color: string;\n  icon: Icon;\n};\n\nconst ANY = 'any';\n\nconst FILTERS: {\n  key: FilterKey;\n  label: string;\n  icon: Icon;\n  options: FilterOption[];\n}[] = [\n  {\n    key: 'status',\n    label: 'Status',\n    icon: CircleDashedIcon,\n    options: [\n      { value: 'todo', label: 'Todo' },\n      { value: 'in-progress', label: 'In progress' },\n      { value: 'in-review', label: 'In review' },\n      { value: 'done', label: 'Done' },\n    ],\n  },\n  {\n    key: 'assignee',\n    label: 'Assignee',\n    icon: UserIcon,\n    options: [\n      { value: 'amara', label: 'Amara' },\n      { value: 'lucas', label: 'Lucas' },\n      { value: 'priya', label: 'Priya' },\n      { value: 'mateo', label: 'Mateo' },\n    ],\n  },\n  {\n    key: 'project',\n    label: 'Project',\n    icon: FolderIcon,\n    options: [\n      { value: 'onboarding', label: 'Onboarding' },\n      { value: 'billing', label: 'Billing' },\n      { value: 'reports', label: 'Reports' },\n    ],\n  },\n];\n\nconst NO_FILTERS: Filters = { status: null, assignee: null, project: null };\n\nconst FIRST_RECENT: RecentSearch[] = [\n  { id: 'recent-1', text: 'invoice rounding', scope: 'Billing · Mateo' },\n  { id: 'recent-2', text: 'onboarding checklist', scope: 'In progress' },\n  { id: 'recent-3', text: 'timesheet export', scope: 'Reports' },\n  { id: 'recent-4', text: 'contrast audit', scope: 'Done · Amara' },\n];\n\nconst SUGGESTIONS: Suggestion[] = [\n  {\n    id: 'onboarding',\n    label: 'Onboarding',\n    line: 'Project · 14 open tasks',\n    color: 'var(--primary)',\n    icon: FolderIcon,\n  },\n  {\n    id: 'billing',\n    label: 'Billing',\n    line: 'Project · 6 open tasks',\n    color: 'var(--success)',\n    icon: FolderIcon,\n  },\n  {\n    id: 'my-week',\n    label: 'Due this week',\n    line: 'Saved view · yours',\n    color: 'var(--warning)',\n    icon: LayersIcon,\n  },\n];\n\nfunction labelOfOption(options: FilterOption[], value: string | null) {\n  const option = options.find((candidate) => candidate.value === value);\n  if (!option) {\n    return null;\n  }\n  return option.label;\n}\n\nfunction pillLabelOf(label: string, pickedLabel: string | null) {\n  if (!pickedLabel) {\n    return label;\n  }\n  return `${label}: ${pickedLabel}`;\n}\n\nfunction scopeOf(filters: Filters) {\n  const labels: string[] = [];\n  for (const filter of FILTERS) {\n    const picked = labelOfOption(filter.options, filters[filter.key]);\n    if (picked) {\n      labels.push(picked);\n    }\n  }\n  if (labels.length === 0) {\n    return 'Everywhere';\n  }\n  return labels.join(' · ');\n}\n\nfunction recentCountLabelOf(count: number) {\n  if (count === 0) {\n    return 'Nothing kept on this device';\n  }\n  if (count === 1) {\n    return '1 search kept on this device';\n  }\n  return `${count} searches kept on this device`;\n}\n\nfunction FilterPill({\n  label,\n  icon: FilterGlyph,\n  options,\n  value,\n  onChange,\n}: {\n  label: string;\n  icon: Icon;\n  options: FilterOption[];\n  value: string | null;\n  onChange: (value: string | null) => void;\n}) {\n  const pickedLabel = labelOfOption(options, value);\n  const isSet = pickedLabel !== null;\n  const pillLabel = pillLabelOf(label, pickedLabel);\n  const menuValue = value ?? ANY;\n\n  function changeValue(nextValue: unknown) {\n    const option = options.find((candidate) => candidate.value === nextValue);\n    if (option) {\n      onChange(option.value);\n      return;\n    }\n    onChange(null);\n  }\n\n  return (\n    <DropdownMenu>\n      <DropdownMenuTrigger\n        render={\n          <Button\n            variant='outline'\n            size='sm'\n            className={cn(isSet && 'text-primary-ink')}\n          />\n        }\n      >\n        <FilterGlyph />\n        <AnimatedSize axis='width' as='span'>\n          <Swap swapKey={pillLabel} kind='label'>\n            {pillLabel}\n          </Swap>\n        </AnimatedSize>\n        <ChevronDownIcon className='text-muted-foreground size-3.5' />\n      </DropdownMenuTrigger>\n      <DropdownMenuContent className='w-48'>\n        <DropdownMenuRadioGroup value={menuValue} onValueChange={changeValue}>\n          <DropdownMenuRadioItem value={ANY}>\n            {`Any ${label.toLowerCase()}`}\n          </DropdownMenuRadioItem>\n          {options.map((option) => (\n            <DropdownMenuRadioItem key={option.value} value={option.value}>\n              {option.label}\n            </DropdownMenuRadioItem>\n          ))}\n        </DropdownMenuRadioGroup>\n      </DropdownMenuContent>\n    </DropdownMenu>\n  );\n}\n\nfunction RecentRow({\n  search,\n  onRun,\n  onRemove,\n}: {\n  search: RecentSearch;\n  onRun: (text: string) => void;\n  onRemove: (searchId: string) => void;\n}) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = rowVariantsOf(shouldReduceMotion);\n\n  function runSearch() {\n    onRun(search.text);\n  }\n\n  function remove() {\n    onRemove(search.id);\n  }\n\n  return (\n    <motion.li\n      variants={variants}\n      initial='hidden'\n      animate='shown'\n      exit='hidden'\n    >\n      <div className='hover:bg-foreground/[0.03] flex h-9 items-center gap-1 rounded-md pr-1'>\n        <button\n          type='button'\n          onClick={runSearch}\n          className='focus-visible:ring-ring/25 flex h-full min-w-0 flex-1 cursor-pointer items-center gap-2.5 rounded-md px-2 text-left outline-none focus-visible:ring-[3px]'\n        >\n          <HistoryIcon className='text-muted-foreground size-4 shrink-0' />\n          <span className='truncate text-[13px]'>{search.text}</span>\n          <span className='text-muted-foreground shrink-0 text-xs'>\n            {search.scope}\n          </span>\n        </button>\n        <Button\n          variant='ghost'\n          size='icon-sm'\n          aria-label={`Remove “${search.text}” from recent searches`}\n          onClick={remove}\n          className='text-muted-foreground'\n        >\n          <XIcon />\n        </Button>\n      </div>\n    </motion.li>\n  );\n}\n\nfunction SuggestionRow({ suggestion }: { suggestion: Suggestion }) {\n  const SuggestionGlyph = suggestion.icon;\n  const gemStyle = { '--gem': suggestion.color } as React.CSSProperties;\n\n  return (\n    <li>\n      <a\n        href='#'\n        className='hover:bg-foreground/[0.03] focus-visible:ring-ring/25 flex h-10 items-center gap-2.5 rounded-md px-2 outline-none focus-visible:ring-[3px]'\n      >\n        <span\n          style={gemStyle}\n          className='gem-plate flex size-5 shrink-0 items-center justify-center rounded-[5px]'\n        >\n          <SuggestionGlyph className='size-3' strokeWidth={2.25} />\n        </span>\n        <span className='flex min-w-0 flex-1 items-baseline gap-2'>\n          <span className='truncate text-[13px] font-medium'>\n            {suggestion.label}\n          </span>\n          <span className='text-muted-foreground truncate text-xs'>\n            {suggestion.line}\n          </span>\n        </span>\n        <ArrowUpRightIcon className='text-muted-foreground size-4 shrink-0' />\n      </a>\n    </li>\n  );\n}\n\nfunction RecentSearchesContent() {\n  const [query, setQuery] = useState('');\n  const [filters, setFilters] = useState<Filters>({\n    ...NO_FILTERS,\n    project: 'billing',\n  });\n  const [recent, setRecent] = useState<RecentSearch[]>(FIRST_RECENT);\n  const [nextId, setNextId] = useState(FIRST_RECENT.length + 1);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowVariants = rowVariantsOf(shouldReduceMotion);\n  const typed = query.trim();\n  const hasQuery = typed.length > 0;\n  const hasRecent = recent.length > 0;\n  const scope = scopeOf(filters);\n  const matchingRecent = recent.filter((search) =>\n    search.text.includes(typed.toLowerCase())\n  );\n  const hasMatchingRecent = matchingRecent.length > 0;\n  const showsMatchingRecent = hasQuery && hasMatchingRecent;\n\n  function changeQuery(event: React.ChangeEvent<HTMLInputElement>) {\n    setQuery(event.target.value);\n  }\n\n  function changeFilter(key: FilterKey, value: string | null) {\n    setFilters((previous) => ({ ...previous, [key]: value }));\n  }\n\n  function keepSearch() {\n    if (!hasQuery) {\n      return;\n    }\n    const text = typed.toLowerCase();\n    const kept: RecentSearch = { id: `recent-${nextId}`, text, scope };\n    setRecent((previous) => {\n      const others = previous.filter((search) => search.text !== text);\n      return [kept, ...others];\n    });\n    setNextId((previous) => previous + 1);\n    setQuery('');\n  }\n\n  function handleKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {\n    if (event.key === 'Enter') {\n      event.preventDefault();\n      keepSearch();\n    }\n  }\n\n  function removeSearch(searchId: string) {\n    setRecent((previous) =>\n      previous.filter((search) => search.id !== searchId)\n    );\n  }\n\n  function clearRecent() {\n    setRecent([]);\n  }\n\n  return (\n    <>\n      <ModalHeader>\n        <ModalTitle>Search</ModalTitle>\n        <ModalDescription>\n          Tasks, people and projects of the Lattice workspace\n        </ModalDescription>\n      </ModalHeader>\n      <div className='flex flex-col gap-2'>\n        <div className='relative'>\n          <SearchIcon className='text-muted-foreground pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2' />\n          <Input\n            type='search'\n            value={query}\n            placeholder='Search tasks, people and projects'\n            aria-label='Search the workspace'\n            onChange={changeQuery}\n            onKeyDown={handleKeyDown}\n            className='pl-8'\n          />\n        </div>\n        <div className='flex flex-wrap items-center gap-1.5'>\n          {FILTERS.map((filter) => {\n            function changeThisFilter(value: string | null) {\n              changeFilter(filter.key, value);\n            }\n\n            return (\n              <FilterPill\n                key={filter.key}\n                label={filter.label}\n                icon={filter.icon}\n                options={filter.options}\n                value={filters[filter.key]}\n                onChange={changeThisFilter}\n              />\n            );\n          })}\n        </div>\n      </div>\n      {hasQuery && (\n        <section aria-label='Search' className='-mx-2 flex flex-col gap-0.5'>\n          <button\n            type='button'\n            onClick={keepSearch}\n            className='bg-foreground/[0.04] focus-visible:ring-ring/25 flex h-9 cursor-pointer items-center gap-2.5 rounded-md px-2 text-left outline-none focus-visible:ring-[3px]'\n          >\n            <SearchIcon className='text-muted-foreground size-4 shrink-0' />\n            <span className='truncate text-[13px]'>\n              {`Search for “${typed}”`}\n            </span>\n            <span className='text-muted-foreground shrink-0 text-xs'>\n              {scope}\n            </span>\n          </button>\n          {showsMatchingRecent && (\n            <ul className='flex flex-col'>\n              {matchingRecent.map((search) => (\n                <li key={search.id}>\n                  <div className='text-muted-foreground flex h-9 items-center gap-2.5 px-2 text-[13px]'>\n                    <HistoryIcon className='size-4 shrink-0' />\n                    <span className='text-foreground truncate'>\n                      {search.text}\n                    </span>\n                    <span className='shrink-0 text-xs'>{search.scope}</span>\n                  </div>\n                </li>\n              ))}\n            </ul>\n          )}\n        </section>\n      )}\n      {!hasQuery && (\n        <section aria-label='Recent searches' className='flex flex-col gap-1'>\n          <div className='flex h-7 items-center gap-2'>\n            <h3 className='text-muted-foreground text-xs font-medium'>\n              Recent\n            </h3>\n            {hasRecent && (\n              <Button\n                variant='ghost'\n                size='sm'\n                onClick={clearRecent}\n                className='text-muted-foreground ml-auto'\n              >\n                Clear all\n              </Button>\n            )}\n          </div>\n          <ul className='-mx-2 flex flex-col'>\n            <AnimatePresence initial={false}>\n              {recent.map((search) => (\n                <RecentRow\n                  key={search.id}\n                  search={search}\n                  onRun={setQuery}\n                  onRemove={removeSearch}\n                />\n              ))}\n            </AnimatePresence>\n          </ul>\n          <AnimatePresence initial={false}>\n            {!hasRecent && (\n              <motion.p\n                key='empty'\n                variants={rowVariants}\n                initial='hidden'\n                animate='shown'\n                exit='hidden'\n                className='text-muted-foreground text-[13px]'\n              >\n                No recent searches. What you search for with Enter shows up here\n              </motion.p>\n            )}\n          </AnimatePresence>\n        </section>\n      )}\n      {!hasQuery && (\n        <section aria-label='Suggested' className='flex flex-col gap-1'>\n          <h3 className='text-muted-foreground flex h-7 items-center text-xs font-medium'>\n            Suggested\n          </h3>\n          <ul className='-mx-2 flex flex-col'>\n            {SUGGESTIONS.map((suggestion) => (\n              <SuggestionRow key={suggestion.id} suggestion={suggestion} />\n            ))}\n          </ul>\n        </section>\n      )}\n      <div className='text-muted-foreground flex flex-wrap items-center gap-x-4 gap-y-2 text-xs'>\n        <span className='flex items-center gap-1.5'>\n          <Kbd>Enter</Kbd>\n          to search and keep it in Recent\n        </span>\n        <span className='ml-auto'>{recentCountLabelOf(recent.length)}</span>\n      </div>\n    </>\n  );\n}\n\nexport default function Modal12() {\n  return (\n    <ModalPreview triggerLabel='Open search' size='md'>\n      <RecentSearchesContent />\n    </ModalPreview>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/modal/modal-12.tsx"
    },
    {
      "path": "registry/ndeko/components/modal/_parts/modal-frame.tsx",
      "content": "'use client';\n\nimport { createContext, useContext } from 'react';\n\nimport { SquareArrowOutUpRightIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button, type ButtonProps } from '@/registry/ndeko/ui/button';\nimport {\n  Dialog,\n  DialogClose,\n  DialogContent,\n  DialogDescription,\n  DialogTitle,\n  DialogTrigger,\n} from '@/registry/ndeko/ui/dialog';\n\n/** Where a modal's content is drawn: open in the page as a preview, or inside the real dialog. */\nexport type ModalHost = 'preview' | 'dialog';\n\nconst ModalHostContext = createContext<ModalHost>('preview');\n\nexport function useModalHost() {\n  return useContext(ModalHostContext);\n}\n\nexport type ModalSize = 'sm' | 'md' | 'lg' | 'xl';\n\nconst SIZE_CLASS: Record<ModalSize, string> = {\n  sm: 'max-w-sm',\n  md: 'max-w-md',\n  lg: 'max-w-lg',\n  xl: 'max-w-[44rem]',\n};\n\nconst TITLE = 'text-lg leading-tight font-semibold text-balance';\n\nconst DESCRIPTION = 'text-muted-foreground text-[13px]';\n\nconst BODY = 'flex flex-col gap-4';\n\ntype ModalTextProps = { className?: string; children: React.ReactNode };\n\nexport function ModalTitle({ className, children }: ModalTextProps) {\n  const host = useModalHost();\n  if (host === 'dialog') {\n    return <DialogTitle className={className}>{children}</DialogTitle>;\n  }\n  return <h2 className={cn(TITLE, className)}>{children}</h2>;\n}\n\nexport function ModalDescription({ className, children }: ModalTextProps) {\n  const host = useModalHost();\n  if (host === 'dialog') {\n    return (\n      <DialogDescription className={className}>{children}</DialogDescription>\n    );\n  }\n  return <p className={cn(DESCRIPTION, className)}>{children}</p>;\n}\n\n/** Leaves room for the dialog's close button, so the preview and the dialog lay out the same. */\nexport function ModalHeader({\n  className,\n  ...props\n}: React.ComponentProps<'div'>) {\n  return (\n    <div className={cn('flex flex-col gap-1.5 pr-8', className)} {...props} />\n  );\n}\n\nexport function ModalFooter({\n  className,\n  ...props\n}: React.ComponentProps<'div'>) {\n  return (\n    <div\n      className={cn(\n        'flex flex-col-reverse gap-2 sm:flex-row sm:items-center sm:justify-end',\n        className\n      )}\n      {...props}\n    />\n  );\n}\n\n/** Closes the dialog. In the preview it stays a plain button that runs its own action, if any. */\nexport function ModalCloseButton({ children, ...props }: ButtonProps) {\n  const host = useModalHost();\n  if (host === 'dialog') {\n    return <DialogClose render={<Button {...props} />}>{children}</DialogClose>;\n  }\n  return <Button {...props}>{children}</Button>;\n}\n\ntype ModalPreviewProps = {\n  /** The content, drawn twice: open in the page, and inside the dialog the trigger opens. */\n  children: React.ReactNode;\n  triggerLabel: string;\n  size?: ModalSize;\n  className?: string;\n};\n\n/** Shows a modal open and whole on the page, with a small trigger that opens the same content in the real dialog. */\nexport function ModalPreview({\n  children,\n  triggerLabel,\n  size = 'md',\n  className,\n}: ModalPreviewProps) {\n  const sizeClass = SIZE_CLASS[size];\n\n  return (\n    <div className='flex w-full flex-col items-center gap-4'>\n      <ModalHostContext.Provider value='preview'>\n        <div\n          className={cn(\n            'surface-raised w-full rounded-2xl p-6 text-left',\n            sizeClass,\n            className\n          )}\n        >\n          <AnimatedSize contentClassName={BODY}>{children}</AnimatedSize>\n        </div>\n      </ModalHostContext.Provider>\n      <Dialog>\n        <DialogTrigger render={<Button variant='outline' size='sm' />}>\n          <SquareArrowOutUpRightIcon />\n          {triggerLabel}\n        </DialogTrigger>\n        <DialogContent className={cn(sizeClass, className)}>\n          <ModalHostContext.Provider value='dialog'>\n            {children}\n          </ModalHostContext.Provider>\n        </DialogContent>\n      </Dialog>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/modal/_parts/modal-frame.tsx"
    },
    {
      "path": "registry/ndeko/components/modal/_parts/motion.ts",
      "content": "import type { Transition, Variants } from 'motion/react';\n\nexport const SWAP_TRANSITION: Transition = {\n  duration: 0.15,\n  ease: [0.2, 0, 0, 1],\n};\n\nconst MORPH_SPRING: Transition = { type: 'spring', bounce: 0, duration: 0.3 };\n\nconst INSTANT: Transition = { duration: 0 };\n\nconst PRESENCE_IN: Transition = { duration: 0.2, ease: [0.23, 1, 0.32, 1] };\n\nconst PRESENCE_OUT: Transition = { duration: 0.14, ease: [0.23, 1, 0.32, 1] };\n\nconst ICON_SWAP: Variants = {\n  enter: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n  visible: { opacity: 1, scale: 1, filter: 'blur(0px)' },\n  exit: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n};\n\nconst LABEL_SWAP: Variants = {\n  enter: { opacity: 0, filter: 'blur(2px)' },\n  visible: { opacity: 1, filter: 'blur(0px)' },\n  exit: { opacity: 0, filter: 'blur(2px)' },\n};\n\nconst FADE_SWAP: Variants = {\n  enter: { opacity: 0 },\n  visible: { opacity: 1 },\n  exit: { opacity: 0 },\n};\n\nconst ROW_PRESENCE: Variants = {\n  hidden: {\n    height: 0,\n    opacity: 0,\n    overflow: 'hidden',\n    transition: PRESENCE_OUT,\n  },\n  shown: {\n    height: 'auto',\n    opacity: 1,\n    transition: PRESENCE_IN,\n    transitionEnd: { overflow: 'visible' },\n  },\n};\n\nconst ROW_FADE: Variants = {\n  hidden: { opacity: 0, transition: PRESENCE_OUT },\n  shown: { opacity: 1, transition: PRESENCE_IN },\n};\n\nconst CHIP_PRESENCE: Variants = {\n  hidden: { opacity: 0, scale: 0.9, transition: PRESENCE_OUT },\n  shown: { opacity: 1, scale: 1, transition: PRESENCE_IN },\n};\n\nexport type SwapKind = 'icon' | 'label';\n\nexport function swapVariantsOf(\n  shouldReduceMotion: boolean | null,\n  kind: SwapKind = 'icon'\n) {\n  if (shouldReduceMotion) {\n    return FADE_SWAP;\n  }\n  if (kind === 'label') {\n    return LABEL_SWAP;\n  }\n  return ICON_SWAP;\n}\n\n/** A row added to or removed from a list: its height opens or collapses, so the rows after it slide. */\nexport function rowVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return ROW_FADE;\n  }\n  return ROW_PRESENCE;\n}\n\nexport function chipVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return ROW_FADE;\n  }\n  return CHIP_PRESENCE;\n}\n\nexport function morphOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return INSTANT;\n  }\n  return MORPH_SPRING;\n}\n",
      "type": "registry:component",
      "target": "components/modal/_parts/motion.ts"
    },
    {
      "path": "registry/ndeko/components/modal/_parts/swap.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { cn } from '@/registry/ndeko/lib/utils';\n\nimport { SWAP_TRANSITION, swapVariantsOf, type SwapKind } from './motion';\n\ntype SwapProps = {\n  /** Changes when the content becomes another: the old one leaves while the new one arrives in its place. */\n  swapKey: string;\n  kind?: SwapKind;\n  className?: string;\n  /** Classes of the moving content, for example `min-w-0 max-w-full` so a long text can truncate inside. */\n  contentClassName?: string;\n  children: React.ReactNode;\n};\n\nexport function Swap({\n  swapKey,\n  kind = 'icon',\n  className,\n  contentClassName,\n  children,\n}: SwapProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = swapVariantsOf(shouldReduceMotion, kind);\n\n  return (\n    <span className={cn('relative inline-flex items-center', className)}>\n      <AnimatePresence mode='popLayout' initial={false}>\n        <motion.span\n          key={swapKey}\n          className={cn(\n            'inline-flex items-center gap-[inherit] whitespace-nowrap',\n            contentClassName\n          )}\n          variants={variants}\n          initial='enter'\n          animate='visible'\n          exit='exit'\n          transition={SWAP_TRANSITION}\n        >\n          {children}\n        </motion.span>\n      </AnimatePresence>\n    </span>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/modal/_parts/swap.tsx"
    }
  ],
  "categories": [
    "components",
    "modal"
  ],
  "type": "registry:component"
}