New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ngx-clipboard

Package Overview
Dependencies
Maintainers
1
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-clipboard - npm Package Compare versions

Comparing version

to
7.0.5-beta0

dist/index.metadata.json

3

dist/bundles/ngxClipboard.umd.js

@@ -189,4 +189,3 @@ (function (global, factory) {

__param(0, _angular_core.Inject(DOCUMENT)),
__metadata$1("design:paramtypes", [Document,
WindowSrv])
__metadata$1("design:paramtypes", [Object, WindowSrv])
], ClipboardService);

@@ -193,0 +192,0 @@ /**

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

(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@angular/core"),require("@angular/common")):typeof define==="function"&&define.amd?define(["exports","@angular/core","@angular/common"],factory):factory((global.ngx=global.ngx||{},global.ngx.clipboard=global.ngx.clipboard||{}),global.ng.core,global.ng.common)})(this,function(exports,_angular_core,_angular_common){"use strict";var __decorate$3=undefined&&undefined.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r};function _window(){return window}var WindowSrv=function(){function WindowSrv(){}Object.defineProperty(WindowSrv.prototype,"nativeWindow",{get:function(){return _window()},enumerable:true,configurable:true});return WindowSrv}();WindowSrv=__decorate$3([_angular_core.Injectable()],WindowSrv);var DOCUMENT=new _angular_core.OpaqueToken("DOCUMENT");function _document(){return document}var __decorate$2=undefined&&undefined.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r};var __metadata$1=undefined&&undefined.__metadata||function(k,v){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(k,v)};var __param=undefined&&undefined.__param||function(paramIndex,decorator){return function(target,key){decorator(target,key,paramIndex)}};var ClipboardService=function(){function ClipboardService(document,windowService){this.document=document;this.windowService=windowService;this.window=this.windowService.nativeWindow}Object.defineProperty(ClipboardService.prototype,"isSupported",{get:function(){return!!this.document.queryCommandSupported&&!!this.document.queryCommandSupported("copy")},enumerable:true,configurable:true});ClipboardService.prototype.isTargetValid=function(element){if(element instanceof HTMLInputElement||element instanceof HTMLTextAreaElement){if(element.hasAttribute("disabled")){throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute')}return true}throw new Error("Target should be input or textarea")};ClipboardService.prototype.copyFromInputElement=function(targetElm,renderer){try{this.selectTarget(targetElm,renderer);var re=this.copyText();this.clearSelection(targetElm,this.window);return re}catch(error){return false}};ClipboardService.prototype.copyFromContent=function(content,renderer){if(!this.tempTextArea){this.tempTextArea=this.createTempTextArea(this.document,this.window);this.document.body.appendChild(this.tempTextArea)}this.tempTextArea.value=content;return this.copyFromInputElement(this.tempTextArea,renderer)};ClipboardService.prototype.destroy=function(){if(this.tempTextArea){this.document.body.removeChild(this.tempTextArea);this.tempTextArea=undefined}};ClipboardService.prototype.selectTarget=function(inputElement,renderer){renderer.invokeElementMethod(inputElement,"select");renderer.invokeElementMethod(inputElement,"setSelectionRange",[0,inputElement.value.length]);return inputElement.value.length};ClipboardService.prototype.copyText=function(){return this.document.execCommand("copy")};ClipboardService.prototype.clearSelection=function(inputElement,window){inputElement&&inputElement.blur();window.getSelection().removeAllRanges()};ClipboardService.prototype.createTempTextArea=function(doc,window){var isRTL=doc.documentElement.getAttribute("dir")==="rtl";var ta;ta=doc.createElement("textarea");ta.style.fontSize="12pt";ta.style.border="0";ta.style.padding="0";ta.style.margin="0";ta.style.position="absolute";ta.style[isRTL?"right":"left"]="-9999px";var yPosition=window.pageYOffset||doc.documentElement.scrollTop;ta.style.top=yPosition+"px";ta.setAttribute("readonly","");return ta};return ClipboardService}();ClipboardService=__decorate$2([_angular_core.Injectable(),__param(0,_angular_core.Inject(DOCUMENT)),__metadata$1("design:paramtypes",[Document,WindowSrv])],ClipboardService);function CLIPBOARD_SERVICE_PROVIDER_FACTORY(doc,windowSrv,parentDispatcher){return parentDispatcher||new ClipboardService(doc,windowSrv)}var CLIPBOARD_SERVICE_PROVIDER={provide:ClipboardService,useFactory:CLIPBOARD_SERVICE_PROVIDER_FACTORY,deps:[DOCUMENT,WindowSrv,[new _angular_core.Optional,new _angular_core.SkipSelf,ClipboardService]]};var __decorate$1=undefined&&undefined.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r};var __metadata=undefined&&undefined.__metadata||function(k,v){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(k,v)};exports.ClipboardDirective=function(){function ClipboardDirective(clipboardSrv,renderer){this.clipboardSrv=clipboardSrv;this.renderer=renderer;this.cbOnSuccess=new _angular_core.EventEmitter;this.cbOnError=new _angular_core.EventEmitter}ClipboardDirective.prototype.ngOnInit=function(){if(!this.clipboardSrv.isSupported){throw new Error("Your environment does not support copy.")}};ClipboardDirective.prototype.ngOnDestroy=function(){this.clipboardSrv.destroy()};ClipboardDirective.prototype.onClick=function(button){if(this.targetElm&&this.clipboardSrv.isTargetValid(this.targetElm)){this.handleResult(this.clipboardSrv.copyFromInputElement(this.targetElm,this.renderer),this.targetElm.value)}else if(this.cbContent){this.handleResult(this.clipboardSrv.copyFromContent(this.cbContent,this.renderer),this.cbContent)}};ClipboardDirective.prototype.handleResult=function(succeeded,copiedContent){if(succeeded){this.cbOnSuccess.emit({isSuccess:true,content:copiedContent})}else{this.cbOnError.emit({isSuccess:false})}};return ClipboardDirective}();__decorate$1([_angular_core.Input("ngxClipboard"),__metadata("design:type",HTMLInputElement)],exports.ClipboardDirective.prototype,"targetElm",void 0);__decorate$1([_angular_core.Input(),__metadata("design:type",String)],exports.ClipboardDirective.prototype,"cbContent",void 0);__decorate$1([_angular_core.Output(),__metadata("design:type",_angular_core.EventEmitter)],exports.ClipboardDirective.prototype,"cbOnSuccess",void 0);__decorate$1([_angular_core.Output(),__metadata("design:type",_angular_core.EventEmitter)],exports.ClipboardDirective.prototype,"cbOnError",void 0);__decorate$1([_angular_core.HostListener("click",["$event.target"]),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",void 0)],exports.ClipboardDirective.prototype,"onClick",null);exports.ClipboardDirective=__decorate$1([_angular_core.Directive({selector:"[ngxClipboard]"}),__metadata("design:paramtypes",[ClipboardService,_angular_core.Renderer])],exports.ClipboardDirective);var __decorate=undefined&&undefined.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r};exports.ClipboardModule=function(){function ClipboardModule(){}return ClipboardModule}();exports.ClipboardModule=__decorate([_angular_core.NgModule({declarations:[exports.ClipboardDirective],exports:[exports.ClipboardDirective],imports:[_angular_common.CommonModule],providers:[{provide:DOCUMENT,useFactory:_document},WindowSrv,CLIPBOARD_SERVICE_PROVIDER]})],exports.ClipboardModule);Object.defineProperty(exports,"__esModule",{value:true})});
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@angular/core"),require("@angular/common")):typeof define==="function"&&define.amd?define(["exports","@angular/core","@angular/common"],factory):factory((global.ngx=global.ngx||{},global.ngx.clipboard=global.ngx.clipboard||{}),global.ng.core,global.ng.common)})(this,function(exports,_angular_core,_angular_common){"use strict";var __decorate$3=undefined&&undefined.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r};function _window(){return window}var WindowSrv=function(){function WindowSrv(){}Object.defineProperty(WindowSrv.prototype,"nativeWindow",{get:function(){return _window()},enumerable:true,configurable:true});return WindowSrv}();WindowSrv=__decorate$3([_angular_core.Injectable()],WindowSrv);var DOCUMENT=new _angular_core.OpaqueToken("DOCUMENT");function _document(){return document}var __decorate$2=undefined&&undefined.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r};var __metadata$1=undefined&&undefined.__metadata||function(k,v){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(k,v)};var __param=undefined&&undefined.__param||function(paramIndex,decorator){return function(target,key){decorator(target,key,paramIndex)}};var ClipboardService=function(){function ClipboardService(document,windowService){this.document=document;this.windowService=windowService;this.window=this.windowService.nativeWindow}Object.defineProperty(ClipboardService.prototype,"isSupported",{get:function(){return!!this.document.queryCommandSupported&&!!this.document.queryCommandSupported("copy")},enumerable:true,configurable:true});ClipboardService.prototype.isTargetValid=function(element){if(element instanceof HTMLInputElement||element instanceof HTMLTextAreaElement){if(element.hasAttribute("disabled")){throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute')}return true}throw new Error("Target should be input or textarea")};ClipboardService.prototype.copyFromInputElement=function(targetElm,renderer){try{this.selectTarget(targetElm,renderer);var re=this.copyText();this.clearSelection(targetElm,this.window);return re}catch(error){return false}};ClipboardService.prototype.copyFromContent=function(content,renderer){if(!this.tempTextArea){this.tempTextArea=this.createTempTextArea(this.document,this.window);this.document.body.appendChild(this.tempTextArea)}this.tempTextArea.value=content;return this.copyFromInputElement(this.tempTextArea,renderer)};ClipboardService.prototype.destroy=function(){if(this.tempTextArea){this.document.body.removeChild(this.tempTextArea);this.tempTextArea=undefined}};ClipboardService.prototype.selectTarget=function(inputElement,renderer){renderer.invokeElementMethod(inputElement,"select");renderer.invokeElementMethod(inputElement,"setSelectionRange",[0,inputElement.value.length]);return inputElement.value.length};ClipboardService.prototype.copyText=function(){return this.document.execCommand("copy")};ClipboardService.prototype.clearSelection=function(inputElement,window){inputElement&&inputElement.blur();window.getSelection().removeAllRanges()};ClipboardService.prototype.createTempTextArea=function(doc,window){var isRTL=doc.documentElement.getAttribute("dir")==="rtl";var ta;ta=doc.createElement("textarea");ta.style.fontSize="12pt";ta.style.border="0";ta.style.padding="0";ta.style.margin="0";ta.style.position="absolute";ta.style[isRTL?"right":"left"]="-9999px";var yPosition=window.pageYOffset||doc.documentElement.scrollTop;ta.style.top=yPosition+"px";ta.setAttribute("readonly","");return ta};return ClipboardService}();ClipboardService=__decorate$2([_angular_core.Injectable(),__param(0,_angular_core.Inject(DOCUMENT)),__metadata$1("design:paramtypes",[Object,WindowSrv])],ClipboardService);function CLIPBOARD_SERVICE_PROVIDER_FACTORY(doc,windowSrv,parentDispatcher){return parentDispatcher||new ClipboardService(doc,windowSrv)}var CLIPBOARD_SERVICE_PROVIDER={provide:ClipboardService,useFactory:CLIPBOARD_SERVICE_PROVIDER_FACTORY,deps:[DOCUMENT,WindowSrv,[new _angular_core.Optional,new _angular_core.SkipSelf,ClipboardService]]};var __decorate$1=undefined&&undefined.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r};var __metadata=undefined&&undefined.__metadata||function(k,v){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(k,v)};exports.ClipboardDirective=function(){function ClipboardDirective(clipboardSrv,renderer){this.clipboardSrv=clipboardSrv;this.renderer=renderer;this.cbOnSuccess=new _angular_core.EventEmitter;this.cbOnError=new _angular_core.EventEmitter}ClipboardDirective.prototype.ngOnInit=function(){if(!this.clipboardSrv.isSupported){throw new Error("Your environment does not support copy.")}};ClipboardDirective.prototype.ngOnDestroy=function(){this.clipboardSrv.destroy()};ClipboardDirective.prototype.onClick=function(button){if(this.targetElm&&this.clipboardSrv.isTargetValid(this.targetElm)){this.handleResult(this.clipboardSrv.copyFromInputElement(this.targetElm,this.renderer),this.targetElm.value)}else if(this.cbContent){this.handleResult(this.clipboardSrv.copyFromContent(this.cbContent,this.renderer),this.cbContent)}};ClipboardDirective.prototype.handleResult=function(succeeded,copiedContent){if(succeeded){this.cbOnSuccess.emit({isSuccess:true,content:copiedContent})}else{this.cbOnError.emit({isSuccess:false})}};return ClipboardDirective}();__decorate$1([_angular_core.Input("ngxClipboard"),__metadata("design:type",HTMLInputElement)],exports.ClipboardDirective.prototype,"targetElm",void 0);__decorate$1([_angular_core.Input(),__metadata("design:type",String)],exports.ClipboardDirective.prototype,"cbContent",void 0);__decorate$1([_angular_core.Output(),__metadata("design:type",_angular_core.EventEmitter)],exports.ClipboardDirective.prototype,"cbOnSuccess",void 0);__decorate$1([_angular_core.Output(),__metadata("design:type",_angular_core.EventEmitter)],exports.ClipboardDirective.prototype,"cbOnError",void 0);__decorate$1([_angular_core.HostListener("click",["$event.target"]),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",void 0)],exports.ClipboardDirective.prototype,"onClick",null);exports.ClipboardDirective=__decorate$1([_angular_core.Directive({selector:"[ngxClipboard]"}),__metadata("design:paramtypes",[ClipboardService,_angular_core.Renderer])],exports.ClipboardDirective);var __decorate=undefined&&undefined.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r};exports.ClipboardModule=function(){function ClipboardModule(){}return ClipboardModule}();exports.ClipboardModule=__decorate([_angular_core.NgModule({declarations:[exports.ClipboardDirective],exports:[exports.ClipboardDirective],imports:[_angular_common.CommonModule],providers:[{provide:DOCUMENT,useFactory:_document},WindowSrv,CLIPBOARD_SERVICE_PROVIDER]})],exports.ClipboardModule);Object.defineProperty(exports,"__esModule",{value:true})});

@@ -10,28 +10,11 @@ import { ClipboardService } from './clipboard.service';

cbOnError: EventEmitter<any>;
/**
* @param {?} clipboardSrv
* @param {?} renderer
*/
constructor(clipboardSrv: ClipboardService, renderer: Renderer);
/**
* @return {?}
*/
ngOnInit(): void;
/**
* @return {?}
*/
ngOnDestroy(): void;
onClick(button: any): void;
/**
* @param {?} button
* @return {?}
*/
private onClick(button);
/**
* Fires an event based on the copy operation result.
\@param {Boolean} succeeded
* @param {?} succeeded
* @param {?} copiedContent
* @return {?}
* @param {Boolean} succeeded
*/
private handleResult(succeeded, copiedContent);
}

