@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.
Files changed (90) hide show
  1. package/dist/Accordion/Accordion.svelte +17 -30
  2. package/dist/Accordion/Accordion.svelte.d.ts +6 -20
  3. package/dist/Animations/ModalAnimation.svelte +44 -30
  4. package/dist/Animations/ModalAnimation.svelte.d.ts +9 -21
  5. package/dist/Animations/OverlayAnimation.svelte +9 -2
  6. package/dist/Animations/OverlayAnimation.svelte.d.ts +6 -28
  7. package/dist/Badge/Badge.svelte +9 -8
  8. package/dist/Badge/Badge.svelte.d.ts +3 -18
  9. package/dist/Banner/Banner.svelte +20 -19
  10. package/dist/Banner/Banner.svelte.d.ts +3 -23
  11. package/dist/Banner/properties.d.ts +6 -2
  12. package/dist/BrandLoader/BrandLoader.svelte +33 -34
  13. package/dist/BrandLoader/BrandLoader.svelte.d.ts +3 -19
  14. package/dist/BrandLoader/properties.d.ts +1 -4
  15. package/dist/BrandLoader/properties.js +1 -7
  16. package/dist/Button/Button.svelte +38 -27
  17. package/dist/Button/Button.svelte.d.ts +4 -23
  18. package/dist/Button/properties.d.ts +9 -5
  19. package/dist/Button/properties.js +1 -7
  20. package/dist/Carousel/Carousel.svelte +132 -108
  21. package/dist/Carousel/Carousel.svelte.d.ts +3 -20
  22. package/dist/Carousel/properties.d.ts +6 -12
  23. package/dist/Carousel/properties.js +1 -7
  24. package/dist/CheckListItem/CheckListItem.svelte +19 -13
  25. package/dist/CheckListItem/CheckListItem.svelte.d.ts +4 -23
  26. package/dist/CheckListItem/properties.d.ts +7 -0
  27. package/dist/CheckListItem/properties.js +1 -0
  28. package/dist/GridItem/GridItem.svelte +17 -11
  29. package/dist/GridItem/GridItem.svelte.d.ts +4 -24
  30. package/dist/GridItem/properties.d.ts +8 -0
  31. package/dist/GridItem/properties.js +1 -0
  32. package/dist/Icon/Icon.svelte +8 -6
  33. package/dist/Icon/Icon.svelte.d.ts +3 -21
  34. package/dist/Icon/properties.d.ts +3 -2
  35. package/dist/Icon/properties.js +1 -4
  36. package/dist/IconStack/IconStack.svelte +5 -3
  37. package/dist/IconStack/IconStack.svelte.d.ts +4 -19
  38. package/dist/IconStack/properties.d.ts +5 -2
  39. package/dist/Img/Img.svelte +13 -9
  40. package/dist/Img/Img.svelte.d.ts +4 -20
  41. package/dist/Img/properties.d.ts +2 -2
  42. package/dist/Input/Input.svelte +172 -139
  43. package/dist/Input/Input.svelte.d.ts +6 -32
  44. package/dist/Input/properties.d.ts +23 -22
  45. package/dist/Input/properties.js +1 -23
  46. package/dist/InputButton/InputButton.svelte +76 -78
  47. package/dist/InputButton/InputButton.svelte.d.ts +6 -35
  48. package/dist/InputButton/properties.d.ts +6 -4
  49. package/dist/InputButton/properties.js +1 -18
  50. package/dist/ListItem/ListItem.svelte +87 -64
  51. package/dist/ListItem/ListItem.svelte.d.ts +4 -35
  52. package/dist/ListItem/properties.d.ts +21 -7
  53. package/dist/ListItem/properties.js +1 -8
  54. package/dist/Loader/Loader.svelte +1 -4
  55. package/dist/Loader/Loader.svelte.d.ts +24 -15
  56. package/dist/Modal/Modal.svelte +121 -93
  57. package/dist/Modal/Modal.svelte.d.ts +3 -29
  58. package/dist/Modal/properties.d.ts +21 -13
  59. package/dist/Modal/properties.js +1 -14
  60. package/dist/Select/Select.svelte +170 -142
  61. package/dist/Select/Select.svelte.d.ts +3 -26
  62. package/dist/Select/properties.d.ts +19 -10
  63. package/dist/Status/Status.svelte +15 -15
  64. package/dist/Status/Status.svelte.d.ts +3 -21
  65. package/dist/Status/properties.d.ts +2 -2
  66. package/dist/Status/properties.js +1 -6
  67. package/dist/Stepper/Step.svelte +13 -13
  68. package/dist/Stepper/Step.svelte.d.ts +4 -23
  69. package/dist/Stepper/Stepper.svelte +10 -7
  70. package/dist/Stepper/Stepper.svelte.d.ts +3 -20
  71. package/dist/Stepper/properties.d.ts +12 -0
  72. package/dist/Table/Table.svelte +73 -47
  73. package/dist/Table/Table.svelte.d.ts +3 -20
  74. package/dist/Table/properties.d.ts +5 -5
  75. package/dist/Toast/Toast.svelte +149 -74
  76. package/dist/Toast/Toast.svelte.d.ts +24 -23
  77. package/dist/Toast/properties.d.ts +10 -11
  78. package/dist/Toast/properties.js +1 -4
  79. package/dist/Toggle/Toggle.svelte +12 -11
  80. package/dist/Toggle/Toggle.svelte.d.ts +4 -21
  81. package/dist/Toggle/properties.d.ts +5 -0
  82. package/dist/Toggle/properties.js +1 -0
  83. package/dist/Toolbar/Toolbar.svelte +27 -20
  84. package/dist/Toolbar/Toolbar.svelte.d.ts +3 -26
  85. package/dist/Toolbar/properties.d.ts +10 -4
  86. package/dist/Toolbar/properties.js +1 -5
  87. package/dist/index.d.ts +0 -11
  88. package/dist/index.js +0 -11
  89. package/dist/utils.d.ts +1 -1
  90. package/package.json +29 -28
