{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "share-dialog-solid",
  "title": "Share Dialog (Solid)",
  "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/solid@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-segmented-control-solid"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/solid/share-dialog.tsx",
      "content": "import {\n  type ShareDialogActionState,\n  type ShareDialogLinkState,\n  type ShareDialogVisibilityState,\n  shareDialogPrimitive,\n} from \"@kind-ui/agent-ui/core\";\nimport type { ComponentProps, JSX } from \"@solidjs/web\";\nimport { Input } from \"@ui-sdk/solid/input\";\nimport { createParts } from \"@ui-sdk/solid/primitive\";\nimport { For, omit, Show } from \"solid-js\";\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 = Omit<ComponentProps<typeof parts.Root>, \"children\"> & {\n  children?: JSX.Element;\n};\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(props: ShareDialogTriggerProps) {\n  return (\n    <parts.Trigger {...omit(props, \"children\")}>\n      {props.children ?? ((state: { label: string }) => state.label)}\n    </parts.Trigger>\n  );\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(props: ShareDialogTitleProps) {\n  return (\n    <parts.Title {...omit(props, \"children\")}>\n      {props.children ?? ((state: { label: string }) => state.label)}\n    </parts.Title>\n  );\n}\n\n/** Who can open the chat, in words, unless you pass children. Describes the dialog. */\nexport function ShareDialogDescription(props: ShareDialogDescriptionProps) {\n  return (\n    <parts.Description {...omit(props, \"children\")}>\n      {props.children ?? ((state: { text: string }) => state.text)}\n    </parts.Description>\n  );\n}\n\nconst visibilityControl = (control: ShareDialogVisibilityState) => (\n  // Hidden from agents, which use the Share Dialog's own `setVisibility`.\n  <KindSegmentedControl\n    controller={control.controller}\n    defaultValue={control.defaultValue}\n    aria-label={control[\"aria-label\"]}\n    data-agent-hidden=\"\"\n  >\n    <KindSegmentedControlIndicator />\n    <For each={control.options} keyed={(option) => option.value}>\n      {(option) => (\n        <KindSegmentedControlItem value={option().value}>{option().label}</KindSegmentedControlItem>\n      )}\n    </For>\n  </KindSegmentedControl>\n);\n\n/** \"Only you\" or \"Anyone with the link\", a UI SDK Segmented Control, unless you pass children. */\nexport function ShareDialogVisibility(props: ShareDialogVisibilityProps) {\n  return (\n    <parts.Visibility {...omit(props, \"children\")}>{props.children ?? visibilityControl}</parts.Visibility>\n  );\n}\n\nconst linkInput = (input: ShareDialogLinkState) => (\n  <Input\n    value={input.value}\n    readonly={input.readOnly}\n    aria-label={input[\"aria-label\"]}\n    data-agent-hidden=\"\"\n  />\n);\n\n/** The `link`, in a read-only UI SDK Input, unless you pass children. */\nexport function ShareDialogLink(props: ShareDialogLinkProps) {\n  return <parts.Link {...omit(props, \"children\")}>{props.children ?? linkInput}</parts.Link>;\n}\n\nconst pendingLabel = (label: string, pending: string) => (state: ShareDialogActionState) => (\n  <Show when={state.pending} fallback={label}>\n    <span aria-hidden=\"true\" data-status-mark=\"\" data-status=\"running\" data-motion={state.motion} />\n    {pending}\n  </Show>\n);\n\n/** Calls `onCreateLink`. \"Create link\", or \"Creating link\" with a running mark while pending, unless you pass children. */\nexport function ShareDialogCreate(props: ShareDialogCreateProps) {\n  return (\n    <parts.Create {...omit(props, \"children\")}>\n      {props.children ?? pendingLabel(\"Create link\", \"Creating link\")}\n    </parts.Create>\n  );\n}\n\n/** Copies the `link`. \"Copy link\", then \"Copied\" for 2 s, unless you pass children. */\nexport function ShareDialogCopy(props: ShareDialogCopyProps) {\n  return (\n    <parts.Copy {...omit(props, \"children\")}>\n      {props.children ?? ((state: { copied: boolean }) => (state.copied ? \"Copied\" : \"Copy link\"))}\n    </parts.Copy>\n  );\n}\n\n/** Calls `onRevoke`. \"Stop sharing\", or \"Stopping\" with a running mark while pending, unless you pass children. */\nexport function ShareDialogRevoke(props: ShareDialogRevokeProps) {\n  return (\n    <parts.Revoke {...omit(props, \"children\")}>\n      {props.children ?? pendingLabel(\"Stop sharing\", \"Stopping\")}\n    </parts.Revoke>\n  );\n}\n\n/** Why the last create or revoke failed, unless you pass children. */\nexport function ShareDialogError(props: ShareDialogErrorProps) {\n  return (\n    <parts.Error {...omit(props, \"children\")}>\n      {props.children ?? ((state: { message: string }) => state.message)}\n    </parts.Error>\n  );\n}\n\n/** Closes the dialog and returns focus to the trigger. \"Done\", unless you pass children. */\nexport function ShareDialogClose(props: ShareDialogCloseProps) {\n  return <parts.Close {...omit(props, \"children\")}>{props.children ?? \"Done\"}</parts.Close>;\n}\n\ntype Render = (props: Record<string, unknown>, state: { presentation?: string }) => JSX.Element;\n\n/** The dialog: its title, who can open the chat, the link and its actions, unless you pass children. */\nexport function ShareDialogContent(props: ShareDialogContentProps) {\n  const render = (content: Record<string, unknown>, state: { presentation?: string }) => {\n    const element = () => {\n      const own = props.render as Render | undefined;\n      return own ? own(content, state) : <div {...content} />;\n    };\n    // A sheet sits in a full-screen viewport, which renders only while the content presents as one.\n    return (\n      <Show when={state.presentation === \"sheet\"} fallback={element()}>\n        <parts.Viewport>{element()}</parts.Viewport>\n      </Show>\n    );\n  };\n  return (\n    <parts.Content\n      {...omit(props, \"children\", \"render\")}\n      render={render as ShareDialogContentProps[\"render\"]}\n    >\n      {props.children ?? (\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    </parts.Content>\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(props: ShareDialogProps) {\n  return (\n    <parts.Root {...omit(props, \"children\")}>\n      {props.children ?? (\n        <>\n          <ShareDialogTrigger />\n          <ShareDialogBackdrop />\n          <ShareDialogContent />\n        </>\n      )}\n    </parts.Root>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@ui/solid/share-dialog.tsx"
    }
  ],
  "meta": {
    "layer": "solid"
  },
  "type": "registry:ui"
}
