@esportsplus/ui 0.51.7 → 0.54.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.
- package/README.md +53 -9
- package/build/components/accordion/index.d.ts +6 -18
- package/build/components/accordion/index.js +10 -36
- package/build/components/accordion/scss/index.scss +1 -1
- package/build/components/anchor/scss/index.scss +1 -1
- package/build/components/button/scss/index.scss +1 -1
- package/build/components/card/scss/index.scss +1 -1
- package/build/components/checkbox/index.d.ts +12 -12
- package/build/components/checkbox/index.js +63 -31
- package/build/components/checkbox/scss/index.scss +1 -1
- package/build/components/checkbox/svg/check.svg +1 -0
- package/build/components/clipboard/copy.d.ts +11 -0
- package/build/components/clipboard/copy.js +49 -0
- package/build/components/clipboard/index.d.ts +1437 -1228
- package/build/components/clipboard/index.js +3 -1
- package/build/components/clipboard/onclick.d.ts +4 -38
- package/build/components/clipboard/onclick.js +10 -10
- package/build/components/counter/index.js +58 -66
- package/build/components/counter/scss/index.scss +1 -1
- package/build/components/form/action.js +8 -8
- package/build/components/form/index.d.ts +4 -4
- package/build/components/form/input.d.ts +4 -4
- package/build/components/form/input.js +3 -3
- package/build/components/grid/scss/index.scss +1 -1
- package/build/components/icon/index.d.ts +2 -19
- package/build/components/icon/index.js +8 -8
- package/build/components/icon/scss/index.scss +1 -1
- package/build/components/index.d.ts +1 -11
- package/build/components/index.js +1 -11
- package/build/components/input/index.d.ts +1 -1
- package/build/components/input/index.js +11 -11
- package/build/components/input/scss/index.scss +1 -1
- package/build/components/link/scss/index.scss +1 -1
- package/build/components/loading/index.js +5 -5
- package/build/components/modal/scss/index.scss +1 -1
- package/build/components/normalize/scss/index.scss +1 -1
- package/build/components/overlay/index.d.ts +2 -18
- package/build/components/overlay/index.js +11 -5
- package/build/components/overlay/scss/index.scss +1 -1
- package/build/components/page/scss/index.scss +1 -1
- package/build/components/radio/index.d.ts +1436 -4
- package/build/components/radio/index.js +0 -1
- package/build/components/range/index.d.ts +1 -1
- package/build/components/range/index.js +13 -13
- package/build/components/range/scss/index.scss +1 -1
- package/build/components/root/scss/index.scss +1 -1
- package/build/components/select/index.d.ts +7 -53
- package/build/components/select/index.js +82 -100
- package/build/components/select/scss/index.scss +1 -1
- package/build/components/sidebar/index.d.ts +2 -18
- package/build/components/sidebar/index.js +11 -5
- package/build/components/sidebar/scss/index.scss +1 -1
- package/build/components/switch/index.d.ts +1436 -4
- package/build/components/switch/index.js +0 -1
- package/build/components/tabs/scss/index.scss +2 -0
- package/build/components/text/scss/index.scss +1 -1
- package/build/components/textarea/index.d.ts +719 -6
- package/build/components/textarea/index.js +37 -15
- package/build/components/textarea/scss/index.scss +1 -1
- package/build/components/toast/index.d.ts +9 -0
- package/build/components/toast/index.js +157 -0
- package/build/components/toast/manager.d.ts +60 -0
- package/build/components/toast/manager.js +203 -0
- package/build/components/toast/scss/index.scss +2 -0
- package/build/components/toast/svg/check.svg +1 -0
- package/build/components/toast/svg/chevron.svg +1 -0
- package/build/components/toast/svg/close.svg +1 -0
- package/build/components/toast/svg/copy.svg +1 -0
- package/build/components/toast/svg/error.svg +1 -0
- package/build/components/toast/svg/info.svg +1 -0
- package/build/components/toast/svg/loading.svg +1 -0
- package/build/components/toast/svg/success.svg +1 -0
- package/build/components/toast/svg/warning.svg +1 -0
- package/build/components/tooltip/index.d.ts +2151 -2544
- package/build/components/tooltip/menu.d.ts +2 -18
- package/build/components/tooltip/menu.js +38 -24
- package/build/components/tooltip/onclick.d.ts +717 -1229
- package/build/components/tooltip/onclick.js +18 -54
- package/build/components/tooltip/onhover.d.ts +713 -20
- package/build/components/tooltip/onhover.js +11 -11
- package/build/components/tooltip/scss/index.scss +1 -1
- package/build/components/typewriter/index.d.ts +2 -19
- package/build/components/typewriter/index.js +10 -10
- package/build/css-utilities/background/scss/index.scss +1 -1
- package/build/css-utilities/border/scss/index.scss +1 -1
- package/build/css-utilities/color/scss/index.scss +1 -1
- package/build/css-utilities/font/geist/scss/Geist-Italic-Variable.woff2 +0 -0
- package/build/css-utilities/font/geist/scss/Geist-Variable.woff2 +0 -0
- package/build/css-utilities/font/geist/scss/GeistMono-Italic-Variable.woff2 +0 -0
- package/build/css-utilities/font/geist/scss/GeistMono-Variable.woff2 +0 -0
- package/build/css-utilities/font/geist/scss/index.scss +2 -0
- package/build/css-utilities/font/montserrat/index.d.ts +1 -0
- package/build/css-utilities/font/montserrat/index.js +1 -0
- package/build/css-utilities/font/montserrat/scss/index.scss +2 -0
- package/build/css-utilities/index.scss +1 -1
- package/build/css-utilities/inline/scss/index.scss +1 -1
- package/build/css-utilities/scrollbar/scss/index.scss +2 -0
- package/build/css-utilities/tabular/scss/index.scss +2 -0
- package/build/css-utilities/text/scss/index.scss +1 -1
- package/build/themes/dark/index.d.ts +0 -2
- package/build/themes/dark/index.js +0 -2
- package/build/themes/dark/input.d.ts +708 -114
- package/build/themes/dark/select.d.ts +732 -1456
- package/build/themes/dark/select.js +7 -5
- package/build/themes/dark/textarea.d.ts +716 -119
- package/package.json +20 -20
- package/pnpm-workspace.yaml +12 -8
- package/scripts/css-variables.test.mjs +50 -0
- package/scripts/sort-scss.md +57 -0
- package/scripts/sort-scss.mjs +233 -0
- package/scripts/sort-scss.test.mjs +217 -0
- package/src/components/accordion/index.ts +7 -30
- package/src/components/accordion/scss/index.scss +9 -12
- package/src/components/anchor/scss/index.scss +2 -2
- package/src/components/button/scss/index.scss +23 -57
- package/src/components/button/scss/variables.scss +1 -19
- package/src/components/card/scss/index.scss +11 -46
- package/src/components/card/scss/variables.scss +1 -2
- package/src/components/checkbox/index.ts +27 -26
- package/src/components/checkbox/scss/index.scss +86 -28
- package/src/components/checkbox/scss/variables.scss +71 -30
- package/src/components/checkbox/svg/check.svg +1 -0
- package/src/components/clipboard/copy.ts +60 -0
- package/src/components/clipboard/index.ts +3 -1
- package/src/components/clipboard/onclick.ts +3 -4
- package/src/components/counter/index.ts +57 -57
- package/src/components/counter/scss/index.scss +4 -5
- package/src/components/counter/scss/variables.scss +0 -1
- package/src/components/form/input.ts +6 -5
- package/src/components/grid/scss/index.scss +1 -1
- package/src/components/icon/index.ts +2 -3
- package/src/components/icon/scss/variables.scss +0 -1
- package/src/components/index.ts +2 -12
- package/src/components/input/index.ts +1 -1
- package/src/components/input/scss/index.scss +8 -7
- package/src/components/input/scss/variables.scss +0 -1
- package/src/components/link/scss/index.scss +9 -34
- package/src/components/link/scss/variables.scss +0 -12
- package/src/components/modal/scss/index.scss +4 -4
- package/src/components/normalize/scss/index.scss +0 -1
- package/src/components/overlay/index.ts +9 -5
- package/src/components/overlay/scss/index.scss +0 -1
- package/src/components/page/scss/index.scss +1 -7
- package/src/components/page/scss/variables.scss +0 -2
- package/src/components/radio/index.ts +0 -1
- package/src/components/range/index.ts +1 -1
- package/src/components/range/scss/index.scss +5 -5
- package/src/components/root/scss/index.scss +44 -39
- package/src/components/root/scss/variables.scss +38 -69
- package/src/components/select/index.ts +80 -109
- package/src/components/select/scss/index.scss +10 -7
- package/src/components/select/scss/variables.scss +0 -1
- package/src/components/sidebar/index.ts +9 -5
- package/src/components/sidebar/scss/index.scss +3 -4
- package/src/components/switch/index.ts +1 -2
- package/src/components/tabs/scss/index.scss +62 -0
- package/src/components/tabs/scss/variables.scss +4 -0
- package/src/components/text/scss/index.scss +8 -1
- package/src/components/text/scss/variables.scss +5 -3
- package/src/components/textarea/index.ts +38 -5
- package/src/components/textarea/scss/index.scss +24 -13
- package/src/components/textarea/scss/variables.scss +0 -1
- package/src/components/toast/index.ts +188 -0
- package/src/components/toast/manager.ts +312 -0
- package/src/components/toast/scss/index.scss +276 -0
- package/src/components/toast/scss/variables.scss +19 -0
- package/src/components/toast/svg/check.svg +1 -0
- package/src/components/toast/svg/chevron.svg +1 -0
- package/src/components/toast/svg/close.svg +1 -0
- package/src/components/toast/svg/copy.svg +1 -0
- package/src/components/toast/svg/error.svg +1 -0
- package/src/components/toast/svg/info.svg +1 -0
- package/src/components/toast/svg/loading.svg +1 -0
- package/src/components/toast/svg/success.svg +1 -0
- package/src/components/toast/svg/warning.svg +1 -0
- package/src/components/tooltip/menu.ts +8 -4
- package/src/components/tooltip/onclick.ts +13 -70
- package/src/components/tooltip/onhover.ts +2 -3
- package/src/components/tooltip/scss/index.scss +2 -3
- package/src/components/typewriter/index.ts +2 -3
- package/src/css-utilities/background/scss/variables.scss +2 -2
- package/src/css-utilities/border/scss/index.scss +1 -27
- package/src/css-utilities/border/scss/variables.scss +3 -34
- package/src/css-utilities/color/scss/variables.scss +2 -6
- package/src/css-utilities/font/geist/scss/Geist-Italic-Variable.woff2 +0 -0
- package/src/css-utilities/font/geist/scss/Geist-Variable.woff2 +0 -0
- package/src/css-utilities/font/geist/scss/GeistMono-Italic-Variable.woff2 +0 -0
- package/src/css-utilities/font/geist/scss/GeistMono-Variable.woff2 +0 -0
- package/src/css-utilities/font/geist/scss/index.scss +55 -0
- package/src/css-utilities/font/montserrat/index.ts +1 -0
- package/src/{fonts → css-utilities/font}/montserrat/scss/index.scss +15 -0
- package/src/css-utilities/index.scss +7 -12
- package/src/css-utilities/inline/scss/index.scss +0 -1
- package/src/css-utilities/scrollbar/scss/index.scss +95 -0
- package/src/css-utilities/scrollbar/scss/variables.scss +5 -0
- package/src/css-utilities/tabular/scss/index.scss +3 -0
- package/src/css-utilities/text/scss/index.scss +30 -71
- package/src/lib/scss/css-variables.scss +29 -5
- package/src/themes/dark/index.ts +0 -2
- package/src/themes/dark/select.ts +7 -5
- package/src/tokens/index.scss +1 -3
- package/src/tokens/scss/border-radius.scss +1 -6
- package/src/tokens/scss/color.scss +14 -14
- package/src/tokens/scss/font-size.scss +12 -11
- package/src/tokens/scss/scale.scss +22 -0
- package/src/tokens/scss/size.scss +19 -9
- package/src/tokens/scss/spacer.scss +9 -9
- package/src/tokens/scss/transition.scss +4 -0
- package/storage/svg/arrow-left.svg +1 -0
- package/storage/svg/arrow-right.svg +1 -0
- package/storage/svg/bolt.svg +1 -0
- package/storage/svg/book.svg +1 -0
- package/storage/svg/cube.svg +1 -0
- package/storage/svg/github.svg +1 -0
- package/storage/svg/info.svg +1 -0
- package/storage/svg/palette.svg +1 -0
- package/storage/svg/search.svg +2 -0
- package/storage/svg/star.svg +1 -0
- package/storage/svg/type.svg +1 -0
- package/tsconfig.json +6 -2
- package/vite-env.d.ts +1 -0
- package/vite.config.ts +78 -72
- package/build/components/alert/index.d.ts +0 -19
- package/build/components/alert/index.js +0 -151
- package/build/components/alert/scss/index.scss +0 -2
- package/build/components/alert/svg/check.svg +0 -11
- package/build/components/alert/svg/close.svg +0 -12
- package/build/components/alert/svg/error.svg +0 -18
- package/build/components/back/index.d.ts +0 -18
- package/build/components/back/index.js +0 -16
- package/build/components/back/scss/index.scss +0 -2
- package/build/components/back/svg/arrow.svg +0 -15
- package/build/components/bubble/scss/index.scss +0 -2
- package/build/components/button/index.d.ts +0 -103
- package/build/components/button/index.js +0 -60
- package/build/components/ellipsis/index.d.ts +0 -4
- package/build/components/ellipsis/index.js +0 -8
- package/build/components/ellipsis/scss/index.scss +0 -2
- package/build/components/frame/index.d.ts +0 -20
- package/build/components/frame/index.js +0 -7
- package/build/components/frame/scss/index.scss +0 -2
- package/build/components/highlight/index.d.ts +0 -22
- package/build/components/highlight/index.js +0 -56
- package/build/components/highlight/scss/index.scss +0 -2
- package/build/components/loader/index.d.ts +0 -22
- package/build/components/loader/index.js +0 -78
- package/build/components/loader/scss/index.scss +0 -2
- package/build/components/radio/scss/index.scss +0 -2
- package/build/components/root/index.d.ts +0 -7
- package/build/components/root/index.js +0 -4
- package/build/components/root/onclick.d.ts +0 -5
- package/build/components/root/onclick.js +0 -12
- package/build/components/scrollbar/index.d.ts +0 -27
- package/build/components/scrollbar/index.js +0 -56
- package/build/components/scrollbar/scss/index.scss +0 -2
- package/build/components/site/index.d.ts +0 -20
- package/build/components/site/index.js +0 -9
- package/build/components/site/scss/index.scss +0 -2
- package/build/components/switch/scss/index.scss +0 -2
- package/build/components/template/index.d.ts +0 -14
- package/build/components/template/index.js +0 -21
- package/build/css-utilities/[margin,padding]/scss/index.scss +0 -2
- package/build/css-utilities/error/scss/index.scss +0 -2
- package/build/css-utilities/flicker/scss/index.scss +0 -2
- package/build/css-utilities/focus/scss/index.scss +0 -2
- package/build/css-utilities/gap/scss/index.scss +0 -2
- package/build/css-utilities/line-height/scss/index.scss +0 -2
- package/build/css-utilities/pointer/scss/index.scss +0 -2
- package/build/css-utilities/scroller/scss/index.scss +0 -2
- package/build/css-utilities/size/scss/index.scss +0 -2
- package/build/css-utilities/viewport/scss/index.scss +0 -2
- package/build/css-utilities/width/scss/index.scss +0 -2
- package/build/fonts/index.d.ts +0 -1
- package/build/fonts/index.js +0 -1
- package/build/fonts/montserrat/scss/index.scss +0 -2
- package/build/themes/dark/alert.d.ts +0 -11
- package/build/themes/dark/alert.js +0 -20
- package/build/themes/dark/back.d.ts +0 -15
- package/build/themes/dark/back.js +0 -7
- package/build/themes/dark/button/scss/index.scss +0 -2
- package/build/themes/dark/link/scss/index.scss +0 -2
- package/src/components/accordion/scss/variables.scss +0 -9
- package/src/components/alert/index.ts +0 -165
- package/src/components/alert/scss/index.scss +0 -25
- package/src/components/alert/scss/variables.scss +0 -3
- package/src/components/alert/svg/check.svg +0 -11
- package/src/components/alert/svg/close.svg +0 -12
- package/src/components/alert/svg/error.svg +0 -18
- package/src/components/back/index.ts +0 -21
- package/src/components/back/scss/index.scss +0 -17
- package/src/components/back/svg/arrow.svg +0 -15
- package/src/components/bubble/scss/index.scss +0 -32
- package/src/components/bubble/scss/variables.scss +0 -20
- package/src/components/button/index.ts +0 -54
- package/src/components/ellipsis/index.ts +0 -11
- package/src/components/ellipsis/scss/index.scss +0 -30
- package/src/components/ellipsis/scss/variables.scss +0 -5
- package/src/components/frame/index.ts +0 -9
- package/src/components/frame/scss/index.scss +0 -39
- package/src/components/frame/scss/variables.scss +0 -4
- package/src/components/highlight/index.ts +0 -67
- package/src/components/highlight/scss/index.scss +0 -7
- package/src/components/highlight/scss/variables.scss +0 -4
- package/src/components/loader/index.ts +0 -81
- package/src/components/loader/scss/index.scss +0 -71
- package/src/components/loader/scss/variables.scss +0 -6
- package/src/components/radio/scss/index.scss +0 -50
- package/src/components/radio/scss/variables.scss +0 -67
- package/src/components/root/index.ts +0 -6
- package/src/components/root/onclick.ts +0 -20
- package/src/components/scrollbar/index.ts +0 -70
- package/src/components/scrollbar/scss/index.scss +0 -82
- package/src/components/scrollbar/scss/variables.scss +0 -6
- package/src/components/site/index.ts +0 -11
- package/src/components/site/scss/index.scss +0 -3
- package/src/components/switch/scss/index.scss +0 -48
- package/src/components/switch/scss/variables.scss +0 -74
- package/src/components/template/index.ts +0 -40
- package/src/css-utilities/[margin,padding]/scss/index.scss +0 -43
- package/src/css-utilities/[margin,padding]/scss/variables.scss +0 -54
- package/src/css-utilities/error/scss/index.scss +0 -24
- package/src/css-utilities/error/scss/variables.scss +0 -3
- package/src/css-utilities/flicker/scss/index.scss +0 -15
- package/src/css-utilities/flicker/scss/variables.scss +0 -5
- package/src/css-utilities/focus/scss/index.scss +0 -7
- package/src/css-utilities/focus/scss/variables.scss +0 -5
- package/src/css-utilities/gap/scss/index.scss +0 -13
- package/src/css-utilities/gap/scss/variables.scss +0 -39
- package/src/css-utilities/line-height/scss/index.scss +0 -1
- package/src/css-utilities/line-height/scss/variables.scss +0 -10
- package/src/css-utilities/pointer/scss/index.scss +0 -5
- package/src/css-utilities/scroller/scss/index.scss +0 -8
- package/src/css-utilities/scroller/scss/variables.scss +0 -4
- package/src/css-utilities/size/scss/index.scss +0 -1
- package/src/css-utilities/size/scss/variables.scss +0 -12
- package/src/css-utilities/text/scss/variables.scss +0 -31
- package/src/css-utilities/viewport/scss/index.scss +0 -5
- package/src/css-utilities/width/scss/index.scss +0 -5
- package/src/css-utilities/width/scss/variables.scss +0 -9
- package/src/fonts/index.ts +0 -1
- package/src/themes/dark/alert.ts +0 -23
- package/src/themes/dark/back.ts +0 -9
- package/src/themes/dark/button/scss/index.scss +0 -46
- package/src/themes/dark/link/scss/index.scss +0 -26
- package/src/tokens/scss/font-weight.scss +0 -6
- package/src/tokens/scss/line-height.scss +0 -6
- package/src/tokens/scss/transition-duration.scss +0 -1
- /package/build/{fonts/montserrat → css-utilities/font/geist}/index.d.ts +0 -0
- /package/build/{fonts/montserrat → css-utilities/font/geist}/index.js +0 -0
- /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Bold.woff +0 -0
- /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Bold.woff2 +0 -0
- /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-BoldItalic.woff +0 -0
- /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-BoldItalic.woff2 +0 -0
- /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Italic.woff +0 -0
- /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Italic.woff2 +0 -0
- /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Medium.woff +0 -0
- /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Medium.woff2 +0 -0
- /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-MediumItalic.woff +0 -0
- /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-MediumItalic.woff2 +0 -0
- /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Regular.woff +0 -0
- /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Regular.woff2 +0 -0
- /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-SemiBold.woff +0 -0
- /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-SemiBold.woff2 +0 -0
- /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-SemiBoldItalic.woff +0 -0
- /package/build/{fonts → css-utilities/font}/montserrat/scss/Montserrat-SemiBoldItalic.woff2 +0 -0
- /package/src/{fonts/montserrat → css-utilities/font/geist}/index.ts +0 -0
- /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Bold.woff +0 -0
- /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Bold.woff2 +0 -0
- /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-BoldItalic.woff +0 -0
- /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-BoldItalic.woff2 +0 -0
- /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Italic.woff +0 -0
- /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Italic.woff2 +0 -0
- /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Medium.woff +0 -0
- /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Medium.woff2 +0 -0
- /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-MediumItalic.woff +0 -0
- /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-MediumItalic.woff2 +0 -0
- /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Regular.woff +0 -0
- /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-Regular.woff2 +0 -0
- /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-SemiBold.woff +0 -0
- /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-SemiBold.woff2 +0 -0
- /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-SemiBoldItalic.woff +0 -0
- /package/src/{fonts → css-utilities/font}/montserrat/scss/Montserrat-SemiBoldItalic.woff2 +0 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { effect, reactive, ReactiveArray } from '@esportsplus/reactivity';
|
|
2
|
+
import { type Renderable } from '@esportsplus/template';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
type Action = {
|
|
6
|
+
label: string;
|
|
7
|
+
onclick: () => void;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type Options = {
|
|
11
|
+
action?: Action;
|
|
12
|
+
description?: Renderable<unknown> | string;
|
|
13
|
+
dismissible?: boolean;
|
|
14
|
+
duration?: number;
|
|
15
|
+
id?: string;
|
|
16
|
+
priority?: 'low' | 'high';
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type Status = 'ending' | 'starting' | 'visible';
|
|
20
|
+
|
|
21
|
+
type Timer = {
|
|
22
|
+
handle: ReturnType<typeof setTimeout> | undefined;
|
|
23
|
+
remaining: number;
|
|
24
|
+
started: number;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
type Toast = {
|
|
28
|
+
action?: Action;
|
|
29
|
+
createdAt: number;
|
|
30
|
+
description?: Renderable<unknown> | string;
|
|
31
|
+
dismissible: boolean;
|
|
32
|
+
duration: number;
|
|
33
|
+
height: number;
|
|
34
|
+
id: string;
|
|
35
|
+
priority: 'low' | 'high';
|
|
36
|
+
status: Status;
|
|
37
|
+
title: Renderable<unknown> | string;
|
|
38
|
+
type: Type;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type Type = 'success' | 'error' | 'info' | 'warning' | 'loading' | 'message';
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
const DURATIONS: Record<Type, number> = {
|
|
45
|
+
error: 6000,
|
|
46
|
+
info: 4000,
|
|
47
|
+
loading: 0,
|
|
48
|
+
message: 4000,
|
|
49
|
+
success: 4000,
|
|
50
|
+
warning: 6000
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const EXIT_DURATION = 300;
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
let counter = 0,
|
|
57
|
+
paused = false,
|
|
58
|
+
timers = new Map<string, Timer>();
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
function buildVisibleToastLayout(toasts: Toast[]): {
|
|
62
|
+
frontmostHeight: number;
|
|
63
|
+
items: { offsetY: number, toast: Toast, visibleIndex: number }[];
|
|
64
|
+
} {
|
|
65
|
+
// Two parallel cursors:
|
|
66
|
+
// - `full*` advances on every toast, so an ending toast keeps the slot it
|
|
67
|
+
// occupied before dismissal and its exit transform originates from the
|
|
68
|
+
// correct position (otherwise it would snap to Y=0 and slide diagonally).
|
|
69
|
+
// - `live*` advances only on non-ending toasts, so live toasts reflow past
|
|
70
|
+
// the vacated slot in parallel with the exit animation instead of
|
|
71
|
+
// waiting for it to finish (which caused a visible "stop and bump").
|
|
72
|
+
let fullIndex = 0,
|
|
73
|
+
fullOffsetY = 0,
|
|
74
|
+
liveIndex = 0,
|
|
75
|
+
liveOffsetY = 0,
|
|
76
|
+
items = toasts.map((toast) => {
|
|
77
|
+
let height = normalizeToastHeight(toast.height),
|
|
78
|
+
item;
|
|
79
|
+
|
|
80
|
+
if (toast.status === 'ending') {
|
|
81
|
+
item = {
|
|
82
|
+
offsetY: fullOffsetY,
|
|
83
|
+
toast,
|
|
84
|
+
visibleIndex: fullIndex
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
fullOffsetY += height;
|
|
88
|
+
fullIndex += 1;
|
|
89
|
+
|
|
90
|
+
return item;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
item = {
|
|
94
|
+
offsetY: liveOffsetY,
|
|
95
|
+
toast,
|
|
96
|
+
visibleIndex: liveIndex
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
fullOffsetY += height;
|
|
100
|
+
fullIndex += 1;
|
|
101
|
+
liveOffsetY += height;
|
|
102
|
+
liveIndex += 1;
|
|
103
|
+
|
|
104
|
+
return item;
|
|
105
|
+
}),
|
|
106
|
+
frontmostLiveToast = toasts.find((toast) => toast.status !== 'ending');
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
frontmostHeight: normalizeToastHeight(frontmostLiveToast?.height),
|
|
110
|
+
items
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function clearTimer(id: string) {
|
|
115
|
+
let timer = timers.get(id);
|
|
116
|
+
|
|
117
|
+
if (!timer) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (timer.handle !== undefined) {
|
|
122
|
+
clearTimeout(timer.handle);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
timers.delete(id);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function create(type: Type, title: Renderable<unknown> | string, options: Options = {}): string {
|
|
129
|
+
let id = options.id ?? `toast-${++counter}`,
|
|
130
|
+
toast = reactive({
|
|
131
|
+
action: options.action,
|
|
132
|
+
createdAt: Date.now(),
|
|
133
|
+
description: options.description,
|
|
134
|
+
dismissible: options.dismissible ?? true,
|
|
135
|
+
duration: options.duration ?? DURATIONS[type],
|
|
136
|
+
height: 0,
|
|
137
|
+
id,
|
|
138
|
+
priority: options.priority ?? 'low',
|
|
139
|
+
status: 'starting' as Status,
|
|
140
|
+
title,
|
|
141
|
+
type
|
|
142
|
+
}) as Toast;
|
|
143
|
+
|
|
144
|
+
toasts.push(toast);
|
|
145
|
+
|
|
146
|
+
queueMicrotask(() => {
|
|
147
|
+
if (toast.status === 'starting' && toasts.includes(toast)) {
|
|
148
|
+
toast.status = 'visible';
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
if (type !== 'loading' && toast.duration > 0) {
|
|
153
|
+
schedule(toast);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return id;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function dismiss(id: string) {
|
|
160
|
+
let toast = toasts.find((value) => value.id === id);
|
|
161
|
+
|
|
162
|
+
if (!toast || toast.status === 'ending') {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
clearTimer(id);
|
|
167
|
+
|
|
168
|
+
toast.status = 'ending';
|
|
169
|
+
|
|
170
|
+
setTimeout(() => remove(id), EXIT_DURATION);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function normalizeToastHeight(height: number | null | undefined): number {
|
|
174
|
+
return typeof height === 'number' && Number.isFinite(height) && height > 0 ? height : 0;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function pause() {
|
|
178
|
+
for (let timer of timers.values()) {
|
|
179
|
+
if (timer.handle === undefined) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
clearTimeout(timer.handle);
|
|
184
|
+
|
|
185
|
+
timer.remaining = Math.max(0, timer.remaining - (performance.now() - timer.started));
|
|
186
|
+
timer.handle = undefined;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function remove(id: string) {
|
|
191
|
+
let index = toasts.findIndex((toast) => toast.id === id);
|
|
192
|
+
|
|
193
|
+
clearTimer(id);
|
|
194
|
+
|
|
195
|
+
if (index !== -1) {
|
|
196
|
+
toasts.splice(index, 1);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function resume() {
|
|
201
|
+
for (let [id, timer] of timers) {
|
|
202
|
+
if (timer.handle !== undefined) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
timer.started = performance.now();
|
|
207
|
+
timer.handle = setTimeout(() => dismiss(id), timer.remaining);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function schedule(toast: Toast) {
|
|
212
|
+
if (toast.duration <= 0) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (state.active) {
|
|
217
|
+
timers.set(toast.id, {
|
|
218
|
+
handle: undefined,
|
|
219
|
+
remaining: toast.duration,
|
|
220
|
+
started: 0
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
timers.set(toast.id, {
|
|
227
|
+
handle: setTimeout(() => dismiss(toast.id), toast.duration),
|
|
228
|
+
remaining: toast.duration,
|
|
229
|
+
started: performance.now()
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function update(id: string, options: Options) {
|
|
234
|
+
let toast = toasts.find((value) => value.id === id);
|
|
235
|
+
|
|
236
|
+
if (!toast) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (options.action !== undefined) {
|
|
241
|
+
toast.action = options.action;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (options.description !== undefined) {
|
|
245
|
+
toast.description = options.description;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (options.dismissible !== undefined) {
|
|
249
|
+
toast.dismissible = options.dismissible;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (options.priority !== undefined) {
|
|
253
|
+
toast.priority = options.priority;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (options.duration !== undefined) {
|
|
257
|
+
toast.duration = options.duration;
|
|
258
|
+
|
|
259
|
+
clearTimer(id);
|
|
260
|
+
|
|
261
|
+
if (toast.type !== 'loading' && toast.duration > 0 && toast.status !== 'ending') {
|
|
262
|
+
schedule(toast);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
const state = reactive({ active: false });
|
|
269
|
+
|
|
270
|
+
const toasts = new ReactiveArray<Toast>();
|
|
271
|
+
|
|
272
|
+
effect(() => {
|
|
273
|
+
let active = state.active;
|
|
274
|
+
|
|
275
|
+
if (active === paused) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
paused = active;
|
|
280
|
+
|
|
281
|
+
if (active) {
|
|
282
|
+
pause();
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
resume();
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
const toast = {
|
|
290
|
+
dismiss: (id?: string) => {
|
|
291
|
+
if (id === undefined) {
|
|
292
|
+
for (let value of [...toasts]) {
|
|
293
|
+
dismiss(value.id);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
dismiss(id);
|
|
300
|
+
},
|
|
301
|
+
error: (title: Renderable<unknown> | string, options?: Options) => create('error', title, options),
|
|
302
|
+
info: (title: Renderable<unknown> | string, options?: Options) => create('info', title, options),
|
|
303
|
+
loading: (title: Renderable<unknown> | string, options?: Options) => create('loading', title, options),
|
|
304
|
+
message: (title: Renderable<unknown> | string, options?: Options) => create('message', title, options),
|
|
305
|
+
success: (title: Renderable<unknown> | string, options?: Options) => create('success', title, options),
|
|
306
|
+
update,
|
|
307
|
+
warning: (title: Renderable<unknown> | string, options?: Options) => create('warning', title, options)
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
export { buildVisibleToastLayout, remove, state, toast, toasts };
|
|
312
|
+
export type { Options, Toast, Type };
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
@use '/lib';
|
|
2
|
+
@use '/tokens';
|
|
3
|
+
@use 'variables';
|
|
4
|
+
|
|
5
|
+
.toaster {
|
|
6
|
+
bottom: auto;
|
|
7
|
+
left: auto;
|
|
8
|
+
position: fixed;
|
|
9
|
+
right: auto;
|
|
10
|
+
top: auto;
|
|
11
|
+
width: min(360px, calc(100% - (var(--toast-inset) * 2)));
|
|
12
|
+
z-index: 9999;
|
|
13
|
+
|
|
14
|
+
&[data-position^='top'] {
|
|
15
|
+
top: var(--toast-inset);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&[data-position^='bottom'] {
|
|
19
|
+
bottom: var(--toast-inset);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&[data-position$='left'] {
|
|
23
|
+
left: var(--toast-inset);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&[data-position$='right'] {
|
|
27
|
+
right: var(--toast-inset);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&[data-position$='center'] {
|
|
31
|
+
left: 50%;
|
|
32
|
+
transform: translateX(-50%);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
.toast {
|
|
38
|
+
background: var(--background);
|
|
39
|
+
border: 1px solid var(--color-border-400);
|
|
40
|
+
border-radius: var(--border-radius-500);
|
|
41
|
+
box-shadow: var(--box-shadow-300);
|
|
42
|
+
color: var(--color-text-400);
|
|
43
|
+
left: 0;
|
|
44
|
+
overflow: visible;
|
|
45
|
+
position: absolute;
|
|
46
|
+
right: 0;
|
|
47
|
+
transform: translateX(var(--toast-swipe-x)) translateY(calc(var(--toast-swipe-y) + (var(--toast-index) * var(--toast-peek)) + (var(--toast-shrink) * var(--toast-calc-height)))) scale(var(--toast-scale));
|
|
48
|
+
transition:
|
|
49
|
+
transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
|
|
50
|
+
opacity 0.3s,
|
|
51
|
+
height 0.2s;
|
|
52
|
+
user-select: none;
|
|
53
|
+
width: 100%;
|
|
54
|
+
z-index: calc(9999 - var(--toast-index, 0));
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
[data-position*='top'] & {
|
|
58
|
+
bottom: auto;
|
|
59
|
+
top: 0;
|
|
60
|
+
transform-origin: top;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
[data-position*='bottom'] & {
|
|
64
|
+
--toast-calc-offset-y: calc((var(--toast-offset-y, 0px) * -1) + (var(--toast-index, 0) * var(--toast-gap) * -1) + var(--toast-swipe-y, 0px));
|
|
65
|
+
bottom: 0;
|
|
66
|
+
top: auto;
|
|
67
|
+
transform: translateX(var(--toast-swipe-x)) translateY(calc(var(--toast-swipe-y) - (var(--toast-index) * var(--toast-peek)) - (var(--toast-shrink) * var(--toast-calc-height)))) scale(var(--toast-scale));
|
|
68
|
+
transform-origin: bottom;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
// Invisible hit-area bridging the gap between stacked toasts while collapsed.
|
|
73
|
+
&::after {
|
|
74
|
+
content: '';
|
|
75
|
+
height: calc(var(--toast-gap) + 1px);
|
|
76
|
+
left: 0;
|
|
77
|
+
position: absolute;
|
|
78
|
+
width: 100%;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
[data-position*='top'] &::after {
|
|
82
|
+
top: 100%;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
[data-position*='bottom'] &::after {
|
|
86
|
+
bottom: 100%;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
&-action {
|
|
91
|
+
flex-shrink: 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&-close {
|
|
95
|
+
align-items: center;
|
|
96
|
+
background: var(--background);
|
|
97
|
+
border: 1px solid var(--color-border-400);
|
|
98
|
+
border-radius: 100%;
|
|
99
|
+
color: var(--color-text-500);
|
|
100
|
+
display: flex;
|
|
101
|
+
height: var(--size-500);
|
|
102
|
+
justify-content: center;
|
|
103
|
+
position: absolute;
|
|
104
|
+
right: calc(var(--size-200) * -1);
|
|
105
|
+
top: calc(var(--size-200) * -1);
|
|
106
|
+
width: var(--size-500);
|
|
107
|
+
z-index: 1;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&-content {
|
|
111
|
+
align-items: center;
|
|
112
|
+
display: flex;
|
|
113
|
+
gap: var(--size-300);
|
|
114
|
+
justify-content: space-between;
|
|
115
|
+
min-height: 0;
|
|
116
|
+
opacity: max(0, 1 - var(--toast-index, 0));
|
|
117
|
+
overflow-x: clip;
|
|
118
|
+
overflow-y: visible;
|
|
119
|
+
padding: var(--size-400);
|
|
120
|
+
transition: opacity 0.3s;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
&-copy {
|
|
124
|
+
align-items: center;
|
|
125
|
+
display: inline-flex;
|
|
126
|
+
justify-content: center;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
&-description {
|
|
130
|
+
color: var(--color-text-300);
|
|
131
|
+
overflow-wrap: anywhere;
|
|
132
|
+
|
|
133
|
+
&--clamp {
|
|
134
|
+
-webkit-box-orient: vertical;
|
|
135
|
+
-webkit-line-clamp: 4;
|
|
136
|
+
display: -webkit-box;
|
|
137
|
+
line-clamp: 4;
|
|
138
|
+
overflow: hidden;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
&-details {
|
|
143
|
+
margin-top: var(--size-200);
|
|
144
|
+
max-height: 160px;
|
|
145
|
+
overflow-y: auto;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
&-details-toggle {
|
|
149
|
+
align-items: center;
|
|
150
|
+
cursor: pointer;
|
|
151
|
+
display: flex;
|
|
152
|
+
gap: var(--size-200);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
&-icon {
|
|
156
|
+
color: var(--toast-color);
|
|
157
|
+
flex-shrink: 0;
|
|
158
|
+
height: 18px;
|
|
159
|
+
width: 18px;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
&-title {
|
|
163
|
+
font-weight: var(--font-weight-400);
|
|
164
|
+
overflow-wrap: anywhere;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
&--error {
|
|
169
|
+
--toast-color: var(--color-red-400);
|
|
170
|
+
|
|
171
|
+
border-color: color-mix(in oklab, var(--toast-color) 30%, var(--color-border-400));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
&--warning {
|
|
175
|
+
--toast-color: var(--color-yellow-400);
|
|
176
|
+
|
|
177
|
+
border-color: color-mix(in oklab, var(--toast-color) 30%, var(--color-border-400));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
&--success {
|
|
181
|
+
--toast-color: var(--color-green-400);
|
|
182
|
+
|
|
183
|
+
border-color: color-mix(in oklab, var(--toast-color) 30%, var(--color-border-400));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
&--info {
|
|
187
|
+
--toast-color: var(--color-blue-400);
|
|
188
|
+
|
|
189
|
+
border-color: color-mix(in oklab, var(--toast-color) 30%, var(--color-border-400));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
&--loading {
|
|
193
|
+
--toast-color: var(--color-grey-500);
|
|
194
|
+
|
|
195
|
+
border-color: color-mix(in oklab, var(--toast-color) 30%, var(--color-border-400));
|
|
196
|
+
|
|
197
|
+
.toast-icon {
|
|
198
|
+
animation: toast-spin 1s linear infinite;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
&--message {
|
|
203
|
+
--toast-color: var(--color-text-300);
|
|
204
|
+
|
|
205
|
+
border-color: color-mix(in oklab, var(--toast-color) 30%, var(--color-border-400));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
// active (viewport hovered): everything fans out to its own measured offset.
|
|
211
|
+
.toaster.--active .toast {
|
|
212
|
+
height: auto;
|
|
213
|
+
transform: translateX(var(--toast-swipe-x)) translateY(var(--toast-calc-offset-y));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.toaster.--active .toast-content {
|
|
217
|
+
opacity: 1;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
// Entering: start off-screen (faded) and let the base transform animate in.
|
|
222
|
+
.toaster .toast.toast--starting {
|
|
223
|
+
opacity: 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.toaster[data-position*='top'] .toast.toast--starting {
|
|
227
|
+
transform: translateY(-120%);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.toaster[data-position*='bottom'] .toast.toast--starting {
|
|
231
|
+
transform: translateY(120%);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
// Leaving: fade, then slide toward the matching viewport edge (or the swipe
|
|
236
|
+
// direction the gesture reported).
|
|
237
|
+
.toaster .toast.toast--ending {
|
|
238
|
+
opacity: 0;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.toaster[data-position*='top'] .toast.toast--ending {
|
|
242
|
+
transform: translateY(calc(-100% - var(--toast-inset)));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.toaster[data-position*='bottom'] .toast.toast--ending {
|
|
246
|
+
transform: translateY(calc(100% + var(--toast-inset)));
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.toaster .toast.toast--ending[data-swipe-direction='left'] {
|
|
250
|
+
transform: translateX(calc(var(--toast-swipe-x) - 100% - var(--toast-inset))) translateY(var(--toast-calc-offset-y));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.toaster .toast.toast--ending[data-swipe-direction='right'] {
|
|
254
|
+
transform: translateX(calc(var(--toast-swipe-x) + 100% + var(--toast-inset))) translateY(var(--toast-calc-offset-y));
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.toaster .toast.toast--ending[data-swipe-direction='up'] {
|
|
258
|
+
transform: translateY(calc(var(--toast-swipe-y) - 100% - var(--toast-inset)));
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.toaster .toast.toast--ending[data-swipe-direction='down'] {
|
|
262
|
+
transform: translateY(calc(var(--toast-swipe-y) + 100% + var(--toast-inset)));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
// Following the finger: never ease the transform during a swipe.
|
|
267
|
+
.toast--swiping {
|
|
268
|
+
transition: none;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
@keyframes toast-spin {
|
|
273
|
+
to {
|
|
274
|
+
transform: rotate(360deg);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.toaster {
|
|
2
|
+
--toast-gap: var(--size-300);
|
|
3
|
+
--toast-inset: var(--size-500);
|
|
4
|
+
--toast-peek: var(--size-300);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
.toast {
|
|
9
|
+
--toast-calc-height: max(var(--toast-frontmost-height, var(--toast-height, 0px)), var(--toast-height, 0px));
|
|
10
|
+
--toast-calc-offset-y: calc(var(--toast-offset-y, 0px) + (var(--toast-index, 0) * var(--toast-gap)) + var(--toast-swipe-y, 0px));
|
|
11
|
+
--toast-color: var(--color-text-300);
|
|
12
|
+
--toast-height: 0px;
|
|
13
|
+
--toast-index: 0;
|
|
14
|
+
--toast-offset-y: 0px;
|
|
15
|
+
--toast-scale: max(0, 1 - (var(--toast-index, 0) * 0.06));
|
|
16
|
+
--toast-shrink: calc(1 - var(--toast-scale));
|
|
17
|
+
--toast-swipe-x: 0px;
|
|
18
|
+
--toast-swipe-y: 0px;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { html, type Attributes, type Renderable } from '@esportsplus/template';
|
|
1
|
+
import { component, html, type Attributes, type Renderable } from '@esportsplus/template';
|
|
2
|
+
import { reactive } from '@esportsplus/reactivity';
|
|
2
3
|
import { omit } from '@esportsplus/utilities';
|
|
3
|
-
import template from '~/components/template';
|
|
4
4
|
import onclick from './onclick';
|
|
5
5
|
|
|
6
6
|
|
|
@@ -20,21 +20,25 @@ const OMIT_OPTION = ['content'];
|
|
|
20
20
|
const OMIT_TOOLTIP_CONTENT = ['direction'];
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
export default
|
|
23
|
+
export default component<A>(
|
|
24
24
|
(attributes, content) => {
|
|
25
25
|
let options = attributes.options,
|
|
26
26
|
option = attributes.option,
|
|
27
|
+
state = attributes.state || reactive({ active: false }),
|
|
27
28
|
tooltipContent = attributes?.['tooltip-content'],
|
|
28
29
|
tooltipContentDirection = tooltipContent?.direction || 'nw';
|
|
29
30
|
|
|
30
31
|
return onclick(
|
|
31
|
-
omit(attributes, OMIT),
|
|
32
|
+
{ ...omit(attributes, OMIT), state },
|
|
32
33
|
html`
|
|
33
34
|
${content}
|
|
34
35
|
|
|
35
36
|
<div
|
|
36
37
|
class='tooltip-content ${`tooltip-content--${tooltipContentDirection}`}'
|
|
37
38
|
${tooltipContent && omit(tooltipContent, OMIT_TOOLTIP_CONTENT)}
|
|
39
|
+
${{
|
|
40
|
+
inert: () => !state.active
|
|
41
|
+
}}
|
|
38
42
|
>
|
|
39
43
|
${options.map((o) => {
|
|
40
44
|
if (o.href) {
|