@protonradio/proton-ui 0.11.18-beta.5 → 0.11.18-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../../node_modules/react/jsx-runtime.cjs.js"),x=require("react"),c=require("../../../utils/copy.cjs.js"),a=require("../BaseInput/Input.cjs.js");;/* empty css */const r=require("../../../utils/string.cjs.js");function l({name:o,value:e,isDisabled:p,onError:i,onSuccess:n}){const[u,s]=x.useState(!1);return t.jsxRuntimeExports.jsx(a.Input,{name:o,value:e,isDisabled:p,suffix:t.jsxRuntimeExports.jsx(j,{isCopied:u,onClick:async()=>{console.log("copy button clicked",{value:e}),await c.copyTextToClipboard(e,i)&&(s(!0),n==null||n(),setTimeout(()=>s(!1),5e3))}})})}const j=({isCopied:o,onClick:e})=>t.jsxRuntimeExports.jsx("div",{className:"proton-CopyInput-button-container",onClick:e,children:t.jsxRuntimeExports.jsxs("button",{"data-testid":"COPY_BUTTON",className:r.csx("proton-CopyInput-button",o&&"proton-CopyInput-button--copied"),children:[t.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 512 512",children:[t.jsxRuntimeExports.jsx("path",{fill:"currentColor",d:"M408 480H184a72 72 0 0 1-72-72V184a72 72 0 0 1 72-72h224a72 72 0 0 1 72 72v224a72 72 0 0 1-72 72"}),t.jsxRuntimeExports.jsx("path",{fill:"currentColor",d:"M160 80h235.88A72.12 72.12 0 0 0 328 32H104a72 72 0 0 0-72 72v224a72.12 72.12 0 0 0 48 67.88V160a80 80 0 0 1 80-80"})]}),t.jsxRuntimeExports.jsx("span",{className:r.csx("proton-CopyInput-button-text",o&&"proton-CopyInput-button-text--copied"),children:o?"Copied!":"Copy"})]})});exports.CopyInput=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../../node_modules/react/jsx-runtime.cjs.js"),x=require("react"),a=require("../../../utils/copy.cjs.js"),c=require("../BaseInput/Input.cjs.js");;/* empty css */const r=require("../../../utils/string.cjs.js");function l({name:o,value:e,isDisabled:p,onError:u,onSuccess:n}){const[i,s]=x.useState(!1);return t.jsxRuntimeExports.jsx(c.Input,{name:o,value:e,isDisabled:p,suffix:t.jsxRuntimeExports.jsx(j,{isCopied:i,onClick:async()=>{await a.copyTextToClipboard(e,u)&&(s(!0),n==null||n(),setTimeout(()=>s(!1),5e3))}})})}const j=({isCopied:o,onClick:e})=>t.jsxRuntimeExports.jsx("div",{className:"proton-CopyInput-button-container",children:t.jsxRuntimeExports.jsxs("button",{"data-testid":"COPY_BUTTON",className:r.csx("proton-CopyInput-button",o&&"proton-CopyInput-button--copied"),onClick:e,type:"button",children:[t.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 512 512",children:[t.jsxRuntimeExports.jsx("path",{fill:"currentColor",d:"M408 480H184a72 72 0 0 1-72-72V184a72 72 0 0 1 72-72h224a72 72 0 0 1 72 72v224a72 72 0 0 1-72 72"}),t.jsxRuntimeExports.jsx("path",{fill:"currentColor",d:"M160 80h235.88A72.12 72.12 0 0 0 328 32H104a72 72 0 0 0-72 72v224a72.12 72.12 0 0 0 48 67.88V160a80 80 0 0 1 80-80"})]}),t.jsxRuntimeExports.jsx("span",{className:r.csx("proton-CopyInput-button-text",o&&"proton-CopyInput-button-text--copied"),children:o?"Copied!":"Copy"})]})});exports.CopyInput=l;
2
2
  //# sourceMappingURL=CopyInput.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CopyInput.cjs.js","sources":["../../../../src/components/Input/CopyInput/CopyInput.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { csx } from \"../../../utils\";\nimport { copyTextToClipboard } from \"../../../utils/copy\";\nimport { Input } from \"../BaseInput/Input\";\nimport \"./CopyInput.css\";\n\nexport interface CopyInputProps {\n /** The name of the input field */\n name: string;\n\n /** The value to display in the input and copy to clipboard */\n value: string;\n\n /** Whether the input is disabled */\n isDisabled?: boolean;\n\n /** Optional callback when copy fails, receives the error object */\n onError?: (error: Error) => void;\n\n /** Optional callback when copy succeeds */\n onSuccess?: () => void;\n}\n\n/**\n * Input with a button to copy value to the clipboard.\n *\n * API:\n * - {@link CopyInputProps}\n */\nexport function CopyInput({\n name,\n value,\n isDisabled,\n onError,\n onSuccess,\n}: CopyInputProps) {\n const [isCopied, setCopied] = useState(false);\n\n return (\n <Input\n name={name}\n value={value}\n isDisabled={isDisabled}\n suffix={\n <CopyButton\n isCopied={isCopied}\n onClick={async () => {\n console.log(\"copy button clicked\", { value})\n\n const copySuccess = await copyTextToClipboard(value, onError);\n if (!copySuccess) return;\n\n setCopied(true);\n onSuccess?.();\n setTimeout(() => setCopied(false), 5000);\n }}\n />\n }\n />\n );\n}\n\nconst CopyButton = ({ isCopied, onClick }) => {\n return (\n <div className=\"proton-CopyInput-button-container\" onClick={onClick}>\n <button\n data-testid=\"COPY_BUTTON\"\n className={csx(\n \"proton-CopyInput-button\",\n isCopied && \"proton-CopyInput-button--copied\"\n )}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 512 512\"\n >\n <path\n fill=\"currentColor\"\n d=\"M408 480H184a72 72 0 0 1-72-72V184a72 72 0 0 1 72-72h224a72 72 0 0 1 72 72v224a72 72 0 0 1-72 72\"\n />\n <path\n fill=\"currentColor\"\n d=\"M160 80h235.88A72.12 72.12 0 0 0 328 32H104a72 72 0 0 0-72 72v224a72.12 72.12 0 0 0 48 67.88V160a80 80 0 0 1 80-80\"\n />\n </svg>\n <span\n className={csx(\n \"proton-CopyInput-button-text\",\n isCopied && \"proton-CopyInput-button-text--copied\"\n )}\n >\n {isCopied ? \"Copied!\" : \"Copy\"}\n </span>\n </button>\n </div>\n );\n};\n"],"names":["CopyInput","name","value","isDisabled","onError","onSuccess","isCopied","setCopied","useState","jsx","Input","CopyButton","copyTextToClipboard","onClick","jsxs","csx"],"mappings":"sUA6BO,SAASA,EAAU,CACxB,KAAAC,EACA,MAAAC,EACA,WAAAC,EACA,QAAAC,EACA,UAAAC,CACF,EAAmB,CACjB,KAAM,CAACC,EAAUC,CAAS,EAAIC,WAAS,EAAK,EAG1C,OAAAC,EAAA,kBAAA,IAACC,EAAA,MAAA,CACC,KAAAT,EACA,MAAAC,EACA,WAAAC,EACA,OACEM,EAAA,kBAAA,IAACE,EAAA,CACC,SAAAL,EACA,QAAS,SAAY,CACnB,QAAQ,IAAI,sBAAuB,CAAE,MAAAJ,CAAM,CAAA,EAEvB,MAAMU,EAAAA,oBAAoBV,EAAOE,CAAO,IAG5DG,EAAU,EAAI,EACFF,GAAA,MAAAA,IACZ,WAAW,IAAME,EAAU,EAAK,EAAG,GAAI,EACzC,CAAA,CACF,CAAA,CAAA,CAIR,CAEA,MAAMI,EAAa,CAAC,CAAE,SAAAL,EAAU,QAAAO,KAE3BJ,EAAAA,kBAAAA,IAAA,MAAA,CAAI,UAAU,oCAAoC,QAAAI,EACjD,SAAAC,EAAA,kBAAA,KAAC,SAAA,CACC,cAAY,cACZ,UAAWC,EAAA,IACT,0BACAT,GAAY,iCACd,EAEA,SAAA,CAAAQ,EAAA,kBAAA,KAAC,MAAA,CACC,MAAM,6BACN,MAAM,KACN,OAAO,KACP,QAAQ,cAER,SAAA,CAAAL,EAAA,kBAAA,IAAC,OAAA,CACC,KAAK,eACL,EAAE,kGAAA,CACJ,EACAA,EAAA,kBAAA,IAAC,OAAA,CACC,KAAK,eACL,EAAE,oHAAA,CACJ,CAAA,CAAA,CACF,EACAA,EAAA,kBAAA,IAAC,OAAA,CACC,UAAWM,EAAA,IACT,+BACAT,GAAY,sCACd,EAEC,WAAW,UAAY,MAAA,CAC1B,CAAA,CAAA,CAEJ,CAAA,CAAA"}
