@stlhorizon/vue-ui 1.1.9 → 1.2.1
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/README.md +298 -1
- package/dist/index.esm.js +1829 -1719
- package/dist/index.js +16 -16
- package/dist/src/App.vue.d.ts.map +1 -1
- package/dist/src/components/Alert.vue.d.ts +2 -2
- package/dist/src/components/Badge.vue.d.ts +2 -2
- package/dist/src/components/Toast.vue.d.ts +14 -23
- package/dist/src/components/Toast.vue.d.ts.map +1 -1
- package/dist/src/components/icons.d.ts +3 -0
- package/dist/src/components/icons.d.ts.map +1 -1
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/lib/toast.d.ts +16 -0
- package/dist/src/lib/toast.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/vue-ui.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -333,4 +333,301 @@ npm run lint
|
|
|
333
333
|
|
|
334
334
|
## License
|
|
335
335
|
|
|
336
|
-
MIT
|
|
336
|
+
MIT
|
|
337
|
+
|
|
338
|
+
toast usage example in app.vue
|
|
339
|
+
<!-- Example App.vue setup -->
|
|
340
|
+
<template>
|
|
341
|
+
<div id="app">
|
|
342
|
+
<!-- Your application content -->
|
|
343
|
+
<div class="p-8 space-y-6">
|
|
344
|
+
<h1 class="text-3xl font-bold">Toast Examples - Sonner Style</h1>
|
|
345
|
+
|
|
346
|
+
<!-- Basic Usage -->
|
|
347
|
+
<section class="space-y-4">
|
|
348
|
+
<h2 class="text-xl font-semibold">Basic Usage</h2>
|
|
349
|
+
<div class="flex flex-wrap gap-2">
|
|
350
|
+
<button
|
|
351
|
+
@click="showBasicToast"
|
|
352
|
+
class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"
|
|
353
|
+
>
|
|
354
|
+
Basic Toast
|
|
355
|
+
</button>
|
|
356
|
+
|
|
357
|
+
<button
|
|
358
|
+
@click="showSuccessToast"
|
|
359
|
+
class="px-4 py-2 bg-green-500 text-white rounded hover:bg-green-600"
|
|
360
|
+
>
|
|
361
|
+
Success
|
|
362
|
+
</button>
|
|
363
|
+
|
|
364
|
+
<button
|
|
365
|
+
@click="showErrorToast"
|
|
366
|
+
class="px-4 py-2 bg-red-500 text-white rounded hover:bg-red-600"
|
|
367
|
+
>
|
|
368
|
+
Error
|
|
369
|
+
</button>
|
|
370
|
+
|
|
371
|
+
<button
|
|
372
|
+
@click="showWarningToast"
|
|
373
|
+
class="px-4 py-2 bg-yellow-500 text-white rounded hover:bg-yellow-600"
|
|
374
|
+
>
|
|
375
|
+
Warning
|
|
376
|
+
</button>
|
|
377
|
+
</div>
|
|
378
|
+
</section>
|
|
379
|
+
|
|
380
|
+
<!-- With Titles and Descriptions -->
|
|
381
|
+
<section class="space-y-4">
|
|
382
|
+
<h2 class="text-xl font-semibold">With Titles & Descriptions</h2>
|
|
383
|
+
<div class="flex flex-wrap gap-2">
|
|
384
|
+
<button
|
|
385
|
+
@click="showRichToast"
|
|
386
|
+
class="px-4 py-2 bg-purple-500 text-white rounded hover:bg-purple-600"
|
|
387
|
+
>
|
|
388
|
+
Rich Toast
|
|
389
|
+
</button>
|
|
390
|
+
|
|
391
|
+
<button
|
|
392
|
+
@click="showActionToast"
|
|
393
|
+
class="px-4 py-2 bg-indigo-500 text-white rounded hover:bg-indigo-600"
|
|
394
|
+
>
|
|
395
|
+
With Action
|
|
396
|
+
</button>
|
|
397
|
+
</div>
|
|
398
|
+
</section>
|
|
399
|
+
|
|
400
|
+
<!-- Promise Examples -->
|
|
401
|
+
<section class="space-y-4">
|
|
402
|
+
<h2 class="text-xl font-semibold">Promise Toasts</h2>
|
|
403
|
+
<div class="flex flex-wrap gap-2">
|
|
404
|
+
<button
|
|
405
|
+
@click="simulateSuccess"
|
|
406
|
+
class="px-4 py-2 bg-emerald-500 text-white rounded hover:bg-emerald-600"
|
|
407
|
+
>
|
|
408
|
+
Promise Success
|
|
409
|
+
</button>
|
|
410
|
+
|
|
411
|
+
<button
|
|
412
|
+
@click="simulateError"
|
|
413
|
+
class="px-4 py-2 bg-rose-500 text-white rounded hover:bg-rose-600"
|
|
414
|
+
>
|
|
415
|
+
Promise Error
|
|
416
|
+
</button>
|
|
417
|
+
|
|
418
|
+
<button
|
|
419
|
+
@click="simulateUpload"
|
|
420
|
+
class="px-4 py-2 bg-cyan-500 text-white rounded hover:bg-cyan-600"
|
|
421
|
+
>
|
|
422
|
+
File Upload
|
|
423
|
+
</button>
|
|
424
|
+
</div>
|
|
425
|
+
</section>
|
|
426
|
+
|
|
427
|
+
<!-- Advanced -->
|
|
428
|
+
<section class="space-y-4">
|
|
429
|
+
<h2 class="text-xl font-semibold">Advanced</h2>
|
|
430
|
+
<div class="flex flex-wrap gap-2">
|
|
431
|
+
<button
|
|
432
|
+
@click="showPersistent"
|
|
433
|
+
class="px-4 py-2 bg-gray-500 text-white rounded hover:bg-gray-600"
|
|
434
|
+
>
|
|
435
|
+
Persistent
|
|
436
|
+
</button>
|
|
437
|
+
|
|
438
|
+
<button
|
|
439
|
+
@click="showCustomDuration"
|
|
440
|
+
class="px-4 py-2 bg-orange-500 text-white rounded hover:bg-orange-600"
|
|
441
|
+
>
|
|
442
|
+
10s Duration
|
|
443
|
+
</button>
|
|
444
|
+
|
|
445
|
+
<button
|
|
446
|
+
@click="toast.dismissAll"
|
|
447
|
+
class="px-4 py-2 bg-gray-700 text-white rounded hover:bg-gray-800"
|
|
448
|
+
>
|
|
449
|
+
Clear All
|
|
450
|
+
</button>
|
|
451
|
+
</div>
|
|
452
|
+
</section>
|
|
453
|
+
|
|
454
|
+
<!-- Real-world Examples -->
|
|
455
|
+
<section class="space-y-4">
|
|
456
|
+
<h2 class="text-xl font-semibold">Real-world Examples</h2>
|
|
457
|
+
<div class="space-y-2">
|
|
458
|
+
<button
|
|
459
|
+
@click="handleFormSubmit"
|
|
460
|
+
class="block px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700"
|
|
461
|
+
>
|
|
462
|
+
Submit Form
|
|
463
|
+
</button>
|
|
464
|
+
|
|
465
|
+
<button
|
|
466
|
+
@click="handleFileUpload"
|
|
467
|
+
class="block px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700"
|
|
468
|
+
>
|
|
469
|
+
Upload File
|
|
470
|
+
</button>
|
|
471
|
+
|
|
472
|
+
<button
|
|
473
|
+
@click="handleDeleteItem"
|
|
474
|
+
class="block px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700"
|
|
475
|
+
>
|
|
476
|
+
Delete Item
|
|
477
|
+
</button>
|
|
478
|
+
</div>
|
|
479
|
+
</section>
|
|
480
|
+
</div>
|
|
481
|
+
|
|
482
|
+
<!-- Toaster component - add once in your root -->
|
|
483
|
+
<Toaster
|
|
484
|
+
position="bottom-center"
|
|
485
|
+
:rich-colors="true"
|
|
486
|
+
:close-button="true"
|
|
487
|
+
/>
|
|
488
|
+
</div>
|
|
489
|
+
</template>
|
|
490
|
+
|
|
491
|
+
<script setup>
|
|
492
|
+
import { toast } from './lib/toast.js'
|
|
493
|
+
import Toaster from './components/Toast.vue'
|
|
494
|
+
|
|
495
|
+
// Basic examples
|
|
496
|
+
const showBasicToast = () => {
|
|
497
|
+
toast("Hello World!")
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
const showSuccessToast = () => {
|
|
501
|
+
toast.success("Operation completed successfully!")
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
const showErrorToast = () => {
|
|
505
|
+
toast.error("Something went wrong!")
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
const showWarningToast = () => {
|
|
509
|
+
toast.warning("Please check your input")
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// Rich content
|
|
513
|
+
const showRichToast = () => {
|
|
514
|
+
toast.success("Profile updated", {
|
|
515
|
+
title: "Success",
|
|
516
|
+
description: "Your profile has been updated successfully.",
|
|
517
|
+
duration: 6000
|
|
518
|
+
})
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
const showActionToast = () => {
|
|
522
|
+
toast("Event has been created", {
|
|
523
|
+
action: {
|
|
524
|
+
label: "Undo",
|
|
525
|
+
onClick: () => toast.info("Undo clicked!")
|
|
526
|
+
}
|
|
527
|
+
})
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// Promise examples
|
|
531
|
+
const simulateSuccess = () => {
|
|
532
|
+
const promise = new Promise((resolve) => {
|
|
533
|
+
setTimeout(() => resolve({ name: "John Doe" }), 2000)
|
|
534
|
+
})
|
|
535
|
+
|
|
536
|
+
toast.promise(promise, {
|
|
537
|
+
loading: "Loading user data...",
|
|
538
|
+
success: (data) => `Welcome ${data.name}!`,
|
|
539
|
+
error: "Failed to load user"
|
|
540
|
+
})
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
const simulateError = () => {
|
|
544
|
+
const promise = new Promise((_, reject) => {
|
|
545
|
+
setTimeout(() => reject(new Error("Network timeout")), 2000)
|
|
546
|
+
})
|
|
547
|
+
|
|
548
|
+
toast.promise(promise, {
|
|
549
|
+
loading: "Connecting...",
|
|
550
|
+
success: "Connected successfully!",
|
|
551
|
+
error: (err) => `Connection failed: ${err.message}`
|
|
552
|
+
})
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
const simulateUpload = () => {
|
|
556
|
+
const promise = new Promise((resolve) => {
|
|
557
|
+
setTimeout(() => resolve(), 3000)
|
|
558
|
+
})
|
|
559
|
+
|
|
560
|
+
toast.promise(promise, {
|
|
561
|
+
loading: "Uploading file...",
|
|
562
|
+
success: "File uploaded successfully!",
|
|
563
|
+
error: "Upload failed"
|
|
564
|
+
})
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// Advanced
|
|
568
|
+
const showPersistent = () => {
|
|
569
|
+
toast.info("This stays until dismissed", {
|
|
570
|
+
duration: 0,
|
|
571
|
+
title: "Persistent Notification"
|
|
572
|
+
})
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
const showCustomDuration = () => {
|
|
576
|
+
toast.warning("This will stay for 10 seconds", {
|
|
577
|
+
duration: 10000
|
|
578
|
+
})
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// Real-world examples matching your use case
|
|
582
|
+
const handleFormSubmit = () => {
|
|
583
|
+
// Simulate validation
|
|
584
|
+
const validationInfo = { isValid: Math.random() > 0.3 }
|
|
585
|
+
|
|
586
|
+
if (!validationInfo.isValid) {
|
|
587
|
+
toast.error("Please select a vehicle that can accommodate your passenger and luggage requirements.")
|
|
588
|
+
return
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
// Simulate form submission
|
|
592
|
+
const submitPromise = new Promise((resolve) => {
|
|
593
|
+
setTimeout(() => resolve(), 2000)
|
|
594
|
+
})
|
|
595
|
+
|
|
596
|
+
toast.promise(submitPromise, {
|
|
597
|
+
loading: "Submitting form...",
|
|
598
|
+
success: "Form submitted successfully!",
|
|
599
|
+
error: "Failed to submit form"
|
|
600
|
+
})
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
const handleFileUpload = () => {
|
|
604
|
+
const uploadPromise = new Promise((resolve, reject) => {
|
|
605
|
+
setTimeout(() => {
|
|
606
|
+
if (Math.random() > 0.5) {
|
|
607
|
+
resolve({ filename: "document.pdf", size: "2.3MB" })
|
|
608
|
+
} else {
|
|
609
|
+
reject(new Error("File too large"))
|
|
610
|
+
}
|
|
611
|
+
}, 1500)
|
|
612
|
+
})
|
|
613
|
+
|
|
614
|
+
toast.promise(uploadPromise, {
|
|
615
|
+
loading: "Uploading file...",
|
|
616
|
+
success: (data) => `${data.filename} (${data.size}) uploaded successfully!`,
|
|
617
|
+
error: (err) => `Upload failed: ${err.message}`
|
|
618
|
+
})
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
const handleDeleteItem = () => {
|
|
622
|
+
toast.error("Item will be deleted permanently", {
|
|
623
|
+
title: "Are you sure?",
|
|
624
|
+
action: {
|
|
625
|
+
label: "Delete",
|
|
626
|
+
onClick: () => {
|
|
627
|
+
toast.success("Item deleted successfully")
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
})
|
|
631
|
+
}
|
|
632
|
+
</script>
|
|
633
|
+
|