fuma 0.3.22 → 0.3.23
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,11 +1,22 @@
|
|
|
1
1
|
<script>import { mdiClipboardTextOutline } from "@mdi/js";
|
|
2
2
|
import { toast } from "svelte-sonner";
|
|
3
3
|
import { Icon } from "../icon/index.js";
|
|
4
|
-
|
|
5
|
-
export
|
|
4
|
+
let valueOrGetValue;
|
|
5
|
+
export { valueOrGetValue as value };
|
|
6
|
+
export let title = "";
|
|
6
7
|
export let icon = mdiClipboardTextOutline;
|
|
7
8
|
export let successMessage = "Copied";
|
|
8
|
-
|
|
9
|
+
let isLoading = false;
|
|
10
|
+
async function loadValue() {
|
|
11
|
+
if (typeof valueOrGetValue === "string")
|
|
12
|
+
return valueOrGetValue;
|
|
13
|
+
return valueOrGetValue();
|
|
14
|
+
}
|
|
15
|
+
async function handleClick() {
|
|
16
|
+
if (isLoading)
|
|
17
|
+
return;
|
|
18
|
+
isLoading = true;
|
|
19
|
+
const value = await loadValue().finally(() => isLoading = false);
|
|
9
20
|
navigator.clipboard.writeText(value).then(() => {
|
|
10
21
|
toast.success(successMessage);
|
|
11
22
|
}).catch((error) => {
|
|
@@ -14,6 +25,20 @@ function handleClick() {
|
|
|
14
25
|
}
|
|
15
26
|
</script>
|
|
16
27
|
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
<div class="relative">
|
|
29
|
+
{#if isLoading}
|
|
30
|
+
<span class="loading loading-spinner absolute left-1 top-1 scale-125 opacity-25" />
|
|
31
|
+
{/if}
|
|
32
|
+
<button
|
|
33
|
+
class="btn btn-square btn-sm"
|
|
34
|
+
on:click|preventDefault={handleClick}
|
|
35
|
+
class:btn-disabled={isLoading}
|
|
36
|
+
>
|
|
37
|
+
<Icon
|
|
38
|
+
path={icon}
|
|
39
|
+
size={20}
|
|
40
|
+
{title}
|
|
41
|
+
class="transition-transform {isLoading ? 'scale-75' : ''}"
|
|
42
|
+
/>
|
|
43
|
+
</button>
|
|
44
|
+
</div>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function getCSV(items, fields) {
|
|
2
|
+
const headers = Object.keys(fields).join('\t');
|
|
3
|
+
const rows = items.map((m) => Object.values(fields)
|
|
4
|
+
.filter((getValue) => !!getValue)
|
|
5
|
+
.map((getValue) => getValue(m))
|
|
6
|
+
.join('\t'));
|
|
7
|
+
return [headers, rows.join('\r\n')].join('\r\n');
|
|
8
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED