@siemens/ix 1.2.1 → 1.3.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/alignment-24ae2e63.js +1372 -0
- package/dist/cjs/{index-354a8c3d.js → index-17eb8998.js} +4 -3
- package/dist/cjs/index.cjs.js +5 -2
- package/dist/cjs/ix-animated-tab_2.cjs.entry.js +1 -1
- package/dist/cjs/ix-application-header.cjs.entry.js +1 -1
- package/dist/cjs/ix-basic-navigation.cjs.entry.js +1 -1
- package/dist/cjs/ix-blind.cjs.entry.js +1 -1
- package/dist/cjs/ix-breadcrumb_2.cjs.entry.js +1 -1
- package/dist/cjs/ix-button.cjs.entry.js +5 -3
- package/dist/cjs/ix-category-filter.cjs.entry.js +9 -9
- package/dist/cjs/ix-chip.cjs.entry.js +22 -9
- package/dist/cjs/ix-counter-pill.cjs.entry.js +2 -2
- package/dist/cjs/ix-date-picker_2.cjs.entry.js +1 -1
- package/dist/cjs/ix-date-time-card.cjs.entry.js +1 -1
- package/dist/cjs/ix-datetime-picker.cjs.entry.js +1 -1
- package/dist/cjs/ix-drawer.cjs.entry.js +1 -1
- package/dist/cjs/ix-dropdown-button.cjs.entry.js +40 -0
- package/dist/cjs/ix-dropdown_2.cjs.entry.js +88 -42
- package/dist/cjs/ix-event-list_2.cjs.entry.js +1 -1
- package/dist/cjs/ix-expanding-search.cjs.entry.js +3 -3
- package/dist/cjs/ix-filter-chip.cjs.entry.js +1 -1
- package/dist/cjs/ix-flip-tile_2.cjs.entry.js +1 -1
- package/dist/cjs/ix-group-context-menu.cjs.entry.js +1 -1
- package/dist/cjs/ix-group_3.cjs.entry.js +1 -1
- package/dist/cjs/ix-icon-button.cjs.entry.js +3 -3
- package/dist/cjs/ix-icon.cjs.entry.js +1 -1
- package/dist/cjs/ix-input-group.cjs.entry.js +1 -1
- package/dist/cjs/ix-kpi.cjs.entry.js +1 -1
- package/dist/cjs/ix-map-navigation_2.cjs.entry.js +5 -4
- package/dist/cjs/ix-menu_9.cjs.entry.js +14 -95
- package/dist/cjs/ix-message-bar.cjs.entry.js +1 -1
- package/dist/cjs/ix-modal-example.cjs.entry.js +1 -1
- package/dist/cjs/ix-modal_2.cjs.entry.js +2 -2
- package/dist/cjs/ix-pill.cjs.entry.js +6 -3
- package/dist/cjs/ix-select_2.cjs.entry.js +36 -15
- package/dist/cjs/ix-spinner.cjs.entry.js +1 -1
- package/dist/cjs/ix-split-button_2.cjs.entry.js +7 -36
- package/dist/cjs/ix-tab-item.cjs.entry.js +1 -1
- package/dist/cjs/ix-tabs.cjs.entry.js +1 -1
- package/dist/cjs/ix-tile.cjs.entry.js +1 -1
- package/dist/cjs/ix-toast_2.cjs.entry.js +1 -1
- package/dist/cjs/ix-toggle.cjs.entry.js +1 -1
- package/dist/cjs/ix-tree_2.cjs.entry.js +1 -1
- package/dist/cjs/ix-upload.cjs.entry.js +1 -1
- package/dist/cjs/ix-validation-tooltip.cjs.entry.js +72 -27
- package/dist/cjs/ix-workflow-step_2.cjs.entry.js +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{modal-a5b22d3f.js → modal-dda2f6be.js} +9 -3
- package/dist/cjs/my-component.cjs.entry.js +1 -1
- package/dist/cjs/siemens-ix.cjs.js +2 -2
- package/dist/cjs/theme-switcher-6b45e082.js +92 -0
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/button/button.css +1 -1
- package/dist/collection/components/button/button.js +4 -2
- package/dist/collection/components/category-filter/category-filter.css +4 -4
- package/dist/collection/components/category-filter/category-filter.js +7 -7
- package/dist/collection/components/chip/chip.css +20 -0
- package/dist/collection/components/chip/chip.js +22 -9
- package/dist/collection/components/counter-pill/counter-pill.css +10 -0
- package/dist/collection/components/dropdown/alignment.js +9 -0
- package/dist/collection/components/dropdown/dropdown.css +1 -0
- package/dist/collection/components/dropdown/dropdown.js +113 -50
- package/dist/collection/components/dropdown/placement.js +1 -0
- package/dist/collection/components/dropdown-button/dropdown-button.css +81 -0
- package/dist/collection/components/dropdown-button/dropdown-button.js +191 -0
- package/dist/collection/components/expanding-search/expanding-search.css +1 -0
- package/dist/collection/components/expanding-search/expanding-search.js +1 -1
- package/dist/collection/components/icon-button/icon-button.css +3 -30
- package/dist/collection/components/icon-button/icon-button.js +2 -2
- package/dist/collection/components/map-navigation/map-navigation.js +3 -2
- package/dist/collection/components/map-navigation-overlay/map-navigation-overlay.css +9 -4
- package/dist/collection/components/menu/menu.css +1 -1
- package/dist/collection/components/menu/menu.js +6 -21
- package/dist/collection/components/menu-avatar/menu-avatar.js +4 -30
- package/dist/collection/components/modal/modal.css +1 -0
- package/dist/collection/components/modal/modal.js +7 -1
- package/dist/collection/components/pill/pill.css +10 -0
- package/dist/collection/components/pill/pill.js +4 -1
- package/dist/collection/components/select/select.css +0 -3
- package/dist/collection/components/select/select.js +13 -12
- package/dist/collection/components/select-item/events.js +16 -0
- package/dist/collection/components/select-item/select-item.js +23 -4
- package/dist/collection/components/split-button/split-button.js +7 -36
- package/dist/collection/components/tree/tree.js +1 -1
- package/dist/collection/components/utils/theme-switcher.js +86 -0
- package/dist/collection/components/validation-tooltip/validation-tooltip.css +4 -24
- package/dist/collection/components/validation-tooltip/validation-tooltip.js +75 -28
- package/dist/collection/exports.js +1 -0
- package/dist/components/alignment.js +1363 -0
- package/dist/components/button.js +5 -3
- package/dist/components/dropdown.js +88 -41
- package/dist/components/icon-button.js +3 -3
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +2 -1
- package/dist/components/ix-category-filter.js +18 -12
- package/dist/components/ix-chip.js +21 -8
- package/dist/components/ix-counter-pill.js +1 -1
- package/dist/components/ix-dropdown-button.d.ts +11 -0
- package/dist/components/ix-dropdown-button.js +86 -0
- package/dist/components/ix-expanding-search.js +2 -2
- package/dist/components/ix-map-navigation.js +3 -2
- package/dist/components/ix-menu-avatar.js +6 -19
- package/dist/components/ix-menu.js +93 -46
- package/dist/components/ix-pill.js +5 -2
- package/dist/components/ix-select.js +9 -14
- package/dist/components/ix-split-button.js +6 -35
- package/dist/components/ix-validation-tooltip.js +74 -27
- package/dist/components/map-navigation-overlay.js +1 -1
- package/dist/components/modal.js +8 -2
- package/dist/components/select-item.js +27 -1
- package/dist/esm/alignment-f63c1b89.js +1363 -0
- package/dist/esm/{index-7746a810.js → index-6f4f3582.js} +5 -3
- package/dist/esm/index.js +3 -2
- package/dist/esm/ix-animated-tab_2.entry.js +1 -1
- package/dist/esm/ix-application-header.entry.js +1 -1
- package/dist/esm/ix-basic-navigation.entry.js +1 -1
- package/dist/esm/ix-blind.entry.js +1 -1
- package/dist/esm/ix-breadcrumb_2.entry.js +1 -1
- package/dist/esm/ix-button.entry.js +5 -3
- package/dist/esm/ix-category-filter.entry.js +9 -9
- package/dist/esm/ix-chip.entry.js +22 -9
- package/dist/esm/ix-counter-pill.entry.js +2 -2
- package/dist/esm/ix-date-picker_2.entry.js +1 -1
- package/dist/esm/ix-date-time-card.entry.js +1 -1
- package/dist/esm/ix-datetime-picker.entry.js +1 -1
- package/dist/esm/ix-drawer.entry.js +1 -1
- package/dist/esm/ix-dropdown-button.entry.js +36 -0
- package/dist/esm/ix-dropdown_2.entry.js +88 -42
- package/dist/esm/ix-event-list_2.entry.js +1 -1
- package/dist/esm/ix-expanding-search.entry.js +3 -3
- package/dist/esm/ix-filter-chip.entry.js +1 -1
- package/dist/esm/ix-flip-tile_2.entry.js +1 -1
- package/dist/esm/ix-group-context-menu.entry.js +1 -1
- package/dist/esm/ix-group_3.entry.js +1 -1
- package/dist/esm/ix-icon-button.entry.js +3 -3
- package/dist/esm/ix-icon.entry.js +1 -1
- package/dist/esm/ix-input-group.entry.js +1 -1
- package/dist/esm/ix-kpi.entry.js +1 -1
- package/dist/esm/ix-map-navigation_2.entry.js +5 -4
- package/dist/esm/ix-menu_9.entry.js +14 -95
- package/dist/esm/ix-message-bar.entry.js +1 -1
- package/dist/esm/ix-modal-example.entry.js +1 -1
- package/dist/esm/ix-modal_2.entry.js +2 -2
- package/dist/esm/ix-pill.entry.js +6 -3
- package/dist/esm/ix-select_2.entry.js +36 -15
- package/dist/esm/ix-spinner.entry.js +1 -1
- package/dist/esm/ix-split-button_2.entry.js +7 -36
- package/dist/esm/ix-tab-item.entry.js +1 -1
- package/dist/esm/ix-tabs.entry.js +1 -1
- package/dist/esm/ix-tile.entry.js +1 -1
- package/dist/esm/ix-toast_2.entry.js +1 -1
- package/dist/esm/ix-toggle.entry.js +1 -1
- package/dist/esm/ix-tree_2.entry.js +1 -1
- package/dist/esm/ix-upload.entry.js +1 -1
- package/dist/esm/ix-validation-tooltip.entry.js +72 -27
- package/dist/esm/ix-workflow-step_2.entry.js +1 -1
- package/dist/esm/loader.js +2 -2
- package/dist/esm/{modal-9c9eaf8e.js → modal-df0a62f2.js} +9 -3
- package/dist/esm/my-component.entry.js +1 -1
- package/dist/esm/siemens-ix.js +2 -2
- package/dist/esm/theme-switcher-dce1aaec.js +89 -0
- package/dist/siemens-ix/index.esm.js +1 -1
- package/dist/siemens-ix/p-03d38416.entry.js +1 -0
- package/dist/siemens-ix/{p-5e4c3828.js → p-05c16b94.js} +2 -2
- package/dist/siemens-ix/p-0e357d27.entry.js +1 -0
- package/dist/siemens-ix/{p-963c5690.entry.js → p-150d7a02.entry.js} +1 -1
- package/dist/siemens-ix/p-18d02e6f.entry.js +1 -0
- package/dist/siemens-ix/{p-b2ecf415.entry.js → p-23d79e3d.entry.js} +1 -1
- package/dist/siemens-ix/{p-91eb1fdd.entry.js → p-2bc72119.entry.js} +1 -1
- package/dist/siemens-ix/p-2bd88760.entry.js +1 -0
- package/dist/siemens-ix/p-2c5abec1.js +1 -0
- package/dist/siemens-ix/{p-dfb5730f.entry.js → p-2e24ae23.entry.js} +1 -1
- package/dist/siemens-ix/{p-4d61503b.entry.js → p-33283dbf.entry.js} +1 -1
- package/dist/siemens-ix/p-35990ac7.js +1 -0
- package/dist/siemens-ix/{p-6e915c70.entry.js → p-3663f989.entry.js} +1 -1
- package/dist/siemens-ix/{p-2f3294b8.entry.js → p-418e2d14.entry.js} +1 -1
- package/dist/siemens-ix/p-43616759.entry.js +1 -0
- package/dist/siemens-ix/{p-03687070.entry.js → p-4b170382.entry.js} +1 -1
- package/dist/siemens-ix/p-4fcb5f2b.entry.js +1 -0
- package/dist/siemens-ix/p-5631ae88.entry.js +1 -0
- package/dist/siemens-ix/{p-5871e480.entry.js → p-5661957c.entry.js} +1 -1
- package/dist/siemens-ix/{p-56771b32.entry.js → p-592f1ed3.entry.js} +1 -1
- package/dist/siemens-ix/p-5bbe9943.entry.js +1 -0
- package/dist/siemens-ix/{p-05f3c48e.entry.js → p-65e61684.entry.js} +1 -1
- package/dist/siemens-ix/p-6fe3bb9c.entry.js +1 -0
- package/dist/siemens-ix/{p-5e3700c3.entry.js → p-72f851ae.entry.js} +1 -1
- package/dist/siemens-ix/{p-e5397173.entry.js → p-7f842cdc.entry.js} +1 -1
- package/dist/siemens-ix/{p-412dbb89.entry.js → p-8a7141a6.entry.js} +1 -1
- package/dist/siemens-ix/{p-10879145.entry.js → p-8b4e4718.entry.js} +1 -1
- package/dist/siemens-ix/{p-ded3a35d.entry.js → p-9b5290d4.entry.js} +1 -1
- package/dist/siemens-ix/{p-c885685e.entry.js → p-a5fa7ae5.entry.js} +1 -1
- package/dist/siemens-ix/{p-61cb7ab7.entry.js → p-a88618e3.entry.js} +1 -1
- package/dist/siemens-ix/p-ab7949ff.entry.js +1 -0
- package/dist/siemens-ix/{p-23578bb6.entry.js → p-b242bd39.entry.js} +1 -1
- package/dist/siemens-ix/p-b3d00feb.entry.js +1 -0
- package/dist/siemens-ix/p-be641020.entry.js +1 -0
- package/dist/siemens-ix/{p-19cc942a.entry.js → p-c3e90c06.entry.js} +1 -1
- package/dist/siemens-ix/{p-558623ce.entry.js → p-c993560f.entry.js} +1 -1
- package/dist/siemens-ix/{p-35d7f18d.entry.js → p-cc0f6f6b.entry.js} +1 -1
- package/dist/siemens-ix/{p-f24f1eb7.entry.js → p-d0bb8225.entry.js} +1 -1
- package/dist/siemens-ix/p-d20119c1.entry.js +1 -0
- package/dist/siemens-ix/p-dec6114f.js +1 -0
- package/dist/siemens-ix/{p-91ecd6ac.entry.js → p-e2925222.entry.js} +1 -1
- package/dist/siemens-ix/{p-1ba8c910.entry.js → p-e7621b0a.entry.js} +1 -1
- package/dist/siemens-ix/{p-494512c0.entry.js → p-ea333007.entry.js} +1 -1
- package/dist/siemens-ix/{p-8f6809f1.entry.js → p-eb150313.entry.js} +1 -1
- package/dist/siemens-ix/{p-b0c95c22.entry.js → p-eed28e55.entry.js} +1 -1
- package/dist/siemens-ix/p-f35ce089.entry.js +1 -0
- package/dist/siemens-ix/{p-2995294d.entry.js → p-f7be9635.entry.js} +1 -1
- package/dist/siemens-ix/{p-712e8945.entry.js → p-fecf0ade.entry.js} +1 -1
- package/dist/siemens-ix/siemens-ix.css +25 -3
- package/dist/siemens-ix/siemens-ix.esm.js +1 -1
- package/dist/types/components/category-filter/category-filter.d.ts +1 -0
- package/dist/types/components/chip/chip.d.ts +2 -1
- package/dist/types/components/dropdown/alignment.d.ts +2 -0
- package/dist/types/components/dropdown/dropdown.d.ts +19 -6
- package/dist/types/components/dropdown/placement.d.ts +8 -0
- package/dist/types/components/dropdown-button/dropdown-button.d.ts +37 -0
- package/dist/types/components/menu/menu.d.ts +0 -2
- package/dist/types/components/menu-avatar/menu-avatar.d.ts +1 -5
- package/dist/types/components/modal/modal.d.ts +1 -0
- package/dist/types/components/select/select.d.ts +2 -1
- package/dist/types/components/select-item/events.d.ts +9 -0
- package/dist/types/components/select-item/select-item.d.ts +3 -2
- package/dist/types/components/split-button/split-button.d.ts +4 -6
- package/dist/types/components/tree/tree.d.ts +1 -1
- package/dist/types/components/utils/theme-switcher.d.ts +19 -0
- package/dist/types/components/validation-tooltip/validation-tooltip.d.ts +12 -4
- package/dist/types/components.d.ts +86 -15
- package/dist/types/exports.d.ts +1 -0
- package/package.json +5 -6
- package/scss/components/_buttons.scss +23 -0
- package/scss/components/_dropdown.scss +2 -0
- package/dist/cjs/popper-d7a0f999.js +0 -1801
- package/dist/collection/components/utils/popover.util.js +0 -33
- package/dist/collection/components/utils/toggle-theme.js +0 -24
- package/dist/components/popover.util.js +0 -36
- package/dist/components/popper.js +0 -1799
- package/dist/esm/popper-42db9fbd.js +0 -1799
- package/dist/siemens-ix/p-080c00b1.entry.js +0 -1
- package/dist/siemens-ix/p-263949b1.js +0 -1
- package/dist/siemens-ix/p-2709fafd.entry.js +0 -1
- package/dist/siemens-ix/p-2b69b027.entry.js +0 -1
- package/dist/siemens-ix/p-6da1e24d.entry.js +0 -1
- package/dist/siemens-ix/p-7b103473.entry.js +0 -1
- package/dist/siemens-ix/p-80d27c08.entry.js +0 -1
- package/dist/siemens-ix/p-842a7652.entry.js +0 -1
- package/dist/siemens-ix/p-9a98369e.entry.js +0 -1
- package/dist/siemens-ix/p-af8213cc.entry.js +0 -1
- package/dist/siemens-ix/p-aff5f463.entry.js +0 -1
- package/dist/siemens-ix/p-bf387a1f.entry.js +0 -1
- package/dist/siemens-ix/p-f3996fc1.entry.js +0 -1
- package/dist/siemens-ix/p-f86fcdf4.js +0 -1
- package/dist/siemens-ix/p-fe28a2be.entry.js +0 -1
- package/dist/types/components/utils/popover.util.d.ts +0 -9
- package/dist/types/components/utils/toggle-theme.d.ts +0 -1
- package/src/components/animated-tab/readme.md +0 -24
- package/src/components/animated-tabs/readme.md +0 -31
- package/src/components/application-header/readme.md +0 -21
- package/src/components/basic-navigation/readme.md +0 -22
- package/src/components/blind/readme.md +0 -29
- package/src/components/breadcrumb/readme.md +0 -33
- package/src/components/breadcrumb-item/readme.md +0 -22
- package/src/components/button/readme.md +0 -27
- package/src/components/category-filter/readme.md +0 -39
- package/src/components/chip/readme.md +0 -36
- package/src/components/counter-pill/readme.md +0 -25
- package/src/components/date-picker/readme.md +0 -53
- package/src/components/date-time-card/readme.md +0 -22
- package/src/components/datetime-picker/readme.md +0 -45
- package/src/components/drawer/readme.md +0 -47
- package/src/components/dropdown/readme.md +0 -49
- package/src/components/dropdown-item/readme.md +0 -45
- package/src/components/event-list/readme.md +0 -24
- package/src/components/event-list-item/readme.md +0 -32
- package/src/components/expanding-search/readme.md +0 -32
- package/src/components/filter-chip/readme.md +0 -30
- package/src/components/flip-tile/readme.md +0 -22
- package/src/components/flip-tile-content/readme.md +0 -14
- package/src/components/group/readme.md +0 -14
- package/src/components/group-dropdown-item/readme.md +0 -22
- package/src/components/group-item/readme.md +0 -34
- package/src/components/icon/readme.md +0 -23
- package/src/components/icon-button/readme.md +0 -31
- package/src/components/input-group/readme.md +0 -14
- package/src/components/kpi/readme.md +0 -27
- package/src/components/map-navigation/readme.md +0 -54
- package/src/components/map-navigation-overlay/readme.md +0 -30
- package/src/components/menu/readme.md +0 -86
- package/src/components/menu-about/readme.md +0 -30
- package/src/components/menu-about-item/readme.md +0 -21
- package/src/components/menu-about-news/readme.md +0 -34
- package/src/components/menu-avatar/readme.md +0 -30
- package/src/components/menu-avatar-item/readme.md +0 -29
- package/src/components/menu-item/readme.md +0 -26
- package/src/components/menu-settings/readme.md +0 -30
- package/src/components/menu-settings-item/readme.md +0 -21
- package/src/components/message-bar/readme.md +0 -31
- package/src/components/modal/readme.md +0 -67
- package/src/components/modal-container/readme.md +0 -29
- package/src/components/my-component/readme.md +0 -16
- package/src/components/pill/readme.md +0 -26
- package/src/components/select/readme.md +0 -37
- package/src/components/select-item/readme.md +0 -44
- package/src/components/spinner/readme.md +0 -22
- package/src/components/split-button/readme.md +0 -36
- package/src/components/split-button-item/readme.md +0 -29
- package/src/components/tab-item/readme.md +0 -28
- package/src/components/tabs/readme.md +0 -25
- package/src/components/tile/readme.md +0 -21
- package/src/components/time-picker/readme.md +0 -51
- package/src/components/toast/readme.md +0 -36
- package/src/components/toggle/readme.md +0 -35
- package/src/components/tree/readme.md +0 -32
- package/src/components/tree-item/readme.md +0 -31
- package/src/components/upload/readme.md +0 -51
- package/src/components/validation-tooltip/readme.md +0 -31
- package/src/components/workflow-step/readme.md +0 -28
- package/src/components/workflow-steps/readme.md +0 -33
|
@@ -0,0 +1,1372 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function getSide(placement) {
|
|
4
|
+
return placement.split('-')[0];
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function getAlignment$1(placement) {
|
|
8
|
+
return placement.split('-')[1];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function getMainAxisFromPlacement(placement) {
|
|
12
|
+
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getLengthFromAxis(axis) {
|
|
16
|
+
return axis === 'y' ? 'height' : 'width';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
20
|
+
let {
|
|
21
|
+
reference,
|
|
22
|
+
floating
|
|
23
|
+
} = _ref;
|
|
24
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
25
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
26
|
+
const mainAxis = getMainAxisFromPlacement(placement);
|
|
27
|
+
const length = getLengthFromAxis(mainAxis);
|
|
28
|
+
const commonAlign = reference[length] / 2 - floating[length] / 2;
|
|
29
|
+
const side = getSide(placement);
|
|
30
|
+
const isVertical = mainAxis === 'x';
|
|
31
|
+
let coords;
|
|
32
|
+
|
|
33
|
+
switch (side) {
|
|
34
|
+
case 'top':
|
|
35
|
+
coords = {
|
|
36
|
+
x: commonX,
|
|
37
|
+
y: reference.y - floating.height
|
|
38
|
+
};
|
|
39
|
+
break;
|
|
40
|
+
|
|
41
|
+
case 'bottom':
|
|
42
|
+
coords = {
|
|
43
|
+
x: commonX,
|
|
44
|
+
y: reference.y + reference.height
|
|
45
|
+
};
|
|
46
|
+
break;
|
|
47
|
+
|
|
48
|
+
case 'right':
|
|
49
|
+
coords = {
|
|
50
|
+
x: reference.x + reference.width,
|
|
51
|
+
y: commonY
|
|
52
|
+
};
|
|
53
|
+
break;
|
|
54
|
+
|
|
55
|
+
case 'left':
|
|
56
|
+
coords = {
|
|
57
|
+
x: reference.x - floating.width,
|
|
58
|
+
y: commonY
|
|
59
|
+
};
|
|
60
|
+
break;
|
|
61
|
+
|
|
62
|
+
default:
|
|
63
|
+
coords = {
|
|
64
|
+
x: reference.x,
|
|
65
|
+
y: reference.y
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
switch (getAlignment$1(placement)) {
|
|
70
|
+
case 'start':
|
|
71
|
+
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
72
|
+
break;
|
|
73
|
+
|
|
74
|
+
case 'end':
|
|
75
|
+
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return coords;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
84
|
+
* next to a reference element when it is given a certain positioning strategy.
|
|
85
|
+
*
|
|
86
|
+
* This export does not have any `platform` interface logic. You will need to
|
|
87
|
+
* write one for the platform you are using Floating UI with.
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
const computePosition$1 = async (reference, floating, config) => {
|
|
91
|
+
const {
|
|
92
|
+
placement = 'bottom',
|
|
93
|
+
strategy = 'absolute',
|
|
94
|
+
middleware = [],
|
|
95
|
+
platform
|
|
96
|
+
} = config;
|
|
97
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
98
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
99
|
+
|
|
100
|
+
let rects = await platform.getElementRects({
|
|
101
|
+
reference,
|
|
102
|
+
floating,
|
|
103
|
+
strategy
|
|
104
|
+
});
|
|
105
|
+
let {
|
|
106
|
+
x,
|
|
107
|
+
y
|
|
108
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
109
|
+
let statefulPlacement = placement;
|
|
110
|
+
let middlewareData = {};
|
|
111
|
+
let resetCount = 0;
|
|
112
|
+
|
|
113
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
114
|
+
const {
|
|
115
|
+
name,
|
|
116
|
+
fn
|
|
117
|
+
} = validMiddleware[i];
|
|
118
|
+
const {
|
|
119
|
+
x: nextX,
|
|
120
|
+
y: nextY,
|
|
121
|
+
data,
|
|
122
|
+
reset
|
|
123
|
+
} = await fn({
|
|
124
|
+
x,
|
|
125
|
+
y,
|
|
126
|
+
initialPlacement: placement,
|
|
127
|
+
placement: statefulPlacement,
|
|
128
|
+
strategy,
|
|
129
|
+
middlewareData,
|
|
130
|
+
rects,
|
|
131
|
+
platform,
|
|
132
|
+
elements: {
|
|
133
|
+
reference,
|
|
134
|
+
floating
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
x = nextX != null ? nextX : x;
|
|
138
|
+
y = nextY != null ? nextY : y;
|
|
139
|
+
middlewareData = { ...middlewareData,
|
|
140
|
+
[name]: { ...middlewareData[name],
|
|
141
|
+
...data
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
if (reset && resetCount <= 50) {
|
|
146
|
+
resetCount++;
|
|
147
|
+
|
|
148
|
+
if (typeof reset === 'object') {
|
|
149
|
+
if (reset.placement) {
|
|
150
|
+
statefulPlacement = reset.placement;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (reset.rects) {
|
|
154
|
+
rects = reset.rects === true ? await platform.getElementRects({
|
|
155
|
+
reference,
|
|
156
|
+
floating,
|
|
157
|
+
strategy
|
|
158
|
+
}) : reset.rects;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
({
|
|
162
|
+
x,
|
|
163
|
+
y
|
|
164
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
i = -1;
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return {
|
|
173
|
+
x,
|
|
174
|
+
y,
|
|
175
|
+
placement: statefulPlacement,
|
|
176
|
+
strategy,
|
|
177
|
+
middlewareData
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
function expandPaddingObject(padding) {
|
|
182
|
+
return {
|
|
183
|
+
top: 0,
|
|
184
|
+
right: 0,
|
|
185
|
+
bottom: 0,
|
|
186
|
+
left: 0,
|
|
187
|
+
...padding
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function getSideObjectFromPadding(padding) {
|
|
192
|
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
193
|
+
top: padding,
|
|
194
|
+
right: padding,
|
|
195
|
+
bottom: padding,
|
|
196
|
+
left: padding
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function rectToClientRect(rect) {
|
|
201
|
+
return { ...rect,
|
|
202
|
+
top: rect.y,
|
|
203
|
+
left: rect.x,
|
|
204
|
+
right: rect.x + rect.width,
|
|
205
|
+
bottom: rect.y + rect.height
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Resolves with an object of overflow side offsets that determine how much the
|
|
211
|
+
* element is overflowing a given clipping boundary.
|
|
212
|
+
* - positive = overflowing the boundary by that number of pixels
|
|
213
|
+
* - negative = how many pixels left before it will overflow
|
|
214
|
+
* - 0 = lies flush with the boundary
|
|
215
|
+
* @see https://floating-ui.com/docs/detectOverflow
|
|
216
|
+
*/
|
|
217
|
+
async function detectOverflow(middlewareArguments, options) {
|
|
218
|
+
var _await$platform$isEle;
|
|
219
|
+
|
|
220
|
+
if (options === void 0) {
|
|
221
|
+
options = {};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const {
|
|
225
|
+
x,
|
|
226
|
+
y,
|
|
227
|
+
platform,
|
|
228
|
+
rects,
|
|
229
|
+
elements,
|
|
230
|
+
strategy
|
|
231
|
+
} = middlewareArguments;
|
|
232
|
+
const {
|
|
233
|
+
boundary = 'clippingAncestors',
|
|
234
|
+
rootBoundary = 'viewport',
|
|
235
|
+
elementContext = 'floating',
|
|
236
|
+
altBoundary = false,
|
|
237
|
+
padding = 0
|
|
238
|
+
} = options;
|
|
239
|
+
const paddingObject = getSideObjectFromPadding(padding);
|
|
240
|
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
241
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
242
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
243
|
+
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
|
244
|
+
boundary,
|
|
245
|
+
rootBoundary,
|
|
246
|
+
strategy
|
|
247
|
+
}));
|
|
248
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
249
|
+
rect: elementContext === 'floating' ? { ...rects.floating,
|
|
250
|
+
x,
|
|
251
|
+
y
|
|
252
|
+
} : rects.reference,
|
|
253
|
+
offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
|
|
254
|
+
strategy
|
|
255
|
+
}) : rects[elementContext]);
|
|
256
|
+
return {
|
|
257
|
+
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
|
258
|
+
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
|
259
|
+
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
|
260
|
+
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const min$1 = Math.min;
|
|
265
|
+
const max$1 = Math.max;
|
|
266
|
+
|
|
267
|
+
function within(min$1$1, value, max$1$1) {
|
|
268
|
+
return max$1(min$1$1, min$1(value, max$1$1));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Positions an inner element of the floating element such that it is centered
|
|
273
|
+
* to the reference element.
|
|
274
|
+
* @see https://floating-ui.com/docs/arrow
|
|
275
|
+
*/
|
|
276
|
+
const arrow = options => ({
|
|
277
|
+
name: 'arrow',
|
|
278
|
+
options,
|
|
279
|
+
|
|
280
|
+
async fn(middlewareArguments) {
|
|
281
|
+
// Since `element` is required, we don't Partial<> the type
|
|
282
|
+
const {
|
|
283
|
+
element,
|
|
284
|
+
padding = 0
|
|
285
|
+
} = options != null ? options : {};
|
|
286
|
+
const {
|
|
287
|
+
x,
|
|
288
|
+
y,
|
|
289
|
+
placement,
|
|
290
|
+
rects,
|
|
291
|
+
platform
|
|
292
|
+
} = middlewareArguments;
|
|
293
|
+
|
|
294
|
+
if (element == null) {
|
|
295
|
+
|
|
296
|
+
return {};
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const paddingObject = getSideObjectFromPadding(padding);
|
|
300
|
+
const coords = {
|
|
301
|
+
x,
|
|
302
|
+
y
|
|
303
|
+
};
|
|
304
|
+
const axis = getMainAxisFromPlacement(placement);
|
|
305
|
+
const alignment = getAlignment$1(placement);
|
|
306
|
+
const length = getLengthFromAxis(axis);
|
|
307
|
+
const arrowDimensions = await platform.getDimensions(element);
|
|
308
|
+
const minProp = axis === 'y' ? 'top' : 'left';
|
|
309
|
+
const maxProp = axis === 'y' ? 'bottom' : 'right';
|
|
310
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
311
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
312
|
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
313
|
+
let clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
|
314
|
+
|
|
315
|
+
if (clientSize === 0) {
|
|
316
|
+
clientSize = rects.floating[length];
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the floating element if the center
|
|
320
|
+
// point is outside the floating element's bounds
|
|
321
|
+
|
|
322
|
+
const min = paddingObject[minProp];
|
|
323
|
+
const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
|
|
324
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
325
|
+
const offset = within(min, center, max); // Make sure that arrow points at the reference
|
|
326
|
+
|
|
327
|
+
const alignmentPadding = alignment === 'start' ? paddingObject[minProp] : paddingObject[maxProp];
|
|
328
|
+
const shouldAddOffset = alignmentPadding > 0 && center !== offset && rects.reference[length] <= rects.floating[length];
|
|
329
|
+
const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
|
|
330
|
+
return {
|
|
331
|
+
[axis]: coords[axis] - alignmentOffset,
|
|
332
|
+
data: {
|
|
333
|
+
[axis]: offset,
|
|
334
|
+
centerOffset: center - offset
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
const hash$1 = {
|
|
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, matched => hash$1[matched]);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
352
|
+
if (rtl === void 0) {
|
|
353
|
+
rtl = false;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
const alignment = getAlignment$1(placement);
|
|
357
|
+
const mainAxis = getMainAxisFromPlacement(placement);
|
|
358
|
+
const length = getLengthFromAxis(mainAxis);
|
|
359
|
+
let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
360
|
+
|
|
361
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
362
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
return {
|
|
366
|
+
main: mainAlignmentSide,
|
|
367
|
+
cross: getOppositePlacement(mainAlignmentSide)
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const hash = {
|
|
372
|
+
start: 'end',
|
|
373
|
+
end: 'start'
|
|
374
|
+
};
|
|
375
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
376
|
+
return placement.replace(/start|end/g, matched => hash[matched]);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const sides = ['top', 'right', 'bottom', 'left'];
|
|
380
|
+
const allPlacements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-start", side + "-end"), []);
|
|
381
|
+
|
|
382
|
+
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
|
383
|
+
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment$1(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment$1(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
|
|
384
|
+
return allowedPlacementsSortedByAlignment.filter(placement => {
|
|
385
|
+
if (alignment) {
|
|
386
|
+
return getAlignment$1(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
return true;
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Automatically chooses the `placement` which has the most space available.
|
|
395
|
+
* @see https://floating-ui.com/docs/autoPlacement
|
|
396
|
+
*/
|
|
397
|
+
const autoPlacement = function (options) {
|
|
398
|
+
if (options === void 0) {
|
|
399
|
+
options = {};
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
return {
|
|
403
|
+
name: 'autoPlacement',
|
|
404
|
+
options,
|
|
405
|
+
|
|
406
|
+
async fn(middlewareArguments) {
|
|
407
|
+
var _middlewareData$autoP, _middlewareData$autoP2, _middlewareData$autoP3, _middlewareData$autoP4, _placementsSortedByLe;
|
|
408
|
+
|
|
409
|
+
const {
|
|
410
|
+
x,
|
|
411
|
+
y,
|
|
412
|
+
rects,
|
|
413
|
+
middlewareData,
|
|
414
|
+
placement,
|
|
415
|
+
platform,
|
|
416
|
+
elements
|
|
417
|
+
} = middlewareArguments;
|
|
418
|
+
const {
|
|
419
|
+
alignment = null,
|
|
420
|
+
allowedPlacements = allPlacements,
|
|
421
|
+
autoAlignment = true,
|
|
422
|
+
...detectOverflowOptions
|
|
423
|
+
} = options;
|
|
424
|
+
const placements = getPlacementList(alignment, autoAlignment, allowedPlacements);
|
|
425
|
+
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
426
|
+
const currentIndex = (_middlewareData$autoP = (_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.index) != null ? _middlewareData$autoP : 0;
|
|
427
|
+
const currentPlacement = placements[currentIndex];
|
|
428
|
+
|
|
429
|
+
if (currentPlacement == null) {
|
|
430
|
+
return {};
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const {
|
|
434
|
+
main,
|
|
435
|
+
cross
|
|
436
|
+
} = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))); // Make `computeCoords` start from the right place
|
|
437
|
+
|
|
438
|
+
if (placement !== currentPlacement) {
|
|
439
|
+
return {
|
|
440
|
+
x,
|
|
441
|
+
y,
|
|
442
|
+
reset: {
|
|
443
|
+
placement: placements[0]
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[main], overflow[cross]];
|
|
449
|
+
const allOverflows = [...((_middlewareData$autoP3 = (_middlewareData$autoP4 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP4.overflows) != null ? _middlewareData$autoP3 : []), {
|
|
450
|
+
placement: currentPlacement,
|
|
451
|
+
overflows: currentOverflows
|
|
452
|
+
}];
|
|
453
|
+
const nextPlacement = placements[currentIndex + 1]; // There are more placements to check
|
|
454
|
+
|
|
455
|
+
if (nextPlacement) {
|
|
456
|
+
return {
|
|
457
|
+
data: {
|
|
458
|
+
index: currentIndex + 1,
|
|
459
|
+
overflows: allOverflows
|
|
460
|
+
},
|
|
461
|
+
reset: {
|
|
462
|
+
placement: nextPlacement
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
const placementsSortedByLeastOverflow = allOverflows.slice().sort((a, b) => a.overflows[0] - b.overflows[0]);
|
|
468
|
+
const placementThatFitsOnAllSides = (_placementsSortedByLe = placementsSortedByLeastOverflow.find(_ref => {
|
|
469
|
+
let {
|
|
470
|
+
overflows
|
|
471
|
+
} = _ref;
|
|
472
|
+
return overflows.every(overflow => overflow <= 0);
|
|
473
|
+
})) == null ? void 0 : _placementsSortedByLe.placement;
|
|
474
|
+
const resetPlacement = placementThatFitsOnAllSides != null ? placementThatFitsOnAllSides : placementsSortedByLeastOverflow[0].placement;
|
|
475
|
+
|
|
476
|
+
if (resetPlacement !== placement) {
|
|
477
|
+
return {
|
|
478
|
+
data: {
|
|
479
|
+
index: currentIndex + 1,
|
|
480
|
+
overflows: allOverflows
|
|
481
|
+
},
|
|
482
|
+
reset: {
|
|
483
|
+
placement: resetPlacement
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
return {};
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
};
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
async function convertValueToCoords(middlewareArguments, value) {
|
|
495
|
+
const {
|
|
496
|
+
placement,
|
|
497
|
+
platform,
|
|
498
|
+
elements
|
|
499
|
+
} = middlewareArguments;
|
|
500
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
501
|
+
const side = getSide(placement);
|
|
502
|
+
const alignment = getAlignment$1(placement);
|
|
503
|
+
const isVertical = getMainAxisFromPlacement(placement) === 'x';
|
|
504
|
+
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
|
505
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
506
|
+
const rawValue = typeof value === 'function' ? value(middlewareArguments) : value; // eslint-disable-next-line prefer-const
|
|
507
|
+
|
|
508
|
+
let {
|
|
509
|
+
mainAxis,
|
|
510
|
+
crossAxis,
|
|
511
|
+
alignmentAxis
|
|
512
|
+
} = typeof rawValue === 'number' ? {
|
|
513
|
+
mainAxis: rawValue,
|
|
514
|
+
crossAxis: 0,
|
|
515
|
+
alignmentAxis: null
|
|
516
|
+
} : {
|
|
517
|
+
mainAxis: 0,
|
|
518
|
+
crossAxis: 0,
|
|
519
|
+
alignmentAxis: null,
|
|
520
|
+
...rawValue
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
if (alignment && typeof alignmentAxis === 'number') {
|
|
524
|
+
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
return isVertical ? {
|
|
528
|
+
x: crossAxis * crossAxisMulti,
|
|
529
|
+
y: mainAxis * mainAxisMulti
|
|
530
|
+
} : {
|
|
531
|
+
x: mainAxis * mainAxisMulti,
|
|
532
|
+
y: crossAxis * crossAxisMulti
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Displaces the floating element from its reference element.
|
|
537
|
+
* @see https://floating-ui.com/docs/offset
|
|
538
|
+
*/
|
|
539
|
+
|
|
540
|
+
const offset = function (value) {
|
|
541
|
+
if (value === void 0) {
|
|
542
|
+
value = 0;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
return {
|
|
546
|
+
name: 'offset',
|
|
547
|
+
options: value,
|
|
548
|
+
|
|
549
|
+
async fn(middlewareArguments) {
|
|
550
|
+
const {
|
|
551
|
+
x,
|
|
552
|
+
y
|
|
553
|
+
} = middlewareArguments;
|
|
554
|
+
const diffCoords = await convertValueToCoords(middlewareArguments, value);
|
|
555
|
+
return {
|
|
556
|
+
x: x + diffCoords.x,
|
|
557
|
+
y: y + diffCoords.y,
|
|
558
|
+
data: diffCoords
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
};
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
function getCrossAxis(axis) {
|
|
566
|
+
return axis === 'x' ? 'y' : 'x';
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Shifts the floating element in order to keep it in view when it will overflow
|
|
571
|
+
* a clipping boundary.
|
|
572
|
+
* @see https://floating-ui.com/docs/shift
|
|
573
|
+
*/
|
|
574
|
+
const shift = function (options) {
|
|
575
|
+
if (options === void 0) {
|
|
576
|
+
options = {};
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
return {
|
|
580
|
+
name: 'shift',
|
|
581
|
+
options,
|
|
582
|
+
|
|
583
|
+
async fn(middlewareArguments) {
|
|
584
|
+
const {
|
|
585
|
+
x,
|
|
586
|
+
y,
|
|
587
|
+
placement
|
|
588
|
+
} = middlewareArguments;
|
|
589
|
+
const {
|
|
590
|
+
mainAxis: checkMainAxis = true,
|
|
591
|
+
crossAxis: checkCrossAxis = false,
|
|
592
|
+
limiter = {
|
|
593
|
+
fn: _ref => {
|
|
594
|
+
let {
|
|
595
|
+
x,
|
|
596
|
+
y
|
|
597
|
+
} = _ref;
|
|
598
|
+
return {
|
|
599
|
+
x,
|
|
600
|
+
y
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
},
|
|
604
|
+
...detectOverflowOptions
|
|
605
|
+
} = options;
|
|
606
|
+
const coords = {
|
|
607
|
+
x,
|
|
608
|
+
y
|
|
609
|
+
};
|
|
610
|
+
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
611
|
+
const mainAxis = getMainAxisFromPlacement(getSide(placement));
|
|
612
|
+
const crossAxis = getCrossAxis(mainAxis);
|
|
613
|
+
let mainAxisCoord = coords[mainAxis];
|
|
614
|
+
let crossAxisCoord = coords[crossAxis];
|
|
615
|
+
|
|
616
|
+
if (checkMainAxis) {
|
|
617
|
+
const minSide = mainAxis === 'y' ? 'top' : 'left';
|
|
618
|
+
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
619
|
+
const min = mainAxisCoord + overflow[minSide];
|
|
620
|
+
const max = mainAxisCoord - overflow[maxSide];
|
|
621
|
+
mainAxisCoord = within(min, mainAxisCoord, max);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
if (checkCrossAxis) {
|
|
625
|
+
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
626
|
+
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
627
|
+
const min = crossAxisCoord + overflow[minSide];
|
|
628
|
+
const max = crossAxisCoord - overflow[maxSide];
|
|
629
|
+
crossAxisCoord = within(min, crossAxisCoord, max);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
const limitedCoords = limiter.fn({ ...middlewareArguments,
|
|
633
|
+
[mainAxis]: mainAxisCoord,
|
|
634
|
+
[crossAxis]: crossAxisCoord
|
|
635
|
+
});
|
|
636
|
+
return { ...limitedCoords,
|
|
637
|
+
data: {
|
|
638
|
+
x: limitedCoords.x - x,
|
|
639
|
+
y: limitedCoords.y - y
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
};
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* Provides improved positioning for inline reference elements that can span
|
|
649
|
+
* over multiple lines, such as hyperlinks or range selections.
|
|
650
|
+
* @see https://floating-ui.com/docs/inline
|
|
651
|
+
*/
|
|
652
|
+
const inline = function (options) {
|
|
653
|
+
if (options === void 0) {
|
|
654
|
+
options = {};
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
return {
|
|
658
|
+
name: 'inline',
|
|
659
|
+
options,
|
|
660
|
+
|
|
661
|
+
async fn(middlewareArguments) {
|
|
662
|
+
var _await$platform$getCl;
|
|
663
|
+
|
|
664
|
+
const {
|
|
665
|
+
placement,
|
|
666
|
+
elements,
|
|
667
|
+
rects,
|
|
668
|
+
platform,
|
|
669
|
+
strategy
|
|
670
|
+
} = middlewareArguments; // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
|
|
671
|
+
// ClientRect's bounds, despite the event listener being triggered. A
|
|
672
|
+
// padding of 2 seems to handle this issue.
|
|
673
|
+
|
|
674
|
+
const {
|
|
675
|
+
padding = 2,
|
|
676
|
+
x,
|
|
677
|
+
y
|
|
678
|
+
} = options;
|
|
679
|
+
const fallback = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
680
|
+
rect: rects.reference,
|
|
681
|
+
offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
|
|
682
|
+
strategy
|
|
683
|
+
}) : rects.reference);
|
|
684
|
+
const clientRects = (_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) != null ? _await$platform$getCl : [];
|
|
685
|
+
const paddingObject = getSideObjectFromPadding(padding);
|
|
686
|
+
|
|
687
|
+
function getBoundingClientRect() {
|
|
688
|
+
// There are two rects and they are disjoined
|
|
689
|
+
if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
|
|
690
|
+
var _clientRects$find;
|
|
691
|
+
|
|
692
|
+
// Find the first rect in which the point is fully inside
|
|
693
|
+
return (_clientRects$find = clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom)) != null ? _clientRects$find : fallback;
|
|
694
|
+
} // There are 2 or more connected rects
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
if (clientRects.length >= 2) {
|
|
698
|
+
if (getMainAxisFromPlacement(placement) === 'x') {
|
|
699
|
+
const firstRect = clientRects[0];
|
|
700
|
+
const lastRect = clientRects[clientRects.length - 1];
|
|
701
|
+
const isTop = getSide(placement) === 'top';
|
|
702
|
+
const top = firstRect.top;
|
|
703
|
+
const bottom = lastRect.bottom;
|
|
704
|
+
const left = isTop ? firstRect.left : lastRect.left;
|
|
705
|
+
const right = isTop ? firstRect.right : lastRect.right;
|
|
706
|
+
const width = right - left;
|
|
707
|
+
const height = bottom - top;
|
|
708
|
+
return {
|
|
709
|
+
top,
|
|
710
|
+
bottom,
|
|
711
|
+
left,
|
|
712
|
+
right,
|
|
713
|
+
width,
|
|
714
|
+
height,
|
|
715
|
+
x: left,
|
|
716
|
+
y: top
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
const isLeftSide = getSide(placement) === 'left';
|
|
721
|
+
const maxRight = max$1(...clientRects.map(rect => rect.right));
|
|
722
|
+
const minLeft = min$1(...clientRects.map(rect => rect.left));
|
|
723
|
+
const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
|
|
724
|
+
const top = measureRects[0].top;
|
|
725
|
+
const bottom = measureRects[measureRects.length - 1].bottom;
|
|
726
|
+
const left = minLeft;
|
|
727
|
+
const right = maxRight;
|
|
728
|
+
const width = right - left;
|
|
729
|
+
const height = bottom - top;
|
|
730
|
+
return {
|
|
731
|
+
top,
|
|
732
|
+
bottom,
|
|
733
|
+
left,
|
|
734
|
+
right,
|
|
735
|
+
width,
|
|
736
|
+
height,
|
|
737
|
+
x: left,
|
|
738
|
+
y: top
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
return fallback;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
const resetRects = await platform.getElementRects({
|
|
746
|
+
reference: {
|
|
747
|
+
getBoundingClientRect
|
|
748
|
+
},
|
|
749
|
+
floating: elements.floating,
|
|
750
|
+
strategy
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
|
|
754
|
+
return {
|
|
755
|
+
reset: {
|
|
756
|
+
rects: resetRects
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
return {};
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
};
|
|
765
|
+
};
|
|
766
|
+
|
|
767
|
+
function isWindow(value) {
|
|
768
|
+
return value && value.document && value.location && value.alert && value.setInterval;
|
|
769
|
+
}
|
|
770
|
+
function getWindow(node) {
|
|
771
|
+
if (node == null) {
|
|
772
|
+
return window;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
if (!isWindow(node)) {
|
|
776
|
+
const ownerDocument = node.ownerDocument;
|
|
777
|
+
return ownerDocument ? ownerDocument.defaultView || window : window;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
return node;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
function getComputedStyle(element) {
|
|
784
|
+
return getWindow(element).getComputedStyle(element);
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
function getNodeName(node) {
|
|
788
|
+
return isWindow(node) ? '' : node ? (node.nodeName || '').toLowerCase() : '';
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
function getUAString() {
|
|
792
|
+
const uaData = navigator.userAgentData;
|
|
793
|
+
|
|
794
|
+
if (uaData != null && uaData.brands) {
|
|
795
|
+
return uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
return navigator.userAgent;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
function isHTMLElement(value) {
|
|
802
|
+
return value instanceof getWindow(value).HTMLElement;
|
|
803
|
+
}
|
|
804
|
+
function isElement(value) {
|
|
805
|
+
return value instanceof getWindow(value).Element;
|
|
806
|
+
}
|
|
807
|
+
function isNode(value) {
|
|
808
|
+
return value instanceof getWindow(value).Node;
|
|
809
|
+
}
|
|
810
|
+
function isShadowRoot(node) {
|
|
811
|
+
// Browsers without `ShadowRoot` support
|
|
812
|
+
if (typeof ShadowRoot === 'undefined') {
|
|
813
|
+
return false;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
const OwnElement = getWindow(node).ShadowRoot;
|
|
817
|
+
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
818
|
+
}
|
|
819
|
+
function isOverflowElement(element) {
|
|
820
|
+
// Firefox wants us to check `-x` and `-y` variations as well
|
|
821
|
+
const {
|
|
822
|
+
overflow,
|
|
823
|
+
overflowX,
|
|
824
|
+
overflowY,
|
|
825
|
+
display
|
|
826
|
+
} = getComputedStyle(element);
|
|
827
|
+
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
|
|
828
|
+
}
|
|
829
|
+
function isTableElement(element) {
|
|
830
|
+
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
831
|
+
}
|
|
832
|
+
function isContainingBlock(element) {
|
|
833
|
+
// TODO: Try and use feature detection here instead
|
|
834
|
+
const isFirefox = /firefox/i.test(getUAString());
|
|
835
|
+
const css = getComputedStyle(element);
|
|
836
|
+
const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter; // This is non-exhaustive but covers the most common CSS properties that
|
|
837
|
+
// create a containing block.
|
|
838
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
839
|
+
|
|
840
|
+
return css.transform !== 'none' || css.perspective !== 'none' || (backdropFilter ? backdropFilter !== 'none' : false) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective'].some(value => css.willChange.includes(value)) || ['paint', 'layout', 'strict', 'content'].some( // TS 4.1 compat
|
|
841
|
+
value => {
|
|
842
|
+
const contain = css.contain;
|
|
843
|
+
return contain != null ? contain.includes(value) : false;
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
function isLayoutViewport() {
|
|
847
|
+
// Not Safari
|
|
848
|
+
return !/^((?!chrome|android).)*safari/i.test(getUAString()); // Feature detection for this fails in various ways
|
|
849
|
+
// • Always-visible scrollbar or not
|
|
850
|
+
// • Width of <html>, etc.
|
|
851
|
+
// const vV = win.visualViewport;
|
|
852
|
+
// return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true;
|
|
853
|
+
}
|
|
854
|
+
function isLastTraversableNode(node) {
|
|
855
|
+
return ['html', 'body', '#document'].includes(getNodeName(node));
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
const min = Math.min;
|
|
859
|
+
const max = Math.max;
|
|
860
|
+
const round = Math.round;
|
|
861
|
+
|
|
862
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
|
863
|
+
var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;
|
|
864
|
+
|
|
865
|
+
if (includeScale === void 0) {
|
|
866
|
+
includeScale = false;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
if (isFixedStrategy === void 0) {
|
|
870
|
+
isFixedStrategy = false;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
const clientRect = element.getBoundingClientRect();
|
|
874
|
+
let scaleX = 1;
|
|
875
|
+
let scaleY = 1;
|
|
876
|
+
|
|
877
|
+
if (includeScale && isHTMLElement(element)) {
|
|
878
|
+
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
|
879
|
+
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
const win = isElement(element) ? getWindow(element) : window;
|
|
883
|
+
const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
|
884
|
+
const x = (clientRect.left + (addVisualOffsets ? (_win$visualViewport$o = (_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) != null ? _win$visualViewport$o : 0 : 0)) / scaleX;
|
|
885
|
+
const y = (clientRect.top + (addVisualOffsets ? (_win$visualViewport$o2 = (_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) != null ? _win$visualViewport$o2 : 0 : 0)) / scaleY;
|
|
886
|
+
const width = clientRect.width / scaleX;
|
|
887
|
+
const height = clientRect.height / scaleY;
|
|
888
|
+
return {
|
|
889
|
+
width,
|
|
890
|
+
height,
|
|
891
|
+
top: y,
|
|
892
|
+
right: x + width,
|
|
893
|
+
bottom: y + height,
|
|
894
|
+
left: x,
|
|
895
|
+
x,
|
|
896
|
+
y
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
function getDocumentElement(node) {
|
|
901
|
+
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
function getNodeScroll(element) {
|
|
905
|
+
if (isElement(element)) {
|
|
906
|
+
return {
|
|
907
|
+
scrollLeft: element.scrollLeft,
|
|
908
|
+
scrollTop: element.scrollTop
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
return {
|
|
913
|
+
scrollLeft: element.pageXOffset,
|
|
914
|
+
scrollTop: element.pageYOffset
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
function getWindowScrollBarX(element) {
|
|
919
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
|
920
|
+
// incorrect for RTL.
|
|
921
|
+
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
function isScaled(element) {
|
|
925
|
+
const rect = getBoundingClientRect(element);
|
|
926
|
+
return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
930
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
931
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
932
|
+
const rect = getBoundingClientRect(element, // @ts-ignore - checked above (TS 4.1 compat)
|
|
933
|
+
isOffsetParentAnElement && isScaled(offsetParent), strategy === 'fixed');
|
|
934
|
+
let scroll = {
|
|
935
|
+
scrollLeft: 0,
|
|
936
|
+
scrollTop: 0
|
|
937
|
+
};
|
|
938
|
+
const offsets = {
|
|
939
|
+
x: 0,
|
|
940
|
+
y: 0
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
944
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
945
|
+
scroll = getNodeScroll(offsetParent);
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
if (isHTMLElement(offsetParent)) {
|
|
949
|
+
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
950
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
951
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
952
|
+
} else if (documentElement) {
|
|
953
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
return {
|
|
958
|
+
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
959
|
+
y: rect.top + scroll.scrollTop - offsets.y,
|
|
960
|
+
width: rect.width,
|
|
961
|
+
height: rect.height
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
function getParentNode(node) {
|
|
966
|
+
if (getNodeName(node) === 'html') {
|
|
967
|
+
return node;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
const result = // Step into the shadow DOM of the parent of a slotted node
|
|
971
|
+
node.assignedSlot || // DOM Element detected
|
|
972
|
+
node.parentNode || ( // ShadowRoot detected
|
|
973
|
+
isShadowRoot(node) ? node.host : null) || // Fallback
|
|
974
|
+
getDocumentElement(node);
|
|
975
|
+
return isShadowRoot(result) ? result.host : result;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
function getTrueOffsetParent(element) {
|
|
979
|
+
if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
|
|
980
|
+
return null;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
return element.offsetParent;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
function getContainingBlock(element) {
|
|
987
|
+
let currentNode = getParentNode(element);
|
|
988
|
+
|
|
989
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
990
|
+
if (isContainingBlock(currentNode)) {
|
|
991
|
+
return currentNode;
|
|
992
|
+
} else {
|
|
993
|
+
currentNode = getParentNode(currentNode);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
return null;
|
|
998
|
+
} // Gets the closest ancestor positioned element. Handles some edge cases,
|
|
999
|
+
// such as table ancestors and cross browser bugs.
|
|
1000
|
+
|
|
1001
|
+
|
|
1002
|
+
function getOffsetParent(element) {
|
|
1003
|
+
const window = getWindow(element);
|
|
1004
|
+
let offsetParent = getTrueOffsetParent(element);
|
|
1005
|
+
|
|
1006
|
+
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
|
|
1007
|
+
offsetParent = getTrueOffsetParent(offsetParent);
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
|
|
1011
|
+
return window;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
return offsetParent || getContainingBlock(element) || window;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
function getDimensions(element) {
|
|
1018
|
+
if (isHTMLElement(element)) {
|
|
1019
|
+
return {
|
|
1020
|
+
width: element.offsetWidth,
|
|
1021
|
+
height: element.offsetHeight
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
const rect = getBoundingClientRect(element);
|
|
1026
|
+
return {
|
|
1027
|
+
width: rect.width,
|
|
1028
|
+
height: rect.height
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
1033
|
+
let {
|
|
1034
|
+
rect,
|
|
1035
|
+
offsetParent,
|
|
1036
|
+
strategy
|
|
1037
|
+
} = _ref;
|
|
1038
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1039
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1040
|
+
|
|
1041
|
+
if (offsetParent === documentElement) {
|
|
1042
|
+
return rect;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
let scroll = {
|
|
1046
|
+
scrollLeft: 0,
|
|
1047
|
+
scrollTop: 0
|
|
1048
|
+
};
|
|
1049
|
+
const offsets = {
|
|
1050
|
+
x: 0,
|
|
1051
|
+
y: 0
|
|
1052
|
+
};
|
|
1053
|
+
|
|
1054
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
1055
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1056
|
+
scroll = getNodeScroll(offsetParent);
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
if (isHTMLElement(offsetParent)) {
|
|
1060
|
+
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
1061
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1062
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1063
|
+
} // This doesn't appear to be need to be negated.
|
|
1064
|
+
// else if (documentElement) {
|
|
1065
|
+
// offsets.x = getWindowScrollBarX(documentElement);
|
|
1066
|
+
// }
|
|
1067
|
+
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
return { ...rect,
|
|
1071
|
+
x: rect.x - scroll.scrollLeft + offsets.x,
|
|
1072
|
+
y: rect.y - scroll.scrollTop + offsets.y
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
function getViewportRect(element, strategy) {
|
|
1077
|
+
const win = getWindow(element);
|
|
1078
|
+
const html = getDocumentElement(element);
|
|
1079
|
+
const visualViewport = win.visualViewport;
|
|
1080
|
+
let width = html.clientWidth;
|
|
1081
|
+
let height = html.clientHeight;
|
|
1082
|
+
let x = 0;
|
|
1083
|
+
let y = 0;
|
|
1084
|
+
|
|
1085
|
+
if (visualViewport) {
|
|
1086
|
+
width = visualViewport.width;
|
|
1087
|
+
height = visualViewport.height;
|
|
1088
|
+
const layoutViewport = isLayoutViewport();
|
|
1089
|
+
|
|
1090
|
+
if (layoutViewport || !layoutViewport && strategy === 'fixed') {
|
|
1091
|
+
x = visualViewport.offsetLeft;
|
|
1092
|
+
y = visualViewport.offsetTop;
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
return {
|
|
1097
|
+
width,
|
|
1098
|
+
height,
|
|
1099
|
+
x,
|
|
1100
|
+
y
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable
|
|
1105
|
+
|
|
1106
|
+
function getDocumentRect(element) {
|
|
1107
|
+
var _element$ownerDocumen;
|
|
1108
|
+
|
|
1109
|
+
const html = getDocumentElement(element);
|
|
1110
|
+
const scroll = getNodeScroll(element);
|
|
1111
|
+
const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
|
1112
|
+
const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
|
1113
|
+
const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
|
1114
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
1115
|
+
const y = -scroll.scrollTop;
|
|
1116
|
+
|
|
1117
|
+
if (getComputedStyle(body || html).direction === 'rtl') {
|
|
1118
|
+
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
return {
|
|
1122
|
+
width,
|
|
1123
|
+
height,
|
|
1124
|
+
x,
|
|
1125
|
+
y
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
function getNearestOverflowAncestor(node) {
|
|
1130
|
+
const parentNode = getParentNode(node);
|
|
1131
|
+
|
|
1132
|
+
if (isLastTraversableNode(parentNode)) {
|
|
1133
|
+
// @ts-ignore assume body is always available
|
|
1134
|
+
return node.ownerDocument.body;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
1138
|
+
return parentNode;
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
return getNearestOverflowAncestor(parentNode);
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
function getOverflowAncestors(node, list) {
|
|
1145
|
+
var _node$ownerDocument;
|
|
1146
|
+
|
|
1147
|
+
if (list === void 0) {
|
|
1148
|
+
list = [];
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
1152
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
|
|
1153
|
+
const win = getWindow(scrollableAncestor);
|
|
1154
|
+
const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
|
|
1155
|
+
const updatedList = list.concat(target);
|
|
1156
|
+
return isBody ? updatedList : // @ts-ignore: isBody tells us target will be an HTMLElement here
|
|
1157
|
+
updatedList.concat(getOverflowAncestors(target));
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
1161
|
+
const clientRect = getBoundingClientRect(element, false, strategy === 'fixed');
|
|
1162
|
+
const top = clientRect.top + element.clientTop;
|
|
1163
|
+
const left = clientRect.left + element.clientLeft;
|
|
1164
|
+
return {
|
|
1165
|
+
top,
|
|
1166
|
+
left,
|
|
1167
|
+
x: left,
|
|
1168
|
+
y: top,
|
|
1169
|
+
right: left + element.clientWidth,
|
|
1170
|
+
bottom: top + element.clientHeight,
|
|
1171
|
+
width: element.clientWidth,
|
|
1172
|
+
height: element.clientHeight
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
1177
|
+
if (clippingAncestor === 'viewport') {
|
|
1178
|
+
return rectToClientRect(getViewportRect(element, strategy));
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
if (isElement(clippingAncestor)) {
|
|
1182
|
+
return getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
return rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
1186
|
+
} // A "clipping ancestor" is an overflowable container with the characteristic of
|
|
1187
|
+
// clipping (or hiding) overflowing elements with a position different from
|
|
1188
|
+
// `initial`
|
|
1189
|
+
|
|
1190
|
+
|
|
1191
|
+
function getClippingElementAncestors(element) {
|
|
1192
|
+
let result = getOverflowAncestors(element).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
|
1193
|
+
let currentNode = element;
|
|
1194
|
+
let currentContainingBlockComputedStyle = null; // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1195
|
+
|
|
1196
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1197
|
+
const computedStyle = getComputedStyle(currentNode);
|
|
1198
|
+
|
|
1199
|
+
if (computedStyle.position === 'static' && currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) && !isContainingBlock(currentNode)) {
|
|
1200
|
+
// Drop non-containing blocks
|
|
1201
|
+
result = result.filter(ancestor => ancestor !== currentNode);
|
|
1202
|
+
} else {
|
|
1203
|
+
// Record last containing block for next iteration
|
|
1204
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
currentNode = getParentNode(currentNode);
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
return result;
|
|
1211
|
+
} // Gets the maximum area that the element is visible in due to any number of
|
|
1212
|
+
// clipping ancestors
|
|
1213
|
+
|
|
1214
|
+
|
|
1215
|
+
function getClippingRect(_ref) {
|
|
1216
|
+
let {
|
|
1217
|
+
element,
|
|
1218
|
+
boundary,
|
|
1219
|
+
rootBoundary,
|
|
1220
|
+
strategy
|
|
1221
|
+
} = _ref;
|
|
1222
|
+
const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element) : [].concat(boundary);
|
|
1223
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
1224
|
+
const firstClippingAncestor = clippingAncestors[0];
|
|
1225
|
+
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
1226
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
1227
|
+
accRect.top = max(rect.top, accRect.top);
|
|
1228
|
+
accRect.right = min(rect.right, accRect.right);
|
|
1229
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
1230
|
+
accRect.left = max(rect.left, accRect.left);
|
|
1231
|
+
return accRect;
|
|
1232
|
+
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
1233
|
+
return {
|
|
1234
|
+
width: clippingRect.right - clippingRect.left,
|
|
1235
|
+
height: clippingRect.bottom - clippingRect.top,
|
|
1236
|
+
x: clippingRect.left,
|
|
1237
|
+
y: clippingRect.top
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
const platform = {
|
|
1242
|
+
getClippingRect,
|
|
1243
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1244
|
+
isElement,
|
|
1245
|
+
getDimensions,
|
|
1246
|
+
getOffsetParent,
|
|
1247
|
+
getDocumentElement,
|
|
1248
|
+
getElementRects: _ref => {
|
|
1249
|
+
let {
|
|
1250
|
+
reference,
|
|
1251
|
+
floating,
|
|
1252
|
+
strategy
|
|
1253
|
+
} = _ref;
|
|
1254
|
+
return {
|
|
1255
|
+
reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
|
|
1256
|
+
floating: { ...getDimensions(floating),
|
|
1257
|
+
x: 0,
|
|
1258
|
+
y: 0
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
},
|
|
1262
|
+
getClientRects: element => Array.from(element.getClientRects()),
|
|
1263
|
+
isRTL: element => getComputedStyle(element).direction === 'rtl'
|
|
1264
|
+
};
|
|
1265
|
+
|
|
1266
|
+
/**
|
|
1267
|
+
* Automatically updates the position of the floating element when necessary.
|
|
1268
|
+
* @see https://floating-ui.com/docs/autoUpdate
|
|
1269
|
+
*/
|
|
1270
|
+
function autoUpdate(reference, floating, update, options) {
|
|
1271
|
+
if (options === void 0) {
|
|
1272
|
+
options = {};
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
const {
|
|
1276
|
+
ancestorScroll: _ancestorScroll = true,
|
|
1277
|
+
ancestorResize = true,
|
|
1278
|
+
elementResize = true,
|
|
1279
|
+
animationFrame = false
|
|
1280
|
+
} = options;
|
|
1281
|
+
const ancestorScroll = _ancestorScroll && !animationFrame;
|
|
1282
|
+
const ancestors = ancestorScroll || ancestorResize ? [...(isElement(reference) ? getOverflowAncestors(reference) : reference.contextElement ? getOverflowAncestors(reference.contextElement) : []), ...getOverflowAncestors(floating)] : [];
|
|
1283
|
+
ancestors.forEach(ancestor => {
|
|
1284
|
+
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
1285
|
+
passive: true
|
|
1286
|
+
});
|
|
1287
|
+
ancestorResize && ancestor.addEventListener('resize', update);
|
|
1288
|
+
});
|
|
1289
|
+
let observer = null;
|
|
1290
|
+
|
|
1291
|
+
if (elementResize) {
|
|
1292
|
+
let initialUpdate = true;
|
|
1293
|
+
observer = new ResizeObserver(() => {
|
|
1294
|
+
if (!initialUpdate) {
|
|
1295
|
+
update();
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
initialUpdate = false;
|
|
1299
|
+
});
|
|
1300
|
+
isElement(reference) && !animationFrame && observer.observe(reference);
|
|
1301
|
+
|
|
1302
|
+
if (!isElement(reference) && reference.contextElement && !animationFrame) {
|
|
1303
|
+
observer.observe(reference.contextElement);
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
observer.observe(floating);
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
let frameId;
|
|
1310
|
+
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
1311
|
+
|
|
1312
|
+
if (animationFrame) {
|
|
1313
|
+
frameLoop();
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
function frameLoop() {
|
|
1317
|
+
const nextRefRect = getBoundingClientRect(reference);
|
|
1318
|
+
|
|
1319
|
+
if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
|
|
1320
|
+
update();
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
prevRefRect = nextRefRect;
|
|
1324
|
+
frameId = requestAnimationFrame(frameLoop);
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
update();
|
|
1328
|
+
return () => {
|
|
1329
|
+
var _observer;
|
|
1330
|
+
|
|
1331
|
+
ancestors.forEach(ancestor => {
|
|
1332
|
+
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
1333
|
+
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
1334
|
+
});
|
|
1335
|
+
(_observer = observer) == null ? void 0 : _observer.disconnect();
|
|
1336
|
+
observer = null;
|
|
1337
|
+
|
|
1338
|
+
if (animationFrame) {
|
|
1339
|
+
cancelAnimationFrame(frameId);
|
|
1340
|
+
}
|
|
1341
|
+
};
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
/**
|
|
1345
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
1346
|
+
* next to a reference element when it is given a certain CSS positioning
|
|
1347
|
+
* strategy.
|
|
1348
|
+
*/
|
|
1349
|
+
|
|
1350
|
+
const computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
|
|
1351
|
+
platform,
|
|
1352
|
+
...options
|
|
1353
|
+
});
|
|
1354
|
+
|
|
1355
|
+
function getAlignment(placement) {
|
|
1356
|
+
if (placement.includes('-end')) {
|
|
1357
|
+
return 'end';
|
|
1358
|
+
}
|
|
1359
|
+
else if (placement.includes('-start')) {
|
|
1360
|
+
return 'start';
|
|
1361
|
+
}
|
|
1362
|
+
return undefined;
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
exports.arrow = arrow;
|
|
1366
|
+
exports.autoPlacement = autoPlacement;
|
|
1367
|
+
exports.autoUpdate = autoUpdate;
|
|
1368
|
+
exports.computePosition = computePosition;
|
|
1369
|
+
exports.getAlignment = getAlignment;
|
|
1370
|
+
exports.inline = inline;
|
|
1371
|
+
exports.offset = offset;
|
|
1372
|
+
exports.shift = shift;
|