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