@@ -8,21 +8,7 @@ import { WindowSrv } from './window.service';

private window;
/**
* @param {?} document
* @param {?} windowService
*/
constructor(document: Document, windowService: WindowSrv);
/**
* @return {?}
*/
constructor(document: any, windowService: WindowSrv);
readonly isSupported: boolean;
/**
* @param {?} element
* @return {?}
*/
isTargetValid(element: HTMLInputElement | HTMLTextAreaElement): boolean;
/**
* copyFromInputElement
* @param {?} targetElm
* @param {?} renderer
* @return {?}
*/

@@ -32,41 +18,11 @@ copyFromInputElement(targetElm: HTMLInputElement | HTMLTextAreaElement, renderer: Renderer): boolean;

* Creates a fake textarea element, sets its value from `text` property,
and makes a selection on it.
* @param {?} content
* @param {?} renderer
* @return {?}
* and makes a selection on it.
*/
copyFromContent(content: string, renderer: Renderer): boolean;
/**
* @return {?}
*/
destroy(): void;
/**
* @param {?} inputElement
* @param {?} renderer
* @return {?}
*/
private selectTarget(inputElement, renderer);
/**
* @return {?}
*/
private copyText();
/**
* @param {?} inputElement
* @param {?} window
* @return {?}
*/
private clearSelection(inputElement, window);
/**
* @param {?} doc
* @param {?} window
* @return {?}
*/
private createTempTextArea(doc, window);
}
/**
* @param {?} doc
* @param {?} windowSrv
* @param {?} parentDispatcher
* @return {?}
*/
export declare function CLIPBOARD_SERVICE_PROVIDER_FACTORY(doc: any, windowSrv: WindowSrv, parentDispatcher: ClipboardService): ClipboardService;

