{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "empty-states-01",
  "title": "Empty list with one action",
  "description": "A project list with nothing in it yet: one sentence on what is missing and the action that adds the first project, which then takes the place of the empty slot.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/input.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/blocks/empty-states/empty-states-01/index.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useState } from 'react';\n\nimport { FolderPlusIcon, PlusIcon } from '@/registry/ndeko/lib/icons';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button } from '@/registry/ndeko/ui/button';\n\nimport { fadePresence } from './motion-parts';\nimport { DraftProjectRow, ProjectRow, type Project } from './project-rows';\n\nconst WORKSPACE_NAME = 'Mossline';\n\nfunction projectCountOf(count: number) {\n  if (count === 0) {\n    return 'No projects';\n  }\n  if (count === 1) {\n    return '1 project';\n  }\n  return `${count} projects`;\n}\n\nfunction EmptyProjects({ onCreate }: { onCreate: () => void }) {\n  return (\n    <div className='hairline-border border-foreground/20 flex flex-col items-center rounded-xl border-dashed px-6 py-12 text-center'>\n      <span className='keycap-3d text-muted-foreground flex size-9 items-center justify-center rounded-lg'>\n        <FolderPlusIcon />\n      </span>\n      <p className='text-muted-foreground mt-4 max-w-sm text-[13px] text-balance'>\n        {WORKSPACE_NAME} has no projects yet, create one to group the tasks\n        behind a goal\n      </p>\n      <Button onClick={onCreate} className='mt-4'>\n        <PlusIcon />\n        Create project\n      </Button>\n    </div>\n  );\n}\n\nexport default function EmptyStates01() {\n  const [projects, setProjects] = useState<Project[]>([]);\n  const [isCreating, setIsCreating] = useState(false);\n  const [nextId, setNextId] = useState(1);\n  const hasProjects = projects.length > 0;\n  const showsList = hasProjects || isCreating;\n\n  function startCreating() {\n    setIsCreating(true);\n  }\n\n  function cancelCreating() {\n    setIsCreating(false);\n  }\n\n  function create(name: string) {\n    const project: Project = { id: `project-${nextId}`, name };\n    setProjects((current) => [project, ...current]);\n    setNextId((current) => current + 1);\n    setIsCreating(false);\n  }\n\n  function remove(projectId: string) {\n    setProjects((current) =>\n      current.filter((project) => project.id !== projectId)\n    );\n  }\n\n  return (\n    <div className='bg-background text-foreground min-h-svh px-4 py-8 sm:px-8 sm:py-10'>\n      <div className='mx-auto max-w-2xl'>\n        <div className='flex h-8 items-center justify-between gap-3'>\n          <div className='min-w-0'>\n            <h1 className='text-sm font-semibold'>Projects</h1>\n            <p className='text-muted-foreground text-xs'>\n              {projectCountOf(projects.length)}\n            </p>\n          </div>\n          {hasProjects && (\n            <Button onClick={startCreating} disabled={isCreating}>\n              <PlusIcon />\n              New project\n            </Button>\n          )}\n        </div>\n        <AnimatedSize className='mt-5'>\n          <div className='relative'>\n            <AnimatePresence mode='popLayout' initial={false}>\n              {!showsList && (\n                <motion.div key='empty' {...fadePresence()}>\n                  <EmptyProjects onCreate={startCreating} />\n                </motion.div>\n              )}\n              {showsList && (\n                <motion.ul\n                  key='list'\n                  aria-label='Projects'\n                  {...fadePresence()}\n                  className='bg-card hairline-ring ring-border hairline-divide-y divide-border overflow-clip rounded-xl shadow-[0_1px_2px_rgb(0_0_0/0.04)]'\n                >\n                  <AnimatePresence initial={false}>\n                    {isCreating && (\n                      <DraftProjectRow\n                        key='draft'\n                        onCreate={create}\n                        onCancel={cancelCreating}\n                      />\n                    )}\n                    {projects.map((project) => (\n                      <ProjectRow\n                        key={project.id}\n                        project={project}\n                        onDelete={remove}\n                      />\n                    ))}\n                  </AnimatePresence>\n                </motion.ul>\n              )}\n            </AnimatePresence>\n          </div>\n        </AnimatedSize>\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/empty-states-01/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/empty-states/empty-states-01/project-rows.tsx",
      "content": "'use client';\n\nimport { motion } from 'motion/react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { FolderIcon, TrashIcon } from '@/registry/ndeko/lib/icons';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Input } from '@/registry/ndeko/ui/input';\n\nimport { heightPresenceOf } from './motion-parts';\n\nexport type Project = {\n  id: string;\n  name: string;\n};\n\nfunction ProjectTile() {\n  return (\n    <span className='keycap-3d text-muted-foreground flex size-7 shrink-0 items-center justify-center rounded-md'>\n      <FolderIcon className='size-3.5' />\n    </span>\n  );\n}\n\nexport function ProjectRow({\n  project,\n  onDelete,\n}: {\n  project: Project;\n  onDelete: (projectId: string) => void;\n}) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n\n  return (\n    <motion.li\n      {...heightPresenceOf(shouldReduceMotion)}\n      className='overflow-hidden'\n    >\n      <div className='flex h-14 items-center gap-3 ps-3 pe-2'>\n        <ProjectTile />\n        <div className='min-w-0 flex-1'>\n          <p className='truncate text-[13px] font-medium'>{project.name}</p>\n          <p className='text-muted-foreground text-xs'>No tasks yet</p>\n        </div>\n        <Button\n          variant='ghost'\n          size='icon-sm'\n          aria-label={`Delete ${project.name}`}\n          onClick={() => onDelete(project.id)}\n          className='text-muted-foreground'\n        >\n          <TrashIcon />\n        </Button>\n      </div>\n    </motion.li>\n  );\n}\n\nexport function DraftProjectRow({\n  onCreate,\n  onCancel,\n}: {\n  onCreate: (name: string) => void;\n  onCancel: () => void;\n}) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const inputRef = useRef<HTMLInputElement>(null);\n  const [name, setName] = useState('');\n  const trimmed = name.trim();\n  const canCreate = trimmed.length > 0;\n\n  useEffect(() => {\n    inputRef.current?.focus();\n  }, []);\n\n  function submit(event: React.FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    if (!canCreate) {\n      return;\n    }\n    onCreate(trimmed);\n  }\n\n  function handleKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {\n    if (event.key === 'Escape') {\n      event.preventDefault();\n      onCancel();\n    }\n  }\n\n  return (\n    <motion.li\n      {...heightPresenceOf(shouldReduceMotion)}\n      className='overflow-hidden'\n    >\n      <form\n        onSubmit={submit}\n        className='flex min-h-14 flex-wrap items-center gap-x-3 gap-y-2 px-3 py-2.5'\n      >\n        <ProjectTile />\n        <Input\n          ref={inputRef}\n          value={name}\n          onChange={(event) => setName(event.target.value)}\n          onKeyDown={handleKeyDown}\n          aria-label='Project name'\n          placeholder='Project name'\n          className='min-w-0 flex-1 basis-40'\n        />\n        <div className='ms-auto flex items-center gap-1'>\n          <Button type='button' variant='ghost' size='sm' onClick={onCancel}>\n            Cancel\n          </Button>\n          <Button type='submit' size='sm' disabled={!canCreate}>\n            Create\n          </Button>\n        </div>\n      </form>\n    </motion.li>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/empty-states-01/project-rows.tsx"
    },
    {
      "path": "registry/ndeko/blocks/empty-states/empty-states-01/motion-parts.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type MotionProps,\n  type Transition,\n  type Variants,\n} from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { cn } from '@/registry/ndeko/lib/utils';\n\nconst EASE_OUT_STRONG: [number, number, number, number] = [0.23, 1, 0.32, 1];\n\nconst ENTER: Transition = { duration: 0.2, ease: EASE_OUT_STRONG };\n\nconst EXIT: Transition = { duration: 0.15, ease: EASE_OUT_STRONG };\n\ntype PresenceProps = Pick<\n  MotionProps,\n  'initial' | 'animate' | 'exit' | 'transition'\n>;\n\nconst HEIGHT_PRESENCE: PresenceProps = {\n  initial: { height: 0, opacity: 0 },\n  animate: { height: 'auto', opacity: 1 },\n  exit: { height: 0, opacity: 0, transition: EXIT },\n  transition: ENTER,\n};\n\nconst FADE_PRESENCE: PresenceProps = {\n  initial: { opacity: 0 },\n  animate: { opacity: 1 },\n  exit: { opacity: 0, transition: EXIT },\n  transition: ENTER,\n};\n\nexport function heightPresenceOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_PRESENCE;\n  }\n  return HEIGHT_PRESENCE;\n}\n\nexport function fadePresence() {\n  return FADE_PRESENCE;\n}\n\nconst SWAP_TRANSITION: Transition = { duration: 0.15, ease: EASE_OUT_STRONG };\n\nconst SWAP_VARIANTS: Variants = {\n  hidden: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n  shown: { opacity: 1, scale: 1, filter: 'blur(0px)' },\n};\n\nconst FADE_VARIANTS: Variants = {\n  hidden: { opacity: 0 },\n  shown: { opacity: 1 },\n};\n\nfunction swapVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return SWAP_VARIANTS;\n}\n\ntype SwapProps = {\n  swapKey: string;\n  children: React.ReactNode;\n  className?: string;\n};\n\nexport function Swap({ swapKey, children, className }: SwapProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = swapVariantsOf(shouldReduceMotion);\n\n  return (\n    <span className={cn('relative inline-flex', className)}>\n      <AnimatePresence mode='popLayout' initial={false}>\n        <motion.span\n          key={swapKey}\n          variants={variants}\n          initial='hidden'\n          animate='shown'\n          exit='hidden'\n          transition={SWAP_TRANSITION}\n          className='inline-flex'\n        >\n          {children}\n        </motion.span>\n      </AnimatePresence>\n    </span>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/empty-states-01/motion-parts.tsx"
    }
  ],
  "categories": [
    "blocks",
    "empty-states"
  ],
  "type": "registry:block"
}