@protonradio/proton-ui 0.11.18-beta.1 → 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 n=async(o,t)=>{let e=!1;if(console.log("copyTextToClipboard",{text:o}),console.log("navigator",navigator),console.log("navigator.clipboard",navigator.clipboard),console.log("navigator.clipboard.writeText",navigator.clipboard.writeText),navigator.clipboard){console.log("navigator.clipboard is supported");try{await navigator.clipboard.writeText(o),e=!0}catch(a){t?t==null||t(a):console.error(a)}}else console.log("navigator.clipboard is not supported, using fallback"),e=s(o);return console.log("copySuccess",e),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"),a=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 c=document.getSelection(),l=c.rangeCount>0&&c.getRangeAt(0);t.append(e),e.select(),e.selectionStart=0,e.selectionEnd=o.length;let i=!1;try{i=document.execCommand("copy")}catch{}return e.remove(),l&&(c.removeAllRanges(),c.addRange(l)),a instanceof HTMLElement&&a.focus(),i};exports.copyTextToClipboard=n;
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 console.log(\"copyTextToClipboard\", { text });\n console.log(\"navigator\", navigator);\n console.log(\"navigator.clipboard\", navigator.clipboard);\n console.log(\"navigator.clipboard.writeText\", navigator.clipboard.writeText);\n if (navigator.clipboard) {\n console.log(\"navigator.clipboard is supported\");\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 console.log(\"navigator.clipboard is not supported, using fallback\");\n copySuccess = DEPRECATED_copyTextToClipboard(text);\n }\n console.log(\"copySuccess\", copySuccess);\n if (!copySuccess) {\n onError\n ? onError?.(new Error(\"Failed to copy to clipboard\"))\n : 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,GAKlB,GAJA,QAAQ,IAAI,sBAAuB,CAAE,KAAAF,CAAM,CAAA,EACnC,QAAA,IAAI,YAAa,SAAS,EAC1B,QAAA,IAAI,sBAAuB,UAAU,SAAS,EACtD,QAAQ,IAAI,gCAAiC,UAAU,UAAU,SAAS,EACtE,UAAU,UAAW,CACvB,QAAQ,IAAI,kCAAkC,EAC1C,GAAA,CACI,MAAA,UAAU,UAAU,UAAUA,CAAI,EAC1BE,EAAA,SACPC,EAAO,CACdF,EAAUA,GAAA,MAAAA,EAAUE,GAAS,QAAQ,MAAMA,CAAK,CAClD,CAAA,MAEA,QAAQ,IAAI,sDAAsD,EAClED,EAAcE,EAA+BJ,CAAI,EAE3C,eAAA,IAAI,cAAeE,CAAW,EACjCA,IAECD,EAAAA,GAAA,MAAAA,EAAU,IAAI,MAAM,6BAA6B,GACjD,QAAQ,MAAM,6BAA6B,GAE1CC,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,32 +1,59 @@
1
- const s = async (o, t) => {
1
+ const i = async (l, c) => {
2
2
  let e = !1;
3
- if (console.log("copyTextToClipboard", { text: o }), console.log("navigator", navigator), console.log("navigator.clipboard", navigator.clipboard), console.log("navigator.clipboard.writeText", navigator.clipboard.writeText), navigator.clipboard) {
4
- console.log("navigator.clipboard is supported");
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
+ });
5
11
  try {
6
- await navigator.clipboard.writeText(o), e = !0;
7
- } catch (a) {
8
- t ? t == null || t(a) : console.error(a);
12
+ await navigator.clipboard.writeText(l), e = !0;
13
+ } catch (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
+ }
9
24
  }
10
- } else
11
- console.log("navigator.clipboard is not supported, using fallback"), e = n(o);
12
- return console.log("copySuccess", e), e || (t ? t == null || t(new Error("Failed to copy to clipboard")) : console.error("Failed to copy to clipboard")), e;
13
- }, n = (o, { target: t = document.body } = {}) => {
14
- if (typeof o != "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")
15
42
  throw new TypeError(
16
- `Expected parameter \`text\` to be a \`string\`, got \`${typeof o}\`.`
43
+ `Expected parameter \`text\` to be a \`string\`, got \`${typeof l}\`.`
17
44
  );
18
- const e = document.createElement("textarea"), a = document.activeElement;
19
- e.value = o, e.setAttribute("readonly", ""), e.style.contain = "strict", e.style.position = "absolute", e.style.left = "-9999px", e.style.fontSize = "12pt";
20
- const c = document.getSelection(), l = c.rangeCount > 0 && c.getRangeAt(0);
21
- t.append(e), e.select(), e.selectionStart = 0, e.selectionEnd = o.length;
22
- let i = !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;
23
50
  try {
24
- i = document.execCommand("copy");
51
+ a = document.execCommand("copy");
25
52
  } catch {
26
53
  }
27
- return e.remove(), l && (c.removeAllRanges(), c.addRange(l)), a instanceof HTMLElement && a.focus(), i;
54
+ return e.remove(), o && (r.removeAllRanges(), r.addRange(o)), t instanceof HTMLElement && t.focus(), a;
28
55
  };
29
56
  export {
30
- s as copyTextToClipboard
57
+ i as copyTextToClipboard
31
58
  };
32
59
  //# 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 console.log(\"copyTextToClipboard\", { text });\n console.log(\"navigator\", navigator);\n console.log(\"navigator.clipboard\", navigator.clipboard);\n console.log(\"navigator.clipboard.writeText\", navigator.clipboard.writeText);\n if (navigator.clipboard) {\n console.log(\"navigator.clipboard is supported\");\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 console.log(\"navigator.clipboard is not supported, using fallback\");\n copySuccess = DEPRECATED_copyTextToClipboard(text);\n }\n console.log(\"copySuccess\", copySuccess);\n if (!copySuccess) {\n onError\n ? onError?.(new Error(\"Failed to copy to clipboard\"))\n : 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;AAKlB,MAJA,QAAQ,IAAI,uBAAuB,EAAE,MAAAF,EAAM,CAAA,GACnC,QAAA,IAAI,aAAa,SAAS,GAC1B,QAAA,IAAI,uBAAuB,UAAU,SAAS,GACtD,QAA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G1BG;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,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AAQ,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.18-beta.1",
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",