@protonradio/proton-ui 0.11.18-beta.6 → 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"),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"),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 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 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"}
@@ -30,7 +30,7 @@ function b({
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 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 l = ({ 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 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 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 s=async(o,c)=>{let e=!1;if(navigator.clipboard&&navigator.clipboard.writeText)try{await navigator.clipboard.writeText(o),e=!0}catch{e=!1}if(!e)try{e=i(o)}catch(t){const r="Failed to copy to clipboard";c?c(new Error(r)):console.error(r,t)}if(!e){const t="Failed to copy to clipboard";c?c(new Error(t)):console.error(t)}return e},i=(o,{target:c=document.body}={})=>{if(typeof o!="string")throw new TypeError(`Expected parameter \`text\` to be a \`string\`, got \`${typeof o}\`.`);const e=document.createElement("textarea"),t=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 r=document.getSelection(),n=r.rangeCount>0&&r.getRangeAt(0);c.append(e),e.select(),e.selectionStart=0,e.selectionEnd=o.length;let a=!1;try{a=document.execCommand("copy")}catch{}return e.remove(),n&&(r.removeAllRanges(),r.addRange(n)),t instanceof HTMLElement&&t.focus(),a};exports.copyTextToClipboard=s;
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 // Try modern Clipboard API first\n if (navigator.clipboard && navigator.clipboard.writeText) {\n try {\n await navigator.clipboard.writeText(text);\n copySuccess = true;\n } catch (error) {\n // Clipboard API failed (likely due to security restrictions or broken user gesture chain)\n // Fall through to deprecated method\n copySuccess = false;\n }\n }\n\n // Fallback to deprecated method if modern API failed or doesn't exist\n // This is important because the deprecated method works better when user gesture chain is broken\n // (e.g., when focus is programmatically changed by modals, focus management, etc.)\n if (!copySuccess) {\n try {\n copySuccess = DEPRECATED_copyTextToClipboard(text);\n } catch (error) {\n // Deprecated method also failed\n const errorMessage = \"Failed to copy to clipboard\";\n if (onError) {\n onError(new Error(errorMessage));\n } else {\n console.error(errorMessage, error);\n }\n }\n }\n\n if (!copySuccess) {\n const errorMessage = \"Failed to copy to clipboard\";\n if (onError) {\n onError(new Error(errorMessage));\n } else {\n console.error(errorMessage);\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","DEPRECATED_copyTextToClipboard","error","errorMessage","target","element","previouslyFocusedElement","selection","originalRange","isSuccess"],"mappings":"gFAAa,MAAAA,EAAsB,MACjCC,EACAC,IACqB,CACrB,IAAIC,EAAc,GAGlB,GAAI,UAAU,WAAa,UAAU,UAAU,UACzC,GAAA,CACI,MAAA,UAAU,UAAU,UAAUF,CAAI,EAC1BE,EAAA,QACA,CAGAA,EAAA,EAChB,CAMF,GAAI,CAACA,EACC,GAAA,CACFA,EAAcC,EAA+BH,CAAI,QAC1CI,EAAO,CAEd,MAAMC,EAAe,8BACjBJ,EACMA,EAAA,IAAI,MAAMI,CAAY,CAAC,EAEvB,QAAA,MAAMA,EAAcD,CAAK,CAErC,CAGF,GAAI,CAACF,EAAa,CAChB,MAAMG,EAAe,8BACjBJ,EACMA,EAAA,IAAI,MAAMI,CAAY,CAAC,EAE/B,QAAQ,MAAMA,CAAY,CAE9B,CAEO,OAAAH,CACT,EAOMC,EAAiC,CACrCH,EACA,CAAE,OAAAM,EAAS,SAAS,IAAS,EAAA,KAC1B,CACC,GAAA,OAAON,GAAS,SAClB,MAAM,IAAI,UACR,yDAAyD,OAAOA,CAAI,KAAA,EAIlE,MAAAO,EAAU,SAAS,cAAc,UAAU,EAC3CC,EAA2B,SAAS,cAE1CD,EAAQ,MAAQP,EAGRO,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,aAAeP,EAAK,OAE5B,IAAIW,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 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,38 +1,29 @@
1
- const i = async (o, c) => {
1
+ const i = async (c, t) => {
2
2
  let e = !1;
3
- if (navigator.clipboard && navigator.clipboard.writeText)
3
+ if (navigator.clipboard)
4
4
  try {
5
- await navigator.clipboard.writeText(o), e = !0;
6
- } catch {
7
- e = !1;
5
+ await navigator.clipboard.writeText(c), e = !0;
6
+ } catch (o) {
7
+ t ? t == null || t(o) : console.error(o);
8
8
  }
9
- if (!e)
10
- try {
11
- e = s(o);
12
- } catch (t) {
13
- const r = "Failed to copy to clipboard";
14
- c ? c(new Error(r)) : console.error(r, t);
15
- }
16
- if (!e) {
17
- const t = "Failed to copy to clipboard";
18
- c ? c(new Error(t)) : console.error(t);
19
- }
20
- return e;
21
- }, s = (o, { target: c = document.body } = {}) => {
22
- 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")
23
14
  throw new TypeError(
24
- `Expected parameter \`text\` to be a \`string\`, got \`${typeof o}\`.`
15
+ `Expected parameter \`text\` to be a \`string\`, got \`${typeof c}\`.`
25
16
  );
26
- const e = document.createElement("textarea"), t = document.activeElement;
27
- e.value = o, e.setAttribute("readonly", ""), e.style.contain = "strict", e.style.position = "absolute", e.style.left = "-9999px", e.style.fontSize = "12pt";
28
- const r = document.getSelection(), n = r.rangeCount > 0 && r.getRangeAt(0);
29
- c.append(e), e.select(), e.selectionStart = 0, e.selectionEnd = o.length;
30
- let a = !1;
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;
31
22
  try {
32
- a = document.execCommand("copy");
23
+ n = document.execCommand("copy");
33
24
  } catch {
34
25
  }
35
- return e.remove(), n && (r.removeAllRanges(), r.addRange(n)), t instanceof HTMLElement && t.focus(), a;
26
+ return e.remove(), l && (a.removeAllRanges(), a.addRange(l)), o instanceof HTMLElement && o.focus(), n;
36
27
  };
37
28
  export {
38
29
  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\n // Try modern Clipboard API first\n if (navigator.clipboard && navigator.clipboard.writeText) {\n try {\n await navigator.clipboard.writeText(text);\n copySuccess = true;\n } catch (error) {\n // Clipboard API failed (likely due to security restrictions or broken user gesture chain)\n // Fall through to deprecated method\n copySuccess = false;\n }\n }\n\n // Fallback to deprecated method if modern API failed or doesn't exist\n // This is important because the deprecated method works better when user gesture chain is broken\n // (e.g., when focus is programmatically changed by modals, focus management, etc.)\n if (!copySuccess) {\n try {\n copySuccess = DEPRECATED_copyTextToClipboard(text);\n } catch (error) {\n // Deprecated method also failed\n const errorMessage = \"Failed to copy to clipboard\";\n if (onError) {\n onError(new Error(errorMessage));\n } else {\n console.error(errorMessage, error);\n }\n }\n }\n\n if (!copySuccess) {\n const errorMessage = \"Failed to copy to clipboard\";\n if (onError) {\n onError(new Error(errorMessage));\n } else {\n console.error(errorMessage);\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","DEPRECATED_copyTextToClipboard","error","errorMessage","target","element","previouslyFocusedElement","selection","originalRange","isSuccess"],"mappings":"AAAa,MAAAA,IAAsB,OACjCC,GACAC,MACqB;AACrB,MAAIC,IAAc;AAGlB,MAAI,UAAU,aAAa,UAAU,UAAU;AACzC,QAAA;AACI,YAAA,UAAU,UAAU,UAAUF,CAAI,GAC1BE,IAAA;AAAA,YACA;AAGA,MAAAA,IAAA;AAAA,IAChB;AAMF,MAAI,CAACA;AACC,QAAA;AACF,MAAAA,IAAcC,EAA+BH,CAAI;AAAA,aAC1CI,GAAO;AAEd,YAAMC,IAAe;AACrB,MAAIJ,IACMA,EAAA,IAAI,MAAMI,CAAY,CAAC,IAEvB,QAAA,MAAMA,GAAcD,CAAK;AAAA,IAErC;AAGF,MAAI,CAACF,GAAa;AAChB,UAAMG,IAAe;AACrB,IAAIJ,IACMA,EAAA,IAAI,MAAMI,CAAY,CAAC,IAE/B,QAAQ,MAAMA,CAAY;AAAA,EAE9B;AAEO,SAAAH;AACT,GAOMC,IAAiC,CACrCH,GACA,EAAE,QAAAM,IAAS,SAAS,KAAS,IAAA,OAC1B;AACC,MAAA,OAAON,KAAS;AAClB,UAAM,IAAI;AAAA,MACR,yDAAyD,OAAOA,CAAI;AAAA,IAAA;AAIlE,QAAAO,IAAU,SAAS,cAAc,UAAU,GAC3CC,IAA2B,SAAS;AAE1C,EAAAD,EAAQ,QAAQP,GAGRO,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,eAAeP,EAAK;AAE5B,MAAIW,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 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.6",
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",