1
+ {"version":3,"file":"CopyInput.cjs.js","sources":["../../../../src/components/Input/CopyInput/CopyInput.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { csx } from \"../../../utils\";\nimport { copyTextToClipboard } from \"../../../utils/copy\";\nimport { Input } from \"../BaseInput/Input\";\nimport \"./CopyInput.css\";\n\nexport interface CopyInputProps {\n /** The name of the input field */\n name: string;\n\n /** The value to display in the input and copy to clipboard */\n value: string;\n\n /** Whether the input is disabled */\n isDisabled?: boolean;\n\n /** Optional callback when copy fails, receives the error object */\n onError?: (error: Error) => void;\n\n /** Optional callback when copy succeeds */\n onSuccess?: () => void;\n}\n\n/**\n * Input with a button to copy value to the clipboard.\n *\n * API:\n * - {@link CopyInputProps}\n */\nexport function CopyInput({\n name,\n value,\n isDisabled,\n onError,\n onSuccess,\n}: CopyInputProps) {\n const [isCopied, setCopied] = useState(false);\n\n return (\n <Input\n name={name}\n value={value}\n isDisabled={isDisabled}\n suffix={\n <CopyButton\n isCopied={isCopied}\n onClick={async () => {\n const copySuccess = await copyTextToClipboard(value, onError);\n if (!copySuccess) return;\n\n setCopied(true);\n onSuccess?.();\n setTimeout(() => setCopied(false), 5000);\n }}\n />\n }\n />\n );\n}\n\nconst CopyButton = ({ isCopied, onClick }) => {\n return (\n <div className=\"proton-CopyInput-button-container\">\n <button\n data-testid=\"COPY_BUTTON\"\n className={csx(\n \"proton-CopyInput-button\",\n isCopied && \"proton-CopyInput-button--copied\"\n )}\n onClick={onClick}\n type=\"button\"\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 512 512\"\n >\n <path\n fill=\"currentColor\"\n d=\"M408 480H184a72 72 0 0 1-72-72V184a72 72 0 0 1 72-72h224a72 72 0 0 1 72 72v224a72 72 0 0 1-72 72\"\n />\n <path\n fill=\"currentColor\"\n d=\"M160 80h235.88A72.12 72.12 0 0 0 328 32H104a72 72 0 0 0-72 72v224a72.12 72.12 0 0 0 48 67.88V160a80 80 0 0 1 80-80\"\n />\n </svg>\n <span\n className={csx(\n \"proton-CopyInput-button-text\",\n isCopied && \"proton-CopyInput-button-text--copied\"\n )}\n >\n {isCopied ? \"Copied!\" : \"Copy\"}\n </span>\n </button>\n </div>\n );\n};\n"],"names":["CopyInput","name","value","isDisabled","onError","onSuccess","isCopied","setCopied","useState","jsx","Input","CopyButton","copyTextToClipboard","onClick","jsxs","csx"],"mappings":"sUA6BO,SAASA,EAAU,CACxB,KAAAC,EACA,MAAAC,EACA,WAAAC,EACA,QAAAC,EACA,UAAAC,CACF,EAAmB,CACjB,KAAM,CAACC,EAAUC,CAAS,EAAIC,WAAS,EAAK,EAG1C,OAAAC,EAAA,kBAAA,IAACC,EAAA,MAAA,CACC,KAAAT,EACA,MAAAC,EACA,WAAAC,EACA,OACEM,EAAA,kBAAA,IAACE,EAAA,CACC,SAAAL,EACA,QAAS,SAAY,CACC,MAAMM,EAAAA,oBAAoBV,EAAOE,CAAO,IAG5DG,EAAU,EAAI,EACFF,GAAA,MAAAA,IACZ,WAAW,IAAME,EAAU,EAAK,EAAG,GAAI,EACzC,CAAA,CACF,CAAA,CAAA,CAIR,CAEA,MAAMI,EAAa,CAAC,CAAE,SAAAL,EAAU,QAAAO,KAE5BJ,EAAAA,kBAAAA,IAAC,MAAI,CAAA,UAAU,oCACb,SAAAK,EAAA,kBAAA,KAAC,SAAA,CACC,cAAY,cACZ,UAAWC,EAAA,IACT,0BACAT,GAAY,iCACd,EACA,QAAAO,EACA,KAAK,SAEL,SAAA,CAAAC,EAAA,kBAAA,KAAC,MAAA,CACC,MAAM,6BACN,MAAM,KACN,OAAO,KACP,QAAQ,cAER,SAAA,CAAAL,EAAA,kBAAA,IAAC,OAAA,CACC,KAAK,eACL,EAAE,kGAAA,CACJ,EACAA,EAAA,kBAAA,IAAC,OAAA,CACC,KAAK,eACL,EAAE,oHAAA,CACJ,CAAA,CAAA,CACF,EACAA,EAAA,kBAAA,IAAC,OAAA,CACC,UAAWM,EAAA,IACT,+BACAT,GAAY,sCACd,EAEC,WAAW,UAAY,MAAA,CAC1B,CAAA,CAAA,CAEJ,CAAA,CAAA"}
@@ -1,7 +1,7 @@
1
1
  import { j as t } from "../../../node_modules/react/jsx-runtime.es.js";
2
- import { useState as c } from "react";
3
- import { copyTextToClipboard as u } from "../../../utils/copy.es.js";
4
- import { Input as l } from "../BaseInput/Input.es.js";
2
+ import { useState as u } from "react";
3
+ import { copyTextToClipboard as c } from "../../../utils/copy.es.js";
4
+ import { Input as x } from "../BaseInput/Input.es.js";
5
5
  /* empty css */
6
6
  import { csx as e } from "../../../utils/string.es.js";
