{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "share-dialog-vue",
  "title": "Share Dialog (Vue)",
  "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/vue@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-segmented-control-vue"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/vue/share-dialog.ts",
      "content": "import {\n  type ShareDialogActionState,\n  type ShareDialogLinkState,\n  type ShareDialogVisibilityState,\n  shareDialogPrimitive,\n} from \"@kind-ui/agent-ui/core\";\nimport { Input } from \"@ui-sdk/vue/input\";\nimport { createParts } from \"@ui-sdk/vue/primitive\";\nimport { type Component, defineComponent, h, type Slots } from \"vue\";\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\nfunction withDefault<C extends Component>(part: C, name: string, fallback: (scope: never) => unknown): C {\n  const Part = defineComponent({\n    name,\n    inheritAttrs: false,\n    setup(_, { attrs, slots }) {\n      return () => h(part, attrs, { ...slots, default: slots.default ?? fallback } as Slots);\n    },\n  });\n  return Part as unknown as C;\n}\n\n/** Opens the dialog. Its `label`, after a share glyph, unless you fill its slot. */\nexport const ShareDialogTrigger = withDefault(\n  parts.Trigger,\n  \"ShareDialogTrigger\",\n  ({ state }: { state: { label: string } }) => state.label,\n);\n\n/** Dims the page behind the dialog. */\nexport const ShareDialogBackdrop = parts.Backdrop;\n\n/** The dialog's title, the `dialogLabel`, unless you fill its slot. */\nexport const ShareDialogTitle = withDefault(\n  parts.Title,\n  \"ShareDialogTitle\",\n  ({ state }: { state: { label: string } }) => state.label,\n);\n\n/** Who can open the chat, in words, unless you fill its slot. Describes the dialog. */\nexport const ShareDialogDescription = withDefault(\n  parts.Description,\n  \"ShareDialogDescription\",\n  ({ state }: { state: { text: string } }) => state.text,\n);\n\n/** \"Only you\" or \"Anyone with the link\", a UI SDK Segmented Control, unless you fill its slot. */\nexport const ShareDialogVisibility = withDefault(\n  parts.Visibility,\n  \"ShareDialogVisibility\",\n  ({ state }: { state: ShareDialogVisibilityState }) =>\n    // Hidden from agents, which use the Share Dialog's own `setVisibility`.\n    h(\n      KindSegmentedControl,\n      {\n        controller: state.controller,\n        defaultValue: state.defaultValue,\n        \"aria-label\": state[\"aria-label\"],\n        \"data-agent-hidden\": \"\",\n      },\n      () => [\n        h(KindSegmentedControlIndicator),\n        ...state.options.map((option) =>\n          h(KindSegmentedControlItem, { key: option.value, value: option.value }, () => option.label),\n        ),\n      ],\n    ),\n);\n\n/** The `link`, in a read-only UI SDK Input, unless you fill its slot. */\nexport const ShareDialogLink = withDefault(\n  parts.Link,\n  \"ShareDialogLink\",\n  ({ state }: { state: ShareDialogLinkState }) =>\n    h(Input, {\n      value: state.value,\n      readOnly: state.readOnly,\n      \"aria-label\": state[\"aria-label\"],\n      \"data-agent-hidden\": \"\",\n    }),\n);\n\nconst pendingLabel =\n  (label: string, pending: string) =>\n  ({ state }: { state: ShareDialogActionState }) =>\n    state.pending\n      ? [\n          h(\"span\", {\n            \"aria-hidden\": \"true\",\n            \"data-status-mark\": \"\",\n            \"data-status\": \"running\",\n            \"data-motion\": state.motion,\n          }),\n          pending,\n        ]\n      : label;\n\n/** Calls `onCreateLink`. \"Create link\", or \"Creating link\" with a running mark while pending, unless you fill its slot. */\nexport const ShareDialogCreate = withDefault(\n  parts.Create,\n  \"ShareDialogCreate\",\n  pendingLabel(\"Create link\", \"Creating link\"),\n);\n\n/** Copies the `link`. \"Copy link\", then \"Copied\" for 2 s, unless you fill its slot. */\nexport const ShareDialogCopy = withDefault(\n  parts.Copy,\n  \"ShareDialogCopy\",\n  ({ state }: { state: { copied: boolean } }) => (state.copied ? \"Copied\" : \"Copy link\"),\n);\n\n/** Calls `onRevoke`. \"Stop sharing\", or \"Stopping\" with a running mark while pending, unless you fill its slot. */\nexport const ShareDialogRevoke = withDefault(\n  parts.Revoke,\n  \"ShareDialogRevoke\",\n  pendingLabel(\"Stop sharing\", \"Stopping\"),\n);\n\n/** Why the last create or revoke failed, unless you fill its slot. */\nexport const ShareDialogError = withDefault(\n  parts.Error,\n  \"ShareDialogError\",\n  ({ state }: { state: { message: string } }) => state.message,\n);\n\n/** Closes the dialog and returns focus to the trigger. \"Done\", unless you fill its slot. */\nexport const ShareDialogClose = withDefault(parts.Close, \"ShareDialogClose\", () => \"Done\");\n\nconst DEFAULT_PANEL = () => [\n  h(\"div\", { \"data-share-dialog-header\": \"\" }, [h(ShareDialogTitle), h(ShareDialogDescription)]),\n  h(ShareDialogVisibility),\n  h(\"div\", { \"data-share-dialog-link-row\": \"\" }, [\n    h(ShareDialogCreate),\n    h(ShareDialogLink),\n    h(ShareDialogCopy),\n  ]),\n  h(\"div\", { \"data-share-dialog-footer\": \"\" }, [\n    h(ShareDialogError),\n    h(ShareDialogRevoke),\n    h(ShareDialogClose),\n  ]),\n];\n\n/** The dialog: its title, who can open the chat, the link and its actions, unless you fill its slot. */\nexport const ShareDialogContent = defineComponent({\n  name: \"ShareDialogContent\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Content, attrs, {\n        default: slots.default ?? DEFAULT_PANEL,\n        // A sheet sits in a full-screen viewport, which renders only while the content presents as one.\n        render: (scope: {\n          props: Record<string, unknown>;\n          state: { presentation: string };\n          children: Component;\n        }) => {\n          const element = slots.render ? slots.render(scope) : h(\"div\", scope.props, [h(scope.children)]);\n          return [scope.state.presentation === \"sheet\" ? h(parts.Viewport, null, () => element) : element];\n        },\n      });\n  },\n}) as unknown as typeof parts.Content;\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. A default slot replaces the trigger and the dialog.\n */\nexport const ShareDialog = withDefault(parts.Root, \"ShareDialog\", () => [\n  h(ShareDialogTrigger),\n  h(ShareDialogBackdrop),\n  h(ShareDialogContent),\n]);\n",
      "type": "registry:ui",
      "target": "@ui/vue/share-dialog.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
