Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stimulus-clipboard

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stimulus-clipboard - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

9

CHANGELOG.md

@@ -9,2 +9,11 @@ # Changelog

## [3.1.0] - 2022-04-15
### Chore
- Fixing stimulus as external library reducing bundle size from `1.59kb` to `0.25kb`.
- Updating Github Workflows.
- Upgrading Node to latest 16.
- Bump dependencies.
## [3.0.0] - 2021-09-28

@@ -11,0 +20,0 @@ ### Chore

34

dist/stimulus-clipboard.es.js

@@ -1,1 +0,33 @@

function t(t){return t.replace(/(?:[_-])([a-z0-9])/g,((t,e)=>e.toUpperCase()))}function e(t){return t.charAt(0).toUpperCase()+t.slice(1)}function r(t,e){const r=s(t);return Array.from(r.reduce(((t,r)=>(function(t,e){const r=t[e];return Array.isArray(r)?r:[]}(r,e).forEach((e=>t.add(e))),t)),new Set))}function n(t,e){return s(t).reduce(((t,r)=>(t.push(...function(t,e){const r=t[e];return r?Object.keys(r).map((t=>[t,r[t]])):[]}(r,e)),t)),[])}function s(t){const e=[];for(;t;)e.push(t),t=Object.getPrototypeOf(t);return e.reverse()}function a([e,r]){return function(e,r){const n=`${a=e,a.replace(/([A-Z])/g,((t,e)=>`-${e.toLowerCase()}`))}-value`,s=function(t){const e=function(t){const e=o(t.type);if(e){const r=u(t.default);if(e!==r)throw new Error(`Type "${e}" must match the type of the default value. Given default value: "${t.default}" as "${r}"`);return e}}(t),r=u(t),n=o(t),s=e||r||n;if(s)return s;throw new Error(`Unknown value type "${t}"`)}(r);var a;return{type:s,key:n,name:t(n),get defaultValue(){return function(t){const e=o(t);if(e)return c[e];const r=t.default;return void 0!==r?r:t}(r)},get hasCustomDefaultValue(){return void 0!==u(r)},reader:i[s],writer:l[s]||l.default}}(e,r)}function o(t){switch(t){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function u(t){switch(typeof t){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}return Array.isArray(t)?"array":"[object Object]"===Object.prototype.toString.call(t)?"object":void 0}(()=>{function t(t){function e(){return Reflect.construct(t,arguments,new.target)}return e.prototype=Object.create(t.prototype,{constructor:{value:e}}),Reflect.setPrototypeOf(e,t),e}try{(function(){const e=t((function(){this.a.call(this)}));e.prototype.a=function(){},new e})()}catch(e){return t=>class extends t{}}})();const c={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},i={array(t){const e=JSON.parse(t);if(!Array.isArray(e))throw new TypeError("Expected array");return e},boolean:t=>!("0"==t||"false"==t),number:t=>Number(t),object(t){const e=JSON.parse(t);if(null===e||"object"!=typeof e||Array.isArray(e))throw new TypeError("Expected object");return e},string:t=>t},l={default:function(t){return`${t}`},array:h,object:h};function h(t){return JSON.stringify(t)}class f{constructor(t){this.context=t}static get shouldLoad(){return!0}get application(){return this.context.application}get scope(){return this.context.scope}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get targets(){return this.scope.targets}get classes(){return this.scope.classes}get data(){return this.scope.data}initialize(){}connect(){}disconnect(){}dispatch(t,{target:e=this.element,detail:r={},prefix:n=this.identifier,bubbles:s=!0,cancelable:a=!0}={}){const o=new CustomEvent(n?`${n}:${t}`:t,{detail:r,bubbles:s,cancelable:a});return e.dispatchEvent(o),o}}f.blessings=[function(t){return r(t,"classes").reduce(((t,r)=>{return Object.assign(t,{[`${n=r}Class`]:{get(){const{classes:t}=this;if(t.has(n))return t.get(n);{const e=t.getAttributeName(n);throw new Error(`Missing attribute "${e}"`)}}},[`${n}Classes`]:{get(){return this.classes.getAll(n)}},[`has${e(n)}Class`]:{get(){return this.classes.has(n)}}});var n}),{})},function(t){return r(t,"targets").reduce(((t,r)=>{return Object.assign(t,{[`${n=r}Target`]:{get(){const t=this.targets.find(n);if(t)return t;throw new Error(`Missing target element "${n}" for "${this.identifier}" controller`)}},[`${n}Targets`]:{get(){return this.targets.findAll(n)}},[`has${e(n)}Target`]:{get(){return this.targets.has(n)}}});var n}),{})},function(t){const r=n(t,"values"),s={valueDescriptorMap:{get(){return r.reduce(((t,e)=>{const r=a(e),n=this.data.getAttributeNameForKey(r.key);return Object.assign(t,{[n]:r})}),{})}}};return r.reduce(((t,r)=>Object.assign(t,function(t){const r=a(t),{key:n,name:s,reader:o,writer:u}=r;return{[s]:{get(){const t=this.data.get(n);return null!==t?o(t):r.defaultValue},set(t){void 0===t?this.data.delete(n):this.data.set(n,u(t))}},[`has${e(s)}`]:{get(){return this.data.has(n)||r.hasCustomDefaultValue}}}}(r))),s)}],f.targets=[],f.values={};class g extends f{connect(){this.hasButtonTarget&&(this.originalText=this.buttonTarget.innerText)}copy(t){t.preventDefault(),this.sourceTarget.select(),document.execCommand("copy"),this.copied()}copied(){this.hasButtonTarget&&(this.timeout&&clearTimeout(this.timeout),this.buttonTarget.innerText=this.data.get("successContent"),this.timeout=setTimeout((()=>{this.buttonTarget.innerText=this.originalText}),this.successDurationValue))}}g.targets=["button","source"],g.values={successDuration:{type:Number,default:2e3}};export default g;
import { Controller } from "@hotwired/stimulus";
class src_default extends Controller {
connect() {
if (!this.hasButtonTarget)
return;
this.originalText = this.buttonTarget.innerText;
}
copy(event) {
event.preventDefault();
this.sourceTarget.select();
document.execCommand("copy");
this.copied();
}
copied() {
if (!this.hasButtonTarget)
return;
if (this.timeout) {
clearTimeout(this.timeout);
}
this.buttonTarget.innerText = this.data.get("successContent");
this.timeout = setTimeout(() => {
this.buttonTarget.innerText = this.originalText;
}, this.successDurationValue);
}
}
src_default.targets = ["button", "source"];
src_default.values = {
successDuration: {
type: Number,
default: 2e3
}
};
export { src_default as default };

2

dist/stimulus-clipboard.umd.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self)["stimulus-clipboard"]=e()}(this,(function(){"use strict";function t(t){return t.replace(/(?:[_-])([a-z0-9])/g,((t,e)=>e.toUpperCase()))}function e(t){return t.charAt(0).toUpperCase()+t.slice(1)}function r(t,e){const r=s(t);return Array.from(r.reduce(((t,r)=>(function(t,e){const r=t[e];return Array.isArray(r)?r:[]}(r,e).forEach((e=>t.add(e))),t)),new Set))}function n(t,e){return s(t).reduce(((t,r)=>(t.push(...function(t,e){const r=t[e];return r?Object.keys(r).map((t=>[t,r[t]])):[]}(r,e)),t)),[])}function s(t){const e=[];for(;t;)e.push(t),t=Object.getPrototypeOf(t);return e.reverse()}function a([e,r]){return function(e,r){const n=`${a=e,a.replace(/([A-Z])/g,((t,e)=>`-${e.toLowerCase()}`))}-value`,s=function(t){const e=function(t){const e=o(t.type);if(e){const r=u(t.default);if(e!==r)throw new Error(`Type "${e}" must match the type of the default value. Given default value: "${t.default}" as "${r}"`);return e}}(t),r=u(t),n=o(t),s=e||r||n;if(s)return s;throw new Error(`Unknown value type "${t}"`)}(r);var a;return{type:s,key:n,name:t(n),get defaultValue(){return function(t){const e=o(t);if(e)return i[e];const r=t.default;return void 0!==r?r:t}(r)},get hasCustomDefaultValue(){return void 0!==u(r)},reader:c[s],writer:l[s]||l.default}}(e,r)}function o(t){switch(t){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function u(t){switch(typeof t){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}return Array.isArray(t)?"array":"[object Object]"===Object.prototype.toString.call(t)?"object":void 0}(()=>{function t(t){function e(){return Reflect.construct(t,arguments,new.target)}return e.prototype=Object.create(t.prototype,{constructor:{value:e}}),Reflect.setPrototypeOf(e,t),e}try{(function(){const e=t((function(){this.a.call(this)}));e.prototype.a=function(){},new e})()}catch(e){return t=>class extends t{}}})();const i={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},c={array(t){const e=JSON.parse(t);if(!Array.isArray(e))throw new TypeError("Expected array");return e},boolean:t=>!("0"==t||"false"==t),number:t=>Number(t),object(t){const e=JSON.parse(t);if(null===e||"object"!=typeof e||Array.isArray(e))throw new TypeError("Expected object");return e},string:t=>t},l={default:function(t){return`${t}`},array:f,object:f};function f(t){return JSON.stringify(t)}class h{constructor(t){this.context=t}static get shouldLoad(){return!0}get application(){return this.context.application}get scope(){return this.context.scope}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get targets(){return this.scope.targets}get classes(){return this.scope.classes}get data(){return this.scope.data}initialize(){}connect(){}disconnect(){}dispatch(t,{target:e=this.element,detail:r={},prefix:n=this.identifier,bubbles:s=!0,cancelable:a=!0}={}){const o=new CustomEvent(n?`${n}:${t}`:t,{detail:r,bubbles:s,cancelable:a});return e.dispatchEvent(o),o}}h.blessings=[function(t){return r(t,"classes").reduce(((t,r)=>{return Object.assign(t,{[`${n=r}Class`]:{get(){const{classes:t}=this;if(t.has(n))return t.get(n);{const e=t.getAttributeName(n);throw new Error(`Missing attribute "${e}"`)}}},[`${n}Classes`]:{get(){return this.classes.getAll(n)}},[`has${e(n)}Class`]:{get(){return this.classes.has(n)}}});var n}),{})},function(t){return r(t,"targets").reduce(((t,r)=>{return Object.assign(t,{[`${n=r}Target`]:{get(){const t=this.targets.find(n);if(t)return t;throw new Error(`Missing target element "${n}" for "${this.identifier}" controller`)}},[`${n}Targets`]:{get(){return this.targets.findAll(n)}},[`has${e(n)}Target`]:{get(){return this.targets.has(n)}}});var n}),{})},function(t){const r=n(t,"values"),s={valueDescriptorMap:{get(){return r.reduce(((t,e)=>{const r=a(e),n=this.data.getAttributeNameForKey(r.key);return Object.assign(t,{[n]:r})}),{})}}};return r.reduce(((t,r)=>Object.assign(t,function(t){const r=a(t),{key:n,name:s,reader:o,writer:u}=r;return{[s]:{get(){const t=this.data.get(n);return null!==t?o(t):r.defaultValue},set(t){void 0===t?this.data.delete(n):this.data.set(n,u(t))}},[`has${e(s)}`]:{get(){return this.data.has(n)||r.hasCustomDefaultValue}}}}(r))),s)}],h.targets=[],h.values={};class g extends h{connect(){this.hasButtonTarget&&(this.originalText=this.buttonTarget.innerText)}copy(t){t.preventDefault(),this.sourceTarget.select(),document.execCommand("copy"),this.copied()}copied(){this.hasButtonTarget&&(this.timeout&&clearTimeout(this.timeout),this.buttonTarget.innerText=this.data.get("successContent"),this.timeout=setTimeout((()=>{this.buttonTarget.innerText=this.originalText}),this.successDurationValue))}}return g.targets=["button","source"],g.values={successDuration:{type:Number,default:2e3}},g}));
(function(e,t){typeof exports=="object"&&typeof module!="undefined"?module.exports=t(require("@hotwired/stimulus")):typeof define=="function"&&define.amd?define(["@hotwired/stimulus"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,e["stimulus-clipboard"]=t(e.Stimulus))})(this,function(e){"use strict";class t extends e.Controller{connect(){!this.hasButtonTarget||(this.originalText=this.buttonTarget.innerText)}copy(i){i.preventDefault(),this.sourceTarget.select(),document.execCommand("copy"),this.copied()}copied(){!this.hasButtonTarget||(this.timeout&&clearTimeout(this.timeout),this.buttonTarget.innerText=this.data.get("successContent"),this.timeout=setTimeout(()=>{this.buttonTarget.innerText=this.originalText},this.successDurationValue))}}return t.targets=["button","source"],t.values={successDuration:{type:Number,default:2e3}},t});
{
"name": "stimulus-clipboard",
"version": "3.0.0",
"version": "3.1.0",
"description": "A Stimulus controller to copy text to clipboard.",

@@ -32,11 +32,11 @@ "keywords": [

"devDependencies": {
"@babel/core": "7.14.3",
"@babel/core": "7.17.9",
"@babel/plugin-syntax-class-properties": "7.12.13",
"@babel/preset-env": "^7.14.4",
"@babel/preset-typescript": "^7.13.0",
"@hotwired/stimulus": "^3.0.0",
"np": "^7.5.0",
"@babel/preset-env": "^7.16.11",
"@babel/preset-typescript": "^7.16.7",
"@hotwired/stimulus": "^3.0.1",
"np": "^7.6.1",
"prettier-standard": "16.4.1",
"typescript": "^4.3.2",
"vite": "^2.3.6"
"typescript": "^4.6.3",
"vite": "^2.9.5"
},

@@ -43,0 +43,0 @@ "peerDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc