compote-ui 0.58.1 → 0.58.2
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/toast/index.d.ts +1 -0
- package/dist/components/toast/toast.d.ts +10 -1
- package/dist/components/toast/toast.js +13 -1
- package/dist/components/toast/toaster.svelte +45 -16
- package/dist/components/toast/toaster.svelte.d.ts +3 -0
- package/dist/icons/PhCheckCircle.svelte +19 -0
- package/dist/icons/PhCheckCircle.svelte.d.ts +5 -0
- package/dist/icons/PhCircleNotch.svelte +19 -0
- package/dist/icons/PhCircleNotch.svelte.d.ts +5 -0
- package/dist/icons/PhInfo.svelte +19 -0
- package/dist/icons/PhInfo.svelte.d.ts +5 -0
- package/dist/icons/PhWarning.svelte +19 -0
- package/dist/icons/PhWarning.svelte.d.ts +5 -0
- package/dist/icons/PhXCircle.svelte +19 -0
- package/dist/icons/PhXCircle.svelte.d.ts +5 -0
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as Toaster } from './toaster.svelte';
|
|
2
2
|
export { toast } from './toast.js';
|
|
3
|
+
export type { ToastOptions, ToastType } from './toast.js';
|
|
3
4
|
export { createToaster } from '@ark-ui/svelte/toast';
|
|
4
5
|
export type { CreateToasterReturn } from '@ark-ui/svelte/toast';
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CreateToasterReturn } from '@ark-ui/svelte/toast';
|
|
2
|
+
export type ToastOptions = Parameters<CreateToasterReturn['create']>[0];
|
|
3
|
+
export type ToastType = NonNullable<ToastOptions['type']>;
|
|
4
|
+
export declare const toast: import("@zag-js/toast").Store<any> & {
|
|
5
|
+
info: (title: string | ToastOptions, options?: Omit<ToastOptions, "type">) => string;
|
|
6
|
+
success: (title: string | ToastOptions, options?: Omit<ToastOptions, "type">) => string;
|
|
7
|
+
warning: (title: string | ToastOptions, options?: Omit<ToastOptions, "type">) => string;
|
|
8
|
+
error: (title: string | ToastOptions, options?: Omit<ToastOptions, "type">) => string;
|
|
9
|
+
loading: (title: string | ToastOptions, options?: Omit<ToastOptions, "type">) => string;
|
|
10
|
+
};
|
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
import { createToaster } from '@ark-ui/svelte/toast';
|
|
2
|
-
|
|
2
|
+
const toaster = createToaster({ placement: 'bottom-end', pauseOnPageIdle: true });
|
|
3
|
+
function shorthand(type) {
|
|
4
|
+
return (title, options) => typeof title === 'string'
|
|
5
|
+
? toaster.create({ ...options, title, type })
|
|
6
|
+
: toaster.create({ ...title, type });
|
|
7
|
+
}
|
|
8
|
+
export const toast = Object.assign(toaster, {
|
|
9
|
+
info: shorthand('info'),
|
|
10
|
+
success: shorthand('success'),
|
|
11
|
+
warning: shorthand('warning'),
|
|
12
|
+
error: shorthand('error'),
|
|
13
|
+
loading: shorthand('loading')
|
|
14
|
+
});
|
|
@@ -1,43 +1,72 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Toast, Toaster } from '@ark-ui/svelte/toast';
|
|
3
|
+
import type { CreateToasterReturn } from '@ark-ui/svelte/toast';
|
|
3
4
|
import { Portal } from '@ark-ui/svelte/portal';
|
|
4
5
|
import { cn } from 'tailwind-variants';
|
|
5
6
|
import type { ClassValue } from 'tailwind-variants';
|
|
6
7
|
import { toast } from './toast.js';
|
|
7
8
|
import PhX from '../../icons/PhX.svelte';
|
|
9
|
+
import PhCheckCircle from '../../icons/PhCheckCircle.svelte';
|
|
10
|
+
import PhXCircle from '../../icons/PhXCircle.svelte';
|
|
11
|
+
import PhWarning from '../../icons/PhWarning.svelte';
|
|
12
|
+
import PhInfo from '../../icons/PhInfo.svelte';
|
|
13
|
+
import PhCircleNotch from '../../icons/PhCircleNotch.svelte';
|
|
8
14
|
|
|
9
15
|
interface Props {
|
|
10
16
|
class?: ClassValue;
|
|
17
|
+
/** Custom toaster instance from `createToaster()`. Defaults to the shared `toast` instance. */
|
|
18
|
+
toaster?: CreateToasterReturn;
|
|
11
19
|
}
|
|
12
20
|
|
|
13
|
-
let { class: className }: Props = $props();
|
|
21
|
+
let { class: className, toaster: toasterInstance = toast }: Props = $props();
|
|
14
22
|
</script>
|
|
15
23
|
|
|
16
24
|
<Portal>
|
|
17
|
-
<Toaster toaster={
|
|
25
|
+
<Toaster toaster={toasterInstance}>
|
|
18
26
|
{#snippet children(toastItem)}
|
|
19
27
|
{@const t = toastItem()}
|
|
20
28
|
<Toast.Root
|
|
21
29
|
class={cn(
|
|
22
|
-
'relative min-w-80 rounded-lg border border-border bg-surface-1 p-4 pr-8 shadow-lg transition-all duration-200',
|
|
23
|
-
'data-[
|
|
24
|
-
'data-[
|
|
25
|
-
'data-[type=
|
|
26
|
-
'data-[type=
|
|
27
|
-
'data-[type=warning]:border-yellow-500/50 data-[type=warning]:bg-yellow-50 dark:data-[type=warning]:bg-yellow-950/30',
|
|
28
|
-
'data-[type=info]:border-blue-500/50 data-[type=info]:bg-blue-50 dark:data-[type=info]:bg-blue-950/30',
|
|
30
|
+
'relative flex min-w-80 items-start gap-3 rounded-lg border border-border bg-surface-1 p-4 pr-8 shadow-lg transition-all duration-200',
|
|
31
|
+
'data-[type=success]:border-success/50 data-[type=success]:bg-[color-mix(in_oklab,var(--color-success)_8%,var(--color-surface-1))]',
|
|
32
|
+
'data-[type=error]:border-danger/50 data-[type=error]:bg-[color-mix(in_oklab,var(--color-danger)_8%,var(--color-surface-1))]',
|
|
33
|
+
'data-[type=warning]:border-warning/50 data-[type=warning]:bg-[color-mix(in_oklab,var(--color-warning)_8%,var(--color-surface-1))]',
|
|
34
|
+
'data-[type=info]:border-info/50 data-[type=info]:bg-[color-mix(in_oklab,var(--color-info)_8%,var(--color-surface-1))]',
|
|
29
35
|
className
|
|
30
36
|
)}
|
|
31
|
-
style="translate: var(--x) var(--y); scale: var(--scale); z-index: var(--z-index); height: var(--height); opacity: var(--opacity);"
|
|
37
|
+
style="translate: var(--x) var(--y); scale: var(--scale); z-index: var(--z-index); height: var(--height); opacity: var(--opacity); will-change: translate, scale, opacity;"
|
|
32
38
|
>
|
|
33
|
-
{#if t.
|
|
34
|
-
<
|
|
35
|
-
{
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
{#if t.type === 'success'}
|
|
40
|
+
<PhCheckCircle class="mt-0.5 size-5 shrink-0 text-success" aria-hidden="true" />
|
|
41
|
+
{:else if t.type === 'error'}
|
|
42
|
+
<PhXCircle class="mt-0.5 size-5 shrink-0 text-danger" aria-hidden="true" />
|
|
43
|
+
{:else if t.type === 'warning'}
|
|
44
|
+
<PhWarning class="mt-0.5 size-5 shrink-0 text-warning" aria-hidden="true" />
|
|
45
|
+
{:else if t.type === 'info'}
|
|
46
|
+
<PhInfo class="mt-0.5 size-5 shrink-0 text-info" aria-hidden="true" />
|
|
47
|
+
{:else if t.type === 'loading'}
|
|
48
|
+
<PhCircleNotch
|
|
49
|
+
class="mt-0.5 size-5 shrink-0 animate-spin text-ink-dim"
|
|
50
|
+
aria-hidden="true"
|
|
51
|
+
/>
|
|
38
52
|
{/if}
|
|
53
|
+
<div class="min-w-0 flex-1">
|
|
54
|
+
{#if t.title}
|
|
55
|
+
<Toast.Title class="text-sm font-medium text-ink">{t.title}</Toast.Title>
|
|
56
|
+
{/if}
|
|
57
|
+
{#if t.description}
|
|
58
|
+
<Toast.Description class="mt-1 text-sm text-ink-dim">{t.description}</Toast.Description>
|
|
59
|
+
{/if}
|
|
60
|
+
{#if t.action}
|
|
61
|
+
<Toast.ActionTrigger
|
|
62
|
+
class="mt-2 inline-flex h-7 items-center rounded-md border border-border bg-surface-1 px-2.5 text-xs font-medium text-ink shadow-sm hover:bg-surface-2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none"
|
|
63
|
+
>
|
|
64
|
+
{t.action.label}
|
|
65
|
+
</Toast.ActionTrigger>
|
|
66
|
+
{/if}
|
|
67
|
+
</div>
|
|
39
68
|
<Toast.CloseTrigger
|
|
40
|
-
class="absolute
|
|
69
|
+
class="absolute top-1.5 right-1.5 rounded p-1 text-ink-dim hover:bg-surface-2 hover:text-ink focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none"
|
|
41
70
|
aria-label="Close notification"
|
|
42
71
|
>
|
|
43
72
|
<PhX class="size-3.5" />
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Toaster } from '@ark-ui/svelte/toast';
|
|
2
|
+
import type { CreateToasterReturn } from '@ark-ui/svelte/toast';
|
|
2
3
|
import type { ClassValue } from 'tailwind-variants';
|
|
3
4
|
interface Props {
|
|
4
5
|
class?: ClassValue;
|
|
6
|
+
/** Custom toaster instance from `createToaster()`. Defaults to the shared `toast` instance. */
|
|
7
|
+
toaster?: CreateToasterReturn;
|
|
5
8
|
}
|
|
6
9
|
declare const Toaster: import("svelte").Component<Props, {}, "">;
|
|
7
10
|
type Toaster = ReturnType<typeof Toaster>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
let { class: className = '', ...restProps } = $props();
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<svg
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
width="1em"
|
|
8
|
+
height="1em"
|
|
9
|
+
viewBox="0 0 256 256"
|
|
10
|
+
class={className}
|
|
11
|
+
{...restProps}
|
|
12
|
+
>
|
|
13
|
+
<path
|
|
14
|
+
fill="currentColor"
|
|
15
|
+
d="M173.66 98.34a8 8 0 0 1 0 11.32l-56 56a8 8 0 0 1-11.32 0l-24-24a8 8 0 0 1 11.32-11.32L112 148.69l50.34-50.35a8 8 0 0 1 11.32 0M232 128A104 104 0 1 1 128 24a104.11 104.11 0 0 1 104 104m-16 0a88 88 0 1 0-88 88a88.1 88.1 0 0 0 88-88"
|
|
16
|
+
/>
|
|
17
|
+
</svg>
|
|
18
|
+
|
|
19
|
+
<!-- Icon from Phosphor by Phosphor Icons - https://github.com/phosphor-icons/core/blob/main/LICENSE -->
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
let { class: className = '', ...restProps } = $props();
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<svg
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
width="1em"
|
|
8
|
+
height="1em"
|
|
9
|
+
viewBox="0 0 256 256"
|
|
10
|
+
class={className}
|
|
11
|
+
{...restProps}
|
|
12
|
+
>
|
|
13
|
+
<path
|
|
14
|
+
fill="currentColor"
|
|
15
|
+
d="M232 128a104 104 0 0 1-208 0c0-41 23.81-78.36 60.66-95.27a8 8 0 0 1 6.68 14.54C60.15 61.59 40 93.27 40 128a88 88 0 0 0 176 0c0-34.73-20.15-66.41-51.34-80.73a8 8 0 0 1 6.68-14.54C208.19 49.64 232 87 232 128"
|
|
16
|
+
/>
|
|
17
|
+
</svg>
|
|
18
|
+
|
|
19
|
+
<!-- Icon from Phosphor by Phosphor Icons - https://github.com/phosphor-icons/core/blob/main/LICENSE -->
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
let { class: className = '', ...restProps } = $props();
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<svg
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
width="1em"
|
|
8
|
+
height="1em"
|
|
9
|
+
viewBox="0 0 256 256"
|
|
10
|
+
class={className}
|
|
11
|
+
{...restProps}
|
|
12
|
+
>
|
|
13
|
+
<path
|
|
14
|
+
fill="currentColor"
|
|
15
|
+
d="M144 176a8 8 0 0 1-8 8a16 16 0 0 1-16-16v-40a8 8 0 0 1 0-16a16 16 0 0 1 16 16v40a8 8 0 0 1 8 8m-32-92a12 12 0 1 1 12 12a12 12 0 0 1-12-12m120 44A104 104 0 1 1 128 24a104.11 104.11 0 0 1 104 104m-16 0a88 88 0 1 0-88 88a88.1 88.1 0 0 0 88-88"
|
|
16
|
+
/>
|
|
17
|
+
</svg>
|
|
18
|
+
|
|
19
|
+
<!-- Icon from Phosphor by Phosphor Icons - https://github.com/phosphor-icons/core/blob/main/LICENSE -->
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
let { class: className = '', ...restProps } = $props();
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<svg
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
width="1em"
|
|
8
|
+
height="1em"
|
|
9
|
+
viewBox="0 0 256 256"
|
|
10
|
+
class={className}
|
|
11
|
+
{...restProps}
|
|
12
|
+
>
|
|
13
|
+
<path
|
|
14
|
+
fill="currentColor"
|
|
15
|
+
d="M236.8 188.09L149.35 36.22a24.76 24.76 0 0 0-42.7 0L19.2 188.09a23.51 23.51 0 0 0 0 23.72A24.35 24.35 0 0 0 40.55 224h174.9a24.35 24.35 0 0 0 21.33-12.19a23.51 23.51 0 0 0 .02-23.72m-13.87 15.71a8.5 8.5 0 0 1-7.48 4.2H40.55a8.5 8.5 0 0 1-7.48-4.2a7.59 7.59 0 0 1 0-7.72l87.45-151.87a8.75 8.75 0 0 1 15 0l87.45 151.87a7.59 7.59 0 0 1-.04 7.72M120 144v-40a8 8 0 0 1 16 0v40a8 8 0 0 1-16 0m20 36a12 12 0 1 1-12-12a12 12 0 0 1 12 12"
|
|
16
|
+
/>
|
|
17
|
+
</svg>
|
|
18
|
+
|
|
19
|
+
<!-- Icon from Phosphor by Phosphor Icons - https://github.com/phosphor-icons/core/blob/main/LICENSE -->
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
let { class: className = '', ...restProps } = $props();
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<svg
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
width="1em"
|
|
8
|
+
height="1em"
|
|
9
|
+
viewBox="0 0 256 256"
|
|
10
|
+
class={className}
|
|
11
|
+
{...restProps}
|
|
12
|
+
>
|
|
13
|
+
<path
|
|
14
|
+
fill="currentColor"
|
|
15
|
+
d="M165.66 101.66L139.31 128l26.35 26.34a8 8 0 0 1-11.32 11.32L128 139.31l-26.34 26.35a8 8 0 0 1-11.32-11.32L116.69 128l-26.35-26.34a8 8 0 0 1 11.32-11.32L128 116.69l26.34-26.35a8 8 0 0 1 11.32 11.32M232 128A104 104 0 1 1 128 24a104.11 104.11 0 0 1 104 104m-16 0a88 88 0 1 0-88 88a88.1 88.1 0 0 0 88-88"
|
|
16
|
+
/>
|
|
17
|
+
</svg>
|
|
18
|
+
|
|
19
|
+
<!-- Icon from Phosphor by Phosphor Icons - https://github.com/phosphor-icons/core/blob/main/LICENSE -->
|
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ export { default as Switch } from './components/switch/switch.svelte';
|
|
|
46
46
|
export * as Tabs from './components/tabs';
|
|
47
47
|
export * as Toast from './components/toast';
|
|
48
48
|
export { toast } from './components/toast';
|
|
49
|
+
export type { ToastOptions, ToastType } from './components/toast';
|
|
49
50
|
export { createToaster } from '@ark-ui/svelte/toast';
|
|
50
51
|
export type { CreateToasterReturn } from '@ark-ui/svelte/toast';
|
|
51
52
|
export { default as Toggle } from './components/toggle/toggle.svelte';
|