@ticatec/uniface-element 0.2.4 → 0.3.0

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 (176) hide show
  1. package/dist/accordion/README.md +169 -0
  2. package/dist/accordion/README_CN.md +176 -0
  3. package/dist/action-bar/README.md +275 -0
  4. package/dist/action-bar/README_CN.md +285 -0
  5. package/dist/app-layout/README.md +374 -0
  6. package/dist/app-layout/README_CN.md +381 -0
  7. package/dist/app-top-bar/README.md +357 -0
  8. package/dist/app-top-bar/README_CN.md +365 -0
  9. package/dist/attachment-files/AttachmentFilesField.svelte +67 -1
  10. package/dist/attachment-files/AttachmentFilesField.svelte.d.ts +8 -1
  11. package/dist/base-calendar/CalendarBase.svelte +0 -3
  12. package/dist/box/README.md +385 -0
  13. package/dist/box/README_CN.md +393 -0
  14. package/dist/breadcrumbs/README.md +442 -0
  15. package/dist/breadcrumbs/README_CN.md +442 -0
  16. package/dist/button/Button.svelte +27 -7
  17. package/dist/button/Button.svelte.d.ts +3 -1
  18. package/dist/button/IconButton.svelte +26 -6
  19. package/dist/button/IconButton.svelte.d.ts +3 -1
  20. package/dist/button/IconButton_README.md +513 -0
  21. package/dist/button/IconButton_README_CN.md +513 -0
  22. package/dist/button/README.md +428 -0
  23. package/dist/button/README_CN.md +428 -0
  24. package/dist/button/TextButton.svelte +26 -6
  25. package/dist/button/TextButton.svelte.d.ts +3 -1
  26. package/dist/button/TextButton_README.md +571 -0
  27. package/dist/button/TextButton_README_CN.md +571 -0
  28. package/dist/card/README.md +666 -0
  29. package/dist/card/README_CN.md +666 -0
  30. package/dist/cascade-options-select/CascadeOptionSelect.svelte +43 -7
  31. package/dist/cascade-options-select/CascadeOptionSelect.svelte.d.ts +3 -4
  32. package/dist/cascade-options-select/README.md +663 -2
  33. package/dist/cascade-options-select/README_CN.md +664 -0
  34. package/dist/checkbox/CheckBox.svelte +20 -6
  35. package/dist/checkbox/CheckBox.svelte.d.ts +4 -2
  36. package/dist/checkbox/README.md +562 -0
  37. package/dist/checkbox/README_CN.md +727 -0
  38. package/dist/common-editor/NumberInput.svelte +39 -26
  39. package/dist/common-editor/NumberInput.svelte.d.ts +5 -1
  40. package/dist/concise-data-table/ConciseListTable.svelte +133 -36
  41. package/dist/concise-data-table/ConciseListTable.svelte.d.ts +8 -1
  42. package/dist/concise-data-table/DataCell.svelte +5 -6
  43. package/dist/concise-data-table/DataRow.svelte +22 -2
  44. package/dist/concise-data-table/DataRow.svelte.d.ts +1 -0
  45. package/dist/concise-data-table/README.md +606 -0
  46. package/dist/concise-data-table/README_CN.md +611 -0
  47. package/dist/context-menu/ContextMenu.svelte +138 -21
  48. package/dist/context-menu/ContextMenu.svelte.d.ts +5 -0
  49. package/dist/context-menu/ContextMenuItem.d.ts +20 -4
  50. package/dist/context-menu/README.md +551 -0
  51. package/dist/context-menu/README_CN.md +551 -0
  52. package/dist/criteria-field/CriteriaField.svelte +3 -5
  53. package/dist/criteria-field/README.md +532 -0
  54. package/dist/criteria-field/README_CN.md +532 -0
  55. package/dist/data-table/README.md +712 -0
  56. package/dist/data-table/README_CN.md +712 -0
  57. package/dist/date-picker/DatePicker.svelte +44 -7
  58. package/dist/date-picker/DatePicker.svelte.d.ts +3 -4
  59. package/dist/date-picker/DateTimePicker.svelte +32 -8
  60. package/dist/date-picker/DateTimePicker.svelte.d.ts +3 -4
  61. package/dist/date-picker/README.md +326 -0
  62. package/dist/date-picker/README_CN.md +316 -0
  63. package/dist/date-picker/ScrollBar.svelte +18 -8
  64. package/dist/date-picker/ScrollBar.svelte.d.ts +1 -1
  65. package/dist/date-picker/TimePanel.svelte +5 -5
  66. package/dist/date-picker/TimePanel.svelte.d.ts +1 -1
  67. package/dist/date-range/README.md +374 -0
  68. package/dist/date-range/README_CN.md +374 -0
  69. package/dist/dialog/README.md +596 -0
  70. package/dist/dialog/README_CN.md +596 -0
  71. package/dist/drawer/README.md +679 -1
  72. package/dist/drawer/README_CN.md +679 -0
  73. package/dist/group-box/group-check-box/GroupCheckBox.svelte +62 -5
  74. package/dist/group-box/group-check-box/GroupCheckBox.svelte.d.ts +7 -2
  75. package/dist/group-box/group-check-box/README.md +749 -0
  76. package/dist/group-box/group-check-box/README_CN.md +750 -0
  77. package/dist/group-box/group-radio-box/GroupRadioBox.svelte +69 -4
  78. package/dist/group-box/group-radio-box/GroupRadioBox.svelte.d.ts +8 -2
  79. package/dist/group-box/group-radio-box/README.md +920 -0
  80. package/dist/group-box/group-radio-box/README_CN.md +920 -0
  81. package/dist/image-files/README.md +1346 -0
  82. package/dist/image-files/README_CN.md +1346 -0
  83. package/dist/input-options-select/InputOptionsSelect.svelte +161 -65
  84. package/dist/input-options-select/InputOptionsSelect.svelte.d.ts +4 -1
  85. package/dist/lib/forwardAllEvents.d.ts +3 -0
  86. package/dist/lib/forwardAllEvents.js +24 -0
  87. package/dist/list-box/README.md +579 -0
  88. package/dist/list-box/README_CN.md +682 -0
  89. package/dist/lookup-editor/LookupEditor.svelte +15 -3
  90. package/dist/lookup-editor/LookupEditor.svelte.d.ts +3 -4
  91. package/dist/lookup-editor/README.md +684 -0
  92. package/dist/lookup-editor/README_CN.md +684 -0
  93. package/dist/memo-editor/MemoEditor.svelte +77 -27
  94. package/dist/memo-editor/MemoEditor.svelte.d.ts +6 -3
  95. package/dist/memo-editor/README.md +819 -0
  96. package/dist/memo-editor/README_CN.md +819 -0
  97. package/dist/message-box/README.md +398 -0
  98. package/dist/message-box/README_CN.md +398 -0
  99. package/dist/number-editor/NumberEditor.svelte +2 -2
  100. package/dist/number-editor/NumberEditor.svelte.d.ts +1 -1
  101. package/dist/number-editor/README.md +353 -22
  102. package/dist/number-editor/README_CN.md +357 -0
  103. package/dist/number-range/README.md +443 -0
  104. package/dist/number-range/README_CN.md +443 -0
  105. package/dist/options-multi-select/OptionsMultiSelect.svelte +87 -12
  106. package/dist/options-multi-select/OptionsMultiSelect.svelte.d.ts +3 -1
  107. package/dist/options-multi-select/README.md +480 -0
  108. package/dist/options-multi-select/README_CN.md +480 -0
  109. package/dist/options-select/OptionsSelect.svelte +36 -5
  110. package/dist/options-select/OptionsSelect.svelte.d.ts +3 -4
  111. package/dist/options-select/README.md +632 -0
  112. package/dist/options-select/README_CN.md +632 -0
  113. package/dist/page/README.md +605 -0
  114. package/dist/page/README_CN.md +605 -0
  115. package/dist/pagination/README.md +946 -0
  116. package/dist/pagination/README_CN.md +946 -0
  117. package/dist/pagination-panel/README.md +1075 -0
  118. package/dist/pagination-panel/README_CN.md +1075 -0
  119. package/dist/popup-hint/README.md +841 -0
  120. package/dist/popup-hint/README_CN.md +840 -0
  121. package/dist/progress-bar/README.md +242 -0
  122. package/dist/progress-bar/README_CN.md +242 -0
  123. package/dist/progress-step-bar/README.md +316 -0
  124. package/dist/progress-step-bar/README_CN.md +316 -0
  125. package/dist/prompts-text-editor/PromptsTextEditor.svelte +6 -3
  126. package/dist/prompts-text-editor/PromptsTextEditor.svelte.d.ts +3 -1
  127. package/dist/prompts-text-editor/README.md +329 -0
  128. package/dist/prompts-text-editor/README_CN.md +329 -0
  129. package/dist/property-editor/README.md +969 -0
  130. package/dist/property-editor/README_CN.md +969 -0
  131. package/dist/radio-button/README.md +372 -0
  132. package/dist/radio-button/README_CN.md +372 -0
  133. package/dist/radio-button/RadioButton.svelte +32 -3
  134. package/dist/radio-button/RadioButton.svelte.d.ts +12 -1
  135. package/dist/search-box/README.md +425 -0
  136. package/dist/search-box/README_CN.md +424 -0
  137. package/dist/search-box/SearchBox.svelte +22 -6
  138. package/dist/search-box/SearchBox.svelte.d.ts +4 -1
  139. package/dist/tabs/README.md +919 -0
  140. package/dist/tabs/README_CN.md +920 -0
  141. package/dist/tag/README.md +922 -0
  142. package/dist/tag/README_CN.md +922 -0
  143. package/dist/text-editor/PasswordEditor.svelte +17 -2
  144. package/dist/text-editor/PasswordEditor.svelte.d.ts +3 -3
  145. package/dist/text-editor/PasswordEditor_README.md +551 -0
  146. package/dist/text-editor/PasswordEditor_README_CN.md +551 -0
  147. package/dist/text-editor/README.md +466 -0
  148. package/dist/text-editor/README_CN.md +466 -0
  149. package/dist/text-editor/TextEditor.svelte +51 -19
  150. package/dist/text-editor/TextEditor.svelte.d.ts +0 -1
  151. package/dist/time-editor/README.md +498 -24
  152. package/dist/time-editor/README_CN.md +498 -0
  153. package/dist/time-editor/TimeEditor.svelte +7 -3
  154. package/dist/time-editor/TimeEditor.svelte.d.ts +3 -1
  155. package/dist/toast/README.md +667 -0
  156. package/dist/toast/README_CN.md +667 -0
  157. package/dist/transfer/README.md +795 -0
  158. package/dist/transfer/Transfer.svelte +6 -4
  159. package/dist/transfer/Transfer.svelte.d.ts +3 -1
  160. package/dist/tree-view/README.md +761 -0
  161. package/dist/tree-view/README_CN.md +761 -0
  162. package/dist/tree-view/TreeView.svelte +5 -3
  163. package/dist/tree-view/TreeView.svelte.d.ts +3 -1
  164. package/dist/unit-number-editor/README.md +546 -20
  165. package/dist/unit-number-editor/README_CN.md +525 -0
  166. package/dist/unit-number-editor/UnitNumberEditor.svelte +62 -8
  167. package/dist/unit-number-editor/UnitNumberEditor.svelte.d.ts +5 -1
  168. package/docs/form-field/cn/README_CN.md +364 -0
  169. package/docs/form-field/en/README.md +364 -0
  170. package/docs/form-panel/flex-form/cn/README_CN.md +586 -0
  171. package/docs/form-panel/flex-form/en/README.md +586 -0
  172. package/docs/form-panel/flex-row-form/cn/README_CN.md +787 -0
  173. package/docs/form-panel/flex-row-form/en/README.md +787 -0
  174. package/docs/form-panel/grid-form/en/README.md +744 -0
  175. package/package.json +1 -1
  176. package/dist/drawer/README-CN.md +0 -1
