@sveltia/ui 0.81.1 → 0.81.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.
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Version of this package, used to resolve the prebuilt Shiki engine chunk from a CDN.
3
3
  */
4
- export const UI_VERSION: "0.81.1";
4
+ export const UI_VERSION: "0.81.2";
@@ -3,4 +3,4 @@
3
3
  /**
4
4
  * Version of this package, used to resolve the prebuilt Shiki engine chunk from a CDN.
5
5
  */
6
- export const UI_VERSION = '0.81.1';
6
+ export const UI_VERSION = '0.81.2';
@@ -74,6 +74,30 @@
74
74
  return true;
75
75
  };
76
76
 
77
+ /**
78
+ * Get the lane in the toast base for the toasts at the given position, creating it if needed.
79
+ * The toasts at the same position are stacked in their lane rather than laid on top of each
80
+ * other.
81
+ * @param {HTMLElement} base Toast base.
82
+ * @param {string} position Toast position, e.g. `bottom-right`.
83
+ * @returns {HTMLElement} Lane.
84
+ */
85
+ const getLane = (base, position) => {
86
+ let lane = /** @type {HTMLElement[]} */ ([...base.children]).find(
87
+ (child) => child.dataset.position === position,
88
+ );
89
+
90
+ if (!lane) {
91
+ lane = document.createElement('div');
92
+ lane.setAttribute('role', 'none');
93
+ lane.className = `toast-lane ${position}`;
94
+ lane.dataset.position = position;
95
+ base.appendChild(lane);
96
+ }
97
+
98
+ return lane;
99
+ };
100
+
77
101
  /**
78
102
  * Toast base shared by all the toasts. It’s created by the first toast mounted and removed with
79
103
  * the last one unmounted, rather than rendered by a component, so it doesn’t go away with the
@@ -292,7 +316,16 @@
292
316
 
293
317
  // Make sure the base is in the topmost modal dialog, in case a dialog event has been missed
294
318
  moveBase(popover);
295
- popover.appendChild(toast);
319
+
320
+ // The newest toast goes next to the edge of the screen: last at the bottom, first at the top
321
+ const lane = getLane(popover, position);
322
+
323
+ if (position.startsWith('top-')) {
324
+ lane.prepend(toast);
325
+ } else {
326
+ lane.append(toast);
327
+ }
328
+
296
329
  raiseBase(popover);
297
330
  });
298
331
 
@@ -362,11 +395,6 @@
362
395
  position: fixed;
363
396
  inset: 16px;
364
397
  z-index: 99999;
365
- display: flex;
366
- flex-direction: column;
367
- justify-content: flex-end;
368
- align-items: flex-end;
369
- gap: 8px;
370
398
  overflow: visible;
371
399
  margin: 0;
372
400
  border: 0;
@@ -387,10 +415,38 @@
387
415
  bottom: calc(var(--sui-bottom-navigation-height) + 16px);
388
416
  }
389
417
 
390
- .toast {
418
+ :global(.sui.toast-base) > :global(.toast-lane) {
391
419
  position: absolute;
420
+ display: flex;
421
+ flex-direction: column;
422
+ margin-block: -4px;
423
+ max-width: 100%;
424
+ }
425
+ :global(.sui.toast-base) > :global(.toast-lane.top-left), :global(.sui.toast-base) > :global(.toast-lane.top-center), :global(.sui.toast-base) > :global(.toast-lane.top-right) {
426
+ inset-block-start: 0;
427
+ }
428
+ :global(.sui.toast-base) > :global(.toast-lane.bottom-left), :global(.sui.toast-base) > :global(.toast-lane.bottom-center), :global(.sui.toast-base) > :global(.toast-lane.bottom-right) {
429
+ inset-block-end: 0;
430
+ }
431
+ :global(.sui.toast-base) > :global(.toast-lane.top-left), :global(.sui.toast-base) > :global(.toast-lane.bottom-left) {
432
+ inset-inline-start: 0;
433
+ align-items: flex-start;
434
+ }
435
+ :global(.sui.toast-base) > :global(.toast-lane.top-center), :global(.sui.toast-base) > :global(.toast-lane.bottom-center) {
436
+ inset-inline: 0;
437
+ align-items: center;
438
+ }
439
+ :global(.sui.toast-base) > :global(.toast-lane.top-right), :global(.sui.toast-base) > :global(.toast-lane.bottom-right) {
440
+ inset-inline-end: 0;
441
+ align-items: flex-end;
442
+ }
443
+
444
+ .toast {
445
+ margin-block: 4px;
392
446
  width: max-content;
393
447
  max-width: 80dvw;
448
+ height: auto;
449
+ overflow: clip;
394
450
  opacity: 1;
395
451
  transition-duration: 250ms;
396
452
  will-change: opacity;
@@ -408,54 +464,21 @@
408
464
  opacity: 0;
409
465
  pointer-events: none;
410
466
  }
411
- .toast.top-left {
412
- inset-block-start: 0;
413
- inset-block-end: auto;
414
- inset-inline-start: 0;
415
- inset-inline-end: auto;
416
- }
417
- .toast.top-center {
418
- inset-block-start: 0;
419
- inset-block-end: auto;
420
- inset-inline-start: 50%;
421
- inset-inline-end: auto;
422
- }
423
- .toast.top-center:dir(ltr) {
424
- transform: translateX(-50%);
425
- }
426
- .toast.top-center:dir(rtl) {
427
- transform: translateX(50%);
428
- }
429
- .toast.top-right {
430
- inset-block-start: 0;
431
- inset-block-end: auto;
432
- inset-inline-start: auto;
433
- inset-inline-end: 0;
434
- }
435
- .toast.bottom-left {
436
- inset-block-start: auto;
437
- inset-block-end: 0;
438
- inset-inline-start: 0;
439
- inset-inline-end: auto;
440
- }
441
- .toast.bottom-center {
442
- inset-block-start: auto;
443
- inset-block-end: 0;
444
- inset-inline-start: 50%;
445
- inset-inline-end: auto;
446
- }
447
- .toast.bottom-center:dir(ltr) {
448
- transform: translateX(-50%);
449
- }
450
- .toast.bottom-center:dir(rtl) {
451
- transform: translateX(50%);
452
- }
453
- .toast.bottom-right {
454
- inset-block-start: auto;
455
- inset-block-end: 0;
456
- inset-inline-start: auto;
457
- inset-inline-end: 0;
467
+ @supports (interpolate-size: allow-keywords) {
468
+ .toast {
469
+ interpolate-size: allow-keywords;
470
+ }
471
+ @starting-style {
472
+ .toast {
473
+ margin-block: 0;
474
+ height: 0;
475
+ }
476
+ }
477
+ .toast[aria-hidden=true] {
478
+ margin-block: 0;
479
+ height: 0;
480
+ }
458
481
  }
459
- .toast :global(.alert) {
460
- box-shadow: 0 8px 16px var(--sui-popup-shadow-color);
482
+ .toast:has(:global(.alert)) {
483
+ filter: drop-shadow(0 8px 8px var(--sui-popup-shadow-color));
461
484
  }</style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltia/ui",
3
- "version": "0.81.1",
3
+ "version": "0.81.2",
4
4
  "description": "A collection of Svelte components and utilities for building user interfaces.",
5
5
  "repository": {
6
6
  "type": "git",