npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kong-ui-public/copy-uuid

v2.0.47

Published

A Kong UI component for displaying uuid and copying it to clipboard.

Downloads

1,153

Readme

@kong-ui-public/copy-uuid

A Kong UI component for displaying uuid and copying it to clipboard.

Features

  • Configurable uuid appearances
  • Ability to copy the uuid to clipboard with one click
  • Customizable notify method through provide or prop

copy-uuid component example with different appearances

Requirements

  • vue must be initialized in the host application
  • @kong/kongponents must be available as a dependency in the host application, along with the package's style imports. See here for instructions on installing Kongponents. Specifically, the following Kongponents must be available:
    • KClipboardProvider
    • KIcon
  • @kong-ui-public/i18n must be available as a dependency in the host application.

Usage

Install

Install the component in your host application

yarn add @kong-ui-public/copy-uuid

Register

You can register copy-uuid globally or locally.

// Global registration
import { createApp } from 'vue'
import CopyUuid, { CopyUuidNotifyParam } from '@kong-ui-public/copy-uuid'
import '@kong-ui-public/copy-uuid/dist/style.css'

const app = createApp(App)

app.use(CopyUuid)
<!-- Local registration -->
<template>
  <copy-uuid />
</template>

<script setup lang="ts">
import { CopyUuid } from '@kong-ui-public/copy-uuid'
</script>

Initialize

You can set up an optional global notify method, and every copy-uuid component instance will use this method as a default.

If you're using copy-uuid as a vue plugin:

// app entry file
import { createApp } from 'vue'
import CopyUuid, { CopyUuidNotifyParam } from '@kong-ui-public/copy-uuid'
import '@kong-ui-public/copy-uuid/dist/style.css'

const app = createApp(App)

app.use(CopyUuid, {
  notify: (props: CopyUuidNotifyParam) => {
    // Notify your end users
  }
})

If you prefer using copy-uuid as a component:

// app entry file
import { createApp } from 'vue'
import { COPY_UUID_NOTIFY_KEY, CopyUuidNotifyParam } from '@kong-ui-public/copy-uuid'

const app = createApp(App)

app.provide(COPY_UUID_NOTIFY_KEY, (props: CopyUuidNotifyParam) => {
  // Notify your end users
})

You could also set up a notify method for each copy-uuid component instance through its prop. If the notify prop is defined, it'll take precedence over the global notify method:

<template>
  <copy-uuid
    <!-- other props -->
    :notify="notify"
  />
</template>

<script setup lang="ts">
  import { CopyUuidNotifyParam } from '@kong-ui-public/copy-uuid'

  const notify = (param: CopyUuidNotifyParam) => {
    // Notify your end users
  }
</script>

TypeScript interfaces

TypeScript interfaces are available here and can be directly imported into your host application. The following interfaces are available for import:

import type { CopyUuidNotifyParam, CopyUuidInstallOptions } from '@kong-ui-public/copy-uuid'

Props

uuid

  • type: String
  • required: true

The UUID string. When the copy button is clicked, this string will be copied to clipboard.

truncated

  • type: Boolean
  • required: false
  • default: true

An indicator of whether a long UUID is truncated. When true, the UUID will be truncated to 8 characters. When false, the UUID will be displayed in full.

useMono

  • type: Boolean
  • required: false
  • default: true

An indicator of whether a .mono class is added to the UUID string. Make sure to import the Kongponents style file in your host application for this class to take effect.

format

  • type: String as PropType<'uuid' | 'hidden' | 'redacted' | 'deleted'>
  • required: false
  • default: uuid

Determines the display format of the UUID string. The component can take the following format values:

  • uuid: displays regular uuid
  • hidden: displays just a copy button without text
  • redacted: displays *****
  • deleted: displays *<first-5-chars-of-uuid>

notify

  • type: Function as PropType<(param: CopyUuidNotifyParam) => void>
  • required: false
  • default: undefined

A function that will be called when the copy button is clicked. The function will receive a CopyUuidNotifyParam object as its only argument. The CopyUuidNotifyParam object has the following properties:

  • type: success | error, indicating whether the copy operation is successful
  • message: string, the message to be displayed to the end user

iconColor

  • type: String
  • required: false
  • default: 'rgba(0, 0, 0, 0.45)'

The color of the copy icon.

tooltip

  • type: String
  • required: false
  • default: ''

Tooltip text to display on hovering over the copy icon. This field is required if successTooltip has a value.

successTooltip

  • type: String
  • required: false
  • default: ''

Note: The tooltip prop is required to have a value in order to use this prop. When using this prop the @success and @error events will not be fired, as the tooltip text will be updated instead. Tooltip text to display on successful copy.

Events

Success and error events are only emitted if NOT using the successTooltip prop.

success

A success event is emitted when the UUID is successfully copied to clipboard. The event payload is the UUID.

error

An error event is emitted when an error occurs when trying to copy the UUID. The event payload is the UUID.