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

@ewc-lib/ewc-dialog-clipboard

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ewc-lib/ewc-dialog-clipboard - npm Package Compare versions

Comparing version 1.0.4-alpha to 1.0.5-alpha

9

package.json
{
"name": "@ewc-lib/ewc-dialog-clipboard",
"version": "1.0.4-alpha",
"version": "1.0.5-alpha",
"description": "",
"main": "src/main.js",
"scripts": {
},
"scripts": {},
"author": "",

@@ -14,5 +13,5 @@ "license": "EUPL v.1.1",

"dependencies": {
"@ewc-lib/ewc-css": "^0.8.0",
"@ewc-lib/ewc-dialog": "^2.0.1-alpha"
"@ewc-lib/ewc-css": "^0.12.5",
"@ewc-lib/ewc-dialog": "^2.0.5-alpha"
}
}

@@ -1,53 +0,74 @@

import * as HTML from "./html.js" // keep this file html free
import * as HTML from "./html.js"; // keep this file html free
import Dialog from "../../ewc-dialog/src/main.js"
import Dialog from "../../ewc-dialog/src/main.js";
class Element extends Dialog {
#isInitialized = false;
#clipboardContent = null;
#isInitialized=false
#clipboardContent = null
constructor() {
super();
}
constructor() {
super()
}
connectedCallback() {
if( this.#isInitialized ) { return }
connectedCallback() {
if (this.#isInitialized) {
return;
}
this.#isInitialized=true
super.connectedCallback()
this.#isInitialized = true;
super.connectedCallback();
this.#modifyParent()
this.#setupEventHandler()
}
this.#modifyParent();
this.#setupEventHandler();
}
set clipboardContent(val) {
this.#clipboardContent = val
}
// ... (No need for setFocusTrapElements() here) ...
set visible(val) {
this.querySelector(".ewc-notification--success").style.display = "none"
this.querySelector(".ewc-notification--error").style.display = "none"
super.visible=val
super.focusTrap.setFirstElement( this.querySelector(".ewc-dialog__top-copy-image").closest("button") )
super.focusTrap.setLastElement(this.querySelector(".ewc-dialog__top-close-image").closest("button"))
}
set clipboardContent(val) {
this.#clipboardContent = val;
}
#modifyParent() {
const titleEl = this.querySelector(".ewc-dialog__title")
titleEl.insertAdjacentElement("afterend", HTML.button().firstElementChild)
titleEl.style.flexGrow = "unset"
this.querySelector(".ewc-dialog__content").appendChild(HTML.footer())
}
set visible(val) {
this.querySelector(".ewc-notification--success").style.display = "none";
this.querySelector(".ewc-notification--error").style.display = "none";
super.visible = val;
#setupEventHandler() {
this.querySelector(".ewc-dialog__top-copy-image").addEventListener("click", this.#copyToClipboard.bind(this))
this.querySelector(".ewc-dialog__top-copy-image").closest("button").addEventListener("keydown", (ev)=>{
if(ev.key==="Enter"||ev.key===" "){
this.#copyToClipboard(this)
}
})
}
// ... (No need to set focus trap elements here) ...
}
#modifyParent() {
const titleEl = this.querySelector(".ewc-dialog__title");
titleEl.insertAdjacentElement("afterend", HTML.button().firstElementChild);
titleEl.style.flexGrow = "unset";
this.querySelector(".ewc-dialog__content").appendChild(HTML.footer());
}
#setupEventHandler() {
this.querySelector(".ewc-dialog__top-copy-image").addEventListener(
"click",
this.#copyToClipboard.bind(this),
);
this.querySelector(".ewc-dialog__top-copy-image")
.closest("button")
.addEventListener("keydown", (ev) => {
if (ev.key === "Enter" || ev.key === " ") {
this.#copyToClipboard(this);
}
});
}
async #copyToClipboard() {
if (this.#clipboardContent != null) {
try {
await navigator.clipboard.writeText(this.#clipboardContent);
this.querySelector(".ewc-notification--success").style.display = "flex";
} catch (error) {
this.querySelector(".ewc-notification--error").style.display = "flex";
}
} else {
console.warn("No clipboard content");
}
}
async #copyToClipboard() {

@@ -71,2 +92,2 @@ if(this.#clipboardContent != null) {

document.body.append(HTML.getSvg())
}
}
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