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

@zag-js/clipboard

Package Overview
Dependencies
Maintainers
1
Versions
342
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zag-js/clipboard - npm Package Compare versions

Comparing version 0.0.0-dev-20240202223441 to 0.0.0-dev-20240203155634

71

dist/index.js

@@ -35,34 +35,11 @@ "use strict";

// src/clipboard.connect.ts
var import_dom_query = require("@zag-js/dom-query");
function connect(state, send, normalize) {
const isCopied = state.matches("copied");
return {
isCopied,
value: state.context.value,
setValue(value) {
send({ type: "VALUE.SET", value });
},
triggerProps: normalize.button({
...parts.trigger,
"data-copied": (0, import_dom_query.dataAttr)(isCopied),
onClick() {
send({ type: "COPY" });
}
}),
getIndicatorProps(props) {
return normalize.element({
...parts.indicator,
hidden: props.copied !== isCopied
});
}
};
}
var import_dom_query2 = require("@zag-js/dom-query");
// src/clipboard.machine.ts
var import_core = require("@zag-js/core");
var import_utils2 = require("@zag-js/utils");
// src/clipboard.dom.ts
var import_dom_query2 = require("@zag-js/dom-query");
var import_dom_query = require("@zag-js/dom-query");
var import_utils = require("@zag-js/utils");
var dom = (0, import_dom_query.createScope)({
getTriggerId: (ctx) => `clip-trigger-${ctx.id}`,
writeToClipboard: (ctx) => copyText(dom.getDoc(ctx), ctx.value)
});
function createNode(doc, text) {

@@ -79,10 +56,4 @@ const node = doc.createElement("pre");

}
var dom = (0, import_dom_query2.createScope)({
getRootId: (ctx) => `clip-${ctx.id}`,
getTriggerId: (ctx) => `clip-trigger-${ctx.id}`,
getIndicatorId: (ctx) => `clip-indicator-${ctx.id}`,
writeToClipboard: (ctx) => copyText(dom.getDoc(ctx), ctx.value)
});
function copyNode(node) {
const win = (0, import_dom_query2.getWindow)(node);
const win = (0, import_dom_query.getWindow)(node);
const selection = win.getSelection();

@@ -116,3 +87,31 @@ if (selection == null) {

// src/clipboard.connect.ts
function connect(state, send, normalize) {
const isCopied = state.matches("copied");
return {
isCopied,
value: state.context.value,
setValue(value) {
send({ type: "VALUE.SET", value });
},
triggerProps: normalize.button({
...parts.trigger.attrs,
id: dom.getTriggerId(state.context),
"data-copied": (0, import_dom_query2.dataAttr)(isCopied),
onClick() {
send({ type: "COPY" });
}
}),
getIndicatorProps(props) {
return normalize.element({
...parts.indicator.attrs,
hidden: props.copied !== isCopied
});
}
};
}
// src/clipboard.machine.ts
var import_core = require("@zag-js/core");
var import_utils2 = require("@zag-js/utils");
function machine(userContext) {

@@ -119,0 +118,0 @@ const ctx = (0, import_utils2.compact)(userContext);

{
"name": "@zag-js/clipboard",
"version": "0.0.0-dev-20240202223441",
"version": "0.0.0-dev-20240203155634",
"description": "Core logic for the clipboard widget implemented as a state machine",

@@ -31,7 +31,7 @@ "keywords": [

"dependencies": {
"@zag-js/anatomy": "0.0.0-dev-20240202223441",
"@zag-js/core": "0.0.0-dev-20240202223441",
"@zag-js/dom-query": "0.0.0-dev-20240202223441",
"@zag-js/utils": "0.0.0-dev-20240202223441",
"@zag-js/types": "0.0.0-dev-20240202223441"
"@zag-js/anatomy": "0.0.0-dev-20240203155634",
"@zag-js/core": "0.0.0-dev-20240203155634",
"@zag-js/dom-query": "0.0.0-dev-20240203155634",
"@zag-js/utils": "0.0.0-dev-20240203155634",
"@zag-js/types": "0.0.0-dev-20240203155634"
},

@@ -38,0 +38,0 @@ "devDependencies": {

@@ -5,2 +5,3 @@ import { dataAttr } from "@zag-js/dom-query"

import type { MachineApi, Send, State } from "./clipboard.types"
import { dom } from "./clipboard.dom"

@@ -17,3 +18,4 @@ export function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T> {

triggerProps: normalize.button({
...parts.trigger,
...parts.trigger.attrs,
id: dom.getTriggerId(state.context),
"data-copied": dataAttr(isCopied),

@@ -26,3 +28,3 @@ onClick() {

return normalize.element({
...parts.indicator,
...parts.indicator.attrs,
hidden: props.copied !== isCopied,

@@ -29,0 +31,0 @@ })

@@ -5,2 +5,7 @@ import { createScope, getWindow } from "@zag-js/dom-query"

export const dom = createScope({
getTriggerId: (ctx: Ctx) => `clip-trigger-${ctx.id}`,
writeToClipboard: (ctx: Ctx) => copyText(dom.getDoc(ctx), ctx.value),
})
function createNode(doc: Document, text: string): HTMLElement {

@@ -18,9 +23,2 @@ const node = doc.createElement("pre")

export const dom = createScope({
getRootId: (ctx: Ctx) => `clip-${ctx.id}`,
getTriggerId: (ctx: Ctx) => `clip-trigger-${ctx.id}`,
getIndicatorId: (ctx: Ctx) => `clip-indicator-${ctx.id}`,
writeToClipboard: (ctx: Ctx) => copyText(dom.getDoc(ctx), ctx.value),
})
function copyNode(node: HTMLElement): Promise<void> {

@@ -27,0 +25,0 @@ const win = getWindow(node)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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