{
  "$schema": "https://uiuxengine.com/schema/v2/registry-item.json",
  "itemFormat": 2,
  "kind": "block",
  "name": "empty-state",
  "id": "engine.empty-state",
  "version": "0.1.0",
  "title": "Empty State",
  "description": "Says that a view has nothing to show yet, and offers the action that fills it.",
  "engine": "^0.4.0",
  "license": "MIT",
  "access": "free",
  "hash": "501888c0dab0fb60d2024ea7c119cb819f592305ba415a9cf3c12fd22be8b02f",
  "dependencies": [
    "@uiuxengine/core",
    "@uiuxengine/react",
    "@uiuxengine/tokens",
    "react"
  ],
  "requires": [],
  "icons": [
    "inbox"
  ],
  "definition": {
    "contract": "empty-state.contract.ts",
    "design": "empty-state.design.ts"
  },
  "files": [
    {
      "path": "empty-state.contract.ts",
      "content": "import { defineContract, prop, slot } from \"@uiuxengine/core\";\n\nexport const emptyStateContract = defineContract({\n  id: \"engine.empty-state\",\n  name: \"emptyState\",\n  version: \"0.1.0\",\n  description: \"Says that a view has nothing to show yet, and offers the action that fills it.\",\n  guidelines: [\n    \"Use it in place of a list, table or result that is empty, not for errors or loading.\",\n    \"The title says what is missing, for example 'No reports yet'. The description says why, or what to do next.\",\n    \"Offer at most one action: the one that fills the view, as a primary button.\",\n    \"Use size sm inside panels, table cells and sidebars, and md for a whole page or view.\",\n  ],\n  props: {\n    size: prop.enum([\"sm\", \"md\"], {\n      default: \"md\",\n      description: \"sm for panels and other small areas, md for a whole view.\",\n    }),\n    title: prop.text({ required: true, maxLength: 60, description: \"What is missing.\" }),\n    description: prop.text({\n      maxLength: 240,\n      description: \"Why the view is empty or what to do next. Wraps to the block's width.\",\n    }),\n  },\n  slots: {\n    icon: slot.icon({ description: \"An icon for what is missing.\" }),\n    action: slot.content({\n      accepts: [\"engine.button\"],\n      description: \"The action that fills the view.\",\n    }),\n  },\n  semantics: { role: \"generic\", nativeElement: \"div\" },\n});\n"
    },
    {
      "path": "empty-state.design.ts",
      "content": "import { defineDesign, icon } from \"@uiuxengine/core\";\nimport { token } from \"@uiuxengine/tokens\";\n\nexport const emptyStateDesign = defineDesign({\n  component: \"engine.empty-state\",\n  axes: [\"size\"],\n  states: {},\n  root: {\n    id: \"root\",\n    kind: \"frame\",\n    layout: {\n      direction: \"vertical\",\n      gap: token(\"control.gap.lg\"),\n      padding: { x: token(\"control.padding-x.lg\"), y: token(\"control.padding-x.lg\") },\n      width: \"fill\",\n      maxWidth: 400,\n    },\n    style: { foreground: token(\"color.fg.default\") },\n    children: [\n      {\n        id: \"icon\",\n        kind: \"icon\",\n        source: { slot: \"icon\" },\n        placeholder: icon(\"inbox\"),\n        visibleWhen: [{ prop: \"icon\", present: true }],\n        style: { size: token(\"icon.size.lg\"), color: token(\"color.fg.muted\") },\n      },\n      {\n        id: \"text\",\n        kind: \"frame\",\n        layout: { direction: \"vertical\", gap: token(\"control.gap.sm\"), width: \"fill\" },\n        children: [\n          {\n            id: \"title\",\n            kind: \"text\",\n            content: { prop: \"title\" },\n            placeholder: \"No items yet\",\n            layout: { wrap: \"words\", width: \"fill\" },\n            style: { typography: token(\"text.control.lg\") },\n          },\n          {\n            id: \"description\",\n            kind: \"text\",\n            content: { prop: \"description\" },\n            placeholder: \"Items you create appear here.\",\n            visibleWhen: [{ prop: \"description\", present: true }],\n            layout: { wrap: \"words\", width: \"fill\" },\n            style: { typography: token(\"text.body.md\"), color: token(\"color.fg.muted\") },\n          },\n        ],\n      },\n      {\n        id: \"action\",\n        kind: \"slot\",\n        source: { slot: \"action\" },\n        visibleWhen: [{ prop: \"action\", present: true }],\n        layout: { direction: \"horizontal\" },\n        placeholder: [\n          { component: \"engine.button\", props: { variant: \"primary\", label: \"Create item\" } },\n        ],\n      },\n    ],\n  },\n  rules: [\n    {\n      id: \"sm\",\n      when: { props: { size: \"sm\" } },\n      set: {\n        root: {\n          layout: {\n            gap: token(\"control.gap.md\"),\n            padding: { x: token(\"control.padding-x.md\"), y: token(\"control.padding-x.md\") },\n          },\n        },\n        icon: { style: { size: token(\"icon.size.md\") } },\n        title: { style: { typography: token(\"text.control.md\") } },\n      },\n    },\n  ],\n});\n"
    },
    {
      "path": "empty-state.tsx",
      "content": "import type { ContentItem, InferProps } from \"@uiuxengine/core\";\nimport {\n  componentsById,\n  type IconSource,\n  renderParts,\n  toIconRef,\n  useComponent,\n  useIconRenderer,\n} from \"@uiuxengine/react\";\nimport type { ComponentPropsWithRef, ReactNode } from \"react\";\nimport { emptyStateContract } from \"./empty-state.contract.ts\";\nimport { emptyStateDesign } from \"./empty-state.design.ts\";\n\ntype ContractProps = InferProps<typeof emptyStateContract>;\n\nexport interface EmptyStateProps\n  extends Omit<ContractProps, \"icon\" | \"action\">,\n    Omit<ComponentPropsWithRef<\"div\">, keyof ContractProps | \"children\"> {\n  icon?: IconSource;\n  /** The action that fills the view: a primary `Button`, or `{ component, props }` as data. */\n  action?: ReactNode | ContentItem;\n}\n\n/** Engine components that slot items given as data (`{ component, props }`) render with. */\nconst engineComponents = componentsById();\n\n/**\n * Renders the Empty State definition. This file is yours once installed: change behavior here, and\n * change structure and styling in the definition, then regenerate.\n */\nexport function EmptyState({\n  size,\n  title,\n  description,\n  icon,\n  action,\n  className,\n  ...rest\n}: EmptyStateProps) {\n  const renderIcon = useIconRenderer();\n  const { props, rootProps } = useComponent(\n    emptyStateContract,\n    emptyStateDesign,\n    {\n      size,\n      title,\n      description,\n      icon: icon === undefined ? undefined : toIconRef(icon),\n      action,\n    },\n    className,\n  );\n  const text: Record<string, string | undefined> = {\n    title: props.title,\n    description: props.description,\n  };\n\n  return (\n    <div {...rootProps} {...rest} className={rootProps.className}>\n      {renderParts(\n        emptyStateDesign,\n        { props },\n        {\n          text: (prop) => text[prop],\n          icon: () => renderIcon(icon),\n          component: (id, childProps, part) => {\n            const Component = engineComponents.get(id)?.component;\n            return Component ? <Component {...childProps} {...part} /> : null;\n          },\n        },\n      )}\n    </div>\n  );\n}\n"
    }
  ]
}
