@quartzds/core 1.0.0-beta.9 → 1.0.0-beta.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/components/index.d.ts +48 -0
- package/components/index.js +60 -28
- package/components/index.js.map +1 -1
- package/components/p-2806fee1.js +1887 -0
- package/components/p-2806fee1.js.map +1 -0
- package/components/p-2bf0797c.js +272 -0
- package/components/p-2bf0797c.js.map +1 -0
- package/components/p-3baf75f4.js +111 -0
- package/components/p-3baf75f4.js.map +1 -0
- package/components/p-3c48ff53.js +103 -0
- package/components/p-3c48ff53.js.map +1 -0
- package/components/p-8abba29b.js +204 -0
- package/components/p-8abba29b.js.map +1 -0
- package/components/p-a020ece3.js +142 -0
- package/components/p-a020ece3.js.map +1 -0
- package/components/p-a6310886.js +144 -0
- package/components/p-a6310886.js.map +1 -0
- package/components/p-b4c302d4.js +91 -0
- package/components/p-b4c302d4.js.map +1 -0
- package/components/p-ba880369.js +256 -0
- package/components/p-ba880369.js.map +1 -0
- package/components/p-c80f112a.js +408 -0
- package/components/p-c80f112a.js.map +1 -0
- package/components/p-d107c90c.js +27 -0
- package/components/p-d107c90c.js.map +1 -0
- package/components/p-d6e52d0b.js +404 -0
- package/components/p-d6e52d0b.js.map +1 -0
- package/components/{floating-ui.dom.esm.js → p-fdd0abae.js} +468 -416
- package/components/p-fdd0abae.js.map +1 -0
- package/components/p-fed0d11f.js +94 -0
- package/components/p-fed0d11f.js.map +1 -0
- package/components/qds-badge-counter.d.ts +11 -0
- package/components/qds-badge-counter.js +13 -0
- package/components/qds-badge-counter.js.map +1 -0
- package/components/qds-badge-indicator.d.ts +11 -0
- package/components/qds-badge-indicator.js +13 -0
- package/components/qds-badge-indicator.js.map +1 -0
- package/components/qds-breadcrumb-item.d.ts +11 -0
- package/components/qds-breadcrumb-item.js +126 -0
- package/components/qds-breadcrumb-item.js.map +1 -0
- package/components/qds-button.d.ts +2 -2
- package/components/qds-button.js +3 -138
- package/components/qds-button.js.map +1 -1
- package/components/qds-checkbox.d.ts +2 -2
- package/components/qds-checkbox.js +3 -146
- package/components/qds-checkbox.js.map +1 -1
- package/components/qds-chip.d.ts +11 -0
- package/components/qds-chip.js +296 -0
- package/components/qds-chip.js.map +1 -0
- package/components/qds-dialog.d.ts +11 -0
- package/components/qds-dialog.js +126 -0
- package/components/qds-dialog.js.map +1 -0
- package/components/qds-divider.d.ts +2 -2
- package/components/qds-divider.js +3 -39
- package/components/qds-divider.js.map +1 -1
- package/components/qds-dropdown.d.ts +2 -2
- package/components/qds-dropdown.js +273 -239
- package/components/qds-dropdown.js.map +1 -1
- package/components/qds-form-message.d.ts +11 -0
- package/components/qds-form-message.js +112 -0
- package/components/qds-form-message.js.map +1 -0
- package/components/qds-icon.d.ts +2 -2
- package/components/qds-icon.js +3 -3
- package/components/qds-inline-link.d.ts +2 -2
- package/components/qds-inline-link.js +136 -73
- package/components/qds-inline-link.js.map +1 -1
- package/components/qds-input.d.ts +2 -2
- package/components/qds-input.js +489 -230
- package/components/qds-input.js.map +1 -1
- package/components/qds-label.d.ts +2 -2
- package/components/qds-label.js +3 -3
- package/components/qds-list-item.d.ts +11 -0
- package/components/qds-list-item.js +212 -0
- package/components/qds-list-item.js.map +1 -0
- package/components/qds-loader.d.ts +11 -0
- package/components/qds-loader.js +113 -0
- package/components/qds-loader.js.map +1 -0
- package/components/qds-nav-list-item.d.ts +11 -0
- package/components/qds-nav-list-item.js +162 -0
- package/components/qds-nav-list-item.js.map +1 -0
- package/components/qds-progress-bar.d.ts +11 -0
- package/components/qds-progress-bar.js +153 -0
- package/components/qds-progress-bar.js.map +1 -0
- package/components/qds-radio.d.ts +2 -2
- package/components/qds-radio.js +147 -93
- package/components/qds-radio.js.map +1 -1
- package/components/qds-select.d.ts +11 -0
- package/components/qds-select.js +361 -0
- package/components/qds-select.js.map +1 -0
- package/components/qds-standalone-link.d.ts +11 -0
- package/components/qds-standalone-link.js +174 -0
- package/components/qds-standalone-link.js.map +1 -0
- package/components/qds-switch.d.ts +2 -2
- package/components/qds-switch.js +221 -105
- package/components/qds-switch.js.map +1 -1
- package/components/qds-tab.d.ts +11 -0
- package/components/qds-tab.js +379 -0
- package/components/qds-tab.js.map +1 -0
- package/components/qds-tabbar.d.ts +11 -0
- package/components/qds-tabbar.js +407 -0
- package/components/qds-tabbar.js.map +1 -0
- package/components/qds-table-body.d.ts +11 -0
- package/components/qds-table-body.js +68 -0
- package/components/qds-table-body.js.map +1 -0
- package/components/qds-table-cell.d.ts +11 -0
- package/components/qds-table-cell.js +71 -0
- package/components/qds-table-cell.js.map +1 -0
- package/components/qds-table-head-cell.d.ts +11 -0
- package/components/qds-table-head-cell.js +73 -0
- package/components/qds-table-head-cell.js.map +1 -0
- package/components/qds-table-head.d.ts +11 -0
- package/components/qds-table-head.js +68 -0
- package/components/qds-table-head.js.map +1 -0
- package/components/qds-table-row.d.ts +11 -0
- package/components/qds-table-row.js +68 -0
- package/components/qds-table-row.js.map +1 -0
- package/components/qds-table.d.ts +11 -0
- package/components/qds-table.js +68 -0
- package/components/qds-table.js.map +1 -0
- package/components/qds-tag.d.ts +11 -0
- package/components/qds-tag.js +13 -0
- package/components/qds-tag.js.map +1 -0
- package/components/qds-textarea.d.ts +2 -2
- package/components/qds-textarea.js +331 -193
- package/components/qds-textarea.js.map +1 -1
- package/components/qds-title.d.ts +2 -2
- package/components/qds-title.js +3 -84
- package/components/qds-title.js.map +1 -1
- package/components/qds-tooltip.d.ts +2 -2
- package/components/qds-tooltip.js +3 -315
- package/components/qds-tooltip.js.map +1 -1
- package/dist/cjs/app-globals-c4cf08df.js +12 -0
- package/dist/cjs/app-globals-c4cf08df.js.map +1 -0
- package/dist/cjs/controls-ee3d2ec8.js +31 -0
- package/dist/cjs/controls-ee3d2ec8.js.map +1 -0
- package/dist/cjs/{floating-ui.dom.esm-71fa96af.js → floating-ui.dom.esm-19b2b933.js} +468 -416
- package/dist/cjs/floating-ui.dom.esm-19b2b933.js.map +1 -0
- package/dist/cjs/helpers-10154521.js +217 -0
- package/dist/cjs/helpers-10154521.js.map +1 -0
- package/dist/cjs/index-523dd2e0.js +2149 -0
- package/dist/cjs/index-523dd2e0.js.map +1 -0
- package/dist/cjs/index.cjs.js +39 -27
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/library-41b19b9e.js +117 -0
- package/dist/cjs/library-41b19b9e.js.map +1 -0
- package/dist/cjs/loader.cjs.js +8 -6
- package/dist/cjs/loader.cjs.js.map +1 -1
- package/dist/cjs/qds-badge-counter_2.cjs.entry.js +151 -0
- package/dist/cjs/qds-badge-counter_2.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-breadcrumb-item.cjs.entry.js +96 -0
- package/dist/cjs/qds-breadcrumb-item.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-button.cjs.entry.js +321 -90
- package/dist/cjs/qds-button.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-checkbox.cjs.entry.js +212 -100
- package/dist/cjs/qds-checkbox.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-chip.cjs.entry.js +256 -0
- package/dist/cjs/qds-chip.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-dialog.cjs.entry.js +108 -0
- package/dist/cjs/qds-dialog.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-divider.cjs.entry.js +60 -18
- package/dist/cjs/qds-divider.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-dropdown.cjs.entry.js +232 -206
- package/dist/cjs/qds-dropdown.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-form-message.cjs.entry.js +86 -0
- package/dist/cjs/qds-form-message.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-icon.cjs.entry.js +113 -90
- package/dist/cjs/qds-icon.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-inline-link.cjs.entry.js +99 -46
- package/dist/cjs/qds-inline-link.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-input.cjs.entry.js +404 -185
- package/dist/cjs/qds-input.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-label.cjs.entry.js +102 -24
- package/dist/cjs/qds-label.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-list-item.cjs.entry.js +157 -0
- package/dist/cjs/qds-list-item.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-loader.cjs.entry.js +94 -0
- package/dist/cjs/qds-loader.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-nav-list-item.cjs.entry.js +124 -0
- package/dist/cjs/qds-nav-list-item.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-progress-bar.cjs.entry.js +135 -0
- package/dist/cjs/qds-progress-bar.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-radio.cjs.entry.js +102 -57
- package/dist/cjs/qds-radio.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-select.cjs.entry.js +323 -0
- package/dist/cjs/qds-select.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-standalone-link.cjs.entry.js +134 -0
- package/dist/cjs/qds-standalone-link.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-switch.cjs.entry.js +193 -64
- package/dist/cjs/qds-switch.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-tab.cjs.entry.js +299 -0
- package/dist/cjs/qds-tab.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-tabbar.cjs.entry.js +349 -0
- package/dist/cjs/qds-tabbar.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-table-body.cjs.entry.js +54 -0
- package/dist/cjs/qds-table-body.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-table-cell.cjs.entry.js +54 -0
- package/dist/cjs/qds-table-cell.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-table-head-cell.cjs.entry.js +54 -0
- package/dist/cjs/qds-table-head-cell.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-table-head.cjs.entry.js +54 -0
- package/dist/cjs/qds-table-head.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-table-row.cjs.entry.js +54 -0
- package/dist/cjs/qds-table-row.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-table.cjs.entry.js +54 -0
- package/dist/cjs/qds-table.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-tag_2.cjs.entry.js +181 -0
- package/dist/cjs/qds-tag_2.cjs.entry.js.map +1 -0
- package/dist/cjs/qds-textarea.cjs.entry.js +288 -153
- package/dist/cjs/qds-textarea.cjs.entry.js.map +1 -1
- package/dist/cjs/qds-tooltip.cjs.entry.js +332 -260
- package/dist/cjs/qds-tooltip.cjs.entry.js.map +1 -1
- package/dist/cjs/qds.cjs.js +15 -13
- package/dist/cjs/qds.cjs.js.map +1 -1
- package/dist/custom-elements.json +8727 -2151
- package/dist/docs.d.ts +344 -240
- package/dist/docs.json +9364 -2903
- package/dist/esm/app-globals-8ced3a41.js +10 -0
- package/dist/esm/app-globals-8ced3a41.js.map +1 -0
- package/dist/esm/controls-a4768aaf.js +27 -0
- package/dist/esm/controls-a4768aaf.js.map +1 -0
- package/dist/esm/{floating-ui.dom.esm-f96ac766.js → floating-ui.dom.esm-61986f35.js} +468 -416
- package/dist/esm/floating-ui.dom.esm-61986f35.js.map +1 -0
- package/dist/esm/helpers-2e4ca34d.js +204 -0
- package/dist/esm/helpers-2e4ca34d.js.map +1 -0
- package/dist/esm/index-b1d6acd2.js +2118 -0
- package/dist/esm/index-b1d6acd2.js.map +1 -0
- package/dist/esm/index.js +39 -28
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/library-2e5458af.js +113 -0
- package/dist/esm/library-2e5458af.js.map +1 -0
- package/dist/esm/loader.js +9 -7
- package/dist/esm/loader.js.map +1 -1
- package/dist/esm/qds-badge-counter_2.entry.js +146 -0
- package/dist/esm/qds-badge-counter_2.entry.js.map +1 -0
- package/dist/esm/qds-breadcrumb-item.entry.js +92 -0
- package/dist/esm/qds-breadcrumb-item.entry.js.map +1 -0
- package/dist/esm/qds-button.entry.js +321 -90
- package/dist/esm/qds-button.entry.js.map +1 -1
- package/dist/esm/qds-checkbox.entry.js +212 -100
- package/dist/esm/qds-checkbox.entry.js.map +1 -1
- package/dist/esm/qds-chip.entry.js +252 -0
- package/dist/esm/qds-chip.entry.js.map +1 -0
- package/dist/esm/qds-dialog.entry.js +104 -0
- package/dist/esm/qds-dialog.entry.js.map +1 -0
- package/dist/esm/qds-divider.entry.js +60 -18
- package/dist/esm/qds-divider.entry.js.map +1 -1
- package/dist/esm/qds-dropdown.entry.js +232 -206
- package/dist/esm/qds-dropdown.entry.js.map +1 -1
- package/dist/esm/qds-form-message.entry.js +82 -0
- package/dist/esm/qds-form-message.entry.js.map +1 -0
- package/dist/esm/qds-icon.entry.js +113 -90
- package/dist/esm/qds-icon.entry.js.map +1 -1
- package/dist/esm/qds-inline-link.entry.js +99 -46
- package/dist/esm/qds-inline-link.entry.js.map +1 -1
- package/dist/esm/qds-input.entry.js +404 -185
- package/dist/esm/qds-input.entry.js.map +1 -1
- package/dist/esm/qds-label.entry.js +102 -24
- package/dist/esm/qds-label.entry.js.map +1 -1
- package/dist/esm/qds-list-item.entry.js +153 -0
- package/dist/esm/qds-list-item.entry.js.map +1 -0
- package/dist/esm/qds-loader.entry.js +90 -0
- package/dist/esm/qds-loader.entry.js.map +1 -0
- package/dist/esm/qds-nav-list-item.entry.js +120 -0
- package/dist/esm/qds-nav-list-item.entry.js.map +1 -0
- package/dist/esm/qds-progress-bar.entry.js +131 -0
- package/dist/esm/qds-progress-bar.entry.js.map +1 -0
- package/dist/esm/qds-radio.entry.js +102 -57
- package/dist/esm/qds-radio.entry.js.map +1 -1
- package/dist/esm/qds-select.entry.js +319 -0
- package/dist/esm/qds-select.entry.js.map +1 -0
- package/dist/esm/qds-standalone-link.entry.js +130 -0
- package/dist/esm/qds-standalone-link.entry.js.map +1 -0
- package/dist/esm/qds-switch.entry.js +193 -64
- package/dist/esm/qds-switch.entry.js.map +1 -1
- package/dist/esm/qds-tab.entry.js +295 -0
- package/dist/esm/qds-tab.entry.js.map +1 -0
- package/dist/esm/qds-tabbar.entry.js +345 -0
- package/dist/esm/qds-tabbar.entry.js.map +1 -0
- package/dist/esm/qds-table-body.entry.js +50 -0
- package/dist/esm/qds-table-body.entry.js.map +1 -0
- package/dist/esm/qds-table-cell.entry.js +50 -0
- package/dist/esm/qds-table-cell.entry.js.map +1 -0
- package/dist/esm/qds-table-head-cell.entry.js +50 -0
- package/dist/esm/qds-table-head-cell.entry.js.map +1 -0
- package/dist/esm/qds-table-head.entry.js +50 -0
- package/dist/esm/qds-table-head.entry.js.map +1 -0
- package/dist/esm/qds-table-row.entry.js +50 -0
- package/dist/esm/qds-table-row.entry.js.map +1 -0
- package/dist/esm/qds-table.entry.js +50 -0
- package/dist/esm/qds-table.entry.js.map +1 -0
- package/dist/esm/qds-tag_2.entry.js +176 -0
- package/dist/esm/qds-tag_2.entry.js.map +1 -0
- package/dist/esm/qds-textarea.entry.js +288 -153
- package/dist/esm/qds-textarea.entry.js.map +1 -1
- package/dist/esm/qds-tooltip.entry.js +332 -260
- package/dist/esm/qds-tooltip.entry.js.map +1 -1
- package/dist/esm/qds.js +16 -14
- package/dist/esm/qds.js.map +1 -1
- package/dist/types/components/badge-counter/badge-counter.d.ts +40 -0
- package/dist/types/components/badge-indicator/badge-indicator.d.ts +36 -0
- package/dist/types/components/breadcrumb-item/breadcrumb-item.d.ts +160 -0
- package/dist/types/components/button/button.d.ts +272 -194
- package/dist/types/components/checkbox/checkbox.d.ts +137 -124
- package/dist/types/components/chip/chip.d.ts +109 -0
- package/dist/types/components/controls.d.ts +4 -1
- package/dist/types/components/dialog/dialog.d.ts +35 -0
- package/dist/types/components/divider/divider.d.ts +13 -9
- package/dist/types/components/dropdown/dropdown.d.ts +107 -125
- package/dist/types/components/form-message/form-message.d.ts +42 -0
- package/dist/types/components/icon/icon.d.ts +24 -24
- package/dist/types/components/icon/library.d.ts +3 -3
- package/dist/types/components/icon/request.d.ts +5 -9
- package/dist/types/components/inline-link/inline-link.d.ts +208 -191
- package/dist/types/components/input/input.d.ts +415 -368
- package/dist/types/components/label/label.d.ts +26 -24
- package/dist/types/components/list-item/list-item.d.ts +100 -0
- package/dist/types/components/loader/loader.d.ts +27 -0
- package/dist/types/components/nav-list-item/nav-list-item.d.ts +67 -0
- package/dist/types/components/progress-bar/progress-bar.d.ts +60 -0
- package/dist/types/components/radio/radio.d.ts +90 -95
- package/dist/types/components/select/select.d.ts +203 -0
- package/dist/types/components/shared.d.ts +6 -0
- package/dist/types/components/standalone-link/standalone-link.d.ts +233 -0
- package/dist/types/components/switch/switch.d.ts +114 -107
- package/dist/types/components/tab/tab.d.ts +160 -0
- package/dist/types/components/tabbar/tabbar.d.ts +47 -0
- package/dist/types/components/table/table.d.ts +15 -0
- package/dist/types/components/table-body/table-body.d.ts +15 -0
- package/dist/types/components/table-cell/table-cell.d.ts +32 -0
- package/dist/types/components/table-head/table-head.d.ts +15 -0
- package/dist/types/components/table-head-cell/table-head-cell.d.ts +56 -0
- package/dist/types/components/table-row/table-row.d.ts +15 -0
- package/dist/types/components/tag/tag.d.ts +55 -0
- package/dist/types/components/textarea/textarea.d.ts +285 -300
- package/dist/types/components/title/title.d.ts +39 -32
- package/dist/types/components/tooltip/tooltip.d.ts +123 -137
- package/dist/types/components.d.ts +3957 -833
- package/dist/types/helpers.d.ts +15 -16
- package/dist/types/index.d.ts +2 -1
- package/dist/types/interface-overrides.d.ts +211 -0
- package/dist/types/qds-test.d.ts +22 -11
- package/dist/types/stencil-public-runtime.d.ts +55 -15
- package/dist/types/utils.d.ts +11 -4
- package/dist/vscode.html-custom-data.json +1528 -210
- package/hydrate/index.d.ts +59 -18
- package/hydrate/index.js +25724 -9014
- package/hydrate/index.mjs +26627 -0
- package/hydrate/package.json +7 -1
- package/loader/cdn.js +3 -4
- package/loader/index.cjs.js +3 -4
- package/loader/index.d.ts +4 -1
- package/loader/index.es2017.js +3 -4
- package/loader/index.js +3 -4
- package/package.json +53 -89
- package/styles/core.css +137 -14
- package/components/floating-ui.dom.esm.js.map +0 -1
- package/components/helpers.js +0 -175
- package/components/helpers.js.map +0 -1
- package/components/icon.js +0 -175
- package/components/icon.js.map +0 -1
- package/components/label.js +0 -55
- package/components/label.js.map +0 -1
- package/dist/cjs/floating-ui.dom.esm-71fa96af.js.map +0 -1
- package/dist/cjs/helpers-452256e8.js +0 -185
- package/dist/cjs/helpers-452256e8.js.map +0 -1
- package/dist/cjs/index-d181f952.js +0 -2039
- package/dist/cjs/index-d181f952.js.map +0 -1
- package/dist/cjs/library-0a619eeb.js +0 -62
- package/dist/cjs/library-0a619eeb.js.map +0 -1
- package/dist/cjs/qds-title.cjs.entry.js +0 -66
- package/dist/cjs/qds-title.cjs.entry.js.map +0 -1
- package/dist/esm/floating-ui.dom.esm-f96ac766.js.map +0 -1
- package/dist/esm/helpers-76b84f45.js +0 -175
- package/dist/esm/helpers-76b84f45.js.map +0 -1
- package/dist/esm/index-d7183092.js +0 -2009
- package/dist/esm/index-d7183092.js.map +0 -1
- package/dist/esm/library-021aca11.js +0 -58
- package/dist/esm/library-021aca11.js.map +0 -1
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/esm/qds-title.entry.js +0 -62
- package/dist/esm/qds-title.entry.js.map +0 -1
- package/dist/types/components/create-story.d.ts +0 -5
|
@@ -1,22 +1,126 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SPDX-FileCopyrightText: ©
|
|
2
|
+
* SPDX-FileCopyrightText: © 2025 Schneider Electric
|
|
3
3
|
*
|
|
4
|
-
* SPDX-License-Identifier:
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
const min = Math.min;
|
|
7
|
+
const max = Math.max;
|
|
8
|
+
const round = Math.round;
|
|
9
|
+
const floor = Math.floor;
|
|
10
|
+
const createCoords = v => ({
|
|
11
|
+
x: v,
|
|
12
|
+
y: v
|
|
13
|
+
});
|
|
14
|
+
const oppositeSideMap = {
|
|
15
|
+
left: 'right',
|
|
16
|
+
right: 'left',
|
|
17
|
+
bottom: 'top',
|
|
18
|
+
top: 'bottom'
|
|
19
|
+
};
|
|
20
|
+
const oppositeAlignmentMap = {
|
|
21
|
+
start: 'end',
|
|
22
|
+
end: 'start'
|
|
23
|
+
};
|
|
24
|
+
function clamp(start, value, end) {
|
|
25
|
+
return max(start, min(value, end));
|
|
26
|
+
}
|
|
27
|
+
function evaluate(value, param) {
|
|
28
|
+
return typeof value === 'function' ? value(param) : value;
|
|
29
|
+
}
|
|
30
|
+
function getSide(placement) {
|
|
31
|
+
return placement.split('-')[0];
|
|
32
|
+
}
|
|
6
33
|
function getAlignment(placement) {
|
|
7
34
|
return placement.split('-')[1];
|
|
8
35
|
}
|
|
9
|
-
|
|
10
|
-
|
|
36
|
+
function getOppositeAxis(axis) {
|
|
37
|
+
return axis === 'x' ? 'y' : 'x';
|
|
38
|
+
}
|
|
39
|
+
function getAxisLength(axis) {
|
|
11
40
|
return axis === 'y' ? 'height' : 'width';
|
|
12
41
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return placement.split('-')[0];
|
|
42
|
+
function getSideAxis(placement) {
|
|
43
|
+
return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
|
|
16
44
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
45
|
+
function getAlignmentAxis(placement) {
|
|
46
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
47
|
+
}
|
|
48
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
49
|
+
if (rtl === void 0) {
|
|
50
|
+
rtl = false;
|
|
51
|
+
}
|
|
52
|
+
const alignment = getAlignment(placement);
|
|
53
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
54
|
+
const length = getAxisLength(alignmentAxis);
|
|
55
|
+
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
56
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
57
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
58
|
+
}
|
|
59
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
60
|
+
}
|
|
61
|
+
function getExpandedPlacements(placement) {
|
|
62
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
63
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
64
|
+
}
|
|
65
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
66
|
+
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
67
|
+
}
|
|
68
|
+
function getSideList(side, isStart, rtl) {
|
|
69
|
+
const lr = ['left', 'right'];
|
|
70
|
+
const rl = ['right', 'left'];
|
|
71
|
+
const tb = ['top', 'bottom'];
|
|
72
|
+
const bt = ['bottom', 'top'];
|
|
73
|
+
switch (side) {
|
|
74
|
+
case 'top':
|
|
75
|
+
case 'bottom':
|
|
76
|
+
if (rtl) return isStart ? rl : lr;
|
|
77
|
+
return isStart ? lr : rl;
|
|
78
|
+
case 'left':
|
|
79
|
+
case 'right':
|
|
80
|
+
return isStart ? tb : bt;
|
|
81
|
+
default:
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
86
|
+
const alignment = getAlignment(placement);
|
|
87
|
+
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
|
88
|
+
if (alignment) {
|
|
89
|
+
list = list.map(side => side + "-" + alignment);
|
|
90
|
+
if (flipAlignment) {
|
|
91
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return list;
|
|
95
|
+
}
|
|
96
|
+
function getOppositePlacement(placement) {
|
|
97
|
+
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
98
|
+
}
|
|
99
|
+
function expandPaddingObject(padding) {
|
|
100
|
+
return {
|
|
101
|
+
top: 0,
|
|
102
|
+
right: 0,
|
|
103
|
+
bottom: 0,
|
|
104
|
+
left: 0,
|
|
105
|
+
...padding
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function getPaddingObject(padding) {
|
|
109
|
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
110
|
+
top: padding,
|
|
111
|
+
right: padding,
|
|
112
|
+
bottom: padding,
|
|
113
|
+
left: padding
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function rectToClientRect(rect) {
|
|
117
|
+
return {
|
|
118
|
+
...rect,
|
|
119
|
+
top: rect.y,
|
|
120
|
+
left: rect.x,
|
|
121
|
+
right: rect.x + rect.width,
|
|
122
|
+
bottom: rect.y + rect.height
|
|
123
|
+
};
|
|
20
124
|
}
|
|
21
125
|
|
|
22
126
|
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
@@ -24,13 +128,14 @@ function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
|
24
128
|
reference,
|
|
25
129
|
floating
|
|
26
130
|
} = _ref;
|
|
131
|
+
const sideAxis = getSideAxis(placement);
|
|
132
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
133
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
134
|
+
const side = getSide(placement);
|
|
135
|
+
const isVertical = sideAxis === 'y';
|
|
27
136
|
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
28
137
|
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
29
|
-
const
|
|
30
|
-
const length = getLengthFromAxis(mainAxis);
|
|
31
|
-
const commonAlign = reference[length] / 2 - floating[length] / 2;
|
|
32
|
-
const side = getSide(placement);
|
|
33
|
-
const isVertical = mainAxis === 'x';
|
|
138
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
34
139
|
let coords;
|
|
35
140
|
switch (side) {
|
|
36
141
|
case 'top':
|
|
@@ -65,10 +170,10 @@ function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
|
65
170
|
}
|
|
66
171
|
switch (getAlignment(placement)) {
|
|
67
172
|
case 'start':
|
|
68
|
-
coords[
|
|
173
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
69
174
|
break;
|
|
70
175
|
case 'end':
|
|
71
|
-
coords[
|
|
176
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
72
177
|
break;
|
|
73
178
|
}
|
|
74
179
|
return coords;
|
|
@@ -166,35 +271,6 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
166
271
|
};
|
|
167
272
|
};
|
|
168
273
|
|
|
169
|
-
function expandPaddingObject(padding) {
|
|
170
|
-
return {
|
|
171
|
-
top: 0,
|
|
172
|
-
right: 0,
|
|
173
|
-
bottom: 0,
|
|
174
|
-
left: 0,
|
|
175
|
-
...padding
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function getSideObjectFromPadding(padding) {
|
|
180
|
-
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
181
|
-
top: padding,
|
|
182
|
-
right: padding,
|
|
183
|
-
bottom: padding,
|
|
184
|
-
left: padding
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function rectToClientRect(rect) {
|
|
189
|
-
return {
|
|
190
|
-
...rect,
|
|
191
|
-
top: rect.y,
|
|
192
|
-
left: rect.x,
|
|
193
|
-
right: rect.x + rect.width,
|
|
194
|
-
bottom: rect.y + rect.height
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
|
|
198
274
|
/**
|
|
199
275
|
* Resolves with an object of overflow side offsets that determine how much the
|
|
200
276
|
* element is overflowing a given clipping boundary on each side.
|
|
@@ -222,8 +298,8 @@ async function detectOverflow(state, options) {
|
|
|
222
298
|
elementContext = 'floating',
|
|
223
299
|
altBoundary = false,
|
|
224
300
|
padding = 0
|
|
225
|
-
} = options;
|
|
226
|
-
const paddingObject =
|
|
301
|
+
} = evaluate(options, state);
|
|
302
|
+
const paddingObject = getPaddingObject(padding);
|
|
227
303
|
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
228
304
|
const element = elements[altBoundary ? altContext : elementContext];
|
|
229
305
|
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
@@ -258,13 +334,6 @@ async function detectOverflow(state, options) {
|
|
|
258
334
|
};
|
|
259
335
|
}
|
|
260
336
|
|
|
261
|
-
const min$1 = Math.min;
|
|
262
|
-
const max$1 = Math.max;
|
|
263
|
-
|
|
264
|
-
function within(min$1$1, value, max$1$1) {
|
|
265
|
-
return max$1(min$1$1, min$1(value, max$1$1));
|
|
266
|
-
}
|
|
267
|
-
|
|
268
337
|
/**
|
|
269
338
|
* Provides data to position an inner element of the floating element so that it
|
|
270
339
|
* appears centered to the reference element.
|
|
@@ -274,11 +343,6 @@ const arrow = options => ({
|
|
|
274
343
|
name: 'arrow',
|
|
275
344
|
options,
|
|
276
345
|
async fn(state) {
|
|
277
|
-
// Since `element` is required, we don't Partial<> the type.
|
|
278
|
-
const {
|
|
279
|
-
element,
|
|
280
|
-
padding = 0
|
|
281
|
-
} = options || {};
|
|
282
346
|
const {
|
|
283
347
|
x,
|
|
284
348
|
y,
|
|
@@ -287,16 +351,21 @@ const arrow = options => ({
|
|
|
287
351
|
platform,
|
|
288
352
|
elements
|
|
289
353
|
} = state;
|
|
354
|
+
// Since `element` is required, we don't Partial<> the type.
|
|
355
|
+
const {
|
|
356
|
+
element,
|
|
357
|
+
padding = 0
|
|
358
|
+
} = evaluate(options, state) || {};
|
|
290
359
|
if (element == null) {
|
|
291
360
|
return {};
|
|
292
361
|
}
|
|
293
|
-
const paddingObject =
|
|
362
|
+
const paddingObject = getPaddingObject(padding);
|
|
294
363
|
const coords = {
|
|
295
364
|
x,
|
|
296
365
|
y
|
|
297
366
|
};
|
|
298
|
-
const axis =
|
|
299
|
-
const length =
|
|
367
|
+
const axis = getAlignmentAxis(placement);
|
|
368
|
+
const length = getAxisLength(axis);
|
|
300
369
|
const arrowDimensions = await platform.getDimensions(element);
|
|
301
370
|
const isYAxis = axis === 'y';
|
|
302
371
|
const minProp = isYAxis ? 'top' : 'left';
|
|
@@ -313,98 +382,35 @@ const arrow = options => ({
|
|
|
313
382
|
}
|
|
314
383
|
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
315
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
|
+
|
|
316
391
|
// Make sure the arrow doesn't overflow the floating element if the center
|
|
317
392
|
// point is outside the floating element's bounds.
|
|
318
|
-
const min =
|
|
319
|
-
const max = clientSize - arrowDimensions[length] -
|
|
393
|
+
const min$1 = minPadding;
|
|
394
|
+
const max = clientSize - arrowDimensions[length] - maxPadding;
|
|
320
395
|
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
321
|
-
const offset =
|
|
396
|
+
const offset = clamp(min$1, center, max);
|
|
322
397
|
|
|
323
398
|
// If the reference is small enough that the arrow's padding causes it to
|
|
324
399
|
// to point to nothing for an aligned placement, adjust the offset of the
|
|
325
400
|
// floating element itself. This stops `shift()` from taking action, but can
|
|
326
401
|
// be worked around by calling it again after the `arrow()` if desired.
|
|
327
|
-
const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min ?
|
|
328
|
-
const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
|
|
402
|
+
const shouldAddOffset = 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 ? min$1 - center : max - center : 0;
|
|
329
404
|
return {
|
|
330
405
|
[axis]: coords[axis] - alignmentOffset,
|
|
331
406
|
data: {
|
|
332
407
|
[axis]: offset,
|
|
333
|
-
centerOffset: center - offset
|
|
408
|
+
centerOffset: center - offset + alignmentOffset
|
|
334
409
|
}
|
|
335
410
|
};
|
|
336
411
|
}
|
|
337
412
|
});
|
|
338
413
|
|
|
339
|
-
const oppositeSideMap = {
|
|
340
|
-
left: 'right',
|
|
341
|
-
right: 'left',
|
|
342
|
-
bottom: 'top',
|
|
343
|
-
top: 'bottom'
|
|
344
|
-
};
|
|
345
|
-
function getOppositePlacement(placement) {
|
|
346
|
-
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
function getAlignmentSides(placement, rects, rtl) {
|
|
350
|
-
if (rtl === void 0) {
|
|
351
|
-
rtl = false;
|
|
352
|
-
}
|
|
353
|
-
const alignment = getAlignment(placement);
|
|
354
|
-
const mainAxis = getMainAxisFromPlacement(placement);
|
|
355
|
-
const length = getLengthFromAxis(mainAxis);
|
|
356
|
-
let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
357
|
-
if (rects.reference[length] > rects.floating[length]) {
|
|
358
|
-
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
359
|
-
}
|
|
360
|
-
return {
|
|
361
|
-
main: mainAlignmentSide,
|
|
362
|
-
cross: getOppositePlacement(mainAlignmentSide)
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
const oppositeAlignmentMap = {
|
|
367
|
-
start: 'end',
|
|
368
|
-
end: 'start'
|
|
369
|
-
};
|
|
370
|
-
function getOppositeAlignmentPlacement(placement) {
|
|
371
|
-
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
function getExpandedPlacements(placement) {
|
|
375
|
-
const oppositePlacement = getOppositePlacement(placement);
|
|
376
|
-
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
function getSideList(side, isStart, rtl) {
|
|
380
|
-
const lr = ['left', 'right'];
|
|
381
|
-
const rl = ['right', 'left'];
|
|
382
|
-
const tb = ['top', 'bottom'];
|
|
383
|
-
const bt = ['bottom', 'top'];
|
|
384
|
-
switch (side) {
|
|
385
|
-
case 'top':
|
|
386
|
-
case 'bottom':
|
|
387
|
-
if (rtl) return isStart ? rl : lr;
|
|
388
|
-
return isStart ? lr : rl;
|
|
389
|
-
case 'left':
|
|
390
|
-
case 'right':
|
|
391
|
-
return isStart ? tb : bt;
|
|
392
|
-
default:
|
|
393
|
-
return [];
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
397
|
-
const alignment = getAlignment(placement);
|
|
398
|
-
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
|
399
|
-
if (alignment) {
|
|
400
|
-
list = list.map(side => side + "-" + alignment);
|
|
401
|
-
if (flipAlignment) {
|
|
402
|
-
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
return list;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
414
|
/**
|
|
409
415
|
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
410
416
|
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
@@ -436,7 +442,7 @@ const flip = function (options) {
|
|
|
436
442
|
fallbackAxisSideDirection = 'none',
|
|
437
443
|
flipAlignment = true,
|
|
438
444
|
...detectOverflowOptions
|
|
439
|
-
} = options;
|
|
445
|
+
} = evaluate(options, state);
|
|
440
446
|
const side = getSide(placement);
|
|
441
447
|
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
442
448
|
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
@@ -452,11 +458,8 @@ const flip = function (options) {
|
|
|
452
458
|
overflows.push(overflow[side]);
|
|
453
459
|
}
|
|
454
460
|
if (checkCrossAxis) {
|
|
455
|
-
const
|
|
456
|
-
|
|
457
|
-
cross
|
|
458
|
-
} = getAlignmentSides(placement, rects, rtl);
|
|
459
|
-
overflows.push(overflow[main], overflow[cross]);
|
|
461
|
+
const sides = getAlignmentSides(placement, rects, rtl);
|
|
462
|
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
460
463
|
}
|
|
461
464
|
overflowsData = [...overflowsData, {
|
|
462
465
|
placement,
|
|
@@ -515,7 +518,9 @@ const flip = function (options) {
|
|
|
515
518
|
};
|
|
516
519
|
};
|
|
517
520
|
|
|
518
|
-
|
|
521
|
+
// For type backwards-compatibility, the `OffsetOptions` type was also
|
|
522
|
+
// Derivable.
|
|
523
|
+
async function convertValueToCoords(state, options) {
|
|
519
524
|
const {
|
|
520
525
|
placement,
|
|
521
526
|
platform,
|
|
@@ -524,10 +529,10 @@ async function convertValueToCoords(state, value) {
|
|
|
524
529
|
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
525
530
|
const side = getSide(placement);
|
|
526
531
|
const alignment = getAlignment(placement);
|
|
527
|
-
const isVertical =
|
|
532
|
+
const isVertical = getSideAxis(placement) === 'y';
|
|
528
533
|
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
|
529
534
|
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
530
|
-
const rawValue =
|
|
535
|
+
const rawValue = evaluate(options, state);
|
|
531
536
|
|
|
532
537
|
// eslint-disable-next-line prefer-const
|
|
533
538
|
let {
|
|
@@ -563,19 +568,19 @@ async function convertValueToCoords(state, value) {
|
|
|
563
568
|
* object may be passed.
|
|
564
569
|
* @see https://floating-ui.com/docs/offset
|
|
565
570
|
*/
|
|
566
|
-
const offset = function (
|
|
567
|
-
if (
|
|
568
|
-
|
|
571
|
+
const offset = function (options) {
|
|
572
|
+
if (options === void 0) {
|
|
573
|
+
options = 0;
|
|
569
574
|
}
|
|
570
575
|
return {
|
|
571
576
|
name: 'offset',
|
|
572
|
-
options
|
|
577
|
+
options,
|
|
573
578
|
async fn(state) {
|
|
574
579
|
const {
|
|
575
580
|
x,
|
|
576
581
|
y
|
|
577
582
|
} = state;
|
|
578
|
-
const diffCoords = await convertValueToCoords(state,
|
|
583
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
579
584
|
return {
|
|
580
585
|
x: x + diffCoords.x,
|
|
581
586
|
y: y + diffCoords.y,
|
|
@@ -585,10 +590,6 @@ const offset = function (value) {
|
|
|
585
590
|
};
|
|
586
591
|
};
|
|
587
592
|
|
|
588
|
-
function getCrossAxis(axis) {
|
|
589
|
-
return axis === 'x' ? 'y' : 'x';
|
|
590
|
-
}
|
|
591
|
-
|
|
592
593
|
/**
|
|
593
594
|
* Optimizes the visibility of the floating element by shifting it in order to
|
|
594
595
|
* keep it in view when it will overflow the clipping boundary.
|
|
@@ -623,14 +624,14 @@ const shift = function (options) {
|
|
|
623
624
|
}
|
|
624
625
|
},
|
|
625
626
|
...detectOverflowOptions
|
|
626
|
-
} = options;
|
|
627
|
+
} = evaluate(options, state);
|
|
627
628
|
const coords = {
|
|
628
629
|
x,
|
|
629
630
|
y
|
|
630
631
|
};
|
|
631
632
|
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
632
|
-
const
|
|
633
|
-
const
|
|
633
|
+
const crossAxis = getSideAxis(getSide(placement));
|
|
634
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
634
635
|
let mainAxisCoord = coords[mainAxis];
|
|
635
636
|
let crossAxisCoord = coords[crossAxis];
|
|
636
637
|
if (checkMainAxis) {
|
|
@@ -638,14 +639,14 @@ const shift = function (options) {
|
|
|
638
639
|
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
639
640
|
const min = mainAxisCoord + overflow[minSide];
|
|
640
641
|
const max = mainAxisCoord - overflow[maxSide];
|
|
641
|
-
mainAxisCoord =
|
|
642
|
+
mainAxisCoord = clamp(min, mainAxisCoord, max);
|
|
642
643
|
}
|
|
643
644
|
if (checkCrossAxis) {
|
|
644
645
|
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
645
646
|
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
646
647
|
const min = crossAxisCoord + overflow[minSide];
|
|
647
648
|
const max = crossAxisCoord - overflow[maxSide];
|
|
648
|
-
crossAxisCoord =
|
|
649
|
+
crossAxisCoord = clamp(min, crossAxisCoord, max);
|
|
649
650
|
}
|
|
650
651
|
const limitedCoords = limiter.fn({
|
|
651
652
|
...state,
|
|
@@ -683,16 +684,16 @@ const limitShift = function (options) {
|
|
|
683
684
|
offset = 0,
|
|
684
685
|
mainAxis: checkMainAxis = true,
|
|
685
686
|
crossAxis: checkCrossAxis = true
|
|
686
|
-
} = options;
|
|
687
|
+
} = evaluate(options, state);
|
|
687
688
|
const coords = {
|
|
688
689
|
x,
|
|
689
690
|
y
|
|
690
691
|
};
|
|
691
|
-
const
|
|
692
|
-
const
|
|
692
|
+
const crossAxis = getSideAxis(placement);
|
|
693
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
693
694
|
let mainAxisCoord = coords[mainAxis];
|
|
694
695
|
let crossAxisCoord = coords[crossAxis];
|
|
695
|
-
const rawOffset =
|
|
696
|
+
const rawOffset = evaluate(offset, state);
|
|
696
697
|
const computedOffset = typeof rawOffset === 'number' ? {
|
|
697
698
|
mainAxis: rawOffset,
|
|
698
699
|
crossAxis: 0
|
|
@@ -731,48 +732,38 @@ const limitShift = function (options) {
|
|
|
731
732
|
};
|
|
732
733
|
};
|
|
733
734
|
|
|
735
|
+
function getNodeName(node) {
|
|
736
|
+
if (isNode(node)) {
|
|
737
|
+
return (node.nodeName || '').toLowerCase();
|
|
738
|
+
}
|
|
739
|
+
// Mocked nodes in testing environments may not be instances of Node. By
|
|
740
|
+
// returning `#document` an infinite loop won't occur.
|
|
741
|
+
// https://github.com/floating-ui/floating-ui/issues/2317
|
|
742
|
+
return '#document';
|
|
743
|
+
}
|
|
734
744
|
function getWindow(node) {
|
|
735
745
|
var _node$ownerDocument;
|
|
736
|
-
return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
746
|
+
return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
737
747
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
return
|
|
748
|
+
function getDocumentElement(node) {
|
|
749
|
+
var _ref;
|
|
750
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
741
751
|
}
|
|
742
|
-
|
|
743
752
|
function isNode(value) {
|
|
744
|
-
return value instanceof getWindow(value).Node;
|
|
753
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
745
754
|
}
|
|
746
|
-
function
|
|
747
|
-
return
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
let uaString;
|
|
751
|
-
function getUAString() {
|
|
752
|
-
if (uaString) {
|
|
753
|
-
return uaString;
|
|
754
|
-
}
|
|
755
|
-
const uaData = navigator.userAgentData;
|
|
756
|
-
if (uaData && Array.isArray(uaData.brands)) {
|
|
757
|
-
uaString = uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
|
|
758
|
-
return uaString;
|
|
759
|
-
}
|
|
760
|
-
return navigator.userAgent;
|
|
755
|
+
function isElement(value) {
|
|
756
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
761
757
|
}
|
|
762
|
-
|
|
763
758
|
function isHTMLElement(value) {
|
|
764
|
-
return value instanceof getWindow(value).HTMLElement;
|
|
759
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
765
760
|
}
|
|
766
|
-
function
|
|
767
|
-
return value instanceof getWindow(value).Element;
|
|
768
|
-
}
|
|
769
|
-
function isShadowRoot(node) {
|
|
761
|
+
function isShadowRoot(value) {
|
|
770
762
|
// Browsers without `ShadowRoot` support.
|
|
771
763
|
if (typeof ShadowRoot === 'undefined') {
|
|
772
764
|
return false;
|
|
773
765
|
}
|
|
774
|
-
|
|
775
|
-
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
766
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
776
767
|
}
|
|
777
768
|
function isOverflowElement(element) {
|
|
778
769
|
const {
|
|
@@ -780,54 +771,93 @@ function isOverflowElement(element) {
|
|
|
780
771
|
overflowX,
|
|
781
772
|
overflowY,
|
|
782
773
|
display
|
|
783
|
-
} = getComputedStyle
|
|
774
|
+
} = getComputedStyle(element);
|
|
784
775
|
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
|
|
785
776
|
}
|
|
786
777
|
function isTableElement(element) {
|
|
787
778
|
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
788
779
|
}
|
|
789
780
|
function isContainingBlock(element) {
|
|
790
|
-
|
|
791
|
-
const
|
|
792
|
-
const css = getComputedStyle$1(element);
|
|
793
|
-
const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter;
|
|
781
|
+
const webkit = isWebKit();
|
|
782
|
+
const css = getComputedStyle(element);
|
|
794
783
|
|
|
795
|
-
// This is non-exhaustive but covers the most common CSS properties that
|
|
796
|
-
// create a containing block.
|
|
797
784
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
798
|
-
return css.transform !== 'none' || css.perspective !== 'none' || (
|
|
799
|
-
// Add type check for old browsers.
|
|
800
|
-
const contain = css.contain;
|
|
801
|
-
return contain != null ? contain.includes(value) : false;
|
|
802
|
-
});
|
|
785
|
+
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));
|
|
803
786
|
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
// Is Safari.
|
|
819
|
-
return /^((?!chrome|android).)*safari/i.test(getUAString());
|
|
787
|
+
function getContainingBlock(element) {
|
|
788
|
+
let currentNode = getParentNode(element);
|
|
789
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
790
|
+
if (isContainingBlock(currentNode)) {
|
|
791
|
+
return currentNode;
|
|
792
|
+
} else {
|
|
793
|
+
currentNode = getParentNode(currentNode);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
return null;
|
|
797
|
+
}
|
|
798
|
+
function isWebKit() {
|
|
799
|
+
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
|
800
|
+
return CSS.supports('-webkit-backdrop-filter', 'none');
|
|
820
801
|
}
|
|
821
802
|
function isLastTraversableNode(node) {
|
|
822
803
|
return ['html', 'body', '#document'].includes(getNodeName(node));
|
|
823
804
|
}
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
805
|
+
function getComputedStyle(element) {
|
|
806
|
+
return getWindow(element).getComputedStyle(element);
|
|
807
|
+
}
|
|
808
|
+
function getNodeScroll(element) {
|
|
809
|
+
if (isElement(element)) {
|
|
810
|
+
return {
|
|
811
|
+
scrollLeft: element.scrollLeft,
|
|
812
|
+
scrollTop: element.scrollTop
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
return {
|
|
816
|
+
scrollLeft: element.pageXOffset,
|
|
817
|
+
scrollTop: element.pageYOffset
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
function getParentNode(node) {
|
|
821
|
+
if (getNodeName(node) === 'html') {
|
|
822
|
+
return node;
|
|
823
|
+
}
|
|
824
|
+
const result =
|
|
825
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
826
|
+
node.assignedSlot ||
|
|
827
|
+
// DOM Element detected.
|
|
828
|
+
node.parentNode ||
|
|
829
|
+
// ShadowRoot detected.
|
|
830
|
+
isShadowRoot(node) && node.host ||
|
|
831
|
+
// Fallback.
|
|
832
|
+
getDocumentElement(node);
|
|
833
|
+
return isShadowRoot(result) ? result.host : result;
|
|
834
|
+
}
|
|
835
|
+
function getNearestOverflowAncestor(node) {
|
|
836
|
+
const parentNode = getParentNode(node);
|
|
837
|
+
if (isLastTraversableNode(parentNode)) {
|
|
838
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
839
|
+
}
|
|
840
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
841
|
+
return parentNode;
|
|
842
|
+
}
|
|
843
|
+
return getNearestOverflowAncestor(parentNode);
|
|
844
|
+
}
|
|
845
|
+
function getOverflowAncestors(node, list) {
|
|
846
|
+
var _node$ownerDocument2;
|
|
847
|
+
if (list === void 0) {
|
|
848
|
+
list = [];
|
|
849
|
+
}
|
|
850
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
851
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
852
|
+
const win = getWindow(scrollableAncestor);
|
|
853
|
+
if (isBody) {
|
|
854
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
|
|
855
|
+
}
|
|
856
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
|
|
857
|
+
}
|
|
828
858
|
|
|
829
859
|
function getCssDimensions(element) {
|
|
830
|
-
const css = getComputedStyle
|
|
860
|
+
const css = getComputedStyle(element);
|
|
831
861
|
// In testing environments, the `width` and `height` properties are empty
|
|
832
862
|
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
|
833
863
|
let width = parseFloat(css.width) || 0;
|
|
@@ -843,7 +873,7 @@ function getCssDimensions(element) {
|
|
|
843
873
|
return {
|
|
844
874
|
width,
|
|
845
875
|
height,
|
|
846
|
-
|
|
876
|
+
$: shouldFallback
|
|
847
877
|
};
|
|
848
878
|
}
|
|
849
879
|
|
|
@@ -851,23 +881,19 @@ function unwrapElement(element) {
|
|
|
851
881
|
return !isElement(element) ? element.contextElement : element;
|
|
852
882
|
}
|
|
853
883
|
|
|
854
|
-
const FALLBACK_SCALE = {
|
|
855
|
-
x: 1,
|
|
856
|
-
y: 1
|
|
857
|
-
};
|
|
858
884
|
function getScale(element) {
|
|
859
885
|
const domElement = unwrapElement(element);
|
|
860
886
|
if (!isHTMLElement(domElement)) {
|
|
861
|
-
return
|
|
887
|
+
return createCoords(1);
|
|
862
888
|
}
|
|
863
889
|
const rect = domElement.getBoundingClientRect();
|
|
864
890
|
const {
|
|
865
891
|
width,
|
|
866
892
|
height,
|
|
867
|
-
|
|
893
|
+
$
|
|
868
894
|
} = getCssDimensions(domElement);
|
|
869
|
-
let x = (
|
|
870
|
-
let y = (
|
|
895
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
896
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
871
897
|
|
|
872
898
|
// 0, NaN, or Infinity should always fallback to 1.
|
|
873
899
|
|
|
@@ -883,8 +909,28 @@ function getScale(element) {
|
|
|
883
909
|
};
|
|
884
910
|
}
|
|
885
911
|
|
|
912
|
+
const noOffsets = /*#__PURE__*/createCoords(0);
|
|
913
|
+
function getVisualOffsets(element) {
|
|
914
|
+
const win = getWindow(element);
|
|
915
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
916
|
+
return noOffsets;
|
|
917
|
+
}
|
|
918
|
+
return {
|
|
919
|
+
x: win.visualViewport.offsetLeft,
|
|
920
|
+
y: win.visualViewport.offsetTop
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
924
|
+
if (isFixed === void 0) {
|
|
925
|
+
isFixed = false;
|
|
926
|
+
}
|
|
927
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
928
|
+
return false;
|
|
929
|
+
}
|
|
930
|
+
return isFixed;
|
|
931
|
+
}
|
|
932
|
+
|
|
886
933
|
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
887
|
-
var _win$visualViewport, _win$visualViewport2;
|
|
888
934
|
if (includeScale === void 0) {
|
|
889
935
|
includeScale = false;
|
|
890
936
|
}
|
|
@@ -893,7 +939,7 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
893
939
|
}
|
|
894
940
|
const clientRect = element.getBoundingClientRect();
|
|
895
941
|
const domElement = unwrapElement(element);
|
|
896
|
-
let scale =
|
|
942
|
+
let scale = createCoords(1);
|
|
897
943
|
if (includeScale) {
|
|
898
944
|
if (offsetParent) {
|
|
899
945
|
if (isElement(offsetParent)) {
|
|
@@ -903,10 +949,9 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
903
949
|
scale = getScale(element);
|
|
904
950
|
}
|
|
905
951
|
}
|
|
906
|
-
const
|
|
907
|
-
|
|
908
|
-
let
|
|
909
|
-
let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y;
|
|
952
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
953
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
954
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
910
955
|
let width = clientRect.width / scale.x;
|
|
911
956
|
let height = clientRect.height / scale.y;
|
|
912
957
|
if (domElement) {
|
|
@@ -917,14 +962,14 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
917
962
|
const iframeScale = getScale(currentIFrame);
|
|
918
963
|
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
919
964
|
const css = getComputedStyle(currentIFrame);
|
|
920
|
-
iframeRect.
|
|
921
|
-
iframeRect.
|
|
965
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
966
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
922
967
|
x *= iframeScale.x;
|
|
923
968
|
y *= iframeScale.y;
|
|
924
969
|
width *= iframeScale.x;
|
|
925
970
|
height *= iframeScale.y;
|
|
926
|
-
x +=
|
|
927
|
-
y +=
|
|
971
|
+
x += left;
|
|
972
|
+
y += top;
|
|
928
973
|
currentIFrame = getWindow(currentIFrame).frameElement;
|
|
929
974
|
}
|
|
930
975
|
}
|
|
@@ -936,23 +981,6 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
936
981
|
});
|
|
937
982
|
}
|
|
938
983
|
|
|
939
|
-
function getDocumentElement(node) {
|
|
940
|
-
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
function getNodeScroll(element) {
|
|
944
|
-
if (isElement(element)) {
|
|
945
|
-
return {
|
|
946
|
-
scrollLeft: element.scrollLeft,
|
|
947
|
-
scrollTop: element.scrollTop
|
|
948
|
-
};
|
|
949
|
-
}
|
|
950
|
-
return {
|
|
951
|
-
scrollLeft: element.pageXOffset,
|
|
952
|
-
scrollTop: element.pageYOffset
|
|
953
|
-
};
|
|
954
|
-
}
|
|
955
|
-
|
|
956
984
|
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
957
985
|
let {
|
|
958
986
|
rect,
|
|
@@ -968,14 +996,8 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
|
968
996
|
scrollLeft: 0,
|
|
969
997
|
scrollTop: 0
|
|
970
998
|
};
|
|
971
|
-
let scale =
|
|
972
|
-
|
|
973
|
-
y: 1
|
|
974
|
-
};
|
|
975
|
-
const offsets = {
|
|
976
|
-
x: 0,
|
|
977
|
-
y: 0
|
|
978
|
-
};
|
|
999
|
+
let scale = createCoords(1);
|
|
1000
|
+
const offsets = createCoords(0);
|
|
979
1001
|
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
980
1002
|
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
981
1003
|
scroll = getNodeScroll(offsetParent);
|
|
@@ -995,6 +1017,10 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
|
995
1017
|
};
|
|
996
1018
|
}
|
|
997
1019
|
|
|
1020
|
+
function getClientRects(element) {
|
|
1021
|
+
return Array.from(element.getClientRects());
|
|
1022
|
+
}
|
|
1023
|
+
|
|
998
1024
|
function getWindowScrollBarX(element) {
|
|
999
1025
|
// If <html> has a CSS width greater than the viewport, then this will be
|
|
1000
1026
|
// incorrect for RTL.
|
|
@@ -1011,7 +1037,7 @@ function getDocumentRect(element) {
|
|
|
1011
1037
|
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
1012
1038
|
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
1013
1039
|
const y = -scroll.scrollTop;
|
|
1014
|
-
if (getComputedStyle
|
|
1040
|
+
if (getComputedStyle(body).direction === 'rtl') {
|
|
1015
1041
|
x += max(html.clientWidth, body.clientWidth) - width;
|
|
1016
1042
|
}
|
|
1017
1043
|
return {
|
|
@@ -1022,49 +1048,6 @@ function getDocumentRect(element) {
|
|
|
1022
1048
|
};
|
|
1023
1049
|
}
|
|
1024
1050
|
|
|
1025
|
-
function getParentNode(node) {
|
|
1026
|
-
if (getNodeName(node) === 'html') {
|
|
1027
|
-
return node;
|
|
1028
|
-
}
|
|
1029
|
-
const result =
|
|
1030
|
-
// Step into the shadow DOM of the parent of a slotted node.
|
|
1031
|
-
node.assignedSlot ||
|
|
1032
|
-
// DOM Element detected.
|
|
1033
|
-
node.parentNode ||
|
|
1034
|
-
// ShadowRoot detected.
|
|
1035
|
-
isShadowRoot(node) && node.host ||
|
|
1036
|
-
// Fallback.
|
|
1037
|
-
getDocumentElement(node);
|
|
1038
|
-
return isShadowRoot(result) ? result.host : result;
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
function getNearestOverflowAncestor(node) {
|
|
1042
|
-
const parentNode = getParentNode(node);
|
|
1043
|
-
if (isLastTraversableNode(parentNode)) {
|
|
1044
|
-
// `getParentNode` will never return a `Document` due to the fallback
|
|
1045
|
-
// check, so it's either the <html> or <body> element.
|
|
1046
|
-
return parentNode.ownerDocument.body;
|
|
1047
|
-
}
|
|
1048
|
-
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
1049
|
-
return parentNode;
|
|
1050
|
-
}
|
|
1051
|
-
return getNearestOverflowAncestor(parentNode);
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
function getOverflowAncestors(node, list) {
|
|
1055
|
-
var _node$ownerDocument;
|
|
1056
|
-
if (list === void 0) {
|
|
1057
|
-
list = [];
|
|
1058
|
-
}
|
|
1059
|
-
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
1060
|
-
const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
|
|
1061
|
-
const win = getWindow(scrollableAncestor);
|
|
1062
|
-
if (isBody) {
|
|
1063
|
-
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
|
|
1064
|
-
}
|
|
1065
|
-
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
1051
|
function getViewportRect(element, strategy) {
|
|
1069
1052
|
const win = getWindow(element);
|
|
1070
1053
|
const html = getDocumentElement(element);
|
|
@@ -1076,7 +1059,7 @@ function getViewportRect(element, strategy) {
|
|
|
1076
1059
|
if (visualViewport) {
|
|
1077
1060
|
width = visualViewport.width;
|
|
1078
1061
|
height = visualViewport.height;
|
|
1079
|
-
const visualViewportBased =
|
|
1062
|
+
const visualViewportBased = isWebKit();
|
|
1080
1063
|
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
|
1081
1064
|
x = visualViewport.offsetLeft;
|
|
1082
1065
|
y = visualViewport.offsetTop;
|
|
@@ -1095,10 +1078,7 @@ function getInnerBoundingClientRect(element, strategy) {
|
|
|
1095
1078
|
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
|
1096
1079
|
const top = clientRect.top + element.clientTop;
|
|
1097
1080
|
const left = clientRect.left + element.clientLeft;
|
|
1098
|
-
const scale = isHTMLElement(element) ? getScale(element) :
|
|
1099
|
-
x: 1,
|
|
1100
|
-
y: 1
|
|
1101
|
-
};
|
|
1081
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
1102
1082
|
const width = element.clientWidth * scale.x;
|
|
1103
1083
|
const height = element.clientHeight * scale.y;
|
|
1104
1084
|
const x = left * scale.x;
|
|
@@ -1119,16 +1099,12 @@ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy)
|
|
|
1119
1099
|
} else if (isElement(clippingAncestor)) {
|
|
1120
1100
|
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
1121
1101
|
} else {
|
|
1122
|
-
const
|
|
1123
|
-
|
|
1102
|
+
const visualOffsets = getVisualOffsets(element);
|
|
1103
|
+
rect = {
|
|
1104
|
+
...clippingAncestor,
|
|
1105
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
1106
|
+
y: clippingAncestor.y - visualOffsets.y
|
|
1124
1107
|
};
|
|
1125
|
-
if (isClientRectVisualViewportBased()) {
|
|
1126
|
-
var _win$visualViewport, _win$visualViewport2;
|
|
1127
|
-
const win = getWindow(element);
|
|
1128
|
-
mutableRect.x -= ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0;
|
|
1129
|
-
mutableRect.y -= ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0;
|
|
1130
|
-
}
|
|
1131
|
-
rect = mutableRect;
|
|
1132
1108
|
}
|
|
1133
1109
|
return rectToClientRect(rect);
|
|
1134
1110
|
}
|
|
@@ -1137,7 +1113,7 @@ function hasFixedPositionAncestor(element, stopNode) {
|
|
|
1137
1113
|
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
1138
1114
|
return false;
|
|
1139
1115
|
}
|
|
1140
|
-
return getComputedStyle
|
|
1116
|
+
return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
|
1141
1117
|
}
|
|
1142
1118
|
|
|
1143
1119
|
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
|
@@ -1150,12 +1126,12 @@ function getClippingElementAncestors(element, cache) {
|
|
|
1150
1126
|
}
|
|
1151
1127
|
let result = getOverflowAncestors(element).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
|
1152
1128
|
let currentContainingBlockComputedStyle = null;
|
|
1153
|
-
const elementIsFixed = getComputedStyle
|
|
1129
|
+
const elementIsFixed = getComputedStyle(element).position === 'fixed';
|
|
1154
1130
|
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
1155
1131
|
|
|
1156
1132
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1157
1133
|
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1158
|
-
const computedStyle = getComputedStyle
|
|
1134
|
+
const computedStyle = getComputedStyle(currentNode);
|
|
1159
1135
|
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
1160
1136
|
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
|
1161
1137
|
currentContainingBlockComputedStyle = null;
|
|
@@ -1206,8 +1182,38 @@ function getDimensions(element) {
|
|
|
1206
1182
|
return getCssDimensions(element);
|
|
1207
1183
|
}
|
|
1208
1184
|
|
|
1185
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1186
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1187
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1188
|
+
const isFixed = strategy === 'fixed';
|
|
1189
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
1190
|
+
let scroll = {
|
|
1191
|
+
scrollLeft: 0,
|
|
1192
|
+
scrollTop: 0
|
|
1193
|
+
};
|
|
1194
|
+
const offsets = createCoords(0);
|
|
1195
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1196
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1197
|
+
scroll = getNodeScroll(offsetParent);
|
|
1198
|
+
}
|
|
1199
|
+
if (isOffsetParentAnElement) {
|
|
1200
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
1201
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1202
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1203
|
+
} else if (documentElement) {
|
|
1204
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
return {
|
|
1208
|
+
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
1209
|
+
y: rect.top + scroll.scrollTop - offsets.y,
|
|
1210
|
+
width: rect.width,
|
|
1211
|
+
height: rect.height
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1209
1215
|
function getTrueOffsetParent(element, polyfill) {
|
|
1210
|
-
if (!isHTMLElement(element) || getComputedStyle
|
|
1216
|
+
if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
|
|
1211
1217
|
return null;
|
|
1212
1218
|
}
|
|
1213
1219
|
if (polyfill) {
|
|
@@ -1215,17 +1221,6 @@ function getTrueOffsetParent(element, polyfill) {
|
|
|
1215
1221
|
}
|
|
1216
1222
|
return element.offsetParent;
|
|
1217
1223
|
}
|
|
1218
|
-
function getContainingBlock(element) {
|
|
1219
|
-
let currentNode = getParentNode(element);
|
|
1220
|
-
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1221
|
-
if (isContainingBlock(currentNode)) {
|
|
1222
|
-
return currentNode;
|
|
1223
|
-
} else {
|
|
1224
|
-
currentNode = getParentNode(currentNode);
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
return null;
|
|
1228
|
-
}
|
|
1229
1224
|
|
|
1230
1225
|
// Gets the closest ancestor positioned element. Handles some edge cases,
|
|
1231
1226
|
// such as table ancestors and cross browser bugs.
|
|
@@ -1235,76 +1230,124 @@ function getOffsetParent(element, polyfill) {
|
|
|
1235
1230
|
return window;
|
|
1236
1231
|
}
|
|
1237
1232
|
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1238
|
-
while (offsetParent && isTableElement(offsetParent) && getComputedStyle
|
|
1233
|
+
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
|
|
1239
1234
|
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
1240
1235
|
}
|
|
1241
|
-
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle
|
|
1236
|
+
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
|
|
1242
1237
|
return window;
|
|
1243
1238
|
}
|
|
1244
1239
|
return offsetParent || getContainingBlock(element) || window;
|
|
1245
1240
|
}
|
|
1246
1241
|
|
|
1247
|
-
function
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
const offsets = {
|
|
1256
|
-
x: 0,
|
|
1257
|
-
y: 0
|
|
1258
|
-
};
|
|
1259
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
1260
|
-
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1261
|
-
scroll = getNodeScroll(offsetParent);
|
|
1262
|
-
}
|
|
1263
|
-
if (isHTMLElement(offsetParent)) {
|
|
1264
|
-
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
1265
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1266
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1267
|
-
} else if (documentElement) {
|
|
1268
|
-
offsets.x = getWindowScrollBarX(documentElement);
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1242
|
+
const getElementRects = async function (_ref) {
|
|
1243
|
+
let {
|
|
1244
|
+
reference,
|
|
1245
|
+
floating,
|
|
1246
|
+
strategy
|
|
1247
|
+
} = _ref;
|
|
1248
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1249
|
+
const getDimensionsFn = this.getDimensions;
|
|
1271
1250
|
return {
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1251
|
+
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
1252
|
+
floating: {
|
|
1253
|
+
x: 0,
|
|
1254
|
+
y: 0,
|
|
1255
|
+
...(await getDimensionsFn(floating))
|
|
1256
|
+
}
|
|
1276
1257
|
};
|
|
1258
|
+
};
|
|
1259
|
+
|
|
1260
|
+
function isRTL(element) {
|
|
1261
|
+
return getComputedStyle(element).direction === 'rtl';
|
|
1277
1262
|
}
|
|
1278
1263
|
|
|
1279
1264
|
const platform = {
|
|
1280
|
-
getClippingRect,
|
|
1281
1265
|
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1282
|
-
isElement,
|
|
1283
|
-
getDimensions,
|
|
1284
|
-
getOffsetParent,
|
|
1285
1266
|
getDocumentElement,
|
|
1267
|
+
getClippingRect,
|
|
1268
|
+
getOffsetParent,
|
|
1269
|
+
getElementRects,
|
|
1270
|
+
getClientRects,
|
|
1271
|
+
getDimensions,
|
|
1286
1272
|
getScale,
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
reference,
|
|
1290
|
-
floating,
|
|
1291
|
-
strategy
|
|
1292
|
-
} = _ref;
|
|
1293
|
-
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1294
|
-
const getDimensionsFn = this.getDimensions;
|
|
1295
|
-
return {
|
|
1296
|
-
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
1297
|
-
floating: {
|
|
1298
|
-
x: 0,
|
|
1299
|
-
y: 0,
|
|
1300
|
-
...(await getDimensionsFn(floating))
|
|
1301
|
-
}
|
|
1302
|
-
};
|
|
1303
|
-
},
|
|
1304
|
-
getClientRects: element => Array.from(element.getClientRects()),
|
|
1305
|
-
isRTL: element => getComputedStyle$1(element).direction === 'rtl'
|
|
1273
|
+
isElement,
|
|
1274
|
+
isRTL
|
|
1306
1275
|
};
|
|
1307
1276
|
|
|
1277
|
+
// https://samthor.au/2021/observing-dom/
|
|
1278
|
+
function observeMove(element, onMove) {
|
|
1279
|
+
let io = null;
|
|
1280
|
+
let timeoutId;
|
|
1281
|
+
const root = getDocumentElement(element);
|
|
1282
|
+
function cleanup() {
|
|
1283
|
+
clearTimeout(timeoutId);
|
|
1284
|
+
io && io.disconnect();
|
|
1285
|
+
io = null;
|
|
1286
|
+
}
|
|
1287
|
+
function refresh(skip, threshold) {
|
|
1288
|
+
if (skip === void 0) {
|
|
1289
|
+
skip = false;
|
|
1290
|
+
}
|
|
1291
|
+
if (threshold === void 0) {
|
|
1292
|
+
threshold = 1;
|
|
1293
|
+
}
|
|
1294
|
+
cleanup();
|
|
1295
|
+
const {
|
|
1296
|
+
left,
|
|
1297
|
+
top,
|
|
1298
|
+
width,
|
|
1299
|
+
height
|
|
1300
|
+
} = element.getBoundingClientRect();
|
|
1301
|
+
if (!skip) {
|
|
1302
|
+
onMove();
|
|
1303
|
+
}
|
|
1304
|
+
if (!width || !height) {
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
const insetTop = floor(top);
|
|
1308
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
|
1309
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
|
1310
|
+
const insetLeft = floor(left);
|
|
1311
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
1312
|
+
const options = {
|
|
1313
|
+
rootMargin,
|
|
1314
|
+
threshold: max(0, min(1, threshold)) || 1
|
|
1315
|
+
};
|
|
1316
|
+
let isFirstUpdate = true;
|
|
1317
|
+
function handleObserve(entries) {
|
|
1318
|
+
const ratio = entries[0].intersectionRatio;
|
|
1319
|
+
if (ratio !== threshold) {
|
|
1320
|
+
if (!isFirstUpdate) {
|
|
1321
|
+
return refresh();
|
|
1322
|
+
}
|
|
1323
|
+
if (!ratio) {
|
|
1324
|
+
timeoutId = setTimeout(() => {
|
|
1325
|
+
refresh(false, 1e-7);
|
|
1326
|
+
}, 100);
|
|
1327
|
+
} else {
|
|
1328
|
+
refresh(false, ratio);
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
isFirstUpdate = false;
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
// Older browsers don't support a `document` as the root and will throw an
|
|
1335
|
+
// error.
|
|
1336
|
+
try {
|
|
1337
|
+
io = new IntersectionObserver(handleObserve, {
|
|
1338
|
+
...options,
|
|
1339
|
+
// Handle <iframe>s
|
|
1340
|
+
root: root.ownerDocument
|
|
1341
|
+
});
|
|
1342
|
+
} catch (e) {
|
|
1343
|
+
io = new IntersectionObserver(handleObserve, options);
|
|
1344
|
+
}
|
|
1345
|
+
io.observe(element);
|
|
1346
|
+
}
|
|
1347
|
+
refresh(true);
|
|
1348
|
+
return cleanup;
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1308
1351
|
/**
|
|
1309
1352
|
* Automatically updates the position of the floating element when necessary.
|
|
1310
1353
|
* Should only be called when the floating element is mounted on the DOM or
|
|
@@ -1320,30 +1363,39 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
1320
1363
|
const {
|
|
1321
1364
|
ancestorScroll = true,
|
|
1322
1365
|
ancestorResize = true,
|
|
1323
|
-
elementResize =
|
|
1366
|
+
elementResize = typeof ResizeObserver === 'function',
|
|
1367
|
+
layoutShift = typeof IntersectionObserver === 'function',
|
|
1324
1368
|
animationFrame = false
|
|
1325
1369
|
} = options;
|
|
1326
|
-
const
|
|
1370
|
+
const referenceEl = unwrapElement(reference);
|
|
1371
|
+
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
|
|
1327
1372
|
ancestors.forEach(ancestor => {
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
ancestor.addEventListener('scroll', update, {
|
|
1332
|
-
passive: true
|
|
1333
|
-
});
|
|
1334
|
-
}
|
|
1373
|
+
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
1374
|
+
passive: true
|
|
1375
|
+
});
|
|
1335
1376
|
ancestorResize && ancestor.addEventListener('resize', update);
|
|
1336
1377
|
});
|
|
1337
|
-
|
|
1378
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
1379
|
+
let reobserveFrame = -1;
|
|
1380
|
+
let resizeObserver = null;
|
|
1338
1381
|
if (elementResize) {
|
|
1339
|
-
|
|
1382
|
+
resizeObserver = new ResizeObserver(_ref => {
|
|
1383
|
+
let [firstEntry] = _ref;
|
|
1384
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
|
1385
|
+
// Prevent update loops when using the `size` middleware.
|
|
1386
|
+
// https://github.com/floating-ui/floating-ui/issues/1740
|
|
1387
|
+
resizeObserver.unobserve(floating);
|
|
1388
|
+
cancelAnimationFrame(reobserveFrame);
|
|
1389
|
+
reobserveFrame = requestAnimationFrame(() => {
|
|
1390
|
+
resizeObserver && resizeObserver.observe(floating);
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1340
1393
|
update();
|
|
1341
1394
|
});
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
observer.observe(reference.contextElement);
|
|
1395
|
+
if (referenceEl && !animationFrame) {
|
|
1396
|
+
resizeObserver.observe(referenceEl);
|
|
1345
1397
|
}
|
|
1346
|
-
|
|
1398
|
+
resizeObserver.observe(floating);
|
|
1347
1399
|
}
|
|
1348
1400
|
let frameId;
|
|
1349
1401
|
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
@@ -1360,13 +1412,13 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
1360
1412
|
}
|
|
1361
1413
|
update();
|
|
1362
1414
|
return () => {
|
|
1363
|
-
var _observer;
|
|
1364
1415
|
ancestors.forEach(ancestor => {
|
|
1365
1416
|
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
1366
1417
|
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
1367
1418
|
});
|
|
1368
|
-
|
|
1369
|
-
|
|
1419
|
+
cleanupIo && cleanupIo();
|
|
1420
|
+
resizeObserver && resizeObserver.disconnect();
|
|
1421
|
+
resizeObserver = null;
|
|
1370
1422
|
if (animationFrame) {
|
|
1371
1423
|
cancelAnimationFrame(frameId);
|
|
1372
1424
|
}
|
|
@@ -1399,4 +1451,4 @@ const computePosition = (reference, floating, options) => {
|
|
|
1399
1451
|
|
|
1400
1452
|
export { autoUpdate as a, arrow as b, computePosition as c, flip as f, limitShift as l, offset as o, shift as s };
|
|
1401
1453
|
|
|
1402
|
-
//# sourceMappingURL=floating-ui.dom.esm-
|
|
1454
|
+
//# sourceMappingURL=floating-ui.dom.esm-61986f35.js.map
|