@x33025/sveltely 0.0.45 → 0.0.46

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,52 @@
1
+ <script lang="ts">
2
+ import type { Component } from 'svelte';
3
+ import Spinner from './Spinner.svelte';
4
+
5
+ type Props = {
6
+ icon?: Component<{ class?: string }>;
7
+ label: string;
8
+ action: () => void | Promise<void>;
9
+ disabled?: boolean;
10
+ class?: string;
11
+ type?: 'button' | 'submit' | 'reset';
12
+ };
13
+
14
+ let {
15
+ icon,
16
+ label,
17
+ action,
18
+ disabled = false,
19
+ class: className = '',
20
+ type = 'button',
21
+ ...props
22
+ }: Props & Record<string, unknown> = $props();
23
+
24
+ let pending = $state(false);
25
+
26
+ const handleClick = async () => {
27
+ if (disabled || pending) return;
28
+ pending = true;
29
+ try {
30
+ await action();
31
+ } finally {
32
+ pending = false;
33
+ }
34
+ };
35
+ </script>
36
+
37
+ <button
38
+ {type}
39
+ class="inline-flex items-center gap-2 disabled:cursor-not-allowed disabled:opacity-50 {className}"
40
+ disabled={disabled || pending}
41
+ aria-busy={pending}
42
+ onclick={handleClick}
43
+ {...props}
44
+ >
45
+ {#if pending}
46
+ <Spinner class="size-4" />
47
+ {:else if icon}
48
+ {@const Icon = icon}
49
+ <Icon class="size-4" />
50
+ {/if}
51
+ <span>{label}</span>
52
+ </button>
@@ -0,0 +1,15 @@
1
+ import type { Component } from 'svelte';
2
+ type Props = {
3
+ icon?: Component<{
4
+ class?: string;
5
+ }>;
6
+ label: string;
7
+ action: () => void | Promise<void>;
8
+ disabled?: boolean;
9
+ class?: string;
10
+ type?: 'button' | 'submit' | 'reset';
11
+ };
12
+ type $$ComponentProps = Props & Record<string, unknown>;
13
+ declare const AsyncButton: Component<$$ComponentProps, {}, "">;
14
+ type AsyncButton = ReturnType<typeof AsyncButton>;
15
+ 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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x33025/sveltely",
3
- "version": "0.0.45",
3
+ "version": "0.0.46",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",