@@ -0,0 +1,667 @@
1
+ # Toast
2
+
3
+ A lightweight toast notification system for displaying temporary messages to users. Features customizable types (success, error, info), automatic dismissal, and smooth animations. Perfect for status updates, error messages, and user feedback.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @ticatec/uniface-element
9
+ ```
10
+
11
+ ## Import
12
+
13
+ ```typescript
14
+ import ToastBoard, { type Toast } from "@ticatec/uniface-element/ToastBoard";
15
+ ```
16
+
17
+ ## Basic Usage
18
+
19
+ ```svelte
20
+ <script>
21
+ import ToastBoard from "@ticatec/uniface-element/ToastBoard";
22
+
23
+ function showSuccessToast() {
24
+ window.Toast.show("Operation completed successfully!", "success", 3);
25
+ }
26
+
27
+ function showErrorToast() {
28
+ window.Toast.show("Something went wrong!", "error", 5);
29
+ }
30
+
31
+ function showInfoToast() {
32
+ window.Toast.show("Information message", "info");
33
+ }
34
+ </script>
35
+
36
+ <!-- Include ToastBoard component (usually in your root layout) -->
37
+ <ToastBoard />
38
+
39
+ <!-- Trigger toasts from anywhere -->
40
+ <button on:click={showSuccessToast}>Show Success</button>
41
+ <button on:click={showErrorToast}>Show Error</button>
42
+ <button on:click={showInfoToast}>Show Info</button>
43
+ ```
44
+
45
+ ## Props (ToastBoard)
46
+
47
+ | Prop | Type | Default | Description |
48
+ |------|------|---------|-------------|
49
+ | `fromBottom` | `boolean` | `false` | Whether to show toasts from bottom of screen |
50
+
51
+ ## Global Toast API
52
+
53
+ Once ToastBoard is mounted, the global `window.Toast` object becomes available:
54
+
55
+ ### Toast.show()
56
+
57
+ ```typescript
58
+ window.Toast.show(message: string, type?: "error" | "info" | "success", duration?: number)
59
+ ```
60
+
61
+ | Parameter | Type | Default | Description |
62
+ |-----------|------|---------|-------------|
63
+ | `message` | `string` | Required | The message to display |
64
+ | `type` | `"error" \| "info" \| "success"` | `"error"` | Toast type/styling |
65
+ | `duration` | `number` | `3` | Duration in seconds before auto-dismiss |
66
+
67
+ ## Types
68
+
69
+ ### Success Toast
70
+ - **Color**: Green background (`#2DC071`)
71
+ - **Usage**: Successful operations, confirmations
72
+ - **Example**: "Data saved successfully!"
73
+
74
+ ### Error Toast
75
+ - **Color**: Red background (`#FF685B`)
76
+ - **Usage**: Error messages, failed operations
77
+ - **Example**: "Failed to save data"
78
+
79
+ ### Info Toast
80
+ - **Color**: Blue background (`#0061FF`)
81
+ - **Usage**: General information, notifications
82
+ - **Example**: "New update available"
83
+
84
+ ## Examples
85
+
86
+ ### Basic Implementation
87
+
88
+ ```svelte
89
+ <script>
90
+ import ToastBoard from "@ticatec/uniface-element/ToastBoard";
91
+
92
+ // Simple toast functions
93
+ function success() {
94
+ window.Toast.show("Success! Data has been saved.", "success", 4);
95
+ }
96
+
97
+ function error() {
98
+ window.Toast.show("Error! Unable to process request.", "error", 6);
99
+ }
100
+
101
+ function info() {
102
+ window.Toast.show("Info: Check your email for updates.", "info", 3);
103
+ }
104
+ </script>
105
+
106
+ <!-- Mount the toast board -->
107
+ <ToastBoard />
108
+
109
+ <div class="demo">
110
+ <h3>Toast Notifications</h3>
111
+ <button on:click={success}>Success Toast</button>
112
+ <button on:click={error}>Error Toast</button>
113
+ <button on:click={info}>Info Toast</button>
114
+ </div>
115
+
116
+ <style>
117
+ .demo {
118
+ padding: 20px;
119
+ }
120
+
121
+ button {
122
+ margin: 0 8px 8px 0;
123
+ padding: 8px 16px;
124
+ border: none;
125
+ border-radius: 4px;
126
+ cursor: pointer;
127
+ }
128
+ </style>
129
+ ```
130
+
131
+ ### Form Validation with Toast
132
+
133
+ ```svelte
134
+ <script>
135
+ import ToastBoard from "@ticatec/uniface-element/ToastBoard";
136
+
137
+ let email = '';
138
+ let password = '';
139
+ let loading = false;
140
+
141
+ async function handleSubmit() {
142
+ if (!email) {
143
+ window.Toast.show("Email is required", "error", 4);
144
+ return;
145
+ }
146
+
147
+ if (!email.includes('@')) {
148
+ window.Toast.show("Please enter a valid email address", "error", 4);
149
+ return;
150
+ }
151
+
152
+ if (!password) {
153
+ window.Toast.show("Password is required", "error", 4);
154
+ return;
155
+ }
156
+
157
+ if (password.length < 6) {
158
+ window.Toast.show("Password must be at least 6 characters", "error", 4);
159
+ return;
160
+ }
161
+
162
+ loading = true;
163
+
164
+ try {
165
+ // Simulate API call
166
+ await new Promise(resolve => setTimeout(resolve, 2000));
167
+
168
+ if (Math.random() > 0.5) {
169
+ window.Toast.show("Login successful! Welcome back.", "success", 3);
170
+ // Redirect or update UI
171
+ } else {
172
+ window.Toast.show("Invalid credentials. Please try again.", "error", 5);
173
+ }
174
+ } catch (error) {
175
+ window.Toast.show("Network error. Please check your connection.", "error", 5);
176
+ } finally {
177
+ loading = false;
178
+ }
179
+ }
180
+ </script>
181
+
182
+ <ToastBoard />
183
+
184
+ <form on:submit|preventDefault={handleSubmit}>
185
+ <h3>Login Form</h3>
186
+
187
+ <div class="field">
188
+ <label>Email:</label>
189
+ <input
190
+ type="email"
191
+ bind:value={email}
192
+ placeholder="Enter your email"
193
+ disabled={loading}
194
+ />
195
+ </div>
196
+
197
+ <div class="field">
198
+ <label>Password:</label>
199
+ <input
200
+ type="password"
201
+ bind:value={password}
202
+ placeholder="Enter your password"
203
+ disabled={loading}
204
+ />
205
+ </div>
206
+
207
+ <button type="submit" disabled={loading}>
208
+ {loading ? 'Logging in...' : 'Login'}
209
+ </button>
210
+ </form>
211
+
212
+ <style>
213
+ form {
214
+ max-width: 300px;
215
+ margin: 20px;
216
+ padding: 20px;
217
+ border: 1px solid #ddd;
218
+ border-radius: 8px;
219
+ }
220
+
221
+ .field {
222
+ margin-bottom: 16px;
223
+ }
224
+
225
+ label {
226
+ display: block;
227
+ margin-bottom: 4px;
228
+ font-weight: 500;
229
+ }
230
+
231
+ input {
232
+ width: 100%;
233
+ padding: 8px 12px;
234
+ border: 1px solid #ccc;
235
+ border-radius: 4px;
236
+ box-sizing: border-box;
237
+ }
238
+
239
+ button {
240
+ width: 100%;
241
+ padding: 10px;
242
+ background: #007bff;
243
+ color: white;
244
+ border: none;
245
+ border-radius: 4px;
246
+ cursor: pointer;
247
+ }
248
+
249
+ button:disabled {
250
+ background: #ccc;
251
+ cursor: not-allowed;
252
+ }
253
+ </style>
254
+ ```
255
+
256
+ ### File Upload with Progress Toast
257
+
258
+ ```svelte
259
+ <script>
260
+ import ToastBoard from "@ticatec/uniface-element/ToastBoard";
261
+
262
+ let fileInput;
263
+ let uploading = false;
264
+
265
+ async function handleFileUpload(event) {
266
+ const file = event.target.files[0];
267
+
268
+ if (!file) {
269
+ window.Toast.show("Please select a file to upload", "error", 3);
270
+ return;
271
+ }
272
+
273
+ // File size validation (5MB limit)
274
+ if (file.size > 5 * 1024 * 1024) {
275
+ window.Toast.show("File size must be less than 5MB", "error", 4);
276
+ return;
277
+ }
278
+
279
+ // File type validation
280
+ const allowedTypes = ['image/jpeg', 'image/png', 'image/gif'];
281
+ if (!allowedTypes.includes(file.type)) {
282
+ window.Toast.show("Only JPEG, PNG, and GIF files are allowed", "error", 4);
283
+ return;
284
+ }
285
+
286
+ uploading = true;
287
+ window.Toast.show("Starting file upload...", "info", 2);
288
+
289
+ try {
290
+ // Simulate upload progress
291
+ await simulateUpload(file);
292
+
293
+ window.Toast.show(`File "${file.name}" uploaded successfully!`, "success", 4);
294
+
295
+ // Clear the input
296
+ fileInput.value = '';
297
+
298
+ } catch (error) {
299
+ window.Toast.show("Upload failed. Please try again.", "error", 5);
300
+ } finally {
301
+ uploading = false;
302
+ }
303
+ }
304
+
305
+ async function simulateUpload(file) {
306
+ // Simulate upload stages
307
+ await new Promise(resolve => setTimeout(resolve, 1000));
308
+ window.Toast.show("Processing file...", "info", 2);
309
+
310
+ await new Promise(resolve => setTimeout(resolve, 1500));
311
+ window.Toast.show("Uploading to server...", "info", 2);
312
+
313
+ await new Promise(resolve => setTimeout(resolve, 1000));
314
+
315
+ // Random failure simulation
316
+ if (Math.random() < 0.2) {
317
+ throw new Error("Upload failed");
318
+ }
319
+ }
320
+ </script>
321
+
322
+ <ToastBoard />
323
+
324
+ <div class="upload-container">
325
+ <h3>File Upload</h3>
326
+
327
+ <div class="upload-area">
328
+ <input
329
+ bind:this={fileInput}
330
+ type="file"
331
+ accept="image/*"
332
+ on:change={handleFileUpload}
333
+ disabled={uploading}
334
+ id="file-upload"
335
+ />
336
+ <label for="file-upload" class:uploading>
337
+ {uploading ? '⏳ Uploading...' : '📁 Choose File'}
338
+ </label>
339
+ </div>
340
+
341
+ <p class="help-text">
342
+ Select JPEG, PNG, or GIF files (max 5MB)
343
+ </p>
344
+ </div>
345
+
346
+ <style>
347
+ .upload-container {
348
+ max-width: 400px;
349
+ margin: 20px;
350
+ padding: 20px;
351
+ border: 1px solid #ddd;
352
+ border-radius: 8px;
353
+ }
354
+
355
+ .upload-area {
356
+ margin: 16px 0;
357
+ }
358
+
359
+ input[type="file"] {
360
+ display: none;
361
+ }
362
+
363
+ label {
364
+ display: inline-block;
365
+ padding: 12px 24px;
366
+ background: #007bff;
367
+ color: white;
368
+ border-radius: 4px;
369
+ cursor: pointer;
370
+ transition: background 0.2s;
371
+ }
372
+
373
+ label:hover {
374
+ background: #0056b3;
375
+ }
376
+
377
+ label.uploading {
378
+ background: #6c757d;
379
+ cursor: not-allowed;
380
+ }
381
+
382
+ .help-text {
383
+ font-size: 14px;
384
+ color: #666;
385
+ margin: 8px 0 0 0;
386
+ }
387
+ </style>
388
+ ```
389
+
390
+ ### API Integration with Toast
391
+
392
+ ```svelte
393
+ <script>
394
+ import ToastBoard from "@ticatec/uniface-element/ToastBoard";
395
+
396
+ let users = [];
397
+ let loading = false;
398
+ let newUser = { name: '', email: '' };
399
+
400
+ async function fetchUsers() {
401
+ loading = true;
402
+ window.Toast.show("Loading users...", "info", 2);
403
+
404
+ try {
405
+ // Simulate API call
406
+ await new Promise(resolve => setTimeout(resolve, 1500));
407
+
408
+ // Mock data
409
+ users = [
410
+ { id: 1, name: 'John Doe', email: 'john@example.com' },
411
+ { id: 2, name: 'Jane Smith', email: 'jane@example.com' }
412
+ ];
413
+
414
+ window.Toast.show(`Loaded ${users.length} users successfully`, "success", 3);
415
+
416
+ } catch (error) {
417
+ window.Toast.show("Failed to load users", "error", 4);
418
+ } finally {
419
+ loading = false;
420
+ }
421
+ }
422
+
423
+ async function addUser() {
424
+ if (!newUser.name || !newUser.email) {
425
+ window.Toast.show("Please fill in all fields", "error", 3);
426
+ return;
427
+ }
428
+
429
+ loading = true;
430
+
431
+ try {
432
+ // Simulate API call
433
+ await new Promise(resolve => setTimeout(resolve, 1000));
434
+
435
+ const user = {
436
+ id: Date.now(),
437
+ name: newUser.name,
438
+ email: newUser.email
439
+ };
440
+
441
+ users = [...users, user];
442
+ newUser = { name: '', email: '' };
443
+
444
+ window.Toast.show("User added successfully!", "success", 3);
445
+
446
+ } catch (error) {
447
+ window.Toast.show("Failed to add user", "error", 4);
448
+ } finally {
449
+ loading = false;
450
+ }
451
+ }
452
+
453
+ async function deleteUser(userId) {
454
+ if (!confirm('Are you sure you want to delete this user?')) {
455
+ return;
456
+ }
457
+
458
+ try {
459
+ // Simulate API call
460
+ await new Promise(resolve => setTimeout(resolve, 800));
461
+
462
+ users = users.filter(u => u.id !== userId);
463
+ window.Toast.show("User deleted successfully", "success", 3);
464
+
465
+ } catch (error) {
466
+ window.Toast.show("Failed to delete user", "error", 4);
467
+ }
468
+ }
469
+ </script>
470
+
471
+ <ToastBoard />
472
+
473
+ <div class="app">
474
+ <h3>User Management</h3>
475
+
476
+ <div class="actions">
477
+ <button on:click={fetchUsers} disabled={loading}>
478
+ {loading ? 'Loading...' : 'Load Users'}
479
+ </button>
480
+ </div>
481
+
482
+ <div class="add-user">
483
+ <h4>Add New User</h4>
484
+ <input
485
+ bind:value={newUser.name}
486
+ placeholder="Name"
487
+ disabled={loading}
488
+ />
489
+ <input
490
+ bind:value={newUser.email}
491
+ placeholder="Email"
492
+ disabled={loading}
493
+ />
494
+ <button on:click={addUser} disabled={loading}>
495
+ {loading ? 'Adding...' : 'Add User'}
496
+ </button>
497
+ </div>
498
+
499
+ <div class="users">
500
+ <h4>Users ({users.length})</h4>
501
+ {#each users as user}
502
+ <div class="user-item">
503
+ <div>
504
+ <strong>{user.name}</strong>
505
+ <span>{user.email}</span>
506
+ </div>
507
+ <button on:click={() => deleteUser(user.id)}>Delete</button>
508
+ </div>
509
+ {/each}
510
+ </div>
511
+ </div>
512
+
513
+ <style>
514
+ .app {
515
+ max-width: 600px;
516
+ margin: 20px;
517
+ padding: 20px;
518
+ border: 1px solid #ddd;
519
+ border-radius: 8px;
520
+ }
521
+
522
+ .actions {
523
+ margin-bottom: 20px;
524
+ }
525
+
526
+ .add-user {
527
+ margin-bottom: 20px;
528
+ padding: 16px;
529
+ background: #f8f9fa;
530
+ border-radius: 4px;
531
+ }
532
+
533
+ .add-user h4 {
534
+ margin: 0 0 12px 0;
535
+ }
536
+
537
+ .add-user input {
538
+ margin: 0 8px 8px 0;
539
+ padding: 8px 12px;
540
+ border: 1px solid #ccc;
541
+ border-radius: 4px;
542
+ }
543
+
544
+ .users h4 {
545
+ margin-bottom: 12px;
546
+ }
547
+
548
+ .user-item {
549
+ display: flex;
550
+ justify-content: space-between;
551
+ align-items: center;
552
+ padding: 12px;
553
+ border: 1px solid #eee;
554
+ border-radius: 4px;
555
+ margin-bottom: 8px;
556
+ }
557
+
558
+ .user-item div {
559
+ display: flex;
560
+ flex-direction: column;
561
+ }
562
+
563
+ .user-item span {
564
+ font-size: 14px;
565
+ color: #666;
566
+ }
567
+
568
+ button {
569
+ padding: 8px 16px;
570
+ border: none;
571
+ border-radius: 4px;
572
+ cursor: pointer;
573
+ background: #007bff;
574
+ color: white;
575
+ }
576
+
577
+ button:disabled {
578
+ background: #ccc;
579
+ cursor: not-allowed;
580
+ }
581
+ </style>
582
+ ```
583
+
584
+ ### Bottom Positioned Toasts
585
+
586
+ ```svelte
587
+ <script>
588
+ import ToastBoard from "@ticatec/uniface-element/ToastBoard";
589
+
590
+ function showBottomToast() {
591
+ window.Toast.show("This toast appears from the bottom!", "info", 4);
592
+ }
593
+ </script>
594
+
595
+ <!-- Position toasts at bottom of screen -->
596
+ <ToastBoard fromBottom={true} />
597
+
598
+ <button on:click={showBottomToast}>Show Bottom Toast</button>
599
+ ```
600
+
601
+ ## Features
602
+
603
+ - **Multiple Types**: Success, error, and info variants with distinct colors
604
+ - **Auto Dismissal**: Configurable duration with automatic hiding
605
+ - **Smooth Animations**: Fly-in transitions from top or bottom
606
+ - **Global Access**: Use from anywhere via `window.Toast.show()`
607
+ - **Positioning**: Support for top or bottom screen positioning
608
+ - **Stacking**: Multiple toasts can be displayed sequentially
609
+ - **Responsive**: Works on all screen sizes
610
+
611
+ ## Styling
612
+
613
+ The toast component uses CSS custom properties for theming:
614
+
615
+ ```css
616
+ :root {
617
+ --uniface-toast-text-color: #ffffff;
618
+ --uniface-toast-error-background-color: #FF685B;
619
+ --uniface-toast-info-background-color: #0061FF;
620
+ --uniface-toast-successful-background-color: #2DC071;
621
+ }
622
+ ```
623
+
624
+ ### Custom Styling
625
+
626
+ ```css
627
+ /* Override toast colors */
628
+ :root {
629
+ --uniface-toast-error-background-color: #dc3545;
630
+ --uniface-toast-info-background-color: #17a2b8;
631
+ --uniface-toast-successful-background-color: #28a745;
632
+ }
633
+
634
+ /* Custom toast board styles */
635
+ .uniface-toast-board {
636
+ /* Your custom styles */
637
+ }
638
+ ```
639
+
640
+ ## Best Practices
641
+
642
+ 1. **Global Setup**: Include ToastBoard once in your root layout/app component
643
+ 2. **Message Clarity**: Use clear, concise messages that users can quickly understand
644
+ 3. **Duration**: Use longer durations for error messages, shorter for success
645
+ 4. **Type Consistency**: Use consistent toast types across your application
646
+ 5. **Positioning**: Choose top or bottom positioning based on your UI layout
647
+ 6. **Error Handling**: Always show toast feedback for async operations
648
+
649
+ ## Accessibility
650
+
651
+ - High contrast colors for readability
652
+ - Automatic dismissal prevents screen clutter
653
+ - Non-intrusive positioning
654
+ - Clear visual hierarchy with distinct colors
655
+
656
+ ## Browser Support
657
+
658
+ - Modern browsers with CSS custom properties support
659
+ - Compatible with Svelte 5+
660
+ - Smooth animations on supported browsers
661
+ - Graceful fallback for older browsers
662
+
663
+ ## Related Components
664
+
665
+ - `MessageBox` - Modal dialog for important messages
666
+ - `AlertBar` - Persistent alert notifications
667
+ - `NotificationCenter` - Advanced notification management