@protonradio/proton-ui 0.11.5-beta.1 → 0.11.5

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.
@@ -0,0 +1,2 @@
1
+ "use strict";function e(...t){return t.filter(i).join(" ")}const i=t=>typeof t=="string"||t instanceof String,s=t=>t.startsWith("http"),a=(t,n)=>{if(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||t.button&&t.button!==0)return;t.preventDefault();const r=n.startsWith("/")?n:`/${n}`;window.history.pushState({},"",r),window.dispatchEvent(new PopStateEvent("popstate"))};exports.csx=e;exports.handleInternalNavigation=a;exports.isUrlExternal=s;
2
+ //# sourceMappingURL=navigation-DdxS0JoV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-DdxS0JoV.js","sources":["../src/utils/string.ts","../src/utils/navigation.ts"],"sourcesContent":["/**\r\n * Concatenates class names into a single string, filtering out non-string values.\r\n */\r\nexport function csx(...classnames: unknown[]): string {\r\n return classnames.filter(isString).join(\" \");\r\n}\r\n\r\nconst isString = (x: unknown): boolean =>\r\n typeof x === \"string\" || x instanceof String;\r\n","/**\r\n * [isUrlExternal] - determine if passed absolute url is external to the current domain.\r\n */\r\nexport const isUrlExternal = (url: string) => {\r\n return url.startsWith(\"http\");\r\n};\r\n\r\n/**\r\n * Handles internal navigation clicks by preventing default browser behavior and\r\n * programmatically updating the URL and history state.\r\n *\r\n * @param e - The click event from the anchor element\r\n * @param to - The destination path to navigate to\r\n *\r\n * @remarks\r\n * - Converts relative paths to absolute by prepending \"/\" if needed\r\n * - Updates browser history using pushState and dispatches a popstate event\r\n */\r\nexport const handleInternalNavigation = (\r\n e: React.MouseEvent<HTMLAnchorElement>,\r\n to: string\r\n) => {\r\n // Don't handle navigation if modifier keys are pressed\r\n if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) {\r\n return;\r\n }\r\n\r\n // Don't handle middle clicks or right clicks\r\n if (e.button && e.button !== 0) {\r\n return;\r\n }\r\n\r\n e.preventDefault();\r\n\r\n // Handle relative paths\r\n const resolvedPath = to.startsWith(\"/\") ? to : `/${to}`;\r\n window.history.pushState({}, \"\", resolvedPath);\r\n window.dispatchEvent(new PopStateEvent(\"popstate\"));\r\n};\r\n"],"names":["csx","classnames","isString","x","isUrlExternal","url","handleInternalNavigation","e","to","resolvedPath"],"mappings":"aAGO,SAASA,KAAOC,EAA+B,CACpD,OAAOA,EAAW,OAAOC,CAAQ,EAAE,KAAK,GAAG,CAC7C,CAEA,MAAMA,EAAYC,GAChB,OAAOA,GAAM,UAAYA,aAAa,OCL3BC,EAAiBC,GACrBA,EAAI,WAAW,MAAM,EAcjBC,EAA2B,CACtCC,EACAC,IACG,CAOH,GALID,EAAE,SAAWA,EAAE,QAAUA,EAAE,SAAWA,EAAE,UAKxCA,EAAE,QAAUA,EAAE,SAAW,EAC3B,OAGFA,EAAE,eAAe,EAGjB,MAAME,EAAeD,EAAG,WAAW,GAAG,EAAIA,EAAK,IAAIA,CAAE,GACrD,OAAO,QAAQ,UAAU,CAAC,EAAG,GAAIC,CAAY,EAC7C,OAAO,cAAc,IAAI,cAAc,UAAU,CAAC,CACpD"}
@@ -0,0 +1,16 @@
1
+ function e(...t) {
2
+ return t.filter(s).join(" ");
3
+ }
4
+ const s = (t) => typeof t == "string" || t instanceof String, i = (t) => t.startsWith("http"), a = (t, n) => {
5
+ if (t.metaKey || t.altKey || t.ctrlKey || t.shiftKey || t.button && t.button !== 0)
6
+ return;
7
+ t.preventDefault();
8
+ const r = n.startsWith("/") ? n : `/${n}`;
9
+ window.history.pushState({}, "", r), window.dispatchEvent(new PopStateEvent("popstate"));
10
+ };
11
+ export {
12
+ e as c,
13
+ a as h,
14
+ i
15
+ };
16
+ //# sourceMappingURL=navigation-DsfDNfej.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation-DsfDNfej.mjs","sources":["../src/utils/string.ts","../src/utils/navigation.ts"],"sourcesContent":["/**\r\n * Concatenates class names into a single string, filtering out non-string values.\r\n */\r\nexport function csx(...classnames: unknown[]): string {\r\n return classnames.filter(isString).join(\" \");\r\n}\r\n\r\nconst isString = (x: unknown): boolean =>\r\n typeof x === \"string\" || x instanceof String;\r\n","/**\r\n * [isUrlExternal] - determine if passed absolute url is external to the current domain.\r\n */\r\nexport const isUrlExternal = (url: string) => {\r\n return url.startsWith(\"http\");\r\n};\r\n\r\n/**\r\n * Handles internal navigation clicks by preventing default browser behavior and\r\n * programmatically updating the URL and history state.\r\n *\r\n * @param e - The click event from the anchor element\r\n * @param to - The destination path to navigate to\r\n *\r\n * @remarks\r\n * - Converts relative paths to absolute by prepending \"/\" if needed\r\n * - Updates browser history using pushState and dispatches a popstate event\r\n */\r\nexport const handleInternalNavigation = (\r\n e: React.MouseEvent<HTMLAnchorElement>,\r\n to: string\r\n) => {\r\n // Don't handle navigation if modifier keys are pressed\r\n if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) {\r\n return;\r\n }\r\n\r\n // Don't handle middle clicks or right clicks\r\n if (e.button && e.button !== 0) {\r\n return;\r\n }\r\n\r\n e.preventDefault();\r\n\r\n // Handle relative paths\r\n const resolvedPath = to.startsWith(\"/\") ? to : `/${to}`;\r\n window.history.pushState({}, \"\", resolvedPath);\r\n window.dispatchEvent(new PopStateEvent(\"popstate\"));\r\n};\r\n"],"names":["csx","classnames","isString","x","isUrlExternal","url","handleInternalNavigation","e","to","resolvedPath"],"mappings":"AAGO,SAASA,KAAOC,GAA+B;AACpD,SAAOA,EAAW,OAAOC,CAAQ,EAAE,KAAK,GAAG;AAC7C;AAEA,MAAMA,IAAW,CAACC,MAChB,OAAOA,KAAM,YAAYA,aAAa,QCL3BC,IAAgB,CAACC,MACrBA,EAAI,WAAW,MAAM,GAcjBC,IAA2B,CACtCC,GACAC,MACG;AAOH,MALID,EAAE,WAAWA,EAAE,UAAUA,EAAE,WAAWA,EAAE,YAKxCA,EAAE,UAAUA,EAAE,WAAW;AAC3B;AAGF,EAAAA,EAAE,eAAe;AAGjB,QAAME,IAAeD,EAAG,WAAW,GAAG,IAAIA,IAAK,IAAIA,CAAE;AACrD,SAAO,QAAQ,UAAU,CAAC,GAAG,IAAIC,CAAY,GAC7C,OAAO,cAAc,IAAI,cAAc,UAAU,CAAC;AACpD;"}
package/dist/utils.cjs.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./color2k-DCgwXUem.js"),t=require("./copy-CNHg70jK.js"),a=require("./image-CUSfY1_T.js");exports.arrayToRgbString=e.arrayToRgbString;exports.darken=e.darken;exports.desaturate=e.desaturate;exports.lighten=e.lighten;exports.saturate=e.saturate;exports.toHex=e.toHex;exports.toRgba=e.toRgba;exports.transparentize=e.transparentize;exports.copyTextToClipboard=t.copyTextToClipboard;exports.csx=t.csx;exports.handleInternalNavigation=t.handleInternalNavigation;exports.isUrlExternal=t.isUrlExternal;exports.generatePalette=a.generatePalette;exports.getDominantColor=a.getDominantColor;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./color2k-DCgwXUem.js"),t=require("./navigation-DdxS0JoV.js"),a=require("./image-CUSfY1_T.js"),r=require("./copy-DxIZCnfT.js");exports.arrayToRgbString=e.arrayToRgbString;exports.darken=e.darken;exports.desaturate=e.desaturate;exports.lighten=e.lighten;exports.saturate=e.saturate;exports.toHex=e.toHex;exports.toRgba=e.toRgba;exports.transparentize=e.transparentize;exports.csx=t.csx;exports.handleInternalNavigation=t.handleInternalNavigation;exports.isUrlExternal=t.isUrlExternal;exports.generatePalette=a.generatePalette;exports.getDominantColor=a.getDominantColor;exports.copyTextToClipboard=r.copyTextToClipboard;
2
2
  //# sourceMappingURL=utils.cjs.js.map
