@gpustack/core-ui 1.0.19 → 1.0.20
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.
|
@@ -209,44 +209,45 @@ var O = { wrapper: "index-module__wrapper___AP3Au" }, k = ({ children: e, maxHei
|
|
|
209
209
|
w(!1);
|
|
210
210
|
}, 3e3);
|
|
211
211
|
}, D = async (e) => {
|
|
212
|
+
if (!navigator.clipboard?.writeText || typeof window.isSecureContext == "boolean" && !window.isSecureContext) return !1;
|
|
212
213
|
try {
|
|
213
|
-
return await navigator.clipboard.writeText(e), !0;
|
|
214
|
+
return document.hasFocus() || window.focus(), await navigator.clipboard.writeText(e), !0;
|
|
214
215
|
} catch {
|
|
215
216
|
return !1;
|
|
216
217
|
}
|
|
217
218
|
}, O = (e) => {
|
|
218
|
-
let t =
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
let t = document.createElement("textarea");
|
|
220
|
+
t.value = e, t.setAttribute("readonly", ""), t.style.cssText = "position:fixed;top:0;left:0;width:1px;height:1px;padding:0;border:none;outline:none;box-shadow:none;background:transparent;opacity:0;pointer-events:none;", t.style.fontSize = "12pt";
|
|
221
|
+
let n = document.getSelection(), r = n && n.rangeCount > 0 ? n.getRangeAt(0) : null, i = document.activeElement;
|
|
222
|
+
document.body.appendChild(t);
|
|
223
|
+
let a = !1;
|
|
221
224
|
try {
|
|
222
|
-
|
|
225
|
+
let r = document.createRange();
|
|
226
|
+
r.selectNodeContents(t), n?.removeAllRanges(), n?.addRange(r), t.setSelectionRange(0, e.length), t.focus(), a = document.execCommand("copy");
|
|
223
227
|
} catch {
|
|
224
|
-
|
|
228
|
+
a = !1;
|
|
225
229
|
} finally {
|
|
226
|
-
document.
|
|
230
|
+
document.body.removeChild(t), n && (n.removeAllRanges(), r && n.addRange(r)), i?.focus?.();
|
|
227
231
|
}
|
|
232
|
+
return a;
|
|
228
233
|
}, k = async () => {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
throw Error("Copy failed");
|
|
239
|
-
} catch {
|
|
240
|
-
b.error(S.formatMessage({ id: "common.copy.fail" }));
|
|
234
|
+
if (await D(n)) {
|
|
235
|
+
w(!0);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
if (O(n)) {
|
|
239
|
+
w(!0);
|
|
240
|
+
return;
|
|
241
241
|
}
|
|
242
|
+
b.error(S.formatMessage({ id: "common.copy.fail" }));
|
|
242
243
|
}, A = l(() => C ? S.formatMessage({ id: "common.button.copied" }) : t ?? S.formatMessage({ id: "common.button.copy" }), [
|
|
243
244
|
C,
|
|
244
245
|
t,
|
|
245
246
|
S
|
|
246
247
|
]);
|
|
247
|
-
return c(() => {
|
|
248
|
-
|
|
249
|
-
}, [C]), /* @__PURE__ */ p("div", {
|
|
248
|
+
return c(() => (E(), () => {
|
|
249
|
+
window.clearTimeout(T.current);
|
|
250
|
+
}), [C]), /* @__PURE__ */ p("div", {
|
|
250
251
|
className: "flex-center gap-4",
|
|
251
252
|
style: { minWidth: 16 },
|
|
252
253
|
children: [e && /* @__PURE__ */ f(M, {
|