@juspay/svelte-ui-components 1.34.0 → 1.34.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/Accordion/Accordion.svelte +17 -30
- package/dist/Accordion/Accordion.svelte.d.ts +6 -20
- package/dist/Animations/ModalAnimation.svelte +44 -30
- package/dist/Animations/ModalAnimation.svelte.d.ts +9 -21
- package/dist/Animations/OverlayAnimation.svelte +9 -2
- package/dist/Animations/OverlayAnimation.svelte.d.ts +6 -28
- package/dist/Badge/Badge.svelte +9 -8
- package/dist/Badge/Badge.svelte.d.ts +3 -18
- package/dist/Banner/Banner.svelte +20 -19
- package/dist/Banner/Banner.svelte.d.ts +3 -23
- package/dist/Banner/properties.d.ts +6 -2
- package/dist/BrandLoader/BrandLoader.svelte +33 -34
- package/dist/BrandLoader/BrandLoader.svelte.d.ts +3 -19
- package/dist/BrandLoader/properties.d.ts +1 -4
- package/dist/BrandLoader/properties.js +1 -7
- package/dist/Button/Button.svelte +38 -27
- package/dist/Button/Button.svelte.d.ts +4 -23
- package/dist/Button/properties.d.ts +9 -5
- package/dist/Button/properties.js +1 -7
- package/dist/Carousel/Carousel.svelte +132 -108
- package/dist/Carousel/Carousel.svelte.d.ts +3 -20
- package/dist/Carousel/properties.d.ts +6 -12
- package/dist/Carousel/properties.js +1 -7
- package/dist/CheckListItem/CheckListItem.svelte +19 -13
- package/dist/CheckListItem/CheckListItem.svelte.d.ts +4 -23
- package/dist/CheckListItem/properties.d.ts +7 -0
- package/dist/CheckListItem/properties.js +1 -0
- package/dist/GridItem/GridItem.svelte +17 -11
- package/dist/GridItem/GridItem.svelte.d.ts +4 -24
- package/dist/GridItem/properties.d.ts +8 -0
- package/dist/GridItem/properties.js +1 -0
- package/dist/Icon/Icon.svelte +8 -6
- package/dist/Icon/Icon.svelte.d.ts +3 -21
- package/dist/Icon/properties.d.ts +3 -2
- package/dist/Icon/properties.js +1 -4
- package/dist/IconStack/IconStack.svelte +5 -3
- package/dist/IconStack/IconStack.svelte.d.ts +4 -19
- package/dist/IconStack/properties.d.ts +5 -2
- package/dist/Img/Img.svelte +13 -9
- package/dist/Img/Img.svelte.d.ts +4 -20
- package/dist/Img/properties.d.ts +2 -2
- package/dist/Input/Input.svelte +172 -139
- package/dist/Input/Input.svelte.d.ts +6 -32
- package/dist/Input/properties.d.ts +23 -22
- package/dist/Input/properties.js +1 -23
- package/dist/InputButton/InputButton.svelte +76 -78
- package/dist/InputButton/InputButton.svelte.d.ts +6 -35
- package/dist/InputButton/properties.d.ts +6 -4
- package/dist/InputButton/properties.js +1 -18
- package/dist/ListItem/ListItem.svelte +87 -64
- package/dist/ListItem/ListItem.svelte.d.ts +4 -35
- package/dist/ListItem/properties.d.ts +21 -7
- package/dist/ListItem/properties.js +1 -8
- package/dist/Loader/Loader.svelte +1 -4
- package/dist/Loader/Loader.svelte.d.ts +24 -15
- package/dist/Modal/Modal.svelte +121 -93
- package/dist/Modal/Modal.svelte.d.ts +3 -29
- package/dist/Modal/properties.d.ts +21 -13
- package/dist/Modal/properties.js +1 -14
- package/dist/Select/Select.svelte +170 -142
- package/dist/Select/Select.svelte.d.ts +3 -26
- package/dist/Select/properties.d.ts +19 -10
- package/dist/Status/Status.svelte +15 -15
- package/dist/Status/Status.svelte.d.ts +3 -21
- package/dist/Status/properties.d.ts +2 -2
- package/dist/Status/properties.js +1 -6
- package/dist/Stepper/Step.svelte +13 -13
- package/dist/Stepper/Step.svelte.d.ts +4 -23
- package/dist/Stepper/Stepper.svelte +10 -7
- package/dist/Stepper/Stepper.svelte.d.ts +3 -20
- package/dist/Stepper/properties.d.ts +12 -0
- package/dist/Table/Table.svelte +73 -47
- package/dist/Table/Table.svelte.d.ts +3 -20
- package/dist/Table/properties.d.ts +5 -5
- package/dist/Toast/Toast.svelte +149 -74
- package/dist/Toast/Toast.svelte.d.ts +24 -23
- package/dist/Toast/properties.d.ts +10 -11
- package/dist/Toast/properties.js +1 -4
- package/dist/Toggle/Toggle.svelte +12 -11
- package/dist/Toggle/Toggle.svelte.d.ts +4 -21
- package/dist/Toggle/properties.d.ts +5 -0
- package/dist/Toggle/properties.js +1 -0
- package/dist/Toolbar/Toolbar.svelte +27 -20
- package/dist/Toolbar/Toolbar.svelte.d.ts +3 -26
- package/dist/Toolbar/properties.d.ts +10 -4
- package/dist/Toolbar/properties.js +1 -5
- package/dist/index.d.ts +0 -11
- package/dist/index.js +0 -11
- package/dist/utils.d.ts +1 -1
- package/package.json +29 -28
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { StepperProperties } from './properties';
|
|
3
|
-
declare const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
events: {
|
|
8
|
-
handleStepClick: CustomEvent<any>;
|
|
9
|
-
} & {
|
|
10
|
-
[evt: string]: CustomEvent<any>;
|
|
11
|
-
};
|
|
12
|
-
slots: {};
|
|
13
|
-
exports?: {} | undefined;
|
|
14
|
-
bindings?: string | undefined;
|
|
15
|
-
};
|
|
16
|
-
export type StepperProps = typeof __propDef.props;
|
|
17
|
-
export type StepperEvents = typeof __propDef.events;
|
|
18
|
-
export type StepperSlots = typeof __propDef.slots;
|
|
19
|
-
export default class Stepper extends SvelteComponent<StepperProps, StepperEvents, StepperSlots> {
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
2
|
+
declare const Stepper: import("svelte").Component<StepperProperties, {}, "">;
|
|
3
|
+
type Stepper = ReturnType<typeof Stepper>;
|
|
4
|
+
export default Stepper;
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
export type StepperProperties = {
|
|
2
2
|
steps: Array<Step>;
|
|
3
3
|
currentStepIndex: number;
|
|
4
|
+
onhandleStepClick?: (event: {
|
|
5
|
+
selectedIndex: number;
|
|
6
|
+
}) => void;
|
|
4
7
|
};
|
|
5
8
|
export type Step = {
|
|
6
9
|
label: string;
|
|
7
10
|
icon?: string;
|
|
8
11
|
};
|
|
12
|
+
export type StepProperties = {
|
|
13
|
+
stepIndex: number;
|
|
14
|
+
label: string;
|
|
15
|
+
icon?: string;
|
|
16
|
+
onclick?: (event: {
|
|
17
|
+
selectedIndex: number;
|
|
18
|
+
}) => void;
|
|
19
|
+
onkeydown?: (event: KeyboardEvent) => void;
|
|
20
|
+
};
|
package/dist/Table/Table.svelte
CHANGED
|
@@ -1,69 +1,95 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const colIndex = properties.tableHeaders.indexOf(column);
|
|
19
|
-
const valueA = a[colIndex];
|
|
20
|
-
const valueB = b[colIndex];
|
|
21
|
-
if (typeof valueA === "number" && typeof valueB === "number") {
|
|
22
|
-
return sortOrders[column] === "asc" ? valueA - valueB : valueB - valueA;
|
|
23
|
-
} else if (typeof valueA === "string" && typeof valueB === "string") {
|
|
24
|
-
return sortOrders[column] === "asc" ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA);
|
|
25
|
-
} else if (typeof valueA === "boolean" && typeof valueB === "boolean") {
|
|
26
|
-
return sortOrders[column] === "asc" ? valueA === valueB ? 0 : valueA ? -1 : 1 : valueA === valueB ? 0 : valueA ? 1 : -1;
|
|
27
|
-
} else {
|
|
28
|
-
return 0;
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { TableProperties } from './properties';
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
tableTitle = '',
|
|
6
|
+
tableHeaders = [],
|
|
7
|
+
tableData = [],
|
|
8
|
+
isTableScrollable = false,
|
|
9
|
+
isContentScrollable = false
|
|
10
|
+
}: TableProperties = $props();
|
|
11
|
+
|
|
12
|
+
let sortOrders = $state<{ [key: string]: 'asc' | 'desc' }>({});
|
|
13
|
+
|
|
14
|
+
let sortedTableData = $derived.by(() => {
|
|
15
|
+
const columns = Object.keys(sortOrders);
|
|
16
|
+
if (columns.length === 0) {
|
|
17
|
+
return [...tableData];
|
|
29
18
|
}
|
|
19
|
+
|
|
20
|
+
// Sort by the last clicked column
|
|
21
|
+
const column = columns[columns.length - 1];
|
|
22
|
+
const order = sortOrders[column];
|
|
23
|
+
|
|
24
|
+
return [...tableData].sort((a, b) => {
|
|
25
|
+
const colIndex = tableHeaders.indexOf(column);
|
|
26
|
+
const valueA = a[colIndex];
|
|
27
|
+
const valueB = b[colIndex];
|
|
28
|
+
|
|
29
|
+
if (typeof valueA === 'number' && typeof valueB === 'number') {
|
|
30
|
+
return order === 'asc' ? valueA - valueB : valueB - valueA;
|
|
31
|
+
} else if (typeof valueA === 'string' && typeof valueB === 'string') {
|
|
32
|
+
return order === 'asc' ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA);
|
|
33
|
+
} else if (typeof valueA === 'boolean' && typeof valueB === 'boolean') {
|
|
34
|
+
return order === 'asc'
|
|
35
|
+
? valueA === valueB
|
|
36
|
+
? 0
|
|
37
|
+
: valueA
|
|
38
|
+
? -1
|
|
39
|
+
: 1
|
|
40
|
+
: valueA === valueB
|
|
41
|
+
? 0
|
|
42
|
+
: valueA
|
|
43
|
+
? 1
|
|
44
|
+
: -1;
|
|
45
|
+
} else {
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
30
49
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
50
|
+
|
|
51
|
+
function sortTableData(column: string) {
|
|
52
|
+
if (!sortOrders[column]) {
|
|
53
|
+
sortOrders[column] = 'asc';
|
|
54
|
+
} else {
|
|
55
|
+
sortOrders[column] = sortOrders[column] === 'asc' ? 'desc' : 'asc';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function handleKeydown(event: KeyboardEvent, header: string) {
|
|
60
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
sortTableData(header);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
36
65
|
</script>
|
|
37
66
|
|
|
38
|
-
{#if
|
|
67
|
+
{#if tableTitle}
|
|
39
68
|
<div class="table-title">
|
|
40
|
-
{
|
|
69
|
+
{tableTitle}
|
|
41
70
|
</div>
|
|
42
71
|
{/if}
|
|
43
|
-
{#if
|
|
44
|
-
<div
|
|
45
|
-
class="table-container {properties.isTableScrollable ? 'scrollable-table' : ' '}"
|
|
46
|
-
role="grid"
|
|
47
|
-
>
|
|
72
|
+
{#if tableHeaders.length !== 0 || tableData.length !== 0}
|
|
73
|
+
<div class="table-container {isTableScrollable ? 'scrollable-table' : ' '}" role="grid">
|
|
48
74
|
<table>
|
|
49
75
|
<thead>
|
|
50
76
|
<tr>
|
|
51
|
-
{#each
|
|
52
|
-
<th class="table-header {
|
|
77
|
+
{#each tableHeaders as header}
|
|
78
|
+
<th class="table-header {isTableScrollable ? 'table-header-sticky' : ' '}">
|
|
53
79
|
{header}
|
|
54
80
|
{#if sortOrders[header] === 'asc'}
|
|
55
81
|
<span
|
|
56
82
|
class="sort-arrow"
|
|
57
|
-
|
|
58
|
-
|
|
83
|
+
onclick={() => sortTableData(header)}
|
|
84
|
+
onkeydown={(e) => handleKeydown(e, header)}
|
|
59
85
|
role="button"
|
|
60
86
|
tabindex="0">▼</span
|
|
61
87
|
>
|
|
62
88
|
{:else}
|
|
63
89
|
<span
|
|
64
90
|
class="sort-arrow"
|
|
65
|
-
|
|
66
|
-
|
|
91
|
+
onclick={() => sortTableData(header)}
|
|
92
|
+
onkeydown={(e) => handleKeydown(e, header)}
|
|
67
93
|
role="button"
|
|
68
94
|
tabindex="0">▲</span
|
|
69
95
|
>
|
|
@@ -77,7 +103,7 @@ onMount(() => {
|
|
|
77
103
|
<tr>
|
|
78
104
|
{#each row as cell}
|
|
79
105
|
<td class="table-content">
|
|
80
|
-
<div class={
|
|
106
|
+
<div class={isContentScrollable ? 'scrollable-content' : ' '}>
|
|
81
107
|
{cell}
|
|
82
108
|
</div>
|
|
83
109
|
</td>
|
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { TableProperties } from './properties';
|
|
3
|
-
declare const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
events: {
|
|
8
|
-
keydown: KeyboardEvent;
|
|
9
|
-
} & {
|
|
10
|
-
[evt: string]: CustomEvent<any>;
|
|
11
|
-
};
|
|
12
|
-
slots: {};
|
|
13
|
-
exports?: {} | undefined;
|
|
14
|
-
bindings?: string | undefined;
|
|
15
|
-
};
|
|
16
|
-
export type TableProps = typeof __propDef.props;
|
|
17
|
-
export type TableEvents = typeof __propDef.events;
|
|
18
|
-
export type TableSlots = typeof __propDef.slots;
|
|
19
|
-
export default class Table extends SvelteComponent<TableProps, TableEvents, TableSlots> {
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
2
|
+
declare const Table: import("svelte").Component<TableProperties, {}, "">;
|
|
3
|
+
type Table = ReturnType<typeof Table>;
|
|
4
|
+
export default Table;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { JSONValue } from 'type-decoder';
|
|
2
2
|
export type TableProperties = {
|
|
3
|
-
tableTitle
|
|
4
|
-
tableHeaders
|
|
5
|
-
tableData
|
|
6
|
-
isTableScrollable
|
|
7
|
-
isContentScrollable
|
|
3
|
+
tableTitle?: string | null;
|
|
4
|
+
tableHeaders?: string[];
|
|
5
|
+
tableData?: Array<JSONValue[]>;
|
|
6
|
+
isTableScrollable?: boolean;
|
|
7
|
+
isContentScrollable?: boolean;
|
|
8
8
|
};
|
package/dist/Toast/Toast.svelte
CHANGED
|
@@ -1,96 +1,171 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import { fly } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { fly } from 'svelte/transition';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import type { ToastDirection } from './properties';
|
|
5
|
+
import type { FlyAnimationConfig } from '../types';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
duration = 2000,
|
|
9
|
+
leftIcon,
|
|
10
|
+
message = '',
|
|
11
|
+
subtext,
|
|
12
|
+
rightIcon,
|
|
13
|
+
type,
|
|
14
|
+
direction,
|
|
15
|
+
overlapPage = true,
|
|
16
|
+
inAnimationOffset,
|
|
17
|
+
inAnimationDuration,
|
|
18
|
+
outAnimationOffset,
|
|
19
|
+
outAnimationDuration,
|
|
20
|
+
testId,
|
|
21
|
+
messageTestId,
|
|
22
|
+
subTextTestId,
|
|
23
|
+
closeIconTestId,
|
|
24
|
+
onToastHide,
|
|
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();
|
|
46
|
+
|
|
47
|
+
const animationConfig: FlyAnimationConfig = getAnimationConfig(direction, overlapPage);
|
|
48
|
+
|
|
49
|
+
let showToast = $state(false);
|
|
50
|
+
let timeoutId = $state<ReturnType<typeof setTimeout> | null>(null);
|
|
51
|
+
|
|
52
|
+
function hideToast() {
|
|
53
|
+
showToast = false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function handleAnimationEnd() {
|
|
57
|
+
onToastHide?.();
|
|
41
58
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Function to generate animation configuration for toast animations.
|
|
62
|
+
* @param {ToastDirection | null} toastDirection - Direction of the toast animation.
|
|
63
|
+
* @param {boolean} overlapPage - Flag indicating whether toast should overlap page content.
|
|
64
|
+
* @returns {FlyAnimationConfig} Animation configuration object.
|
|
65
|
+
*/
|
|
66
|
+
function getAnimationConfig(
|
|
67
|
+
toastDirection: ToastDirection | undefined = undefined,
|
|
68
|
+
overlapPage: boolean
|
|
69
|
+
): FlyAnimationConfig {
|
|
70
|
+
// Initializing variables to store animation offsets
|
|
71
|
+
let inX: number = 0;
|
|
72
|
+
let inY: number = 0;
|
|
73
|
+
let outX: number = 0;
|
|
74
|
+
let outY: number = 0;
|
|
75
|
+
|
|
76
|
+
// Determining animation offsets based on toast direction
|
|
77
|
+
// Multiplying by -1 effectively flips the direction of movement along the specified axis, ensuring that the toast animation moves in the intended direction based on the chosen toast direction.
|
|
78
|
+
switch (toastDirection) {
|
|
79
|
+
case 'left-to-right':
|
|
80
|
+
// Calculating horizontal offsets for left-to-right animation
|
|
81
|
+
inX = -1 * (inAnimationOffset ?? 500);
|
|
82
|
+
outX = -1 * (outAnimationOffset ?? 500);
|
|
83
|
+
break;
|
|
84
|
+
case 'right-to-left':
|
|
85
|
+
// Calculating horizontal offsets for right-to-left animation
|
|
86
|
+
inX = inAnimationOffset ?? 500;
|
|
87
|
+
outX = outAnimationOffset ?? 500;
|
|
88
|
+
break;
|
|
89
|
+
case 'bottom-to-top':
|
|
90
|
+
// Calculating vertical offsets for bottom-to-top animation
|
|
91
|
+
inY = inAnimationOffset ?? (overlapPage ? 500 : 20);
|
|
92
|
+
outY = outAnimationOffset ?? (overlapPage ? 500 : 20);
|
|
93
|
+
break;
|
|
94
|
+
case 'top-to-bottom':
|
|
95
|
+
default:
|
|
96
|
+
// Calculating vertical offsets for top-to-bottom animation
|
|
97
|
+
inY = -1 * (inAnimationOffset ?? (overlapPage ? 500 : 20));
|
|
98
|
+
outY = -1 * (outAnimationOffset ?? (overlapPage ? 100 : 20));
|
|
99
|
+
break;
|
|
52
100
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
101
|
+
// Returning animation configuration object
|
|
102
|
+
return {
|
|
103
|
+
in: {
|
|
104
|
+
x: inX,
|
|
105
|
+
y: inY,
|
|
106
|
+
duration: inAnimationDuration ?? 400
|
|
107
|
+
},
|
|
108
|
+
out: {
|
|
109
|
+
x: outX,
|
|
110
|
+
y: outY,
|
|
111
|
+
duration: outAnimationDuration ?? 800
|
|
112
|
+
}
|
|
113
|
+
};
|
|
62
114
|
}
|
|
63
|
-
|
|
115
|
+
|
|
116
|
+
$effect(() => {
|
|
117
|
+
showToast = true;
|
|
118
|
+
timeoutId = setTimeout(hideToast, 200);
|
|
119
|
+
|
|
120
|
+
return () => {
|
|
121
|
+
if (timeoutId !== null) {
|
|
122
|
+
clearTimeout(timeoutId);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
});
|
|
64
126
|
</script>
|
|
65
127
|
|
|
66
128
|
{#if showToast}
|
|
67
129
|
<div
|
|
68
|
-
class="toast {
|
|
69
|
-
class:no-page-overlap={!
|
|
130
|
+
class="toast {type ?? ''}"
|
|
131
|
+
class:no-page-overlap={!overlapPage}
|
|
70
132
|
in:fly={animationConfig.in}
|
|
71
133
|
out:fly={animationConfig.out}
|
|
72
|
-
|
|
134
|
+
onoutroend={handleAnimationEnd}
|
|
135
|
+
data-pw={testId}
|
|
73
136
|
>
|
|
74
|
-
{#if
|
|
137
|
+
{#if leftIcon}
|
|
75
138
|
<div class="toast-icon-wrapper">
|
|
76
|
-
<img class="toast-icon" src={
|
|
139
|
+
<img class="toast-icon" src={leftIcon} alt="toast-icon" />
|
|
77
140
|
</div>
|
|
78
141
|
{/if}
|
|
79
142
|
|
|
80
|
-
<div class="toast-message" data-pw={
|
|
81
|
-
{
|
|
82
|
-
{#if
|
|
83
|
-
<div class="toast-subtext" data-pw={
|
|
143
|
+
<div class="toast-message" data-pw={messageTestId}>
|
|
144
|
+
{message}
|
|
145
|
+
{#if subtext}
|
|
146
|
+
<div class="toast-subtext" data-pw={subTextTestId}>{subtext}</div>
|
|
84
147
|
{/if}
|
|
85
148
|
|
|
86
|
-
{#if
|
|
87
|
-
|
|
149
|
+
{#if bottomContent}
|
|
150
|
+
{@render bottomContent()}
|
|
88
151
|
{/if}
|
|
89
152
|
</div>
|
|
90
153
|
|
|
91
|
-
{#if
|
|
92
|
-
<div
|
|
93
|
-
|
|
154
|
+
{#if rightIcon}
|
|
155
|
+
<div
|
|
156
|
+
class="close-button"
|
|
157
|
+
tabindex="0"
|
|
158
|
+
role="button"
|
|
159
|
+
onclick={hideToast}
|
|
160
|
+
onkeypress={(e) => {
|
|
161
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
162
|
+
e.preventDefault();
|
|
163
|
+
hideToast();
|
|
164
|
+
}
|
|
165
|
+
}}
|
|
166
|
+
data-pw={closeIconTestId}
|
|
167
|
+
>
|
|
168
|
+
<img class="toast-icon" src={rightIcon} alt="close-icon" />
|
|
94
169
|
</div>
|
|
95
170
|
{/if}
|
|
96
171
|
</div>
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { ToastDirection } from './properties';
|
|
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;
|
|
18
22
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export
|
|
22
|
-
export default class Toast extends SvelteComponent<ToastProps, ToastEvents, ToastSlots> {
|
|
23
|
-
}
|
|
24
|
-
export {};
|
|
23
|
+
declare const Toast: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
24
|
+
type Toast = ReturnType<typeof Toast>;
|
|
25
|
+
export default Toast;
|
|
@@ -2,20 +2,19 @@ export type ToastType = 'success' | 'error' | 'info' | 'warn';
|
|
|
2
2
|
export type ToastDirection = 'left-to-right' | 'right-to-left' | 'top-to-bottom' | 'bottom-to-top';
|
|
3
3
|
export type ToastProperties = {
|
|
4
4
|
duration: number;
|
|
5
|
-
leftIcon?: string;
|
|
5
|
+
leftIcon?: string | null;
|
|
6
6
|
message: string;
|
|
7
|
-
subtext?: string;
|
|
8
|
-
rightIcon?: string;
|
|
9
|
-
type?: ToastType;
|
|
10
|
-
direction?: ToastDirection;
|
|
7
|
+
subtext?: string | null;
|
|
8
|
+
rightIcon?: string | null;
|
|
9
|
+
type?: ToastType | null;
|
|
10
|
+
direction?: ToastDirection | null;
|
|
11
11
|
overlapPage?: boolean;
|
|
12
|
-
inAnimationOffset?: number;
|
|
13
|
-
inAnimationDuration?: number;
|
|
14
|
-
outAnimationOffset?: number;
|
|
15
|
-
outAnimationDuration?: number;
|
|
16
|
-
testId?: string;
|
|
12
|
+
inAnimationOffset?: number | null;
|
|
13
|
+
inAnimationDuration?: number | null;
|
|
14
|
+
outAnimationOffset?: number | null;
|
|
15
|
+
outAnimationDuration?: number | null;
|
|
16
|
+
testId?: string | null;
|
|
17
17
|
messageTestId?: string;
|
|
18
18
|
subTextTestId?: string;
|
|
19
19
|
closeIconTestId?: string;
|
|
20
20
|
};
|
|
21
|
-
export declare const defaultToastProperties: ToastProperties;
|
package/dist/Toast/properties.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ToggleProperties } from './properties';
|
|
3
|
+
|
|
4
|
+
let { checked = false, text = '', onclick }: ToggleProperties = $props();
|
|
5
|
+
|
|
6
|
+
function handleCheckboxClick(e: MouseEvent): void {
|
|
7
|
+
if (e.target instanceof HTMLInputElement && typeof e.target.checked === 'boolean') {
|
|
8
|
+
checked = e.target.checked;
|
|
9
|
+
}
|
|
10
|
+
onclick?.(checked);
|
|
8
11
|
}
|
|
9
|
-
dispatch("click", checked);
|
|
10
|
-
}
|
|
11
12
|
</script>
|
|
12
13
|
|
|
13
14
|
<div class="container">
|
|
14
15
|
<div class="text" hidden={text.length === 0}>{text}</div>
|
|
15
16
|
<label class="switch">
|
|
16
|
-
<input class="input-checkbox" type="checkbox"
|
|
17
|
-
<span class="slider round"
|
|
17
|
+
<input class="input-checkbox" type="checkbox" {checked} onclick={handleCheckboxClick} />
|
|
18
|
+
<span class="slider round"></span>
|
|
18
19
|
</label>
|
|
19
20
|
</div>
|
|
20
21
|
|
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
text?: string;
|
|
6
|
-
};
|
|
7
|
-
events: {
|
|
8
|
-
click: CustomEvent<any>;
|
|
9
|
-
} & {
|
|
10
|
-
[evt: string]: CustomEvent<any>;
|
|
11
|
-
};
|
|
12
|
-
slots: {};
|
|
13
|
-
exports?: {} | undefined;
|
|
14
|
-
bindings?: string | undefined;
|
|
15
|
-
};
|
|
16
|
-
export type ToggleProps = typeof __propDef.props;
|
|
17
|
-
export type ToggleEvents = typeof __propDef.events;
|
|
18
|
-
export type ToggleSlots = typeof __propDef.slots;
|
|
19
|
-
export default class Toggle extends SvelteComponent<ToggleProps, ToggleEvents, ToggleSlots> {
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
1
|
+
import type { ToggleProperties } from './properties';
|
|
2
|
+
declare const Toggle: import("svelte").Component<ToggleProperties, {}, "">;
|
|
3
|
+
type Toggle = ReturnType<typeof Toggle>;
|
|
4
|
+
export default Toggle;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|