{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "share-dialog",
  "title": "Share Dialog",
  "description": "A Share button whose dialog chooses who can open the chat and shows the link the host makes, with Copy link.",
  "dependencies": [
    "@kind-ui/agent-ui@0.9.0",
    "@ui-sdk/core@0.1.0-beta.17",
    "@ui-sdk/react@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-segmented-control"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/react/share-dialog.tsx",
      "content": "\"use client\";\n\nimport { shareDialogPrimitive } from \"@kind-ui/agent-ui/core\";\nimport { Input } from \"@ui-sdk/react/input\";\nimport { createParts, renderElement } from \"@ui-sdk/react/primitive\";\nimport type { ComponentProps } from \"react\";\nimport {\n  KindSegmentedControl,\n  KindSegmentedControlIndicator,\n  KindSegmentedControlItem,\n} from \"./internal/segmented-control\";\n\nconst parts = createParts(shareDialogPrimitive, {\n  root: \"div\",\n  trigger: \"button\",\n  backdrop: \"div\",\n  viewport: \"div\",\n  content: \"div\",\n  title: \"h2\",\n  description: \"p\",\n  visibility: \"div\",\n  link: \"div\",\n  create: \"button\",\n  copy: \"button\",\n  revoke: \"button\",\n  error: \"p\",\n  close: \"button\",\n});\n\nexport type ShareDialogProps = ComponentProps<typeof parts.Root>;\nexport type ShareDialogTriggerProps = ComponentProps<typeof parts.Trigger>;\nexport type ShareDialogContentProps = ComponentProps<typeof parts.Content>;\nexport type ShareDialogTitleProps = ComponentProps<typeof parts.Title>;\nexport type ShareDialogDescriptionProps = ComponentProps<typeof parts.Description>;\nexport type ShareDialogVisibilityProps = ComponentProps<typeof parts.Visibility>;\nexport type ShareDialogLinkProps = ComponentProps<typeof parts.Link>;\nexport type ShareDialogCreateProps = ComponentProps<typeof parts.Create>;\nexport type ShareDialogCopyProps = ComponentProps<typeof parts.Copy>;\nexport type ShareDialogRevokeProps = ComponentProps<typeof parts.Revoke>;\nexport type ShareDialogErrorProps = ComponentProps<typeof parts.Error>;\nexport type ShareDialogCloseProps = ComponentProps<typeof parts.Close>;\n\n/** Opens the dialog. Its `label`, after a share glyph, unless you pass children. */\nexport function ShareDialogTrigger({ children = ({ label }) => label, ...props }: ShareDialogTriggerProps) {\n  return <parts.Trigger {...props}>{children}</parts.Trigger>;\n}\n\n/** Dims the page behind the dialog. */\nexport const ShareDialogBackdrop = parts.Backdrop;\n\n/** The dialog's title, the `dialogLabel`, unless you pass children. */\nexport function ShareDialogTitle({ children = ({ label }) => label, ...props }: ShareDialogTitleProps) {\n  return <parts.Title {...props}>{children}</parts.Title>;\n}\n\n/** Who can open the chat, in words, unless you pass children. Describes the dialog. */\nexport function ShareDialogDescription({\n  children = ({ text }) => text,\n  ...props\n}: ShareDialogDescriptionProps) {\n  return <parts.Description {...props}>{children}</parts.Description>;\n}\n\nconst VISIBILITY: ShareDialogVisibilityProps[\"children\"] = ({ options, ...control }) => (\n  // Hidden from agents, which use the Share Dialog's own `setVisibility`.\n  <KindSegmentedControl {...control} data-agent-hidden=\"\">\n    <KindSegmentedControlIndicator />\n    {options.map((option) => (\n      <KindSegmentedControlItem key={option.value} value={option.value}>\n        {option.label}\n      </KindSegmentedControlItem>\n    ))}\n  </KindSegmentedControl>\n);\n\n/** \"Only you\" or \"Anyone with the link\", a UI SDK Segmented Control, unless you pass children. */\nexport function ShareDialogVisibility({ children = VISIBILITY, ...props }: ShareDialogVisibilityProps) {\n  return <parts.Visibility {...props}>{children}</parts.Visibility>;\n}\n\nconst LINK: ShareDialogLinkProps[\"children\"] = (input) => <Input {...input} data-agent-hidden=\"\" />;\n\n/** The `link`, in a read-only UI SDK Input, unless you pass children. */\nexport function ShareDialogLink({ children = LINK, ...props }: ShareDialogLinkProps) {\n  return <parts.Link {...props}>{children}</parts.Link>;\n}\n\nconst pendingLabel =\n  (label: string, pending: string): ShareDialogCreateProps[\"children\"] =>\n  (state) =>\n    state.pending ? (\n      <>\n        <span aria-hidden=\"true\" data-status-mark=\"\" data-status=\"running\" data-motion={state.motion} />\n        {pending}\n      </>\n    ) : (\n      label\n    );\n\nconst CREATE = pendingLabel(\"Create link\", \"Creating link\");\nconst REVOKE = pendingLabel(\"Stop sharing\", \"Stopping\");\n\n/** Calls `onCreateLink`. \"Create link\", or \"Creating link\" with a running mark while pending, unless you pass children. */\nexport function ShareDialogCreate({ children = CREATE, ...props }: ShareDialogCreateProps) {\n  return <parts.Create {...props}>{children}</parts.Create>;\n}\n\n/** Copies the `link`. \"Copy link\", then \"Copied\" for 2 s, unless you pass children. */\nexport function ShareDialogCopy({\n  children = ({ copied }) => (copied ? \"Copied\" : \"Copy link\"),\n  ...props\n}: ShareDialogCopyProps) {\n  return <parts.Copy {...props}>{children}</parts.Copy>;\n}\n\n/** Calls `onRevoke`. \"Stop sharing\", or \"Stopping\" with a running mark while pending, unless you pass children. */\nexport function ShareDialogRevoke({ children = REVOKE, ...props }: ShareDialogRevokeProps) {\n  return <parts.Revoke {...props}>{children}</parts.Revoke>;\n}\n\n/** Why the last create or revoke failed, unless you pass children. */\nexport function ShareDialogError({ children = ({ message }) => message, ...props }: ShareDialogErrorProps) {\n  return <parts.Error {...props}>{children}</parts.Error>;\n}\n\n/** Closes the dialog and returns focus to the trigger. \"Done\", unless you pass children. */\nexport function ShareDialogClose({ children = \"Done\", ...props }: ShareDialogCloseProps) {\n  return <parts.Close {...props}>{children}</parts.Close>;\n}\n\nconst DEFAULT_PANEL = (\n  <>\n    <div data-share-dialog-header=\"\">\n      <ShareDialogTitle />\n      <ShareDialogDescription />\n    </div>\n    <ShareDialogVisibility />\n    <div data-share-dialog-link-row=\"\">\n      <ShareDialogCreate />\n      <ShareDialogLink />\n      <ShareDialogCopy />\n    </div>\n    <div data-share-dialog-footer=\"\">\n      <ShareDialogError />\n      <ShareDialogRevoke />\n      <ShareDialogClose />\n    </div>\n  </>\n);\n\n/** The dialog: its title, who can open the chat, the link and its actions, unless you pass children. */\nexport function ShareDialogContent({ children = DEFAULT_PANEL, render, ...props }: ShareDialogContentProps) {\n  return (\n    <parts.Content\n      {...props}\n      // A sheet sits in a full-screen viewport, which renders only while the content presents as one.\n      render={(content, state) => {\n        const element = renderElement(\"div\", content, render, state);\n        return state.presentation === \"sheet\" ? <parts.Viewport>{element}</parts.Viewport> : element;\n      }}\n    >\n      {children}\n    </parts.Content>\n  );\n}\n\n// Shared, so an update doesn't render the default parts' wrappers again.\nconst DEFAULT_PARTS = (\n  <>\n    <ShareDialogTrigger />\n    <ShareDialogBackdrop />\n    <ShareDialogContent />\n  </>\n);\n\n/**\n * A Share button whose dialog chooses who can open the chat and shows the link the host makes, with Copy link and\n * Stop sharing. Any `children` replace the trigger and the dialog.\n */\nexport function ShareDialog({ children = DEFAULT_PARTS, ...props }: ShareDialogProps) {\n  return <parts.Root {...props}>{children}</parts.Root>;\n}\n",
      "type": "registry:ui",
      "target": "@ui/share-dialog.tsx"
    }
  ],
  "meta": {
    "layer": "react"
  },
  "type": "registry:ui"
}
