@rkosafo/cai.components 0.0.74 → 0.0.78

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 (127) hide show
  1. package/README.md +8 -8
  2. package/dist/baseEditor/index.svelte +32 -32
  3. package/dist/builders/filters/FilterBuilder.svelte +641 -641
  4. package/dist/forms/FormCheckbox/FormCheckbox.svelte +53 -53
  5. package/dist/forms/FormClEditor/ClEdito.svelte +68 -68
  6. package/dist/forms/FormDatepicker/FormDatepicker.svelte +159 -159
  7. package/dist/forms/FormFileUpload/FormFileUplad.svelte +134 -134
  8. package/dist/forms/FormInput/FormInput.svelte +87 -87
  9. package/dist/forms/FormRadio/FormRadio.svelte +53 -53
  10. package/dist/forms/FormSelect/FormSelect.svelte +88 -88
  11. package/dist/forms/FormTextarea/FormTextarea.svelte +78 -78
  12. package/dist/forms/button-toggle/ButtonToggle.svelte +119 -0
  13. package/dist/forms/button-toggle/ButtonToggle.svelte.d.ts +139 -0
  14. package/dist/forms/button-toggle/ButtonToggleGroup.svelte +0 -0
  15. package/dist/forms/button-toggle/ButtonToggleGroup.svelte.d.ts +26 -0
  16. package/dist/forms/button-toggle/CheckIcon.svelte +28 -0
  17. package/dist/forms/button-toggle/CheckIcon.svelte.d.ts +4 -0
  18. package/dist/forms/button-toggle/index.d.ts +4 -0
  19. package/dist/forms/button-toggle/index.js +4 -0
  20. package/dist/forms/button-toggle/theme.d.ts +347 -0
  21. package/dist/forms/button-toggle/theme.js +129 -0
  22. package/dist/forms/checkbox/Checkbox.svelte +82 -82
  23. package/dist/forms/checkbox/CheckboxButton.svelte +92 -92
  24. package/dist/forms/datepicker/Datepicker.svelte +707 -707
  25. package/dist/forms/form/Form.svelte +69 -69
  26. package/dist/forms/input/Input.svelte +363 -363
  27. package/dist/forms/label/Label.svelte +38 -38
  28. package/dist/forms/radio/Radio.svelte +48 -48
  29. package/dist/forms/radio/RadioButton.svelte +22 -22
  30. package/dist/forms/select/Select.svelte +56 -56
  31. package/dist/forms/textarea/Textarea.svelte +165 -165
  32. package/dist/forms/toggle/Toggle.svelte +70 -0
  33. package/dist/forms/toggle/Toggle.svelte.d.ts +3 -0
  34. package/dist/forms/toggle/index.d.ts +2 -0
  35. package/dist/forms/toggle/index.js +2 -0
  36. package/dist/forms/toggle/theme.d.ts +280 -0
  37. package/dist/forms/toggle/theme.js +97 -0
  38. package/dist/index.d.ts +3 -0
  39. package/dist/index.js +3 -0
  40. package/dist/layout/Chat/CategorySelector.svelte +52 -52
  41. package/dist/layout/Chat/ChatEntry.svelte +246 -246
  42. package/dist/layout/Chat/ChatEntrySkeleton.svelte +81 -81
  43. package/dist/layout/Chat/ChatHeader.svelte +172 -172
  44. package/dist/layout/Chat/ChatInput.svelte +207 -207
  45. package/dist/layout/Chat/DraggableWindow.svelte +230 -230
  46. package/dist/layout/Chat/PreviewPage.svelte +182 -182
  47. package/dist/layout/Chat/RichText.svelte +216 -216
  48. package/dist/layout/ComponentCanvas/Canvas.svelte +40 -40
  49. package/dist/layout/ComponentCanvas/ComponentRenderer.svelte +85 -85
  50. package/dist/layout/TF/Content/Content.svelte +21 -21
  51. package/dist/layout/TF/Header/Header.svelte +166 -166
  52. package/dist/layout/TF/Sidebar/Sidebar.svelte +148 -148
  53. package/dist/layout/TF/Wrapper/Wrapper.svelte +17 -17
  54. package/dist/layout/mailing/MailPaginator.svelte +36 -36
  55. package/dist/layout/mailing/MailSidebar.svelte +39 -39
  56. package/dist/layout/mailing/MailToolBar.svelte +174 -174
  57. package/dist/layout/mailing/MailingContent.svelte +10 -10
  58. package/dist/layout/mailing/MailingHeader.svelte +55 -55
  59. package/dist/layout/mailing/MailingMessageCard.svelte +112 -112
  60. package/dist/layout/mailing/MailingMessageViewer.svelte +87 -87
  61. package/dist/layout/mailing/MailingModule.svelte +448 -448
  62. package/dist/styles/docs.css +615 -615
  63. package/dist/styles/tf-layout.css +185 -185
  64. package/dist/themes/ThemeProvider.svelte +20 -20
  65. package/dist/themes/themes.d.ts +3 -0
  66. package/dist/themes/themes.js +3 -0
  67. package/dist/types/index.d.ts +59 -2
  68. package/dist/typography/heading/Heading.svelte +35 -35
  69. package/dist/ui/accordion/Accordion.svelte +49 -49
  70. package/dist/ui/accordion/AccordionItem.svelte +173 -173
  71. package/dist/ui/alert/Alert.svelte +83 -83
  72. package/dist/ui/alertDialog/AlertDialog.svelte +40 -40
  73. package/dist/ui/avatar/Avatar.svelte +77 -77
  74. package/dist/ui/box/Box.svelte +28 -28
  75. package/dist/ui/breadcrumb/Breadcrumb.svelte +39 -28
  76. package/dist/ui/buttons/ActionButton.svelte +234 -234
  77. package/dist/ui/buttons/Button.svelte +102 -102
  78. package/dist/ui/buttons/GradientButton.svelte +59 -59
  79. package/dist/ui/datatable/Datatable.svelte +525 -525
  80. package/dist/ui/drawer/Drawer.svelte +300 -300
  81. package/dist/ui/dropdown/Dropdown.svelte +36 -36
  82. package/dist/ui/dropdown/DropdownDivider.svelte +11 -11
  83. package/dist/ui/dropdown/DropdownGroup.svelte +14 -14
  84. package/dist/ui/dropdown/DropdownHeader.svelte +14 -14
  85. package/dist/ui/dropdown/DropdownItem.svelte +52 -52
  86. package/dist/ui/footer/Footer.svelte +15 -15
  87. package/dist/ui/footer/FooterBrand.svelte +37 -37
  88. package/dist/ui/footer/FooterCopyright.svelte +45 -45
  89. package/dist/ui/footer/FooterIcon.svelte +22 -22
  90. package/dist/ui/footer/FooterLink.svelte +33 -33
  91. package/dist/ui/footer/FooterLinkGroup.svelte +13 -13
  92. package/dist/ui/icons/IconifyIcon.svelte +7 -7
  93. package/dist/ui/indicator/Indicator.svelte +42 -42
  94. package/dist/ui/modal/Modal.svelte +265 -265
  95. package/dist/ui/modal/theme.d.ts +26 -26
  96. package/dist/ui/modal/theme.js +25 -25
  97. package/dist/ui/notificationList/NotificationList.svelte +123 -123
  98. package/dist/ui/pageLoader/PageLoader.svelte +14 -14
  99. package/dist/ui/paginate/Paginate.svelte +96 -96
  100. package/dist/ui/speedDial/SpeedDial.svelte +77 -0
  101. package/dist/ui/speedDial/SpeedDial.svelte.d.ts +21 -0
  102. package/dist/ui/speedDial/SpeedDialButton.svelte +75 -0
  103. package/dist/ui/speedDial/SpeedDialButton.svelte.d.ts +20 -0
  104. package/dist/ui/speedDial/SpeedDialTrigger.svelte +79 -0
  105. package/dist/ui/speedDial/SpeedDialTrigger.svelte.d.ts +18 -0
  106. package/dist/ui/speedDial/index.d.ts +4 -0
  107. package/dist/ui/speedDial/index.js +4 -0
  108. package/dist/ui/speedDial/theme.d.ts +75 -0
  109. package/dist/ui/speedDial/theme.js +35 -0
  110. package/dist/ui/tab/Tab.svelte +67 -67
  111. package/dist/ui/table/Table.svelte +396 -394
  112. package/dist/ui/tableLoader/TableLoader.svelte +24 -24
  113. package/dist/ui/toast/Toast.svelte +337 -337
  114. package/dist/ui/toast/Toast.svelte.d.ts +10 -10
  115. package/dist/ui/toast/index.d.ts +1 -2
  116. package/dist/ui/toast/index.js +3 -1
  117. package/dist/ui/toolbar/Toolbar.svelte +59 -59
  118. package/dist/ui/toolbar/ToolbarButton.svelte +56 -56
  119. package/dist/ui/toolbar/ToolbarGroup.svelte +43 -43
  120. package/dist/ui/tooltip/Tooltip.svelte +51 -51
  121. package/dist/utils/Popper.svelte +257 -257
  122. package/dist/utils/closeButton/CloseButton.svelte +88 -88
  123. package/dist/utils/index.d.ts +3 -2
  124. package/dist/utils/index.js +13 -3
  125. package/dist/utils/singleSelection.svelte.js +48 -48
  126. package/dist/youtube/index.svelte +12 -12
  127. package/package.json +2 -1