@@ -73,0 +29,0 @@ export declare const CLIPBOARD_SERVICE_PROVIDER: {

@@ -146,4 +146,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

__param(0, Inject(DOCUMENT)),
__metadata("design:paramtypes", [Document,
WindowSrv])
__metadata("design:paramtypes", [Object, WindowSrv])
], ClipboardService);

@@ -150,0 +149,0 @@ export { ClipboardService };

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

export { ClipboardDirective } from './clipboard.directive';
export { ClipboardService, CLIPBOARD_SERVICE_PROVIDER_FACTORY, CLIPBOARD_SERVICE_PROVIDER } from './clipboard.service';
export * from './clipboard.directive';
export * from './clipboard.service';
export declare class ClipboardModule {
}

@@ -6,3 +6,3 @@ {

"module": "./dist/index.js",
"version": "7.0.4",
"version": "7.0.5-beta0",
"author": {

@@ -9,0 +9,0 @@ "name": "Sam Lin",

@@ -31,3 +31,3 @@ import { ClipboardService } from './clipboard.service';

@HostListener('click', ['$event.target']) private onClick(button) {
@HostListener('click', ['$event.target']) public onClick(button) {
if (this.targetElm && this.clipboardSrv.isTargetValid(this.targetElm)) {

@@ -34,0 +34,0 @@ this.handleResult(this.clipboardSrv.copyFromInputElement(this.targetElm, this.renderer),

@@ -11,3 +11,3 @@ import { WindowSrv } from './window.service';

constructor(
@Inject(DOCUMENT) private document: Document,
@Inject(DOCUMENT) private document,
private windowService: WindowSrv

@@ -14,0 +14,0 @@ ) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet