@x33025/sveltely 0.0.45 → 0.0.47
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/components/AsyncButton.svelte +50 -0
- package/dist/components/AsyncButton.svelte.d.ts +12 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/style.css +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
4
|
+
import Spinner from './Spinner.svelte';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
icon?: Component<{ class?: string }>;
|
|
8
|
+
label: string;
|
|
9
|
+
action: () => void | Promise<void>;
|
|
10
|
+
} & Omit<HTMLButtonAttributes, 'children' | 'onclick'>;
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
icon,
|
|
14
|
+
label,
|
|
15
|
+
action,
|
|
16
|
+
disabled = false,
|
|
17
|
+
class: className = '',
|
|
18
|
+
type = 'button',
|
|
19
|
+
...props
|
|
20
|
+
}: Props = $props();
|
|
21
|
+
|
|
22
|
+
let pending = $state(false);
|
|
23
|
+
|
|
24
|
+
const handleClick = async () => {
|
|
25
|
+
if (disabled || pending) return;
|
|
26
|
+
pending = true;
|
|
27
|
+
try {
|
|
28
|
+
await action();
|
|
29
|
+
} finally {
|
|
30
|
+
pending = false;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<button
|
|
36
|
+
{type}
|
|
37
|
+
class="inline-flex items-center gap-2 disabled:cursor-not-allowed disabled:opacity-50 {className}"
|
|
38
|
+
disabled={disabled || pending}
|
|
39
|
+
aria-busy={pending}
|
|
40
|
+
{...props}
|
|
41
|
+
onclick={handleClick}
|
|
42
|
+
>
|
|
43
|
+
{#if pending}
|
|
44
|
+
<Spinner class="size-4" />
|
|
45
|
+
{:else if icon}
|
|
46
|
+
{@const Icon = icon}
|
|
47
|
+
<Icon class="size-4" />
|
|
48
|
+
{/if}
|
|
49
|
+
<span>{label}</span>
|
|
50
|
+
</button>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Component } from 'svelte';
|
|
2
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
|
+
type Props = {
|
|
4
|
+
icon?: Component<{
|
|
5
|
+
class?: string;
|
|
6
|
+
}>;
|
|
7
|
+
label: string;
|
|
8
|
+
action: () => void | Promise<void>;
|
|
9
|
+
} & Omit<HTMLButtonAttributes, 'children' | 'onclick'>;
|
|
10
|
+
declare const AsyncButton: Component<Props, {}, "">;
|
|
11
|
+
type AsyncButton = ReturnType<typeof AsyncButton>;
|
|
12
|
+
export default AsyncButton;
|
package/dist/index.d.ts
CHANGED
|
@@ -13,3 +13,4 @@ export { default as Tooltip } from './components/Tooltip.svelte';
|
|
|
13
13
|
export { default as Dropdown } from './components/Dropdown';
|
|
14
14
|
export { default as Popover } from './components/Popover';
|
|
15
15
|
export { default as ChipInput } from './components/ChipInput.svelte';
|
|
16
|
+
export { default as AsyncButton } from './components/AsyncButton.svelte';
|
package/dist/index.js
CHANGED
|
@@ -13,3 +13,4 @@ export { default as Tooltip } from './components/Tooltip.svelte';
|
|
|
13
13
|
export { default as Dropdown } from './components/Dropdown';
|
|
14
14
|
export { default as Popover } from './components/Popover';
|
|
15
15
|
export { default as ChipInput } from './components/ChipInput.svelte';
|
|
16
|
+
export { default as AsyncButton } from './components/AsyncButton.svelte';
|
package/dist/style.css
CHANGED
|
@@ -373,6 +373,9 @@
|
|
|
373
373
|
.bg-zinc-50 {
|
|
374
374
|
background-color: var(--color-zinc-50);
|
|
375
375
|
}
|
|
376
|
+
.bg-zinc-900 {
|
|
377
|
+
background-color: var(--color-zinc-900);
|
|
378
|
+
}
|
|
376
379
|
.p-0 {
|
|
377
380
|
padding: calc(var(--spacing) * 0);
|
|
378
381
|
}
|
|
@@ -429,6 +432,9 @@
|
|
|
429
432
|
.text-red-700 {
|
|
430
433
|
color: var(--color-red-700);
|
|
431
434
|
}
|
|
435
|
+
.text-white {
|
|
436
|
+
color: var(--color-white);
|
|
437
|
+
}
|
|
432
438
|
.text-zinc-500 {
|
|
433
439
|
color: var(--color-zinc-500);
|
|
434
440
|
}
|
|
@@ -529,6 +535,11 @@
|
|
|
529
535
|
opacity: 40%;
|
|
530
536
|
}
|
|
531
537
|
}
|
|
538
|
+
.disabled\:opacity-50 {
|
|
539
|
+
&:disabled {
|
|
540
|
+
opacity: 50%;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
532
543
|
}
|
|
533
544
|
@layer base {
|
|
534
545
|
html, body {
|