(toasts: ReadonlyArray<Entry>, limit: number)
| 806 | // of the toasts in front of it, its own height, and whether it's past the |
| 807 | // limit. A closing toast keeps its place in the list but leaves the count. |
| 808 | const stackOf = (toasts: ReadonlyArray<Entry>, limit: number) => { |
| 809 | const stack = new Map< |
| 810 | string, |
| 811 | { |
| 812 | readonly index: number |
| 813 | readonly offset: number |
| 814 | readonly height: number |
| 815 | readonly limited: boolean |
| 816 | } |
| 817 | >() |
| 818 | let visible = 0 |
| 819 | let offset = 0 |
| 820 | toasts.forEach((toast, index) => { |
| 821 | const ending = toast.transition === "ending" |
| 822 | const limited = !ending && visible >= limit |
| 823 | stack.set(toast.id, { |
| 824 | index: ending ? index : visible, |
| 825 | offset, |
| 826 | height: toast.height, |
| 827 | limited |
| 828 | }) |
| 829 | offset += toast.height |
| 830 | if (!ending) visible += 1 |
| 831 | }) |
| 832 | return stack |
| 833 | } |
| 834 | |
| 835 | // `$` in any handler of the provider's `update`: a tag's `$` fits the one |
| 836 | // over the whole message type. |
no test coverage detected