@juspay/svelte-ui-components 2.2.1 → 2.2.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/Img/Img.svelte
CHANGED
package/dist/Toast/Toast.svelte
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { fly } from 'svelte/transition';
|
|
3
|
-
import type {
|
|
4
|
-
import type { ToastDirection } from './properties';
|
|
3
|
+
import type { ToastDirection, ToastProperties } from './properties';
|
|
5
4
|
import type { FlyAnimationConfig } from '../types';
|
|
5
|
+
import { onMount } from 'svelte';
|
|
6
6
|
|
|
7
7
|
let {
|
|
8
8
|
duration = 2000,
|
|
@@ -23,28 +23,9 @@
|
|
|
23
23
|
closeIconTestId,
|
|
24
24
|
onToastHide,
|
|
25
25
|
bottomContent
|
|
26
|
-
}:
|
|
27
|
-
duration?: number | null;
|
|
28
|
-
leftIcon?: string | null;
|
|
29
|
-
message?: string | null;
|
|
30
|
-
subtext?: string | null;
|
|
31
|
-
rightIcon?: string | null;
|
|
32
|
-
type?: 'success' | 'error' | 'info' | 'warn' | null;
|
|
33
|
-
direction: ToastDirection;
|
|
34
|
-
overlapPage?: boolean;
|
|
35
|
-
inAnimationOffset?: number | null;
|
|
36
|
-
inAnimationDuration?: number | null;
|
|
37
|
-
outAnimationOffset?: number | null;
|
|
38
|
-
outAnimationDuration?: number | null;
|
|
39
|
-
testId?: string | null;
|
|
40
|
-
messageTestId?: string | null;
|
|
41
|
-
subTextTestId?: string | null;
|
|
42
|
-
closeIconTestId?: string | null;
|
|
43
|
-
onToastHide?: () => void;
|
|
44
|
-
bottomContent?: Snippet;
|
|
45
|
-
} = $props();
|
|
26
|
+
}: ToastProperties = $props();
|
|
46
27
|
|
|
47
|
-
const animationConfig: FlyAnimationConfig = getAnimationConfig(
|
|
28
|
+
const animationConfig: FlyAnimationConfig = $derived(getAnimationConfig(overlapPage, direction));
|
|
48
29
|
|
|
49
30
|
let showToast = $state(false);
|
|
50
31
|
let timeoutId = $state<ReturnType<typeof setTimeout> | null>(null);
|
|
@@ -64,8 +45,8 @@
|
|
|
64
45
|
* @returns {FlyAnimationConfig} Animation configuration object.
|
|
65
46
|
*/
|
|
66
47
|
function getAnimationConfig(
|
|
67
|
-
|
|
68
|
-
|
|
48
|
+
overlapPage: boolean,
|
|
49
|
+
toastDirection?: ToastDirection,
|
|
69
50
|
): FlyAnimationConfig {
|
|
70
51
|
// Initializing variables to store animation offsets
|
|
71
52
|
let inX: number = 0;
|
|
@@ -113,9 +94,9 @@
|
|
|
113
94
|
};
|
|
114
95
|
}
|
|
115
96
|
|
|
116
|
-
|
|
97
|
+
onMount(() => {
|
|
117
98
|
showToast = true;
|
|
118
|
-
timeoutId = setTimeout(hideToast,
|
|
99
|
+
timeoutId = setTimeout(hideToast, duration);
|
|
119
100
|
|
|
120
101
|
return () => {
|
|
121
102
|
if (timeoutId !== null) {
|
|
@@ -1,25 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
type $$ComponentProps = {
|
|
4
|
-
duration?: number | null;
|
|
5
|
-
leftIcon?: string | null;
|
|
6
|
-
message?: string | null;
|
|
7
|
-
subtext?: string | null;
|
|
8
|
-
rightIcon?: string | null;
|
|
9
|
-
type?: 'success' | 'error' | 'info' | 'warn' | null;
|
|
10
|
-
direction: ToastDirection;
|
|
11
|
-
overlapPage?: boolean;
|
|
12
|
-
inAnimationOffset?: number | null;
|
|
13
|
-
inAnimationDuration?: number | null;
|
|
14
|
-
outAnimationOffset?: number | null;
|
|
15
|
-
outAnimationDuration?: number | null;
|
|
16
|
-
testId?: string | null;
|
|
17
|
-
messageTestId?: string | null;
|
|
18
|
-
subTextTestId?: string | null;
|
|
19
|
-
closeIconTestId?: string | null;
|
|
20
|
-
onToastHide?: () => void;
|
|
21
|
-
bottomContent?: Snippet;
|
|
22
|
-
};
|
|
23
|
-
declare const Toast: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
1
|
+
import type { ToastProperties } from './properties';
|
|
2
|
+
declare const Toast: import("svelte").Component<ToastProperties, {}, "">;
|
|
24
3
|
type Toast = ReturnType<typeof Toast>;
|
|
25
4
|
export default Toast;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
1
2
|
export type ToastType = 'success' | 'error' | 'info' | 'warn';
|
|
2
3
|
export type ToastDirection = 'left-to-right' | 'right-to-left' | 'top-to-bottom' | 'bottom-to-top';
|
|
3
4
|
export type ToastProperties = {
|
|
4
|
-
duration
|
|
5
|
+
duration?: number;
|
|
5
6
|
leftIcon?: string | null;
|
|
6
7
|
message: string;
|
|
7
8
|
subtext?: string | null;
|
|
8
9
|
rightIcon?: string | null;
|
|
9
10
|
type?: ToastType | null;
|
|
10
|
-
direction?: ToastDirection
|
|
11
|
+
direction?: ToastDirection;
|
|
11
12
|
overlapPage?: boolean;
|
|
12
13
|
inAnimationOffset?: number | null;
|
|
13
14
|
inAnimationDuration?: number | null;
|
|
@@ -17,4 +18,6 @@ export type ToastProperties = {
|
|
|
17
18
|
messageTestId?: string;
|
|
18
19
|
subTextTestId?: string;
|
|
19
20
|
closeIconTestId?: string;
|
|
21
|
+
bottomContent?: Snippet;
|
|
22
|
+
onToastHide?: () => void;
|
|
20
23
|
};
|