package/dist/utils.es.js CHANGED
@@ -1,16 +1,17 @@
1
1
  import { a as e, b as r, d as s, l as o, s as n, c as i, e as l, t as g } from "./color2k-CpDB_dpw.mjs";
2
- import { a as p, c as d, h as b, i as c } from "./copy-B-xGO04t.mjs";
3
- import { g as f, a as h } from "./image-DFyN0Kd9.mjs";
2
+ import { c as p, h as c, i as d } from "./navigation-DsfDNfej.mjs";
3
+ import { g as b, a as f } from "./image-DFyN0Kd9.mjs";
4
+ import { c as T } from "./copy-qSgElu2b.mjs";
4
5
  export {
5
6
  e as arrayToRgbString,
6
- p as copyTextToClipboard,
7
- d as csx,
7
+ T as copyTextToClipboard,
8
+ p as csx,
8
9
  r as darken,
9
10
  s as desaturate,
10
- f as generatePalette,
11
- h as getDominantColor,
12
- b as handleInternalNavigation,
13
- c as isUrlExternal,
11
+ b as generatePalette,
12
+ f as getDominantColor,
13
+ c as handleInternalNavigation,
14
+ d as isUrlExternal,
14
15
  o as lighten,
15
16
  n as saturate,
16
17
  i as toHex,
@@ -1 +1 @@
1
- {"version":3,"file":"utils.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
1
+ {"version":3,"file":"utils.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protonradio/proton-ui",
3
- "version": "0.11.5-beta.1",
3
+ "version": "0.11.5",
4
4
  "description": "",
5
5
  "main": "./dist/proton-ui.umd.js",
6
6
  "module": "./dist/proton-ui.es.js",
@@ -10,6 +10,11 @@
10
10
  "import": "./dist/index.es.js",
11
11
  "require": "./dist/index.cjs.js"
12
12
  },
13
+ "./Button": {
14
+ "types": "./dist/Button.d.ts",
15
+ "import": "./dist/Button.es.js",
16
+ "require": "./dist/Button.cjs.js"
17
+ },
13
18
  "./utils": {
14
19
  "types": "./dist/utils.d.ts",
15
20
  "import": "./dist/utils.es.js",
@@ -46,6 +51,9 @@
46
51
  "*": [
47
52
  "./dist/index.d.ts"
48
53
  ],
54
+ "Button": [
55
+ "./dist/Button.d.ts"
56
+ ],
49
57
  "constants": [
50
58
  "./dist/constants.d.ts"
51
59
  ],
@@ -98,8 +106,6 @@
98
106
  "react-dom": "^18.3.1"
99
107
  },
100
108
  "peerDependencies": {
101
- "@radix-ui/react-portal": "^1.1.9",
102
- "radix-ui": "^1.4.2",
103
109
  "react-aria": "^3.39.0",
104
110
  "react-aria-components": "^1.8.0",
105
111
  "react-stately": "^3.37.0"
@@ -1,43 +0,0 @@
1
- function r(...t) {
2
- return t.filter(i).join(" ");
3
- }
4
- const i = (t) => typeof t == "string" || t instanceof String, p = (t) => t.startsWith("http"), d = (t, n) => {
5
- if (t.metaKey || t.altKey || t.ctrlKey || t.shiftKey || t.button && t.button !== 0)
6
- return;
7
- t.preventDefault();
8
- const e = n.startsWith("/") ? n : `/${n}`;
9
- window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate"));
10
- }, u = async (t, n) => {
11
- let e = !1;
12
- if (navigator.clipboard)
13
- try {
14
- await navigator.clipboard.writeText(t), e = !0;
15
- } catch (a) {
16
- n ? n == null || n(a) : console.error(a);
17
- }
18
- else
19
- e = l(t);
20
- return e || (n ? n == null || n(new Error("Failed to copy to clipboard")) : console.error("Failed to copy to clipboard")), e;
21
- }, l = (t, { target: n = document.body } = {}) => {
22
- if (typeof t != "string")
23
- throw new TypeError(
24
- `Expected parameter \`text\` to be a \`string\`, got \`${typeof t}\`.`
25
- );
26
- const e = document.createElement("textarea"), a = document.activeElement;
27
- e.value = t, e.setAttribute("readonly", ""), e.style.contain = "strict", e.style.position = "absolute", e.style.left = "-9999px", e.style.fontSize = "12pt";
28
- const o = document.getSelection(), s = o.rangeCount > 0 && o.getRangeAt(0);
29
- n.append(e), e.select(), e.selectionStart = 0, e.selectionEnd = t.length;
30
- let c = !1;
31
- try {
32
- c = document.execCommand("copy");
33
- } catch {
34
- }
35
- return e.remove(), s && (o.removeAllRanges(), o.addRange(s)), a instanceof HTMLElement && a.focus(), c;
36
- };
37
- export {
38
- u as a,
39
- r as c,
40
- d as h,
41
- p as i
42
- };
43
- //# sourceMappingURL=copy-B-xGO04t.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"copy-B-xGO04t.mjs","sources":["../src/utils/string.ts","../src/utils/navigation.ts","../src/utils/copy.ts"],"sourcesContent":["/**\r\n * Concatenates class names into a single string, filtering out non-string values.\r\n */\r\nexport function csx(...classnames: unknown[]): string {\r\n return classnames.filter(isString).join(\" \");\r\n}\r\n\r\nconst isString = (x: unknown): boolean =>\r\n typeof x === \"string\" || x instanceof String;\r\n","/**\r\n * [isUrlExternal] - determine if passed absolute url is external to the current domain.\r\n */\r\nexport const isUrlExternal = (url: string) => {\r\n return url.startsWith(\"http\");\r\n};\r\n\r\n/**\r\n * Handles internal navigation clicks by preventing default browser behavior and\r\n * programmatically updating the URL and history state.\r\n *\r\n * @param e - The click event from the anchor element\r\n * @param to - The destination path to navigate to\r\n *\r\n * @remarks\r\n * - Converts relative paths to absolute by prepending \"/\" if needed\r\n * - Updates browser history using pushState and dispatches a popstate event\r\n */\r\nexport const handleInternalNavigation = (\r\n e: React.MouseEvent<HTMLAnchorElement>,\r\n to: string\r\n) => {\r\n // Don't handle navigation if modifier keys are pressed\r\n if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) {\r\n return;\r\n }\r\n\r\n // Don't handle middle clicks or right clicks\r\n if (e.button && e.button !== 0) {\r\n return;\r\n }\r\n\r\n e.preventDefault();\r\n\r\n // Handle relative paths\r\n const resolvedPath = to.startsWith(\"/\") ? to : `/${to}`;\r\n window.history.pushState({}, \"\", resolvedPath);\r\n window.dispatchEvent(new PopStateEvent(\"popstate\"));\r\n};\r\n","export const copyTextToClipboard = async (\r\n text: string,\r\n onError?: (error: Error) => void\r\n): Promise<boolean> => {\r\n let copySuccess = false;\r\n if (navigator.clipboard) {\r\n try {\r\n await navigator.clipboard.writeText(text);\r\n copySuccess = true;\r\n } catch (error) {\r\n onError ? onError?.(error) : console.error(error);\r\n }\r\n } else {\r\n copySuccess = DEPRECATED_copyTextToClipboard(text);\r\n }\r\n if (!copySuccess) {\r\n onError ? onError?.(new Error(\"Failed to copy to clipboard\")) : console.error(\"Failed to copy to clipboard\");\r\n }\r\n return copySuccess;\r\n};\r\n\r\n/**\r\n * Fallback legacy function to copy text to clipboard for browsers that don't support navigator.clipboard.writeText\r\n * @reference https://github.com/sindresorhus/copy-text-to-clipboard/blob/main/index.js\r\n * @deprecated Use navigator.clipboard.writeText instead\r\n */\r\nconst DEPRECATED_copyTextToClipboard = (\r\n text,\r\n { target = document.body } = {}\r\n) => {\r\n if (typeof text !== \"string\") {\r\n throw new TypeError(\r\n `Expected parameter \\`text\\` to be a \\`string\\`, got \\`${typeof text}\\`.`\r\n );\r\n }\r\n\r\n const element = document.createElement(\"textarea\");\r\n const previouslyFocusedElement = document.activeElement;\r\n\r\n element.value = text;\r\n\r\n // Prevent keyboard from showing on mobile\r\n element.setAttribute(\"readonly\", \"\");\r\n\r\n element.style.contain = \"strict\";\r\n element.style.position = \"absolute\";\r\n element.style.left = \"-9999px\";\r\n element.style.fontSize = \"12pt\"; // Prevent zooming on iOS\r\n\r\n const selection = document.getSelection();\r\n const originalRange = selection.rangeCount > 0 && selection.getRangeAt(0);\r\n\r\n target.append(element);\r\n element.select();\r\n\r\n // Explicit selection workaround for iOS\r\n element.selectionStart = 0;\r\n element.selectionEnd = text.length;\r\n\r\n let isSuccess = false;\r\n try {\r\n isSuccess = document.execCommand(\"copy\");\r\n } catch {}\r\n\r\n element.remove();\r\n\r\n if (originalRange) {\r\n selection.removeAllRanges();\r\n selection.addRange(originalRange);\r\n }\r\n\r\n // Get the focus back on the previously focused element, if any\r\n if (previouslyFocusedElement instanceof HTMLElement) {\r\n previouslyFocusedElement.focus();\r\n }\r\n\r\n return isSuccess;\r\n};\r\n"],"names":["csx","classnames","isString","x","isUrlExternal","url","handleInternalNavigation","e","to","resolvedPath","copyTextToClipboard","text","onError","copySuccess","error","DEPRECATED_copyTextToClipboard","target","element","previouslyFocusedElement","selection","originalRange","isSuccess"],"mappings":"AAGO,SAASA,KAAOC,GAA+B;AACpD,SAAOA,EAAW,OAAOC,CAAQ,EAAE,KAAK,GAAG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C,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,2 +0,0 @@
1
- "use strict";function c(...t){return t.filter(l).join(" ")}const l=t=>typeof t=="string"||t instanceof String,r=t=>t.startsWith("http"),p=(t,n)=>{if(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||t.button&&t.button!==0)return;t.preventDefault();const e=n.startsWith("/")?n:`/${n}`;window.history.pushState({},"",e),window.dispatchEvent(new PopStateEvent("popstate"))},d=async(t,n)=>{let e=!1;if(navigator.clipboard)try{await navigator.clipboard.writeText(t),e=!0}catch(a){n?n==null||n(a):console.error(a)}else e=u(t);return e||(n?n==null||n(new Error("Failed to copy to clipboard")):console.error("Failed to copy to clipboard")),e},u=(t,{target:n=document.body}={})=>{if(typeof t!="string")throw new TypeError(`Expected parameter \`text\` to be a \`string\`, got \`${typeof t}\`.`);const e=document.createElement("textarea"),a=document.activeElement;e.value=t,e.setAttribute("readonly",""),e.style.contain="strict",e.style.position="absolute",e.style.left="-9999px",e.style.fontSize="12pt";const o=document.getSelection(),i=o.rangeCount>0&&o.getRangeAt(0);n.append(e),e.select(),e.selectionStart=0,e.selectionEnd=t.length;let s=!1;try{s=document.execCommand("copy")}catch{}return e.remove(),i&&(o.removeAllRanges(),o.addRange(i)),a instanceof HTMLElement&&a.focus(),s};exports.copyTextToClipboard=d;exports.csx=c;exports.handleInternalNavigation=p;exports.isUrlExternal=r;
2
- //# sourceMappingURL=copy-CNHg70jK.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"copy-CNHg70jK.js","sources":["../src/utils/string.ts","../src/utils/navigation.ts","../src/utils/copy.ts"],"sourcesContent":["/**\r\n * Concatenates class names into a single string, filtering out non-string values.\r\n */\r\nexport function csx(...classnames: unknown[]): string {\r\n return classnames.filter(isString).join(\" \");\r\n}\r\n\r\nconst isString = (x: unknown): boolean =>\r\n typeof x === \"string\" || x instanceof String;\r\n","/**\r\n * [isUrlExternal] - determine if passed absolute url is external to the current domain.\r\n */\r\nexport const isUrlExternal = (url: string) => {\r\n return url.startsWith(\"http\");\r\n};\r\n\r\n/**\r\n * Handles internal navigation clicks by preventing default browser behavior and\r\n * programmatically updating the URL and history state.\r\n *\r\n * @param e - The click event from the anchor element\r\n * @param to - The destination path to navigate to\r\n *\r\n * @remarks\r\n * - Converts relative paths to absolute by prepending \"/\" if needed\r\n * - Updates browser history using pushState and dispatches a popstate event\r\n */\r\nexport const handleInternalNavigation = (\r\n e: React.MouseEvent<HTMLAnchorElement>,\r\n to: string\r\n) => {\r\n // Don't handle navigation if modifier keys are pressed\r\n if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) {\r\n return;\r\n }\r\n\r\n // Don't handle middle clicks or right clicks\r\n if (e.button && e.button !== 0) {\r\n return;\r\n }\r\n\r\n e.preventDefault();\r\n\r\n // Handle relative paths\r\n const resolvedPath = to.startsWith(\"/\") ? to : `/${to}`;\r\n window.history.pushState({}, \"\", resolvedPath);\r\n window.dispatchEvent(new PopStateEvent(\"popstate\"));\r\n};\r\n","export const copyTextToClipboard = async (\r\n text: string,\r\n onError?: (error: Error) => void\r\n): Promise<boolean> => {\r\n let copySuccess = false;\r\n if (navigator.clipboard) {\r\n try {\r\n await navigator.clipboard.writeText(text);\r\n copySuccess = true;\r\n } catch (error) {\r\n onError ? onError?.(error) : console.error(error);\r\n }\r\n } else {\r\n copySuccess = DEPRECATED_copyTextToClipboard(text);\r\n }\r\n if (!copySuccess) {\r\n onError ? onError?.(new Error(\"Failed to copy to clipboard\")) : console.error(\"Failed to copy to clipboard\");\r\n }\r\n return copySuccess;\r\n};\r\n\r\n/**\r\n * Fallback legacy function to copy text to clipboard for browsers that don't support navigator.clipboard.writeText\r\n * @reference https://github.com/sindresorhus/copy-text-to-clipboard/blob/main/index.js\r\n * @deprecated Use navigator.clipboard.writeText instead\r\n */\r\nconst DEPRECATED_copyTextToClipboard = (\r\n text,\r\n { target = document.body } = {}\r\n) => {\r\n if (typeof text !== \"string\") {\r\n throw new TypeError(\r\n `Expected parameter \\`text\\` to be a \\`string\\`, got \\`${typeof text}\\`.`\r\n );\r\n }\r\n\r\n const element = document.createElement(\"textarea\");\r\n const previouslyFocusedElement = document.activeElement;\r\n\r\n element.value = text;\r\n\r\n // Prevent keyboard from showing on mobile\r\n element.setAttribute(\"readonly\", \"\");\r\n\r\n element.style.contain = \"strict\";\r\n element.style.position = \"absolute\";\r\n element.style.left = \"-9999px\";\r\n element.style.fontSize = \"12pt\"; // Prevent zooming on iOS\r\n\r\n const selection = document.getSelection();\r\n const originalRange = selection.rangeCount > 0 && selection.getRangeAt(0);\r\n\r\n target.append(element);\r\n element.select();\r\n\r\n // Explicit selection workaround for iOS\r\n element.selectionStart = 0;\r\n element.selectionEnd = text.length;\r\n\r\n let isSuccess = false;\r\n try {\r\n isSuccess = document.execCommand(\"copy\");\r\n } catch {}\r\n\r\n element.remove();\r\n\r\n if (originalRange) {\r\n selection.removeAllRanges();\r\n selection.addRange(originalRange);\r\n }\r\n\r\n // Get the focus back on the previously focused element, if any\r\n if (previouslyFocusedElement instanceof HTMLElement) {\r\n previouslyFocusedElement.focus();\r\n }\r\n\r\n return isSuccess;\r\n};\r\n"],"names":["csx","classnames","isString","x","isUrlExternal","url","handleInternalNavigation","e","to","resolvedPath","copyTextToClipboard","text","onError","copySuccess","error","DEPRECATED_copyTextToClipboard","target","element","previouslyFocusedElement","selection","originalRange","isSuccess"],"mappings":"aAGO,SAASA,KAAOC,EAA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