@swisspost/design-system-components 1.6.3 → 1.7.1
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/dist/cjs/{check-non-empty-ae713942.js → check-non-empty-eeaa8f77.js} +4 -4
- package/dist/cjs/check-non-empty-eeaa8f77.js.map +1 -0
- package/dist/cjs/index-8c288b1a.js +45 -0
- package/dist/cjs/index-8c288b1a.js.map +1 -0
- package/dist/cjs/{index-b619e205.js → index-c07c0cdb.js} +144 -65
- package/dist/cjs/index-c07c0cdb.js.map +1 -0
- package/dist/cjs/index.cjs.js +17 -12
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/package-989e0b36.js +7 -0
- package/dist/cjs/package-989e0b36.js.map +1 -0
- package/dist/cjs/post-accordion-bc0c6f31.js +87 -0
- package/dist/cjs/post-accordion-bc0c6f31.js.map +1 -0
- package/dist/cjs/post-accordion.cjs.entry.js +4 -80
- package/dist/cjs/post-accordion.cjs.entry.js.map +1 -1
- package/dist/cjs/post-alert-39ac30a4.js +101 -0
- package/dist/cjs/{post-alert-b46943e0.js.map → post-alert-39ac30a4.js.map} +1 -1
- package/dist/cjs/post-alert.cjs.entry.js +5 -6
- package/dist/cjs/post-alert.cjs.entry.js.map +1 -1
- package/dist/cjs/{post-collapsible-04364cda.js → post-collapsible-85f8ace5.js} +69 -69
- package/dist/cjs/{post-collapsible-04364cda.js.map → post-collapsible-85f8ace5.js.map} +1 -1
- package/dist/cjs/post-collapsible.cjs.entry.js +4 -5
- package/dist/cjs/post-collapsible.cjs.entry.js.map +1 -1
- package/dist/cjs/post-components.cjs.js +3 -3
- package/dist/cjs/post-components.cjs.js.map +1 -1
- package/dist/cjs/post-icon-53e50c15.js +105 -0
- package/dist/cjs/post-icon-53e50c15.js.map +1 -0
- package/dist/cjs/post-icon.cjs.entry.js +5 -6
- package/dist/cjs/post-icon.cjs.entry.js.map +1 -1
- package/dist/cjs/post-popover-5a75c1b2.js +118 -0
- package/dist/cjs/post-popover-5a75c1b2.js.map +1 -0
- package/dist/cjs/post-popover.cjs.entry.js +13 -0
- package/dist/cjs/post-popover.cjs.entry.js.map +1 -0
- package/dist/cjs/post-popovercontainer-84378594.js +1878 -0
- package/dist/cjs/post-popovercontainer-84378594.js.map +1 -0
- package/dist/cjs/post-popovercontainer.cjs.entry.js +13 -0
- package/dist/cjs/post-popovercontainer.cjs.entry.js.map +1 -0
- package/dist/cjs/post-tab-header-02c6e31e.js +33 -0
- package/dist/cjs/{post-tab-header-805c0a52.js.map → post-tab-header-02c6e31e.js.map} +1 -1
- package/dist/cjs/post-tab-header.cjs.entry.js +4 -4
- package/dist/cjs/post-tab-panel-3973b707.js +27 -0
- package/dist/cjs/{post-tab-panel-caa44a77.js.map → post-tab-panel-3973b707.js.map} +1 -1
- package/dist/cjs/post-tab-panel.cjs.entry.js +3 -3
- package/dist/cjs/post-tabs-7a4fead7.js +153 -0
- package/dist/cjs/post-tabs-7a4fead7.js.map +1 -0
- package/dist/cjs/post-tabs.cjs.entry.js +3 -3
- package/dist/cjs/{post-tooltip-32a9c549.js → post-tooltip-79a9c96d.js} +78 -1754
- package/dist/cjs/post-tooltip-79a9c96d.js.map +1 -0
- package/dist/cjs/post-tooltip.cjs.entry.js +3 -4
- package/dist/cjs/post-tooltip.cjs.entry.js.map +1 -1
- package/dist/collection/animations/collapse.js +5 -5
- package/dist/collection/animations/collapse.js.map +1 -1
- package/dist/collection/collection-manifest.json +5 -3
- package/dist/collection/components/post-accordion/post-accordion.js +167 -166
- package/dist/collection/components/post-accordion/post-accordion.js.map +1 -1
- package/dist/collection/components/post-alert/post-alert.css +2 -2
- package/dist/collection/components/post-alert/post-alert.js +246 -246
- package/dist/collection/components/post-alert/post-alert.js.map +1 -1
- package/dist/collection/components/post-collapsible/post-collapsible.js +169 -168
- package/dist/collection/components/post-collapsible/post-collapsible.js.map +1 -1
- package/dist/collection/components/post-icon/post-icon.css +1 -1
- package/dist/collection/components/post-icon/post-icon.js +250 -250
- package/dist/collection/components/post-icon/post-icon.js.map +1 -1
- package/dist/collection/components/post-popover/post-popover.css +3 -0
- package/dist/collection/components/post-popover/post-popover.js +267 -0
- package/dist/collection/components/post-popover/post-popover.js.map +1 -0
- package/dist/collection/components/post-popovercontainer/post-popovercontainer.css +1 -0
- package/dist/collection/components/post-popovercontainer/post-popovercontainer.js +288 -0
- package/dist/collection/components/post-popovercontainer/post-popovercontainer.js.map +1 -0
- package/dist/collection/components/post-tab-header/post-tab-header.css +1 -1
- package/dist/collection/components/post-tab-header/post-tab-header.js +62 -62
- package/dist/collection/components/post-tab-header/post-tab-header.js.map +1 -1
- package/dist/collection/components/post-tab-panel/post-tab-panel.js +50 -50
- package/dist/collection/components/post-tab-panel/post-tab-panel.js.map +1 -1
- package/dist/collection/components/post-tabs/post-tabs.css +1 -1
- package/dist/collection/components/post-tabs/post-tabs.js +224 -223
- package/dist/collection/components/post-tabs/post-tabs.js.map +1 -1
- package/dist/collection/components/post-tooltip/post-tooltip.css +1 -1
- package/dist/collection/components/post-tooltip/post-tooltip.js +192 -325
- package/dist/collection/components/post-tooltip/post-tooltip.js.map +1 -1
- package/dist/collection/index.js +3 -0
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/utils/is-motion-reduced.js +1 -1
- package/dist/collection/utils/is-motion-reduced.js.map +1 -1
- package/dist/collection/utils/property-checkers/check-non-empty.js +3 -3
- package/dist/collection/utils/property-checkers/check-non-empty.js.map +1 -1
- package/dist/collection/utils/property-checkers/check-one-of.js +2 -2
- package/dist/collection/utils/property-checkers/check-one-of.js.map +1 -1
- package/dist/collection/utils/property-checkers/check-pattern.js +2 -2
- package/dist/collection/utils/property-checkers/check-pattern.js.map +1 -1
- package/dist/collection/utils/property-checkers/check-type.js +10 -10
- package/dist/collection/utils/property-checkers/check-type.js.map +1 -1
- package/dist/collection/utils/property-checkers/empty-or.js +5 -5
- package/dist/collection/utils/property-checkers/empty-or.js.map +1 -1
- package/dist/components/check-non-empty.js +3 -3
- package/dist/components/check-non-empty.js.map +1 -1
- package/dist/components/index.js +3 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/index2.js +22 -18
- package/dist/components/index2.js.map +1 -1
- package/dist/components/package.js +1 -1
- package/dist/components/post-accordion.d.ts +2 -2
- package/dist/components/post-accordion.js +1 -101
- package/dist/components/post-accordion.js.map +1 -1
- package/dist/components/post-accordion2.js +105 -0
- package/dist/components/post-accordion2.js.map +1 -0
- package/dist/components/post-alert.d.ts +2 -2
- package/dist/components/post-alert2.js +119 -119
- package/dist/components/post-alert2.js.map +1 -1
- package/dist/components/post-collapsible.d.ts +2 -2
- package/dist/components/post-collapsible2.js +90 -90
- package/dist/components/post-collapsible2.js.map +1 -1
- package/dist/components/post-icon.d.ts +2 -2
- package/dist/components/post-icon2.js +118 -118
- package/dist/components/post-icon2.js.map +1 -1
- package/dist/components/post-popover.d.ts +11 -0
- package/dist/components/post-popover.js +8 -0
- package/dist/components/post-popover.js.map +1 -0
- package/dist/components/post-popover2.js +144 -0
- package/dist/components/post-popover2.js.map +1 -0
- package/dist/components/post-popovercontainer.d.ts +11 -0
- package/dist/components/post-popovercontainer.js +8 -0
- package/dist/components/post-popovercontainer.js.map +1 -0
- package/dist/components/post-popovercontainer2.js +1897 -0
- package/dist/components/post-popovercontainer2.js.map +1 -0
- package/dist/components/post-tab-header.d.ts +2 -2
- package/dist/components/post-tab-header2.js +38 -38
- package/dist/components/post-tab-header2.js.map +1 -1
- package/dist/components/post-tab-panel.d.ts +2 -2
- package/dist/components/post-tab-panel2.js +30 -30
- package/dist/components/post-tab-panel2.js.map +1 -1
- package/dist/components/post-tabs.d.ts +2 -2
- package/dist/components/post-tabs2.js +147 -147
- package/dist/components/post-tabs2.js.map +1 -1
- package/dist/components/post-tooltip.d.ts +2 -2
- package/dist/components/post-tooltip2.js +100 -1774
- package/dist/components/post-tooltip2.js.map +1 -1
- package/dist/docs.d.ts +1 -21
- package/dist/docs.json +604 -77
- package/dist/esm/check-non-empty-58bd6b17.js +11 -0
- package/dist/esm/{check-non-empty-09c39561.js.map → check-non-empty-58bd6b17.js.map} +1 -1
- package/dist/esm/index-1427953c.js +40 -0
- package/dist/esm/index-1427953c.js.map +1 -0
- package/dist/esm/{index-4eff5fc5.js → index-35998e08.js} +144 -65
- package/dist/esm/index-35998e08.js.map +1 -0
- package/dist/esm/index.js +14 -12
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/package-e13ef9ad.js +5 -0
- package/dist/esm/package-e13ef9ad.js.map +1 -0
- package/dist/esm/post-accordion-8e96598a.js +85 -0
- package/dist/esm/post-accordion-8e96598a.js.map +1 -0
- package/dist/esm/post-accordion.entry.js +3 -83
- package/dist/esm/post-accordion.entry.js.map +1 -1
- package/dist/esm/post-alert-5e352303.js +99 -0
- package/dist/esm/{post-alert-e457e249.js.map → post-alert-5e352303.js.map} +1 -1
- package/dist/esm/post-alert.entry.js +5 -6
- package/dist/esm/post-alert.entry.js.map +1 -1
- package/dist/esm/{post-collapsible-c0a826b2.js → post-collapsible-3cc5dd87.js} +69 -69
- package/dist/esm/{post-collapsible-c0a826b2.js.map → post-collapsible-3cc5dd87.js.map} +1 -1
- package/dist/esm/post-collapsible.entry.js +4 -5
- package/dist/esm/post-collapsible.entry.js.map +1 -1
- package/dist/esm/post-components.js +4 -4
- package/dist/esm/post-components.js.map +1 -1
- package/dist/esm/post-icon-fdda3f99.js +103 -0
- package/dist/esm/post-icon-fdda3f99.js.map +1 -0
- package/dist/esm/post-icon.entry.js +5 -6
- package/dist/esm/post-icon.entry.js.map +1 -1
- package/dist/esm/post-popover-ff2c259f.js +116 -0
- package/dist/esm/post-popover-ff2c259f.js.map +1 -0
- package/dist/esm/post-popover.entry.js +5 -0
- package/dist/esm/post-popover.entry.js.map +1 -0
- package/dist/esm/post-popovercontainer-f4cd18cd.js +1876 -0
- package/dist/esm/post-popovercontainer-f4cd18cd.js.map +1 -0
- package/dist/esm/post-popovercontainer.entry.js +5 -0
- package/dist/esm/post-popovercontainer.entry.js.map +1 -0
- package/dist/esm/post-tab-header-486b267b.js +31 -0
- package/dist/esm/{post-tab-header-f0c355d6.js.map → post-tab-header-486b267b.js.map} +1 -1
- package/dist/esm/post-tab-header.entry.js +4 -4
- package/dist/esm/post-tab-panel-13940300.js +25 -0
- package/dist/esm/{post-tab-panel-46f02247.js.map → post-tab-panel-13940300.js.map} +1 -1
- package/dist/esm/post-tab-panel.entry.js +3 -3
- package/dist/esm/post-tabs-6f44ed1d.js +151 -0
- package/dist/esm/post-tabs-6f44ed1d.js.map +1 -0
- package/dist/esm/post-tabs.entry.js +3 -3
- package/dist/esm/{post-tooltip-fa7b4a0a.js → post-tooltip-1d99cd0c.js} +78 -1754
- package/dist/esm/post-tooltip-1d99cd0c.js.map +1 -0
- package/dist/esm/post-tooltip.entry.js +3 -4
- package/dist/esm/post-tooltip.entry.js.map +1 -1
- package/dist/post-components/index.esm.js +1 -1
- package/dist/post-components/p-169b8ef7.entry.js +2 -0
- package/dist/post-components/p-28be44d7.js +2 -0
- package/dist/post-components/{p-8b6fe20d.js.map → p-28be44d7.js.map} +1 -1
- package/dist/post-components/p-3ef3a1d2.js +2 -0
- package/dist/post-components/p-3ef3a1d2.js.map +1 -0
- package/dist/post-components/p-4b94c2a1.entry.js +2 -0
- package/dist/post-components/p-4cbb5212.entry.js +2 -0
- package/dist/post-components/p-51ae6f46.entry.js +2 -0
- package/dist/post-components/p-668bf58c.entry.js +2 -0
- package/dist/post-components/p-67d0a4fa.entry.js +2 -0
- package/dist/post-components/p-6b3a5063.entry.js +2 -0
- package/dist/post-components/{p-3604be27.js → p-6cdc82c6.js} +2 -2
- package/dist/post-components/p-723336f2.js +2 -0
- package/dist/post-components/{p-ca1e407c.js.map → p-723336f2.js.map} +1 -1
- package/dist/post-components/p-7d08e4f1.js +2 -0
- package/dist/post-components/p-7d08e4f1.js.map +1 -0
- package/dist/post-components/p-81591ad0.js +3 -0
- package/dist/post-components/p-81591ad0.js.map +1 -0
- package/dist/post-components/p-96f4ebc4.js +2 -0
- package/dist/post-components/p-96f4ebc4.js.map +1 -0
- package/dist/post-components/p-9b1b6e06.entry.js +2 -0
- package/dist/post-components/{p-9f71d450.js → p-a5a23448.js} +2 -2
- package/dist/post-components/p-aca6e9c1.js +2 -0
- package/dist/post-components/{p-fffce1d7.js.map → p-aca6e9c1.js.map} +1 -1
- package/dist/post-components/{p-b531475e.js → p-b095519d.js} +1 -1
- package/dist/post-components/p-bc27f061.js +9 -0
- package/dist/post-components/p-bc27f061.js.map +1 -0
- package/dist/post-components/p-bd1d0117.js +2 -0
- package/dist/post-components/p-bd1d0117.js.map +1 -0
- package/dist/post-components/p-d3ed113e.js +2 -0
- package/dist/post-components/p-d3ed113e.js.map +1 -0
- package/dist/post-components/p-d8365401.entry.js +2 -0
- package/dist/post-components/p-d8365401.entry.js.map +1 -0
- package/dist/post-components/p-e78d158d.entry.js +2 -0
- package/dist/post-components/p-e78d158d.entry.js.map +1 -0
- package/dist/post-components/{p-7b8797c6.entry.js → p-f695aab4.js} +2 -2
- package/dist/post-components/post-components.esm.js +1 -1
- package/dist/post-components/post-components.esm.js.map +1 -1
- package/dist/types/components/post-accordion/post-accordion.d.ts +26 -26
- package/dist/types/components/post-alert/post-alert.d.ts +45 -45
- package/dist/types/components/post-collapsible/post-collapsible.d.ts +31 -31
- package/dist/types/components/post-icon/post-icon.d.ts +43 -43
- package/dist/types/components/post-popover/post-popover.d.ts +53 -0
- package/dist/types/components/post-popovercontainer/post-popovercontainer.d.ts +62 -0
- package/dist/types/components/post-tab-header/post-tab-header.d.ts +9 -9
- package/dist/types/components/post-tab-panel/post-tab-panel.d.ts +8 -8
- package/dist/types/components/post-tabs/post-tabs.d.ts +32 -32
- package/dist/types/components/post-tooltip/post-tooltip.d.ts +35 -62
- package/dist/types/components.d.ts +115 -10
- package/dist/types/index.d.ts +3 -0
- package/dist/types/stencil-public-runtime.d.ts +8 -0
- package/package.json +15 -13
- package/dist/cjs/check-non-empty-ae713942.js.map +0 -1
- package/dist/cjs/check-one-of-27ad3154.js +0 -10
- package/dist/cjs/check-one-of-27ad3154.js.map +0 -1
- package/dist/cjs/index-b38a23e0.js +0 -41
- package/dist/cjs/index-b38a23e0.js.map +0 -1
- package/dist/cjs/index-b619e205.js.map +0 -1
- package/dist/cjs/package-4e9ab85c.js +0 -7
- package/dist/cjs/package-4e9ab85c.js.map +0 -1
- package/dist/cjs/post-alert-b46943e0.js +0 -101
- package/dist/cjs/post-icon-5b36814e.js +0 -105
- package/dist/cjs/post-icon-5b36814e.js.map +0 -1
- package/dist/cjs/post-tab-header-805c0a52.js +0 -33
- package/dist/cjs/post-tab-panel-caa44a77.js +0 -27
- package/dist/cjs/post-tabs-29d4dc70.js +0 -153
- package/dist/cjs/post-tabs-29d4dc70.js.map +0 -1
- package/dist/cjs/post-tooltip-32a9c549.js.map +0 -1
- package/dist/components/check-one-of.js +0 -8
- package/dist/components/check-one-of.js.map +0 -1
- package/dist/esm/check-non-empty-09c39561.js +0 -11
- package/dist/esm/check-one-of-74750af9.js +0 -8
- package/dist/esm/check-one-of-74750af9.js.map +0 -1
- package/dist/esm/index-35921354.js +0 -36
- package/dist/esm/index-35921354.js.map +0 -1
- package/dist/esm/index-4eff5fc5.js.map +0 -1
- package/dist/esm/package-b9b10dd3.js +0 -5
- package/dist/esm/package-b9b10dd3.js.map +0 -1
- package/dist/esm/post-alert-e457e249.js +0 -99
- package/dist/esm/post-icon-b34da686.js +0 -103
- package/dist/esm/post-icon-b34da686.js.map +0 -1
- package/dist/esm/post-tab-header-f0c355d6.js +0 -31
- package/dist/esm/post-tab-panel-46f02247.js +0 -25
- package/dist/esm/post-tabs-5dd55290.js +0 -151
- package/dist/esm/post-tabs-5dd55290.js.map +0 -1
- package/dist/esm/post-tooltip-fa7b4a0a.js.map +0 -1
- package/dist/post-components/p-1339f8cd.js +0 -2
- package/dist/post-components/p-1339f8cd.js.map +0 -1
- package/dist/post-components/p-195b8c88.entry.js +0 -2
- package/dist/post-components/p-3225e008.entry.js +0 -2
- package/dist/post-components/p-61ffffa9.entry.js +0 -2
- package/dist/post-components/p-88262544.js +0 -2
- package/dist/post-components/p-8b6fe20d.js +0 -2
- package/dist/post-components/p-a7649277.js +0 -3
- package/dist/post-components/p-a7649277.js.map +0 -1
- package/dist/post-components/p-a7c78dea.entry.js +0 -2
- package/dist/post-components/p-b2c3ed97.entry.js +0 -2
- package/dist/post-components/p-ba9aba3a.entry.js +0 -2
- package/dist/post-components/p-bd293ff3.entry.js +0 -2
- package/dist/post-components/p-ca1e407c.js +0 -2
- package/dist/post-components/p-d407b1c3.js +0 -2
- package/dist/post-components/p-d407b1c3.js.map +0 -1
- package/dist/post-components/p-dfe29f7f.js +0 -2
- package/dist/post-components/p-dfe29f7f.js.map +0 -1
- package/dist/post-components/p-fd7015ae.js +0 -9
- package/dist/post-components/p-fd7015ae.js.map +0 -1
- package/dist/post-components/p-fffce1d7.js +0 -2
- /package/dist/post-components/{p-195b8c88.entry.js.map → p-169b8ef7.entry.js.map} +0 -0
- /package/dist/post-components/{p-3225e008.entry.js.map → p-4b94c2a1.entry.js.map} +0 -0
- /package/dist/post-components/{p-61ffffa9.entry.js.map → p-4cbb5212.entry.js.map} +0 -0
- /package/dist/post-components/{p-88262544.js.map → p-51ae6f46.entry.js.map} +0 -0
- /package/dist/post-components/{p-a7c78dea.entry.js.map → p-668bf58c.entry.js.map} +0 -0
- /package/dist/post-components/{p-b2c3ed97.entry.js.map → p-67d0a4fa.entry.js.map} +0 -0
- /package/dist/post-components/{p-ba9aba3a.entry.js.map → p-6b3a5063.entry.js.map} +0 -0
- /package/dist/post-components/{p-3604be27.js.map → p-6cdc82c6.js.map} +0 -0
- /package/dist/post-components/{p-bd293ff3.entry.js.map → p-9b1b6e06.entry.js.map} +0 -0
- /package/dist/post-components/{p-9f71d450.js.map → p-a5a23448.js.map} +0 -0
- /package/dist/post-components/{p-b531475e.js.map → p-b095519d.js.map} +0 -0
- /package/dist/post-components/{p-7b8797c6.entry.js.map → p-f695aab4.js.map} +0 -0
|
@@ -1,1531 +1,6 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement as HTMLElement$1, h, Host } from '@stencil/core/internal/client';
|
|
2
2
|
import { v as version$2 } from './package.js';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const min = Math.min;
|
|
6
|
-
const max = Math.max;
|
|
7
|
-
const round = Math.round;
|
|
8
|
-
const floor = Math.floor;
|
|
9
|
-
const createCoords = v => ({
|
|
10
|
-
x: v,
|
|
11
|
-
y: v
|
|
12
|
-
});
|
|
13
|
-
const oppositeSideMap = {
|
|
14
|
-
left: 'right',
|
|
15
|
-
right: 'left',
|
|
16
|
-
bottom: 'top',
|
|
17
|
-
top: 'bottom'
|
|
18
|
-
};
|
|
19
|
-
const oppositeAlignmentMap = {
|
|
20
|
-
start: 'end',
|
|
21
|
-
end: 'start'
|
|
22
|
-
};
|
|
23
|
-
function clamp(start, value, end) {
|
|
24
|
-
return max(start, min(value, end));
|
|
25
|
-
}
|
|
26
|
-
function evaluate(value, param) {
|
|
27
|
-
return typeof value === 'function' ? value(param) : value;
|
|
28
|
-
}
|
|
29
|
-
function getSide(placement) {
|
|
30
|
-
return placement.split('-')[0];
|
|
31
|
-
}
|
|
32
|
-
function getAlignment(placement) {
|
|
33
|
-
return placement.split('-')[1];
|
|
34
|
-
}
|
|
35
|
-
function getOppositeAxis(axis) {
|
|
36
|
-
return axis === 'x' ? 'y' : 'x';
|
|
37
|
-
}
|
|
38
|
-
function getAxisLength(axis) {
|
|
39
|
-
return axis === 'y' ? 'height' : 'width';
|
|
40
|
-
}
|
|
41
|
-
function getSideAxis(placement) {
|
|
42
|
-
return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
|
|
43
|
-
}
|
|
44
|
-
function getAlignmentAxis(placement) {
|
|
45
|
-
return getOppositeAxis(getSideAxis(placement));
|
|
46
|
-
}
|
|
47
|
-
function getAlignmentSides(placement, rects, rtl) {
|
|
48
|
-
if (rtl === void 0) {
|
|
49
|
-
rtl = false;
|
|
50
|
-
}
|
|
51
|
-
const alignment = getAlignment(placement);
|
|
52
|
-
const alignmentAxis = getAlignmentAxis(placement);
|
|
53
|
-
const length = getAxisLength(alignmentAxis);
|
|
54
|
-
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
55
|
-
if (rects.reference[length] > rects.floating[length]) {
|
|
56
|
-
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
57
|
-
}
|
|
58
|
-
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
59
|
-
}
|
|
60
|
-
function getExpandedPlacements(placement) {
|
|
61
|
-
const oppositePlacement = getOppositePlacement(placement);
|
|
62
|
-
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
63
|
-
}
|
|
64
|
-
function getOppositeAlignmentPlacement(placement) {
|
|
65
|
-
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
66
|
-
}
|
|
67
|
-
function getSideList(side, isStart, rtl) {
|
|
68
|
-
const lr = ['left', 'right'];
|
|
69
|
-
const rl = ['right', 'left'];
|
|
70
|
-
const tb = ['top', 'bottom'];
|
|
71
|
-
const bt = ['bottom', 'top'];
|
|
72
|
-
switch (side) {
|
|
73
|
-
case 'top':
|
|
74
|
-
case 'bottom':
|
|
75
|
-
if (rtl) return isStart ? rl : lr;
|
|
76
|
-
return isStart ? lr : rl;
|
|
77
|
-
case 'left':
|
|
78
|
-
case 'right':
|
|
79
|
-
return isStart ? tb : bt;
|
|
80
|
-
default:
|
|
81
|
-
return [];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
85
|
-
const alignment = getAlignment(placement);
|
|
86
|
-
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
|
87
|
-
if (alignment) {
|
|
88
|
-
list = list.map(side => side + "-" + alignment);
|
|
89
|
-
if (flipAlignment) {
|
|
90
|
-
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return list;
|
|
94
|
-
}
|
|
95
|
-
function getOppositePlacement(placement) {
|
|
96
|
-
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
97
|
-
}
|
|
98
|
-
function expandPaddingObject(padding) {
|
|
99
|
-
return {
|
|
100
|
-
top: 0,
|
|
101
|
-
right: 0,
|
|
102
|
-
bottom: 0,
|
|
103
|
-
left: 0,
|
|
104
|
-
...padding
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
function getPaddingObject(padding) {
|
|
108
|
-
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
109
|
-
top: padding,
|
|
110
|
-
right: padding,
|
|
111
|
-
bottom: padding,
|
|
112
|
-
left: padding
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
function rectToClientRect(rect) {
|
|
116
|
-
return {
|
|
117
|
-
...rect,
|
|
118
|
-
top: rect.y,
|
|
119
|
-
left: rect.x,
|
|
120
|
-
right: rect.x + rect.width,
|
|
121
|
-
bottom: rect.y + rect.height
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
126
|
-
let {
|
|
127
|
-
reference,
|
|
128
|
-
floating
|
|
129
|
-
} = _ref;
|
|
130
|
-
const sideAxis = getSideAxis(placement);
|
|
131
|
-
const alignmentAxis = getAlignmentAxis(placement);
|
|
132
|
-
const alignLength = getAxisLength(alignmentAxis);
|
|
133
|
-
const side = getSide(placement);
|
|
134
|
-
const isVertical = sideAxis === 'y';
|
|
135
|
-
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
136
|
-
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
137
|
-
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
138
|
-
let coords;
|
|
139
|
-
switch (side) {
|
|
140
|
-
case 'top':
|
|
141
|
-
coords = {
|
|
142
|
-
x: commonX,
|
|
143
|
-
y: reference.y - floating.height
|
|
144
|
-
};
|
|
145
|
-
break;
|
|
146
|
-
case 'bottom':
|
|
147
|
-
coords = {
|
|
148
|
-
x: commonX,
|
|
149
|
-
y: reference.y + reference.height
|
|
150
|
-
};
|
|
151
|
-
break;
|
|
152
|
-
case 'right':
|
|
153
|
-
coords = {
|
|
154
|
-
x: reference.x + reference.width,
|
|
155
|
-
y: commonY
|
|
156
|
-
};
|
|
157
|
-
break;
|
|
158
|
-
case 'left':
|
|
159
|
-
coords = {
|
|
160
|
-
x: reference.x - floating.width,
|
|
161
|
-
y: commonY
|
|
162
|
-
};
|
|
163
|
-
break;
|
|
164
|
-
default:
|
|
165
|
-
coords = {
|
|
166
|
-
x: reference.x,
|
|
167
|
-
y: reference.y
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
switch (getAlignment(placement)) {
|
|
171
|
-
case 'start':
|
|
172
|
-
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
173
|
-
break;
|
|
174
|
-
case 'end':
|
|
175
|
-
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
return coords;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Computes the `x` and `y` coordinates that will place the floating element
|
|
183
|
-
* next to a reference element when it is given a certain positioning strategy.
|
|
184
|
-
*
|
|
185
|
-
* This export does not have any `platform` interface logic. You will need to
|
|
186
|
-
* write one for the platform you are using Floating UI with.
|
|
187
|
-
*/
|
|
188
|
-
const computePosition$1 = async (reference, floating, config) => {
|
|
189
|
-
const {
|
|
190
|
-
placement = 'bottom',
|
|
191
|
-
strategy = 'absolute',
|
|
192
|
-
middleware = [],
|
|
193
|
-
platform
|
|
194
|
-
} = config;
|
|
195
|
-
const validMiddleware = middleware.filter(Boolean);
|
|
196
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
197
|
-
let rects = await platform.getElementRects({
|
|
198
|
-
reference,
|
|
199
|
-
floating,
|
|
200
|
-
strategy
|
|
201
|
-
});
|
|
202
|
-
let {
|
|
203
|
-
x,
|
|
204
|
-
y
|
|
205
|
-
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
206
|
-
let statefulPlacement = placement;
|
|
207
|
-
let middlewareData = {};
|
|
208
|
-
let resetCount = 0;
|
|
209
|
-
for (let i = 0; i < validMiddleware.length; i++) {
|
|
210
|
-
const {
|
|
211
|
-
name,
|
|
212
|
-
fn
|
|
213
|
-
} = validMiddleware[i];
|
|
214
|
-
const {
|
|
215
|
-
x: nextX,
|
|
216
|
-
y: nextY,
|
|
217
|
-
data,
|
|
218
|
-
reset
|
|
219
|
-
} = await fn({
|
|
220
|
-
x,
|
|
221
|
-
y,
|
|
222
|
-
initialPlacement: placement,
|
|
223
|
-
placement: statefulPlacement,
|
|
224
|
-
strategy,
|
|
225
|
-
middlewareData,
|
|
226
|
-
rects,
|
|
227
|
-
platform,
|
|
228
|
-
elements: {
|
|
229
|
-
reference,
|
|
230
|
-
floating
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
x = nextX != null ? nextX : x;
|
|
234
|
-
y = nextY != null ? nextY : y;
|
|
235
|
-
middlewareData = {
|
|
236
|
-
...middlewareData,
|
|
237
|
-
[name]: {
|
|
238
|
-
...middlewareData[name],
|
|
239
|
-
...data
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
if (reset && resetCount <= 50) {
|
|
243
|
-
resetCount++;
|
|
244
|
-
if (typeof reset === 'object') {
|
|
245
|
-
if (reset.placement) {
|
|
246
|
-
statefulPlacement = reset.placement;
|
|
247
|
-
}
|
|
248
|
-
if (reset.rects) {
|
|
249
|
-
rects = reset.rects === true ? await platform.getElementRects({
|
|
250
|
-
reference,
|
|
251
|
-
floating,
|
|
252
|
-
strategy
|
|
253
|
-
}) : reset.rects;
|
|
254
|
-
}
|
|
255
|
-
({
|
|
256
|
-
x,
|
|
257
|
-
y
|
|
258
|
-
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
259
|
-
}
|
|
260
|
-
i = -1;
|
|
261
|
-
continue;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
return {
|
|
265
|
-
x,
|
|
266
|
-
y,
|
|
267
|
-
placement: statefulPlacement,
|
|
268
|
-
strategy,
|
|
269
|
-
middlewareData
|
|
270
|
-
};
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Resolves with an object of overflow side offsets that determine how much the
|
|
275
|
-
* element is overflowing a given clipping boundary on each side.
|
|
276
|
-
* - positive = overflowing the boundary by that number of pixels
|
|
277
|
-
* - negative = how many pixels left before it will overflow
|
|
278
|
-
* - 0 = lies flush with the boundary
|
|
279
|
-
* @see https://floating-ui.com/docs/detectOverflow
|
|
280
|
-
*/
|
|
281
|
-
async function detectOverflow(state, options) {
|
|
282
|
-
var _await$platform$isEle;
|
|
283
|
-
if (options === void 0) {
|
|
284
|
-
options = {};
|
|
285
|
-
}
|
|
286
|
-
const {
|
|
287
|
-
x,
|
|
288
|
-
y,
|
|
289
|
-
platform,
|
|
290
|
-
rects,
|
|
291
|
-
elements,
|
|
292
|
-
strategy
|
|
293
|
-
} = state;
|
|
294
|
-
const {
|
|
295
|
-
boundary = 'clippingAncestors',
|
|
296
|
-
rootBoundary = 'viewport',
|
|
297
|
-
elementContext = 'floating',
|
|
298
|
-
altBoundary = false,
|
|
299
|
-
padding = 0
|
|
300
|
-
} = evaluate(options, state);
|
|
301
|
-
const paddingObject = getPaddingObject(padding);
|
|
302
|
-
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
303
|
-
const element = elements[altBoundary ? altContext : elementContext];
|
|
304
|
-
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
305
|
-
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
|
306
|
-
boundary,
|
|
307
|
-
rootBoundary,
|
|
308
|
-
strategy
|
|
309
|
-
}));
|
|
310
|
-
const rect = elementContext === 'floating' ? {
|
|
311
|
-
...rects.floating,
|
|
312
|
-
x,
|
|
313
|
-
y
|
|
314
|
-
} : rects.reference;
|
|
315
|
-
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
316
|
-
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
317
|
-
x: 1,
|
|
318
|
-
y: 1
|
|
319
|
-
} : {
|
|
320
|
-
x: 1,
|
|
321
|
-
y: 1
|
|
322
|
-
};
|
|
323
|
-
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
324
|
-
rect,
|
|
325
|
-
offsetParent,
|
|
326
|
-
strategy
|
|
327
|
-
}) : rect);
|
|
328
|
-
return {
|
|
329
|
-
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
330
|
-
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
331
|
-
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
332
|
-
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Provides data to position an inner element of the floating element so that it
|
|
338
|
-
* appears centered to the reference element.
|
|
339
|
-
* @see https://floating-ui.com/docs/arrow
|
|
340
|
-
*/
|
|
341
|
-
const arrow = options => ({
|
|
342
|
-
name: 'arrow',
|
|
343
|
-
options,
|
|
344
|
-
async fn(state) {
|
|
345
|
-
const {
|
|
346
|
-
x,
|
|
347
|
-
y,
|
|
348
|
-
placement,
|
|
349
|
-
rects,
|
|
350
|
-
platform,
|
|
351
|
-
elements,
|
|
352
|
-
middlewareData
|
|
353
|
-
} = state;
|
|
354
|
-
// Since `element` is required, we don't Partial<> the type.
|
|
355
|
-
const {
|
|
356
|
-
element,
|
|
357
|
-
padding = 0
|
|
358
|
-
} = evaluate(options, state) || {};
|
|
359
|
-
if (element == null) {
|
|
360
|
-
return {};
|
|
361
|
-
}
|
|
362
|
-
const paddingObject = getPaddingObject(padding);
|
|
363
|
-
const coords = {
|
|
364
|
-
x,
|
|
365
|
-
y
|
|
366
|
-
};
|
|
367
|
-
const axis = getAlignmentAxis(placement);
|
|
368
|
-
const length = getAxisLength(axis);
|
|
369
|
-
const arrowDimensions = await platform.getDimensions(element);
|
|
370
|
-
const isYAxis = axis === 'y';
|
|
371
|
-
const minProp = isYAxis ? 'top' : 'left';
|
|
372
|
-
const maxProp = isYAxis ? 'bottom' : 'right';
|
|
373
|
-
const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
|
374
|
-
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
375
|
-
const startDiff = coords[axis] - rects.reference[axis];
|
|
376
|
-
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
377
|
-
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
378
|
-
|
|
379
|
-
// DOM platform can return `window` as the `offsetParent`.
|
|
380
|
-
if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
|
|
381
|
-
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
382
|
-
}
|
|
383
|
-
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
384
|
-
|
|
385
|
-
// If the padding is large enough that it causes the arrow to no longer be
|
|
386
|
-
// centered, modify the padding so that it is centered.
|
|
387
|
-
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
388
|
-
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
389
|
-
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
390
|
-
|
|
391
|
-
// Make sure the arrow doesn't overflow the floating element if the center
|
|
392
|
-
// point is outside the floating element's bounds.
|
|
393
|
-
const min$1 = minPadding;
|
|
394
|
-
const max = clientSize - arrowDimensions[length] - maxPadding;
|
|
395
|
-
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
396
|
-
const offset = clamp(min$1, center, max);
|
|
397
|
-
|
|
398
|
-
// If the reference is small enough that the arrow's padding causes it to
|
|
399
|
-
// to point to nothing for an aligned placement, adjust the offset of the
|
|
400
|
-
// floating element itself. To ensure `shift()` continues to take action,
|
|
401
|
-
// a single reset is performed when this is true.
|
|
402
|
-
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
403
|
-
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
|
|
404
|
-
return {
|
|
405
|
-
[axis]: coords[axis] + alignmentOffset,
|
|
406
|
-
data: {
|
|
407
|
-
[axis]: offset,
|
|
408
|
-
centerOffset: center - offset - alignmentOffset,
|
|
409
|
-
...(shouldAddOffset && {
|
|
410
|
-
alignmentOffset
|
|
411
|
-
})
|
|
412
|
-
},
|
|
413
|
-
reset: shouldAddOffset
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
420
|
-
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
421
|
-
* clipping boundary. Alternative to `autoPlacement`.
|
|
422
|
-
* @see https://floating-ui.com/docs/flip
|
|
423
|
-
*/
|
|
424
|
-
const flip = function (options) {
|
|
425
|
-
if (options === void 0) {
|
|
426
|
-
options = {};
|
|
427
|
-
}
|
|
428
|
-
return {
|
|
429
|
-
name: 'flip',
|
|
430
|
-
options,
|
|
431
|
-
async fn(state) {
|
|
432
|
-
var _middlewareData$arrow, _middlewareData$flip;
|
|
433
|
-
const {
|
|
434
|
-
placement,
|
|
435
|
-
middlewareData,
|
|
436
|
-
rects,
|
|
437
|
-
initialPlacement,
|
|
438
|
-
platform,
|
|
439
|
-
elements
|
|
440
|
-
} = state;
|
|
441
|
-
const {
|
|
442
|
-
mainAxis: checkMainAxis = true,
|
|
443
|
-
crossAxis: checkCrossAxis = true,
|
|
444
|
-
fallbackPlacements: specifiedFallbackPlacements,
|
|
445
|
-
fallbackStrategy = 'bestFit',
|
|
446
|
-
fallbackAxisSideDirection = 'none',
|
|
447
|
-
flipAlignment = true,
|
|
448
|
-
...detectOverflowOptions
|
|
449
|
-
} = evaluate(options, state);
|
|
450
|
-
|
|
451
|
-
// If a reset by the arrow was caused due to an alignment offset being
|
|
452
|
-
// added, we should skip any logic now since `flip()` has already done its
|
|
453
|
-
// work.
|
|
454
|
-
// https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
|
|
455
|
-
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
456
|
-
return {};
|
|
457
|
-
}
|
|
458
|
-
const side = getSide(placement);
|
|
459
|
-
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
460
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
461
|
-
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
462
|
-
if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
|
|
463
|
-
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
464
|
-
}
|
|
465
|
-
const placements = [initialPlacement, ...fallbackPlacements];
|
|
466
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
467
|
-
const overflows = [];
|
|
468
|
-
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
469
|
-
if (checkMainAxis) {
|
|
470
|
-
overflows.push(overflow[side]);
|
|
471
|
-
}
|
|
472
|
-
if (checkCrossAxis) {
|
|
473
|
-
const sides = getAlignmentSides(placement, rects, rtl);
|
|
474
|
-
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
475
|
-
}
|
|
476
|
-
overflowsData = [...overflowsData, {
|
|
477
|
-
placement,
|
|
478
|
-
overflows
|
|
479
|
-
}];
|
|
480
|
-
|
|
481
|
-
// One or more sides is overflowing.
|
|
482
|
-
if (!overflows.every(side => side <= 0)) {
|
|
483
|
-
var _middlewareData$flip2, _overflowsData$filter;
|
|
484
|
-
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
485
|
-
const nextPlacement = placements[nextIndex];
|
|
486
|
-
if (nextPlacement) {
|
|
487
|
-
// Try next placement and re-run the lifecycle.
|
|
488
|
-
return {
|
|
489
|
-
data: {
|
|
490
|
-
index: nextIndex,
|
|
491
|
-
overflows: overflowsData
|
|
492
|
-
},
|
|
493
|
-
reset: {
|
|
494
|
-
placement: nextPlacement
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
// First, find the candidates that fit on the mainAxis side of overflow,
|
|
500
|
-
// then find the placement that fits the best on the main crossAxis side.
|
|
501
|
-
let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
|
502
|
-
|
|
503
|
-
// Otherwise fallback.
|
|
504
|
-
if (!resetPlacement) {
|
|
505
|
-
switch (fallbackStrategy) {
|
|
506
|
-
case 'bestFit':
|
|
507
|
-
{
|
|
508
|
-
var _overflowsData$map$so;
|
|
509
|
-
const placement = (_overflowsData$map$so = overflowsData.map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
|
|
510
|
-
if (placement) {
|
|
511
|
-
resetPlacement = placement;
|
|
512
|
-
}
|
|
513
|
-
break;
|
|
514
|
-
}
|
|
515
|
-
case 'initialPlacement':
|
|
516
|
-
resetPlacement = initialPlacement;
|
|
517
|
-
break;
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
if (placement !== resetPlacement) {
|
|
521
|
-
return {
|
|
522
|
-
reset: {
|
|
523
|
-
placement: resetPlacement
|
|
524
|
-
}
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
return {};
|
|
529
|
-
}
|
|
530
|
-
};
|
|
531
|
-
};
|
|
532
|
-
|
|
533
|
-
function getBoundingRect(rects) {
|
|
534
|
-
const minX = min(...rects.map(rect => rect.left));
|
|
535
|
-
const minY = min(...rects.map(rect => rect.top));
|
|
536
|
-
const maxX = max(...rects.map(rect => rect.right));
|
|
537
|
-
const maxY = max(...rects.map(rect => rect.bottom));
|
|
538
|
-
return {
|
|
539
|
-
x: minX,
|
|
540
|
-
y: minY,
|
|
541
|
-
width: maxX - minX,
|
|
542
|
-
height: maxY - minY
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
function getRectsByLine(rects) {
|
|
546
|
-
const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
|
|
547
|
-
const groups = [];
|
|
548
|
-
let prevRect = null;
|
|
549
|
-
for (let i = 0; i < sortedRects.length; i++) {
|
|
550
|
-
const rect = sortedRects[i];
|
|
551
|
-
if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
|
|
552
|
-
groups.push([rect]);
|
|
553
|
-
} else {
|
|
554
|
-
groups[groups.length - 1].push(rect);
|
|
555
|
-
}
|
|
556
|
-
prevRect = rect;
|
|
557
|
-
}
|
|
558
|
-
return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
|
|
559
|
-
}
|
|
560
|
-
/**
|
|
561
|
-
* Provides improved positioning for inline reference elements that can span
|
|
562
|
-
* over multiple lines, such as hyperlinks or range selections.
|
|
563
|
-
* @see https://floating-ui.com/docs/inline
|
|
564
|
-
*/
|
|
565
|
-
const inline = function (options) {
|
|
566
|
-
if (options === void 0) {
|
|
567
|
-
options = {};
|
|
568
|
-
}
|
|
569
|
-
return {
|
|
570
|
-
name: 'inline',
|
|
571
|
-
options,
|
|
572
|
-
async fn(state) {
|
|
573
|
-
const {
|
|
574
|
-
placement,
|
|
575
|
-
elements,
|
|
576
|
-
rects,
|
|
577
|
-
platform,
|
|
578
|
-
strategy
|
|
579
|
-
} = state;
|
|
580
|
-
// A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
|
|
581
|
-
// ClientRect's bounds, despite the event listener being triggered. A
|
|
582
|
-
// padding of 2 seems to handle this issue.
|
|
583
|
-
const {
|
|
584
|
-
padding = 2,
|
|
585
|
-
x,
|
|
586
|
-
y
|
|
587
|
-
} = evaluate(options, state);
|
|
588
|
-
const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
|
|
589
|
-
const clientRects = getRectsByLine(nativeClientRects);
|
|
590
|
-
const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
|
|
591
|
-
const paddingObject = getPaddingObject(padding);
|
|
592
|
-
function getBoundingClientRect() {
|
|
593
|
-
// There are two rects and they are disjoined.
|
|
594
|
-
if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
|
|
595
|
-
// Find the first rect in which the point is fully inside.
|
|
596
|
-
return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
// There are 2 or more connected rects.
|
|
600
|
-
if (clientRects.length >= 2) {
|
|
601
|
-
if (getSideAxis(placement) === 'y') {
|
|
602
|
-
const firstRect = clientRects[0];
|
|
603
|
-
const lastRect = clientRects[clientRects.length - 1];
|
|
604
|
-
const isTop = getSide(placement) === 'top';
|
|
605
|
-
const top = firstRect.top;
|
|
606
|
-
const bottom = lastRect.bottom;
|
|
607
|
-
const left = isTop ? firstRect.left : lastRect.left;
|
|
608
|
-
const right = isTop ? firstRect.right : lastRect.right;
|
|
609
|
-
const width = right - left;
|
|
610
|
-
const height = bottom - top;
|
|
611
|
-
return {
|
|
612
|
-
top,
|
|
613
|
-
bottom,
|
|
614
|
-
left,
|
|
615
|
-
right,
|
|
616
|
-
width,
|
|
617
|
-
height,
|
|
618
|
-
x: left,
|
|
619
|
-
y: top
|
|
620
|
-
};
|
|
621
|
-
}
|
|
622
|
-
const isLeftSide = getSide(placement) === 'left';
|
|
623
|
-
const maxRight = max(...clientRects.map(rect => rect.right));
|
|
624
|
-
const minLeft = min(...clientRects.map(rect => rect.left));
|
|
625
|
-
const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
|
|
626
|
-
const top = measureRects[0].top;
|
|
627
|
-
const bottom = measureRects[measureRects.length - 1].bottom;
|
|
628
|
-
const left = minLeft;
|
|
629
|
-
const right = maxRight;
|
|
630
|
-
const width = right - left;
|
|
631
|
-
const height = bottom - top;
|
|
632
|
-
return {
|
|
633
|
-
top,
|
|
634
|
-
bottom,
|
|
635
|
-
left,
|
|
636
|
-
right,
|
|
637
|
-
width,
|
|
638
|
-
height,
|
|
639
|
-
x: left,
|
|
640
|
-
y: top
|
|
641
|
-
};
|
|
642
|
-
}
|
|
643
|
-
return fallback;
|
|
644
|
-
}
|
|
645
|
-
const resetRects = await platform.getElementRects({
|
|
646
|
-
reference: {
|
|
647
|
-
getBoundingClientRect
|
|
648
|
-
},
|
|
649
|
-
floating: elements.floating,
|
|
650
|
-
strategy
|
|
651
|
-
});
|
|
652
|
-
if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
|
|
653
|
-
return {
|
|
654
|
-
reset: {
|
|
655
|
-
rects: resetRects
|
|
656
|
-
}
|
|
657
|
-
};
|
|
658
|
-
}
|
|
659
|
-
return {};
|
|
660
|
-
}
|
|
661
|
-
};
|
|
662
|
-
};
|
|
663
|
-
|
|
664
|
-
// For type backwards-compatibility, the `OffsetOptions` type was also
|
|
665
|
-
// Derivable.
|
|
666
|
-
async function convertValueToCoords(state, options) {
|
|
667
|
-
const {
|
|
668
|
-
placement,
|
|
669
|
-
platform,
|
|
670
|
-
elements
|
|
671
|
-
} = state;
|
|
672
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
673
|
-
const side = getSide(placement);
|
|
674
|
-
const alignment = getAlignment(placement);
|
|
675
|
-
const isVertical = getSideAxis(placement) === 'y';
|
|
676
|
-
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
|
677
|
-
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
678
|
-
const rawValue = evaluate(options, state);
|
|
679
|
-
|
|
680
|
-
// eslint-disable-next-line prefer-const
|
|
681
|
-
let {
|
|
682
|
-
mainAxis,
|
|
683
|
-
crossAxis,
|
|
684
|
-
alignmentAxis
|
|
685
|
-
} = typeof rawValue === 'number' ? {
|
|
686
|
-
mainAxis: rawValue,
|
|
687
|
-
crossAxis: 0,
|
|
688
|
-
alignmentAxis: null
|
|
689
|
-
} : {
|
|
690
|
-
mainAxis: 0,
|
|
691
|
-
crossAxis: 0,
|
|
692
|
-
alignmentAxis: null,
|
|
693
|
-
...rawValue
|
|
694
|
-
};
|
|
695
|
-
if (alignment && typeof alignmentAxis === 'number') {
|
|
696
|
-
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
697
|
-
}
|
|
698
|
-
return isVertical ? {
|
|
699
|
-
x: crossAxis * crossAxisMulti,
|
|
700
|
-
y: mainAxis * mainAxisMulti
|
|
701
|
-
} : {
|
|
702
|
-
x: mainAxis * mainAxisMulti,
|
|
703
|
-
y: crossAxis * crossAxisMulti
|
|
704
|
-
};
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
/**
|
|
708
|
-
* Modifies the placement by translating the floating element along the
|
|
709
|
-
* specified axes.
|
|
710
|
-
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
711
|
-
* object may be passed.
|
|
712
|
-
* @see https://floating-ui.com/docs/offset
|
|
713
|
-
*/
|
|
714
|
-
const offset = function (options) {
|
|
715
|
-
if (options === void 0) {
|
|
716
|
-
options = 0;
|
|
717
|
-
}
|
|
718
|
-
return {
|
|
719
|
-
name: 'offset',
|
|
720
|
-
options,
|
|
721
|
-
async fn(state) {
|
|
722
|
-
const {
|
|
723
|
-
x,
|
|
724
|
-
y
|
|
725
|
-
} = state;
|
|
726
|
-
const diffCoords = await convertValueToCoords(state, options);
|
|
727
|
-
return {
|
|
728
|
-
x: x + diffCoords.x,
|
|
729
|
-
y: y + diffCoords.y,
|
|
730
|
-
data: diffCoords
|
|
731
|
-
};
|
|
732
|
-
}
|
|
733
|
-
};
|
|
734
|
-
};
|
|
735
|
-
|
|
736
|
-
/**
|
|
737
|
-
* Optimizes the visibility of the floating element by shifting it in order to
|
|
738
|
-
* keep it in view when it will overflow the clipping boundary.
|
|
739
|
-
* @see https://floating-ui.com/docs/shift
|
|
740
|
-
*/
|
|
741
|
-
const shift = function (options) {
|
|
742
|
-
if (options === void 0) {
|
|
743
|
-
options = {};
|
|
744
|
-
}
|
|
745
|
-
return {
|
|
746
|
-
name: 'shift',
|
|
747
|
-
options,
|
|
748
|
-
async fn(state) {
|
|
749
|
-
const {
|
|
750
|
-
x,
|
|
751
|
-
y,
|
|
752
|
-
placement
|
|
753
|
-
} = state;
|
|
754
|
-
const {
|
|
755
|
-
mainAxis: checkMainAxis = true,
|
|
756
|
-
crossAxis: checkCrossAxis = false,
|
|
757
|
-
limiter = {
|
|
758
|
-
fn: _ref => {
|
|
759
|
-
let {
|
|
760
|
-
x,
|
|
761
|
-
y
|
|
762
|
-
} = _ref;
|
|
763
|
-
return {
|
|
764
|
-
x,
|
|
765
|
-
y
|
|
766
|
-
};
|
|
767
|
-
}
|
|
768
|
-
},
|
|
769
|
-
...detectOverflowOptions
|
|
770
|
-
} = evaluate(options, state);
|
|
771
|
-
const coords = {
|
|
772
|
-
x,
|
|
773
|
-
y
|
|
774
|
-
};
|
|
775
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
776
|
-
const crossAxis = getSideAxis(getSide(placement));
|
|
777
|
-
const mainAxis = getOppositeAxis(crossAxis);
|
|
778
|
-
let mainAxisCoord = coords[mainAxis];
|
|
779
|
-
let crossAxisCoord = coords[crossAxis];
|
|
780
|
-
if (checkMainAxis) {
|
|
781
|
-
const minSide = mainAxis === 'y' ? 'top' : 'left';
|
|
782
|
-
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
783
|
-
const min = mainAxisCoord + overflow[minSide];
|
|
784
|
-
const max = mainAxisCoord - overflow[maxSide];
|
|
785
|
-
mainAxisCoord = clamp(min, mainAxisCoord, max);
|
|
786
|
-
}
|
|
787
|
-
if (checkCrossAxis) {
|
|
788
|
-
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
789
|
-
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
790
|
-
const min = crossAxisCoord + overflow[minSide];
|
|
791
|
-
const max = crossAxisCoord - overflow[maxSide];
|
|
792
|
-
crossAxisCoord = clamp(min, crossAxisCoord, max);
|
|
793
|
-
}
|
|
794
|
-
const limitedCoords = limiter.fn({
|
|
795
|
-
...state,
|
|
796
|
-
[mainAxis]: mainAxisCoord,
|
|
797
|
-
[crossAxis]: crossAxisCoord
|
|
798
|
-
});
|
|
799
|
-
return {
|
|
800
|
-
...limitedCoords,
|
|
801
|
-
data: {
|
|
802
|
-
x: limitedCoords.x - x,
|
|
803
|
-
y: limitedCoords.y - y
|
|
804
|
-
}
|
|
805
|
-
};
|
|
806
|
-
}
|
|
807
|
-
};
|
|
808
|
-
};
|
|
809
|
-
|
|
810
|
-
function getNodeName(node) {
|
|
811
|
-
if (isNode(node)) {
|
|
812
|
-
return (node.nodeName || '').toLowerCase();
|
|
813
|
-
}
|
|
814
|
-
// Mocked nodes in testing environments may not be instances of Node. By
|
|
815
|
-
// returning `#document` an infinite loop won't occur.
|
|
816
|
-
// https://github.com/floating-ui/floating-ui/issues/2317
|
|
817
|
-
return '#document';
|
|
818
|
-
}
|
|
819
|
-
function getWindow$1(node) {
|
|
820
|
-
var _node$ownerDocument;
|
|
821
|
-
return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
822
|
-
}
|
|
823
|
-
function getDocumentElement(node) {
|
|
824
|
-
var _ref;
|
|
825
|
-
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
826
|
-
}
|
|
827
|
-
function isNode(value) {
|
|
828
|
-
return value instanceof Node || value instanceof getWindow$1(value).Node;
|
|
829
|
-
}
|
|
830
|
-
function isElement(value) {
|
|
831
|
-
return value instanceof Element || value instanceof getWindow$1(value).Element;
|
|
832
|
-
}
|
|
833
|
-
function isHTMLElement(value) {
|
|
834
|
-
return value instanceof HTMLElement || value instanceof getWindow$1(value).HTMLElement;
|
|
835
|
-
}
|
|
836
|
-
function isShadowRoot(value) {
|
|
837
|
-
// Browsers without `ShadowRoot` support.
|
|
838
|
-
if (typeof ShadowRoot === 'undefined') {
|
|
839
|
-
return false;
|
|
840
|
-
}
|
|
841
|
-
return value instanceof ShadowRoot || value instanceof getWindow$1(value).ShadowRoot;
|
|
842
|
-
}
|
|
843
|
-
function isOverflowElement(element) {
|
|
844
|
-
const {
|
|
845
|
-
overflow,
|
|
846
|
-
overflowX,
|
|
847
|
-
overflowY,
|
|
848
|
-
display
|
|
849
|
-
} = getComputedStyle(element);
|
|
850
|
-
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
|
|
851
|
-
}
|
|
852
|
-
function isTableElement(element) {
|
|
853
|
-
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
854
|
-
}
|
|
855
|
-
function isContainingBlock(element) {
|
|
856
|
-
const webkit = isWebKit();
|
|
857
|
-
const css = getComputedStyle(element);
|
|
858
|
-
|
|
859
|
-
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
860
|
-
return css.transform !== 'none' || css.perspective !== 'none' || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
|
|
861
|
-
}
|
|
862
|
-
function getContainingBlock(element) {
|
|
863
|
-
let currentNode = getParentNode(element);
|
|
864
|
-
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
865
|
-
if (isContainingBlock(currentNode)) {
|
|
866
|
-
return currentNode;
|
|
867
|
-
} else {
|
|
868
|
-
currentNode = getParentNode(currentNode);
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
return null;
|
|
872
|
-
}
|
|
873
|
-
function isWebKit() {
|
|
874
|
-
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
|
875
|
-
return CSS.supports('-webkit-backdrop-filter', 'none');
|
|
876
|
-
}
|
|
877
|
-
function isLastTraversableNode(node) {
|
|
878
|
-
return ['html', 'body', '#document'].includes(getNodeName(node));
|
|
879
|
-
}
|
|
880
|
-
function getComputedStyle(element) {
|
|
881
|
-
return getWindow$1(element).getComputedStyle(element);
|
|
882
|
-
}
|
|
883
|
-
function getNodeScroll(element) {
|
|
884
|
-
if (isElement(element)) {
|
|
885
|
-
return {
|
|
886
|
-
scrollLeft: element.scrollLeft,
|
|
887
|
-
scrollTop: element.scrollTop
|
|
888
|
-
};
|
|
889
|
-
}
|
|
890
|
-
return {
|
|
891
|
-
scrollLeft: element.pageXOffset,
|
|
892
|
-
scrollTop: element.pageYOffset
|
|
893
|
-
};
|
|
894
|
-
}
|
|
895
|
-
function getParentNode(node) {
|
|
896
|
-
if (getNodeName(node) === 'html') {
|
|
897
|
-
return node;
|
|
898
|
-
}
|
|
899
|
-
const result =
|
|
900
|
-
// Step into the shadow DOM of the parent of a slotted node.
|
|
901
|
-
node.assignedSlot ||
|
|
902
|
-
// DOM Element detected.
|
|
903
|
-
node.parentNode ||
|
|
904
|
-
// ShadowRoot detected.
|
|
905
|
-
isShadowRoot(node) && node.host ||
|
|
906
|
-
// Fallback.
|
|
907
|
-
getDocumentElement(node);
|
|
908
|
-
return isShadowRoot(result) ? result.host : result;
|
|
909
|
-
}
|
|
910
|
-
function getNearestOverflowAncestor(node) {
|
|
911
|
-
const parentNode = getParentNode(node);
|
|
912
|
-
if (isLastTraversableNode(parentNode)) {
|
|
913
|
-
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
914
|
-
}
|
|
915
|
-
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
916
|
-
return parentNode;
|
|
917
|
-
}
|
|
918
|
-
return getNearestOverflowAncestor(parentNode);
|
|
919
|
-
}
|
|
920
|
-
function getOverflowAncestors(node, list, traverseIframes) {
|
|
921
|
-
var _node$ownerDocument2;
|
|
922
|
-
if (list === void 0) {
|
|
923
|
-
list = [];
|
|
924
|
-
}
|
|
925
|
-
if (traverseIframes === void 0) {
|
|
926
|
-
traverseIframes = true;
|
|
927
|
-
}
|
|
928
|
-
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
929
|
-
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
930
|
-
const win = getWindow$1(scrollableAncestor);
|
|
931
|
-
if (isBody) {
|
|
932
|
-
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
|
|
933
|
-
}
|
|
934
|
-
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
function getCssDimensions(element) {
|
|
938
|
-
const css = getComputedStyle(element);
|
|
939
|
-
// In testing environments, the `width` and `height` properties are empty
|
|
940
|
-
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
|
941
|
-
let width = parseFloat(css.width) || 0;
|
|
942
|
-
let height = parseFloat(css.height) || 0;
|
|
943
|
-
const hasOffset = isHTMLElement(element);
|
|
944
|
-
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
945
|
-
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
946
|
-
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
947
|
-
if (shouldFallback) {
|
|
948
|
-
width = offsetWidth;
|
|
949
|
-
height = offsetHeight;
|
|
950
|
-
}
|
|
951
|
-
return {
|
|
952
|
-
width,
|
|
953
|
-
height,
|
|
954
|
-
$: shouldFallback
|
|
955
|
-
};
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
function unwrapElement(element) {
|
|
959
|
-
return !isElement(element) ? element.contextElement : element;
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
function getScale(element) {
|
|
963
|
-
const domElement = unwrapElement(element);
|
|
964
|
-
if (!isHTMLElement(domElement)) {
|
|
965
|
-
return createCoords(1);
|
|
966
|
-
}
|
|
967
|
-
const rect = domElement.getBoundingClientRect();
|
|
968
|
-
const {
|
|
969
|
-
width,
|
|
970
|
-
height,
|
|
971
|
-
$
|
|
972
|
-
} = getCssDimensions(domElement);
|
|
973
|
-
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
974
|
-
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
975
|
-
|
|
976
|
-
// 0, NaN, or Infinity should always fallback to 1.
|
|
977
|
-
|
|
978
|
-
if (!x || !Number.isFinite(x)) {
|
|
979
|
-
x = 1;
|
|
980
|
-
}
|
|
981
|
-
if (!y || !Number.isFinite(y)) {
|
|
982
|
-
y = 1;
|
|
983
|
-
}
|
|
984
|
-
return {
|
|
985
|
-
x,
|
|
986
|
-
y
|
|
987
|
-
};
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
const noOffsets = /*#__PURE__*/createCoords(0);
|
|
991
|
-
function getVisualOffsets(element) {
|
|
992
|
-
const win = getWindow$1(element);
|
|
993
|
-
if (!isWebKit() || !win.visualViewport) {
|
|
994
|
-
return noOffsets;
|
|
995
|
-
}
|
|
996
|
-
return {
|
|
997
|
-
x: win.visualViewport.offsetLeft,
|
|
998
|
-
y: win.visualViewport.offsetTop
|
|
999
|
-
};
|
|
1000
|
-
}
|
|
1001
|
-
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
1002
|
-
if (isFixed === void 0) {
|
|
1003
|
-
isFixed = false;
|
|
1004
|
-
}
|
|
1005
|
-
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow$1(element)) {
|
|
1006
|
-
return false;
|
|
1007
|
-
}
|
|
1008
|
-
return isFixed;
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
1012
|
-
if (includeScale === void 0) {
|
|
1013
|
-
includeScale = false;
|
|
1014
|
-
}
|
|
1015
|
-
if (isFixedStrategy === void 0) {
|
|
1016
|
-
isFixedStrategy = false;
|
|
1017
|
-
}
|
|
1018
|
-
const clientRect = element.getBoundingClientRect();
|
|
1019
|
-
const domElement = unwrapElement(element);
|
|
1020
|
-
let scale = createCoords(1);
|
|
1021
|
-
if (includeScale) {
|
|
1022
|
-
if (offsetParent) {
|
|
1023
|
-
if (isElement(offsetParent)) {
|
|
1024
|
-
scale = getScale(offsetParent);
|
|
1025
|
-
}
|
|
1026
|
-
} else {
|
|
1027
|
-
scale = getScale(element);
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
1031
|
-
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
1032
|
-
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
1033
|
-
let width = clientRect.width / scale.x;
|
|
1034
|
-
let height = clientRect.height / scale.y;
|
|
1035
|
-
if (domElement) {
|
|
1036
|
-
const win = getWindow$1(domElement);
|
|
1037
|
-
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow$1(offsetParent) : offsetParent;
|
|
1038
|
-
let currentIFrame = win.frameElement;
|
|
1039
|
-
while (currentIFrame && offsetParent && offsetWin !== win) {
|
|
1040
|
-
const iframeScale = getScale(currentIFrame);
|
|
1041
|
-
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
1042
|
-
const css = getComputedStyle(currentIFrame);
|
|
1043
|
-
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
1044
|
-
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
1045
|
-
x *= iframeScale.x;
|
|
1046
|
-
y *= iframeScale.y;
|
|
1047
|
-
width *= iframeScale.x;
|
|
1048
|
-
height *= iframeScale.y;
|
|
1049
|
-
x += left;
|
|
1050
|
-
y += top;
|
|
1051
|
-
currentIFrame = getWindow$1(currentIFrame).frameElement;
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
return rectToClientRect({
|
|
1055
|
-
width,
|
|
1056
|
-
height,
|
|
1057
|
-
x,
|
|
1058
|
-
y
|
|
1059
|
-
});
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
1063
|
-
let {
|
|
1064
|
-
rect,
|
|
1065
|
-
offsetParent,
|
|
1066
|
-
strategy
|
|
1067
|
-
} = _ref;
|
|
1068
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1069
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
1070
|
-
if (offsetParent === documentElement) {
|
|
1071
|
-
return rect;
|
|
1072
|
-
}
|
|
1073
|
-
let scroll = {
|
|
1074
|
-
scrollLeft: 0,
|
|
1075
|
-
scrollTop: 0
|
|
1076
|
-
};
|
|
1077
|
-
let scale = createCoords(1);
|
|
1078
|
-
const offsets = createCoords(0);
|
|
1079
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
1080
|
-
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1081
|
-
scroll = getNodeScroll(offsetParent);
|
|
1082
|
-
}
|
|
1083
|
-
if (isHTMLElement(offsetParent)) {
|
|
1084
|
-
const offsetRect = getBoundingClientRect(offsetParent);
|
|
1085
|
-
scale = getScale(offsetParent);
|
|
1086
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1087
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
return {
|
|
1091
|
-
width: rect.width * scale.x,
|
|
1092
|
-
height: rect.height * scale.y,
|
|
1093
|
-
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
|
|
1094
|
-
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
|
|
1095
|
-
};
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
function getClientRects(element) {
|
|
1099
|
-
return Array.from(element.getClientRects());
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
function getWindowScrollBarX(element) {
|
|
1103
|
-
// If <html> has a CSS width greater than the viewport, then this will be
|
|
1104
|
-
// incorrect for RTL.
|
|
1105
|
-
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
// Gets the entire size of the scrollable document area, even extending outside
|
|
1109
|
-
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
|
1110
|
-
function getDocumentRect(element) {
|
|
1111
|
-
const html = getDocumentElement(element);
|
|
1112
|
-
const scroll = getNodeScroll(element);
|
|
1113
|
-
const body = element.ownerDocument.body;
|
|
1114
|
-
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
1115
|
-
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
1116
|
-
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
1117
|
-
const y = -scroll.scrollTop;
|
|
1118
|
-
if (getComputedStyle(body).direction === 'rtl') {
|
|
1119
|
-
x += max(html.clientWidth, body.clientWidth) - width;
|
|
1120
|
-
}
|
|
1121
|
-
return {
|
|
1122
|
-
width,
|
|
1123
|
-
height,
|
|
1124
|
-
x,
|
|
1125
|
-
y
|
|
1126
|
-
};
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
function getViewportRect(element, strategy) {
|
|
1130
|
-
const win = getWindow$1(element);
|
|
1131
|
-
const html = getDocumentElement(element);
|
|
1132
|
-
const visualViewport = win.visualViewport;
|
|
1133
|
-
let width = html.clientWidth;
|
|
1134
|
-
let height = html.clientHeight;
|
|
1135
|
-
let x = 0;
|
|
1136
|
-
let y = 0;
|
|
1137
|
-
if (visualViewport) {
|
|
1138
|
-
width = visualViewport.width;
|
|
1139
|
-
height = visualViewport.height;
|
|
1140
|
-
const visualViewportBased = isWebKit();
|
|
1141
|
-
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
|
1142
|
-
x = visualViewport.offsetLeft;
|
|
1143
|
-
y = visualViewport.offsetTop;
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
return {
|
|
1147
|
-
width,
|
|
1148
|
-
height,
|
|
1149
|
-
x,
|
|
1150
|
-
y
|
|
1151
|
-
};
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
// Returns the inner client rect, subtracting scrollbars if present.
|
|
1155
|
-
function getInnerBoundingClientRect(element, strategy) {
|
|
1156
|
-
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
|
1157
|
-
const top = clientRect.top + element.clientTop;
|
|
1158
|
-
const left = clientRect.left + element.clientLeft;
|
|
1159
|
-
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
1160
|
-
const width = element.clientWidth * scale.x;
|
|
1161
|
-
const height = element.clientHeight * scale.y;
|
|
1162
|
-
const x = left * scale.x;
|
|
1163
|
-
const y = top * scale.y;
|
|
1164
|
-
return {
|
|
1165
|
-
width,
|
|
1166
|
-
height,
|
|
1167
|
-
x,
|
|
1168
|
-
y
|
|
1169
|
-
};
|
|
1170
|
-
}
|
|
1171
|
-
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
1172
|
-
let rect;
|
|
1173
|
-
if (clippingAncestor === 'viewport') {
|
|
1174
|
-
rect = getViewportRect(element, strategy);
|
|
1175
|
-
} else if (clippingAncestor === 'document') {
|
|
1176
|
-
rect = getDocumentRect(getDocumentElement(element));
|
|
1177
|
-
} else if (isElement(clippingAncestor)) {
|
|
1178
|
-
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
1179
|
-
} else {
|
|
1180
|
-
const visualOffsets = getVisualOffsets(element);
|
|
1181
|
-
rect = {
|
|
1182
|
-
...clippingAncestor,
|
|
1183
|
-
x: clippingAncestor.x - visualOffsets.x,
|
|
1184
|
-
y: clippingAncestor.y - visualOffsets.y
|
|
1185
|
-
};
|
|
1186
|
-
}
|
|
1187
|
-
return rectToClientRect(rect);
|
|
1188
|
-
}
|
|
1189
|
-
function hasFixedPositionAncestor(element, stopNode) {
|
|
1190
|
-
const parentNode = getParentNode(element);
|
|
1191
|
-
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
1192
|
-
return false;
|
|
1193
|
-
}
|
|
1194
|
-
return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1197
|
-
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
|
1198
|
-
// clipping (or hiding) child elements. This returns all clipping ancestors
|
|
1199
|
-
// of the given element up the tree.
|
|
1200
|
-
function getClippingElementAncestors(element, cache) {
|
|
1201
|
-
const cachedResult = cache.get(element);
|
|
1202
|
-
if (cachedResult) {
|
|
1203
|
-
return cachedResult;
|
|
1204
|
-
}
|
|
1205
|
-
let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
|
1206
|
-
let currentContainingBlockComputedStyle = null;
|
|
1207
|
-
const elementIsFixed = getComputedStyle(element).position === 'fixed';
|
|
1208
|
-
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
1209
|
-
|
|
1210
|
-
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1211
|
-
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1212
|
-
const computedStyle = getComputedStyle(currentNode);
|
|
1213
|
-
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
1214
|
-
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
|
1215
|
-
currentContainingBlockComputedStyle = null;
|
|
1216
|
-
}
|
|
1217
|
-
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
1218
|
-
if (shouldDropCurrentNode) {
|
|
1219
|
-
// Drop non-containing blocks.
|
|
1220
|
-
result = result.filter(ancestor => ancestor !== currentNode);
|
|
1221
|
-
} else {
|
|
1222
|
-
// Record last containing block for next iteration.
|
|
1223
|
-
currentContainingBlockComputedStyle = computedStyle;
|
|
1224
|
-
}
|
|
1225
|
-
currentNode = getParentNode(currentNode);
|
|
1226
|
-
}
|
|
1227
|
-
cache.set(element, result);
|
|
1228
|
-
return result;
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
// Gets the maximum area that the element is visible in due to any number of
|
|
1232
|
-
// clipping ancestors.
|
|
1233
|
-
function getClippingRect(_ref) {
|
|
1234
|
-
let {
|
|
1235
|
-
element,
|
|
1236
|
-
boundary,
|
|
1237
|
-
rootBoundary,
|
|
1238
|
-
strategy
|
|
1239
|
-
} = _ref;
|
|
1240
|
-
const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
1241
|
-
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
1242
|
-
const firstClippingAncestor = clippingAncestors[0];
|
|
1243
|
-
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
1244
|
-
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
1245
|
-
accRect.top = max(rect.top, accRect.top);
|
|
1246
|
-
accRect.right = min(rect.right, accRect.right);
|
|
1247
|
-
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
1248
|
-
accRect.left = max(rect.left, accRect.left);
|
|
1249
|
-
return accRect;
|
|
1250
|
-
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
1251
|
-
return {
|
|
1252
|
-
width: clippingRect.right - clippingRect.left,
|
|
1253
|
-
height: clippingRect.bottom - clippingRect.top,
|
|
1254
|
-
x: clippingRect.left,
|
|
1255
|
-
y: clippingRect.top
|
|
1256
|
-
};
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
function getDimensions(element) {
|
|
1260
|
-
return getCssDimensions(element);
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
|
-
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1264
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1265
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
1266
|
-
const isFixed = strategy === 'fixed';
|
|
1267
|
-
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
1268
|
-
let scroll = {
|
|
1269
|
-
scrollLeft: 0,
|
|
1270
|
-
scrollTop: 0
|
|
1271
|
-
};
|
|
1272
|
-
const offsets = createCoords(0);
|
|
1273
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1274
|
-
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1275
|
-
scroll = getNodeScroll(offsetParent);
|
|
1276
|
-
}
|
|
1277
|
-
if (isOffsetParentAnElement) {
|
|
1278
|
-
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
1279
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1280
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1281
|
-
} else if (documentElement) {
|
|
1282
|
-
offsets.x = getWindowScrollBarX(documentElement);
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
return {
|
|
1286
|
-
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
1287
|
-
y: rect.top + scroll.scrollTop - offsets.y,
|
|
1288
|
-
width: rect.width,
|
|
1289
|
-
height: rect.height
|
|
1290
|
-
};
|
|
1291
|
-
}
|
|
1292
|
-
|
|
1293
|
-
function getTrueOffsetParent(element, polyfill) {
|
|
1294
|
-
if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
|
|
1295
|
-
return null;
|
|
1296
|
-
}
|
|
1297
|
-
if (polyfill) {
|
|
1298
|
-
return polyfill(element);
|
|
1299
|
-
}
|
|
1300
|
-
return element.offsetParent;
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
// Gets the closest ancestor positioned element. Handles some edge cases,
|
|
1304
|
-
// such as table ancestors and cross browser bugs.
|
|
1305
|
-
function getOffsetParent(element, polyfill) {
|
|
1306
|
-
const window = getWindow$1(element);
|
|
1307
|
-
if (!isHTMLElement(element)) {
|
|
1308
|
-
return window;
|
|
1309
|
-
}
|
|
1310
|
-
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1311
|
-
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
|
|
1312
|
-
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
1313
|
-
}
|
|
1314
|
-
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
|
|
1315
|
-
return window;
|
|
1316
|
-
}
|
|
1317
|
-
return offsetParent || getContainingBlock(element) || window;
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
const getElementRects = async function (_ref) {
|
|
1321
|
-
let {
|
|
1322
|
-
reference,
|
|
1323
|
-
floating,
|
|
1324
|
-
strategy
|
|
1325
|
-
} = _ref;
|
|
1326
|
-
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1327
|
-
const getDimensionsFn = this.getDimensions;
|
|
1328
|
-
return {
|
|
1329
|
-
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
1330
|
-
floating: {
|
|
1331
|
-
x: 0,
|
|
1332
|
-
y: 0,
|
|
1333
|
-
...(await getDimensionsFn(floating))
|
|
1334
|
-
}
|
|
1335
|
-
};
|
|
1336
|
-
};
|
|
1337
|
-
|
|
1338
|
-
function isRTL(element) {
|
|
1339
|
-
return getComputedStyle(element).direction === 'rtl';
|
|
1340
|
-
}
|
|
1341
|
-
|
|
1342
|
-
const platform$2 = {
|
|
1343
|
-
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1344
|
-
getDocumentElement,
|
|
1345
|
-
getClippingRect,
|
|
1346
|
-
getOffsetParent,
|
|
1347
|
-
getElementRects,
|
|
1348
|
-
getClientRects,
|
|
1349
|
-
getDimensions,
|
|
1350
|
-
getScale,
|
|
1351
|
-
isElement,
|
|
1352
|
-
isRTL
|
|
1353
|
-
};
|
|
1354
|
-
|
|
1355
|
-
// https://samthor.au/2021/observing-dom/
|
|
1356
|
-
function observeMove(element, onMove) {
|
|
1357
|
-
let io = null;
|
|
1358
|
-
let timeoutId;
|
|
1359
|
-
const root = getDocumentElement(element);
|
|
1360
|
-
function cleanup() {
|
|
1361
|
-
clearTimeout(timeoutId);
|
|
1362
|
-
io && io.disconnect();
|
|
1363
|
-
io = null;
|
|
1364
|
-
}
|
|
1365
|
-
function refresh(skip, threshold) {
|
|
1366
|
-
if (skip === void 0) {
|
|
1367
|
-
skip = false;
|
|
1368
|
-
}
|
|
1369
|
-
if (threshold === void 0) {
|
|
1370
|
-
threshold = 1;
|
|
1371
|
-
}
|
|
1372
|
-
cleanup();
|
|
1373
|
-
const {
|
|
1374
|
-
left,
|
|
1375
|
-
top,
|
|
1376
|
-
width,
|
|
1377
|
-
height
|
|
1378
|
-
} = element.getBoundingClientRect();
|
|
1379
|
-
if (!skip) {
|
|
1380
|
-
onMove();
|
|
1381
|
-
}
|
|
1382
|
-
if (!width || !height) {
|
|
1383
|
-
return;
|
|
1384
|
-
}
|
|
1385
|
-
const insetTop = floor(top);
|
|
1386
|
-
const insetRight = floor(root.clientWidth - (left + width));
|
|
1387
|
-
const insetBottom = floor(root.clientHeight - (top + height));
|
|
1388
|
-
const insetLeft = floor(left);
|
|
1389
|
-
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
1390
|
-
const options = {
|
|
1391
|
-
rootMargin,
|
|
1392
|
-
threshold: max(0, min(1, threshold)) || 1
|
|
1393
|
-
};
|
|
1394
|
-
let isFirstUpdate = true;
|
|
1395
|
-
function handleObserve(entries) {
|
|
1396
|
-
const ratio = entries[0].intersectionRatio;
|
|
1397
|
-
if (ratio !== threshold) {
|
|
1398
|
-
if (!isFirstUpdate) {
|
|
1399
|
-
return refresh();
|
|
1400
|
-
}
|
|
1401
|
-
if (!ratio) {
|
|
1402
|
-
timeoutId = setTimeout(() => {
|
|
1403
|
-
refresh(false, 1e-7);
|
|
1404
|
-
}, 100);
|
|
1405
|
-
} else {
|
|
1406
|
-
refresh(false, ratio);
|
|
1407
|
-
}
|
|
1408
|
-
}
|
|
1409
|
-
isFirstUpdate = false;
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
|
-
// Older browsers don't support a `document` as the root and will throw an
|
|
1413
|
-
// error.
|
|
1414
|
-
try {
|
|
1415
|
-
io = new IntersectionObserver(handleObserve, {
|
|
1416
|
-
...options,
|
|
1417
|
-
// Handle <iframe>s
|
|
1418
|
-
root: root.ownerDocument
|
|
1419
|
-
});
|
|
1420
|
-
} catch (e) {
|
|
1421
|
-
io = new IntersectionObserver(handleObserve, options);
|
|
1422
|
-
}
|
|
1423
|
-
io.observe(element);
|
|
1424
|
-
}
|
|
1425
|
-
refresh(true);
|
|
1426
|
-
return cleanup;
|
|
1427
|
-
}
|
|
1428
|
-
|
|
1429
|
-
/**
|
|
1430
|
-
* Automatically updates the position of the floating element when necessary.
|
|
1431
|
-
* Should only be called when the floating element is mounted on the DOM or
|
|
1432
|
-
* visible on the screen.
|
|
1433
|
-
* @returns cleanup function that should be invoked when the floating element is
|
|
1434
|
-
* removed from the DOM or hidden from the screen.
|
|
1435
|
-
* @see https://floating-ui.com/docs/autoUpdate
|
|
1436
|
-
*/
|
|
1437
|
-
function autoUpdate(reference, floating, update, options) {
|
|
1438
|
-
if (options === void 0) {
|
|
1439
|
-
options = {};
|
|
1440
|
-
}
|
|
1441
|
-
const {
|
|
1442
|
-
ancestorScroll = true,
|
|
1443
|
-
ancestorResize = true,
|
|
1444
|
-
elementResize = typeof ResizeObserver === 'function',
|
|
1445
|
-
layoutShift = typeof IntersectionObserver === 'function',
|
|
1446
|
-
animationFrame = false
|
|
1447
|
-
} = options;
|
|
1448
|
-
const referenceEl = unwrapElement(reference);
|
|
1449
|
-
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
|
|
1450
|
-
ancestors.forEach(ancestor => {
|
|
1451
|
-
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
1452
|
-
passive: true
|
|
1453
|
-
});
|
|
1454
|
-
ancestorResize && ancestor.addEventListener('resize', update);
|
|
1455
|
-
});
|
|
1456
|
-
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
1457
|
-
let reobserveFrame = -1;
|
|
1458
|
-
let resizeObserver = null;
|
|
1459
|
-
if (elementResize) {
|
|
1460
|
-
resizeObserver = new ResizeObserver(_ref => {
|
|
1461
|
-
let [firstEntry] = _ref;
|
|
1462
|
-
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
|
1463
|
-
// Prevent update loops when using the `size` middleware.
|
|
1464
|
-
// https://github.com/floating-ui/floating-ui/issues/1740
|
|
1465
|
-
resizeObserver.unobserve(floating);
|
|
1466
|
-
cancelAnimationFrame(reobserveFrame);
|
|
1467
|
-
reobserveFrame = requestAnimationFrame(() => {
|
|
1468
|
-
resizeObserver && resizeObserver.observe(floating);
|
|
1469
|
-
});
|
|
1470
|
-
}
|
|
1471
|
-
update();
|
|
1472
|
-
});
|
|
1473
|
-
if (referenceEl && !animationFrame) {
|
|
1474
|
-
resizeObserver.observe(referenceEl);
|
|
1475
|
-
}
|
|
1476
|
-
resizeObserver.observe(floating);
|
|
1477
|
-
}
|
|
1478
|
-
let frameId;
|
|
1479
|
-
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
1480
|
-
if (animationFrame) {
|
|
1481
|
-
frameLoop();
|
|
1482
|
-
}
|
|
1483
|
-
function frameLoop() {
|
|
1484
|
-
const nextRefRect = getBoundingClientRect(reference);
|
|
1485
|
-
if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
|
|
1486
|
-
update();
|
|
1487
|
-
}
|
|
1488
|
-
prevRefRect = nextRefRect;
|
|
1489
|
-
frameId = requestAnimationFrame(frameLoop);
|
|
1490
|
-
}
|
|
1491
|
-
update();
|
|
1492
|
-
return () => {
|
|
1493
|
-
ancestors.forEach(ancestor => {
|
|
1494
|
-
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
1495
|
-
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
1496
|
-
});
|
|
1497
|
-
cleanupIo && cleanupIo();
|
|
1498
|
-
resizeObserver && resizeObserver.disconnect();
|
|
1499
|
-
resizeObserver = null;
|
|
1500
|
-
if (animationFrame) {
|
|
1501
|
-
cancelAnimationFrame(frameId);
|
|
1502
|
-
}
|
|
1503
|
-
};
|
|
1504
|
-
}
|
|
1505
|
-
|
|
1506
|
-
/**
|
|
1507
|
-
* Computes the `x` and `y` coordinates that will place the floating element
|
|
1508
|
-
* next to a reference element when it is given a certain CSS positioning
|
|
1509
|
-
* strategy.
|
|
1510
|
-
*/
|
|
1511
|
-
const computePosition = (reference, floating, options) => {
|
|
1512
|
-
// This caches the expensive `getClippingElementAncestors` function so that
|
|
1513
|
-
// multiple lifecycle resets re-use the same result. It only lives for a
|
|
1514
|
-
// single call. If other functions become expensive, we can add them as well.
|
|
1515
|
-
const cache = new Map();
|
|
1516
|
-
const mergedOptions = {
|
|
1517
|
-
platform: platform$2,
|
|
1518
|
-
...options
|
|
1519
|
-
};
|
|
1520
|
-
const platformWithCache = {
|
|
1521
|
-
...mergedOptions.platform,
|
|
1522
|
-
_c: cache
|
|
1523
|
-
};
|
|
1524
|
-
return computePosition$1(reference, floating, {
|
|
1525
|
-
...mergedOptions,
|
|
1526
|
-
platform: platformWithCache
|
|
1527
|
-
});
|
|
1528
|
-
};
|
|
3
|
+
import { d as defineCustomElement$1 } from './post-popovercontainer2.js';
|
|
1529
4
|
|
|
1530
5
|
// input may be undefined, selector-tring, Node, NodeList, HTMLCollection, array of Nodes
|
|
1531
6
|
// yes, to some extent this is a bad replica of jQuery's constructor function
|
|
@@ -4659,64 +3134,6 @@ isFocusableRules.except = function () {
|
|
|
4659
3134
|
// provide isFocusRelevant(context) as default iterator callback
|
|
4660
3135
|
var isFocusable = isFocusableRules.except({});
|
|
4661
3136
|
|
|
4662
|
-
(()=>{var c=class extends Event{oldState;newState;constructor(t,{oldState:o="",newState:r="",...i}={}){super(t,i),this.oldState=String(o||""),this.newState=String(r||"");}},R=new WeakMap;function A(e,t,o){R.set(e,setTimeout(()=>{R.has(e)&&e.dispatchEvent(new c("toggle",{cancelable:!1,oldState:t,newState:o}));},0));}var x=globalThis.ShadowRoot||function(){},z=globalThis.HTMLDialogElement||function(){},M=new WeakMap,p=new WeakMap,h=new WeakMap;function L(e){return h.get(e)||"hidden"}var b=new WeakMap;function O(e){let t=e.popoverTargetElement;if(!(t instanceof HTMLElement))return;let o=L(t);e.popoverTargetAction==="show"&&o==="showing"||e.popoverTargetAction==="hide"&&o==="hidden"||(o==="showing"?m(t,!0,!0):d(t,!1)&&(b.set(t,e),S(t)));}function d(e,t){return !(e.popover!=="auto"&&e.popover!=="manual"||!e.isConnected||t&&L(e)!=="showing"||!t&&L(e)!=="hidden"||e instanceof z&&e.hasAttribute("open")||document.fullscreenElement===e)}function N(e){return e?Array.from(p.get(e.ownerDocument)||[]).indexOf(e)+1:0}function V(e){let t=W(e),o=U(e);return N(t)>N(o)?t:o}function y(e){let t=p.get(e);for(let o of t||[])if(!o.isConnected)t.delete(o);else return o;return null}function v(e){return typeof e.getRootNode=="function"?e.getRootNode():e.parentNode?v(e.parentNode):e}function W(e){for(;e;){if(e instanceof HTMLElement&&e.popover==="auto"&&h.get(e)==="showing")return e;if(e=e.parentElement||v(e),e instanceof x&&(e=e.host),e instanceof Document)return}}function U(e){for(;e;){let t=e.popoverTargetElement;if(t instanceof HTMLElement)return t;if(e=e.parentElement||v(e),e instanceof x&&(e=e.host),e instanceof Document)return}}function G(e){let t=new Map,o=0,r=e.ownerDocument;for(let a of p.get(r)||[])t.set(a,o),o+=1;t.set(e,o),o+=1;let i=null;function l(a){let g=W(a);if(g===null)return null;let n=t.get(g);(i===null||t.get(i)<n)&&(i=g);}return l(e?.parentElement),i}function Q(e){return e.hidden||e instanceof x||(e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLOptGroupElement||e instanceof HTMLOptionElement||e instanceof HTMLFieldSetElement)&&e.disabled||e instanceof HTMLInputElement&&e.type==="hidden"||e instanceof HTMLAnchorElement&&e.href===""?!1:typeof e.tabIndex=="number"&&e.tabIndex!==-1}function _(e){if(e.shadowRoot&&e.shadowRoot.delegatesFocus!==!0)return null;let t=e;t.shadowRoot&&(t=t.shadowRoot);let o=t.querySelector("[autofocus]");if(o)return o;{let l=t.querySelectorAll("slot");for(let a of l){let g=a.assignedElements({flatten:!0});for(let n of g){if(n.hasAttribute("autofocus"))return n;if(o=n.querySelector("[autofocus]"),o)return o}}}let r=e.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_ELEMENT),i=r.currentNode;for(;i;){if(Q(i))return i;i=r.nextNode();}}function $(e){_(e)?.focus();}var H=new WeakMap;function S(e){if(!d(e,!1))return;let t=e.ownerDocument;if(!e.dispatchEvent(new c("beforetoggle",{cancelable:!0,oldState:"closed",newState:"open"}))||!d(e,!1))return;let o=!1;if(e.popover==="auto"){let i=e.getAttribute("popover"),l=G(e)||t;if(T(l,!1,!0),i!==e.getAttribute("popover")||!d(e,!1))return}y(t)||(o=!0),H.delete(e);let r=t.activeElement;e.classList.add(":popover-open"),h.set(e,"showing"),M.has(t)||M.set(t,new Set),M.get(t).add(e),$(e),e.popover==="auto"&&(p.has(t)||p.set(t,new Set),p.get(t).add(e),q(b.get(e),!0)),o&&r&&e.popover==="auto"&&H.set(e,r),A(e,"closed","open");}function m(e,t=!1,o=!1){if(!d(e,!0))return;let r=e.ownerDocument;if(e.popover==="auto"&&(T(e,t,o),!d(e,!0))||(q(b.get(e),!1),b.delete(e),o&&(e.dispatchEvent(new c("beforetoggle",{oldState:"open",newState:"closed"})),!d(e,!0))))return;M.get(r)?.delete(e),p.get(r)?.delete(e),e.classList.remove(":popover-open"),h.set(e,"hidden"),o&&A(e,"open","closed");let i=H.get(e);i&&(H.delete(e),t&&i.focus());}function F(e,t=!1,o=!1){let r=y(e);for(;r;)m(r,t,o),r=y(e);}function T(e,t,o){let r=e.ownerDocument||e;if(e instanceof Document)return F(r,t,o);let i=null,l=!1;for(let a of p.get(r)||[])if(a===e)l=!0;else if(l){i=a;break}if(!l)return F(r,t,o);for(;i&&L(i)==="showing"&&p.get(r)?.size;)m(i,t,o);}var P=new WeakMap;function D(e){if(!e.isTrusted)return;let t=e.composedPath()[0];if(!t)return;let o=t.ownerDocument;if(!y(o))return;let i=V(t);if(i&&e.type==="pointerdown")P.set(o,i);else if(e.type==="pointerup"){let l=P.get(o)===i;P.delete(o),l&&T(i||o,!1,!0);}}var k=new WeakMap;function q(e,t=!1){if(!e)return;k.has(e)||k.set(e,e.getAttribute("aria-expanded"));let o=e.popoverTargetElement;if(o instanceof HTMLElement&&o.popover==="auto")e.setAttribute("aria-expanded",String(t));else {let r=k.get(e);r?e.setAttribute("aria-expanded",r):e.removeAttribute("aria-expanded");}}var B=globalThis.ShadowRoot||function(){};function j(){return typeof HTMLElement<"u"&&typeof HTMLElement.prototype=="object"&&"popover"in HTMLElement.prototype}function f(e,t,o){let r=e[t];Object.defineProperty(e,t,{value(i){return r.call(this,o(i))}});}var J=/(^|[^\\]):popover-open\b/g,C=`
|
|
4663
|
-
:where([popover]) {
|
|
4664
|
-
position: fixed;
|
|
4665
|
-
z-index: 2147483647;
|
|
4666
|
-
inset: 0;
|
|
4667
|
-
padding: 0.25em;
|
|
4668
|
-
width: fit-content;
|
|
4669
|
-
height: fit-content;
|
|
4670
|
-
border-width: initial;
|
|
4671
|
-
border-color: initial;
|
|
4672
|
-
border-image: initial;
|
|
4673
|
-
border-style: solid;
|
|
4674
|
-
background-color: canvas;
|
|
4675
|
-
color: canvastext;
|
|
4676
|
-
overflow: auto;
|
|
4677
|
-
margin: auto;
|
|
4678
|
-
}
|
|
4679
|
-
|
|
4680
|
-
:where(dialog[popover][open]) {
|
|
4681
|
-
display: revert;
|
|
4682
|
-
}
|
|
4683
|
-
|
|
4684
|
-
:where([anchor].\\:popover-open) {
|
|
4685
|
-
inset: auto;
|
|
4686
|
-
}
|
|
4687
|
-
|
|
4688
|
-
:where([anchor]:popover-open) {
|
|
4689
|
-
inset: auto;
|
|
4690
|
-
}
|
|
4691
|
-
|
|
4692
|
-
@supports not (background-color: canvas) {
|
|
4693
|
-
:where([popover]) {
|
|
4694
|
-
background-color: white;
|
|
4695
|
-
color: black;
|
|
4696
|
-
}
|
|
4697
|
-
}
|
|
4698
|
-
|
|
4699
|
-
@supports (width: -moz-fit-content) {
|
|
4700
|
-
:where([popover]) {
|
|
4701
|
-
width: -moz-fit-content;
|
|
4702
|
-
height: -moz-fit-content;
|
|
4703
|
-
}
|
|
4704
|
-
}
|
|
4705
|
-
|
|
4706
|
-
@supports not (inset: 0) {
|
|
4707
|
-
:where([popover]) {
|
|
4708
|
-
top: 0;
|
|
4709
|
-
left: 0;
|
|
4710
|
-
right: 0;
|
|
4711
|
-
bottom: 0;
|
|
4712
|
-
}
|
|
4713
|
-
}
|
|
4714
|
-
|
|
4715
|
-
:where([popover]:not(.\\:popover-open)) {
|
|
4716
|
-
display: none;
|
|
4717
|
-
}
|
|
4718
|
-
`,E=null;function I(e){if(E===null)try{E=new CSSStyleSheet,E.replaceSync(C);}catch{E=!1;}if(E===!1){let t=document.createElement("style");t.textContent=C,e instanceof Document?e.head.prepend(t):e.prepend(t);}else e.adoptedStyleSheets=[E,...e.adoptedStyleSheets];}function K(){window.ToggleEvent=window.ToggleEvent||c;function e(n){return n?.includes(":popover-open")&&(n=n.replace(J,"$1.\\:popover-open")),n}f(Document.prototype,"querySelector",e),f(Document.prototype,"querySelectorAll",e),f(Element.prototype,"querySelector",e),f(Element.prototype,"querySelectorAll",e),f(Element.prototype,"matches",e),f(Element.prototype,"closest",e),f(DocumentFragment.prototype,"querySelectorAll",e),f(DocumentFragment.prototype,"querySelectorAll",e),Object.defineProperties(HTMLElement.prototype,{popover:{enumerable:!0,configurable:!0,get(){if(!this.hasAttribute("popover"))return null;let n=(this.getAttribute("popover")||"").toLowerCase();return n===""||n=="auto"?"auto":"manual"},set(n){this.setAttribute("popover",n);}},showPopover:{enumerable:!0,configurable:!0,value(){S(this);}},hidePopover:{enumerable:!0,configurable:!0,value(){m(this,!0,!0);}},togglePopover:{enumerable:!0,configurable:!0,value(n){h.get(this)==="showing"&&n===void 0||n===!1?m(this,!0,!0):(n===void 0||n===!0)&&S(this);}}});let t=Element.prototype.attachShadow;t&&Object.defineProperties(Element.prototype,{attachShadow:{enumerable:!0,configurable:!0,writable:!0,value(n){let s=t.call(this,n);return I(s),s}}});let o=HTMLElement.prototype.attachInternals;o&&Object.defineProperties(HTMLElement.prototype,{attachInternals:{enumerable:!0,configurable:!0,writable:!0,value(){let n=o.call(this);return n.shadowRoot&&I(n.shadowRoot),n}}});let r=new WeakMap;function i(n){Object.defineProperties(n.prototype,{popoverTargetElement:{enumerable:!0,configurable:!0,set(s){if(s===null)this.removeAttribute("popovertarget"),r.delete(this);else if(s instanceof Element)this.setAttribute("popovertarget",""),r.set(this,s);else throw new TypeError("popoverTargetElement must be an element or null")},get(){if(this.localName!=="button"&&this.localName!=="input"||this.localName==="input"&&this.type!=="reset"&&this.type!=="image"&&this.type!=="button"||this.disabled||this.form&&this.type==="submit")return null;let s=r.get(this);if(s&&s.isConnected)return s;if(s&&!s.isConnected)return r.delete(this),null;let u=v(this),w=this.getAttribute("popovertarget");return (u instanceof Document||u instanceof B)&&w&&u.getElementById(w)||null}},popoverTargetAction:{enumerable:!0,configurable:!0,get(){let s=(this.getAttribute("popovertargetaction")||"").toLowerCase();return s==="show"||s==="hide"?s:"toggle"},set(s){this.setAttribute("popovertargetaction",s);}}});}i(HTMLButtonElement),i(HTMLInputElement);let l=n=>{if(!n.isTrusted)return;let s=n.composedPath()[0];if(!(s instanceof Element)||s?.shadowRoot)return;let u=v(s);if(!(u instanceof B||u instanceof Document))return;let w=s.closest("[popovertargetaction],[popovertarget]");if(w){O(w);return}},a=n=>{let s=n.key,u=n.target;!n.defaultPrevented&&u&&(s==="Escape"||s==="Esc")&&T(u.ownerDocument,!0,!0);};(n=>{n.addEventListener("click",l),n.addEventListener("keydown",a),n.addEventListener("pointerdown",D),n.addEventListener("pointerup",D);})(document),I(document);}j()||K();})();
|
|
4719
|
-
|
|
4720
3137
|
/*!
|
|
4721
3138
|
* long-press-event - v@version@
|
|
4722
3139
|
* Pure JavaScript long-press-event
|
|
@@ -4981,207 +3398,116 @@ var isFocusable = isFocusableRules.except({});
|
|
|
4981
3398
|
|
|
4982
3399
|
}(window, document));
|
|
4983
3400
|
|
|
4984
|
-
const
|
|
3401
|
+
const postTooltipCss = ":host{--post-contrast-color:#fff;--post-bg-rgb:51, 51, 51}post-popovercontainer::part(popover){padding:.25rem .5rem}";
|
|
4985
3402
|
|
|
4986
|
-
const postTooltipCss = ":host,.bg-yellow{--post-bg-opacity:1;background-color:rgba(var(--post-bg-rgb), var(--post-bg-opacity)) !important;color:var(--post-contrast-color) !important}.bg-yellow{--post-contrast-color:#000;--post-contrast-color-inverted:#fff;--post-gray-10:hsl(0, 0%, 90%);--post-gray-20:hsl(0, 0%, 80%);--post-gray-40:hsl(0, 0%, 60%);--post-gray-60:hsl(0, 0%, 40%);--post-gray-80:hsl(0, 0%, 20%);--post-yellow:#fc0;--post-light:#faf9f8;--post-gray:#f4f3f1;--post-dark:hsl(0, 0%, 20%);--post-primary:hsl(0, 0%, 20%);--post-white:#fff;--post-black:#000;--post-info:#cce4ee;--post-success:#2c911c;--post-warning:#f49e00;--post-danger:#a51728;--post-nightblue:#004976;--post-nightblue-bright:#0076a8;--post-petrol:#006d68;--post-petrol-bright:#00968f;--post-coral:#9e2a2f;--post-coral-bright:#e03c31;--post-olive:#716135;--post-olive-bright:#aa9d2e;--post-purple:#80276c;--post-purple-bright:#c5299b;--post-aubergine:#523178;--post-aubergine-bright:#7566a0;--post-success-green:#2c871d;--post-error-red:#a51728;--post-warning-orange:#f49e00;--post-success-background:#c0debb;--post-error-background:#ffdade;--post-warning-background:#fce2b2;--post-contrast-color-rgb:0, 0, 0;--post-contrast-color-inverted-rgb:255, 255, 255;--post-gray-10-rgb:230, 230, 230;--post-gray-20-rgb:204, 204, 204;--post-gray-40-rgb:153, 153, 153;--post-gray-60-rgb:102, 102, 102;--post-gray-80-rgb:51, 51, 51;--post-yellow-rgb:255, 204, 0;--post-light-rgb:250, 249, 248;--post-gray-rgb:244, 243, 241;--post-dark-rgb:51, 51, 51;--post-primary-rgb:51, 51, 51;--post-white-rgb:255, 255, 255;--post-black-rgb:0, 0, 0;--post-info-rgb:204, 228, 238;--post-success-rgb:44, 145, 28;--post-warning-rgb:244, 158, 0;--post-danger-rgb:165, 23, 40;--post-nightblue-rgb:0, 73, 118;--post-nightblue-bright-rgb:0, 118, 168;--post-petrol-rgb:0, 109, 104;--post-petrol-bright-rgb:0, 150, 143;--post-coral-rgb:158, 42, 47;--post-coral-bright-rgb:224, 60, 49;--post-olive-rgb:113, 97, 53;--post-olive-bright-rgb:170, 157, 46;--post-purple-rgb:128, 39, 108;--post-purple-bright-rgb:197, 41, 155;--post-aubergine-rgb:82, 49, 120;--post-aubergine-bright-rgb:117, 102, 160;--post-success-green-rgb:44, 135, 29;--post-error-red-rgb:165, 23, 40;--post-warning-orange-rgb:244, 158, 0;--post-success-background-rgb:192, 222, 187;--post-error-background-rgb:255, 218, 222;--post-warning-background-rgb:252, 226, 178}:host{--post-contrast-color:#fff;--post-contrast-color-inverted:#000;--post-dark:#faf9f8;--post-light:hsl(0, 0%, 20%);--post-gray-80:hsl(0, 0%, 90%);--post-gray-60:hsl(0, 0%, 80%);--post-gray-40:hsl(0, 0%, 60%);--post-gray-20:hsl(0, 0%, 40%);--post-gray-10:hsl(0, 0%, 20%);--post-contrast-color-rgb:255, 255, 255;--post-contrast-color-inverted-rgb:0, 0, 0;--post-dark-rgb:250, 249, 248;--post-light-rgb:51, 51, 51;--post-gray-80-rgb:230, 230, 230;--post-gray-60-rgb:204, 204, 204;--post-gray-40-rgb:153, 153, 153;--post-gray-20-rgb:102, 102, 102;--post-gray-10-rgb:51, 51, 51}:host{--post-bg-rgb:51, 51, 51}div{position:absolute;z-index:1070;width:max-content;max-width:30ch;margin:0;padding:.25rem .5rem;color:inherit;background-color:inherit;border-color:rgba(0,0,0,0);border-radius:4px;overflow:visible;pointer-events:none}.arrow{position:absolute;width:.7071067812rem;aspect-ratio:1/1;background-color:inherit;rotate:45deg;pointer-events:none;z-index:-1;border-right:2px solid rgba(0,0,0,0);border-bottom:2px solid rgba(0,0,0,0)}.bg-yellow{--post-bg-rgb:255, 204, 0}";
|
|
4987
|
-
|
|
4988
|
-
const SIDE_MAP = {
|
|
4989
|
-
top: 'bottom',
|
|
4990
|
-
right: 'left',
|
|
4991
|
-
bottom: 'top',
|
|
4992
|
-
left: 'right',
|
|
4993
|
-
};
|
|
4994
3403
|
const PostTooltip = /*@__PURE__*/ proxyCustomElement(class PostTooltip extends HTMLElement$1 {
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
3404
|
+
constructor() {
|
|
3405
|
+
super();
|
|
3406
|
+
this.__registerHost();
|
|
3407
|
+
this.__attachShadow();
|
|
3408
|
+
this.placement = 'top';
|
|
3409
|
+
// Create local versions of event handlers for de-registration
|
|
3410
|
+
// https://stackoverflow.com/questions/33859113/javascript-removeeventlistener-not-working-inside-a-class
|
|
3411
|
+
this.localShowTooltip = e => this.show(e.target);
|
|
3412
|
+
this.localHideTooltip = this.hide.bind(this);
|
|
3413
|
+
}
|
|
3414
|
+
connectedCallback() {
|
|
3415
|
+
if (!this.host.id) {
|
|
3416
|
+
throw new Error('No id set: <post-tooltip> must have an id, linking it to it\'s target element using the data-tooltip-target attribute.');
|
|
3417
|
+
}
|
|
3418
|
+
if (!this.triggers) {
|
|
3419
|
+
throw new Error(`No trigger found for <post-tooltip id="${this.host.id}">, please add the 'data-tooltip-target="${this.host.id}" attribute to the trigger element.`);
|
|
3420
|
+
}
|
|
3421
|
+
// Patch popovertargetaction="interest" until it's implemented
|
|
3422
|
+
// https://github.com/openui/open-ui/issues/767#issuecomment-1654177227
|
|
3423
|
+
this.triggers.forEach(trigger => this.patchPopoverTargetActionInterest(trigger));
|
|
5002
3424
|
}
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
this.localHideTooltip = this.hide.bind(this);
|
|
5015
|
-
this.localToggleTooltip = this.toggle.bind(this);
|
|
5016
|
-
}
|
|
5017
|
-
componentWillLoad() {
|
|
5018
|
-
this.validateBackgroundColor();
|
|
5019
|
-
// Append tooltip host to the end of the body to get around overflow: hidden restrictions
|
|
5020
|
-
// for browsers that don't support popover yet
|
|
5021
|
-
document.body.appendChild(this.host);
|
|
5022
|
-
}
|
|
5023
|
-
connectedCallback() {
|
|
5024
|
-
if (!this.host.id) {
|
|
5025
|
-
throw new Error('No id set: <post-tooltip> must have an id, linking it to it\'s target element using the data-tooltip-target attribute.');
|
|
3425
|
+
/**
|
|
3426
|
+
* Remove a bunch of event listeners if the tooltip gets removed from the DOM
|
|
3427
|
+
*/
|
|
3428
|
+
disconnectedCallback() {
|
|
3429
|
+
this.triggers.forEach(trigger => {
|
|
3430
|
+
trigger.removeEventListener('mouseenter', this.localShowTooltip);
|
|
3431
|
+
trigger.removeEventListener('mouseleave', this.localHideTooltip);
|
|
3432
|
+
trigger.removeEventListener('focus', this.localShowTooltip);
|
|
3433
|
+
trigger.removeEventListener('blur', this.localHideTooltip);
|
|
3434
|
+
trigger.removeEventListener('long-press', this.localShowTooltip);
|
|
3435
|
+
});
|
|
5026
3436
|
}
|
|
5027
|
-
|
|
5028
|
-
|
|
3437
|
+
componentWillLoad() {
|
|
3438
|
+
// Append tooltip host to the end of the body to get around overflow: hidden restrictions
|
|
3439
|
+
// for browsers that don't support popover yet
|
|
3440
|
+
document.body.appendChild(this.host);
|
|
5029
3441
|
}
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
*/
|
|
5037
|
-
disconnectedCallback() {
|
|
5038
|
-
this.triggers.forEach(trigger => {
|
|
5039
|
-
trigger.removeEventListener('mouseenter', this.localShowTooltip);
|
|
5040
|
-
trigger.removeEventListener('mouseleave', this.localHideTooltip);
|
|
5041
|
-
trigger.removeEventListener('focus', this.localShowTooltip);
|
|
5042
|
-
trigger.removeEventListener('blur', this.localHideTooltip);
|
|
5043
|
-
trigger.removeEventListener('long-press', this.localShowTooltip);
|
|
5044
|
-
});
|
|
5045
|
-
if (this.tooltipRef)
|
|
5046
|
-
this.tooltipRef.removeEventListener('beforetoggle', this.localToggleTooltip);
|
|
5047
|
-
if (typeof this.clearAutoUpdate === 'function')
|
|
5048
|
-
this.clearAutoUpdate();
|
|
5049
|
-
}
|
|
5050
|
-
componentDidLoad() {
|
|
5051
|
-
// Has the benefit of rendering the tooltip without the popover attribute which
|
|
5052
|
-
// causes the tooltip to show up on the page if it's not linked to a target. This makes
|
|
5053
|
-
// the error obvious.
|
|
5054
|
-
if (!this.host.id || !this.triggers)
|
|
5055
|
-
return false;
|
|
5056
|
-
this.tooltipRef.setAttribute('popover', '');
|
|
5057
|
-
this.tooltipRef.addEventListener('beforetoggle', this.handleToggle.bind(this));
|
|
5058
|
-
}
|
|
5059
|
-
/**
|
|
5060
|
-
* Programmatically display the tooltip
|
|
5061
|
-
* @param target An element with [data-tooltip-target="id"] where the tooltip should be shown
|
|
5062
|
-
*/
|
|
5063
|
-
async show(target) {
|
|
5064
|
-
this.eventTarget = target;
|
|
5065
|
-
this.tooltipRef.showPopover();
|
|
5066
|
-
}
|
|
5067
|
-
/**
|
|
5068
|
-
* Programmatically hide this tooltip
|
|
5069
|
-
*/
|
|
5070
|
-
async hide() {
|
|
5071
|
-
this.eventTarget = null;
|
|
5072
|
-
this.tooltipRef.hidePopover();
|
|
5073
|
-
}
|
|
5074
|
-
/**
|
|
5075
|
-
* Toggle tooltip display
|
|
5076
|
-
* @param target An element with [data-tooltip-target="id"] where the tooltip should be shown
|
|
5077
|
-
* @param force Pass true to always show or false to always hide
|
|
5078
|
-
*/
|
|
5079
|
-
async toggle(target, force) {
|
|
5080
|
-
this.eventTarget = target;
|
|
5081
|
-
this.tooltipRef.togglePopover(force);
|
|
5082
|
-
}
|
|
5083
|
-
get triggers() {
|
|
5084
|
-
return document.querySelectorAll(`[data-tooltip-target="${this.host.id}"]`);
|
|
5085
|
-
}
|
|
5086
|
-
patchPopoverTargetActionInterest(trigger) {
|
|
5087
|
-
trigger.addEventListener('mouseenter', this.localShowTooltip);
|
|
5088
|
-
trigger.addEventListener('mouseleave', this.localHideTooltip);
|
|
5089
|
-
trigger.addEventListener('focus', this.localShowTooltip);
|
|
5090
|
-
trigger.addEventListener('blur', this.localHideTooltip);
|
|
5091
|
-
trigger.addEventListener('long-press', this.localShowTooltip);
|
|
5092
|
-
// Patch missing aria-describedby attribute on the trigger without overriding existing values
|
|
5093
|
-
const describedBy = trigger.getAttribute('aria-describedby');
|
|
5094
|
-
if (!(describedBy === null || describedBy === void 0 ? void 0 : describedBy.includes(this.host.id))) {
|
|
5095
|
-
const newDescribedBy = describedBy ? `${describedBy} ${this.host.id}` : this.host.id;
|
|
5096
|
-
trigger.setAttribute('aria-describedby', newDescribedBy);
|
|
3442
|
+
/**
|
|
3443
|
+
* Programmatically display the tooltip
|
|
3444
|
+
* @param target An element with [data-tooltip-target="id"] where the tooltip should be shown
|
|
3445
|
+
*/
|
|
3446
|
+
async show(target) {
|
|
3447
|
+
this.popoverRef.show(target);
|
|
5097
3448
|
}
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
3449
|
+
/**
|
|
3450
|
+
* Programmatically hide this tooltip
|
|
3451
|
+
*/
|
|
3452
|
+
async hide() {
|
|
3453
|
+
this.popoverRef.hide();
|
|
5101
3454
|
}
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
3455
|
+
/**
|
|
3456
|
+
* Toggle tooltip display
|
|
3457
|
+
* @param target An element with [data-tooltip-target="id"] where the tooltip should be shown
|
|
3458
|
+
* @param force Pass true to always show or false to always hide
|
|
3459
|
+
*/
|
|
3460
|
+
async toggle(target, force) {
|
|
3461
|
+
this.popoverRef.toggle(target, force);
|
|
3462
|
+
}
|
|
3463
|
+
get triggers() {
|
|
3464
|
+
return document.querySelectorAll(`[data-tooltip-target="${this.host.id}"]`);
|
|
3465
|
+
}
|
|
3466
|
+
patchPopoverTargetActionInterest(trigger) {
|
|
3467
|
+
trigger.addEventListener('mouseenter', this.localShowTooltip);
|
|
3468
|
+
trigger.addEventListener('mouseleave', this.localHideTooltip);
|
|
3469
|
+
trigger.addEventListener('focus', this.localShowTooltip);
|
|
3470
|
+
trigger.addEventListener('blur', this.localHideTooltip);
|
|
3471
|
+
trigger.addEventListener('long-press', this.localShowTooltip);
|
|
3472
|
+
// Patch missing aria-describedby attribute on the trigger without overriding existing values
|
|
3473
|
+
const describedBy = trigger.getAttribute('aria-describedby');
|
|
3474
|
+
if (!(describedBy === null || describedBy === void 0 ? void 0 : describedBy.includes(this.host.id))) {
|
|
3475
|
+
const newDescribedBy = describedBy ? `${describedBy} ${this.host.id}` : this.host.id;
|
|
3476
|
+
trigger.setAttribute('aria-describedby', newDescribedBy);
|
|
3477
|
+
}
|
|
3478
|
+
// Patch missing focus ability on the trigger element
|
|
3479
|
+
if (!isFocusable(trigger)) {
|
|
3480
|
+
trigger.setAttribute('tabindex', '0');
|
|
3481
|
+
}
|
|
5113
3482
|
}
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
this.clearAutoUpdate();
|
|
3483
|
+
render() {
|
|
3484
|
+
return (h(Host, { "data-version": version$2 }, h("post-popovercontainer", { role: "tooltip", tabindex: "-1", arrow: true, placement: this.placement, ref: (el) => (this.popoverRef = el) }, h("slot", null))));
|
|
5117
3485
|
}
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
* Start listening for DOM updates, scroll events etc. that have
|
|
5121
|
-
* an influence on tooltip positioning
|
|
5122
|
-
*/
|
|
5123
|
-
startAutoupdates() {
|
|
5124
|
-
this.clearAutoUpdate = autoUpdate(this.eventTarget, this.tooltipRef, this.positionTooltip.bind(this));
|
|
5125
|
-
}
|
|
5126
|
-
// Tooltip and arrow positioning with floating-ui
|
|
5127
|
-
// Docs: https://floating-ui.com/docs/computePosition
|
|
5128
|
-
async positionTooltip() {
|
|
5129
|
-
const { x, y, middlewareData, placement: currentPlacement, } = await computePosition(this.eventTarget, this.tooltipRef, {
|
|
5130
|
-
placement: this.placement || 'top',
|
|
5131
|
-
middleware: [
|
|
5132
|
-
flip(),
|
|
5133
|
-
inline(),
|
|
5134
|
-
shift({ padding: 8 }),
|
|
5135
|
-
offset(12),
|
|
5136
|
-
arrow({ element: this.arrowRef, padding: 8 }),
|
|
5137
|
-
],
|
|
5138
|
-
});
|
|
5139
|
-
// Tooltip
|
|
5140
|
-
this.tooltipRef.style.left = `${x}px`;
|
|
5141
|
-
this.tooltipRef.style.top = `${y}px`;
|
|
5142
|
-
// Arrow
|
|
5143
|
-
// Tutorial: https://codesandbox.io/s/mystifying-kare-ee3hmh?file=/src/index.js
|
|
5144
|
-
const side = currentPlacement.split('-')[0];
|
|
5145
|
-
const { x: arrowX, y: arrowY } = middlewareData.arrow;
|
|
5146
|
-
const staticSide = SIDE_MAP[side];
|
|
5147
|
-
Object.assign(this.arrowRef.style, {
|
|
5148
|
-
top: arrowY ? `${arrowY}px` : '',
|
|
5149
|
-
left: arrowX ? `${arrowX}px` : '',
|
|
5150
|
-
[staticSide]: `${-this.arrowRef.offsetWidth / 2}px`,
|
|
5151
|
-
});
|
|
5152
|
-
}
|
|
5153
|
-
render() {
|
|
5154
|
-
return (h(Host, { "data-version": version$2 }, h("div", { role: "tooltip", tabindex: "-1", class: this.tooltipClasses, ref: (el) => (this.tooltipRef = el) }, h("span", { class: "arrow", ref: el => {
|
|
5155
|
-
this.arrowRef = el;
|
|
5156
|
-
} }), h("slot", null))));
|
|
5157
|
-
}
|
|
5158
|
-
get host() { return this; }
|
|
5159
|
-
static get watchers() { return {
|
|
5160
|
-
"backgroundColor": ["validateBackgroundColor"]
|
|
5161
|
-
}; }
|
|
5162
|
-
static get style() { return postTooltipCss; }
|
|
3486
|
+
get host() { return this; }
|
|
3487
|
+
static get style() { return postTooltipCss; }
|
|
5163
3488
|
}, [1, "post-tooltip", {
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
"toggle": [64]
|
|
5170
|
-
}, undefined, {
|
|
5171
|
-
"backgroundColor": ["validateBackgroundColor"]
|
|
5172
|
-
}]);
|
|
3489
|
+
"placement": [1],
|
|
3490
|
+
"show": [64],
|
|
3491
|
+
"hide": [64],
|
|
3492
|
+
"toggle": [64]
|
|
3493
|
+
}]);
|
|
5173
3494
|
function defineCustomElement() {
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
3495
|
+
if (typeof customElements === "undefined") {
|
|
3496
|
+
return;
|
|
3497
|
+
}
|
|
3498
|
+
const components = ["post-tooltip", "post-popovercontainer"];
|
|
3499
|
+
components.forEach(tagName => { switch (tagName) {
|
|
3500
|
+
case "post-tooltip":
|
|
3501
|
+
if (!customElements.get(tagName)) {
|
|
3502
|
+
customElements.define(tagName, PostTooltip);
|
|
3503
|
+
}
|
|
3504
|
+
break;
|
|
3505
|
+
case "post-popovercontainer":
|
|
3506
|
+
if (!customElements.get(tagName)) {
|
|
3507
|
+
defineCustomElement$1();
|
|
3508
|
+
}
|
|
3509
|
+
break;
|
|
3510
|
+
} });
|
|
5185
3511
|
}
|
|
5186
3512
|
|
|
5187
3513
|
export { PostTooltip as P, defineCustomElement as d };
|