@expressivecss/expressive 0.15.0 → 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 +1502 -1
- package/README.md +9 -8
- package/dist/css/expressive.css +19247 -11923
- 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-KVJAVDBC.mjs → chunk-4QUCNFSD.mjs} +64 -113
- package/dist/js/chunks/chunk-4QUCNFSD.mjs.map +7 -0
- package/dist/js/chunks/{chunk-UETTGDLI.mjs → chunk-4TRZ2AER.mjs} +35 -41
- package/dist/js/chunks/chunk-4TRZ2AER.mjs.map +7 -0
- package/dist/js/chunks/{chunk-C6CHEWYP.mjs → chunk-5KIHWJI2.mjs} +40 -26
- package/dist/js/chunks/chunk-5KIHWJI2.mjs.map +7 -0
- package/dist/js/chunks/{chunk-L27Q6ZMI.mjs → chunk-67ZPPKXS.mjs} +20 -33
- package/dist/js/chunks/chunk-67ZPPKXS.mjs.map +7 -0
- package/dist/js/chunks/{chunk-XAEAEHIX.mjs → chunk-6FSEUFVW.mjs} +39 -26
- 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-CK2XCICY.mjs → chunk-75E5EDJF.mjs} +3 -11
- package/dist/js/chunks/chunk-75E5EDJF.mjs.map +7 -0
- package/dist/js/chunks/{chunk-KHXZ2A4K.mjs → chunk-7NLUI3RR.mjs} +139 -66
- 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-LQWUDNHZ.mjs → chunk-ANKFWNWT.mjs} +21 -45
- package/dist/js/chunks/chunk-ANKFWNWT.mjs.map +7 -0
- package/dist/js/chunks/{chunk-5CEAOLUA.mjs → chunk-B7DQFHA5.mjs} +30 -47
- 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-VGNYF6FB.mjs → chunk-BPF3I2MN.mjs} +109 -24
- 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-NUHMOAOY.mjs → chunk-CSYWKEK3.mjs} +310 -196
- 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-74MXKKLN.mjs → chunk-EC26RU2D.mjs} +11 -29
- package/dist/js/chunks/chunk-EC26RU2D.mjs.map +7 -0
- package/dist/js/chunks/{chunk-WDK4T63U.mjs → chunk-EVCVFEV3.mjs} +235 -146
- 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-PDG64UHF.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-BGZLF6JZ.mjs → chunk-KZPSAXIU.mjs} +142 -32
- 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-DXGRXYYL.mjs → chunk-OP43LLIC.mjs} +28 -45
- 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-TSZYSW7F.mjs → chunk-OYNUDOHR.mjs} +19 -47
- package/dist/js/chunks/chunk-OYNUDOHR.mjs.map +7 -0
- package/dist/js/chunks/{chunk-UAZSDUVP.mjs → chunk-P6DRQ6KS.mjs} +36 -30
- 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-GJL6GCIU.mjs → chunk-QXKWVHBD.mjs} +265 -161
- package/dist/js/chunks/chunk-QXKWVHBD.mjs.map +7 -0
- package/dist/js/chunks/{chunk-X4ISMKE2.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-SMY7GJSS.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-ZX6M7SWO.mjs → chunk-VGY4M57S.mjs} +266 -120
- 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-SFI2U4YW.mjs → chunk-VMY55K2X.mjs} +76 -109
- package/dist/js/chunks/chunk-VMY55K2X.mjs.map +7 -0
- package/dist/js/chunks/{chunk-KUFHW3DS.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-FM5CZOUB.mjs → chunk-ZJNLAGY5.mjs} +19 -30
- 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 +10613 -4327
- package/dist/js/expressive.cjs.map +4 -4
- package/dist/js/expressive.js +10613 -4327
- package/dist/js/expressive.js.map +4 -4
- package/dist/js/expressive.min.js +23 -22
- package/dist/js/expressive.min.js.map +4 -4
- package/dist/js/expressive.mjs +182 -71
- 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 +131 -66
- 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 +3 -3
- package/dist/js/internal/components/lightbox.mjs +3 -3
- package/dist/js/internal/components/lineChart.mjs +25 -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 -41
- 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 +173 -71
- 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 +91 -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 +56 -32
- package/dist/types/components/expandingCard.d.ts +4 -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 +16 -1
- package/dist/types/components/inputMask.d.ts +30 -0
- package/dist/types/components/keypad.d.ts +38 -6
- package/dist/types/components/lightbox.d.ts +14 -20
- package/dist/types/components/lineChart.d.ts +172 -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 +60 -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 -7
- package/dist/types/components/registry.d.ts +73 -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 +3 -15
- package/dist/types/components/snackbar.d.ts +61 -0
- package/dist/types/components/swipeActions.d.ts +81 -0
- package/dist/types/components/tabs.d.ts +89 -27
- package/dist/types/components/timepicker.d.ts +113 -21
- 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 -8
- 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/_elevation.scss +13 -7
- package/src/sass/abstracts/_index.scss +1 -0
- package/src/sass/abstracts/_mixins.scss +422 -36
- package/src/sass/abstracts/_spring.scss +63 -0
- package/src/sass/abstracts/_variables.scss +39 -21
- package/src/sass/base/_fonts.scss +61 -48
- package/src/sass/base/_global.scss +104 -24
- package/src/sass/base/_index.scss +2 -0
- 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 +6 -5
- 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 +15 -25
- package/src/sass/components/_buttons.scss +156 -63
- package/src/sass/components/_calendar.scss +246 -0
- package/src/sass/components/_cards.scss +36 -44
- package/src/sass/components/_carousel.scss +27 -103
- package/src/sass/components/_cascader.scss +142 -0
- package/src/sass/components/_chips.scss +36 -46
- 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 -25
- package/src/sass/components/_datepicker.scss +54 -40
- package/src/sass/components/_description-list.scss +85 -0
- package/src/sass/components/_dialog.scss +42 -41
- 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 +111 -22
- package/src/sass/components/_icon-buttons.scss +7 -7
- 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 +20 -0
- package/src/sass/components/_keypad.scss +39 -19
- package/src/sass/components/_kpi.scss +6 -11
- package/src/sass/components/_lightbox.scss +24 -13
- 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 +33 -11
- package/src/sass/components/_marquee.scss +3 -2
- package/src/sass/components/_mega-menu.scss +137 -0
- package/src/sass/components/_menu.scss +143 -123
- 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 +34 -20
- package/src/sass/components/_navigation-bar.scss +15 -77
- package/src/sass/components/_navigation-rail.scss +151 -92
- package/src/sass/components/_org-chart.scss +192 -0
- package/src/sass/components/_page-footer.scss +1 -1
- package/src/sass/components/_pagination.scss +6 -13
- package/src/sass/components/_panes.scss +32 -26
- 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 +152 -31
- 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 -37
- 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 -1
- 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 +109 -78
- package/src/sass/components/_toolbar.scss +35 -43
- 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 +106 -24
- 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 +7 -7
- package/src/sass/components/forms/_file-input.scss +6 -8
- 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 +33 -94
- package/src/sass/components/forms/_rating.scss +2 -32
- package/src/sass/components/forms/_select.scss +199 -20
- package/src/sass/components/forms/_slider.scss +91 -94
- 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 +0 -2
- package/src/sass/tokens/_theme.scss +10 -1
- package/src/sass/tokens/_vibrant.scss +2 -5
- package/src/sass/utilities/_defer-render.scss +17 -0
- package/src/sass/utilities/_helpers.scss +183 -26
- package/src/sass/utilities/_index.scss +1 -0
- 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-33QVDDGR.mjs +0 -270
- package/dist/js/chunks/chunk-33QVDDGR.mjs.map +0 -7
- package/dist/js/chunks/chunk-45FER6RI.mjs +0 -59
- package/dist/js/chunks/chunk-45FER6RI.mjs.map +0 -7
- package/dist/js/chunks/chunk-5CEAOLUA.mjs.map +0 -7
- package/dist/js/chunks/chunk-6VATUZC6.mjs +0 -295
- package/dist/js/chunks/chunk-6VATUZC6.mjs.map +0 -7
- package/dist/js/chunks/chunk-74MXKKLN.mjs.map +0 -7
- package/dist/js/chunks/chunk-AIURVCG6.mjs +0 -55
- package/dist/js/chunks/chunk-AIURVCG6.mjs.map +0 -7
- package/dist/js/chunks/chunk-BGZLF6JZ.mjs.map +0 -7
- package/dist/js/chunks/chunk-C6CHEWYP.mjs.map +0 -7
- package/dist/js/chunks/chunk-CK2XCICY.mjs.map +0 -7
- package/dist/js/chunks/chunk-CXXM2L4F.mjs +0 -344
- package/dist/js/chunks/chunk-CXXM2L4F.mjs.map +0 -7
- package/dist/js/chunks/chunk-DXGRXYYL.mjs.map +0 -7
- package/dist/js/chunks/chunk-FM5CZOUB.mjs.map +0 -7
- package/dist/js/chunks/chunk-GJL6GCIU.mjs.map +0 -7
- package/dist/js/chunks/chunk-K3HZMFMD.mjs +0 -135
- package/dist/js/chunks/chunk-K3HZMFMD.mjs.map +0 -7
- package/dist/js/chunks/chunk-KHXZ2A4K.mjs.map +0 -7
- package/dist/js/chunks/chunk-KQACNQ22.mjs +0 -7
- package/dist/js/chunks/chunk-KQACNQ22.mjs.map +0 -7
- package/dist/js/chunks/chunk-KUFHW3DS.mjs.map +0 -7
- package/dist/js/chunks/chunk-KVJAVDBC.mjs.map +0 -7
- package/dist/js/chunks/chunk-L27Q6ZMI.mjs.map +0 -7
- package/dist/js/chunks/chunk-LQWUDNHZ.mjs.map +0 -7
- package/dist/js/chunks/chunk-M372EDXD.mjs +0 -322
- package/dist/js/chunks/chunk-M372EDXD.mjs.map +0 -7
- package/dist/js/chunks/chunk-M3MURWMB.mjs +0 -82
- package/dist/js/chunks/chunk-M3MURWMB.mjs.map +0 -7
- package/dist/js/chunks/chunk-NUHMOAOY.mjs.map +0 -7
- package/dist/js/chunks/chunk-OWG3LMUL.mjs +0 -169
- package/dist/js/chunks/chunk-OWG3LMUL.mjs.map +0 -7
- package/dist/js/chunks/chunk-PD6HYHAE.mjs +0 -48
- package/dist/js/chunks/chunk-PD6HYHAE.mjs.map +0 -7
- package/dist/js/chunks/chunk-PDG64UHF.mjs.map +0 -7
- package/dist/js/chunks/chunk-PO3AXVR3.mjs +0 -546
- package/dist/js/chunks/chunk-PO3AXVR3.mjs.map +0 -7
- package/dist/js/chunks/chunk-QYGK36OG.mjs +0 -181
- package/dist/js/chunks/chunk-QYGK36OG.mjs.map +0 -7
- package/dist/js/chunks/chunk-SFI2U4YW.mjs.map +0 -7
- package/dist/js/chunks/chunk-SMY7GJSS.mjs.map +0 -7
- package/dist/js/chunks/chunk-TCCA2HDG.mjs +0 -414
- package/dist/js/chunks/chunk-TCCA2HDG.mjs.map +0 -7
- package/dist/js/chunks/chunk-TSZYSW7F.mjs.map +0 -7
- package/dist/js/chunks/chunk-UAZSDUVP.mjs.map +0 -7
- package/dist/js/chunks/chunk-UBRZZWRA.mjs +0 -127
- package/dist/js/chunks/chunk-UBRZZWRA.mjs.map +0 -7
- package/dist/js/chunks/chunk-UCOE7ZDL.mjs +0 -287
- package/dist/js/chunks/chunk-UCOE7ZDL.mjs.map +0 -7
- package/dist/js/chunks/chunk-UETTGDLI.mjs.map +0 -7
- package/dist/js/chunks/chunk-UNCRDLP6.mjs +0 -136
- package/dist/js/chunks/chunk-UNCRDLP6.mjs.map +0 -7
- package/dist/js/chunks/chunk-VGNYF6FB.mjs.map +0 -7
- package/dist/js/chunks/chunk-VGPGBNGL.mjs +0 -68
- package/dist/js/chunks/chunk-VGPGBNGL.mjs.map +0 -7
- package/dist/js/chunks/chunk-VKAUVTQY.mjs +0 -1
- package/dist/js/chunks/chunk-VM4FTS7L.mjs +0 -48
- package/dist/js/chunks/chunk-VM4FTS7L.mjs.map +0 -7
- package/dist/js/chunks/chunk-WDK4T63U.mjs.map +0 -7
- package/dist/js/chunks/chunk-WOCCTVUF.mjs +0 -185
- package/dist/js/chunks/chunk-WOCCTVUF.mjs.map +0 -7
- package/dist/js/chunks/chunk-WQYN5L4E.mjs +0 -107
- package/dist/js/chunks/chunk-WQYN5L4E.mjs.map +0 -7
- package/dist/js/chunks/chunk-X4ISMKE2.mjs.map +0 -7
- package/dist/js/chunks/chunk-XAEAEHIX.mjs.map +0 -7
- package/dist/js/chunks/chunk-ZX6M7SWO.mjs.map +0 -7
- /package/dist/js/chunks/{chunk-VKAUVTQY.mjs.map → chunk-GNRSYMVH.mjs.map} +0 -0
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Utils
|
|
3
|
-
} from "./chunk-M372EDXD.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()];
|
|
@@ -37,7 +40,7 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
37
40
|
}
|
|
38
41
|
};
|
|
39
42
|
this._handleLightboxKeypress = (e) => {
|
|
40
|
-
if (this._trigger === this.el && (e.key ===
|
|
43
|
+
if (this._trigger === this.el && (e.key === "Enter" || e.key === " ")) {
|
|
41
44
|
e.preventDefault();
|
|
42
45
|
this._handleLightboxToggle();
|
|
43
46
|
}
|
|
@@ -50,35 +53,38 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
50
53
|
if (this.overlayActive) this.close();
|
|
51
54
|
};
|
|
52
55
|
this._handleWindowEscape = (e) => {
|
|
53
|
-
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();
|
|
54
62
|
};
|
|
55
63
|
/**
|
|
56
64
|
* Open lightbox.
|
|
57
65
|
*/
|
|
58
66
|
this.open = () => {
|
|
59
67
|
if (this._destroyed || this._isOpen) return;
|
|
68
|
+
this._phase++;
|
|
60
69
|
const revision = this._cancel();
|
|
61
70
|
if (this.overlayActive) this._reset();
|
|
62
|
-
this._isOpen = true;
|
|
63
71
|
this._updateVars();
|
|
64
72
|
const originRect = this.el.getBoundingClientRect();
|
|
65
73
|
const placeholderRect = this.placeholder.getBoundingClientRect();
|
|
74
|
+
if (!originRect.width || !originRect.height) return;
|
|
75
|
+
this._isOpen = true;
|
|
66
76
|
this.originalWidth = originRect.width;
|
|
67
77
|
this.originalHeight = originRect.height;
|
|
68
78
|
this.doneAnimating = false;
|
|
69
79
|
this.el.classList.add("active");
|
|
70
80
|
this.overlayActive = true;
|
|
71
|
-
if (
|
|
72
|
-
this.options.onOpenStart.call(this, this.el);
|
|
73
|
-
if (revision !== this._revision) return;
|
|
81
|
+
if (!this._notify("open", this.options.onOpenStart, { current: () => revision === this._revision })) return;
|
|
74
82
|
this.placeholder.style.width = placeholderRect.width + "px";
|
|
75
83
|
this.placeholder.style.height = placeholderRect.height + "px";
|
|
76
|
-
this.placeholder.style.position = "relative";
|
|
77
|
-
this.placeholder.style.top = "0";
|
|
78
|
-
this.placeholder.style.left = "0";
|
|
79
|
-
this._makeAncestorsOverflowVisible();
|
|
80
84
|
this.el.style.position = "absolute";
|
|
81
|
-
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";
|
|
82
88
|
this.el.style.willChange = "left, top, width, height";
|
|
83
89
|
this.attrWidth = this.el.getAttribute("width");
|
|
84
90
|
this.attrHeight = this.el.getAttribute("height");
|
|
@@ -91,6 +97,7 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
91
97
|
this.el.removeAttribute("height");
|
|
92
98
|
}
|
|
93
99
|
this._addOverlay();
|
|
100
|
+
this._showOnTop(this.el);
|
|
94
101
|
if (this.caption !== "") this._addCaption();
|
|
95
102
|
const widthPercent = this.originalWidth / this.windowWidth;
|
|
96
103
|
const heightPercent = this.originalHeight / this.windowHeight;
|
|
@@ -103,9 +110,13 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
103
110
|
this.newWidth = this.windowHeight * 0.9 * ratio;
|
|
104
111
|
this.newHeight = this.windowHeight * 0.9;
|
|
105
112
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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 });
|
|
109
120
|
this._animateImageIn();
|
|
110
121
|
};
|
|
111
122
|
/**
|
|
@@ -113,24 +124,17 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
113
124
|
*/
|
|
114
125
|
this.close = () => {
|
|
115
126
|
if (this._destroyed || !this._isOpen) return;
|
|
127
|
+
this._phase++;
|
|
116
128
|
const revision = this._cancel();
|
|
117
129
|
this._isOpen = false;
|
|
118
130
|
this.doneAnimating = false;
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
window.removeEventListener("scroll", this._handleWindowChange);
|
|
123
|
-
window.removeEventListener("resize", this._handleWindowChange);
|
|
124
|
-
window.removeEventListener("keyup", this._handleWindowEscape);
|
|
131
|
+
if (!this._notify("close", this.options.onCloseStart, { current: () => revision === this._revision })) return;
|
|
132
|
+
this._windowEvents?.abort();
|
|
133
|
+
this._restoreFocus();
|
|
125
134
|
if (this._overlay) this._fadeOut(this._overlay);
|
|
126
135
|
if (this._photoCaption) this._fadeOut(this._photoCaption);
|
|
127
136
|
this._animateImageOut();
|
|
128
137
|
};
|
|
129
|
-
this.el["Expressive_Lightbox"] = this;
|
|
130
|
-
this.options = {
|
|
131
|
-
..._Lightbox.defaults,
|
|
132
|
-
...options
|
|
133
|
-
};
|
|
134
138
|
this.overlayActive = false;
|
|
135
139
|
this.doneAnimating = true;
|
|
136
140
|
this.placeholder = document.createElement("div");
|
|
@@ -149,53 +153,35 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
149
153
|
static get defaults() {
|
|
150
154
|
return _defaults;
|
|
151
155
|
}
|
|
152
|
-
/**
|
|
153
|
-
* Initializes instances of Lightbox.
|
|
154
|
-
* @param els HTML elements.
|
|
155
|
-
* @param options Component options.
|
|
156
|
-
*/
|
|
157
|
-
static init(els, options = {}) {
|
|
158
|
-
return super.init(els, options, _Lightbox);
|
|
159
|
-
}
|
|
160
|
-
static getInstance(el) {
|
|
161
|
-
return el["Expressive_Lightbox"];
|
|
162
|
-
}
|
|
163
156
|
destroy() {
|
|
164
157
|
if (this._destroyed) return;
|
|
165
158
|
this._destroyed = true;
|
|
166
|
-
const
|
|
167
|
-
const focused = root.activeElement === this.el;
|
|
168
|
-
this._removeEventHandlers();
|
|
159
|
+
const focused = this.el.getRootNode().activeElement === this.el;
|
|
169
160
|
this._cancel();
|
|
170
161
|
this._reset();
|
|
171
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();
|
|
172
171
|
let active = document.activeElement;
|
|
173
172
|
while (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;
|
|
174
|
-
if (
|
|
175
|
-
if (this._tabindex === null) this.el.removeAttribute("tabindex");
|
|
176
|
-
else this.el.setAttribute("tabindex", this._tabindex);
|
|
177
|
-
this.el["Expressive_Lightbox"] = void 0;
|
|
173
|
+
if ([document.body, root.host].includes(active)) this._trigger.focus({ preventScroll: true });
|
|
178
174
|
}
|
|
179
175
|
_reset() {
|
|
180
|
-
|
|
181
|
-
window.removeEventListener("resize", this._handleWindowChange);
|
|
182
|
-
window.removeEventListener("keyup", this._handleWindowEscape);
|
|
176
|
+
this._windowEvents?.abort();
|
|
183
177
|
this._overlay?.remove();
|
|
184
178
|
this._photoCaption?.remove();
|
|
185
|
-
|
|
186
|
-
const saved = _Lightbox._overflow.get(ancestor);
|
|
187
|
-
if (--saved.count === 0) {
|
|
188
|
-
ancestor.style.setProperty("overflow", saved.value, saved.priority);
|
|
189
|
-
_Lightbox._overflow.delete(ancestor);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
this._changedAncestorList = [];
|
|
179
|
+
this.el.removeAttribute("popover");
|
|
193
180
|
if (this.attrWidth != null) this.el.setAttribute("width", this.attrWidth);
|
|
194
181
|
if (this.attrHeight != null) this.el.setAttribute("height", this.attrHeight);
|
|
195
182
|
this.el.classList.remove("active");
|
|
196
183
|
this.placeholder.removeAttribute("style");
|
|
197
|
-
|
|
198
|
-
else this.el.setAttribute("style", this.originInlineStyles);
|
|
184
|
+
restoreAttribute(this.el, "style", this.originInlineStyles);
|
|
199
185
|
this.overlayActive = false;
|
|
200
186
|
this._isOpen = false;
|
|
201
187
|
this.doneAnimating = true;
|
|
@@ -217,37 +203,23 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
217
203
|
this._timers.set(timer, callback);
|
|
218
204
|
}
|
|
219
205
|
_setupEventHandlers() {
|
|
220
|
-
|
|
221
|
-
this.
|
|
222
|
-
this.
|
|
223
|
-
|
|
224
|
-
_removeEventHandlers() {
|
|
225
|
-
this._motion.removeEventListener("change", this._handleMotionChange);
|
|
226
|
-
this._trigger.removeEventListener("click", this._handleLightboxToggle);
|
|
227
|
-
this.el.removeEventListener("keydown", this._handleLightboxKeypress);
|
|
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 });
|
|
228
210
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
saved.count++;
|
|
237
|
-
_Lightbox._overflow.set(curr, saved);
|
|
238
|
-
this._changedAncestorList.push(curr);
|
|
239
|
-
curr.style.overflow = "visible";
|
|
240
|
-
}
|
|
241
|
-
ancestor = ancestor.parentNode ?? ancestor.host;
|
|
242
|
-
}
|
|
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();
|
|
243
218
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
const
|
|
247
|
-
return {
|
|
248
|
-
top: box.top + window.scrollY - docElem.clientTop,
|
|
249
|
-
left: box.left + window.scrollX - docElem.clientLeft
|
|
250
|
-
};
|
|
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" };
|
|
251
223
|
}
|
|
252
224
|
_updateVars() {
|
|
253
225
|
this.windowWidth = window.innerWidth;
|
|
@@ -256,6 +228,7 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
256
228
|
}
|
|
257
229
|
// Image
|
|
258
230
|
_animateImageIn() {
|
|
231
|
+
const phase = this._phase;
|
|
259
232
|
this.el.style.maxHeight = this.newHeight.toString() + "px";
|
|
260
233
|
this.el.style.maxWidth = this.newWidth.toString() + "px";
|
|
261
234
|
const duration = this._motion.matches ? 0 : this.options.inDuration;
|
|
@@ -263,7 +236,6 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
263
236
|
this.el.style.height = this.originalHeight + "px";
|
|
264
237
|
this.el.style.width = this.originalWidth + "px";
|
|
265
238
|
this._schedule(() => {
|
|
266
|
-
const placeholderOffset = this._offset(this.placeholder);
|
|
267
239
|
this.el.style.transition = `height ${duration}ms ease,
|
|
268
240
|
width ${duration}ms ease,
|
|
269
241
|
left ${duration}ms ease,
|
|
@@ -271,15 +243,16 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
271
243
|
`;
|
|
272
244
|
this.el.style.height = this.newHeight + "px";
|
|
273
245
|
this.el.style.width = this.newWidth + "px";
|
|
274
|
-
this.el.style.left =
|
|
275
|
-
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";
|
|
276
248
|
}, 1);
|
|
277
249
|
this._schedule(() => {
|
|
278
250
|
this.doneAnimating = true;
|
|
279
|
-
|
|
251
|
+
this._notify("opened", this.options.onOpenEnd, { current: () => phase === this._phase });
|
|
280
252
|
}, duration);
|
|
281
253
|
}
|
|
282
254
|
_animateImageOut() {
|
|
255
|
+
const phase = this._phase;
|
|
283
256
|
const duration = this._motion.matches ? 0 : this.options.outDuration;
|
|
284
257
|
this.el.style.transition = `height ${duration}ms ease,
|
|
285
258
|
width ${duration}ms ease,
|
|
@@ -288,12 +261,10 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
288
261
|
`;
|
|
289
262
|
this.el.style.height = this.originalHeight + "px";
|
|
290
263
|
this.el.style.width = this.originalWidth + "px";
|
|
291
|
-
this.el.style.
|
|
292
|
-
this.el.style.top = "0";
|
|
264
|
+
Object.assign(this.el.style, this._restingPlace());
|
|
293
265
|
this._schedule(() => {
|
|
294
266
|
this._reset();
|
|
295
|
-
|
|
296
|
-
this.options.onCloseEnd.call(this, this.el);
|
|
267
|
+
this._notify("closed", this.options.onCloseEnd, { current: () => phase === this._phase });
|
|
297
268
|
}, duration);
|
|
298
269
|
}
|
|
299
270
|
// Caption
|
|
@@ -303,6 +274,7 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
303
274
|
this._photoCaption.innerText = this.caption;
|
|
304
275
|
Utils.portalRoot(this.el).append(this._photoCaption);
|
|
305
276
|
this._photoCaption.style.display = "inline";
|
|
277
|
+
this._showOnTop(this._photoCaption);
|
|
306
278
|
this._fadeIn(this._photoCaption);
|
|
307
279
|
}
|
|
308
280
|
// Overlay
|
|
@@ -318,11 +290,7 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
318
290
|
{ once: true }
|
|
319
291
|
);
|
|
320
292
|
this.el.before(this._overlay);
|
|
321
|
-
|
|
322
|
-
this._overlay.style.width = this.windowWidth + "px";
|
|
323
|
-
this._overlay.style.height = this.windowHeight + "px";
|
|
324
|
-
this._overlay.style.left = -1 * overlayOffset.left + "px";
|
|
325
|
-
this._overlay.style.top = -1 * overlayOffset.top + "px";
|
|
293
|
+
this._showOnTop(this._overlay);
|
|
326
294
|
this._fadeIn(this._overlay);
|
|
327
295
|
}
|
|
328
296
|
_fadeIn(el) {
|
|
@@ -340,10 +308,9 @@ var _Lightbox = class _Lightbox extends Component {
|
|
|
340
308
|
el.style.opacity = "0";
|
|
341
309
|
}
|
|
342
310
|
};
|
|
343
|
-
|
|
344
|
-
var Lightbox = _Lightbox;
|
|
311
|
+
Lightbox.key = "Expressive_Lightbox";
|
|
345
312
|
|
|
346
313
|
export {
|
|
347
314
|
Lightbox
|
|
348
315
|
};
|
|
349
|
-
//# 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;AAEA,SAAQ,wBAAwB,MAAM;AAEpC,UAAI,KAAK,QAAS,MAAK,MAAM;AAAA,UACxB,MAAK,KAAK;AAAA,IACjB;AAEA,SAAQ,sB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,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,GAAG,IAAI;AAAA,EACzB,QAAQ,CAAC;AAAA,EACT,QAAQ,CAAC,UAAU,QAAQ;AAAA,EAC3B,QAAQ;AAAA,EACR,aAAa;AACf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
+
}
|
|
@@ -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,OAAK,KAAK,EAAE;AACZ,SAAO;AACT;AAGO,SAAS,YAAY,IAAa,MAA6B;AACpE,QAAM,QAAQ,iBAAiB,EAAE;AACjC,QAAM,OAA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