@websline/system-components 1.3.24 → 1.3.26
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/atoms/actions/closeButton/closeButton.variants.js +3 -3
- package/dist/components/atoms/actions/iconButton/IconButton.svelte +1 -1
- package/dist/components/atoms/actions/iconButton/IconButton.svelte.d.ts +2 -2
- package/dist/components/atoms/actions/iconButton/iconButton.variants.js +2 -2
- package/dist/components/atoms/input/input.variants.js +3 -3
- package/dist/components/atoms/select/Select.svelte +38 -19
- package/dist/components/atoms/select/Select.svelte.d.ts +8 -0
- package/dist/components/atoms/select/select.variants.d.ts +6 -1
- package/dist/components/atoms/select/select.variants.js +17 -12
- package/dist/components/molecules/{notification/Notification.svelte → notifications/systemAlert/SystemAlert.svelte} +8 -8
- package/dist/components/molecules/notifications/systemAlert/SystemAlert.svelte.d.ts +57 -0
- package/dist/components/molecules/{notification/notification.variants.d.ts → notifications/systemAlert/systemAlert.variants.d.ts} +4 -4
- package/dist/components/molecules/{notification/notification.variants.js → notifications/systemAlert/systemAlert.variants.js} +6 -6
- package/dist/components/molecules/notifications/toast/Toast.svelte +51 -0
- package/dist/components/molecules/notifications/toast/Toast.svelte.d.ts +49 -0
- package/dist/components/molecules/notifications/toast/toast.variants.d.ts +31 -0
- package/dist/components/molecules/notifications/toast/toast.variants.js +18 -0
- package/dist/components/molecules/toggleGroup/ToggleGroupItem.svelte +25 -26
- package/dist/components/molecules/toggleGroup/toggleGroupItem.variants.d.ts +15 -45
- package/dist/components/molecules/toggleGroup/toggleGroupItem.variants.js +12 -25
- package/dist/components/organisms/notificationGroup/NotificationGroup.svelte +71 -39
- package/dist/components/organisms/notificationGroup/NotificationGroup.svelte.d.ts +13 -2
- package/dist/components/organisms/notificationGroup/notificationGroup.variants.d.ts +72 -17
- package/dist/components/organisms/notificationGroup/notificationGroup.variants.js +14 -4
- package/dist/index.css +9 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/utils/notification.d.ts +6 -1
- package/dist/utils/notification.js +18 -4
- package/package.json +23 -24
- package/dist/components/molecules/notification/Notification.svelte.d.ts +0 -57
|
@@ -3,8 +3,8 @@ import { tv } from "../../../../utils/tailwind.js";
|
|
|
3
3
|
const closeButtonVariants = tv({
|
|
4
4
|
slots: {
|
|
5
5
|
button:
|
|
6
|
-
"relative cursor-pointer overflow-hidden bg-
|
|
7
|
-
bar: "absolute inset-
|
|
6
|
+
"relative cursor-pointer overflow-hidden bg-neutral-100 p-1 text-neutral-700 transition duration-200 select-none dark:bg-neutral-900 dark:text-neutral-300",
|
|
7
|
+
bar: "absolute inset-0 z-0 bg-neutral-300 dark:bg-neutral-700",
|
|
8
8
|
},
|
|
9
9
|
variants: {
|
|
10
10
|
shape: {
|
|
@@ -12,7 +12,7 @@ const closeButtonVariants = tv({
|
|
|
12
12
|
button: "rounded-full",
|
|
13
13
|
},
|
|
14
14
|
square: {
|
|
15
|
-
button: "rounded-
|
|
15
|
+
button: "rounded-sm",
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
18
|
},
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @typedef {Object} Props
|
|
7
7
|
* @property {string} [as="button"] The HTML element to use for the button
|
|
8
8
|
* @property {string} [class=""] Additional CSS classes to apply to the component
|
|
9
|
-
* @property {"default" | "primary" | "secondary" | "success" | "
|
|
9
|
+
* @property {"default" | "primary" | "secondary" | "success" | "error" | "transparent"} [color="default"] Button color
|
|
10
10
|
* @property {boolean} [disabled=false] Whether the button is disabled
|
|
11
11
|
* @property {boolean} [loading=false] Whether the button is in a loading state, for example after a form submission
|
|
12
12
|
* @property {string} [icon=""] Icon name
|
|
@@ -15,7 +15,7 @@ declare const IconButton: import("svelte").Component<{
|
|
|
15
15
|
/**
|
|
16
16
|
* Button color
|
|
17
17
|
*/
|
|
18
|
-
color?: "default" | "primary" | "secondary" | "success" | "
|
|
18
|
+
color?: "default" | "primary" | "secondary" | "success" | "error" | "transparent";
|
|
19
19
|
/**
|
|
20
20
|
* Whether the button is disabled
|
|
21
21
|
*/
|
|
@@ -61,7 +61,7 @@ type Props = {
|
|
|
61
61
|
/**
|
|
62
62
|
* Button color
|
|
63
63
|
*/
|
|
64
|
-
color?: "default" | "primary" | "secondary" | "success" | "
|
|
64
|
+
color?: "default" | "primary" | "secondary" | "success" | "error" | "transparent";
|
|
65
65
|
/**
|
|
66
66
|
* Whether the button is disabled
|
|
67
67
|
*/
|
|
@@ -73,13 +73,13 @@ const iconButtonVariants = tv({
|
|
|
73
73
|
"border-green-500 text-green-500 hover:border-green-700 hover:bg-green-700 hover:text-white dark:border-green-500 dark:text-green-500 dark:hover:border-green-700 dark:hover:bg-green-700",
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
|
-
color: "
|
|
76
|
+
color: "error",
|
|
77
77
|
variant: "filled",
|
|
78
78
|
class:
|
|
79
79
|
"bg-red-500 text-white hover:bg-red-700 dark:bg-red-500 dark:hover:bg-red-700",
|
|
80
80
|
},
|
|
81
81
|
{
|
|
82
|
-
color: "
|
|
82
|
+
color: "error",
|
|
83
83
|
variant: "outlined",
|
|
84
84
|
class:
|
|
85
85
|
"border-red-500 text-red-500 hover:border-red-700 hover:bg-red-700 hover:text-white dark:border-red-500 dark:text-red-500 dark:hover:border-red-700 dark:hover:bg-red-700",
|
|
@@ -4,10 +4,10 @@ const inputVariants = tv({
|
|
|
4
4
|
extend: inputBaseVariant,
|
|
5
5
|
slots: {
|
|
6
6
|
adornmentStart:
|
|
7
|
-
"pointer-events-none
|
|
7
|
+
"pointer-events-none shrink-0 body-small text-neutral-900 dark:text-neutral-200",
|
|
8
8
|
adornmentEnd:
|
|
9
|
-
"pointer-events-none
|
|
10
|
-
base: "
|
|
9
|
+
"pointer-events-none shrink-0 body-small text-neutral-900 dark:text-neutral-200",
|
|
10
|
+
base: "flex h-10 items-center gap-2",
|
|
11
11
|
input:
|
|
12
12
|
"h-full w-full border-0 bg-transparent p-0 [font-size:inherit] leading-[inherit] focus:shadow-none focus:ring-0 focus:outline-0",
|
|
13
13
|
},
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {Object} Props
|
|
7
|
+
* @property {string|import("svelte").SvelteComponent|Function} [adornmentStart=""] Content to display at the start of the field (e.g., icon or text)
|
|
7
8
|
* @property {"default" | "raised"} [buttonAppearance="default"] Appearance of the button variant
|
|
8
9
|
* @property {"small" | "medium" | "large"} [buttonSize="medium"] Size of the button variant
|
|
9
10
|
* @property {string} [class=""] Additional CSS classes for the select
|
|
@@ -19,6 +20,7 @@
|
|
|
19
20
|
|
|
20
21
|
/** @type {Props} */
|
|
21
22
|
let {
|
|
23
|
+
adornmentStart = "",
|
|
22
24
|
buttonAppearance = "default",
|
|
23
25
|
buttonSize = "medium",
|
|
24
26
|
class: className = "",
|
|
@@ -43,6 +45,7 @@
|
|
|
43
45
|
error: error ?? storeValues.error ?? false,
|
|
44
46
|
id: id ?? storeValues.id ?? "",
|
|
45
47
|
required: required ?? storeValues.required ?? false,
|
|
48
|
+
value: value ?? "",
|
|
46
49
|
};
|
|
47
50
|
});
|
|
48
51
|
|
|
@@ -50,32 +53,48 @@
|
|
|
50
53
|
selectVariants({
|
|
51
54
|
buttonAppearance,
|
|
52
55
|
buttonSize,
|
|
53
|
-
defaultValue: variant === "default" &&
|
|
56
|
+
defaultValue: variant === "default" && localValues.value === "",
|
|
54
57
|
error: localValues.error,
|
|
55
58
|
variant,
|
|
56
59
|
}),
|
|
57
60
|
);
|
|
61
|
+
|
|
62
|
+
const setValue = (v) => (value = v);
|
|
58
63
|
</script>
|
|
59
64
|
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
>{placeholder}</option>
|
|
65
|
+
<div class={styles.base({ class: className, disabled: localValues.disabled })}>
|
|
66
|
+
{#if adornmentStart}
|
|
67
|
+
<div class={styles.adornmentStart()}>
|
|
68
|
+
{#if typeof adornmentStart === "function"}
|
|
69
|
+
{@render adornmentStart()}
|
|
70
|
+
{:else}
|
|
71
|
+
{adornmentStart}
|
|
72
|
+
{/if}
|
|
73
|
+
</div>
|
|
70
74
|
{/if}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
<select
|
|
76
|
+
class={styles.select()}
|
|
77
|
+
disabled={localValues.disabled}
|
|
78
|
+
id={localValues.id}
|
|
79
|
+
required={localValues.required}
|
|
80
|
+
bind:value={() => localValues.value, setValue}
|
|
81
|
+
{...rest}>
|
|
82
|
+
{#if placeholder}
|
|
83
|
+
<option
|
|
84
|
+
class={styles.option({ disabled: localValues.required })}
|
|
85
|
+
hidden={localValues.required}
|
|
86
|
+
readonly
|
|
87
|
+
value="">{placeholder}</option>
|
|
88
|
+
{/if}
|
|
89
|
+
{#each options as { disabled, label, value: optValue } (optValue)}
|
|
90
|
+
<option
|
|
91
|
+
class={styles.option({ disabled })}
|
|
92
|
+
{disabled}
|
|
93
|
+
selected={value === optValue}
|
|
94
|
+
value={optValue}>{label}</option>
|
|
95
|
+
{/each}
|
|
96
|
+
</select>
|
|
97
|
+
</div>
|
|
79
98
|
|
|
80
99
|
<style>
|
|
81
100
|
select {
|
|
@@ -4,6 +4,10 @@ type Select = {
|
|
|
4
4
|
$set?(props: Partial<Props>): void;
|
|
5
5
|
};
|
|
6
6
|
declare const Select: import("svelte").Component<{
|
|
7
|
+
/**
|
|
8
|
+
* Content to display at the start of the field (e.g., icon or text)
|
|
9
|
+
*/
|
|
10
|
+
adornmentStart?: string | import("svelte").SvelteComponent | Function;
|
|
7
11
|
/**
|
|
8
12
|
* Appearance of the button variant
|
|
9
13
|
*/
|
|
@@ -54,6 +58,10 @@ declare const Select: import("svelte").Component<{
|
|
|
54
58
|
variant?: "default" | "button";
|
|
55
59
|
}, {}, "value">;
|
|
56
60
|
type Props = {
|
|
61
|
+
/**
|
|
62
|
+
* Content to display at the start of the field (e.g., icon or text)
|
|
63
|
+
*/
|
|
64
|
+
adornmentStart?: string | import("svelte").SvelteComponent | Function;
|
|
57
65
|
/**
|
|
58
66
|
* Appearance of the button variant
|
|
59
67
|
*/
|
|
@@ -2,6 +2,7 @@ export const selectVariants: import("tailwind-variants").TVReturnType<{
|
|
|
2
2
|
disabled: {
|
|
3
3
|
false: {
|
|
4
4
|
option: string;
|
|
5
|
+
select: string;
|
|
5
6
|
};
|
|
6
7
|
true: {
|
|
7
8
|
option: string;
|
|
@@ -9,15 +10,19 @@ export const selectVariants: import("tailwind-variants").TVReturnType<{
|
|
|
9
10
|
};
|
|
10
11
|
variant: {
|
|
11
12
|
default: {
|
|
13
|
+
adornmentStart: string;
|
|
12
14
|
base: string;
|
|
13
15
|
};
|
|
14
16
|
button: {
|
|
17
|
+
adornmentStart: string;
|
|
15
18
|
base: string;
|
|
16
19
|
};
|
|
17
20
|
};
|
|
18
21
|
}, {
|
|
19
|
-
|
|
22
|
+
adornmentStart: string;
|
|
23
|
+
base: string;
|
|
20
24
|
option: string[];
|
|
25
|
+
select: string[];
|
|
21
26
|
}, undefined, {
|
|
22
27
|
disabled: {
|
|
23
28
|
true: {
|
|
@@ -3,29 +3,32 @@ import { inputBaseVariant, tv } from "../../../utils/tailwind.js";
|
|
|
3
3
|
const selectVariants = tv({
|
|
4
4
|
extend: inputBaseVariant,
|
|
5
5
|
slots: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"[&::picker(select)]:my-1 [&::picker(select)]:rounded-sm [&::picker(select)]:border-0 [&::picker(select)]:p-1",
|
|
9
|
-
"[&::picker-icon]:hidden",
|
|
10
|
-
"[&::picker(select)]:bg-white [&::picker(select)]:shadow-sm dark:[&::picker(select)]:bg-neutral-800",
|
|
11
|
-
"bg-none after:bg-current after:bg-size-[100%] after:bg-center after:bg-no-repeat",
|
|
12
|
-
"after:ml-auto after:size-5 after:shrink-0",
|
|
13
|
-
"[&:open]:after:rotate-180",
|
|
14
|
-
],
|
|
6
|
+
adornmentStart: "pointer-events-none shrink-0 body-small leading-[inherit]",
|
|
7
|
+
base: "flex items-center ui-select-label",
|
|
15
8
|
option: [
|
|
16
|
-
"flex rounded-sm p-2
|
|
9
|
+
"flex rounded-sm p-2",
|
|
17
10
|
"bg-white dark:bg-neutral-800",
|
|
18
11
|
"bg-linear-to-r to-transparent",
|
|
19
12
|
"[&::checkmark]:order-1 [&::checkmark]:ml-auto [&::checkmark]:shrink-0",
|
|
20
13
|
"[&::checkmark]:bg-current [&::checkmark]:bg-size-[100%] [&::checkmark]:bg-center [&::checkmark]:bg-no-repeat",
|
|
21
14
|
"[&::checkmark]:size-4 [&::checkmark]:content-['']",
|
|
22
15
|
],
|
|
16
|
+
select: [
|
|
17
|
+
"flex size-full items-center border-0 bg-transparent p-0 [font-size:inherit] leading-[inherit] focus:shadow-none focus:ring-0 focus:outline-0",
|
|
18
|
+
"[&::picker(select)]:my-1 [&::picker(select)]:rounded-sm [&::picker(select)]:border-0 [&::picker(select)]:p-1",
|
|
19
|
+
"[&::picker-icon]:hidden",
|
|
20
|
+
"[&::picker(select)]:bg-white [&::picker(select)]:shadow-sm dark:[&::picker(select)]:bg-neutral-800",
|
|
21
|
+
"bg-none after:bg-current after:bg-size-[100%] after:bg-center after:bg-no-repeat",
|
|
22
|
+
"after:ml-auto after:size-5 after:shrink-0",
|
|
23
|
+
"[&:open]:after:rotate-180",
|
|
24
|
+
],
|
|
23
25
|
},
|
|
24
26
|
variants: {
|
|
25
27
|
disabled: {
|
|
26
28
|
false: {
|
|
27
29
|
option:
|
|
28
30
|
"cursor-pointer text-neutral-900 hover:from-black/15 dark:text-neutral-200 dark:hover:from-white/15",
|
|
31
|
+
select: "cursor-pointer",
|
|
29
32
|
},
|
|
30
33
|
true: {
|
|
31
34
|
option: "text-neutral-500 dark:text-neutral-500 [&::checkmark]:hidden",
|
|
@@ -33,9 +36,11 @@ const selectVariants = tv({
|
|
|
33
36
|
},
|
|
34
37
|
variant: {
|
|
35
38
|
default: {
|
|
36
|
-
|
|
39
|
+
adornmentStart: "text-neutral-900 dark:text-neutral-200",
|
|
40
|
+
base: "min-h-10 gap-2 border border-neutral-300 pr-2 pl-4",
|
|
37
41
|
},
|
|
38
42
|
button: {
|
|
43
|
+
adornmentStart: "text-neutral-500",
|
|
39
44
|
base: "gap-0.5 border-none bg-white pr-1 pl-2 leading-5 ring-transparent! dark:bg-neutral-800",
|
|
40
45
|
},
|
|
41
46
|
},
|
|
@@ -65,7 +70,7 @@ const selectVariants = tv({
|
|
|
65
70
|
variant: "button",
|
|
66
71
|
disabled: false,
|
|
67
72
|
class: {
|
|
68
|
-
base: "
|
|
73
|
+
base: "focus-within:bg-neutral-300 hover:bg-neutral-300 focus:ring-2 focus:ring-blue-500 dark:focus-within:bg-neutral-600 dark:hover:bg-neutral-600",
|
|
69
74
|
},
|
|
70
75
|
},
|
|
71
76
|
{
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { CloseButton, Icon } from "
|
|
3
|
-
import {
|
|
2
|
+
import { CloseButton, Icon } from "../../../../index.js";
|
|
3
|
+
import { systemAlertVariants } from "./systemAlert.variants.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {Object} Props
|
|
7
|
-
* @property {boolean} [autoClose=true] Whether to automatically close the
|
|
7
|
+
* @property {boolean} [autoClose=true] Whether to automatically close the system alert after a duration
|
|
8
8
|
* @property {string} [class=""] Additional CSS classes to apply to the component
|
|
9
|
-
* @property {string} [icon=""] Icon to display in the
|
|
10
|
-
* @property {string} [message=""] Message to display in the
|
|
11
|
-
* @property {string} [title=""] Title to display in the
|
|
12
|
-
* @property {"info" | "success" | "warning" | "
|
|
9
|
+
* @property {string} [icon=""] Icon to display in the system alert
|
|
10
|
+
* @property {string} [message=""] Message to display in the system alert
|
|
11
|
+
* @property {string} [title=""] Title to display in the system alert
|
|
12
|
+
* @property {"info" | "success" | "warning" | "error"} [variant="info"] System alert variant
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
/** @type {Props} */
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
...rest
|
|
25
25
|
} = $props();
|
|
26
26
|
|
|
27
|
-
let styles = $derived(
|
|
27
|
+
let styles = $derived(systemAlertVariants({ variant }));
|
|
28
28
|
</script>
|
|
29
29
|
|
|
30
30
|
<div class={styles.base({ class: className })} {...rest}>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export default SystemAlert;
|
|
2
|
+
type SystemAlert = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<Props>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const SystemAlert: import("svelte").Component<{
|
|
7
|
+
/**
|
|
8
|
+
* Whether to automatically close the system alert after a duration
|
|
9
|
+
*/
|
|
10
|
+
autoClose?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Additional CSS classes to apply to the component
|
|
13
|
+
*/
|
|
14
|
+
class?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Icon to display in the system alert
|
|
17
|
+
*/
|
|
18
|
+
icon?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Message to display in the system alert
|
|
21
|
+
*/
|
|
22
|
+
message?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Title to display in the system alert
|
|
25
|
+
*/
|
|
26
|
+
title?: string;
|
|
27
|
+
/**
|
|
28
|
+
* System alert variant
|
|
29
|
+
*/
|
|
30
|
+
variant?: "info" | "success" | "warning" | "error";
|
|
31
|
+
}, {}, "">;
|
|
32
|
+
type Props = {
|
|
33
|
+
/**
|
|
34
|
+
* Whether to automatically close the system alert after a duration
|
|
35
|
+
*/
|
|
36
|
+
autoClose?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Additional CSS classes to apply to the component
|
|
39
|
+
*/
|
|
40
|
+
class?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Icon to display in the system alert
|
|
43
|
+
*/
|
|
44
|
+
icon?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Message to display in the system alert
|
|
47
|
+
*/
|
|
48
|
+
message?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Title to display in the system alert
|
|
51
|
+
*/
|
|
52
|
+
title?: string;
|
|
53
|
+
/**
|
|
54
|
+
* System alert variant
|
|
55
|
+
*/
|
|
56
|
+
variant?: "info" | "success" | "warning" | "error";
|
|
57
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const systemAlertVariants: import("tailwind-variants").TVReturnType<{
|
|
2
2
|
variant: {
|
|
3
3
|
info: {
|
|
4
4
|
icon: string;
|
|
@@ -9,7 +9,7 @@ export const notificationVariants: import("tailwind-variants").TVReturnType<{
|
|
|
9
9
|
warning: {
|
|
10
10
|
icon: string;
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
error: {
|
|
13
13
|
icon: string;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
@@ -31,7 +31,7 @@ export const notificationVariants: import("tailwind-variants").TVReturnType<{
|
|
|
31
31
|
warning: {
|
|
32
32
|
icon: string;
|
|
33
33
|
};
|
|
34
|
-
|
|
34
|
+
error: {
|
|
35
35
|
icon: string;
|
|
36
36
|
};
|
|
37
37
|
};
|
|
@@ -53,7 +53,7 @@ export const notificationVariants: import("tailwind-variants").TVReturnType<{
|
|
|
53
53
|
warning: {
|
|
54
54
|
icon: string;
|
|
55
55
|
};
|
|
56
|
-
|
|
56
|
+
error: {
|
|
57
57
|
icon: string;
|
|
58
58
|
};
|
|
59
59
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { tv } from "
|
|
1
|
+
import { tv } from "../../../../utils/tailwind.js";
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const systemAlertVariants = tv({
|
|
4
4
|
slots: {
|
|
5
|
-
base: "grid grid-cols-[40px_1fr_24px] gap-2 rounded-lg border border-neutral-
|
|
5
|
+
base: "grid grid-cols-[40px_1fr_24px] gap-2 rounded-lg border border-neutral-200 bg-white/90 p-2 backdrop-blur-sm dark:border-neutral-700 dark:bg-neutral-800/90",
|
|
6
6
|
close: "col-3 self-start",
|
|
7
7
|
icon: "flex h-10 w-10 items-center justify-center rounded-sm text-white",
|
|
8
8
|
content: "flex flex-col justify-center",
|
|
9
9
|
message: "ui-caption-helper text-neutral-500",
|
|
10
|
-
title: "body-small dark:text-
|
|
10
|
+
title: "body-small dark:text-neutral-200",
|
|
11
11
|
},
|
|
12
12
|
variants: {
|
|
13
13
|
variant: {
|
|
@@ -20,11 +20,11 @@ const notificationVariants = tv({
|
|
|
20
20
|
warning: {
|
|
21
21
|
icon: "bg-yellow-500",
|
|
22
22
|
},
|
|
23
|
-
|
|
23
|
+
error: {
|
|
24
24
|
icon: "bg-red-500",
|
|
25
25
|
},
|
|
26
26
|
},
|
|
27
27
|
},
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
export {
|
|
30
|
+
export { systemAlertVariants };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Icon, Spinner } from "../../../../index.js";
|
|
3
|
+
import { toastVariants } from "./toast.variants.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} Props
|
|
7
|
+
* @property {string} [class=""] Additional CSS classes to apply to the component
|
|
8
|
+
* @property {number} [durationInSeconds=6] Duration in seconds before auto-close triggers
|
|
9
|
+
* @property {string} [message=""] Message to display in the toast
|
|
10
|
+
* @property {(event) => void} [onClose] Function to call when the toast is auto-closed
|
|
11
|
+
* @property {"info" | "loading" | "error"} [variant="info"] Toast variant
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const ICONS_BY_VARIANT = {
|
|
15
|
+
error: "closeSmall",
|
|
16
|
+
info: "check",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** @type {Props} */
|
|
20
|
+
let {
|
|
21
|
+
class: className = "",
|
|
22
|
+
durationInSeconds = 6,
|
|
23
|
+
message = "",
|
|
24
|
+
onClose,
|
|
25
|
+
variant = "info",
|
|
26
|
+
...rest
|
|
27
|
+
} = $props();
|
|
28
|
+
|
|
29
|
+
let to;
|
|
30
|
+
let styles = $derived(toastVariants({ variant }));
|
|
31
|
+
|
|
32
|
+
$effect(() => {
|
|
33
|
+
clearTimeout(to);
|
|
34
|
+
if (variant !== "loading" && durationInSeconds > 0) {
|
|
35
|
+
to = setTimeout(() => {
|
|
36
|
+
onClose?.();
|
|
37
|
+
}, durationInSeconds * 1e3);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<div class={styles.base({ class: className })} {...rest}>
|
|
43
|
+
<div class={styles.icon()}>
|
|
44
|
+
{#if variant === "loading"}
|
|
45
|
+
<Spinner size="small" />
|
|
46
|
+
{:else}
|
|
47
|
+
<Icon name={ICONS_BY_VARIANT[variant]} size={24} />
|
|
48
|
+
{/if}
|
|
49
|
+
</div>
|
|
50
|
+
<p class={styles.message()}>{message}</p>
|
|
51
|
+
</div>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export default Toast;
|
|
2
|
+
type Toast = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<Props>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const Toast: import("svelte").Component<{
|
|
7
|
+
/**
|
|
8
|
+
* Additional CSS classes to apply to the component
|
|
9
|
+
*/
|
|
10
|
+
class?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Duration in seconds before auto-close triggers
|
|
13
|
+
*/
|
|
14
|
+
durationInSeconds?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Message to display in the toast
|
|
17
|
+
*/
|
|
18
|
+
message?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Function to call when the toast is auto-closed
|
|
21
|
+
*/
|
|
22
|
+
onClose?: (event: any) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Toast variant
|
|
25
|
+
*/
|
|
26
|
+
variant?: "info" | "loading" | "error";
|
|
27
|
+
}, {}, "">;
|
|
28
|
+
type Props = {
|
|
29
|
+
/**
|
|
30
|
+
* Additional CSS classes to apply to the component
|
|
31
|
+
*/
|
|
32
|
+
class?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Duration in seconds before auto-close triggers
|
|
35
|
+
*/
|
|
36
|
+
durationInSeconds?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Message to display in the toast
|
|
39
|
+
*/
|
|
40
|
+
message?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Function to call when the toast is auto-closed
|
|
43
|
+
*/
|
|
44
|
+
onClose?: (event: any) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Toast variant
|
|
47
|
+
*/
|
|
48
|
+
variant?: "info" | "loading" | "error";
|
|
49
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const toastVariants: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
variant: {
|
|
3
|
+
error: {
|
|
4
|
+
base: string;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
}, {
|
|
8
|
+
base: string;
|
|
9
|
+
icon: string;
|
|
10
|
+
message: string;
|
|
11
|
+
}, undefined, {
|
|
12
|
+
variant: {
|
|
13
|
+
error: {
|
|
14
|
+
base: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}, {
|
|
18
|
+
base: string;
|
|
19
|
+
icon: string;
|
|
20
|
+
message: string;
|
|
21
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
22
|
+
variant: {
|
|
23
|
+
error: {
|
|
24
|
+
base: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}, {
|
|
28
|
+
base: string;
|
|
29
|
+
icon: string;
|
|
30
|
+
message: string;
|
|
31
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { tv } from "../../../../utils/tailwind.js";
|
|
2
|
+
|
|
3
|
+
const toastVariants = tv({
|
|
4
|
+
slots: {
|
|
5
|
+
base: "flex items-center gap-2 rounded-lg bg-neutral-900 px-4 py-2 text-neutral-200",
|
|
6
|
+
icon: "grid size-6 place-items-center",
|
|
7
|
+
message: "ui-select-label font-medium",
|
|
8
|
+
},
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
error: {
|
|
12
|
+
base: "bg-red-500",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export { toastVariants };
|
|
@@ -44,31 +44,30 @@
|
|
|
44
44
|
});
|
|
45
45
|
</script>
|
|
46
46
|
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
<button
|
|
48
|
+
class={stylesByVariant.base({ class: baseClass || className })}
|
|
49
|
+
role="tab"
|
|
50
|
+
onclick={() => {
|
|
51
|
+
store.update(localeValue);
|
|
52
|
+
}}
|
|
53
|
+
type="button"
|
|
54
|
+
{...rest}>
|
|
55
|
+
{#if icon}
|
|
56
|
+
<Icon
|
|
57
|
+
class={stylesByVariant.icon()}
|
|
58
|
+
name={icon}
|
|
59
|
+
size={variant === "tabs" || size === "small" ? 16 : 24} />
|
|
60
|
+
{/if}
|
|
61
|
+
{#if children}
|
|
55
62
|
<div class={stylesByVariant.content()}>
|
|
56
|
-
{
|
|
57
|
-
<Icon
|
|
58
|
-
class={stylesByVariant.icon()}
|
|
59
|
-
name={icon}
|
|
60
|
-
size={variant === "tabs" || size === "small" ? 16 : 24} />
|
|
61
|
-
{/if}
|
|
62
|
-
<span class={stylesByVariant.span()}>
|
|
63
|
-
{@render children?.()}
|
|
64
|
-
</span>
|
|
63
|
+
{@render children()}
|
|
65
64
|
</div>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
</
|
|
65
|
+
{/if}
|
|
66
|
+
{#if isActive}
|
|
67
|
+
<div
|
|
68
|
+
class={stylesByVariant.trigger({ appearance })}
|
|
69
|
+
in:send={{ key: "active-tab" }}
|
|
70
|
+
out:receive={{ key: "active-tab" }}>
|
|
71
|
+
</div>
|
|
72
|
+
{/if}
|
|
73
|
+
</button>
|