@@ -1,337 +1,337 @@
1
- <script lang="ts" module>
2
- export type ToastType = 'success' | 'error' | 'warning' | 'info' | 'loading' | 'custom';
3
- export type ToastPosition =
4
- | 'top-left'
5
- | 'top-center'
6
- | 'top-right'
7
- | 'bottom-left'
8
- | 'bottom-center'
9
- | 'bottom-right';
10
-
11
- export interface CustomToastOptions extends ToastOptions {
12
- icon?: string;
13
- showProgress?: boolean;
14
- progressColor?: string;
15
- borderColor?: string;
16
- backgroundColor?: string;
17
- textColor?: string;
18
- iconColor?: string;
19
- style?: any;
20
- action?: {
21
- label: string | boolean;
22
- onClick: () => void;
23
- buttonStyle?: string;
24
- };
25
- }
26
-
27
- export interface ToastTheme {
28
- success?: Partial<CustomToastOptions>;
29
- error?: Partial<CustomToastOptions>;
30
- warning?: Partial<CustomToastOptions>;
31
- info?: Partial<CustomToastOptions>;
32
- loading?: Partial<CustomToastOptions>;
33
- custom?: Partial<CustomToastOptions>;
34
- }
35
-
36
- export interface ToasterProps {
37
- position?: ToastPosition;
38
- duration?: number;
39
- theme?: ToastTheme;
40
- className?: string;
41
- toastOptions?: ToastOptions;
42
- richColors?: boolean;
43
- customIcons?: boolean;
44
- closeButton?: boolean;
45
- pauseOnHover?: boolean;
46
- reverseOrder?: boolean;
47
- visibleToasts?: number;
48
- expand?: boolean;
49
- gap?: number;
50
- offset?: number | string;
51
- }
52
- // Default theme configuration
53
- const defaultTheme: ToastTheme = {
54
- success: {
55
- icon: '✅',
56
- borderColor: '#22c55e',
57
- backgroundColor: '#f0fdf4',
58
- textColor: '#166534',
59
- iconColor: '#16a34a',
60
- progressColor: '#22c55e'
61
- },
62
- error: {
63
- icon: '❌',
64
- borderColor: '#ef4444',
65
- backgroundColor: '#fef2f2',
66
- textColor: '#991b1b',
67
- iconColor: '#dc2626',
68
- progressColor: '#ef4444'
69
- },
70
- warning: {
71
- icon: '⚠️',
72
- borderColor: '#f59e0b',
73
- backgroundColor: '#fffbeb',
74
- textColor: '#92400e',
75
- iconColor: '#d97706',
76
- progressColor: '#f59e0b'
77
- },
78
- info: {
79
- icon: 'ℹ️',
80
- borderColor: '#3b82f6',
81
- backgroundColor: '#eff6ff',
82
- textColor: '#1e40af',
83
- iconColor: '#2563eb',
84
- progressColor: '#3b82f6'
85
- },
86
- loading: {
87
- icon: '⏳',
88
- borderColor: '#6b7280',
89
- backgroundColor: '#f9fafb',
90
- textColor: '#374151',
91
- iconColor: '#6b7280',
92
- progressColor: '#6b7280'
93
- }
94
- };
95
-
96
- let currentDuration = 4000;
97
- let currentTheme: ToastTheme = {};
98
- let currentRichColors = false;
99
-
100
- function buildToastStyle(
101
- theme: Partial<CustomToastOptions>,
102
- options?: CustomToastOptions,
103
- type?: ToastType,
104
- richColors?: boolean
105
- ): string {
106
- if (options?.style) return options.style;
107
-
108
- const baseStyle = `
109
- border: 1px solid ${options?.borderColor || theme.borderColor || '#e5e7eb'};
110
- background: ${options?.backgroundColor || theme.backgroundColor || '#ffffff'};
111
- color: ${options?.textColor || theme.textColor || '#1f2937'};
112
- padding: 12px 16px;
113
- border-radius: 8px;
114
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
115
- font-size: 14px;
116
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
117
- display: flex;
118
- align-items: center;
119
- gap: 8px;
120
- `;
121
-
122
- if (richColors && type && defaultTheme[type]) {
123
- const richTheme = defaultTheme[type]!;
124
- return `
125
- ${baseStyle}
126
- border-color: ${options?.borderColor || richTheme.borderColor}!important;
127
- background: ${options?.backgroundColor || richTheme.backgroundColor}!important;
128
- color: ${options?.textColor || richTheme.textColor}!important;
129
- `;
130
- }
131
-
132
- return baseStyle;
133
- }
134
-
135
- export const toast = {
136
- success: (message: string, options?: CustomToastOptions) => {
137
- const themeOptions = currentTheme?.success || defaultTheme.success || {};
138
- const style = buildToastStyle(themeOptions, options, 'success');
139
-
140
- return originalToast.success(message, {
141
- duration: currentDuration,
142
- ...themeOptions,
143
- ...options,
144
- style,
145
- icon: options?.icon || themeOptions.icon
146
- });
147
- },
148
-
149
- error: (message: string, options?: CustomToastOptions) => {
150
- const themeOptions = currentTheme?.error || defaultTheme.error || {};
151
- const style = buildToastStyle(themeOptions, options, 'error');
152
-
153
- return originalToast.error(message, {
154
- duration: currentDuration,
155
- ...themeOptions,
156
- ...options,
157
- style,
158
- icon: options?.icon || themeOptions.icon
159
- });
160
- },
161
-
162
- warning: (message: string, options?: CustomToastOptions) => {
163
- const themeOptions = currentTheme?.warning || defaultTheme.warning || {};
164
- const style = buildToastStyle(themeOptions, options, 'warning');
165
-
166
- return originalToast(message, {
167
- duration: currentDuration,
168
- ...themeOptions,
169
- ...options,
170
- style,
171
- icon: options?.icon || themeOptions.icon
172
- });
173
- },
174
-
175
- info: (message: string, options?: CustomToastOptions) => {
176
- const themeOptions = currentTheme?.info || defaultTheme.info || {};
177
- const style = buildToastStyle(themeOptions, options, 'info');
178
-
179
- return originalToast(message, {
180
- duration: currentDuration,
181
- ...themeOptions,
182
- ...options,
183
- style,
184
- icon: options?.icon || themeOptions.icon
185
- });
186
- },
187
-
188
- loading: (message: string, options?: CustomToastOptions) => {
189
- const themeOptions = currentTheme?.loading || defaultTheme.loading || {};
190
- const style = buildToastStyle(themeOptions, options, 'loading');
191
-
192
- return originalToast.loading(message, {
193
- duration: currentDuration,
194
- ...themeOptions,
195
- ...options,
196
- style,
197
- icon: options?.icon || themeOptions.icon
198
- });
199
- },
200
-
201
- promise: <T,>(
202
- promise: Promise<T>,
203
- messages: { loading: string; success: string; error: string },
204
- options?: {
205
- loading?: CustomToastOptions;
206
- success?: CustomToastOptions;
207
- error?: CustomToastOptions;
208
- }
209
- ) => {
210
- const loadingTheme = currentTheme?.loading || defaultTheme.loading || {};
211
- const successTheme = currentTheme?.success || defaultTheme.success || {};
212
- const errorTheme = currentTheme?.error || defaultTheme.error || {};
213
-
214
- return originalToast.promise(promise, messages, {
215
- loading: {
216
- ...loadingTheme,
217
- ...options?.loading,
218
- style: buildToastStyle(loadingTheme, options?.loading, 'loading'),
219
- icon: options?.loading?.icon || loadingTheme.icon
220
- },
221
- success: {
222
- ...successTheme,
223
- ...options?.success,
224
- style: buildToastStyle(successTheme, options?.success, 'success'),
225
- icon: options?.success?.icon || successTheme.icon
226
- },
227
- error: {
228
- ...errorTheme,
229
- ...options?.error,
230
- style: buildToastStyle(errorTheme, options?.error, 'error'),
231
- icon: options?.error?.icon || errorTheme.icon
232
- }
233
- });
234
- },
235
-
236
- // Custom toast with complete control
237
- custom: (message: string, type: ToastType = 'info', options?: CustomToastOptions) => {
238
- const themeOptions = currentTheme?.[type] || defaultTheme[type] || defaultTheme.info || {};
239
- const style = buildToastStyle(themeOptions, options, type);
240
-
241
- return originalToast(message, {
242
- duration: currentDuration,
243
- ...themeOptions,
244
- ...options,
245
- style,
246
- icon: options?.icon || themeOptions.icon
247
- });
248
- },
249
-
250
- // Action toast with button
251
- action: (
252
- message: string,
253
- action: { label: string; onClick: () => void },
254
- options?: CustomToastOptions
255
- ) => {
256
- const themeOptions = currentTheme?.info || defaultTheme.info || {};
257
- const style = buildToastStyle(themeOptions, options, 'info');
258
-
259
- return originalToast(message, {
260
- duration: currentDuration,
261
- ...themeOptions,
262
- ...options,
263
- style,
264
- icon: options?.icon || themeOptions.icon,
265
- action: {
266
- label: action.label,
267
- onClick: action.onClick,
268
- buttonStyle:
269
- options?.action?.buttonStyle ||
270
- 'background: #3b82f6; color: white; border: none; padding: 4px 12px; border-radius: 4px; cursor: pointer;'
271
- }
272
- });
273
- },
274
-
275
- // Dismiss specific toast or all toasts
276
- dismiss: (toastId?: string) => {
277
- return originalToast.dismiss(toastId);
278
- },
279
-
280
- // Remove specific toast
281
- remove: (toastId?: string) => {
282
- return originalToast.remove(toastId);
283
- }
284
- };
285
-
286
- export function updateToastConfig(config: {
287
- duration?: number;
288
- theme?: ToastTheme;
289
- richColors?: boolean;
290
- }) {
291
- if (config.duration !== undefined) currentDuration = config.duration;
292
- if (config.theme !== undefined) currentTheme = config.theme;
293
- if (config.richColors !== undefined) currentRichColors = config.richColors;
294
- }
295
-
296
- export { originalToast };
297
- export type { ToastOptions };
298
- </script>
299
-
300
- <script lang="ts">
301
- import { Toaster, toast as originalToast, type ToastOptions } from 'svelte-french-toast';
302
-
303
- let {
304
- position = 'top-center',
305
- duration = 4000,
306
- theme = {},
307
- className = '',
308
- toastOptions = {},
309
- richColors = false,
310
- customIcons = true,
311
- closeButton = true,
312
- pauseOnHover = true,
313
- reverseOrder = false,
314
- visibleToasts = 3,
315
- expand = false,
316
- gap = 8,
317
- offset = '32px'
318
- }: ToasterProps = $props();
319
-
320
- $effect(() => {
321
- updateToastConfig({ duration, theme, richColors });
322
- });
323
- </script>
324
-
325
- <Toaster
326
- {position}
327
- {duration}
328
- {className}
329
- {toastOptions}
330
- {closeButton}
331
- {pauseOnHover}
332
- {reverseOrder}
333
- {visibleToasts}
334
- {expand}
335
- {gap}
336
- {offset}
337
- />
1
+ <script lang="ts" module>
2
+ export type ToastType = 'success' | 'error' | 'warning' | 'info' | 'loading' | 'custom';
3
+ export type ToastPosition =
4
+ | 'top-left'
5
+ | 'top-center'
6
+ | 'top-right'
7
+ | 'bottom-left'
8
+ | 'bottom-center'
9
+ | 'bottom-right';
10
+
11
+ export interface CustomToastOptions extends ToastOptions {
12
+ icon?: string;
13
+ showProgress?: boolean;
14
+ progressColor?: string;
15
+ borderColor?: string;
16
+ backgroundColor?: string;
17
+ textColor?: string;
18
+ iconColor?: string;
19
+ style?: any;
20
+ action?: {
21
+ label: string | boolean;
22
+ onClick: () => void;
23
+ buttonStyle?: string;
24
+ };
25
+ }
26
+
27
+ export interface ToastTheme {
28
+ success?: Partial<CustomToastOptions>;
29
+ error?: Partial<CustomToastOptions>;
30
+ warning?: Partial<CustomToastOptions>;
31
+ info?: Partial<CustomToastOptions>;
32
+ loading?: Partial<CustomToastOptions>;
33
+ custom?: Partial<CustomToastOptions>;
34
+ }
35
+
36
+ export interface ToasterProps {
37
+ position?: ToastPosition;
38
+ duration?: number;
39
+ theme?: ToastTheme;
40
+ className?: string;
41
+ toastOptions?: ToastOptions;
42
+ richColors?: boolean;
43
+ customIcons?: boolean;
44
+ closeButton?: boolean;
45
+ pauseOnHover?: boolean;
46
+ reverseOrder?: boolean;
47
+ visibleToasts?: number;
48
+ expand?: boolean;
49
+ gap?: number;
50
+ offset?: number | string;
51
+ }
52
+ // Default theme configuration
53
+ const defaultTheme: ToastTheme = {
54
+ success: {
55
+ icon: '✅',
56
+ borderColor: '#22c55e',
57
+ backgroundColor: '#f0fdf4',
58
+ textColor: '#166534',
59
+ iconColor: '#16a34a',
60
+ progressColor: '#22c55e'
61
+ },
62
+ error: {
63
+ icon: '❌',
64
+ borderColor: '#ef4444',
65
+ backgroundColor: '#fef2f2',
66
+ textColor: '#991b1b',
67
+ iconColor: '#dc2626',
68
+ progressColor: '#ef4444'
69
+ },
70
+ warning: {
71
+ icon: '⚠️',
72
+ borderColor: '#f59e0b',
73
+ backgroundColor: '#fffbeb',
74
+ textColor: '#92400e',
75
+ iconColor: '#d97706',
76
+ progressColor: '#f59e0b'
77
+ },
78
+ info: {
79
+ icon: 'ℹ️',
80
+ borderColor: '#3b82f6',
81
+ backgroundColor: '#eff6ff',
82
+ textColor: '#1e40af',
83
+ iconColor: '#2563eb',
84
+ progressColor: '#3b82f6'
85
+ },
86
+ loading: {
87
+ icon: '⏳',
88
+ borderColor: '#6b7280',
89
+ backgroundColor: '#f9fafb',
90
+ textColor: '#374151',
91
+ iconColor: '#6b7280',
92
+ progressColor: '#6b7280'
93
+ }
94
+ };
95
+
96
+ let currentDuration = 4000;
97
+ let currentTheme: ToastTheme = {};
98
+ let currentRichColors = false;
99
+
100
+ function buildToastStyle(
101
+ theme: Partial<CustomToastOptions>,
102
+ options?: CustomToastOptions,
103
+ type?: ToastType,
104
+ richColors?: boolean
105
+ ): string {
106
+ if (options?.style) return options.style;
107
+
108
+ const baseStyle = `
109
+ border: 1px solid ${options?.borderColor || theme.borderColor || '#e5e7eb'};
110
+ background: ${options?.backgroundColor || theme.backgroundColor || '#ffffff'};
111
+ color: ${options?.textColor || theme.textColor || '#1f2937'};
112
+ padding: 12px 16px;
113
+ border-radius: 8px;
114
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
115
+ font-size: 14px;
116
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
117
+ display: flex;
118
+ align-items: center;
119
+ gap: 8px;
120
+ `;
121
+
122
+ if (richColors && type && defaultTheme[type]) {
123
+ const richTheme = defaultTheme[type]!;
124
+ return `
125
+ ${baseStyle}
126
+ border-color: ${options?.borderColor || richTheme.borderColor}!important;
127
+ background: ${options?.backgroundColor || richTheme.backgroundColor}!important;
128
+ color: ${options?.textColor || richTheme.textColor}!important;
129
+ `;
130
+ }
131
+
132
+ return baseStyle;
133
+ }
134
+
135
+ export const toast = {
136
+ success: (message: string, options?: CustomToastOptions) => {
137
+ const themeOptions = currentTheme?.success || defaultTheme.success || {};
138
+ const style = buildToastStyle(themeOptions, options, 'success');
139
+
140
+ return originalToast.success(message, {
141
+ duration: currentDuration,
142
+ ...themeOptions,
143
+ ...options,
144
+ style,
145
+ icon: options?.icon || themeOptions.icon
146
+ });
147
+ },
148
+
149
+ error: (message: string, options?: CustomToastOptions) => {
150
+ const themeOptions = currentTheme?.error || defaultTheme.error || {};
151
+ const style = buildToastStyle(themeOptions, options, 'error');
152
+
153
+ return originalToast.error(message, {
154
+ duration: currentDuration,
155
+ ...themeOptions,
156
+ ...options,
157
+ style,
158
+ icon: options?.icon || themeOptions.icon
159
+ });
160
+ },
161
+
162
+ warning: (message: string, options?: CustomToastOptions) => {
163
+ const themeOptions = currentTheme?.warning || defaultTheme.warning || {};
164
+ const style = buildToastStyle(themeOptions, options, 'warning');
165
+
166
+ return originalToast(message, {
167
+ duration: currentDuration,
168
+ ...themeOptions,
169
+ ...options,
170
+ style,
171
+ icon: options?.icon || themeOptions.icon
172
+ });
173
+ },
174
+
175
+ info: (message: string, options?: CustomToastOptions) => {
176
+ const themeOptions = currentTheme?.info || defaultTheme.info || {};
177
+ const style = buildToastStyle(themeOptions, options, 'info');
178
+
179
+ return originalToast(message, {
180
+ duration: currentDuration,
181
+ ...themeOptions,
182
+ ...options,
183
+ style,
184
+ icon: options?.icon || themeOptions.icon
185
+ });
186
+ },
187
+
188
+ loading: (message: string, options?: CustomToastOptions) => {
189
+ const themeOptions = currentTheme?.loading || defaultTheme.loading || {};
190
+ const style = buildToastStyle(themeOptions, options, 'loading');
191
+
192
+ return originalToast.loading(message, {
193
+ duration: currentDuration,
194
+ ...themeOptions,
195
+ ...options,
196
+ style,
197
+ icon: options?.icon || themeOptions.icon
198
+ });
199
+ },
200
+
201
+ promise: <T,>(
202
+ promise: Promise<T>,
203
+ messages: { loading: string; success: string; error: string },
204
+ options?: {
205
+ loading?: CustomToastOptions;
206
+ success?: CustomToastOptions;
207
+ error?: CustomToastOptions;
208
+ }
209
+ ) => {
210
+ const loadingTheme = currentTheme?.loading || defaultTheme.loading || {};
211
+ const successTheme = currentTheme?.success || defaultTheme.success || {};
212
+ const errorTheme = currentTheme?.error || defaultTheme.error || {};
213
+
214
+ return originalToast.promise(promise, messages, {
215
+ loading: {
216
+ ...loadingTheme,
217
+ ...options?.loading,
218
+ style: buildToastStyle(loadingTheme, options?.loading, 'loading'),
219
+ icon: options?.loading?.icon || loadingTheme.icon
220
+ },
221
+ success: {
222
+ ...successTheme,
223
+ ...options?.success,
224
+ style: buildToastStyle(successTheme, options?.success, 'success'),
225
+ icon: options?.success?.icon || successTheme.icon
226
+ },
227
+ error: {
228
+ ...errorTheme,
229
+ ...options?.error,
230
+ style: buildToastStyle(errorTheme, options?.error, 'error'),
231
+ icon: options?.error?.icon || errorTheme.icon
232
+ }
233
+ });
234
+ },
235
+
236
+ // Custom toast with complete control
237
+ custom: (message: string, type: ToastType = 'info', options?: CustomToastOptions) => {
238
+ const themeOptions = currentTheme?.[type] || defaultTheme[type] || defaultTheme.info || {};
239
+ const style = buildToastStyle(themeOptions, options, type);
240
+
241
+ return originalToast(message, {
242
+ duration: currentDuration,
243
+ ...themeOptions,
244
+ ...options,
245
+ style,
246
+ icon: options?.icon || themeOptions.icon
247
+ });
248
+ },
249
+
250
+ // Action toast with button
251
+ action: (
252
+ message: string,
253
+ action: { label: string; onClick: () => void },
254
+ options?: CustomToastOptions
255
+ ) => {
256
+ const themeOptions = currentTheme?.info || defaultTheme.info || {};
257
+ const style = buildToastStyle(themeOptions, options, 'info');
258
+
259
+ return originalToast(message, {
260
+ duration: currentDuration,
261
+ ...themeOptions,
262
+ ...options,
263
+ style,
264
+ icon: options?.icon || themeOptions.icon,
265
+ action: {
266
+ label: action.label,
267
+ onClick: action.onClick,
268
+ buttonStyle:
269
+ options?.action?.buttonStyle ||
270
+ 'background: #3b82f6; color: white; border: none; padding: 4px 12px; border-radius: 4px; cursor: pointer;'
271
+ }
272
+ });
273
+ },
274
+
275
+ // Dismiss specific toast or all toasts
276
+ dismiss: (toastId?: string) => {
277
+ return originalToast.dismiss(toastId);
278
+ },
279
+
280
+ // Remove specific toast
281
+ remove: (toastId?: string) => {
282
+ return originalToast.remove(toastId);
283
+ }
284
+ };
285
+
286
+ export function updateToastConfig(config: {
287
+ duration?: number;
288
+ theme?: ToastTheme;
289
+ richColors?: boolean;
290
+ }) {
291
+ if (config.duration !== undefined) currentDuration = config.duration;
292
+ if (config.theme !== undefined) currentTheme = config.theme;
293
+ if (config.richColors !== undefined) currentRichColors = config.richColors;
294
+ }
295
+
296
+ export { originalToast };
297
+ export type { ToastOptions };
298
+ </script>
299
+
300
+ <script lang="ts">
301
+ import { Toaster, toast as originalToast, type ToastOptions } from 'svelte-french-toast';
302
+
303
+ let {
304
+ position = 'top-center',
305
+ duration = 4000,
306
+ theme = {},
307
+ className = '',
308
+ toastOptions = {},
309
+ richColors = false,
310
+ customIcons = true,
311
+ closeButton = true,
312
+ pauseOnHover = true,
313
+ reverseOrder = false,
314
+ visibleToasts = 3,
315
+ expand = false,
316
+ gap = 8,
317
+ offset = '32px'
318
+ }: ToasterProps = $props();
319
+
320
+ $effect(() => {
321
+ updateToastConfig({ duration, theme, richColors });
322
+ });
323
+ </script>
324
+
325
+ <Toaster
326
+ {position}
327
+ {duration}
328
+ {className}
329
+ {toastOptions}
330
+ {closeButton}
331
+ {pauseOnHover}
332
+ {reverseOrder}
333
+ {visibleToasts}
334
+ {expand}
335
+ {gap}
336
+ {offset}
337
+ />