@protonradio/proton-ui 0.11.17 → 0.11.18-beta.2

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"),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",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"),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;
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 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,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,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 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,7 +1,7 @@
1
1
  import { j as t } from "../../../node_modules/react/jsx-runtime.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";
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";
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: r
12
+ onSuccess: n
13
13
  }) {
14
- const [a, n] = u(!1);
14
+ const [a, r] = c(!1);
15
15
  return /* @__PURE__ */ t.jsx(
16
- x,
16
+ l,
17
17
  {
18
18
  name: o,
19
19
  value: p,
20
20
  isDisabled: s,
21
21
  suffix: /* @__PURE__ */ t.jsx(
22
- l,
22
+ x,
23
23
  {
24
24
  isCopied: a,
25
25
  onClick: async () => {
26
- await c(p, i) && (n(!0), r == null || r(), setTimeout(() => n(!1), 5e3));
26
+ console.log("copy button clicked", { value: p }), await u(p, i) && (r(!0), n == null || n(), setTimeout(() => r(!1), 5e3));
27
27
  }
28
28
  }
29
29
  )
30
30
  }
31
31
  );
32
32
  }
33
- const l = ({ isCopied: o, onClick: p }) => /* @__PURE__ */ t.jsx("div", { className: "proton-CopyInput-button-container", onClick: p, children: /* @__PURE__ */ t.jsxs(
33
+ const x = ({ isCopied: o, onClick: p }) => /* @__PURE__ */ t.jsx("div", { className: "proton-CopyInput-button-container", onClick: p, children: /* @__PURE__ */ t.jsxs(
34
34
  "button",
35
35
  {
36
36
  "data-testid": "COPY_BUTTON",
@@ -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 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;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,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 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,2 +1,2 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=async(l,c)=>{let e=!1;const t=o=>{const a=o instanceof Error?o.message:"Failed to copy to clipboard";console.error(a),c==null||c(new Error(a))};if(typeof navigator<"u"&&navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){console.log("clipboard API IS available, using clipboard API",{navigator});try{await navigator.clipboard.writeText(l),e=!0}catch(o){console.log("clipboard API failed, trying fallback",{error:o});try{e=n(l),e||(console.log("fallback unsuccessful, calling onErrorCallback",{error:o}),t(o))}catch(a){console.log("fallback errored, calling onErrorCallback",{fallbackError:a}),t(a)}}}else{console.log("clipboard API NOT available, using fallback");try{e=n(l),e||(console.log("fallback unsuccessful, calling onErrorCallback",{copySuccess:e}),t(new Error("Failed to copy to clipboard: Clipboard API not available and fallback method failed")))}catch(o){console.log("fallback errored, calling onErrorCallback",{error:o}),t(o)}}return e},n=(l,{target:c=document.body}={})=>{if(typeof l!="string")throw new TypeError(`Expected parameter \`text\` to be a \`string\`, got \`${typeof l}\`.`);const e=document.createElement("textarea"),t=document.activeElement;e.value=l,e.setAttribute("readonly",""),e.style.contain="strict",e.style.position="absolute",e.style.left="-9999px",e.style.fontSize="12pt";const r=document.getSelection(),o=r.rangeCount>0&&r.getRangeAt(0);c.append(e),e.select(),e.selectionStart=0,e.selectionEnd=l.length;let a=!1;try{a=document.execCommand("copy")}catch{}return e.remove(),o&&(r.removeAllRanges(),r.addRange(o)),t instanceof HTMLElement&&t.focus(),a};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 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
+ {"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: navigator.clipboard may be undefined in non-secure contexts (non-HTTPS)\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 IS available, using clipboard API\", {\n navigator,\n });\n try {\n await navigator.clipboard.writeText(text);\n copySuccess = true;\n } catch (error) {\n // If clipboard API fails, try fallback\n\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 }\n } catch (fallbackError) {\n console.log(\"fallback errored, calling onErrorCallback\", {\n fallbackError,\n });\n onErrorCallback(fallbackError);\n }\n }\n } else {\n // Use fallback method when clipboard API is not available\n\n console.log(\"clipboard API NOT available, using fallback\");\n try {\n copySuccess = DEPRECATED_copyTextToClipboard(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\"\n )\n );\n }\n } catch (error) {\n console.log(\"fallback errored, calling onErrorCallback\", { error });\n onErrorCallback(error);\n }\n }\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","onErrorCallback","error","errorMessage","DEPRECATED_copyTextToClipboard","fallbackError","target","element","previouslyFocusedElement","selection","originalRange","isSuccess"],"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,EAUnC,GAJE,OAAO,UAAc,KACrB,UAAU,WACV,OAAO,UAAU,UAAU,WAAc,WAEjB,CACxB,QAAQ,IAAI,kDAAmD,CAC7D,SAAA,CACD,EACG,GAAA,CACI,MAAA,UAAU,UAAU,UAAUL,CAAI,EAC1BE,EAAA,SACPE,EAAO,CAGd,QAAQ,IAAI,wCAAyC,CAAE,MAAAA,CAAO,CAAA,EAC1D,GAAA,CACFF,EAAcI,EAA+BN,CAAI,EAE5CE,IACH,QAAQ,IAAI,iDAAkD,CAC5D,MAAAE,CAAA,CACD,EACDD,EAAgBC,CAAK,SAEhBG,EAAe,CACtB,QAAQ,IAAI,4CAA6C,CACvD,cAAAA,CAAA,CACD,EACDJ,EAAgBI,CAAa,CAC/B,CACF,CAAA,KACK,CAGL,QAAQ,IAAI,8CAA8C,EACtD,GAAA,CACFL,EAAcI,EAA+BN,CAAI,EAC5CE,IACH,QAAQ,IAAI,iDAAkD,CAC5D,YAAAA,CAAA,CACD,EACDC,EACE,IAAI,MACF,qFACF,CAAA,SAGGC,EAAO,CACd,QAAQ,IAAI,4CAA6C,CAAE,MAAAA,CAAO,CAAA,EAClED,EAAgBC,CAAK,CACvB,CACF,CAEO,OAAAF,CACT,EAOMI,EAAiC,CACrCN,EACA,CAAE,OAAAQ,EAAS,SAAS,IAAS,EAAA,KAC1B,CACC,GAAA,OAAOR,GAAS,SAClB,MAAM,IAAI,UACR,yDAAyD,OAAOA,CAAI,KAAA,EAIlE,MAAAS,EAAU,SAAS,cAAc,UAAU,EAC3CC,EAA2B,SAAS,cAE1CD,EAAQ,MAAQT,EAGRS,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,aAAeT,EAAK,OAE5B,IAAIa,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,29 +1,57 @@
1
- const i = async (c, t) => {
1
+ const i = async (l, c) => {
2
2
  let e = !1;
3
- if (navigator.clipboard)
3
+ const t = (o) => {
4
+ const a = o instanceof Error ? o.message : "Failed to copy to clipboard";
5
+ console.error(a), c == null || c(new Error(a));
6
+ };
7
+ if (typeof navigator < "u" && navigator.clipboard && typeof navigator.clipboard.writeText == "function") {
8
+ console.log("clipboard API IS available, using clipboard API", {
9
+ navigator
10
+ });
4
11
  try {
5
- await navigator.clipboard.writeText(c), e = !0;
12
+ await navigator.clipboard.writeText(l), e = !0;
6
13
  } catch (o) {
7
- t ? t == null || t(o) : console.error(o);
14
+ console.log("clipboard API failed, trying fallback", { error: o });
15
+ try {
16
+ e = n(l), e || (console.log("fallback unsuccessful, calling onErrorCallback", {
17
+ error: o
18
+ }), t(o));
19
+ } catch (a) {
20
+ console.log("fallback errored, calling onErrorCallback", {
21
+ fallbackError: a
22
+ }), t(a);
23
+ }
8
24
  }
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")
25
+ } else {
26
+ console.log("clipboard API NOT available, using fallback");
27
+ try {
28
+ e = n(l), e || (console.log("fallback unsuccessful, calling onErrorCallback", {
29
+ copySuccess: e
30
+ }), t(
31
+ new Error(
32
+ "Failed to copy to clipboard: Clipboard API not available and fallback method failed"
33
+ )
34
+ ));
35
+ } catch (o) {
36
+ console.log("fallback errored, calling onErrorCallback", { error: o }), t(o);
37
+ }
38
+ }
39
+ return e;
40
+ }, n = (l, { target: c = document.body } = {}) => {
41
+ if (typeof l != "string")
14
42
  throw new TypeError(
15
- `Expected parameter \`text\` to be a \`string\`, got \`${typeof c}\`.`
43
+ `Expected parameter \`text\` to be a \`string\`, got \`${typeof l}\`.`
16
44
  );
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;
45
+ const e = document.createElement("textarea"), t = document.activeElement;
46
+ e.value = l, e.setAttribute("readonly", ""), e.style.contain = "strict", e.style.position = "absolute", e.style.left = "-9999px", e.style.fontSize = "12pt";
47
+ const r = document.getSelection(), o = r.rangeCount > 0 && r.getRangeAt(0);
48
+ c.append(e), e.select(), e.selectionStart = 0, e.selectionEnd = l.length;
49
+ let a = !1;
22
50
  try {
23
- n = document.execCommand("copy");
51
+ a = document.execCommand("copy");
24
52
  } catch {
25
53
  }
26
- return e.remove(), l && (a.removeAllRanges(), a.addRange(l)), o instanceof HTMLElement && o.focus(), n;
54
+ return e.remove(), o && (r.removeAllRanges(), r.addRange(o)), t instanceof HTMLElement && t.focus(), a;
27
55
  };
28
56
  export {
29
57
  i as copyTextToClipboard
@@ -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 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;"}
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: navigator.clipboard may be undefined in non-secure contexts (non-HTTPS)\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 IS available, using clipboard API\", {\n navigator,\n });\n try {\n await navigator.clipboard.writeText(text);\n copySuccess = true;\n } catch (error) {\n // If clipboard API fails, try fallback\n\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 }\n } catch (fallbackError) {\n console.log(\"fallback errored, calling onErrorCallback\", {\n fallbackError,\n });\n onErrorCallback(fallbackError);\n }\n }\n } else {\n // Use fallback method when clipboard API is not available\n\n console.log(\"clipboard API NOT available, using fallback\");\n try {\n copySuccess = DEPRECATED_copyTextToClipboard(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\"\n )\n );\n }\n } catch (error) {\n console.log(\"fallback errored, calling onErrorCallback\", { error });\n onErrorCallback(error);\n }\n }\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","onErrorCallback","error","errorMessage","DEPRECATED_copyTextToClipboard","fallbackError","target","element","previouslyFocusedElement","selection","originalRange","isSuccess"],"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;AAUnC,MAJE,OAAO,YAAc,OACrB,UAAU,aACV,OAAO,UAAU,UAAU,aAAc,YAEjB;AACxB,YAAQ,IAAI,mDAAmD;AAAA,MAC7D;AAAA,IAAA,CACD;AACG,QAAA;AACI,YAAA,UAAU,UAAU,UAAUL,CAAI,GAC1BE,IAAA;AAAA,aACPE,GAAO;AAGd,cAAQ,IAAI,yCAAyC,EAAE,OAAAA,EAAO,CAAA;AAC1D,UAAA;AACF,QAAAF,IAAcI,EAA+BN,CAAI,GAE5CE,MACH,QAAQ,IAAI,kDAAkD;AAAA,UAC5D,OAAAE;AAAA,QAAA,CACD,GACDD,EAAgBC,CAAK;AAAA,eAEhBG,GAAe;AACtB,gBAAQ,IAAI,6CAA6C;AAAA,UACvD,eAAAA;AAAA,QAAA,CACD,GACDJ,EAAgBI,CAAa;AAAA,MAC/B;AAAA,IACF;AAAA,EAAA,OACK;AAGL,YAAQ,IAAI,8CAA8C;AACtD,QAAA;AACF,MAAAL,IAAcI,EAA+BN,CAAI,GAC5CE,MACH,QAAQ,IAAI,kDAAkD;AAAA,QAC5D,aAAAA;AAAA,MAAA,CACD,GACDC;AAAA,QACE,IAAI;AAAA,UACF;AAAA,QACF;AAAA,MAAA;AAAA,aAGGC,GAAO;AACd,cAAQ,IAAI,6CAA6C,EAAE,OAAAA,EAAO,CAAA,GAClED,EAAgBC,CAAK;AAAA,IACvB;AAAA,EACF;AAEO,SAAAF;AACT,GAOMI,IAAiC,CACrCN,GACA,EAAE,QAAAQ,IAAS,SAAS,KAAS,IAAA,OAC1B;AACC,MAAA,OAAOR,KAAS;AAClB,UAAM,IAAI;AAAA,MACR,yDAAyD,OAAOA,CAAI;AAAA,IAAA;AAIlE,QAAAS,IAAU,SAAS,cAAc,UAAU,GAC3CC,IAA2B,SAAS;AAE1C,EAAAD,EAAQ,QAAQT,GAGRS,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,eAAeT,EAAK;AAE5B,MAAIa,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.17",
3
+ "version": "0.11.18-beta.2",
4
4
  "description": "",
5
5
  "main": "./dist/proton-ui.umd.js",
6
6
  "module": "./dist/proton-ui.es.js",