fuma 0.3.22 → 0.3.24
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.
- package/dist/ui/button/ButtonCopy.svelte +31 -6
- package/dist/ui/button/ButtonCopy.svelte.d.ts +2 -2
- package/dist/ui/form/Form.svelte +5 -2
- package/dist/ui/form/Form.svelte.d.ts +3 -0
- package/dist/utils/csv.d.ts +2 -0
- package/dist/utils/csv.js +8 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +1 -1
|
@@ -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>
|
package/dist/ui/form/Form.svelte
CHANGED
|
@@ -96,7 +96,7 @@ const getBoolean = (bool) => (_data) => typeof bool === "boolean" || bool === vo
|
|
|
96
96
|
>
|
|
97
97
|
<slot />
|
|
98
98
|
|
|
99
|
-
{#if data
|
|
99
|
+
{#if data?.id}
|
|
100
100
|
<input type="hidden" name="id" value={data.id} />
|
|
101
101
|
{/if}
|
|
102
102
|
|
|
@@ -137,7 +137,10 @@ const getBoolean = (bool) => (_data) => typeof bool === "boolean" || bool === vo
|
|
|
137
137
|
<button class="btn btn-primary"> Valider </button>
|
|
138
138
|
<div class="grow" />
|
|
139
139
|
{#if data.id && actionDelete}
|
|
140
|
-
|
|
140
|
+
{@const formaction = `${action}${actionDelete}`}
|
|
141
|
+
<slot name="delete" {formaction}>
|
|
142
|
+
<ButtonDelete {formaction}>Supprimer</ButtonDelete>
|
|
143
|
+
</slot>
|
|
141
144
|
{/if}
|
|
142
145
|
</div>
|
|
143
146
|
</form>
|
|
@@ -33,6 +33,9 @@ declare class __sveltets_Render<Shape extends z.ZodRawShape, ReturnData extends
|
|
|
33
33
|
};
|
|
34
34
|
slots(): {
|
|
35
35
|
default: {};
|
|
36
|
+
delete: {
|
|
37
|
+
formaction: any;
|
|
38
|
+
};
|
|
36
39
|
};
|
|
37
40
|
}
|
|
38
41
|
export type FormProps<Shape extends z.ZodRawShape, ReturnData extends Record<string, unknown> = FormDataInput<Shape>, Data extends FormDataInput<Shape> = FormDataInput<Shape>> = ReturnType<__sveltets_Render<Shape, ReturnData, Data>['props']>;
|
|
@@ -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