@@ -1,21 +1,4 @@
1
- import { SvelteComponent } from "svelte";
2
1
  import type { StepperProperties } from './properties';
3
- declare const __propDef: {
4
- props: {
5
- properties: StepperProperties;
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
+ };
@@ -1,69 +1,95 @@
1
- <script>import { onMount } from "svelte";
2
- export let properties = {
3
- tableTitle: "",
4
- tableHeaders: [],
5
- tableData: [],
6
- isTableScrollable: false,
7
- isContentScrollable: false
8
- };
9
- let sortOrders = {};
10
- let sortedTableData = [...properties.tableData];
11
- function sortTableData(column) {
12
- if (!sortOrders[column]) {
13
- sortOrders[column] = "asc";
14
- } else {
15
- sortOrders[column] = sortOrders[column] === "asc" ? "desc" : "asc";
16
- }
17
- sortedTableData = [...properties.tableData].sort((a, b) => {
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
- return 0;
32
- }
33
- onMount(() => {
34
- sortedTableData = [...properties.tableData];
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 properties && properties.tableTitle}
67
+ {#if tableTitle}
39
68
  <div class="table-title">
40
- {properties.tableTitle}
69
+ {tableTitle}
41
70
  </div>
42
71
  {/if}
43
- {#if properties.tableHeaders.length !== 0 || properties.tableData.length !== 0}
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 properties.tableHeaders as header}
52
- <th class="table-header {properties.isTableScrollable ? 'table-header-sticky' : ' '}">
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
- on:click={() => sortTableData(header)}
58
- on:keydown
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
- on:click={() => sortTableData(header)}
66
- on:keydown
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={properties.isContentScrollable ? 'scrollable-content' : ' '}>
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 __propDef: {
4
- props: {
5
- properties?: TableProperties;
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: string | null;
4
- tableHeaders: string[];
5
- tableData: Array<JSONValue[]>;
6
- isTableScrollable: boolean;
7
- isContentScrollable: boolean;
3
+ tableTitle?: string | null;
4
+ tableHeaders?: string[];
5
+ tableData?: Array<JSONValue[]>;
6
+ isTableScrollable?: boolean;
7
+ isContentScrollable?: boolean;
8
8
  };
@@ -1,96 +1,171 @@
1
- <script>import { createEventDispatcher, onDestroy, onMount } from "svelte";
2
- import { fly } from "svelte/transition";
3
- import { defaultToastProperties } from "./properties";
4
- export let properties = defaultToastProperties;
5
- const dispatch = createEventDispatcher();
6
- const animationConfig = getAnimationConfig(
7
- properties.direction,
8
- properties.overlapPage ?? true
9
- );
10
- let showToast = false;
11
- let timeoutId = null;
12
- function hideToast() {
13
- showToast = false;
14
- }
15
- function handleAnimationEnd() {
16
- dispatch("onToastHide");
17
- }
18
- function getAnimationConfig(toastDirection = null, overlapPage) {
19
- let inX = 0;
20
- let inY = 0;
21
- let outX = 0;
22
- let outY = 0;
23
- switch (toastDirection) {
24
- case "left-to-right":
25
- inX = -1 * (properties.inAnimationOffset ?? 500);
26
- outX = -1 * (properties.outAnimationOffset ?? 500);
27
- break;
28
- case "right-to-left":
29
- inX = properties.inAnimationOffset ?? 500;
30
- outX = properties.outAnimationOffset ?? 500;
31
- break;
32
- case "bottom-to-top":
33
- inY = properties.inAnimationOffset ?? (overlapPage ? 500 : 20);
34
- outY = properties.outAnimationOffset ?? (overlapPage ? 500 : 20);
35
- break;
36
- case "top-to-bottom":
37
- default:
38
- inY = -1 * (properties.inAnimationOffset ?? (overlapPage ? 500 : 20));
39
- outY = -1 * (properties.outAnimationOffset ?? (overlapPage ? 100 : 20));
40
- break;
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
- return {
43
- in: {
44
- x: inX,
45
- y: inY,
46
- duration: properties.inAnimationDuration ?? 400
47
- },
48
- out: {
49
- x: outX,
50
- y: outY,
51
- duration: properties.outAnimationDuration ?? 800
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
- onMount(() => {
56
- showToast = true;
57
- timeoutId = setTimeout(hideToast, properties.duration);
58
- });
59
- onDestroy(() => {
60
- if (timeoutId !== null) {
61
- clearTimeout(timeoutId);
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 {properties.type ?? ''}"
69
- class:no-page-overlap={!(properties?.overlapPage ?? true)}
130
+ class="toast {type ?? ''}"
131
+ class:no-page-overlap={!overlapPage}
70
132
  in:fly={animationConfig.in}
71
133
  out:fly={animationConfig.out}
72
- on:outroend={handleAnimationEnd}
134
+ onoutroend={handleAnimationEnd}
135
+ data-pw={testId}
73
136
  >
74
- {#if properties.leftIcon}
137
+ {#if leftIcon}
75
138
  <div class="toast-icon-wrapper">
76
- <img class="toast-icon" src={properties.leftIcon} alt="toast-icon" />
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={properties.messageTestId}>
81
- {properties.message}
82
- {#if properties.subtext}
83
- <div class="toast-subtext" data-pw={properties.subTextTestId}>{properties.subtext}</div>
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 $$slots.bottomContent}
87
- <slot name="bottomContent" />
149
+ {#if bottomContent}
150
+ {@render bottomContent()}
88
151
  {/if}
89
152
  </div>
90
153
 
91
- {#if properties.rightIcon}
92
- <div class="close-button" tabindex="0" role="button" on:click={hideToast} on:keypress data-pw={properties.closeIconTestId}>
93
- <img class="toast-icon" src={properties.rightIcon} alt="close-icon" />
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 { SvelteComponent } from "svelte";
2
- import { type ToastProperties } from './properties';
3
- declare const __propDef: {
4
- props: {
5
- properties?: ToastProperties;
6
- };
7
- events: {
8
- keypress: KeyboardEvent;
9
- onToastHide: CustomEvent<any>;
10
- } & {
11
- [evt: string]: CustomEvent<any>;
12
- };
13
- slots: {
14
- bottomContent: {};
15
- };
16
- exports?: {} | undefined;
17
- bindings?: string | undefined;
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
- export type ToastProps = typeof __propDef.props;
20
- export type ToastEvents = typeof __propDef.events;
21
- export type ToastSlots = typeof __propDef.slots;
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;
@@ -1,4 +1 @@
1
- export const defaultToastProperties = {
2
- duration: 2000,
3
- message: ''
4
- };
1
+ export {};
@@ -1,20 +1,21 @@
1
- <script>import { createEventDispatcher } from "svelte";
2
- export let checked = false;
3
- export let text = "";
4
- const dispatch = createEventDispatcher();
5
- function handleCheckboxClick(e) {
6
- if (e.target instanceof HTMLInputElement && typeof e.target.checked === "boolean") {
7
- checked = e.target.checked;
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" bind:checked={checked} on:click={handleCheckboxClick} />
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 { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- checked?: boolean;
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,5 @@
1
+ export type ToggleProperties = {
2
+ checked?: boolean;
3
+ text: string;
4
+ onclick?: (checked: boolean) => void;
5
+ };
@@ -0,0 +1 @@
1
+ export {};