@molecule/app-copy-link-field-vue

Feature · copy-link-field · App (browser) · v1.2.1 · Apache-2.0

Read-only input + copy-to-clipboard button for share links, API keys, webhook URLs

npm install @molecule/app-copy-link-field-vue

npm · Source on GitHub

How it works

@molecule/app-copy-link-field-vue is a ready-made copy-link-field feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

import { createApp, defineComponent, h } from 'vue'
import { moleculePlugin } from '@molecule/app-vue'
import { CopyLinkField } from '@molecule/app-copy-link-field-vue'

const App = defineComponent({
  setup() {
    return () =>
      h(CopyLinkField, {
        label: 'Share link',
        value: 'https://example.com/invite/abc123',
        onCopy: () => console.log('copied'),
        feedbackMs: 2000,
      })
  },
})

const app = createApp(App)
app.use(moleculePlugin, { i18n: i18nProvider })
app.mount('#app')

Works with: @molecule/app-clipboard, @molecule/app-ui, @molecule/app-ui-vue, @molecule/app-vue

Reference

Vue copy-link field.

Exports <CopyLinkField> — read-only input + copy-to-clipboard button with "Copied!" feedback. Vue counterpart of @molecule/app-copy-link-field-react: the same props (React names), the same DOM for the same input, the same ClassMap tokens and i18n keys.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

import { createApp, defineComponent, h } from 'vue'
import { moleculePlugin } from '@molecule/app-vue'
import { CopyLinkField } from '@molecule/app-copy-link-field-vue'

const App = defineComponent({
  setup() {
    return () =>
      h(CopyLinkField, {
        label: 'Share link',
        value: 'https://example.com/invite/abc123',
        onCopy: () => console.log('copied'),
        feedbackMs: 2000,
      })
  },
})

const app = createApp(App)
app.use(moleculePlugin, { i18n: i18nProvider })
app.mount('#app')

Type

feature

Installation

npm install @molecule/app-copy-link-field-vue @molecule/app-clipboard @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue

API

Interfaces

CopyLinkFieldProps

Props for the CopyLinkField component.

interface CopyLinkFieldProps {
  /** Value to display (and copy on click). */
  value: string
  /** Optional label above the field. */
  label?: string
  /** Called after a successful copy. */
  onCopy?: () => void
  /** How long the "Copied!" state lingers (ms). Defaults to 1500. */
  feedbackMs?: number
  /** Size of the copy button. Defaults to `'sm'`. */
  size?: 'sm' | 'md'
  /** Extra classes. */
  className?: string
}

Constants

CopyLinkField

Read-only input + copy-to-clipboard button. Common in share-link panels, API-key cards, webhook URLs.

The copy button copies through @molecule/app-clipboard (copyTextWithFallback — the bonded clipboard provider first, then a legacy copy fallback — which resolves false instead of throwing), so it works on insecure (non-HTTPS) contexts too; the copied feedback shows and onCopy fires only when the copy succeeded. The input is read-only and selects its content on focus, so manual Ctrl/Cmd+C still works as the fallback. Labels use copyLink.* i18n keys.

const CopyLinkField: DefineComponent<
  ExtractPropTypes<{
    value: { type: StringConstructor; required: true }
    label: { type: StringConstructor; default: undefined }
    onCopy: { type: PropType<() => void>; default: undefined }
    feedbackMs: { type: NumberConstructor; default: number }
    size: { type: PropType<'sm' | 'md'>; default: string }
    className: StringConstructor
  }>,
  () => VNodeChild,
  {},
  {},
  {},
  ComponentOptionsMixin,
  ComponentOptionsMixin,
  {},
  string,
  PublicProps,
  Readonly<
    ExtractPropTypes<{
      value: { type: StringConstructor; required: true }
      label: { type: StringConstructor; default: undefined }
      onCopy: { type: PropType<() => void>; default: undefined }
      feedbackMs: { type: NumberConstructor; default: number }
      size: { type: PropType<'sm' | 'md'>; default: string }
      className: StringConstructor
    }>
  > &
    Readonly<{}>,
  { label: string; onCopy: () => void; feedbackMs: number; size: 'sm' | 'md' },
  {},
  {},
  {},
  string,
  ComponentProvideOptions,
  true,
  {},
  any
>
  • props — Component props (see CopyLinkFieldProps).

Returns: The copy-link field component.

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-clipboard ^1.0.1
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-vue ^1.1.0
  • @molecule/app-vue ^3.6.0 || ^4.0.0
  • vue ^3.4.0

Runtime Dependencies

  • @molecule/app-clipboard
  • @molecule/app-ui
  • @molecule/app-ui-vue
  • @molecule/app-vue
  • vue

The copy button copies through @molecule/app-clipboard (copyTextWithFallback — the bonded clipboard provider first, then a legacy copy fallback — which resolves false instead of throwing), so it works on insecure (non-HTTPS) contexts too; the copied feedback shows and onCopy fires only when the copy succeeded. The input is read-only and selects its content on focus, so manual Ctrl/Cmd+C still works as the fallback. Labels use copyLink.* i18n keys (companion bond: @molecule/app-locales-copy-link-field), read through the binding's useTranslation() — the bonded @molecule/app-i18n provider satisfies it, so the static t works wherever the provider is bonded. Styling routes through ClassMap tokens (cm.stack(1), cm.flex, cm.input(), cm.flex1) and requires a bonded ClassMap (e.g. @molecule/app-ui-tailwind).

Translations

Translation strings are provided by @molecule/app-locales-copy-link-field.