@aspect-ops/exon-ui 0.0.2 → 0.0.3
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/ActionSheet/ActionSheet.svelte +270 -0
- package/dist/components/ActionSheet/ActionSheet.svelte.d.ts +12 -0
- package/dist/components/ActionSheet/ActionSheetItem.svelte +151 -0
- package/dist/components/ActionSheet/ActionSheetItem.svelte.d.ts +10 -0
- package/dist/components/ActionSheet/index.d.ts +3 -0
- package/dist/components/ActionSheet/index.js +2 -0
- package/dist/components/Alert/Alert.svelte +165 -0
- package/dist/components/Alert/Alert.svelte.d.ts +11 -0
- package/dist/components/Alert/index.d.ts +1 -0
- package/dist/components/Alert/index.js +1 -0
- package/dist/components/AspectRatio/AspectRatio.svelte +42 -0
- package/dist/components/AspectRatio/AspectRatio.svelte.d.ts +9 -0
- package/dist/components/AspectRatio/index.d.ts +1 -0
- package/dist/components/AspectRatio/index.js +1 -0
- package/dist/components/Avatar/Avatar.svelte +147 -0
- package/dist/components/Avatar/Avatar.svelte.d.ts +12 -0
- package/dist/components/Avatar/AvatarGroup.svelte +153 -0
- package/dist/components/Avatar/AvatarGroup.svelte.d.ts +12 -0
- package/dist/components/Avatar/index.d.ts +2 -0
- package/dist/components/Avatar/index.js +2 -0
- package/dist/components/BottomSheet/BottomSheet.svelte +230 -0
- package/dist/components/BottomSheet/BottomSheet.svelte.d.ts +7 -0
- package/dist/components/BottomSheet/BottomSheetBody.svelte +20 -0
- package/dist/components/BottomSheet/BottomSheetBody.svelte.d.ts +7 -0
- package/dist/components/BottomSheet/BottomSheetHeader.svelte +27 -0
- package/dist/components/BottomSheet/BottomSheetHeader.svelte.d.ts +7 -0
- package/dist/components/BottomSheet/index.d.ts +3 -0
- package/dist/components/BottomSheet/index.js +3 -0
- package/dist/components/Box/Box.svelte +41 -0
- package/dist/components/Box/Box.svelte.d.ts +7 -0
- package/dist/components/Box/index.d.ts +1 -0
- package/dist/components/Box/index.js +1 -0
- package/dist/components/Card/Card.svelte +95 -0
- package/dist/components/Card/Card.svelte.d.ts +10 -0
- package/dist/components/Card/CardBody.svelte +32 -0
- package/dist/components/Card/CardBody.svelte.d.ts +7 -0
- package/dist/components/Card/CardFooter.svelte +34 -0
- package/dist/components/Card/CardFooter.svelte.d.ts +7 -0
- package/dist/components/Card/CardHeader.svelte +67 -0
- package/dist/components/Card/CardHeader.svelte.d.ts +9 -0
- package/dist/components/Card/index.d.ts +4 -0
- package/dist/components/Card/index.js +4 -0
- package/dist/components/Center/Center.svelte +28 -0
- package/dist/components/Center/Center.svelte.d.ts +8 -0
- package/dist/components/Center/index.d.ts +1 -0
- package/dist/components/Center/index.js +1 -0
- package/dist/components/Container/Container.svelte +58 -0
- package/dist/components/Container/Container.svelte.d.ts +10 -0
- package/dist/components/Container/index.d.ts +1 -0
- package/dist/components/Container/index.js +1 -0
- package/dist/components/Divider/Divider.svelte +38 -0
- package/dist/components/Divider/Divider.svelte.d.ts +9 -0
- package/dist/components/Divider/index.d.ts +1 -0
- package/dist/components/Divider/index.js +1 -0
- package/dist/components/EmptyState/EmptyState.svelte +164 -0
- package/dist/components/EmptyState/EmptyState.svelte.d.ts +12 -0
- package/dist/components/EmptyState/index.d.ts +1 -0
- package/dist/components/EmptyState/index.js +1 -0
- package/dist/components/FAB/FAB.svelte +242 -0
- package/dist/components/FAB/FAB.svelte.d.ts +9 -0
- package/dist/components/FAB/FABGroup.svelte +449 -0
- package/dist/components/FAB/FABGroup.svelte.d.ts +9 -0
- package/dist/components/FAB/index.d.ts +3 -0
- package/dist/components/FAB/index.js +2 -0
- package/dist/components/Grid/Grid.svelte +136 -0
- package/dist/components/Grid/Grid.svelte.d.ts +12 -0
- package/dist/components/Grid/GridItem.svelte +21 -0
- package/dist/components/Grid/GridItem.svelte.d.ts +7 -0
- package/dist/components/Grid/index.d.ts +2 -0
- package/dist/components/Grid/index.js +2 -0
- package/dist/components/List/List.svelte +42 -0
- package/dist/components/List/List.svelte.d.ts +18 -0
- package/dist/components/List/ListItem.svelte +139 -0
- package/dist/components/List/ListItem.svelte.d.ts +36 -0
- package/dist/components/List/index.d.ts +2 -0
- package/dist/components/List/index.js +2 -0
- package/dist/components/Modal/Modal.svelte +204 -0
- package/dist/components/Modal/Modal.svelte.d.ts +7 -0
- package/dist/components/Modal/ModalBody.svelte +50 -0
- package/dist/components/Modal/ModalBody.svelte.d.ts +7 -0
- package/dist/components/Modal/ModalFooter.svelte +37 -0
- package/dist/components/Modal/ModalFooter.svelte.d.ts +7 -0
- package/dist/components/Modal/ModalHeader.svelte +73 -0
- package/dist/components/Modal/ModalHeader.svelte.d.ts +7 -0
- package/dist/components/Modal/index.d.ts +4 -0
- package/dist/components/Modal/index.js +4 -0
- package/dist/components/Popover/Popover.svelte +14 -0
- package/dist/components/Popover/Popover.svelte.d.ts +7 -0
- package/dist/components/Popover/PopoverContent.svelte +63 -0
- package/dist/components/Popover/PopoverContent.svelte.d.ts +7 -0
- package/dist/components/Popover/PopoverTrigger.svelte +14 -0
- package/dist/components/Popover/PopoverTrigger.svelte.d.ts +7 -0
- package/dist/components/Popover/index.d.ts +3 -0
- package/dist/components/Popover/index.js +3 -0
- package/dist/components/Progress/ProgressBar.svelte +86 -0
- package/dist/components/Progress/ProgressBar.svelte.d.ts +11 -0
- package/dist/components/Progress/ProgressCircle.svelte +134 -0
- package/dist/components/Progress/ProgressCircle.svelte.d.ts +12 -0
- package/dist/components/Progress/Spinner.svelte +68 -0
- package/dist/components/Progress/Spinner.svelte.d.ts +8 -0
- package/dist/components/Progress/index.d.ts +3 -0
- package/dist/components/Progress/index.js +3 -0
- package/dist/components/PullToRefresh/PullToRefresh.svelte +304 -0
- package/dist/components/PullToRefresh/PullToRefresh.svelte.d.ts +20 -0
- package/dist/components/PullToRefresh/index.d.ts +1 -0
- package/dist/components/PullToRefresh/index.js +1 -0
- package/dist/components/SafeArea/SafeArea.svelte +33 -0
- package/dist/components/SafeArea/SafeArea.svelte.d.ts +7 -0
- package/dist/components/Select/Select.svelte +55 -12
- package/dist/components/Skeleton/Skeleton.svelte +59 -0
- package/dist/components/Skeleton/Skeleton.svelte.d.ts +10 -0
- package/dist/components/Skeleton/index.d.ts +1 -0
- package/dist/components/Skeleton/index.js +1 -0
- package/dist/components/Spacer/Spacer.svelte +56 -0
- package/dist/components/Spacer/Spacer.svelte.d.ts +6 -0
- package/dist/components/Spacer/index.d.ts +1 -0
- package/dist/components/Spacer/index.js +1 -0
- package/dist/components/Stack/Stack.svelte +117 -0
- package/dist/components/Stack/Stack.svelte.d.ts +13 -0
- package/dist/components/Stack/index.d.ts +1 -0
- package/dist/components/Stack/index.js +1 -0
- package/dist/components/SwipeActions/SwipeAction.svelte +43 -0
- package/dist/components/SwipeActions/SwipeAction.svelte.d.ts +8 -0
- package/dist/components/SwipeActions/SwipeActions.svelte +193 -0
- package/dist/components/SwipeActions/SwipeActions.svelte.d.ts +9 -0
- package/dist/components/SwipeActions/index.d.ts +2 -0
- package/dist/components/SwipeActions/index.js +2 -0
- package/dist/components/Switch/Switch.svelte +29 -9
- package/dist/components/Table/Table.svelte +175 -0
- package/dist/components/Table/Table.svelte.d.ts +38 -0
- package/dist/components/Table/TableBody.svelte +26 -0
- package/dist/components/Table/TableBody.svelte.d.ts +13 -0
- package/dist/components/Table/TableCell.svelte +85 -0
- package/dist/components/Table/TableCell.svelte.d.ts +28 -0
- package/dist/components/Table/TableHead.svelte +36 -0
- package/dist/components/Table/TableHead.svelte.d.ts +13 -0
- package/dist/components/Table/TableHeader.svelte +217 -0
- package/dist/components/Table/TableHeader.svelte.d.ts +32 -0
- package/dist/components/Table/TableRow.svelte +92 -0
- package/dist/components/Table/TableRow.svelte.d.ts +28 -0
- package/dist/components/Table/index.d.ts +6 -0
- package/dist/components/Table/index.js +6 -0
- package/dist/components/Tag/Tag.svelte +189 -0
- package/dist/components/Tag/Tag.svelte.d.ts +13 -0
- package/dist/components/Tag/index.d.ts +1 -0
- package/dist/components/Tag/index.js +1 -0
- package/dist/components/Toast/Toast.svelte +241 -0
- package/dist/components/Toast/Toast.svelte.d.ts +18 -0
- package/dist/components/Toast/ToastContainer.svelte +110 -0
- package/dist/components/Toast/ToastContainer.svelte.d.ts +8 -0
- package/dist/components/Toast/index.d.ts +3 -0
- package/dist/components/Toast/index.js +3 -0
- package/dist/components/Toast/toast.d.ts +13 -0
- package/dist/components/Toast/toast.js +55 -0
- package/dist/components/Tooltip/Tooltip.svelte +71 -0
- package/dist/components/Tooltip/Tooltip.svelte.d.ts +7 -0
- package/dist/components/Tooltip/index.d.ts +2 -0
- package/dist/components/Tooltip/index.js +1 -0
- package/dist/index.d.ts +29 -1
- package/dist/index.js +32 -0
- package/dist/styles/tokens.css +5 -0
- package/dist/types/data-display.d.ts +93 -0
- package/dist/types/data-display.js +1 -0
- package/dist/types/feedback.d.ts +92 -0
- package/dist/types/feedback.js +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/layout.d.ts +57 -0
- package/dist/types/layout.js +1 -0
- package/dist/types/mobile.d.ts +91 -0
- package/dist/types/mobile.js +1 -0
- package/dist/utils/gestures.d.ts +219 -0
- package/dist/utils/gestures.js +492 -0
- package/dist/utils/haptics.d.ts +89 -0
- package/dist/utils/haptics.js +198 -0
- package/dist/utils/platform.d.ts +47 -0
- package/dist/utils/platform.js +156 -0
- package/package.json +1 -1
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { TagVariant, TagSize } from '../../types/index.js';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
variant?: TagVariant;
|
|
6
|
+
size?: TagSize;
|
|
7
|
+
dismissible?: boolean;
|
|
8
|
+
ondismiss?: () => void;
|
|
9
|
+
class?: string;
|
|
10
|
+
children?: import('svelte').Snippet;
|
|
11
|
+
icon?: import('svelte').Snippet;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let {
|
|
15
|
+
variant = 'default',
|
|
16
|
+
size = 'md',
|
|
17
|
+
dismissible = false,
|
|
18
|
+
ondismiss,
|
|
19
|
+
class: className = '',
|
|
20
|
+
children,
|
|
21
|
+
icon
|
|
22
|
+
}: Props = $props();
|
|
23
|
+
|
|
24
|
+
function handleDismiss() {
|
|
25
|
+
ondismiss?.();
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<span class="tag tag--{variant} tag--{size} {className}" role={dismissible ? undefined : 'status'}>
|
|
30
|
+
{#if icon}
|
|
31
|
+
<span class="tag__icon" aria-hidden="true">
|
|
32
|
+
{@render icon()}
|
|
33
|
+
</span>
|
|
34
|
+
{/if}
|
|
35
|
+
<span class="tag__label">
|
|
36
|
+
{#if children}
|
|
37
|
+
{@render children()}
|
|
38
|
+
{/if}
|
|
39
|
+
</span>
|
|
40
|
+
{#if dismissible}
|
|
41
|
+
<button type="button" class="tag__close" onclick={handleDismiss} aria-label="Remove tag">
|
|
42
|
+
×
|
|
43
|
+
</button>
|
|
44
|
+
{/if}
|
|
45
|
+
</span>
|
|
46
|
+
|
|
47
|
+
<style>
|
|
48
|
+
.tag {
|
|
49
|
+
display: inline-flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
gap: var(--space-xs, 0.25rem);
|
|
52
|
+
padding: var(--space-xs, 0.25rem) var(--space-sm, 0.5rem);
|
|
53
|
+
border-radius: var(--radius-full, 9999px);
|
|
54
|
+
font-family: inherit;
|
|
55
|
+
font-weight: 500;
|
|
56
|
+
line-height: 1;
|
|
57
|
+
white-space: nowrap;
|
|
58
|
+
transition: background-color 0.2s ease;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.tag__label {
|
|
62
|
+
flex: 1;
|
|
63
|
+
min-width: 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.tag__icon {
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
flex-shrink: 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.tag__close {
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
justify-content: center;
|
|
77
|
+
flex-shrink: 0;
|
|
78
|
+
width: 2.75rem;
|
|
79
|
+
height: 2.75rem;
|
|
80
|
+
margin: -0.25rem -0.25rem -0.25rem 0;
|
|
81
|
+
padding: 0;
|
|
82
|
+
border: none;
|
|
83
|
+
border-radius: var(--radius-full, 9999px);
|
|
84
|
+
background: transparent;
|
|
85
|
+
font-family: inherit;
|
|
86
|
+
font-size: 1.25rem;
|
|
87
|
+
line-height: 1;
|
|
88
|
+
cursor: pointer;
|
|
89
|
+
transition: background-color 0.2s ease;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.tag__close:hover {
|
|
93
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.tag__close:focus-visible {
|
|
97
|
+
outline: 2px solid currentColor;
|
|
98
|
+
outline-offset: 2px;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* Size variants */
|
|
102
|
+
.tag--sm {
|
|
103
|
+
font-size: var(--text-xs, 0.75rem);
|
|
104
|
+
padding: 0.125rem var(--space-xs, 0.25rem);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.tag--sm .tag__close {
|
|
108
|
+
width: 2rem;
|
|
109
|
+
height: 2rem;
|
|
110
|
+
font-size: 1rem;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.tag--md {
|
|
114
|
+
font-size: var(--text-sm, 0.875rem);
|
|
115
|
+
padding: var(--space-xs, 0.25rem) var(--space-sm, 0.5rem);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.tag--md .tag__close {
|
|
119
|
+
width: 2.75rem;
|
|
120
|
+
height: 2.75rem;
|
|
121
|
+
font-size: 1.25rem;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.tag--lg {
|
|
125
|
+
font-size: var(--text-base, 1rem);
|
|
126
|
+
padding: var(--space-sm, 0.5rem) var(--space-md, 0.75rem);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.tag--lg .tag__close {
|
|
130
|
+
width: 2.75rem;
|
|
131
|
+
height: 2.75rem;
|
|
132
|
+
font-size: 1.5rem;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* Color variants */
|
|
136
|
+
.tag--default {
|
|
137
|
+
background: var(--color-bg-muted, #f3f4f6);
|
|
138
|
+
color: var(--color-text, #1f2937);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.tag--default .tag__close:hover {
|
|
142
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.tag--primary {
|
|
146
|
+
background: var(--color-primary, #3b82f6);
|
|
147
|
+
color: var(--color-text-inverse, #ffffff);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.tag--primary .tag__close:hover {
|
|
151
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.tag--secondary {
|
|
155
|
+
background: var(--color-secondary, #6b7280);
|
|
156
|
+
color: var(--color-text-inverse, #ffffff);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.tag--secondary .tag__close:hover {
|
|
160
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.tag--success {
|
|
164
|
+
background: var(--color-success, #10b981);
|
|
165
|
+
color: var(--color-text-inverse, #ffffff);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.tag--success .tag__close:hover {
|
|
169
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.tag--warning {
|
|
173
|
+
background: var(--color-warning, #f59e0b);
|
|
174
|
+
color: var(--color-text, #1f2937);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.tag--warning .tag__close:hover {
|
|
178
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.tag--error {
|
|
182
|
+
background: var(--color-error, #ef4444);
|
|
183
|
+
color: var(--color-text-inverse, #ffffff);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.tag--error .tag__close:hover {
|
|
187
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
188
|
+
}
|
|
189
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TagVariant, TagSize } from '../../types/index.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
variant?: TagVariant;
|
|
4
|
+
size?: TagSize;
|
|
5
|
+
dismissible?: boolean;
|
|
6
|
+
ondismiss?: () => void;
|
|
7
|
+
class?: string;
|
|
8
|
+
children?: import('svelte').Snippet;
|
|
9
|
+
icon?: import('svelte').Snippet;
|
|
10
|
+
}
|
|
11
|
+
declare const Tag: import("svelte").Component<Props, {}, "">;
|
|
12
|
+
type Tag = ReturnType<typeof Tag>;
|
|
13
|
+
export default Tag;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Tag } from './Tag.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Tag } from './Tag.svelte';
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import type { ToastVariant } from '../../types/index.js';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
id: string;
|
|
7
|
+
message: string;
|
|
8
|
+
variant?: ToastVariant;
|
|
9
|
+
dismissible?: boolean;
|
|
10
|
+
progress?: boolean;
|
|
11
|
+
duration?: number;
|
|
12
|
+
action?: {
|
|
13
|
+
label: string;
|
|
14
|
+
onClick: () => void;
|
|
15
|
+
};
|
|
16
|
+
onDismiss?: (id: string) => void;
|
|
17
|
+
class?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
id,
|
|
22
|
+
message,
|
|
23
|
+
variant = 'info',
|
|
24
|
+
dismissible = true,
|
|
25
|
+
progress = true,
|
|
26
|
+
duration = 5000,
|
|
27
|
+
action,
|
|
28
|
+
onDismiss,
|
|
29
|
+
class: className = ''
|
|
30
|
+
}: Props = $props();
|
|
31
|
+
|
|
32
|
+
let visible = $state(false);
|
|
33
|
+
let progressValue = $state(100);
|
|
34
|
+
let timeoutId: number | undefined;
|
|
35
|
+
let intervalId: number | undefined;
|
|
36
|
+
|
|
37
|
+
onMount(() => {
|
|
38
|
+
// Trigger slide-in animation
|
|
39
|
+
visible = true;
|
|
40
|
+
|
|
41
|
+
// Start progress bar animation if enabled
|
|
42
|
+
if (progress && duration > 0) {
|
|
43
|
+
const startTime = Date.now();
|
|
44
|
+
intervalId = window.setInterval(() => {
|
|
45
|
+
const elapsed = Date.now() - startTime;
|
|
46
|
+
const remaining = Math.max(0, ((duration - elapsed) / duration) * 100);
|
|
47
|
+
progressValue = remaining;
|
|
48
|
+
|
|
49
|
+
if (remaining <= 0) {
|
|
50
|
+
clearInterval(intervalId);
|
|
51
|
+
}
|
|
52
|
+
}, 16); // ~60fps
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Auto-dismiss after duration
|
|
56
|
+
if (duration > 0) {
|
|
57
|
+
timeoutId = window.setTimeout(() => {
|
|
58
|
+
handleDismiss();
|
|
59
|
+
}, duration);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return () => {
|
|
63
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
64
|
+
if (intervalId) clearInterval(intervalId);
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
function handleDismiss() {
|
|
69
|
+
visible = false;
|
|
70
|
+
// Wait for animation to complete before calling onDismiss
|
|
71
|
+
setTimeout(() => {
|
|
72
|
+
onDismiss?.(id);
|
|
73
|
+
}, 300);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function handleAction() {
|
|
77
|
+
action?.onClick();
|
|
78
|
+
handleDismiss();
|
|
79
|
+
}
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<div
|
|
83
|
+
class="toast toast--{variant} {visible ? 'toast--visible' : ''} {className}"
|
|
84
|
+
role="status"
|
|
85
|
+
aria-live="polite"
|
|
86
|
+
>
|
|
87
|
+
<div class="toast__content">
|
|
88
|
+
<div class="toast__message">{message}</div>
|
|
89
|
+
|
|
90
|
+
{#if action}
|
|
91
|
+
<button type="button" class="toast__action" onclick={handleAction}>
|
|
92
|
+
{action.label}
|
|
93
|
+
</button>
|
|
94
|
+
{/if}
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
{#if dismissible}
|
|
98
|
+
<button type="button" class="toast__close" onclick={handleDismiss} aria-label="Dismiss toast">
|
|
99
|
+
×
|
|
100
|
+
</button>
|
|
101
|
+
{/if}
|
|
102
|
+
|
|
103
|
+
{#if progress && duration > 0}
|
|
104
|
+
<div class="toast__progress">
|
|
105
|
+
<div class="toast__progress-bar" style="width: {progressValue}%"></div>
|
|
106
|
+
</div>
|
|
107
|
+
{/if}
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<style>
|
|
111
|
+
.toast {
|
|
112
|
+
position: relative;
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: flex-start;
|
|
115
|
+
justify-content: space-between;
|
|
116
|
+
min-width: 18.75rem;
|
|
117
|
+
max-width: 25rem;
|
|
118
|
+
padding: var(--space-md, 1rem);
|
|
119
|
+
border-radius: var(--radius-md, 0.375rem);
|
|
120
|
+
box-shadow:
|
|
121
|
+
0 0.25rem 0.375rem -0.125rem rgba(0, 0, 0, 0.1),
|
|
122
|
+
0 0.625rem 0.9375rem -0.1875rem rgba(0, 0, 0, 0.1);
|
|
123
|
+
font-family: inherit;
|
|
124
|
+
font-size: var(--text-sm, 0.875rem);
|
|
125
|
+
line-height: 1.5;
|
|
126
|
+
opacity: 0;
|
|
127
|
+
transform: translateY(0.5rem);
|
|
128
|
+
transition:
|
|
129
|
+
opacity 0.3s ease,
|
|
130
|
+
transform 0.3s ease;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.toast--visible {
|
|
134
|
+
opacity: 1;
|
|
135
|
+
transform: translateY(0);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.toast__content {
|
|
139
|
+
display: flex;
|
|
140
|
+
align-items: center;
|
|
141
|
+
gap: var(--space-md, 1rem);
|
|
142
|
+
flex: 1;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.toast__message {
|
|
146
|
+
flex: 1;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.toast__action {
|
|
150
|
+
flex-shrink: 0;
|
|
151
|
+
padding: 0.25rem 0.75rem;
|
|
152
|
+
border: none;
|
|
153
|
+
border-radius: var(--radius-sm, 0.25rem);
|
|
154
|
+
background: rgba(255, 255, 255, 0.2);
|
|
155
|
+
font-family: inherit;
|
|
156
|
+
font-size: var(--text-sm, 0.875rem);
|
|
157
|
+
font-weight: 600;
|
|
158
|
+
cursor: pointer;
|
|
159
|
+
transition: background-color 0.2s ease;
|
|
160
|
+
min-height: 2.75rem;
|
|
161
|
+
min-width: 2.75rem;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.toast__action:hover {
|
|
165
|
+
background: rgba(255, 255, 255, 0.3);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.toast__action:focus-visible {
|
|
169
|
+
outline: 2px solid currentColor;
|
|
170
|
+
outline-offset: 2px;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.toast__close {
|
|
174
|
+
flex-shrink: 0;
|
|
175
|
+
display: flex;
|
|
176
|
+
align-items: center;
|
|
177
|
+
justify-content: center;
|
|
178
|
+
width: 2.75rem;
|
|
179
|
+
height: 2.75rem;
|
|
180
|
+
margin: -0.5rem -0.5rem -0.5rem 0.5rem;
|
|
181
|
+
padding: 0;
|
|
182
|
+
border: none;
|
|
183
|
+
border-radius: var(--radius-sm, 0.25rem);
|
|
184
|
+
background: transparent;
|
|
185
|
+
font-family: inherit;
|
|
186
|
+
font-size: 1.5rem;
|
|
187
|
+
line-height: 1;
|
|
188
|
+
cursor: pointer;
|
|
189
|
+
transition: background-color 0.2s ease;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.toast__close:hover {
|
|
193
|
+
background: rgba(255, 255, 255, 0.1);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.toast__close:focus-visible {
|
|
197
|
+
outline: 2px solid currentColor;
|
|
198
|
+
outline-offset: 2px;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.toast__progress {
|
|
202
|
+
position: absolute;
|
|
203
|
+
bottom: 0;
|
|
204
|
+
left: 0;
|
|
205
|
+
right: 0;
|
|
206
|
+
height: 0.25rem;
|
|
207
|
+
background: rgba(0, 0, 0, 0.1);
|
|
208
|
+
border-radius: 0 0 var(--radius-md, 0.375rem) var(--radius-md, 0.375rem);
|
|
209
|
+
overflow: hidden;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.toast__progress-bar {
|
|
213
|
+
height: 100%;
|
|
214
|
+
background: currentColor;
|
|
215
|
+
transition: width 0.016s linear;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/* Info variant */
|
|
219
|
+
.toast--info {
|
|
220
|
+
background-color: var(--color-info, #3b82f6);
|
|
221
|
+
color: white;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/* Success variant */
|
|
225
|
+
.toast--success {
|
|
226
|
+
background-color: var(--color-success, #10b981);
|
|
227
|
+
color: white;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/* Warning variant */
|
|
231
|
+
.toast--warning {
|
|
232
|
+
background-color: var(--color-warning, #f59e0b);
|
|
233
|
+
color: white;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/* Error variant */
|
|
237
|
+
.toast--error {
|
|
238
|
+
background-color: var(--color-error, #ef4444);
|
|
239
|
+
color: white;
|
|
240
|
+
}
|
|
241
|
+
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ToastVariant } from '../../types/index.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
id: string;
|
|
4
|
+
message: string;
|
|
5
|
+
variant?: ToastVariant;
|
|
6
|
+
dismissible?: boolean;
|
|
7
|
+
progress?: boolean;
|
|
8
|
+
duration?: number;
|
|
9
|
+
action?: {
|
|
10
|
+
label: string;
|
|
11
|
+
onClick: () => void;
|
|
12
|
+
};
|
|
13
|
+
onDismiss?: (id: string) => void;
|
|
14
|
+
class?: string;
|
|
15
|
+
}
|
|
16
|
+
declare const Toast: import("svelte").Component<Props, {}, "">;
|
|
17
|
+
type Toast = ReturnType<typeof Toast>;
|
|
18
|
+
export default Toast;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import Toast from './Toast.svelte';
|
|
4
|
+
import { toast } from './toast.js';
|
|
5
|
+
import type { ToastPosition } from '../../types/index.js';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
position?: ToastPosition;
|
|
9
|
+
class?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let { position = 'bottom-right', class: className = '' }: Props = $props();
|
|
13
|
+
|
|
14
|
+
let mounted = $state(false);
|
|
15
|
+
let toasts = $state<typeof $toast>([]);
|
|
16
|
+
|
|
17
|
+
// Subscribe to toast store
|
|
18
|
+
const unsubscribe = toast.subscribe((value) => {
|
|
19
|
+
toasts = value;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
onMount(() => {
|
|
23
|
+
mounted = true;
|
|
24
|
+
|
|
25
|
+
return () => {
|
|
26
|
+
unsubscribe();
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
function handleDismiss(id: string) {
|
|
31
|
+
toast.remove(id);
|
|
32
|
+
}
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
{#if mounted}
|
|
36
|
+
<div class="toast-container toast-container--{position} {className}">
|
|
37
|
+
{#each toasts as toastData (toastData.id)}
|
|
38
|
+
<Toast
|
|
39
|
+
id={toastData.id}
|
|
40
|
+
message={toastData.message}
|
|
41
|
+
variant={toastData.variant}
|
|
42
|
+
dismissible={toastData.dismissible}
|
|
43
|
+
progress={true}
|
|
44
|
+
duration={toastData.duration}
|
|
45
|
+
action={toastData.action}
|
|
46
|
+
onDismiss={handleDismiss}
|
|
47
|
+
/>
|
|
48
|
+
{/each}
|
|
49
|
+
</div>
|
|
50
|
+
{/if}
|
|
51
|
+
|
|
52
|
+
<style>
|
|
53
|
+
.toast-container {
|
|
54
|
+
position: fixed;
|
|
55
|
+
z-index: 9999;
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-direction: column;
|
|
58
|
+
gap: var(--space-md, 1rem);
|
|
59
|
+
pointer-events: none;
|
|
60
|
+
font-family:
|
|
61
|
+
-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.toast-container :global(*) {
|
|
65
|
+
pointer-events: auto;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* Position variants */
|
|
69
|
+
.toast-container--top {
|
|
70
|
+
top: var(--space-lg, 1.5rem);
|
|
71
|
+
left: 50%;
|
|
72
|
+
transform: translateX(-50%);
|
|
73
|
+
padding-top: env(safe-area-inset-top, 0);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.toast-container--top-left {
|
|
77
|
+
top: var(--space-lg, 1.5rem);
|
|
78
|
+
left: var(--space-lg, 1.5rem);
|
|
79
|
+
padding-top: env(safe-area-inset-top, 0);
|
|
80
|
+
padding-left: env(safe-area-inset-left, 0);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.toast-container--top-right {
|
|
84
|
+
top: var(--space-lg, 1.5rem);
|
|
85
|
+
right: var(--space-lg, 1.5rem);
|
|
86
|
+
padding-top: env(safe-area-inset-top, 0);
|
|
87
|
+
padding-right: env(safe-area-inset-right, 0);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.toast-container--bottom {
|
|
91
|
+
bottom: var(--space-lg, 1.5rem);
|
|
92
|
+
left: 50%;
|
|
93
|
+
transform: translateX(-50%);
|
|
94
|
+
padding-bottom: env(safe-area-inset-bottom, 0);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.toast-container--bottom-left {
|
|
98
|
+
bottom: var(--space-lg, 1.5rem);
|
|
99
|
+
left: var(--space-lg, 1.5rem);
|
|
100
|
+
padding-bottom: env(safe-area-inset-bottom, 0);
|
|
101
|
+
padding-left: env(safe-area-inset-left, 0);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.toast-container--bottom-right {
|
|
105
|
+
bottom: var(--space-lg, 1.5rem);
|
|
106
|
+
right: var(--space-lg, 1.5rem);
|
|
107
|
+
padding-bottom: env(safe-area-inset-bottom, 0);
|
|
108
|
+
padding-right: env(safe-area-inset-right, 0);
|
|
109
|
+
}
|
|
110
|
+
</style>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ToastPosition } from '../../types/index.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
position?: ToastPosition;
|
|
4
|
+
class?: string;
|
|
5
|
+
}
|
|
6
|
+
declare const ToastContainer: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type ToastContainer = ReturnType<typeof ToastContainer>;
|
|
8
|
+
export default ToastContainer;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ToastData } from '../../types/index.js';
|
|
2
|
+
export declare const toast: {
|
|
3
|
+
subscribe: (this: void, run: import("svelte/store").Subscriber<ToastData[]>, invalidate?: () => void) => import("svelte/store").Unsubscriber;
|
|
4
|
+
add: (options: Omit<ToastData, "id"> & {
|
|
5
|
+
id?: string;
|
|
6
|
+
}) => string;
|
|
7
|
+
remove: (id: string) => void;
|
|
8
|
+
clear: () => void;
|
|
9
|
+
info: (message: string, options?: Partial<Omit<ToastData, "id" | "message" | "variant">>) => string;
|
|
10
|
+
success: (message: string, options?: Partial<Omit<ToastData, "id" | "message" | "variant">>) => string;
|
|
11
|
+
warning: (message: string, options?: Partial<Omit<ToastData, "id" | "message" | "variant">>) => string;
|
|
12
|
+
error: (message: string, options?: Partial<Omit<ToastData, "id" | "message" | "variant">>) => string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { writable } from 'svelte/store';
|
|
2
|
+
// Create the toast store
|
|
3
|
+
function createToastStore() {
|
|
4
|
+
const { subscribe, update } = writable([]);
|
|
5
|
+
// Generate unique ID
|
|
6
|
+
function generateId() {
|
|
7
|
+
return `toast-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
8
|
+
}
|
|
9
|
+
// Add a toast
|
|
10
|
+
function add(options) {
|
|
11
|
+
const id = options.id || generateId();
|
|
12
|
+
const duration = options.duration ?? 5000;
|
|
13
|
+
const toastData = {
|
|
14
|
+
...options,
|
|
15
|
+
id,
|
|
16
|
+
duration,
|
|
17
|
+
variant: options.variant || 'info',
|
|
18
|
+
dismissible: options.dismissible ?? true
|
|
19
|
+
};
|
|
20
|
+
update((toasts) => [...toasts, toastData]);
|
|
21
|
+
return id;
|
|
22
|
+
}
|
|
23
|
+
// Remove a specific toast
|
|
24
|
+
function remove(id) {
|
|
25
|
+
update((toasts) => toasts.filter((t) => t.id !== id));
|
|
26
|
+
}
|
|
27
|
+
// Clear all toasts
|
|
28
|
+
function clear() {
|
|
29
|
+
update(() => []);
|
|
30
|
+
}
|
|
31
|
+
// Convenience methods for different variants
|
|
32
|
+
function info(message, options) {
|
|
33
|
+
return add({ message, variant: 'info', ...options });
|
|
34
|
+
}
|
|
35
|
+
function success(message, options) {
|
|
36
|
+
return add({ message, variant: 'success', ...options });
|
|
37
|
+
}
|
|
38
|
+
function warning(message, options) {
|
|
39
|
+
return add({ message, variant: 'warning', ...options });
|
|
40
|
+
}
|
|
41
|
+
function error(message, options) {
|
|
42
|
+
return add({ message, variant: 'error', ...options });
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
subscribe,
|
|
46
|
+
add,
|
|
47
|
+
remove,
|
|
48
|
+
clear,
|
|
49
|
+
info,
|
|
50
|
+
success,
|
|
51
|
+
warning,
|
|
52
|
+
error
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export const toast = createToastStore();
|