7
7
  function b({
@@ -9,28 +9,28 @@ function b({
9
9
  value: p,
10
10
  isDisabled: s,
11
11
  onError: i,
12
- onSuccess: n
12
+ onSuccess: r
13
13
  }) {
14
- const [a, r] = c(!1);
14
+ const [a, n] = u(!1);
15
15
  return /* @__PURE__ */ t.jsx(
16
- l,
16
+ x,
17
17
  {
18
18
  name: o,
19
19
  value: p,
20
20
  isDisabled: s,
21
21
  suffix: /* @__PURE__ */ t.jsx(
22
- x,
22
+ l,
23
23
  {
24
24
  isCopied: a,
25
25
  onClick: async () => {
26
- console.log("copy button clicked", { value: p }), await u(p, i) && (r(!0), n == null || n(), setTimeout(() => r(!1), 5e3));
26
+ await c(p, i) && (n(!0), r == null || r(), setTimeout(() => n(!1), 5e3));
27
27
  }
28
28
  }
29
29
  )
30
30
  }
31
31
  );
32
32
  }
33
- const x = ({ isCopied: o, onClick: p }) => /* @__PURE__ */ t.jsx("div", { className: "proton-CopyInput-button-container", onClick: p, children: /* @__PURE__ */ t.jsxs(
33
+ const l = ({ isCopied: o, onClick: p }) => /* @__PURE__ */ t.jsx("div", { className: "proton-CopyInput-button-container", children: /* @__PURE__ */ t.jsxs(
34
34
  "button",
35
35
  {
36
36
  "data-testid": "COPY_BUTTON",
@@ -38,6 +38,8 @@ const x = ({ isCopied: o, onClick: p }) => /* @__PURE__ */ t.jsx("div", { classN
38
38
  "proton-CopyInput-button",
39
39
  o && "proton-CopyInput-button--copied"
40
40
  ),
41
+ onClick: p,
42
+ type: "button",
41
43
  children: [
42
44
  /* @__PURE__ */ t.jsxs(
43
45
  "svg",
@@ -1 +1 @@
1
- {"version":3,"file":"CopyInput.es.js","sources":["../../../../src/components/Input/CopyInput/CopyInput.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { csx } from \"../../../utils\";\nimport { copyTextToClipboard } from \"../../../utils/copy\";\nimport { Input } from \"../BaseInput/Input\";\nimport \"./CopyInput.css\";\n\nexport interface CopyInputProps {\n /** The name of the input field */\n name: string;\n\n /** The value to display in the input and copy to clipboard */\n value: string;\n\n /** Whether the input is disabled */\n isDisabled?: boolean;\n\n /** Optional callback when copy fails, receives the error object */\n onError?: (error: Error) => void;\n\n /** Optional callback when copy succeeds */\n onSuccess?: () => void;\n}\n\n/**\n * Input with a button to copy value to the clipboard.\n *\n * API:\n * - {@link CopyInputProps}\n */\nexport function CopyInput({\n name,\n value,\n isDisabled,\n onError,\n onSuccess,\n}: CopyInputProps) {\n const [isCopied, setCopied] = useState(false);\n\n return (\n <Input\n name={name}\n value={value}\n isDisabled={isDisabled}\n suffix={\n <CopyButton\n isCopied={isCopied}\n onClick={async () => {\n console.log(\"copy button clicked\", { value})\n\n const copySuccess = await copyTextToClipboard(value, onError);\n if (!copySuccess) return;\n\n setCopied(true);\n onSuccess?.();\n setTimeout(() => setCopied(false), 5000);\n }}\n />\n }\n />\n );\n}\n\nconst CopyButton = ({ isCopied, onClick }) => {\n return (\n <div className=\"proton-CopyInput-button-container\" onClick={onClick}>\n <button\n data-testid=\"COPY_BUTTON\"\n className={csx(\n \"proton-CopyInput-button\",\n isCopied && \"proton-CopyInput-button--copied\"\n )}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 512 512\"\n >\n <path\n fill=\"currentColor\"\n d=\"M408 480H184a72 72 0 0 1-72-72V184a72 72 0 0 1 72-72h224a72 72 0 0 1 72 72v224a72 72 0 0 1-72 72\"\n />\n <path\n fill=\"currentColor\"\n d=\"M160 80h235.88A72.12 72.12 0 0 0 328 32H104a72 72 0 0 0-72 72v224a72.12 72.12 0 0 0 48 67.88V160a80 80 0 0 1 80-80\"\n />\n </svg>\n <span\n className={csx(\n \"proton-CopyInput-button-text\",\n isCopied && \"proton-CopyInput-button-text--copied\"\n )}\n >\n {isCopied ? \"Copied!\" : \"Copy\"}\n </span>\n </button>\n </div>\n );\n};\n"],"names":["CopyInput","name","value","isDisabled","onError","onSuccess","isCopied","setCopied","useState","jsx","Input","CopyButton","copyTextToClipboard","onClick","jsxs","csx"],"mappings":";;;;;;AA6BO,SAASA,EAAU;AAAA,EACxB,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC;AACF,GAAmB;AACjB,QAAM,CAACC,GAAUC,CAAS,IAAIC,EAAS,EAAK;AAG1C,SAAAC,gBAAAA,EAAA;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,MAAAT;AAAA,MACA,OAAAC;AAAA,MACA,YAAAC;AAAA,MACA,QACEM,gBAAAA,EAAA;AAAA,QAACE;AAAA,QAAA;AAAA,UACC,UAAAL;AAAA,UACA,SAAS,YAAY;AAInB,YAHA,QAAQ,IAAI,uBAAuB,EAAE,OAAAJ,EAAM,CAAA,GAEvB,MAAMU,EAAoBV,GAAOE,CAAO,MAG5DG,EAAU,EAAI,GACFF,KAAA,QAAAA,KACZ,WAAW,MAAME,EAAU,EAAK,GAAG,GAAI;AAAA,UACzC;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAIR;AAEA,MAAMI,IAAa,CAAC,EAAE,UAAAL,GAAU,SAAAO,QAE3BJ,gBAAAA,EAAAA,IAAA,OAAA,EAAI,WAAU,qCAAoC,SAAAI,GACjD,UAAAC,gBAAAA,EAAA;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,eAAY;AAAA,IACZ,WAAWC;AAAA,MACT;AAAA,MACAT,KAAY;AAAA,IACd;AAAA,IAEA,UAAA;AAAA,MAAAQ,gBAAAA,EAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,OAAM;AAAA,UACN,OAAM;AAAA,UACN,QAAO;AAAA,UACP,SAAQ;AAAA,UAER,UAAA;AAAA,YAAAL,gBAAAA,EAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,MAAK;AAAA,gBACL,GAAE;AAAA,cAAA;AAAA,YACJ;AAAA,YACAA,gBAAAA,EAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,MAAK;AAAA,gBACL,GAAE;AAAA,cAAA;AAAA,YACJ;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,MACAA,gBAAAA,EAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWM;AAAA,YACT;AAAA,YACAT,KAAY;AAAA,UACd;AAAA,UAEC,cAAW,YAAY;AAAA,QAAA;AAAA,MAC1B;AAAA,IAAA;AAAA,EAAA;AAEJ,EAAA,CAAA;"}
1
+ {"version":3,"file":"CopyInput.es.js","sources":["../../../../src/components/Input/CopyInput/CopyInput.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { csx } from \"../../../utils\";\nimport { copyTextToClipboard } from \"../../../utils/copy\";\nimport { Input } from \"../BaseInput/Input\";\nimport \"./CopyInput.css\";\n\nexport interface CopyInputProps {\n /** The name of the input field */\n name: string;\n\n /** The value to display in the input and copy to clipboard */\n value: string;\n\n /** Whether the input is disabled */\n isDisabled?: boolean;\n\n /** Optional callback when copy fails, receives the error object */\n onError?: (error: Error) => void;\n\n /** Optional callback when copy succeeds */\n onSuccess?: () => void;\n}\n\n/**\n * Input with a button to copy value to the clipboard.\n *\n * API:\n * - {@link CopyInputProps}\n */\nexport function CopyInput({\n name,\n value,\n isDisabled,\n onError,\n onSuccess,\n}: CopyInputProps) {\n const [isCopied, setCopied] = useState(false);\n\n return (\n <Input\n name={name}\n value={value}\n isDisabled={isDisabled}\n suffix={\n <CopyButton\n isCopied={isCopied}\n onClick={async () => {\n const copySuccess = await copyTextToClipboard(value, onError);\n if (!copySuccess) return;\n\n setCopied(true);\n onSuccess?.();\n setTimeout(() => setCopied(false), 5000);\n }}\n />\n }\n />\n );\n}\n\nconst CopyButton = ({ isCopied, onClick }) => {\n return (\n <div className=\"proton-CopyInput-button-container\">\n <button\n data-testid=\"COPY_BUTTON\"\n className={csx(\n \"proton-CopyInput-button\",\n isCopied && \"proton-CopyInput-button--copied\"\n )}\n onClick={onClick}\n type=\"button\"\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 512 512\"\n >\n <path\n fill=\"currentColor\"\n d=\"M408 480H184a72 72 0 0 1-72-72V184a72 72 0 0 1 72-72h224a72 72 0 0 1 72 72v224a72 72 0 0 1-72 72\"\n />\n <path\n fill=\"currentColor\"\n d=\"M160 80h235.88A72.12 72.12 0 0 0 328 32H104a72 72 0 0 0-72 72v224a72.12 72.12 0 0 0 48 67.88V160a80 80 0 0 1 80-80\"\n />\n </svg>\n <span\n className={csx(\n \"proton-CopyInput-button-text\",\n isCopied && \"proton-CopyInput-button-text--copied\"\n )}\n >\n {isCopied ? \"Copied!\" : \"Copy\"}\n </span>\n </button>\n </div>\n );\n};\n"],"names":["CopyInput","name","value","isDisabled","onError","onSuccess","isCopied","setCopied","useState","jsx","Input","CopyButton","copyTextToClipboard","onClick","jsxs","csx"],"mappings":";;;;;;AA6BO,SAASA,EAAU;AAAA,EACxB,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC;AACF,GAAmB;AACjB,QAAM,CAACC,GAAUC,CAAS,IAAIC,EAAS,EAAK;AAG1C,SAAAC,gBAAAA,EAAA;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,MAAAT;AAAA,MACA,OAAAC;AAAA,MACA,YAAAC;AAAA,MACA,QACEM,gBAAAA,EAAA;AAAA,QAACE;AAAA,QAAA;AAAA,UACC,UAAAL;AAAA,UACA,SAAS,YAAY;AAEnB,YADoB,MAAMM,EAAoBV,GAAOE,CAAO,MAG5DG,EAAU,EAAI,GACFF,KAAA,QAAAA,KACZ,WAAW,MAAME,EAAU,EAAK,GAAG,GAAI;AAAA,UACzC;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAIR;AAEA,MAAMI,IAAa,CAAC,EAAE,UAAAL,GAAU,SAAAO,QAE5BJ,gBAAAA,EAAAA,IAAC,OAAI,EAAA,WAAU,qCACb,UAAAK,gBAAAA,EAAA;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,eAAY;AAAA,IACZ,WAAWC;AAAA,MACT;AAAA,MACAT,KAAY;AAAA,IACd;AAAA,IACA,SAAAO;AAAA,IACA,MAAK;AAAA,IAEL,UAAA;AAAA,MAAAC,gBAAAA,EAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,OAAM;AAAA,UACN,OAAM;AAAA,UACN,QAAO;AAAA,UACP,SAAQ;AAAA,UAER,UAAA;AAAA,YAAAL,gBAAAA,EAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,MAAK;AAAA,gBACL,GAAE;AAAA,cAAA;AAAA,YACJ;AAAA,YACAA,gBAAAA,EAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,MAAK;AAAA,gBACL,GAAE;AAAA,cAAA;AAAA,YACJ;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,MACAA,gBAAAA,EAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWM;AAAA,YACT;AAAA,YACAT,KAAY;AAAA,UACd;AAAA,UAEC,cAAW,YAAY;AAAA,QAAA;AAAA,MAC1B;AAAA,IAAA;AAAA,EAAA;AAEJ,EAAA,CAAA;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=async(o,c)=>{let e=!1;const n=t=>{const l=t instanceof Error?t.message:"Failed to copy to clipboard";console.error(l),c==null||c(new Error(l))};if(typeof navigator<"u"&&navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){console.log("clipboard API detected, attempting to use it");try{await navigator.clipboard.writeText(o),e=!0,console.log("clipboard API succeeded")}catch(t){console.log("clipboard API failed, trying fallback",{error:t});try{e=d(o),e?console.log("fallback succeeded after clipboard API failure"):(console.log("fallback unsuccessful, calling onErrorCallback",{error:t}),n(t))}catch(l){console.log("fallback errored, calling onErrorCallback",{fallbackError:l}),n(l)}}}else{console.log("clipboard API NOT available, using fallback",{hasNavigator:typeof navigator<"u",hasClipboard:typeof navigator<"u"&&!!navigator.clipboard,hasWriteText:typeof navigator<"u"&&navigator.clipboard&&typeof navigator.clipboard.writeText=="function"});try{e=d(o),console.log("fallback result",{copySuccess:e,text:o}),e?(console.log("fallback successful - copy should have worked"),console.warn("Note: execCommand returned true, but the copy may have been silently blocked by browser security restrictions.")):(console.log("fallback unsuccessful, calling onErrorCallback",{copySuccess:e}),n(new Error("Failed to copy to clipboard: Clipboard API not available and fallback method failed. This may be due to browser security restrictions (e.g., iframe permissions, non-HTTPS context, or Modal/Portal focus management).")))}catch(t){console.log("fallback errored, calling onErrorCallback",{error:t}),n(t)}}return console.log("copyTextToClipboard final result",{copySuccess:e}),e},d=(o,{target:c=document.body}={})=>{if(typeof o!="string")throw new TypeError(`Expected parameter \`text\` to be a \`string\`, got \`${typeof o}\`.`);if(!document.execCommand)return console.error("document.execCommand is not available"),!1;const e=document.createElement("textarea"),n=document.activeElement;e.value=o;const i=document.body;e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="2px",e.style.height="2px",e.style.padding="0",e.style.border="none",e.style.margin="0",e.style.outline="none",e.style.boxShadow="none",e.style.background="transparent",e.style.opacity="0",e.style.zIndex="-1",e.style.fontSize="12pt",e.setAttribute("tabindex","-1"),e.setAttribute("aria-hidden","true");const t=document.getSelection(),l=t.rangeCount>0&&t.getRangeAt(0);i.appendChild(e);let r=!1,s=null;try{if(e.focus({preventScroll:!0}),e.select(),e.setSelectionRange)try{e.setSelectionRange(0,o.length)}catch{e.select()}const a=e.selectionStart===0&&e.selectionEnd===o.length;console.log("element selection state before execCommand",{isSelected:a,selectionStart:e.selectionStart,selectionEnd:e.selectionEnd,textLength:o.length,isConnected:e.isConnected,ownerDocument:e.ownerDocument===document,hasFocus:document.activeElement===e}),(!a||document.activeElement!==e)&&o.length>0&&(e.focus({preventScroll:!0}),e.select(),e.setSelectionRange&&e.setSelectionRange(0,o.length)),r=document.execCommand("copy"),console.log("document.execCommand('copy') result",{isSuccess:r,textLength:o.length,activeElement:document.activeElement===e}),r?console.log("execCommand returned true - copy should have succeeded (but may be blocked by browser security)"):console.warn("execCommand returned false - copy failed")}catch(a){s=a,console.error("document.execCommand('copy') threw an error",a)}return e.remove(),l&&(t.removeAllRanges(),t.addRange(l)),n instanceof HTMLElement&&setTimeout(()=>{try{n.focus()}catch(a){console.log("Could not restore focus (non-critical)",a)}},0),s?(console.error("execCommand error",s),!1):r};exports.copyTextToClipboard=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=async(o,t)=>{let e=!1;if(navigator.clipboard)try{await navigator.clipboard.writeText(o),e=!0}catch(c){t?t==null||t(c):console.error(c)}else e=s(o);return e||(t?t==null||t(new Error("Failed to copy to clipboard")):console.error("Failed to copy to clipboard")),e},s=(o,{target:t=document.body}={})=>{if(typeof o!="string")throw new TypeError(`Expected parameter \`text\` to be a \`string\`, got \`${typeof o}\`.`);const e=document.createElement("textarea"),c=document.activeElement;e.value=o,e.setAttribute("readonly",""),e.style.contain="strict",e.style.position="absolute",e.style.left="-9999px",e.style.fontSize="12pt";const a=document.getSelection(),l=a.rangeCount>0&&a.getRangeAt(0);t.append(e),e.select(),e.selectionStart=0,e.selectionEnd=o.length;let n=!1;try{n=document.execCommand("copy")}catch{}return e.remove(),l&&(a.removeAllRanges(),a.addRange(l)),c instanceof HTMLElement&&c.focus(),n};exports.copyTextToClipboard=i;
2
2
  //# sourceMappingURL=copy.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"copy.cjs.js","sources":["../../src/utils/copy.ts"],"sourcesContent":["export const copyTextToClipboard = async (\n text: string,\n onError?: (error: Error) => void\n): Promise<boolean> => {\n let copySuccess = false;\n\n const onErrorCallback = (error: Error) => {\n const errorMessage =\n error instanceof Error ? error.message : \"Failed to copy to clipboard\";\n\n console.error(errorMessage);\n onError?.(new Error(errorMessage));\n };\n\n // Check if clipboard API is available\n // Note: The Clipboard API handles its own security checks.\n // If not in a secure context (HTTPS), navigator.clipboard will be undefined\n // or writeText() will throw an error. We don't need to manually check isSecureContext.\n const isClipboardAvailable =\n typeof navigator !== \"undefined\" &&\n navigator.clipboard &&\n typeof navigator.clipboard.writeText === \"function\";\n\n if (isClipboardAvailable) {\n console.log(\"clipboard API detected, attempting to use it\");\n try {\n await navigator.clipboard.writeText(text);\n copySuccess = true;\n console.log(\"clipboard API succeeded\");\n } catch (error) {\n // Clipboard API failed (could be security restriction, permission denied, etc.)\n // Fall back to execCommand method\n console.log(\"clipboard API failed, trying fallback\", { error });\n try {\n copySuccess = DEPRECATED_copyTextToClipboard(text);\n\n if (!copySuccess) {\n console.log(\"fallback unsuccessful, calling onErrorCallback\", {\n error,\n });\n onErrorCallback(error);\n } else {\n console.log(\"fallback succeeded after clipboard API failure\");\n }\n } catch (fallbackError) {\n console.log(\"fallback errored, calling onErrorCallback\", {\n fallbackError,\n });\n onErrorCallback(fallbackError);\n }\n }\n } else {\n // Clipboard API not available, use fallback method\n console.log(\"clipboard API NOT available, using fallback\", {\n hasNavigator: typeof navigator !== \"undefined\",\n hasClipboard: typeof navigator !== \"undefined\" && !!navigator.clipboard,\n hasWriteText:\n typeof navigator !== \"undefined\" &&\n navigator.clipboard &&\n typeof navigator.clipboard.writeText === \"function\",\n });\n\n try {\n copySuccess = DEPRECATED_copyTextToClipboard(text);\n console.log(\"fallback result\", { copySuccess, text });\n if (!copySuccess) {\n console.log(\"fallback unsuccessful, calling onErrorCallback\", {\n copySuccess,\n });\n onErrorCallback(\n new Error(\n \"Failed to copy to clipboard: Clipboard API not available and fallback method failed. This may be due to browser security restrictions (e.g., iframe permissions, non-HTTPS context, or Modal/Portal focus management).\"\n )\n );\n } else {\n console.log(\"fallback successful - copy should have worked\");\n // WARNING: In some contexts (iframes, cross-origin, Modal portals),\n // execCommand may return true but the copy may still be blocked by the browser.\n // There's no reliable way to verify if the copy actually succeeded.\n console.warn(\n \"Note: execCommand returned true, but the copy may have been silently blocked by browser security restrictions.\"\n );\n }\n } catch (error) {\n console.log(\"fallback errored, calling onErrorCallback\", { error });\n onErrorCallback(error);\n }\n }\n\n console.log(\"copyTextToClipboard final result\", { copySuccess });\n return copySuccess;\n};\n\n/**\n * Fallback legacy function to copy text to clipboard for browsers that don't support navigator.clipboard.writeText\n * @reference https://github.com/sindresorhus/copy-text-to-clipboard/blob/main/index.js\n * @deprecated Use navigator.clipboard.writeText instead\n */\nconst DEPRECATED_copyTextToClipboard = (\n text,\n { target = document.body } = {}\n) => {\n if (typeof text !== \"string\") {\n throw new TypeError(\n `Expected parameter \\`text\\` to be a \\`string\\`, got \\`${typeof text}\\`.`\n );\n }\n\n // Check if execCommand is available\n if (!document.execCommand) {\n console.error(\"document.execCommand is not available\");\n return false;\n }\n\n const element = document.createElement(\"textarea\");\n const previouslyFocusedElement = document.activeElement;\n\n element.value = text;\n\n // IMPORTANT: Always append to document.body, not the target\n // This ensures the element is in the active document, which is required\n // for execCommand to work, especially when inside portals/modals\n const container = document.body;\n\n // Style the element to be invisible but still \"visible\" to the browser\n // Some browsers require the element to be in the render tree and \"visible\"\n element.style.position = \"fixed\";\n element.style.top = \"0\";\n element.style.left = \"0\";\n element.style.width = \"2px\";\n element.style.height = \"2px\";\n element.style.padding = \"0\";\n element.style.border = \"none\";\n element.style.margin = \"0\";\n element.style.outline = \"none\";\n element.style.boxShadow = \"none\";\n element.style.background = \"transparent\";\n element.style.opacity = \"0\";\n element.style.zIndex = \"-1\";\n element.style.fontSize = \"12pt\"; // Prevent zooming on iOS\n // NOTE: Do NOT set readonly - some browsers require the element to be editable\n // for execCommand to work properly, especially in Modal/Portal contexts\n element.setAttribute(\"tabindex\", \"-1\");\n element.setAttribute(\"aria-hidden\", \"true\");\n\n const selection = document.getSelection();\n const originalRange = selection.rangeCount > 0 && selection.getRangeAt(0);\n\n // Append to document.body (critical for Modal/Portal contexts)\n container.appendChild(element);\n\n let isSuccess = false;\n let execCommandError = null;\n\n try {\n // Focus and select - must happen synchronously within user activation\n // Try multiple approaches to ensure it works in Modal contexts\n element.focus({ preventScroll: true });\n\n // Use both select() and setSelectionRange for maximum compatibility\n element.select();\n\n // Explicit selection workaround for iOS and ensure full selection\n if (element.setSelectionRange) {\n try {\n element.setSelectionRange(0, text.length);\n } catch (e) {\n // setSelectionRange may fail, try select() again\n element.select();\n }\n }\n\n // Verify selection before attempting copy\n const isSelected =\n element.selectionStart === 0 && element.selectionEnd === text.length;\n\n console.log(\"element selection state before execCommand\", {\n isSelected,\n selectionStart: element.selectionStart,\n selectionEnd: element.selectionEnd,\n textLength: text.length,\n isConnected: element.isConnected,\n ownerDocument: element.ownerDocument === document,\n hasFocus: document.activeElement === element,\n });\n\n // If not properly selected or focused, try again\n if (\n (!isSelected || document.activeElement !== element) &&\n text.length > 0\n ) {\n element.focus({ preventScroll: true });\n element.select();\n if (element.setSelectionRange) {\n element.setSelectionRange(0, text.length);\n }\n }\n\n // Execute copy command - must be synchronous within user activation\n // Some browsers will return true even if copy fails (security restriction)\n isSuccess = document.execCommand(\"copy\");\n\n console.log(\"document.execCommand('copy') result\", {\n isSuccess,\n textLength: text.length,\n activeElement: document.activeElement === element,\n });\n\n if (!isSuccess) {\n console.warn(\"execCommand returned false - copy failed\");\n } else {\n // Even if execCommand returns true, the copy might have been blocked\n // by browser security. There's no reliable way to verify, but we log it.\n console.log(\n \"execCommand returned true - copy should have succeeded (but may be blocked by browser security)\"\n );\n }\n } catch (error) {\n execCommandError = error;\n console.error(\"document.execCommand('copy') threw an error\", error);\n }\n\n // Clean up immediately\n element.remove();\n\n // Restore original selection\n if (originalRange) {\n selection.removeAllRanges();\n selection.addRange(originalRange);\n }\n\n // Restore focus to previously focused element\n // Use setTimeout to avoid focus conflicts with Modal's FocusScope\n if (previouslyFocusedElement instanceof HTMLElement) {\n // Small delay to let the Modal's focus management settle\n setTimeout(() => {\n try {\n previouslyFocusedElement.focus();\n } catch (e) {\n // Focus might fail if element is no longer in DOM, that's okay\n console.log(\"Could not restore focus (non-critical)\", e);\n }\n }, 0);\n }\n\n if (execCommandError) {\n console.error(\"execCommand error\", execCommandError);\n return false;\n }\n\n return isSuccess;\n};\n"],"names":["copyTextToClipboard","text","onError","copySuccess","onErrorCallback","error","errorMessage","DEPRECATED_copyTextToClipboard","fallbackError","target","element","previouslyFocusedElement","container","selection","originalRange","isSuccess","execCommandError","isSelected","e"],"mappings":"gFAAa,MAAAA,EAAsB,MACjCC,EACAC,IACqB,CACrB,IAAIC,EAAc,GAEZ,MAAAC,EAAmBC,GAAiB,CACxC,MAAMC,EACJD,aAAiB,MAAQA,EAAM,QAAU,8BAE3C,QAAQ,MAAMC,CAAY,EAChBJ,GAAA,MAAAA,EAAA,IAAI,MAAMI,CAAY,EAAC,EAYnC,GAJE,OAAO,UAAc,KACrB,UAAU,WACV,OAAO,UAAU,UAAU,WAAc,WAEjB,CACxB,QAAQ,IAAI,8CAA8C,EACtD,GAAA,CACI,MAAA,UAAU,UAAU,UAAUL,CAAI,EAC1BE,EAAA,GACd,QAAQ,IAAI,yBAAyB,QAC9BE,EAAO,CAGd,QAAQ,IAAI,wCAAyC,CAAE,MAAAA,CAAO,CAAA,EAC1D,GAAA,CACFF,EAAcI,EAA+BN,CAAI,EAE5CE,EAMH,QAAQ,IAAI,gDAAgD,GAL5D,QAAQ,IAAI,iDAAkD,CAC5D,MAAAE,CAAA,CACD,EACDD,EAAgBC,CAAK,SAIhBG,EAAe,CACtB,QAAQ,IAAI,4CAA6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IACFD,EAAU,gBAAgB,EAC1BA,EAAU,SAASC,CAAa,GAK9BH,aAAoC,aAEtC,WAAW,IAAM,CACX,GAAA,CACFA,EAAyB,MAAM,QACxBO,EAAG,CAEF,QAAA,IAAI,yCAA0CA,CAAC,CACzD,GACC,CAAC,EAGFF,GACM,QAAA,MAAM,oBAAqBA,CAAgB,EAC5C,IAGFD,CACT"}
1
+ {"version":3,"file":"copy.cjs.js","sources":["../../src/utils/copy.ts"],"sourcesContent":["export const copyTextToClipboard = async (\n text: string,\n onError?: (error: Error) => void\n): Promise<boolean> => {\n let copySuccess = false;\n if (navigator.clipboard) {\n try {\n await navigator.clipboard.writeText(text);\n copySuccess = true;\n } catch (error) {\n onError ? onError?.(error) : console.error(error);\n }\n } else {\n copySuccess = DEPRECATED_copyTextToClipboard(text);\n }\n if (!copySuccess) {\n onError ? onError?.(new Error(\"Failed to copy to clipboard\")) : console.error(\"Failed to copy to clipboard\");\n }\n return copySuccess;\n};\n\n/**\n * Fallback legacy function to copy text to clipboard for browsers that don't support navigator.clipboard.writeText\n * @reference https://github.com/sindresorhus/copy-text-to-clipboard/blob/main/index.js\n * @deprecated Use navigator.clipboard.writeText instead\n */\nconst DEPRECATED_copyTextToClipboard = (\n text,\n { target = document.body } = {}\n) => {\n if (typeof text !== \"string\") {\n throw new TypeError(\n `Expected parameter \\`text\\` to be a \\`string\\`, got \\`${typeof text}\\`.`\n );\n }\n\n const element = document.createElement(\"textarea\");\n const previouslyFocusedElement = document.activeElement;\n\n element.value = text;\n\n // Prevent keyboard from showing on mobile\n element.setAttribute(\"readonly\", \"\");\n\n element.style.contain = \"strict\";\n element.style.position = \"absolute\";\n element.style.left = \"-9999px\";\n element.style.fontSize = \"12pt\"; // Prevent zooming on iOS\n\n const selection = document.getSelection();\n const originalRange = selection.rangeCount > 0 && selection.getRangeAt(0);\n\n target.append(element);\n element.select();\n\n // Explicit selection workaround for iOS\n element.selectionStart = 0;\n element.selectionEnd = text.length;\n\n let isSuccess = false;\n try {\n isSuccess = document.execCommand(\"copy\");\n } catch {}\n\n element.remove();\n\n if (originalRange) {\n selection.removeAllRanges();\n selection.addRange(originalRange);\n }\n\n // Get the focus back on the previously focused element, if any\n if (previouslyFocusedElement instanceof HTMLElement) {\n previouslyFocusedElement.focus();\n }\n\n return isSuccess;\n};\n"],"names":["copyTextToClipboard","text","onError","copySuccess","error","DEPRECATED_copyTextToClipboard","target","element","previouslyFocusedElement","selection","originalRange","isSuccess"],"mappings":"gFAAa,MAAAA,EAAsB,MACjCC,EACAC,IACqB,CACrB,IAAIC,EAAc,GAClB,GAAI,UAAU,UACR,GAAA,CACI,MAAA,UAAU,UAAU,UAAUF,CAAI,EAC1BE,EAAA,SACPC,EAAO,CACdF,EAAUA,GAAA,MAAAA,EAAUE,GAAS,QAAQ,MAAMA,CAAK,CAClD,MAEAD,EAAcE,EAA+BJ,CAAI,EAEnD,OAAKE,IACOD,EAAAA,GAAA,MAAAA,EAAU,IAAI,MAAM,6BAA6B,GAAK,QAAQ,MAAM,6BAA6B,GAEtGC,CACT,EAOME,EAAiC,CACrCJ,EACA,CAAE,OAAAK,EAAS,SAAS,IAAS,EAAA,KAC1B,CACC,GAAA,OAAOL,GAAS,SAClB,MAAM,IAAI,UACR,yDAAyD,OAAOA,CAAI,KAAA,EAIlE,MAAAM,EAAU,SAAS,cAAc,UAAU,EAC3CC,EAA2B,SAAS,cAE1CD,EAAQ,MAAQN,EAGRM,EAAA,aAAa,WAAY,EAAE,EAEnCA,EAAQ,MAAM,QAAU,SACxBA,EAAQ,MAAM,SAAW,WACzBA,EAAQ,MAAM,KAAO,UACrBA,EAAQ,MAAM,SAAW,OAEnB,MAAAE,EAAY,SAAS,eACrBC,EAAgBD,EAAU,WAAa,GAAKA,EAAU,WAAW,CAAC,EAExEH,EAAO,OAAOC,CAAO,EACrBA,EAAQ,OAAO,EAGfA,EAAQ,eAAiB,EACzBA,EAAQ,aAAeN,EAAK,OAE5B,IAAIU,EAAY,GACZ,GAAA,CACUA,EAAA,SAAS,YAAY,MAAM,CAAA,MACjC,CAAC,CAET,OAAAJ,EAAQ,OAAO,EAEXG,IACFD,EAAU,gBAAgB,EAC1BA,EAAU,SAASC,CAAa,GAI9BF,aAAoC,aACtCA,EAAyB,MAAM,EAG1BG,CACT"}
@@ -1,95 +1,31 @@
1
- const g = async (o, c) => {
1
+ const i = async (c, t) => {
2
2
  let e = !1;
3
- const n = (t) => {
4
- const l = t instanceof Error ? t.message : "Failed to copy to clipboard";
5
- console.error(l), c == null || c(new Error(l));
6
- };
7
- if (typeof navigator < "u" && navigator.clipboard && typeof navigator.clipboard.writeText == "function") {
8
- console.log("clipboard API detected, attempting to use it");
3
+ if (navigator.clipboard)
9
4
  try {
10
- await navigator.clipboard.writeText(o), e = !0, console.log("clipboard API succeeded");
11
- } catch (t) {
12
- console.log("clipboard API failed, trying fallback", { error: t });
13
- try {
14
- e = d(o), e ? console.log("fallback succeeded after clipboard API failure") : (console.log("fallback unsuccessful, calling onErrorCallback", {
15
- error: t
16
- }), n(t));
17
- } catch (l) {
18
- console.log("fallback errored, calling onErrorCallback", {
19
- fallbackError: l
20
- }), n(l);
21
- }
5
+ await navigator.clipboard.writeText(c), e = !0;
6
+ } catch (o) {
7
+ t ? t == null || t(o) : console.error(o);
22
8
  }
23
- } else {
24
- console.log("clipboard API NOT available, using fallback", {
25
- hasNavigator: typeof navigator < "u",
26
- hasClipboard: typeof navigator < "u" && !!navigator.clipboard,
27
- hasWriteText: typeof navigator < "u" && navigator.clipboard && typeof navigator.clipboard.writeText == "function"
28
- });
29
- try {
30
- e = d(o), console.log("fallback result", { copySuccess: e, text: o }), e ? (console.log("fallback successful - copy should have worked"), console.warn(
31
- "Note: execCommand returned true, but the copy may have been silently blocked by browser security restrictions."
32
- )) : (console.log("fallback unsuccessful, calling onErrorCallback", {
33
- copySuccess: e
34
- }), n(
35
- new Error(
36
- "Failed to copy to clipboard: Clipboard API not available and fallback method failed. This may be due to browser security restrictions (e.g., iframe permissions, non-HTTPS context, or Modal/Portal focus management)."
37
- )
38
- ));
39
- } catch (t) {
40
- console.log("fallback errored, calling onErrorCallback", { error: t }), n(t);
41
- }
42
- }
43
- return console.log("copyTextToClipboard final result", { copySuccess: e }), e;
44
- }, d = (o, { target: c = document.body } = {}) => {
45
- if (typeof o != "string")
9
+ else
10
+ e = s(c);
11
+ return e || (t ? t == null || t(new Error("Failed to copy to clipboard")) : console.error("Failed to copy to clipboard")), e;
12
+ }, s = (c, { target: t = document.body } = {}) => {
13
+ if (typeof c != "string")
46
14
  throw new TypeError(
47
- `Expected parameter \`text\` to be a \`string\`, got \`${typeof o}\`.`
15
+ `Expected parameter \`text\` to be a \`string\`, got \`${typeof c}\`.`
48
16
  );
49
- if (!document.execCommand)
50
- return console.error("document.execCommand is not available"), !1;
51
- const e = document.createElement("textarea"), n = document.activeElement;
52
- e.value = o;
53
- const i = document.body;
54
- e.style.position = "fixed", e.style.top = "0", e.style.left = "0", e.style.width = "2px", e.style.height = "2px", e.style.padding = "0", e.style.border = "none", e.style.margin = "0", e.style.outline = "none", e.style.boxShadow = "none", e.style.background = "transparent", e.style.opacity = "0", e.style.zIndex = "-1", e.style.fontSize = "12pt", e.setAttribute("tabindex", "-1"), e.setAttribute("aria-hidden", "true");
55
- const t = document.getSelection(), l = t.rangeCount > 0 && t.getRangeAt(0);
56
- i.appendChild(e);
57
- let r = !1, s = null;
17
+ const e = document.createElement("textarea"), o = document.activeElement;
18
+ e.value = c, e.setAttribute("readonly", ""), e.style.contain = "strict", e.style.position = "absolute", e.style.left = "-9999px", e.style.fontSize = "12pt";
19
+ const a = document.getSelection(), l = a.rangeCount > 0 && a.getRangeAt(0);
20
+ t.append(e), e.select(), e.selectionStart = 0, e.selectionEnd = c.length;
21
+ let n = !1;
58
22
  try {
59
- if (e.focus({ preventScroll: !0 }), e.select(), e.setSelectionRange)
60
- try {
61
- e.setSelectionRange(0, o.length);
62
- } catch {
63
- e.select();
64
- }
65
- const a = e.selectionStart === 0 && e.selectionEnd === o.length;
66
- console.log("element selection state before execCommand", {
67
- isSelected: a,
68
- selectionStart: e.selectionStart,
69
- selectionEnd: e.selectionEnd,
70
- textLength: o.length,
71
- isConnected: e.isConnected,
72
- ownerDocument: e.ownerDocument === document,
73
- hasFocus: document.activeElement === e
74
- }), (!a || document.activeElement !== e) && o.length > 0 && (e.focus({ preventScroll: !0 }), e.select(), e.setSelectionRange && e.setSelectionRange(0, o.length)), r = document.execCommand("copy"), console.log("document.execCommand('copy') result", {
75
- isSuccess: r,
76
- textLength: o.length,
77
- activeElement: document.activeElement === e
78
- }), r ? console.log(
79
- "execCommand returned true - copy should have succeeded (but may be blocked by browser security)"
80
- ) : console.warn("execCommand returned false - copy failed");
81
- } catch (a) {
82
- s = a, console.error("document.execCommand('copy') threw an error", a);
23
+ n = document.execCommand("copy");
24
+ } catch {
83
25
  }
84
- return e.remove(), l && (t.removeAllRanges(), t.addRange(l)), n instanceof HTMLElement && setTimeout(() => {
85
- try {
86
- n.focus();
87
- } catch (a) {
88
- console.log("Could not restore focus (non-critical)", a);
89
- }
90
- }, 0), s ? (console.error("execCommand error", s), !1) : r;
26
+ return e.remove(), l && (a.removeAllRanges(), a.addRange(l)), o instanceof HTMLElement && o.focus(), n;
91
27
  };
92
28
  export {
93
- g as copyTextToClipboard
29
+ i as copyTextToClipboard
94
30
  };
95
31
  //# sourceMappingURL=copy.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"copy.es.js","sources":["../../src/utils/copy.ts"],"sourcesContent":["export const copyTextToClipboard = async (\n text: string,\n onError?: (error: Error) => void\n): Promise<boolean> => {\n let copySuccess = false;\n\n const onErrorCallback = (error: Error) => {\n const errorMessage =\n error instanceof Error ? error.message : \"Failed to copy to clipboard\";\n\n console.error(errorMessage);\n onError?.(new Error(errorMessage));\n };\n\n // Check if clipboard API is available\n // Note: The Clipboard API handles its own security checks.\n // If not in a secure context (HTTPS), navigator.clipboard will be undefined\n // or writeText() will throw an error. We don't need to manually check isSecureContext.\n const isClipboardAvailable =\n typeof navigator !== \"undefined\" &&\n navigator.clipboard &&\n typeof navigator.clipboard.writeText === \"function\";\n\n if (isClipboardAvailable) {\n console.log(\"clipboard API detected, attempting to use it\");\n try {\n await navigator.clipboard.writeText(text);\n copySuccess = true;\n console.log(\"clipboard API succeeded\");\n } catch (error) {\n // Clipboard API failed (could be security restriction, permission denied, etc.)\n // Fall back to execCommand method\n console.log(\"clipboard API failed, trying fallback\", { error });\n try {\n copySuccess = DEPRECATED_copyTextToClipboard(text);\n\n if (!copySuccess) {\n console.log(\"fallback unsuccessful, calling onErrorCallback\", {\n error,\n });\n onErrorCallback(error);\n } else {\n console.log(\"fallback succeeded after clipboard API failure\");\n }\n } catch (fallbackError) {\n console.log(\"fallback errored, calling onErrorCallback\", {\n fallbackError,\n });\n onErrorCallback(fallbackError);\n }\n }\n } else {\n // Clipboard API not available, use fallback method\n console.log(\"clipboard API NOT available, using fallback\", {\n hasNavigator: typeof navigator !== \"undefined\",\n hasClipboard: typeof navigator !== \"undefined\" && !!navigator.clipboard,\n hasWriteText:\n typeof navigator !== \"undefined\" &&\n navigator.clipboard &&\n typeof navigator.clipboard.writeText === \"function\",\n });\n\n try {\n copySuccess = DEPRECATED_copyTextToClipboard(text);\n console.log(\"fallback result\", { copySuccess, text });\n if (!copySuccess) {\n console.log(\"fallback unsuccessful, calling onErrorCallback\", {\n copySuccess,\n });\n onErrorCallback(\n new Error(\n \"Failed to copy to clipboard: Clipboard API not available and fallback method failed. This may be due to browser security restrictions (e.g., iframe permissions, non-HTTPS context, or Modal/Portal focus management).\"\n )\n );\n } else {\n console.log(\"fallback successful - copy should have worked\");\n // WARNING: In some contexts (iframes, cross-origin, Modal portals),\n // execCommand may return true but the copy may still be blocked by the browser.\n // There's no reliable way to verify if the copy actually succeeded.\n console.warn(\n \"Note: execCommand returned true, but the copy may have been silently blocked by browser security restrictions.\"\n );\n }\n } catch (error) {\n console.log(\"fallback errored, calling onErrorCallback\", { error });\n onErrorCallback(error);\n }\n }\n\n console.log(\"copyTextToClipboard final result\", { copySuccess });\n return copySuccess;\n};\n\n/**\n * Fallback legacy function to copy text to clipboard for browsers that don't support navigator.clipboard.writeText\n * @reference https://github.com/sindresorhus/copy-text-to-clipboard/blob/main/index.js\n * @deprecated Use navigator.clipboard.writeText instead\n */\nconst DEPRECATED_copyTextToClipboard = (\n text,\n { target = document.body } = {}\n) => {\n if (typeof text !== \"string\") {\n throw new TypeError(\n `Expected parameter \\`text\\` to be a \\`string\\`, got \\`${typeof text}\\`.`\n );\n }\n\n // Check if execCommand is available\n if (!document.execCommand) {\n console.error(\"document.execCommand is not available\");\n return false;\n }\n\n const element = document.createElement(\"textarea\");\n const previouslyFocusedElement = document.activeElement;\n\n element.value = text;\n\n // IMPORTANT: Always append to document.body, not the target\n // This ensures the element is in the active document, which is required\n // for execCommand to work, especially when inside portals/modals\n const container = document.body;\n\n // Style the element to be invisible but still \"visible\" to the browser\n // Some browsers require the element to be in the render tree and \"visible\"\n element.style.position = \"fixed\";\n element.style.top = \"0\";\n element.style.left = \"0\";\n element.style.width = \"2px\";\n element.style.height = \"2px\";\n element.style.padding = \"0\";\n element.style.border = \"none\";\n element.style.margin = \"0\";\n element.style.outline = \"none\";\n element.style.boxShadow = \"none\";\n element.style.background = \"transparent\";\n element.style.opacity = \"0\";\n element.style.zIndex = \"-1\";\n element.style.fontSize = \"12pt\"; // Prevent zooming on iOS\n // NOTE: Do NOT set readonly - some browsers require the element to be editable\n // for execCommand to work properly, especially in Modal/Portal contexts\n element.setAttribute(\"tabindex\", \"-1\");\n element.setAttribute(\"aria-hidden\", \"true\");\n\n const selection = document.getSelection();\n const originalRange = selection.rangeCount > 0 && selection.getRangeAt(0);\n\n // Append to document.body (critical for Modal/Portal contexts)\n container.appendChild(element);\n\n let isSuccess = false;\n let execCommandError = null;\n\n try {\n // Focus and select - must happen synchronously within user activation\n // Try multiple approaches to ensure it works in Modal contexts\n element.focus({ preventScroll: true });\n\n // Use both select() and setSelectionRange for maximum compatibility\n element.select();\n\n // Explicit selection workaround for iOS and ensure full selection\n if (element.setSelectionRange) {\n try {\n element.setSelectionRange(0, text.length);\n } catch (e) {\n // setSelectionRange may fail, try select() again\n element.select();\n }\n }\n\n // Verify selection before attempting copy\n const isSelected =\n element.selectionStart === 0 && element.selectionEnd === text.length;\n\n console.log(\"element selection state before execCommand\", {\n isSelected,\n selectionStart: element.selectionStart,\n selectionEnd: element.selectionEnd,\n textLength: text.length,\n isConnected: element.isConnected,\n ownerDocument: element.ownerDocument === document,\n hasFocus: document.activeElement === element,\n });\n\n // If not properly selected or focused, try again\n if (\n (!isSelected || document.activeElement !== element) &&\n text.length > 0\n ) {\n element.focus({ preventScroll: true });\n element.select();\n if (element.setSelectionRange) {\n element.setSelectionRange(0, text.length);\n }\n }\n\n // Execute copy command - must be synchronous within user activation\n // Some browsers will return true even if copy fails (security restriction)\n isSuccess = document.execCommand(\"copy\");\n\n console.log(\"document.execCommand('copy') result\", {\n isSuccess,\n textLength: text.length,\n activeElement: document.activeElement === element,\n });\n\n if (!isSuccess) {\n console.warn(\"execCommand returned false - copy failed\");\n } else {\n // Even if execCommand returns true, the copy might have been blocked\n // by browser security. There's no reliable way to verify, but we log it.\n console.log(\n \"execCommand returned true - copy should have succeeded (but may be blocked by browser security)\"\n );\n }\n } catch (error) {\n execCommandError = error;\n console.error(\"document.execCommand('copy') threw an error\", error);\n }\n\n // Clean up immediately\n element.remove();\n\n // Restore original selection\n if (originalRange) {\n selection.removeAllRanges();\n selection.addRange(originalRange);\n }\n\n // Restore focus to previously focused element\n // Use setTimeout to avoid focus conflicts with Modal's FocusScope\n if (previouslyFocusedElement instanceof HTMLElement) {\n // Small delay to let the Modal's focus management settle\n setTimeout(() => {\n try {\n previouslyFocusedElement.focus();\n } catch (e) {\n // Focus might fail if element is no longer in DOM, that's okay\n console.log(\"Could not restore focus (non-critical)\", e);\n }\n }, 0);\n }\n\n if (execCommandError) {\n console.error(\"execCommand error\", execCommandError);\n return false;\n }\n\n return isSuccess;\n};\n"],"names":["copyTextToClipboard","text","onError","copySuccess","onErrorCallback","error","errorMessage","DEPRECATED_copyTextToClipboard","fallbackError","target","element","previouslyFocusedElement","container","selection","originalRange","isSuccess","execCommandError","isSelected","e"],"mappings":"AAAa,MAAAA,IAAsB,OACjCC,GACAC,MACqB;AACrB,MAAIC,IAAc;AAEZ,QAAAC,IAAkB,CAACC,MAAiB;AACxC,UAAMC,IACJD,aAAiB,QAAQA,EAAM,UAAU;AAE3C,YAAQ,MAAMC,CAAY,GAChBJ,KAAA,QAAAA,EAAA,IAAI,MAAMI,CAAY;AAAA,EAAC;AAYnC,MAJE,OAAO,YAAc,OACrB,UAAU,aACV,OAAO,UAAU,UAAU,aAAc,YAEjB;AACxB,YAAQ,IAAI,8CAA8C;AACtD,QAAA;AACI,YAAA,UAAU,UAAU,UAAUL,CAAI,GAC1BE,IAAA,IACd,QAAQ,IAAI,yBAAyB;AAAA,aAC9BE,GAAO;AAGd,cAAQ,IAAI,yCAAyC,EAAE,OAAAA,EAAO,CAAA;AAC1D,UAAA;AACF,QAAAF,IAAcI,EAA+BN,CAAI,GAE5CE,IAMH,QAAQ,IAAI,gDAAgD,KAL5D,QAAQ,IAAI,kDAAkD;AAAA,UAC5D,OAAAE;AAAA,QAAA,CACD,GACDD,EAAgBC,CAAK;AAAA,eAIhBG,GAAe;AACtB,gBAAQ,IAAI,6CAA6C;AAAA,UACvD,eAAAA;AAAA,QAAA,CACD,GACDJ,EAAgBI,CAAa;AAAA,MAC/B;AAAA,IACF;AAAA,EAAA,OACK;AAEL,YAAQ,IAAI,+CAA+C;AAAA,MACzD,cAAc,OAAO,YAAc;AAAA,MACnC,cAAc,OAAO,YAAc,OAAe,CAAC,CAAC,UAAU;AAAA,MAC9D,cACE,OAAO,YAAc,OACrB,UAAU,aACV,OAAO,UAAU,UAAU,aAAc;AAAA,IAAA,CAC5C;AAEG,QAAA;AACF,MAAAL,IAAcI,EAA+BN,CAAI,GACjD,QAAQ,IAAI,mBAAm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AA;AACF,MAAAA,EAAyB,MAAM;AAAA,aACxBO,GAAG;AAEF,cAAA,IAAI,0CAA0CA,CAAC;AAAA,IACzD;AAAA,KACC,CAAC,GAGFF,KACM,QAAA,MAAM,qBAAqBA,CAAgB,GAC5C,MAGFD;AACT;"}
1
+ {"version":3,"file":"copy.es.js","sources":["../../src/utils/copy.ts"],"sourcesContent":["export const copyTextToClipboard = async (\n text: string,\n onError?: (error: Error) => void\n): Promise<boolean> => {\n let copySuccess = false;\n if (navigator.clipboard) {\n try {\n await navigator.clipboard.writeText(text);\n copySuccess = true;\n } catch (error) {\n onError ? onError?.(error) : console.error(error);\n }\n } else {\n copySuccess = DEPRECATED_copyTextToClipboard(text);\n }\n if (!copySuccess) {\n onError ? onError?.(new Error(\"Failed to copy to clipboard\")) : console.error(\"Failed to copy to clipboard\");\n }\n return copySuccess;\n};\n\n/**\n * Fallback legacy function to copy text to clipboard for browsers that don't support navigator.clipboard.writeText\n * @reference https://github.com/sindresorhus/copy-text-to-clipboard/blob/main/index.js\n * @deprecated Use navigator.clipboard.writeText instead\n */\nconst DEPRECATED_copyTextToClipboard = (\n text,\n { target = document.body } = {}\n) => {\n if (typeof text !== \"string\") {\n throw new TypeError(\n `Expected parameter \\`text\\` to be a \\`string\\`, got \\`${typeof text}\\`.`\n );\n }\n\n const element = document.createElement(\"textarea\");\n const previouslyFocusedElement = document.activeElement;\n\n element.value = text;\n\n // Prevent keyboard from showing on mobile\n element.setAttribute(\"readonly\", \"\");\n\n element.style.contain = \"strict\";\n element.style.position = \"absolute\";\n element.style.left = \"-9999px\";\n element.style.fontSize = \"12pt\"; // Prevent zooming on iOS\n\n const selection = document.getSelection();\n const originalRange = selection.rangeCount > 0 && selection.getRangeAt(0);\n\n target.append(element);\n element.select();\n\n // Explicit selection workaround for iOS\n element.selectionStart = 0;\n element.selectionEnd = text.length;\n\n let isSuccess = false;\n try {\n isSuccess = document.execCommand(\"copy\");\n } catch {}\n\n element.remove();\n\n if (originalRange) {\n selection.removeAllRanges();\n selection.addRange(originalRange);\n }\n\n // Get the focus back on the previously focused element, if any\n if (previouslyFocusedElement instanceof HTMLElement) {\n previouslyFocusedElement.focus();\n }\n\n return isSuccess;\n};\n"],"names":["copyTextToClipboard","text","onError","copySuccess","error","DEPRECATED_copyTextToClipboard","target","element","previouslyFocusedElement","selection","originalRange","isSuccess"],"mappings":"AAAa,MAAAA,IAAsB,OACjCC,GACAC,MACqB;AACrB,MAAIC,IAAc;AAClB,MAAI,UAAU;AACR,QAAA;AACI,YAAA,UAAU,UAAU,UAAUF,CAAI,GAC1BE,IAAA;AAAA,aACPC,GAAO;AACd,MAAAF,IAAUA,KAAA,QAAAA,EAAUE,KAAS,QAAQ,MAAMA,CAAK;AAAA,IAClD;AAAA;AAEA,IAAAD,IAAcE,EAA+BJ,CAAI;AAEnD,SAAKE,MACOD,IAAAA,KAAA,QAAAA,EAAU,IAAI,MAAM,6BAA6B,KAAK,QAAQ,MAAM,6BAA6B,IAEtGC;AACT,GAOME,IAAiC,CACrCJ,GACA,EAAE,QAAAK,IAAS,SAAS,KAAS,IAAA,OAC1B;AACC,MAAA,OAAOL,KAAS;AAClB,UAAM,IAAI;AAAA,MACR,yDAAyD,OAAOA,CAAI;AAAA,IAAA;AAIlE,QAAAM,IAAU,SAAS,cAAc,UAAU,GAC3CC,IAA2B,SAAS;AAE1C,EAAAD,EAAQ,QAAQN,GAGRM,EAAA,aAAa,YAAY,EAAE,GAEnCA,EAAQ,MAAM,UAAU,UACxBA,EAAQ,MAAM,WAAW,YACzBA,EAAQ,MAAM,OAAO,WACrBA,EAAQ,MAAM,WAAW;AAEnB,QAAAE,IAAY,SAAS,gBACrBC,IAAgBD,EAAU,aAAa,KAAKA,EAAU,WAAW,CAAC;AAExE,EAAAH,EAAO,OAAOC,CAAO,GACrBA,EAAQ,OAAO,GAGfA,EAAQ,iBAAiB,GACzBA,EAAQ,eAAeN,EAAK;AAE5B,MAAIU,IAAY;AACZ,MAAA;AACU,IAAAA,IAAA,SAAS,YAAY,MAAM;AAAA,EAAA,QACjC;AAAA,EAAC;AAET,SAAAJ,EAAQ,OAAO,GAEXG,MACFD,EAAU,gBAAgB,GAC1BA,EAAU,SAASC,CAAa,IAI9BF,aAAoC,eACtCA,EAAyB,MAAM,GAG1BG;AACT;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protonradio/proton-ui",
3
- "version": "0.11.18-beta.5",
3
+ "version": "0.11.18-beta.7",
4
4
  "description": "",
5
5
  "main": "./dist/proton-ui.umd.js",
6
6
  "module": "./dist/proton-ui.es.js",