@expressivecss/expressive 0.14.1 → 0.16.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/CHANGELOG.md +1589 -1
- package/README.md +9 -8
- package/dist/css/expressive.css +19304 -12021
- package/dist/css/expressive.css.map +1 -1
- package/dist/css/expressive.min.css +1 -1
- package/dist/css/expressive.min.css.map +1 -1
- package/dist/fonts/LICENSE-noto-sans-arabic +93 -0
- package/dist/fonts/LICENSE-noto-sans-hebrew +93 -0
- package/dist/fonts/LICENSE-noto-sans-thai +93 -0
- package/dist/fonts/material-symbols-outlined.woff2 +0 -0
- package/dist/fonts/material-symbols-rounded.woff2 +0 -0
- package/dist/fonts/material-symbols-sharp.woff2 +0 -0
- package/dist/fonts/noto-sans-arabic-arabic-400.woff2 +0 -0
- package/dist/fonts/noto-sans-arabic-arabic-500.woff2 +0 -0
- package/dist/fonts/noto-sans-arabic-arabic-700.woff2 +0 -0
- package/dist/fonts/noto-sans-cyrillic-400.woff2 +0 -0
- package/dist/fonts/noto-sans-cyrillic-500.woff2 +0 -0
- package/dist/fonts/noto-sans-cyrillic-700.woff2 +0 -0
- package/dist/fonts/noto-sans-cyrillic-ext-400.woff2 +0 -0
- package/dist/fonts/noto-sans-cyrillic-ext-500.woff2 +0 -0
- package/dist/fonts/noto-sans-cyrillic-ext-700.woff2 +0 -0
- package/dist/fonts/noto-sans-devanagari-400.woff2 +0 -0
- package/dist/fonts/noto-sans-devanagari-500.woff2 +0 -0
- package/dist/fonts/noto-sans-devanagari-700.woff2 +0 -0
- package/dist/fonts/noto-sans-greek-400.woff2 +0 -0
- package/dist/fonts/noto-sans-greek-500.woff2 +0 -0
- package/dist/fonts/noto-sans-greek-700.woff2 +0 -0
- package/dist/fonts/noto-sans-greek-ext-400.woff2 +0 -0
- package/dist/fonts/noto-sans-greek-ext-500.woff2 +0 -0
- package/dist/fonts/noto-sans-greek-ext-700.woff2 +0 -0
- package/dist/fonts/noto-sans-hebrew-hebrew-400.woff2 +0 -0
- package/dist/fonts/noto-sans-hebrew-hebrew-500.woff2 +0 -0
- package/dist/fonts/noto-sans-hebrew-hebrew-700.woff2 +0 -0
- package/dist/fonts/noto-sans-latin-700.woff2 +0 -0
- package/dist/fonts/noto-sans-latin-ext-400.woff2 +0 -0
- package/dist/fonts/noto-sans-latin-ext-500.woff2 +0 -0
- package/dist/fonts/noto-sans-latin-ext-700.woff2 +0 -0
- package/dist/fonts/noto-sans-thai-thai-400.woff2 +0 -0
- package/dist/fonts/noto-sans-thai-thai-500.woff2 +0 -0
- package/dist/fonts/noto-sans-thai-thai-700.woff2 +0 -0
- package/dist/fonts/noto-sans-vietnamese-400.woff2 +0 -0
- package/dist/fonts/noto-sans-vietnamese-500.woff2 +0 -0
- package/dist/fonts/noto-sans-vietnamese-700.woff2 +0 -0
- package/dist/fonts/roboto-cyrillic-400.woff2 +0 -0
- package/dist/fonts/roboto-cyrillic-500.woff2 +0 -0
- package/dist/fonts/roboto-cyrillic-700.woff2 +0 -0
- package/dist/fonts/roboto-cyrillic-ext-400.woff2 +0 -0
- package/dist/fonts/roboto-cyrillic-ext-500.woff2 +0 -0
- package/dist/fonts/roboto-cyrillic-ext-700.woff2 +0 -0
- package/dist/fonts/roboto-greek-400.woff2 +0 -0
- package/dist/fonts/roboto-greek-500.woff2 +0 -0
- package/dist/fonts/roboto-greek-700.woff2 +0 -0
- package/dist/fonts/roboto-greek-ext-400.woff2 +0 -0
- package/dist/fonts/roboto-greek-ext-500.woff2 +0 -0
- package/dist/fonts/roboto-greek-ext-700.woff2 +0 -0
- package/dist/fonts/roboto-latin-700.woff2 +0 -0
- package/dist/fonts/roboto-latin-ext-400.woff2 +0 -0
- package/dist/fonts/roboto-latin-ext-500.woff2 +0 -0
- package/dist/fonts/roboto-latin-ext-700.woff2 +0 -0
- package/dist/fonts/roboto-vietnamese-400.woff2 +0 -0
- package/dist/fonts/roboto-vietnamese-500.woff2 +0 -0
- package/dist/fonts/roboto-vietnamese-700.woff2 +0 -0
- package/dist/js/chunks/chunk-2CS6TITK.mjs +219 -0
- package/dist/js/chunks/chunk-2CS6TITK.mjs.map +7 -0
- package/dist/js/chunks/chunk-2RLBDFH4.mjs +108 -0
- package/dist/js/chunks/chunk-2RLBDFH4.mjs.map +7 -0
- package/dist/js/chunks/chunk-3L3QIYLC.mjs +85 -0
- package/dist/js/chunks/chunk-3L3QIYLC.mjs.map +7 -0
- package/dist/js/chunks/chunk-4EWGD4V2.mjs +75 -0
- package/dist/js/chunks/chunk-4EWGD4V2.mjs.map +7 -0
- package/dist/js/chunks/chunk-4IKVPCSU.mjs +7 -0
- package/dist/js/chunks/chunk-4IKVPCSU.mjs.map +7 -0
- package/dist/js/chunks/chunk-4PIXLDNJ.mjs +127 -0
- package/dist/js/chunks/chunk-4PIXLDNJ.mjs.map +7 -0
- package/dist/js/chunks/{chunk-A7ALMYUR.mjs → chunk-4QUCNFSD.mjs} +68 -125
- package/dist/js/chunks/chunk-4QUCNFSD.mjs.map +7 -0
- package/dist/js/chunks/{chunk-4TKTLGEM.mjs → chunk-4TRZ2AER.mjs} +35 -41
- package/dist/js/chunks/chunk-4TRZ2AER.mjs.map +7 -0
- package/dist/js/chunks/{chunk-BG6ZRB5H.mjs → chunk-5KIHWJI2.mjs} +40 -26
- package/dist/js/chunks/chunk-5KIHWJI2.mjs.map +7 -0
- package/dist/js/chunks/{chunk-YDCS5S3J.mjs → chunk-67ZPPKXS.mjs} +20 -33
- package/dist/js/chunks/chunk-67ZPPKXS.mjs.map +7 -0
- package/dist/js/chunks/{chunk-3DHK5CZU.mjs → chunk-6FSEUFVW.mjs} +40 -29
- package/dist/js/chunks/chunk-6FSEUFVW.mjs.map +7 -0
- package/dist/js/chunks/chunk-752ADW4M.mjs +225 -0
- package/dist/js/chunks/chunk-752ADW4M.mjs.map +7 -0
- package/dist/js/chunks/{chunk-GVGT6MIU.mjs → chunk-75E5EDJF.mjs} +3 -11
- package/dist/js/chunks/chunk-75E5EDJF.mjs.map +7 -0
- package/dist/js/chunks/{chunk-TBM3FT7G.mjs → chunk-7NLUI3RR.mjs} +148 -78
- package/dist/js/chunks/chunk-7NLUI3RR.mjs.map +7 -0
- package/dist/js/chunks/chunk-7W7TV6NY.mjs +108 -0
- package/dist/js/chunks/chunk-7W7TV6NY.mjs.map +7 -0
- package/dist/js/chunks/chunk-7YQBHTK3.mjs +225 -0
- package/dist/js/chunks/chunk-7YQBHTK3.mjs.map +7 -0
- package/dist/js/chunks/chunk-7YZ5CN3V.mjs +33 -0
- package/dist/js/chunks/chunk-7YZ5CN3V.mjs.map +7 -0
- package/dist/js/chunks/chunk-AI73GJKG.mjs +28 -0
- package/dist/js/chunks/chunk-AI73GJKG.mjs.map +7 -0
- package/dist/js/chunks/{chunk-NS2UMNZV.mjs → chunk-ANKFWNWT.mjs} +21 -45
- package/dist/js/chunks/chunk-ANKFWNWT.mjs.map +7 -0
- package/dist/js/chunks/{chunk-GIW4K4SE.mjs → chunk-B7DQFHA5.mjs} +37 -53
- package/dist/js/chunks/chunk-B7DQFHA5.mjs.map +7 -0
- package/dist/js/chunks/chunk-BIGU5RCJ.mjs +153 -0
- package/dist/js/chunks/chunk-BIGU5RCJ.mjs.map +7 -0
- package/dist/js/chunks/{chunk-GUB3TNO2.mjs → chunk-BPF3I2MN.mjs} +109 -27
- package/dist/js/chunks/chunk-BPF3I2MN.mjs.map +7 -0
- package/dist/js/chunks/chunk-CMGXGYUC.mjs +74 -0
- package/dist/js/chunks/chunk-CMGXGYUC.mjs.map +7 -0
- package/dist/js/chunks/{chunk-JIDMQGK6.mjs → chunk-CSYWKEK3.mjs} +322 -223
- package/dist/js/chunks/chunk-CSYWKEK3.mjs.map +7 -0
- package/dist/js/chunks/chunk-CZSQHXEV.mjs +227 -0
- package/dist/js/chunks/chunk-CZSQHXEV.mjs.map +7 -0
- package/dist/js/chunks/chunk-DZYVU75J.mjs +121 -0
- package/dist/js/chunks/chunk-DZYVU75J.mjs.map +7 -0
- package/dist/js/chunks/{chunk-QDAL4IYN.mjs → chunk-EC26RU2D.mjs} +11 -29
- package/dist/js/chunks/chunk-EC26RU2D.mjs.map +7 -0
- package/dist/js/chunks/{chunk-3GVFZ4XO.mjs → chunk-EVCVFEV3.mjs} +238 -152
- package/dist/js/chunks/chunk-EVCVFEV3.mjs.map +7 -0
- package/dist/js/chunks/chunk-FCNF4GRJ.mjs +445 -0
- package/dist/js/chunks/chunk-FCNF4GRJ.mjs.map +7 -0
- package/dist/js/chunks/chunk-GCWWEZKO.mjs +342 -0
- package/dist/js/chunks/chunk-GCWWEZKO.mjs.map +7 -0
- package/dist/js/chunks/chunk-GNRSYMVH.mjs +1 -0
- package/dist/js/chunks/chunk-GVZQH2H5.mjs +54 -0
- package/dist/js/chunks/chunk-GVZQH2H5.mjs.map +7 -0
- package/dist/js/chunks/chunk-GWZ76SR4.mjs +435 -0
- package/dist/js/chunks/chunk-GWZ76SR4.mjs.map +7 -0
- package/dist/js/chunks/{chunk-ZAS25YFD.mjs → chunk-ILDRRG7T.mjs} +21 -23
- package/dist/js/chunks/chunk-ILDRRG7T.mjs.map +7 -0
- package/dist/js/chunks/chunk-INLZWHLY.mjs +80 -0
- package/dist/js/chunks/chunk-INLZWHLY.mjs.map +7 -0
- package/dist/js/chunks/chunk-JUKBBN6P.mjs +175 -0
- package/dist/js/chunks/chunk-JUKBBN6P.mjs.map +7 -0
- package/dist/js/chunks/chunk-KYIEG4U3.mjs +730 -0
- package/dist/js/chunks/chunk-KYIEG4U3.mjs.map +7 -0
- package/dist/js/chunks/{chunk-KHV6DZXX.mjs → chunk-KZPSAXIU.mjs} +156 -46
- package/dist/js/chunks/chunk-KZPSAXIU.mjs.map +7 -0
- package/dist/js/chunks/chunk-LDXCC2L3.mjs +438 -0
- package/dist/js/chunks/chunk-LDXCC2L3.mjs.map +7 -0
- package/dist/js/chunks/chunk-NAC72P7R.mjs +137 -0
- package/dist/js/chunks/chunk-NAC72P7R.mjs.map +7 -0
- package/dist/js/chunks/chunk-NBJAUGPP.mjs +244 -0
- package/dist/js/chunks/chunk-NBJAUGPP.mjs.map +7 -0
- package/dist/js/chunks/chunk-NNHVANQA.mjs +113 -0
- package/dist/js/chunks/chunk-NNHVANQA.mjs.map +7 -0
- package/dist/js/chunks/chunk-NVQ5EHCU.mjs +376 -0
- package/dist/js/chunks/chunk-NVQ5EHCU.mjs.map +7 -0
- package/dist/js/chunks/{chunk-Z2NRKI7R.mjs → chunk-OP43LLIC.mjs} +44 -73
- package/dist/js/chunks/chunk-OP43LLIC.mjs.map +7 -0
- package/dist/js/chunks/chunk-OUCHKSAW.mjs +63 -0
- package/dist/js/chunks/chunk-OUCHKSAW.mjs.map +7 -0
- package/dist/js/chunks/{chunk-PM655FXL.mjs → chunk-OYNUDOHR.mjs} +20 -48
- package/dist/js/chunks/chunk-OYNUDOHR.mjs.map +7 -0
- package/dist/js/chunks/{chunk-UEZUJQ66.mjs → chunk-P6DRQ6KS.mjs} +36 -31
- package/dist/js/chunks/chunk-P6DRQ6KS.mjs.map +7 -0
- package/dist/js/chunks/chunk-PA7NU5AK.mjs +99 -0
- package/dist/js/chunks/chunk-PA7NU5AK.mjs.map +7 -0
- package/dist/js/chunks/chunk-QACZ6TUP.mjs +224 -0
- package/dist/js/chunks/chunk-QACZ6TUP.mjs.map +7 -0
- package/dist/js/chunks/{chunk-5HQSGDZ5.mjs → chunk-QXKWVHBD.mjs} +286 -203
- package/dist/js/chunks/chunk-QXKWVHBD.mjs.map +7 -0
- package/dist/js/chunks/{chunk-DAIU5SLG.mjs → chunk-ROH2HDB4.mjs} +7 -6
- package/dist/js/chunks/chunk-ROH2HDB4.mjs.map +7 -0
- package/dist/js/chunks/chunk-S23RJ3XY.mjs +86 -0
- package/dist/js/chunks/chunk-S23RJ3XY.mjs.map +7 -0
- package/dist/js/chunks/{chunk-FS7XY3HT.mjs → chunk-SPPHF7YZ.mjs} +36 -29
- package/dist/js/chunks/chunk-SPPHF7YZ.mjs.map +7 -0
- package/dist/js/chunks/chunk-T3BNSRP3.mjs +152 -0
- package/dist/js/chunks/chunk-T3BNSRP3.mjs.map +7 -0
- package/dist/js/chunks/chunk-TFABTUAZ.mjs +108 -0
- package/dist/js/chunks/chunk-TFABTUAZ.mjs.map +7 -0
- package/dist/js/chunks/chunk-U4B3VHFS.mjs +507 -0
- package/dist/js/chunks/chunk-U4B3VHFS.mjs.map +7 -0
- package/dist/js/chunks/chunk-UGJHCHXG.mjs +341 -0
- package/dist/js/chunks/chunk-UGJHCHXG.mjs.map +7 -0
- package/dist/js/chunks/chunk-VFV75DHF.mjs +70 -0
- package/dist/js/chunks/chunk-VFV75DHF.mjs.map +7 -0
- package/dist/js/chunks/{chunk-4HZMB7LI.mjs → chunk-VGY4M57S.mjs} +281 -135
- package/dist/js/chunks/chunk-VGY4M57S.mjs.map +7 -0
- package/dist/js/chunks/chunk-VH4BMAZS.mjs +167 -0
- package/dist/js/chunks/chunk-VH4BMAZS.mjs.map +7 -0
- package/dist/js/chunks/chunk-VJVQIXHC.mjs +123 -0
- package/dist/js/chunks/chunk-VJVQIXHC.mjs.map +7 -0
- package/dist/js/chunks/{chunk-S3XDFGSZ.mjs → chunk-VMY55K2X.mjs} +92 -141
- package/dist/js/chunks/chunk-VMY55K2X.mjs.map +7 -0
- package/dist/js/chunks/{chunk-UEXCIMJZ.mjs → chunk-VR3L2WN5.mjs} +11 -17
- package/dist/js/chunks/chunk-VR3L2WN5.mjs.map +7 -0
- package/dist/js/chunks/chunk-W6FAL3TI.mjs +38 -0
- package/dist/js/chunks/chunk-W6FAL3TI.mjs.map +7 -0
- package/dist/js/chunks/chunk-WU7XJ4RR.mjs +450 -0
- package/dist/js/chunks/chunk-WU7XJ4RR.mjs.map +7 -0
- package/dist/js/chunks/chunk-X7SDA2J5.mjs +116 -0
- package/dist/js/chunks/chunk-X7SDA2J5.mjs.map +7 -0
- package/dist/js/chunks/chunk-Y6H2X7ZC.mjs +209 -0
- package/dist/js/chunks/chunk-Y6H2X7ZC.mjs.map +7 -0
- package/dist/js/chunks/chunk-Y6TLRA3U.mjs +129 -0
- package/dist/js/chunks/chunk-Y6TLRA3U.mjs.map +7 -0
- package/dist/js/chunks/chunk-Z4GICXR2.mjs +190 -0
- package/dist/js/chunks/chunk-Z4GICXR2.mjs.map +7 -0
- package/dist/js/chunks/chunk-Z4OARDZ7.mjs +442 -0
- package/dist/js/chunks/chunk-Z4OARDZ7.mjs.map +7 -0
- package/dist/js/chunks/{chunk-MZ6Z24BX.mjs → chunk-ZJNLAGY5.mjs} +19 -34
- package/dist/js/chunks/chunk-ZJNLAGY5.mjs.map +7 -0
- package/dist/js/chunks/chunk-ZKWUWBUB.mjs +81 -0
- package/dist/js/chunks/chunk-ZKWUWBUB.mjs.map +7 -0
- package/dist/js/chunks/chunk-ZM3XBHWV.mjs +746 -0
- package/dist/js/chunks/chunk-ZM3XBHWV.mjs.map +7 -0
- package/dist/js/chunks/chunk-ZO6ZLHFF.mjs +48 -0
- package/dist/js/chunks/chunk-ZO6ZLHFF.mjs.map +7 -0
- package/dist/js/chunks/chunk-ZVLOUDIJ.mjs +251 -0
- package/dist/js/chunks/chunk-ZVLOUDIJ.mjs.map +7 -0
- package/dist/js/expressive.cjs +10333 -4070
- package/dist/js/expressive.cjs.map +4 -4
- package/dist/js/expressive.js +10333 -4070
- package/dist/js/expressive.js.map +4 -4
- package/dist/js/expressive.min.js +23 -25
- package/dist/js/expressive.min.js.map +4 -4
- package/dist/js/expressive.mjs +184 -69
- package/dist/js/expressive.mjs.map +2 -2
- package/dist/js/internal/behaviors/bottomSheets.mjs +4 -3
- package/dist/js/internal/behaviors/copy.mjs +9 -0
- package/dist/js/internal/behaviors/copy.mjs.map +7 -0
- package/dist/js/internal/behaviors/dataTables.mjs +10 -0
- package/dist/js/internal/behaviors/dataTables.mjs.map +7 -0
- package/dist/js/internal/behaviors/dialogs.mjs +2 -2
- package/dist/js/internal/behaviors/forms.mjs +2 -2
- package/dist/js/internal/behaviors/imageCompare.mjs +8 -0
- package/dist/js/internal/behaviors/imageCompare.mjs.map +7 -0
- package/dist/js/internal/behaviors/lists.mjs +8 -0
- package/dist/js/internal/behaviors/lists.mjs.map +7 -0
- package/dist/js/internal/behaviors/paneResize.mjs +8 -0
- package/dist/js/internal/behaviors/paneResize.mjs.map +7 -0
- package/dist/js/internal/behaviors/sheetDrag.mjs +7 -2
- package/dist/js/internal/behaviors/sideSheets.mjs +4 -3
- package/dist/js/internal/behaviors/sortable.mjs +8 -0
- package/dist/js/internal/behaviors/sortable.mjs.map +7 -0
- package/dist/js/internal/behaviors/theme.mjs +8 -0
- package/dist/js/internal/behaviors/theme.mjs.map +7 -0
- package/dist/js/internal/behaviors/tour.mjs +8 -0
- package/dist/js/internal/behaviors/tour.mjs.map +7 -0
- package/dist/js/internal/behaviors/transferList.mjs +8 -0
- package/dist/js/internal/behaviors/transferList.mjs.map +7 -0
- package/dist/js/internal/components/appBar.mjs +3 -2
- package/dist/js/internal/components/autocomplete.mjs +4 -4
- package/dist/js/internal/components/backToTop.mjs +9 -0
- package/dist/js/internal/components/backToTop.mjs.map +7 -0
- package/dist/js/internal/components/barChart.mjs +5 -4
- package/dist/js/internal/components/buttonGroup.mjs +3 -2
- package/dist/js/internal/components/buttons.mjs +3 -3
- package/dist/js/internal/components/cards.mjs +3 -3
- package/dist/js/internal/components/carousel.mjs +3 -3
- package/dist/js/internal/components/cascader.mjs +10 -0
- package/dist/js/internal/components/cascader.mjs.map +7 -0
- package/dist/js/internal/components/characterCounter.mjs +3 -2
- package/dist/js/internal/components/chips.mjs +6 -5
- package/dist/js/internal/components/colorPicker.mjs +9 -0
- package/dist/js/internal/components/colorPicker.mjs.map +7 -0
- package/dist/js/internal/components/columnChart.mjs +4 -3
- package/dist/js/internal/components/commandPalette.mjs +3 -3
- package/dist/js/internal/components/confetti.mjs +3 -2
- package/dist/js/internal/components/currencyInput.mjs +9 -0
- package/dist/js/internal/components/currencyInput.mjs.map +7 -0
- package/dist/js/internal/components/datepicker.mjs +11 -8
- package/dist/js/internal/components/expandingCard.mjs +3 -3
- package/dist/js/internal/components/funnelChart.mjs +10 -0
- package/dist/js/internal/components/funnelChart.mjs.map +7 -0
- package/dist/js/internal/components/heatmapChart.mjs +4 -3
- package/dist/js/internal/components/hoverCard.mjs +9 -0
- package/dist/js/internal/components/hoverCard.mjs.map +7 -0
- package/dist/js/internal/components/index.mjs +133 -64
- package/dist/js/internal/components/inputMask.mjs +9 -0
- package/dist/js/internal/components/inputMask.mjs.map +7 -0
- package/dist/js/internal/components/keypad.mjs +9 -0
- package/dist/js/internal/components/keypad.mjs.map +7 -0
- package/dist/js/internal/components/lightbox.mjs +3 -3
- package/dist/js/internal/components/lineChart.mjs +29 -4
- package/dist/js/internal/components/loadingOverlay.mjs +9 -0
- package/dist/js/internal/components/loadingOverlay.mjs.map +7 -0
- package/dist/js/internal/components/mapView.mjs +3 -3
- package/dist/js/internal/components/menu.mjs +3 -3
- package/dist/js/internal/components/menubar.mjs +10 -0
- package/dist/js/internal/components/menubar.mjs.map +7 -0
- package/dist/js/internal/components/messageScroller.mjs +3 -3
- package/dist/js/internal/components/mixedChart.mjs +5 -4
- package/dist/js/internal/components/navigationRail.mjs +3 -2
- package/dist/js/internal/components/particles.mjs +3 -2
- package/dist/js/internal/components/pieChart.mjs +4 -3
- package/dist/js/internal/components/pullToRefresh.mjs +9 -0
- package/dist/js/internal/components/pullToRefresh.mjs.map +7 -0
- package/dist/js/internal/components/questionnaire.mjs +3 -3
- package/dist/js/internal/components/radarChart.mjs +4 -3
- package/dist/js/internal/components/radialChart.mjs +4 -3
- package/dist/js/internal/components/registry.mjs +59 -40
- package/dist/js/internal/components/richTextEditor.mjs +3 -3
- package/dist/js/internal/components/sankeyChart.mjs +10 -0
- package/dist/js/internal/components/sankeyChart.mjs.map +7 -0
- package/dist/js/internal/components/scatterChart.mjs +10 -0
- package/dist/js/internal/components/scatterChart.mjs.map +7 -0
- package/dist/js/internal/components/scrollspy.mjs +3 -2
- package/dist/js/internal/components/select.mjs +4 -4
- package/dist/js/internal/components/showMore.mjs +9 -0
- package/dist/js/internal/components/showMore.mjs.map +7 -0
- package/dist/js/internal/components/slider.mjs +3 -3
- package/dist/js/internal/components/snackbar.mjs +2 -2
- package/dist/js/internal/components/swipeActions.mjs +9 -0
- package/dist/js/internal/components/swipeActions.mjs.map +7 -0
- package/dist/js/internal/components/tabs.mjs +3 -4
- package/dist/js/internal/components/timepicker.mjs +5 -4
- package/dist/js/internal/components/tooltip.mjs +3 -3
- package/dist/js/internal/components/treeSelect.mjs +13 -0
- package/dist/js/internal/components/treeSelect.mjs.map +7 -0
- package/dist/js/internal/components/treemapChart.mjs +10 -0
- package/dist/js/internal/components/treemapChart.mjs.map +7 -0
- package/dist/js/internal/core/component.mjs +2 -1
- package/dist/js/internal/core/formControl.mjs +12 -0
- package/dist/js/internal/core/formControl.mjs.map +7 -0
- package/dist/js/internal/core/spring.mjs +11 -0
- package/dist/js/internal/core/spring.mjs.map +7 -0
- package/dist/js/internal/core/utils.mjs +11 -3
- package/dist/js/internal/plugins/dockedDisplayPlugin.mjs +2 -2
- package/dist/js/internal/plugins/modalDisplayPlugin.mjs +13 -0
- package/dist/js/internal/plugins/modalDisplayPlugin.mjs.map +7 -0
- package/dist/js/modular.mjs +175 -69
- package/dist/types/behaviors/bottomSheets.d.ts +19 -3
- package/dist/types/behaviors/copy.d.ts +18 -0
- package/dist/types/behaviors/dataTables.d.ts +129 -0
- package/dist/types/behaviors/dialogs.d.ts +27 -1
- package/dist/types/behaviors/forms.d.ts +68 -2
- package/dist/types/behaviors/imageCompare.d.ts +12 -0
- package/dist/types/behaviors/lists.d.ts +12 -0
- package/dist/types/behaviors/paneResize.d.ts +29 -0
- package/dist/types/behaviors/sheetDrag.d.ts +18 -0
- package/dist/types/behaviors/sideSheets.d.ts +1 -1
- package/dist/types/behaviors/sortable.d.ts +28 -0
- package/dist/types/behaviors/theme.d.ts +22 -0
- package/dist/types/behaviors/tour.d.ts +36 -0
- package/dist/types/behaviors/transferList.d.ts +51 -0
- package/dist/types/components/appBar.d.ts +5 -6
- package/dist/types/components/autocomplete.d.ts +92 -17
- package/dist/types/components/backToTop.d.ts +36 -0
- package/dist/types/components/barChart.d.ts +3 -6
- package/dist/types/components/buttonGroup.d.ts +2 -4
- package/dist/types/components/buttons.d.ts +5 -5
- package/dist/types/components/cards.d.ts +3 -16
- package/dist/types/components/carousel.d.ts +9 -15
- package/dist/types/components/cascader.d.ts +130 -0
- package/dist/types/components/characterCounter.d.ts +2 -15
- package/dist/types/components/chips.d.ts +65 -19
- package/dist/types/components/colorPicker.d.ts +42 -0
- package/dist/types/components/columnChart.d.ts +23 -10
- package/dist/types/components/commandPalette.d.ts +11 -16
- package/dist/types/components/confetti.d.ts +2 -4
- package/dist/types/components/currencyInput.d.ts +59 -0
- package/dist/types/components/datepicker.d.ts +59 -36
- package/dist/types/components/expandingCard.d.ts +6 -6
- package/dist/types/components/funnelChart.d.ts +38 -0
- package/dist/types/components/heatmapChart.d.ts +39 -8
- package/dist/types/components/hoverCard.d.ts +58 -0
- package/dist/types/components/index.d.ts +17 -1
- package/dist/types/components/inputMask.d.ts +30 -0
- package/dist/types/components/keypad.d.ts +66 -0
- package/dist/types/components/lightbox.d.ts +17 -25
- package/dist/types/components/lineChart.d.ts +176 -10
- package/dist/types/components/loadingOverlay.d.ts +42 -0
- package/dist/types/components/mapView.d.ts +26 -17
- package/dist/types/components/menu.d.ts +61 -22
- package/dist/types/components/menubar.d.ts +37 -0
- package/dist/types/components/messageScroller.d.ts +2 -14
- package/dist/types/components/mixedChart.d.ts +15 -6
- package/dist/types/components/navigationRail.d.ts +16 -5
- package/dist/types/components/particles.d.ts +8 -4
- package/dist/types/components/pieChart.d.ts +32 -7
- package/dist/types/components/pullToRefresh.d.ts +80 -0
- package/dist/types/components/questionnaire.d.ts +58 -16
- package/dist/types/components/radarChart.d.ts +10 -6
- package/dist/types/components/radialChart.d.ts +58 -8
- package/dist/types/components/registry.d.ts +77 -3
- package/dist/types/components/richTextEditor.d.ts +6 -14
- package/dist/types/components/sankeyChart.d.ts +72 -0
- package/dist/types/components/scatterChart.d.ts +102 -0
- package/dist/types/components/scrollspy.d.ts +3 -5
- package/dist/types/components/select.d.ts +43 -30
- package/dist/types/components/showMore.d.ts +51 -0
- package/dist/types/components/slider.d.ts +5 -15
- package/dist/types/components/snackbar.d.ts +62 -0
- package/dist/types/components/swipeActions.d.ts +81 -0
- package/dist/types/components/tabs.d.ts +93 -27
- package/dist/types/components/timepicker.d.ts +114 -20
- package/dist/types/components/tooltip.d.ts +56 -20
- package/dist/types/components/treeSelect.d.ts +106 -0
- package/dist/types/components/treemapChart.d.ts +56 -0
- package/dist/types/core/component.d.ts +43 -25
- package/dist/types/core/formControl.d.ts +21 -0
- package/dist/types/core/spring.d.ts +20 -0
- package/dist/types/core/utils.d.ts +85 -72
- package/dist/types/modular.d.ts +33 -1
- package/dist/types/plugins/dockedDisplayPlugin.d.ts +10 -7
- package/dist/types/plugins/modalDisplayPlugin.d.ts +32 -0
- package/package.json +10 -8
- package/src/sass/README.md +27 -18
- package/src/sass/abstracts/_breakpoints.scss +0 -1
- package/src/sass/abstracts/_elevation.scss +13 -7
- package/src/sass/abstracts/_index.scss +1 -0
- package/src/sass/abstracts/_mixins.scss +438 -92
- package/src/sass/abstracts/_spring.scss +63 -0
- package/src/sass/abstracts/_variables.scss +43 -15
- package/src/sass/base/_fonts.scss +61 -48
- package/src/sass/base/_global.scss +105 -34
- package/src/sass/base/_index.scss +3 -1
- package/src/sass/base/_normalize.scss +59 -114
- package/src/sass/base/_print.scss +21 -0
- package/src/sass/base/_prose.scss +68 -0
- package/src/sass/base/_typography.scss +9 -5
- package/src/sass/components/_accordion.scss +9 -16
- package/src/sass/components/_alert.scss +102 -0
- package/src/sass/components/_aura.scss +8 -3
- package/src/sass/components/_avatar.scss +3 -3
- package/src/sass/components/_back-to-top.scss +38 -0
- package/src/sass/components/_badges.scss +7 -13
- package/src/sass/components/_bar-chart.scss +41 -19
- package/src/sass/components/_bottom-sheet.scss +44 -16
- package/src/sass/components/_breadcrumb.scss +8 -1
- package/src/sass/components/_button-groups.scss +44 -89
- package/src/sass/components/_buttons.scss +156 -63
- package/src/sass/components/_calendar.scss +246 -0
- package/src/sass/components/_cards.scss +41 -68
- package/src/sass/components/_carousel.scss +43 -158
- package/src/sass/components/_cascader.scss +142 -0
- package/src/sass/components/_chips.scss +36 -52
- package/src/sass/components/_column-chart.scss +19 -12
- package/src/sass/components/_command-palette.scss +4 -7
- package/src/sass/components/_confetti.scss +0 -2
- package/src/sass/components/_countdown.scss +1 -1
- package/src/sass/components/_data-table.scss +162 -27
- package/src/sass/components/_datepicker.scss +57 -62
- package/src/sass/components/_description-list.scss +85 -0
- package/src/sass/components/_dialog.scss +42 -44
- package/src/sass/components/_docked-display.scss +1 -3
- package/src/sass/components/_drag-handle.scss +16 -20
- package/src/sass/components/_expanding-card.scss +20 -9
- package/src/sass/components/_fab-menu.scss +44 -32
- package/src/sass/components/_funnel-chart.scss +124 -0
- package/src/sass/components/_heatmap-chart.scss +113 -24
- package/src/sass/components/_icon-buttons.scss +7 -8
- package/src/sass/components/_icons-material-design.scss +2 -2
- package/src/sass/components/_image-compare.scss +108 -0
- package/src/sass/components/_index.scss +21 -0
- package/src/sass/components/_keypad.scss +182 -0
- package/src/sass/components/_kpi.scss +6 -11
- package/src/sass/components/_lightbox.scss +26 -20
- package/src/sass/components/_line-chart.scss +16 -2
- package/src/sass/components/_list.scss +59 -14
- package/src/sass/components/_loading-indicator.scss +1 -0
- package/src/sass/components/_loading-overlay.scss +105 -0
- package/src/sass/components/_map.scss +35 -13
- package/src/sass/components/_marquee.scss +3 -2
- package/src/sass/components/_mega-menu.scss +137 -0
- package/src/sass/components/_menu.scss +159 -182
- package/src/sass/components/_menubar.scss +59 -0
- package/src/sass/components/_message-scroller.scss +2 -2
- package/src/sass/components/_message.scss +3 -3
- package/src/sass/components/_mixed-chart.scss +37 -9
- package/src/sass/components/_modal-display.scss +21 -0
- package/src/sass/components/_navbar.scss +43 -65
- package/src/sass/components/_navigation-bar.scss +15 -77
- package/src/sass/components/_navigation-rail.scss +171 -121
- package/src/sass/components/_org-chart.scss +192 -0
- package/src/sass/components/_page-footer.scss +16 -13
- package/src/sass/components/_pagination.scss +6 -13
- package/src/sass/components/_panes.scss +33 -31
- package/src/sass/components/_particles.scss +0 -2
- package/src/sass/components/_pie-chart.scss +91 -11
- package/src/sass/components/_popover.scss +18 -5
- package/src/sass/components/_progress.scss +158 -35
- package/src/sass/components/_pull-to-refresh.scss +90 -0
- package/src/sass/components/_questionnaire.scss +74 -3
- package/src/sass/components/_radar-chart.scss +38 -10
- package/src/sass/components/_radial-chart.scss +113 -5
- package/src/sass/components/_rich-text-editor.scss +2 -2
- package/src/sass/components/_sankey-chart.scss +114 -0
- package/src/sass/components/_scatter-chart.scss +153 -0
- package/src/sass/components/_scrim.scss +0 -2
- package/src/sass/components/_scrollspy.scss +0 -2
- package/src/sass/components/_search.scss +26 -22
- package/src/sass/components/_show-more.scss +8 -0
- package/src/sass/components/_side-sheet.scss +23 -40
- package/src/sass/components/_skeleton.scss +2 -4
- package/src/sass/components/_snackbar.scss +27 -21
- package/src/sass/components/_split-button.scss +5 -5
- package/src/sass/components/_stat.scss +3 -8
- package/src/sass/components/_stepper.scss +1 -5
- package/src/sass/components/_swipe-actions.scss +71 -0
- package/src/sass/components/_tabs.scss +51 -32
- package/src/sass/components/_timeline.scss +12 -12
- package/src/sass/components/_timepicker.scss +111 -112
- package/src/sass/components/_toolbar.scss +35 -47
- package/src/sass/components/_tooltip.scss +21 -12
- package/src/sass/components/_tour.scss +89 -0
- package/src/sass/components/_transfer-list.scss +73 -0
- package/src/sass/components/_transitions.scss +4 -4
- package/src/sass/components/_tree.scss +3 -16
- package/src/sass/components/_treemap-chart.scss +122 -0
- package/src/sass/components/forms/_checkboxes.scss +140 -86
- package/src/sass/components/forms/_color-picker.scss +135 -0
- package/src/sass/components/forms/_color-swatches.scss +85 -0
- package/src/sass/components/forms/_drop-zone.scss +15 -9
- package/src/sass/components/forms/_fieldset.scss +10 -10
- package/src/sass/components/forms/_file-input.scss +6 -9
- package/src/sass/components/forms/_index.scss +3 -1
- package/src/sass/components/forms/_input-fields.scss +254 -90
- package/src/sass/components/forms/_radio-buttons.scss +40 -127
- package/src/sass/components/forms/_rating.scss +2 -32
- package/src/sass/components/forms/_select.scss +199 -23
- package/src/sass/components/forms/_slider.scss +140 -330
- package/src/sass/components/forms/_switches.scss +53 -164
- package/src/sass/custom.scss +10 -1
- package/src/sass/expressive.scss +3 -63
- package/src/sass/tokens/_contrast.scss +94 -0
- package/src/sass/tokens/_elevation.scss +16 -0
- package/src/sass/tokens/_index.scss +5 -0
- package/src/sass/tokens/_motion.scss +109 -0
- package/src/sass/tokens/_reference.scss +72 -141
- package/src/sass/tokens/_shape.scss +38 -0
- package/src/sass/tokens/_stacking.scss +27 -0
- package/src/sass/tokens/_state.scss +2 -4
- package/src/sass/tokens/_theme.scss +11 -2
- package/src/sass/tokens/_vibrant.scss +2 -5
- package/src/sass/utilities/_colors.scss +6 -1
- package/src/sass/utilities/_defer-render.scss +17 -0
- package/src/sass/utilities/_helpers.scss +183 -26
- package/src/sass/utilities/_index.scss +2 -1
- package/src/sass/utilities/_scroll-area.scss +0 -2
- package/src/sass/utilities/_spacing.scss +52 -34
- package/src/sass/utilities/_typescale.scss +8 -1
- package/src/sass/utilities/_visibility.scss +47 -76
- package/src/sass/utilities/_z-depth.scss +7 -4
- package/dist/js/chunks/chunk-3DHK5CZU.mjs.map +0 -7
- package/dist/js/chunks/chunk-3GVFZ4XO.mjs.map +0 -7
- package/dist/js/chunks/chunk-4HZMB7LI.mjs.map +0 -7
- package/dist/js/chunks/chunk-4KMNFIFZ.mjs +0 -270
- package/dist/js/chunks/chunk-4KMNFIFZ.mjs.map +0 -7
- package/dist/js/chunks/chunk-4TKTLGEM.mjs.map +0 -7
- package/dist/js/chunks/chunk-5BKHWHYY.mjs +0 -292
- package/dist/js/chunks/chunk-5BKHWHYY.mjs.map +0 -7
- package/dist/js/chunks/chunk-5HQSGDZ5.mjs.map +0 -7
- package/dist/js/chunks/chunk-6N2XAEFK.mjs +0 -125
- package/dist/js/chunks/chunk-6N2XAEFK.mjs.map +0 -7
- package/dist/js/chunks/chunk-A7ALMYUR.mjs.map +0 -7
- package/dist/js/chunks/chunk-BG6ZRB5H.mjs.map +0 -7
- package/dist/js/chunks/chunk-CUQPB25U.mjs +0 -55
- package/dist/js/chunks/chunk-CUQPB25U.mjs.map +0 -7
- package/dist/js/chunks/chunk-DAIU5SLG.mjs.map +0 -7
- package/dist/js/chunks/chunk-FS7XY3HT.mjs.map +0 -7
- package/dist/js/chunks/chunk-GIW4K4SE.mjs.map +0 -7
- package/dist/js/chunks/chunk-GUB3TNO2.mjs.map +0 -7
- package/dist/js/chunks/chunk-GVGT6MIU.mjs.map +0 -7
- package/dist/js/chunks/chunk-GZKEFWPM.mjs +0 -181
- package/dist/js/chunks/chunk-GZKEFWPM.mjs.map +0 -7
- package/dist/js/chunks/chunk-HKT2S7VM.mjs +0 -48
- package/dist/js/chunks/chunk-HKT2S7VM.mjs.map +0 -7
- package/dist/js/chunks/chunk-ILP3PDTL.mjs +0 -187
- package/dist/js/chunks/chunk-ILP3PDTL.mjs.map +0 -7
- package/dist/js/chunks/chunk-JIDMQGK6.mjs.map +0 -7
- package/dist/js/chunks/chunk-KBNN3QDH.mjs +0 -7
- package/dist/js/chunks/chunk-KBNN3QDH.mjs.map +0 -7
- package/dist/js/chunks/chunk-KHV6DZXX.mjs.map +0 -7
- package/dist/js/chunks/chunk-KY6U46SM.mjs +0 -345
- package/dist/js/chunks/chunk-KY6U46SM.mjs.map +0 -7
- package/dist/js/chunks/chunk-LRZMJZ3T.mjs +0 -291
- package/dist/js/chunks/chunk-LRZMJZ3T.mjs.map +0 -7
- package/dist/js/chunks/chunk-LTWPGFBR.mjs +0 -59
- package/dist/js/chunks/chunk-LTWPGFBR.mjs.map +0 -7
- package/dist/js/chunks/chunk-MNPROCZF.mjs +0 -328
- package/dist/js/chunks/chunk-MNPROCZF.mjs.map +0 -7
- package/dist/js/chunks/chunk-MZ6Z24BX.mjs.map +0 -7
- package/dist/js/chunks/chunk-NS2UMNZV.mjs.map +0 -7
- package/dist/js/chunks/chunk-O5XPWXIQ.mjs +0 -406
- package/dist/js/chunks/chunk-O5XPWXIQ.mjs.map +0 -7
- package/dist/js/chunks/chunk-PM655FXL.mjs.map +0 -7
- package/dist/js/chunks/chunk-QDAL4IYN.mjs.map +0 -7
- package/dist/js/chunks/chunk-QERLECVU.mjs +0 -572
- package/dist/js/chunks/chunk-QERLECVU.mjs.map +0 -7
- package/dist/js/chunks/chunk-QJABDLSD.mjs +0 -112
- package/dist/js/chunks/chunk-QJABDLSD.mjs.map +0 -7
- package/dist/js/chunks/chunk-RHRQKTTX.mjs +0 -139
- package/dist/js/chunks/chunk-RHRQKTTX.mjs.map +0 -7
- package/dist/js/chunks/chunk-S3XDFGSZ.mjs.map +0 -7
- package/dist/js/chunks/chunk-SPETGK25.mjs +0 -59
- package/dist/js/chunks/chunk-SPETGK25.mjs.map +0 -7
- package/dist/js/chunks/chunk-TBM3FT7G.mjs.map +0 -7
- package/dist/js/chunks/chunk-UEXCIMJZ.mjs.map +0 -7
- package/dist/js/chunks/chunk-UEZUJQ66.mjs.map +0 -7
- package/dist/js/chunks/chunk-VGZSAFTX.mjs +0 -173
- package/dist/js/chunks/chunk-VGZSAFTX.mjs.map +0 -7
- package/dist/js/chunks/chunk-X7OCHZVF.mjs +0 -76
- package/dist/js/chunks/chunk-X7OCHZVF.mjs.map +0 -7
- package/dist/js/chunks/chunk-YDCS5S3J.mjs.map +0 -7
- package/dist/js/chunks/chunk-YMSXJON6.mjs +0 -79
- package/dist/js/chunks/chunk-YMSXJON6.mjs.map +0 -7
- package/dist/js/chunks/chunk-Z2NRKI7R.mjs.map +0 -7
- package/dist/js/chunks/chunk-ZAS25YFD.mjs.map +0 -7
- package/dist/js/chunks/chunk-ZKZKNSLC.mjs +0 -1
- /package/dist/js/chunks/{chunk-ZKZKNSLC.mjs.map → chunk-GNRSYMVH.mjs.map} +0 -0
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Utils
|
|
3
|
-
} from "./chunk-MNPROCZF.mjs";
|
|
4
1
|
import {
|
|
5
2
|
Component
|
|
6
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CMGXGYUC.mjs";
|
|
4
|
+
import {
|
|
5
|
+
Utils,
|
|
6
|
+
controllerFor,
|
|
7
|
+
restoreAttribute
|
|
8
|
+
} from "./chunk-ZVLOUDIJ.mjs";
|
|
7
9
|
|
|
8
10
|
// src/ts/components/lightbox.ts
|
|
9
11
|
var _defaults = {
|
|
@@ -14,16 +16,17 @@ var _defaults = {
|
|
|
14
16
|
onCloseStart: null,
|
|
15
17
|
onCloseEnd: null
|
|
16
18
|
};
|
|
17
|
-
var
|
|
19
|
+
var Lightbox = class extends Component {
|
|
18
20
|
constructor(el, options) {
|
|
19
|
-
super(el, options
|
|
20
|
-
/** Ancestors forced to `overflow: visible`, with the inline value to put back. */
|
|
21
|
-
this._changedAncestorList = [];
|
|
21
|
+
super(el, options);
|
|
22
22
|
this._timers = /* @__PURE__ */ new Map();
|
|
23
23
|
this._motion = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
24
24
|
this._isOpen = false;
|
|
25
25
|
this._destroyed = false;
|
|
26
26
|
this._revision = 0;
|
|
27
|
+
// Counts opens and closes only. _revision also moves when reduced motion
|
|
28
|
+
// flushes a transition, which must still report its end.
|
|
29
|
+
this._phase = 0;
|
|
27
30
|
this._handleMotionChange = () => {
|
|
28
31
|
if (!this._motion.matches) return;
|
|
29
32
|
const callbacks = [...this._timers.values()];
|
|
@@ -36,11 +39,8 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
36
39
|
for (const el of [this.el, this._overlay, this._photoCaption]) if (el) el.style.transition = "none";
|
|
37
40
|
}
|
|
38
41
|
};
|
|
39
|
-
this._handleLightboxClick = () => {
|
|
40
|
-
this._handleLightboxToggle();
|
|
41
|
-
};
|
|
42
42
|
this._handleLightboxKeypress = (e) => {
|
|
43
|
-
if (this._trigger === this.el && (e.key ===
|
|
43
|
+
if (this._trigger === this.el && (e.key === "Enter" || e.key === " ")) {
|
|
44
44
|
e.preventDefault();
|
|
45
45
|
this._handleLightboxToggle();
|
|
46
46
|
}
|
|
@@ -49,42 +49,42 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
49
49
|
if (this._isOpen) this.close();
|
|
50
50
|
else this.open();
|
|
51
51
|
};
|
|
52
|
-
this.
|
|
53
|
-
if (this.overlayActive) this.close();
|
|
54
|
-
};
|
|
55
|
-
this._handleWindowResize = () => {
|
|
52
|
+
this._handleWindowChange = () => {
|
|
56
53
|
if (this.overlayActive) this.close();
|
|
57
54
|
};
|
|
58
55
|
this._handleWindowEscape = (e) => {
|
|
59
|
-
if (e.key ===
|
|
56
|
+
if (e.key === "Escape") this.close();
|
|
57
|
+
};
|
|
58
|
+
// The image zooms in place, not in a modal, so Tab would reach the page
|
|
59
|
+
// behind the overlay. Tab closes it instead, then moves focus as usual.
|
|
60
|
+
this._handleWindowTab = (e) => {
|
|
61
|
+
if (e.key === "Tab") this.close();
|
|
60
62
|
};
|
|
61
63
|
/**
|
|
62
64
|
* Open lightbox.
|
|
63
65
|
*/
|
|
64
66
|
this.open = () => {
|
|
65
67
|
if (this._destroyed || this._isOpen) return;
|
|
68
|
+
this._phase++;
|
|
66
69
|
const revision = this._cancel();
|
|
67
70
|
if (this.overlayActive) this._reset();
|
|
68
|
-
this._isOpen = true;
|
|
69
71
|
this._updateVars();
|
|
70
72
|
const originRect = this.el.getBoundingClientRect();
|
|
71
73
|
const placeholderRect = this.placeholder.getBoundingClientRect();
|
|
74
|
+
if (!originRect.width || !originRect.height) return;
|
|
75
|
+
this._isOpen = true;
|
|
72
76
|
this.originalWidth = originRect.width;
|
|
73
77
|
this.originalHeight = originRect.height;
|
|
74
78
|
this.doneAnimating = false;
|
|
75
79
|
this.el.classList.add("active");
|
|
76
80
|
this.overlayActive = true;
|
|
77
|
-
if (
|
|
78
|
-
this.options.onOpenStart.call(this, this.el);
|
|
79
|
-
if (revision !== this._revision) return;
|
|
81
|
+
if (!this._notify("open", this.options.onOpenStart, { current: () => revision === this._revision })) return;
|
|
80
82
|
this.placeholder.style.width = placeholderRect.width + "px";
|
|
81
83
|
this.placeholder.style.height = placeholderRect.height + "px";
|
|
82
|
-
this.placeholder.style.position = "relative";
|
|
83
|
-
this.placeholder.style.top = "0";
|
|
84
|
-
this.placeholder.style.left = "0";
|
|
85
|
-
this._makeAncestorsOverflowVisible();
|
|
86
84
|
this.el.style.position = "absolute";
|
|
87
|
-
this.el.style.
|
|
85
|
+
this.el.style.inset = "auto";
|
|
86
|
+
this.el.style.left = placeholderRect.left + window.scrollX + "px";
|
|
87
|
+
this.el.style.top = placeholderRect.top + window.scrollY + "px";
|
|
88
88
|
this.el.style.willChange = "left, top, width, height";
|
|
89
89
|
this.attrWidth = this.el.getAttribute("width");
|
|
90
90
|
this.attrHeight = this.el.getAttribute("height");
|
|
@@ -97,11 +97,10 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
97
97
|
this.el.removeAttribute("height");
|
|
98
98
|
}
|
|
99
99
|
this._addOverlay();
|
|
100
|
+
this._showOnTop(this.el);
|
|
100
101
|
if (this.caption !== "") this._addCaption();
|
|
101
102
|
const widthPercent = this.originalWidth / this.windowWidth;
|
|
102
103
|
const heightPercent = this.originalHeight / this.windowHeight;
|
|
103
|
-
this.newWidth = 0;
|
|
104
|
-
this.newHeight = 0;
|
|
105
104
|
if (widthPercent > heightPercent) {
|
|
106
105
|
const ratio = this.originalHeight / this.originalWidth;
|
|
107
106
|
this.newWidth = this.windowWidth * 0.9;
|
|
@@ -111,9 +110,13 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
111
110
|
this.newWidth = this.windowHeight * 0.9 * ratio;
|
|
112
111
|
this.newHeight = this.windowHeight * 0.9;
|
|
113
112
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
this._windowEvents?.abort();
|
|
114
|
+
this._windowEvents = controllerFor(this.el);
|
|
115
|
+
const { signal } = this._windowEvents;
|
|
116
|
+
window.addEventListener("scroll", this._handleWindowChange, { passive: true, signal });
|
|
117
|
+
window.addEventListener("resize", this._handleWindowChange, { passive: true, signal });
|
|
118
|
+
window.addEventListener("keyup", this._handleWindowEscape, { signal });
|
|
119
|
+
window.addEventListener("keydown", this._handleWindowTab, { signal });
|
|
117
120
|
this._animateImageIn();
|
|
118
121
|
};
|
|
119
122
|
/**
|
|
@@ -121,24 +124,17 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
121
124
|
*/
|
|
122
125
|
this.close = () => {
|
|
123
126
|
if (this._destroyed || !this._isOpen) return;
|
|
127
|
+
this._phase++;
|
|
124
128
|
const revision = this._cancel();
|
|
125
129
|
this._isOpen = false;
|
|
126
130
|
this.doneAnimating = false;
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
window.removeEventListener("keyup", this._handleWindowEscape);
|
|
133
|
-
if (this._overlay) this._removeOverlay();
|
|
134
|
-
if (this._photoCaption) this._removeCaption();
|
|
131
|
+
if (!this._notify("close", this.options.onCloseStart, { current: () => revision === this._revision })) return;
|
|
132
|
+
this._windowEvents?.abort();
|
|
133
|
+
this._restoreFocus();
|
|
134
|
+
if (this._overlay) this._fadeOut(this._overlay);
|
|
135
|
+
if (this._photoCaption) this._fadeOut(this._photoCaption);
|
|
135
136
|
this._animateImageOut();
|
|
136
137
|
};
|
|
137
|
-
this.el["Expressive_Lightbox"] = this;
|
|
138
|
-
this.options = {
|
|
139
|
-
..._Lightbox.defaults,
|
|
140
|
-
...options
|
|
141
|
-
};
|
|
142
138
|
this.overlayActive = false;
|
|
143
139
|
this.doneAnimating = true;
|
|
144
140
|
this.placeholder = document.createElement("div");
|
|
@@ -157,53 +153,35 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
157
153
|
static get defaults() {
|
|
158
154
|
return _defaults;
|
|
159
155
|
}
|
|
160
|
-
/**
|
|
161
|
-
* Initializes instances of Lightbox.
|
|
162
|
-
* @param els HTML elements.
|
|
163
|
-
* @param options Component options.
|
|
164
|
-
*/
|
|
165
|
-
static init(els, options = {}) {
|
|
166
|
-
return super.init(els, options, _Lightbox);
|
|
167
|
-
}
|
|
168
|
-
static getInstance(el) {
|
|
169
|
-
return el["Expressive_Lightbox"];
|
|
170
|
-
}
|
|
171
156
|
destroy() {
|
|
172
157
|
if (this._destroyed) return;
|
|
173
158
|
this._destroyed = true;
|
|
174
|
-
const
|
|
175
|
-
const focused = root.activeElement === this.el;
|
|
176
|
-
this._removeEventHandlers();
|
|
159
|
+
const focused = this.el.getRootNode().activeElement === this.el;
|
|
177
160
|
this._cancel();
|
|
178
161
|
this._reset();
|
|
179
162
|
this.placeholder.replaceWith(this.el);
|
|
163
|
+
if (focused) this._restoreFocus();
|
|
164
|
+
restoreAttribute(this.el, "tabindex", this._tabindex);
|
|
165
|
+
super.destroy();
|
|
166
|
+
}
|
|
167
|
+
// Back to the trigger when focus fell to the body (or the shadow host), as
|
|
168
|
+
// a click on the overlay, which cannot take focus, leaves it.
|
|
169
|
+
_restoreFocus() {
|
|
170
|
+
const root = this.el.getRootNode();
|
|
180
171
|
let active = document.activeElement;
|
|
181
172
|
while (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;
|
|
182
|
-
if (
|
|
183
|
-
if (this._tabindex === null) this.el.removeAttribute("tabindex");
|
|
184
|
-
else this.el.setAttribute("tabindex", this._tabindex);
|
|
185
|
-
this.el["Expressive_Lightbox"] = void 0;
|
|
173
|
+
if ([document.body, root.host].includes(active)) this._trigger.focus({ preventScroll: true });
|
|
186
174
|
}
|
|
187
175
|
_reset() {
|
|
188
|
-
|
|
189
|
-
window.removeEventListener("resize", this._handleWindowResize);
|
|
190
|
-
window.removeEventListener("keyup", this._handleWindowEscape);
|
|
176
|
+
this._windowEvents?.abort();
|
|
191
177
|
this._overlay?.remove();
|
|
192
178
|
this._photoCaption?.remove();
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
ancestor.style.setProperty("overflow", saved.value, saved.priority);
|
|
197
|
-
_Lightbox._overflow.delete(ancestor);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
this._changedAncestorList = [];
|
|
201
|
-
if (this.attrWidth !== null && this.attrWidth !== void 0) this.el.setAttribute("width", this.attrWidth);
|
|
202
|
-
if (this.attrHeight !== null && this.attrHeight !== void 0) this.el.setAttribute("height", this.attrHeight);
|
|
179
|
+
this.el.removeAttribute("popover");
|
|
180
|
+
if (this.attrWidth != null) this.el.setAttribute("width", this.attrWidth);
|
|
181
|
+
if (this.attrHeight != null) this.el.setAttribute("height", this.attrHeight);
|
|
203
182
|
this.el.classList.remove("active");
|
|
204
183
|
this.placeholder.removeAttribute("style");
|
|
205
|
-
|
|
206
|
-
else this.el.setAttribute("style", this.originInlineStyles);
|
|
184
|
+
restoreAttribute(this.el, "style", this.originInlineStyles);
|
|
207
185
|
this.overlayActive = false;
|
|
208
186
|
this._isOpen = false;
|
|
209
187
|
this.doneAnimating = true;
|
|
@@ -225,37 +203,23 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
225
203
|
this._timers.set(timer, callback);
|
|
226
204
|
}
|
|
227
205
|
_setupEventHandlers() {
|
|
228
|
-
|
|
229
|
-
this.
|
|
230
|
-
this.
|
|
206
|
+
const { signal } = this._events;
|
|
207
|
+
this._motion.addEventListener("change", this._handleMotionChange, { signal });
|
|
208
|
+
this._trigger.addEventListener("click", this._handleLightboxToggle, { signal });
|
|
209
|
+
this.el.addEventListener("keydown", this._handleLightboxKeypress, { signal });
|
|
231
210
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
211
|
+
/**
|
|
212
|
+
* Shows `el` as a manual popover, so it is in the top layer: no ancestor
|
|
213
|
+
* clips or covers it, and it stacks above what was shown before it.
|
|
214
|
+
*/
|
|
215
|
+
_showOnTop(el) {
|
|
216
|
+
el.setAttribute("popover", "manual");
|
|
217
|
+
el.showPopover();
|
|
236
218
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
const curr = ancestor;
|
|
242
|
-
if (curr.style && (curr.style.overflow !== "visible" || _Lightbox._overflow.has(curr))) {
|
|
243
|
-
const saved = _Lightbox._overflow.get(curr) ?? { count: 0, value: curr.style.overflow, priority: curr.style.getPropertyPriority("overflow") };
|
|
244
|
-
saved.count++;
|
|
245
|
-
_Lightbox._overflow.set(curr, saved);
|
|
246
|
-
this._changedAncestorList.push(curr);
|
|
247
|
-
curr.style.overflow = "visible";
|
|
248
|
-
}
|
|
249
|
-
ancestor = ancestor.parentNode ?? ancestor.host;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
_offset(el) {
|
|
253
|
-
const box = el.getBoundingClientRect();
|
|
254
|
-
const docElem = document.documentElement;
|
|
255
|
-
return {
|
|
256
|
-
top: box.top + window.scrollY - docElem.clientTop,
|
|
257
|
-
left: box.left + window.scrollX - docElem.clientLeft
|
|
258
|
-
};
|
|
219
|
+
/** The placeholder's document position, where the image rests. */
|
|
220
|
+
_restingPlace() {
|
|
221
|
+
const box = this.placeholder.getBoundingClientRect();
|
|
222
|
+
return { left: box.left + window.scrollX + "px", top: box.top + window.scrollY + "px" };
|
|
259
223
|
}
|
|
260
224
|
_updateVars() {
|
|
261
225
|
this.windowWidth = window.innerWidth;
|
|
@@ -264,6 +228,7 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
264
228
|
}
|
|
265
229
|
// Image
|
|
266
230
|
_animateImageIn() {
|
|
231
|
+
const phase = this._phase;
|
|
267
232
|
this.el.style.maxHeight = this.newHeight.toString() + "px";
|
|
268
233
|
this.el.style.maxWidth = this.newWidth.toString() + "px";
|
|
269
234
|
const duration = this._motion.matches ? 0 : this.options.inDuration;
|
|
@@ -271,7 +236,6 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
271
236
|
this.el.style.height = this.originalHeight + "px";
|
|
272
237
|
this.el.style.width = this.originalWidth + "px";
|
|
273
238
|
this._schedule(() => {
|
|
274
|
-
const placeholderOffset = this._offset(this.placeholder);
|
|
275
239
|
this.el.style.transition = `height ${duration}ms ease,
|
|
276
240
|
width ${duration}ms ease,
|
|
277
241
|
left ${duration}ms ease,
|
|
@@ -279,15 +243,16 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
279
243
|
`;
|
|
280
244
|
this.el.style.height = this.newHeight + "px";
|
|
281
245
|
this.el.style.width = this.newWidth + "px";
|
|
282
|
-
this.el.style.left =
|
|
283
|
-
this.el.style.top =
|
|
246
|
+
this.el.style.left = window.scrollX + (this.windowWidth - this.newWidth) / 2 + "px";
|
|
247
|
+
this.el.style.top = window.scrollY + (this.windowHeight - this.newHeight) / 2 + "px";
|
|
284
248
|
}, 1);
|
|
285
249
|
this._schedule(() => {
|
|
286
250
|
this.doneAnimating = true;
|
|
287
|
-
|
|
251
|
+
this._notify("opened", this.options.onOpenEnd, { current: () => phase === this._phase });
|
|
288
252
|
}, duration);
|
|
289
253
|
}
|
|
290
254
|
_animateImageOut() {
|
|
255
|
+
const phase = this._phase;
|
|
291
256
|
const duration = this._motion.matches ? 0 : this.options.outDuration;
|
|
292
257
|
this.el.style.transition = `height ${duration}ms ease,
|
|
293
258
|
width ${duration}ms ease,
|
|
@@ -296,12 +261,10 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
296
261
|
`;
|
|
297
262
|
this.el.style.height = this.originalHeight + "px";
|
|
298
263
|
this.el.style.width = this.originalWidth + "px";
|
|
299
|
-
this.el.style.
|
|
300
|
-
this.el.style.top = "0";
|
|
264
|
+
Object.assign(this.el.style, this._restingPlace());
|
|
301
265
|
this._schedule(() => {
|
|
302
266
|
this._reset();
|
|
303
|
-
|
|
304
|
-
this.options.onCloseEnd.call(this, this.el);
|
|
267
|
+
this._notify("closed", this.options.onCloseEnd, { current: () => phase === this._phase });
|
|
305
268
|
}, duration);
|
|
306
269
|
}
|
|
307
270
|
// Caption
|
|
@@ -311,18 +274,8 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
311
274
|
this._photoCaption.innerText = this.caption;
|
|
312
275
|
Utils.portalRoot(this.el).append(this._photoCaption);
|
|
313
276
|
this._photoCaption.style.display = "inline";
|
|
314
|
-
this._photoCaption
|
|
315
|
-
this._photoCaption
|
|
316
|
-
const duration = this._motion.matches ? 0 : this.options.inDuration;
|
|
317
|
-
this._schedule(() => {
|
|
318
|
-
this._photoCaption.style.transition = `opacity ${duration}ms ease`;
|
|
319
|
-
this._photoCaption.style.opacity = "1";
|
|
320
|
-
}, 1);
|
|
321
|
-
}
|
|
322
|
-
_removeCaption() {
|
|
323
|
-
const duration = this._motion.matches ? 0 : this.options.outDuration;
|
|
324
|
-
this._photoCaption.style.transition = `opacity ${duration}ms ease`;
|
|
325
|
-
this._photoCaption.style.opacity = "0";
|
|
277
|
+
this._showOnTop(this._photoCaption);
|
|
278
|
+
this._fadeIn(this._photoCaption);
|
|
326
279
|
}
|
|
327
280
|
// Overlay
|
|
328
281
|
_addOverlay() {
|
|
@@ -337,29 +290,27 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
337
290
|
{ once: true }
|
|
338
291
|
);
|
|
339
292
|
this.el.before(this._overlay);
|
|
340
|
-
|
|
341
|
-
this.
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
this._overlay.style.opacity = "0";
|
|
293
|
+
this._showOnTop(this._overlay);
|
|
294
|
+
this._fadeIn(this._overlay);
|
|
295
|
+
}
|
|
296
|
+
_fadeIn(el) {
|
|
297
|
+
el.style.transition = "none";
|
|
298
|
+
el.style.opacity = "0";
|
|
347
299
|
const duration = this._motion.matches ? 0 : this.options.inDuration;
|
|
348
300
|
this._schedule(() => {
|
|
349
|
-
|
|
350
|
-
|
|
301
|
+
el.style.transition = `opacity ${duration}ms ease`;
|
|
302
|
+
el.style.opacity = "1";
|
|
351
303
|
}, 1);
|
|
352
304
|
}
|
|
353
|
-
|
|
305
|
+
_fadeOut(el) {
|
|
354
306
|
const duration = this._motion.matches ? 0 : this.options.outDuration;
|
|
355
|
-
|
|
356
|
-
|
|
307
|
+
el.style.transition = `opacity ${duration}ms ease`;
|
|
308
|
+
el.style.opacity = "0";
|
|
357
309
|
}
|
|
358
310
|
};
|
|
359
|
-
|
|
360
|
-
var Lightbox = _Lightbox;
|
|
311
|
+
Lightbox.key = "Expressive_Lightbox";
|
|
361
312
|
|
|
362
313
|
export {
|
|
363
314
|
Lightbox
|
|
364
315
|
};
|
|
365
|
-
//# sourceMappingURL=chunk-
|
|
316
|
+
//# sourceMappingURL=chunk-VMY55K2X.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/ts/components/lightbox.ts"],
|
|
4
|
+
"sourcesContent": ["import { Utils, controllerFor, restoreAttribute } from '../core/utils';\nimport { BaseOptions, Component } from '../core/component';\n\nexport interface LightboxOptions extends BaseOptions {\n /**\n * Transition in duration in milliseconds.\n * @default 275\n */\n inDuration: number;\n /**\n * Transition out duration in milliseconds.\n * @default 200\n */\n outDuration: number;\n /**\n * Callback function called before lightbox is opened.\n * @default null\n */\n onOpenStart: (el: Element) => void;\n /**\n * Callback function called after lightbox is opened.\n * @default null\n */\n onOpenEnd: (el: Element) => void;\n /**\n * Callback function called before lightbox is closed.\n * @default null\n */\n onCloseStart: (el: Element) => void;\n /**\n * Callback function called after lightbox is closed.\n * @default null\n */\n onCloseEnd: (el: Element) => void;\n}\n\nconst _defaults: LightboxOptions = {\n inDuration: 275,\n outDuration: 200,\n onOpenStart: null,\n onOpenEnd: null,\n onCloseStart: null,\n onCloseEnd: null\n};\n\nexport class Lightbox extends Component<LightboxOptions> {\n /** If the lightbox overlay is showing. */\n overlayActive: boolean;\n /** If the lightbox is no longer being animated. */\n doneAnimating: boolean;\n /** Caption, if specified. */\n caption: string;\n /** Original width of image. */\n originalWidth: number;\n /** Original height of image. */\n originalHeight: number;\n private originInlineStyles: string;\n private placeholder: HTMLElement;\n private newHeight: number;\n private newWidth: number;\n private windowWidth: number;\n private windowHeight: number;\n private attrWidth: string;\n private attrHeight: string;\n private _overlay: HTMLElement;\n private _photoCaption: HTMLElement;\n private _trigger: HTMLElement;\n private _tabindex: string | null;\n private _timers = new Map<ReturnType<typeof setTimeout>, () => void>();\n private _motion = window.matchMedia('(prefers-reduced-motion: reduce)');\n private _isOpen = false;\n private _destroyed = false;\n /** Removes the listeners that close an open lightbox. */\n private _windowEvents: AbortController | undefined;\n private _revision = 0;\n // Counts opens and closes only. _revision also moves when reduced motion\n // flushes a transition, which must still report its end.\n private _phase = 0;\n\n constructor(el: HTMLElement, options: Partial<LightboxOptions>) {\n super(el, options);\n\n this.overlayActive = false;\n this.doneAnimating = true;\n this.placeholder = document.createElement('div');\n this.placeholder.classList.add('material-placeholder');\n this.originalWidth = 0;\n this.originalHeight = 0;\n this.originInlineStyles = this.el.getAttribute('style');\n this.caption = this.el.getAttribute('data-caption') || '';\n this._tabindex = this.el.getAttribute('tabindex');\n this._trigger = this.el.closest('button') ?? this.el;\n this.el.tabIndex = this._trigger === this.el ? 0 : -1;\n // Wrap\n this.el.before(this.placeholder);\n this.placeholder.append(this.el);\n this._setupEventHandlers();\n }\n\n static get defaults(): LightboxOptions {\n return _defaults;\n }\n\n static key = 'Expressive_Lightbox';\n\n destroy() {\n if (this._destroyed) return;\n this._destroyed = true;\n const focused = (this.el.getRootNode() as Document | ShadowRoot).activeElement === this.el;\n this._cancel();\n this._reset();\n this.placeholder.replaceWith(this.el);\n if (focused) this._restoreFocus();\n restoreAttribute(this.el, 'tabindex', this._tabindex);\n super.destroy();\n }\n\n // Back to the trigger when focus fell to the body (or the shadow host), as\n // a click on the overlay, which cannot take focus, leaves it.\n private _restoreFocus() {\n const root = this.el.getRootNode() as Document | ShadowRoot;\n let active = document.activeElement;\n while (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;\n if ([document.body, (root as ShadowRoot).host].includes(active)) this._trigger.focus({ preventScroll: true });\n }\n\n private _reset() {\n this._windowEvents?.abort();\n // Removing a popover, or its attribute, takes it out of the top layer.\n this._overlay?.remove();\n this._photoCaption?.remove();\n this.el.removeAttribute('popover');\n if (this.attrWidth != null) this.el.setAttribute('width', this.attrWidth);\n if (this.attrHeight != null) this.el.setAttribute('height', this.attrHeight);\n this.el.classList.remove('active');\n this.placeholder.removeAttribute('style');\n restoreAttribute(this.el, 'style', this.originInlineStyles);\n this.overlayActive = false;\n this._isOpen = false;\n this.doneAnimating = true;\n }\n\n private _cancel() {\n for (const timer of this._timers.keys()) clearTimeout(timer);\n this._timers.clear();\n return ++this._revision;\n }\n\n private _schedule(callback: () => void, delay: number) {\n if (this._motion.matches) { callback(); return; }\n const timer = setTimeout(() => { this._timers.delete(timer); callback(); }, delay);\n this._timers.set(timer, callback);\n }\n\n private _handleMotionChange = () => {\n if (!this._motion.matches) return;\n const callbacks = [...this._timers.values()];\n const revision = this._cancel();\n for (const callback of callbacks) {\n if (revision !== this._revision) break;\n callback();\n }\n if (this.overlayActive) {\n for (const el of [this.el, this._overlay, this._photoCaption]) if (el) el.style.transition = 'none';\n }\n };\n\n private _setupEventHandlers() {\n const { signal } = this._events;\n this._motion.addEventListener('change', this._handleMotionChange, { signal });\n this._trigger.addEventListener('click', this._handleLightboxToggle, { signal });\n this.el.addEventListener('keydown', this._handleLightboxKeypress, { signal });\n }\n\n private _handleLightboxKeypress = (e: KeyboardEvent) => {\n if (this._trigger === this.el && (e.key === 'Enter' || e.key === ' ')) {\n e.preventDefault();\n this._handleLightboxToggle();\n }\n };\n\n private _handleLightboxToggle = () => {\n // If already modal, return to original\n if (this._isOpen) this.close();\n else this.open();\n };\n\n private _handleWindowChange = () => {\n if (this.overlayActive) this.close();\n };\n\n private _handleWindowEscape = (e: KeyboardEvent) => {\n if (e.key === 'Escape') this.close();\n };\n\n // The image zooms in place, not in a modal, so Tab would reach the page\n // behind the overlay. Tab closes it instead, then moves focus as usual.\n private _handleWindowTab = (e: KeyboardEvent) => {\n if (e.key === 'Tab') this.close();\n };\n\n /**\n * Shows `el` as a manual popover, so it is in the top layer: no ancestor\n * clips or covers it, and it stacks above what was shown before it.\n */\n private _showOnTop(el: HTMLElement) {\n el.setAttribute('popover', 'manual');\n el.showPopover();\n }\n\n /** The placeholder's document position, where the image rests. */\n private _restingPlace() {\n const box = this.placeholder.getBoundingClientRect();\n return { left: box.left + window.scrollX + 'px', top: box.top + window.scrollY + 'px' };\n }\n\n private _updateVars(): void {\n this.windowWidth = window.innerWidth;\n this.windowHeight = window.innerHeight;\n this.caption = this.el.getAttribute('data-caption') || '';\n }\n\n // Image\n private _animateImageIn(): void {\n const phase = this._phase;\n this.el.style.maxHeight = this.newHeight.toString() + 'px';\n this.el.style.maxWidth = this.newWidth.toString() + 'px';\n const duration = this._motion.matches ? 0 : this.options.inDuration;\n // from\n this.el.style.transition = 'none';\n this.el.style.height = this.originalHeight + 'px';\n this.el.style.width = this.originalWidth + 'px';\n this._schedule(() => {\n // easeOutQuad\n this.el.style.transition = `height ${duration}ms ease,\n width ${duration}ms ease,\n left ${duration}ms ease,\n top ${duration}ms ease\n `;\n // to\n this.el.style.height = this.newHeight + 'px';\n this.el.style.width = this.newWidth + 'px';\n this.el.style.left = window.scrollX + (this.windowWidth - this.newWidth) / 2 + 'px';\n this.el.style.top = window.scrollY + (this.windowHeight - this.newHeight) / 2 + 'px';\n }, 1);\n\n this._schedule(() => {\n this.doneAnimating = true;\n this._notify('opened', this.options.onOpenEnd, { current: () => phase === this._phase });\n }, duration);\n\n }\n private _animateImageOut(): void {\n const phase = this._phase;\n const duration = this._motion.matches ? 0 : this.options.outDuration;\n // easeOutQuad\n this.el.style.transition = `height ${duration}ms ease,\n width ${duration}ms ease,\n left ${duration}ms ease,\n top ${duration}ms ease\n `;\n // to\n this.el.style.height = this.originalHeight + 'px'; // was originalWidth\n this.el.style.width = this.originalWidth + 'px';\n Object.assign(this.el.style, this._restingPlace());\n this._schedule(() => {\n this._reset();\n // onCloseEnd callback\n this._notify('closed', this.options.onCloseEnd, { current: () => phase === this._phase });\n }, duration);\n }\n\n // Caption\n private _addCaption(): void {\n this._photoCaption = document.createElement('div');\n this._photoCaption.classList.add('lightbox-caption');\n this._photoCaption.innerText = this.caption;\n Utils.portalRoot(this.el).append(this._photoCaption);\n this._photoCaption.style.display = 'inline';\n this._showOnTop(this._photoCaption);\n this._fadeIn(this._photoCaption);\n }\n\n // Overlay\n private _addOverlay(): void {\n this._overlay = document.createElement('div');\n this._overlay.id = 'lightbox-overlay';\n this._overlay.addEventListener(\n 'click',\n (event) => {\n event.stopPropagation();\n this.close();\n },\n { once: true }\n );\n\n this.el.before(this._overlay);\n this._showOnTop(this._overlay);\n this._fadeIn(this._overlay);\n }\n\n private _fadeIn(el: HTMLElement): void {\n el.style.transition = 'none';\n el.style.opacity = '0';\n const duration = this._motion.matches ? 0 : this.options.inDuration;\n this._schedule(() => {\n el.style.transition = `opacity ${duration}ms ease`;\n el.style.opacity = '1';\n }, 1);\n }\n\n private _fadeOut(el: HTMLElement): void {\n const duration = this._motion.matches ? 0 : this.options.outDuration;\n el.style.transition = `opacity ${duration}ms ease`;\n el.style.opacity = '0';\n }\n\n /**\n * Open lightbox.\n */\n open = () => {\n if (this._destroyed || this._isOpen) return;\n this._phase++;\n const revision = this._cancel();\n if (this.overlayActive) this._reset();\n this._updateVars();\n // Both rects are read up front: measuring the placeholder after writing\n // its width forced a second layout for the height.\n const originRect = this.el.getBoundingClientRect();\n const placeholderRect = this.placeholder.getBoundingClientRect();\n // An image not yet loaded, or hidden, has no size to zoom from; the\n // ratios below would be 0 / 0.\n if (!originRect.width || !originRect.height) return;\n this._isOpen = true;\n this.originalWidth = originRect.width;\n this.originalHeight = originRect.height;\n // Set states\n this.doneAnimating = false;\n this.el.classList.add('active');\n this.overlayActive = true;\n // onOpenStart callback\n if (!this._notify('open', this.options.onOpenStart, { current: () => revision === this._revision })) return;\n // Set positioning for placeholder\n this.placeholder.style.width = placeholderRect.width + 'px';\n this.placeholder.style.height = placeholderRect.height + 'px';\n // In the top layer the image is positioned in the document, starting\n // where the placeholder holds its place.\n this.el.style.position = 'absolute';\n this.el.style.inset = 'auto';\n this.el.style.left = placeholderRect.left + window.scrollX + 'px';\n this.el.style.top = placeholderRect.top + window.scrollY + 'px';\n this.el.style.willChange = 'left, top, width, height';\n // Change from width or height attribute to css\n this.attrWidth = this.el.getAttribute('width');\n this.attrHeight = this.el.getAttribute('height');\n if (this.attrWidth) {\n this.el.style.width = this.attrWidth + 'px';\n this.el.removeAttribute('width');\n }\n if (this.attrHeight) {\n this.el.style.height = this.attrHeight + 'px'; // was width, from the height attribute\n this.el.removeAttribute('height');\n }\n // The overlay, the image and the caption go into the top layer in that\n // order, so each stacks above the one before.\n this._addOverlay();\n this._showOnTop(this.el);\n if (this.caption !== '') this._addCaption();\n // Resize Image\n const widthPercent = this.originalWidth / this.windowWidth;\n const heightPercent = this.originalHeight / this.windowHeight;\n if (widthPercent > heightPercent) {\n // Width first\n const ratio = this.originalHeight / this.originalWidth;\n this.newWidth = this.windowWidth * 0.9;\n this.newHeight = this.windowWidth * 0.9 * ratio;\n } else {\n // Height first\n const ratio = this.originalWidth / this.originalHeight;\n this.newWidth = this.windowHeight * 0.9 * ratio;\n this.newHeight = this.windowHeight * 0.9;\n }\n // Handle Exit triggers\n this._windowEvents?.abort();\n this._windowEvents = controllerFor(this.el);\n const { signal } = this._windowEvents;\n window.addEventListener('scroll', this._handleWindowChange, { passive: true, signal });\n window.addEventListener('resize', this._handleWindowChange, { passive: true, signal });\n window.addEventListener('keyup', this._handleWindowEscape, { signal });\n window.addEventListener('keydown', this._handleWindowTab, { signal });\n this._animateImageIn();\n };\n\n /**\n * Close lightbox.\n */\n close = () => {\n if (this._destroyed || !this._isOpen) return;\n this._phase++;\n const revision = this._cancel();\n this._isOpen = false;\n this.doneAnimating = false;\n // onCloseStart callback\n if (!this._notify('close', this.options.onCloseStart, { current: () => revision === this._revision })) return;\n // disable exit handlers\n this._windowEvents?.abort();\n this._restoreFocus();\n if (this._overlay) this._fadeOut(this._overlay);\n if (this._photoCaption) this._fadeOut(this._photoCaption);\n this._animateImageOut();\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAoCA,IAAM,YAA6B;AAAA,EACjC,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AAAA,EACb,WAAW;AAAA,EACX,cAAc;AAAA,EACd,YAAY;AACd;AAEO,IAAM,WAAN,cAAuB,UAA2B;AAAA,EAkCvD,YAAY,IAAiB,SAAmC;AAC9D,UAAM,IAAI,OAAO;AAZnB,SAAQ,UAAU,oBAAI,IAA+C;AACrE,SAAQ,UAAU,OAAO,WAAW,kCAAkC;AACtE,SAAQ,UAAU;AAClB,SAAQ,aAAa;AAGrB,SAAQ,YAAY;AAGpB;AAAA;AAAA,SAAQ,SAAS;AA6EjB,SAAQ,sBAAsB,MAAM;AAClC,UAAI,CAAC,KAAK,QAAQ,QAAS;AAC3B,YAAM,YAAY,CAAC,GAAG,KAAK,QAAQ,OAAO,CAAC;AAC3C,YAAM,WAAW,KAAK,QAAQ;AAC9B,iBAAW,YAAY,WAAW;AAChC,YAAI,aAAa,KAAK,UAAW;AACjC,iBAAS;AAAA,MACX;AACA,UAAI,KAAK,eAAe;AACtB,mBAAW,MAAM,CAAC,KAAK,IAAI,KAAK,UAAU,KAAK,aAAa,EAAG,KAAI,GAAI,IAAG,MAAM,aAAa;AAAA,MAC/F;AAAA,IACF;AASA,SAAQ,0BAA0B,CAAC,MAAqB;AACtD,UAAI,KAAK,aAAa,KAAK,OAAO,EAAE,QAAQ,WAAW,EAAE,QAAQ,MAAM;AACrE,UAAE,eAAe;AACjB,aAAK,sBAAsB;AAAA,MAC7B;AAAA,IACF;AAE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IACf;AAEA,SAAK,GAAG,OAAO,KAAK,QAAQ;AAC5B,SAAK,WAAW,KAAK,QAAQ;AAC7B,SAAK,QAAQ,KAAK,QAAQ;AAAA,EAC5B;AAAA,EAEQ,QAAQ,IAAuB;AACrC,OAAG,MAAM,aAAa;AACtB,OAAG,MAAM,UAAU;AACnB,UAAM,WAAW,KAAK,QAAQ,UAAU,IAAI,KAAK,QAAQ;AACzD,SAAK,UAAU,MAAM;AACnB,SAAG,MAAM,aAAa,WAAW,QAAQ;AACzC,SAAG,MAAM,UAAU;AAAA,IACrB,GAAG,CAAC;AAAA,EACN;AAAA,EAEQ,SAAS,IAAuB;AACtC,UAAM,WAAW,KAAK,QAAQ,UAAU,IAAI,KAAK,QAAQ;AACzD,OAAG,MAAM,aAAa,WAAW,QAAQ;AACzC,OAAG,MAAM,UAAU;AAAA,EACrB;AAgGF;AA9Wa,SA0DJ,MAAM;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Component
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CMGXGYUC.mjs";
|
|
4
4
|
|
|
5
5
|
// src/ts/components/confetti.ts
|
|
6
6
|
var _defaults = {
|
|
@@ -23,26 +23,18 @@ var FALLBACK_COLORS = ["#26ccff", "#a25afd", "#ff5e7e", "#88ff5a", "#fcff42", "#
|
|
|
23
23
|
var RAD = Math.PI / 180;
|
|
24
24
|
var scenes = /* @__PURE__ */ new Map();
|
|
25
25
|
var overlay = null;
|
|
26
|
-
var
|
|
26
|
+
var _Confetti = class _Confetti extends Component {
|
|
27
27
|
constructor(el, options) {
|
|
28
|
-
super(el, options
|
|
28
|
+
super(el, options);
|
|
29
29
|
this._onClick = () => {
|
|
30
30
|
this.fire();
|
|
31
31
|
};
|
|
32
|
-
|
|
33
|
-
this.options = { ..._Confetti.defaults, ...options };
|
|
34
|
-
if (!(el instanceof HTMLCanvasElement)) el.addEventListener("click", this._onClick);
|
|
32
|
+
if (!(el instanceof HTMLCanvasElement)) el.addEventListener("click", this._onClick, { signal: this._events.signal });
|
|
35
33
|
else if (!this.options.manualStart) this.fire();
|
|
36
34
|
}
|
|
37
35
|
static get defaults() {
|
|
38
36
|
return _defaults;
|
|
39
37
|
}
|
|
40
|
-
static init(els, options = {}) {
|
|
41
|
-
return super.init(els, options, _Confetti);
|
|
42
|
-
}
|
|
43
|
-
static getInstance(el) {
|
|
44
|
-
return el["Expressive_Confetti"];
|
|
45
|
-
}
|
|
46
38
|
/**
|
|
47
39
|
* Bursts over the whole viewport. Resolves when the last piece is gone.
|
|
48
40
|
*/
|
|
@@ -64,13 +56,14 @@ var Confetti = class _Confetti extends Component {
|
|
|
64
56
|
return burst(viewportCanvas, this.el.parentElement ?? document.body, merged);
|
|
65
57
|
}
|
|
66
58
|
destroy() {
|
|
67
|
-
this.el.removeEventListener("click", this._onClick);
|
|
68
59
|
if (this.el instanceof HTMLCanvasElement) stop(this.el);
|
|
69
|
-
|
|
60
|
+
super.destroy();
|
|
70
61
|
}
|
|
71
62
|
};
|
|
63
|
+
_Confetti.key = "Expressive_Confetti";
|
|
64
|
+
var Confetti = _Confetti;
|
|
72
65
|
function burst(getCanvas, themed, o) {
|
|
73
|
-
if (
|
|
66
|
+
if (matchMedia("(prefers-reduced-motion: reduce)").matches) return Promise.resolve();
|
|
74
67
|
const canvas = getCanvas();
|
|
75
68
|
let scene = scenes.get(canvas);
|
|
76
69
|
if (!scene) {
|
|
@@ -183,10 +176,11 @@ function viewportCanvas() {
|
|
|
183
176
|
height: "100%",
|
|
184
177
|
margin: "0",
|
|
185
178
|
padding: "0",
|
|
179
|
+
// The fallback keeps the order where the sheet, and so the token, is absent.
|
|
186
180
|
border: "0",
|
|
187
181
|
background: "transparent",
|
|
188
182
|
pointerEvents: "none",
|
|
189
|
-
zIndex: "10001"
|
|
183
|
+
zIndex: "var(--expressive-z-confetti, 10001)"
|
|
190
184
|
});
|
|
191
185
|
document.body.append(overlay);
|
|
192
186
|
if (typeof overlay.showPopover === "function") {
|
|
@@ -211,4 +205,4 @@ function themeColors(themed) {
|
|
|
211
205
|
export {
|
|
212
206
|
Confetti
|
|
213
207
|
};
|
|
214
|
-
//# sourceMappingURL=chunk-
|
|
208
|
+
//# sourceMappingURL=chunk-VR3L2WN5.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/ts/components/confetti.ts"],
|
|
4
|
+
"sourcesContent": ["import { Component, BaseOptions } from '../core/component';\n\nexport type ConfettiShape = 'square' | 'circle' | 'star';\n\nexport interface ConfettiOptions extends BaseOptions {\n /**\n * Pieces per burst.\n * @default 50\n */\n particleCount: number;\n /**\n * Launch direction in degrees. 90 is straight up, 0 is right.\n * @default 90\n */\n angle: number;\n /**\n * How far the pieces fan out from the angle, in degrees.\n * @default 45\n */\n spread: number;\n /**\n * Launch speed in pixels per frame.\n * @default 45\n */\n startVelocity: number;\n /**\n * Share of its speed a piece keeps each frame.\n * @default 0.9\n */\n decay: number;\n /**\n * Pull toward the bottom. 0 floats, 1 is normal.\n * @default 1\n */\n gravity: number;\n /**\n * Sideways push per frame. Negative drifts left.\n * @default 0\n */\n drift: number;\n /**\n * Frames a piece lives while it fades out.\n * @default 200\n */\n ticks: number;\n /**\n * Launch point as fractions of the canvas, 0 to 1. A missing side is\n * 0.5. A trigger element ignores it and launches from its own center.\n * @default { x: 0.5, y: 0.5 }\n */\n origin: { x?: number; y?: number };\n /**\n * CSS colors. Empty uses the theme's primary, secondary and tertiary\n * colors and their containers.\n * @default []\n */\n colors: string[];\n /**\n * @default ['square', 'circle']\n */\n shapes: ConfettiShape[];\n /**\n * Piece size multiplier.\n * @default 1\n */\n scalar: number;\n /**\n * On a canvas, wait for `fire()` instead of bursting once at init.\n * @default false\n */\n manualStart: boolean;\n}\n\nconst _defaults: ConfettiOptions = {\n particleCount: 50,\n angle: 90,\n spread: 45,\n startVelocity: 45,\n decay: 0.9,\n gravity: 1,\n drift: 0,\n ticks: 200,\n origin: { x: 0.5, y: 0.5 },\n colors: [],\n shapes: ['square', 'circle'],\n scalar: 1,\n manualStart: false\n};\n\nconst THEME_COLORS = ['primary', 'secondary', 'tertiary', 'primary-container', 'secondary-container', 'tertiary-container'];\n// Used when the page has no theme tokens.\nconst FALLBACK_COLORS = ['#26ccff', '#a25afd', '#ff5e7e', '#88ff5a', '#fcff42', '#ffa62d', '#ff36ff'];\nconst RAD = Math.PI / 180;\n\ninterface Piece {\n x: number;\n y: number;\n velocity: number;\n angle: number;\n wobble: number;\n wobbleSpeed: number;\n tilt: number;\n tick: number;\n color: string;\n shape: ConfettiShape;\n options: ConfettiOptions;\n}\n\ninterface Scene {\n ctx: CanvasRenderingContext2D;\n pieces: Piece[];\n frame: number;\n last: number;\n done: (() => void)[];\n overlay: boolean;\n}\n\nconst scenes = new Map<HTMLCanvasElement, Scene>();\nlet overlay: HTMLCanvasElement | null = null;\n\n/**\n * Confetti. Bursts of theme-colored pieces drawn on a canvas.\n *\n * - `Confetti.fire(options)` bursts over the whole viewport.\n * - Any other `.confetti` element bursts from its center when clicked.\n * - A `<canvas class=\"confetti\">` bursts inside its own box, once at init\n * unless `manualStart`, and again on each `fire()`.\n *\n * The viewport canvas is a manual popover, so it draws above an open modal\n * dialog, and it ignores the pointer. Nothing is drawn when the reader\n * prefers reduced motion.\n */\nexport class Confetti extends Component<ConfettiOptions> {\n private _onClick = () => { this.fire(); };\n\n constructor(el: HTMLElement, options: Partial<ConfettiOptions>) {\n super(el, options);\n if (!(el instanceof HTMLCanvasElement)) el.addEventListener('click', this._onClick, { signal: this._events.signal });\n else if (!this.options.manualStart) this.fire();\n }\n\n static get defaults(): ConfettiOptions {\n return _defaults;\n }\n\n static key = 'Expressive_Confetti';\n\n /**\n * Bursts over the whole viewport. Resolves when the last piece is gone.\n */\n static fire(options: Partial<ConfettiOptions> = {}): Promise<void> {\n return burst(viewportCanvas, document.body, { ...Confetti.defaults, ...options });\n }\n\n /**\n * Bursts on this canvas, or from this element's center over the viewport.\n * Resolves when the last piece is gone.\n */\n fire(options: Partial<ConfettiOptions> = {}): Promise<void> {\n const merged = { ...this.options, ...options };\n if (this.el instanceof HTMLCanvasElement) {\n const canvas = this.el;\n return burst(() => canvas, canvas.parentElement ?? document.body, merged);\n }\n const r = this.el.getBoundingClientRect();\n merged.origin = { x: (r.left + r.width / 2) / innerWidth, y: (r.top + r.height / 2) / innerHeight };\n return burst(viewportCanvas, this.el.parentElement ?? document.body, merged);\n }\n\n destroy() {\n if (this.el instanceof HTMLCanvasElement) stop(this.el);\n super.destroy();\n }\n}\n\n// `themed` is where the theme colors are read, so a scoped theme applies.\nfunction burst(getCanvas: () => HTMLCanvasElement, themed: Element, o: ConfettiOptions): Promise<void> {\n if (matchMedia('(prefers-reduced-motion: reduce)').matches) return Promise.resolve();\n const canvas = getCanvas();\n let scene = scenes.get(canvas);\n if (!scene) {\n const ctx = canvas.getContext('2d');\n if (!ctx) return Promise.resolve();\n scene = { ctx, pieces: [], frame: 0, last: 0, done: [], overlay: canvas === overlay };\n scenes.set(canvas, scene);\n }\n const { width, height } = fit(canvas);\n const colors = o.colors.length ? o.colors : themeColors(themed);\n const x = (o.origin.x ?? 0.5) * width;\n const y = (o.origin.y ?? 0.5) * height;\n for (let i = 0; i < o.particleCount; i++) {\n scene.pieces.push({\n x, y,\n velocity: o.startVelocity * (0.5 + Math.random()),\n angle: -o.angle * RAD + (0.5 - Math.random()) * o.spread * RAD,\n wobble: Math.random() * 10,\n wobbleSpeed: 0.05 + Math.random() * 0.05,\n tilt: (0.25 + Math.random() / 2) * Math.PI,\n tick: 0,\n color: colors[i % colors.length],\n shape: o.shapes[Math.floor(Math.random() * o.shapes.length)] ?? 'square',\n options: o\n });\n }\n const s = scene;\n if (!s.frame) s.frame = requestAnimationFrame((now) => { s.last = now; draw(canvas, s, now); });\n return new Promise((resolve) => s.done.push(resolve));\n}\n\nfunction draw(canvas: HTMLCanvasElement, scene: Scene, now: number) {\n // Frames are counted at 60 per second whatever the display rate.\n const step = Math.min((now - scene.last) / (1000 / 60), 4);\n scene.last = now;\n const { width, height } = fit(canvas);\n const { ctx } = scene;\n const dpr = canvas.width / (width || 1);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n scene.pieces = scene.pieces.filter((p) => {\n const o = p.options;\n p.x += (Math.cos(p.angle) * p.velocity + o.drift) * step;\n p.y += (Math.sin(p.angle) * p.velocity + o.gravity * 3) * step;\n p.velocity *= o.decay ** step;\n p.wobble += p.wobbleSpeed * step;\n p.tilt += 0.1 * step;\n p.tick += step;\n if (p.tick >= o.ticks) return false;\n const size = 8 * o.scalar;\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n ctx.translate(p.x + 10 * o.scalar * Math.cos(p.wobble), p.y + 10 * o.scalar * Math.sin(p.wobble));\n ctx.rotate(p.tilt);\n ctx.scale(1, Math.cos(p.wobble));\n ctx.globalAlpha = 1 - p.tick / o.ticks;\n ctx.fillStyle = p.color;\n ctx.beginPath();\n if (p.shape === 'circle') ctx.arc(0, 0, size / 2, 0, 2 * Math.PI);\n else if (p.shape === 'star') star(ctx, size * 0.75);\n else ctx.rect(-size / 2, -size / 2, size, size);\n ctx.fill();\n return true;\n });\n if (scene.pieces.length) scene.frame = requestAnimationFrame((t) => draw(canvas, scene, t));\n else stop(canvas);\n}\n\nfunction stop(canvas: HTMLCanvasElement) {\n const scene = scenes.get(canvas);\n if (!scene) return;\n cancelAnimationFrame(scene.frame);\n scenes.delete(canvas);\n scene.ctx.setTransform(1, 0, 0, 1, 0, 0);\n scene.ctx.clearRect(0, 0, canvas.width, canvas.height);\n if (scene.overlay) {\n canvas.remove();\n overlay = null;\n }\n for (const resolve of scene.done) resolve();\n}\n\nfunction star(ctx: CanvasRenderingContext2D, r: number) {\n for (let i = 0; i < 10; i++) {\n const a = (i * Math.PI) / 5 - Math.PI / 2;\n const d = i % 2 ? r / 2 : r;\n ctx.lineTo(Math.cos(a) * d, Math.sin(a) * d);\n }\n ctx.closePath();\n}\n\n// Matches the canvas's pixel buffer to its box and the screen's pixel ratio.\nfunction fit(canvas: HTMLCanvasElement) {\n const width = canvas.clientWidth;\n const height = canvas.clientHeight;\n const w = Math.round(width * devicePixelRatio);\n const h = Math.round(height * devicePixelRatio);\n if (canvas.width !== w || canvas.height !== h) {\n canvas.width = w;\n canvas.height = h;\n }\n return { width, height };\n}\n\nfunction viewportCanvas(): HTMLCanvasElement {\n if (overlay?.isConnected) return overlay;\n overlay = document.createElement('canvas');\n overlay.className = 'confetti-overlay';\n overlay.setAttribute('aria-hidden', 'true');\n // Inline, so the overlay works even where the stylesheet does not reach.\n Object.assign(overlay.style, {\n position: 'fixed', inset: '0', width: '100%', height: '100%', margin: '0', padding: '0',\n // The fallback keeps the order where the sheet, and so the token, is absent.\n border: '0', background: 'transparent', pointerEvents: 'none', zIndex: 'var(--expressive-z-confetti, 10001)'\n });\n document.body.append(overlay);\n if (typeof overlay.showPopover === 'function') {\n overlay.popover = 'manual';\n overlay.showPopover();\n }\n return overlay;\n}\n\n// Resolves each theme color token through `color`, so light-dark() and\n// relative colors reach the canvas as plain colors.\nfunction themeColors(themed: Element): string[] {\n const probe = document.createElement('span');\n probe.hidden = true;\n themed.append(probe);\n const style = getComputedStyle(probe);\n const colors = THEME_COLORS.filter((role) => style.getPropertyValue(`--md-sys-color-${role}`).trim()).map((role) => {\n probe.style.color = `var(--md-sys-color-${role})`;\n return getComputedStyle(probe).color;\n });\n probe.remove();\n return colors.length ? colors : FALLBACK_COLORS;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;AAyEA,IAAM,YAA6B;AAAA,EACjC,eAAe;AAAA,EACf,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,OAAO;AAAA,EACP,SAAS;AAAA,EACT,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ,EAAE,GAAG,KAAK,GA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B,KAAK,EAAE;AAAA,EACjC,CAAC;AACD,QAAM,OAAO;AACb,SAAO,OAAO,SAAS,SAAS;AAClC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// src/ts/core/spring.ts
|
|
2
|
+
var FPS = 60;
|
|
3
|
+
var REST = 0.5;
|
|
4
|
+
var LONGEST = 5;
|
|
5
|
+
function displacement(x0, v0, { damping, stiffness }, t) {
|
|
6
|
+
const w = Math.sqrt(stiffness);
|
|
7
|
+
if (damping >= 1) return Math.exp(-w * t) * (x0 + (v0 + w * x0) * t);
|
|
8
|
+
const wd = w * Math.sqrt(1 - damping * damping);
|
|
9
|
+
return Math.exp(-damping * w * t) * (x0 * Math.cos(wd * t) + (v0 + damping * w * x0) / wd * Math.sin(wd * t));
|
|
10
|
+
}
|
|
11
|
+
function springPath(from, to, velocity, spring) {
|
|
12
|
+
const path = [from];
|
|
13
|
+
const [x0, v0] = [from - to, velocity * 1e3];
|
|
14
|
+
for (let frame = 1; frame < LONGEST * FPS; frame++) {
|
|
15
|
+
const x = displacement(x0, v0, spring, frame / FPS);
|
|
16
|
+
path.push(to + x);
|
|
17
|
+
if (Math.abs(x) < REST && Math.abs(to + x - path[frame - 1]) < REST) break;
|
|
18
|
+
}
|
|
19
|
+
path.push(to);
|
|
20
|
+
return path;
|
|
21
|
+
}
|
|
22
|
+
function springToken(el, name) {
|
|
23
|
+
const style = getComputedStyle(el);
|
|
24
|
+
const read = (part) => parseFloat(style.getPropertyValue(`--md-sys-motion-spring-${name}-${part}`));
|
|
25
|
+
const [damping, stiffness] = [read("damping"), read("stiffness")];
|
|
26
|
+
return damping > 0 && stiffness > 0 ? { damping, stiffness } : null;
|
|
27
|
+
}
|
|
28
|
+
function animatePath(el, property, path, write) {
|
|
29
|
+
const frames = path.map((value) => ({ [property]: write(value) }));
|
|
30
|
+
return el.animate(frames, { duration: (path.length - 1) * 1e3 / FPS, easing: "linear" });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
springPath,
|
|
35
|
+
springToken,
|
|
36
|
+
animatePath
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=chunk-W6FAL3TI.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/ts/core/spring.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Springs solved at run time. The CSS springs are sampled at build time\n * into linear() easings that always start from rest, so motion that is\n * interrupted restarts. A spring solved here starts from where something\n * is, at the speed it has, as M3's springs do: mass 1, a damping ratio and\n * a stiffness.\n */\nexport interface Spring {\n damping: number;\n stiffness: number;\n}\n\n/** Frames per second the path is sampled at. */\nconst FPS = 60;\n/** Settled once within this distance of the target and moving less than this a frame. */\nconst REST = 0.5;\n/** No spring runs longer than this, in seconds. */\nconst LONGEST = 5;\n\n/**\n * How far from the target a spring is at `t` seconds, released `x0` away\n * at speed `v0`: underdamped springs oscillate as they decay, and M3's\n * critically damped ones do not.\n */\nfunction displacement(x0: number, v0: number, { damping, stiffness }: Spring, t: number) {\n const w = Math.sqrt(stiffness);\n if (damping >= 1) return Math.exp(-w * t) * (x0 + (v0 + w * x0) * t);\n const wd = w * Math.sqrt(1 - damping * damping);\n return Math.exp(-damping * w * t) * (x0 * Math.cos(wd * t) + ((v0 + damping * w * x0) / wd) * Math.sin(wd * t));\n}\n\n/**\n * The spring's path from `from` to `to`, released at `velocity` in units\n * per millisecond, as one value a frame until it settles on `to`.\n */\nexport function springPath(from: number, to: number, velocity: number, spring: Spring): number[] {\n const path = [from];\n const [x0, v0] = [from - to, velocity * 1000];\n for (let frame = 1; frame < LONGEST * FPS; frame++) {\n const x = displacement(x0, v0, spring, frame / FPS);\n path.push(to + x);\n if (Math.abs(x) < REST && Math.abs(to + x - path[frame - 1]) < REST) break;\n }\n path.push(to);\n return path;\n}\n\n/** The spring a CSS token names, from its -damping and -stiffness tokens, or null without them. */\nexport function springToken(el: Element, name: string): Spring | null {\n const style = getComputedStyle(el);\n const read = (part: string) => parseFloat(style.getPropertyValue(`--md-sys-motion-spring-${name}-${part}`));\n const [damping, stiffness] = [read('damping'), read('stiffness')];\n return damping > 0 && stiffness > 0 ? { damping, stiffness } : null;\n}\n\n/** Plays a path on one property, `write` turning each value into CSS. */\nexport function animatePath(el: Element, property: string, path: number[], write: (value: number) => string): Animation {\n const frames = path.map((value) => ({ [property]: write(value) }));\n return el.animate(frames, { duration: ((path.length - 1) * 1000) / FPS, easing: 'linear' });\n}\n"],
|
|
5
|
+
"mappings": ";AAaA,IAAM,MAAM;AAEZ,IAAM,OAAO;AAEb,IAAM,UAAU;AAOhB,SAAS,aAAa,IAAY,IAAY,EAAE,SAAS,UAAU,GAAW,GAAW;AACvF,QAAM,IAAI,KAAK,KAAK,SAAS;AAC7B,MAAI,WAAW,EAAG,QAAO,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,MAAM,KAAK,IAAI,MAAM;AAClE,QAAM,KAAK,IAAI,KAAK,KAAK,IAAI,UAAU,OAAO;AAC9C,SAAO,KAAK,IAAI,CAAC,UAAU,IAAI,CAAC,KAAK,KAAK,KAAK,IAAI,KAAK,CAAC,KAAM,KAAK,UAAU,IAAI,MAAM,KAAM,KAAK,IAAI,KAAK,CAAC;AAC/G;AAMO,SAAS,WAAW,MAAc,IAAY,UAAkB,QAA0B;AAC/F,QAAM,OAAO,CAAC,IAAI;AAClB,QAAM,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,IAAI,WAAW,GAAI;AAC5C,WAAS,QAAQ,GAAG,QAAQ,UAAU,KAAK,SAAS;AAClD,UAAM,IAAI,aAAa,IAAI,IAAI,QAAQ,QAAQ,GAAG;AAClD,SAAK,KAAK,KAAK,CAAC;AAChB,QAAI,KAAK,IAAI,CAAC,IAAI,QAAQ,KAAK,IAAI,KAAK,IAAI,KAAK,QAAQ,CAAC,CAAC,IAAI,KAAM;AAAA,EACvE;AACA,OA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