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

kopasin-js

v1.1.9

Published

kopasin-js is a simple, lightweight, and customizable JavaScript library for adding copy-paste interactivity to your projects

Downloads

6

Readme

KopasinJS

kopasin-js is a lightweight and customizable JavaScript library designed to add copy-paste functionality to your web projects. With kopasin-js, you can effortlessly enable users to copy and paste text with minimal setup and maximum flexibility. This library use 0% of JQuery.

License GitHub Downloads (all assets, all releases) npm bundle size GitHub commit activity

Features

  • Simple Setup: Easy to integrate with just a few lines of code.
  • Customizable: Tailor the library to fit your specific needs.
  • Lightweight: Minimal impact on your project's performance.
  • Cross-Browser Support: Works seamlessly across modern web browsers.

Visits

Installation

To get started with kopasin-js, you can either include it via CDN or install it via npm.

Using CDN

Add the following script to your HTML:

# USING CDN
<script src="https://cdn.jsdelivr.net/npm/kopasin-js@latest/dist/kopasin-js.global.js"></script>
# OR
<script src="https://unpkg.com/[email protected]/dist/kopasin-js.global.js"></script>

# USING DOWNLOADED FILES
<script src="dist/kopasin-js.global.js"></script>

With Import

Install via NPM

npm i kopasin-js

And then import the library

import KopasinJS from "kopasin-js"

Example Usage

Copying Text from an Input

To copy a value from input element, we need to create 2 element, which is the <input /> element and <button></button> element

<input type="text" id="copy-this" value="Copy Me" readonly>
<button type="button" id="copy-button">Copy</button>

After that, load KopasinJS like this

new Kopasin({
  copy: {
    on: 'click',
    trigger: document.getElementById('copy-button'),
    source: document.getElementById('copy-this'),
    success: function () {
      console.log('Copied!')
    },
    error: function () {
      console.log('Failed to copy')
    }
  },
});

The success and error callback is optional, but you can use the success callback for improving the user experience with interactivity after copying is successful.

Copying Text from an Element

To copy a value from an element (example: <div>), we also need to create 2 element, which is the <div></div> element and <button></button> element.

<div id="copy-this">Copy Me</div> <!-- You can also use another element like <p>, <span> and anything -->
<button type="button" id="copy-button">Copy</button>

For the javascript code is still same.

new Kopasin({
  copy: {
    on: 'click',
    trigger: document.getElementById('copy-button'),
    source: document.getElementById('copy-this'),
    success: function () {
      console.log('Copied!')
    },
    error: function () {
      console.log('Failed to copy')
    }
  },
});

Options for copy

| Key | Type | Description | Required | Default Value | |---------|-------------|------------------------------------------------------------------------------------------------------------------------|----------|---------------| | on | String | The event that will be used to trigger the element in the trigger option, must be valid event for addEventListener | yes | click | | trigger | HTMLElement | This element will be used to trigger the copy process | yes | | | source | HTMLElement | Element that you want to copy the value/text from | yes | | | success | Function | Function that will fired after copying is done | no | () => {} | | error | Function | Function that will fired after copying is failed | no | () => {} |

Options for paste

| Key | Type | Description | Required | Default Value | |---------|---------------------------------|------------------------------------------------------------------------------------------------------------------------|----------|---------------| | on | String | The event that will be used to trigger the element in the trigger option, must be valid event for addEventListener | yes | click | | trigger | HTMLElement | This element will be used to trigger the pasting process | yes | | | target | HTMLInputElement | HTMLElement | Target element that the value/text will replaced with a value from your clipboard | yes | | | success | Function | Function that will fired after pasting is done | no | () => {} | | error | Function | This function will fired if pasting are failed | no | () => {} |

Donate

If you have used this library and it's useful for you, please consider to donate:

Saweria

License

The KopasinJS is open-sourced software licensed under the MIT license.