@web-atoms/web-controls 2.6.4 → 2.6.6
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/tsconfig.tsbuildinfo +1 -1
- package/dist-esm/ArrayLike.js +14 -12
- package/dist-esm/DataAttributes.js +18 -19
- package/dist-esm/Focusable.js +10 -11
- package/dist-esm/ModuleFiles.js +43 -42
- package/dist-esm/NumberFormats.js +60 -56
- package/dist-esm/PageNavigator.js +28 -30
- package/dist-esm/animations/Animations.global.css +2 -0
- package/dist-esm/animations/Animations.global.css.map +1 -0
- package/dist-esm/animations/Animations.js +36 -33
- package/dist-esm/basic/AtomChips.js +312 -305
- package/dist-esm/basic/AtomRepeater.js +1070 -1035
- package/dist-esm/basic/AtomSuggestions.js +97 -107
- package/dist-esm/basic/AttachedPopup.js +0 -1
- package/dist-esm/basic/Button.js +45 -19
- package/dist-esm/basic/Button.local.css +2 -0
- package/dist-esm/basic/Button.local.css.map +1 -0
- package/dist-esm/basic/ButtonBar.global.css +2 -0
- package/dist-esm/basic/ButtonBar.global.css.map +1 -0
- package/dist-esm/basic/ButtonBar.js +84 -64
- package/dist-esm/basic/Calendar.js +211 -203
- package/dist-esm/basic/CheckBoxList.js +90 -70
- package/dist-esm/basic/Checkbox.js +16 -8
- package/dist-esm/basic/Chip.js +36 -12
- package/dist-esm/basic/ComboBox.js +47 -51
- package/dist-esm/basic/DataGrid.js +258 -252
- package/dist-esm/basic/DateField.js +149 -127
- package/dist-esm/basic/DropDown.js +91 -103
- package/dist-esm/basic/DropDownInput.global.css +2 -0
- package/dist-esm/basic/DropDownInput.global.css.map +1 -0
- package/dist-esm/basic/DropDownInput.js +78 -106
- package/dist-esm/basic/Editable.js +82 -77
- package/dist-esm/basic/Expander.js +104 -86
- package/dist-esm/basic/FilesDragDrop.global.css +2 -0
- package/dist-esm/basic/FilesDragDrop.global.css.map +1 -0
- package/dist-esm/basic/FilesDragDrop.js +84 -80
- package/dist-esm/basic/Form.js +80 -52
- package/dist-esm/basic/FormField.js +164 -106
- package/dist-esm/basic/IElement.js +1 -2
- package/dist-esm/basic/InlinePopup.js +263 -234
- package/dist-esm/basic/InlinePopupButton.js +99 -88
- package/dist-esm/basic/InlinePopupControl.js +24 -23
- package/dist-esm/basic/ItemPath.js +59 -60
- package/dist-esm/basic/LimitedText.js +49 -38
- package/dist-esm/basic/ListRepeater.js +13 -14
- package/dist-esm/basic/MaskedInput.js +37 -29
- package/dist-esm/basic/MaskedInputDiv.js +55 -48
- package/dist-esm/basic/MergeNode.js +64 -35
- package/dist-esm/basic/PasswordBox.js +32 -17
- package/dist-esm/basic/PinchZoomView.js +221 -199
- package/dist-esm/basic/PopupButton.js +39 -16
- package/dist-esm/basic/PopupMenu.js +3 -4
- package/dist-esm/basic/RadioButtonList.js +35 -25
- package/dist-esm/basic/RefreshLock.js +41 -42
- package/dist-esm/basic/Resizable.js +43 -33
- package/dist-esm/basic/Select.js +72 -65
- package/dist-esm/basic/SortByButton.global.css +2 -0
- package/dist-esm/basic/SortByButton.global.css.map +1 -0
- package/dist-esm/basic/SortByButton.js +41 -31
- package/dist-esm/basic/Swipe.js +91 -84
- package/dist-esm/basic/Switch.js +22 -8
- package/dist-esm/basic/TableRepeater.js +29 -33
- package/dist-esm/basic/TimeEditor.js +97 -52
- package/dist-esm/basic/TitleEditor.js +115 -95
- package/dist-esm/basic/ToggleButtonBar.js +21 -22
- package/dist-esm/basic/Tooltip.js +49 -47
- package/dist-esm/basic/TypeWriter.js +45 -42
- package/dist-esm/basic/UploadEvent.js +211 -178
- package/dist-esm/basic/ZoomView.js +229 -198
- package/dist-esm/basic/combineClasses.js +2 -3
- package/dist-esm/basic/elements/AtomPopover.css +2 -0
- package/dist-esm/basic/elements/AtomPopover.css.map +1 -0
- package/dist-esm/basic/elements/AtomPopover.js +270 -253
- package/dist-esm/basic/elements/getContainingBlock.js +34 -35
- package/dist-esm/basic/elements/relativeRect.js +40 -21
- package/dist-esm/basic/styles/calendar.global.css +2 -0
- package/dist-esm/basic/styles/calendar.global.css.map +1 -0
- package/dist-esm/basic/styles/check-box-list.global.css +2 -0
- package/dist-esm/basic/styles/check-box-list.global.css.map +1 -0
- package/dist-esm/basic/styles/checkbox.global.css +2 -0
- package/dist-esm/basic/styles/checkbox.global.css.map +1 -0
- package/dist-esm/basic/styles/chip.global.css +2 -0
- package/dist-esm/basic/styles/chip.global.css.map +1 -0
- package/dist-esm/basic/styles/chips.global.css +2 -0
- package/dist-esm/basic/styles/chips.global.css.map +1 -0
- package/dist-esm/basic/styles/data-grid.global.css +2 -0
- package/dist-esm/basic/styles/data-grid.global.css.map +1 -0
- package/dist-esm/basic/styles/date-field.global.css +2 -0
- package/dist-esm/basic/styles/date-field.global.css.map +1 -0
- package/dist-esm/basic/styles/drop-down.global.css +2 -0
- package/dist-esm/basic/styles/drop-down.global.css.map +1 -0
- package/dist-esm/basic/styles/expander.global.css +2 -0
- package/dist-esm/basic/styles/expander.global.css.map +1 -0
- package/dist-esm/basic/styles/form-field.global.css +2 -0
- package/dist-esm/basic/styles/form-field.global.css.map +1 -0
- package/dist-esm/basic/styles/inline-popup.global.css +2 -0
- package/dist-esm/basic/styles/inline-popup.global.css.map +1 -0
- package/dist-esm/basic/styles/item-suggestion.global.css +2 -0
- package/dist-esm/basic/styles/item-suggestion.global.css.map +1 -0
- package/dist-esm/basic/styles/list-repeater.global.css +2 -0
- package/dist-esm/basic/styles/list-repeater.global.css.map +1 -0
- package/dist-esm/basic/styles/masked-input.global.css +2 -0
- package/dist-esm/basic/styles/masked-input.global.css.map +1 -0
- package/dist-esm/basic/styles/password-box.global.css +2 -0
- package/dist-esm/basic/styles/password-box.global.css.map +1 -0
- package/dist-esm/basic/styles/pinch-zoom-view.global.css +2 -0
- package/dist-esm/basic/styles/pinch-zoom-view.global.css.map +1 -0
- package/dist-esm/basic/styles/popup-button.global.css +2 -0
- package/dist-esm/basic/styles/popup-button.global.css.map +1 -0
- package/dist-esm/basic/styles/popup.global.css +2 -0
- package/dist-esm/basic/styles/popup.global.css.map +1 -0
- package/dist-esm/basic/styles/radio-button-list.global.css +2 -0
- package/dist-esm/basic/styles/radio-button-list.global.css.map +1 -0
- package/dist-esm/basic/styles/repeater.global.css +2 -0
- package/dist-esm/basic/styles/repeater.global.css.map +1 -0
- package/dist-esm/basic/styles/scale.svg +4 -0
- package/dist-esm/basic/styles/suggestion-popup.global.css +2 -0
- package/dist-esm/basic/styles/suggestion-popup.global.css.map +1 -0
- package/dist-esm/basic/styles/suggestion.global.css +2 -0
- package/dist-esm/basic/styles/suggestion.global.css.map +1 -0
- package/dist-esm/basic/styles/swipe.global.css +2 -0
- package/dist-esm/basic/styles/swipe.global.css.map +1 -0
- package/dist-esm/basic/styles/switch.global.css +2 -0
- package/dist-esm/basic/styles/switch.global.css.map +1 -0
- package/dist-esm/basic/styles/time-editor.global.css +2 -0
- package/dist-esm/basic/styles/time-editor.global.css.map +1 -0
- package/dist-esm/basic/styles/title-editor.global.css +2 -0
- package/dist-esm/basic/styles/title-editor.global.css.map +1 -0
- package/dist-esm/basic/styles/toggle-button-bar.global.css +2 -0
- package/dist-esm/basic/styles/toggle-button-bar.global.css.map +1 -0
- package/dist-esm/basic/styles/toggle-view.global.css +2 -0
- package/dist-esm/basic/styles/toggle-view.global.css.map +1 -0
- package/dist-esm/basic/styles/tooltip.global.css +2 -0
- package/dist-esm/basic/styles/tooltip.global.css.map +1 -0
- package/dist-esm/basic/styles/zoom-view.global.css +2 -0
- package/dist-esm/basic/styles/zoom-view.global.css.map +1 -0
- package/dist-esm/desktop-app/DesktopApp.js +65 -80
- package/dist-esm/desktop-app/MobileDesktopApp.js +20 -23
- package/dist-esm/html-editor/AtomHtmlEditor.js +243 -268
- package/dist-esm/html-editor/HtmlEditorCommands.js +6 -4
- package/dist-esm/html-editor/InlineHtmlEditor.js +174 -166
- package/dist-esm/html-editor/RangeEditor.js +49 -51
- package/dist-esm/html-editor/commands/AddImage.js +40 -35
- package/dist-esm/html-editor/commands/AddLink.js +56 -54
- package/dist-esm/html-editor/commands/AddLink.local.css +2 -0
- package/dist-esm/html-editor/commands/AddLink.local.css.map +1 -0
- package/dist-esm/html-editor/commands/Align.js +24 -7
- package/dist-esm/html-editor/commands/AttachFile.js +23 -13
- package/dist-esm/html-editor/commands/AttachImage.js +35 -25
- package/dist-esm/html-editor/commands/Bold.js +10 -11
- package/dist-esm/html-editor/commands/ChangeColor.js +31 -107
- package/dist-esm/html-editor/commands/ChangeColor.local.css +2 -0
- package/dist-esm/html-editor/commands/ChangeColor.local.css.map +1 -0
- package/dist-esm/html-editor/commands/ChangeFont.js +42 -42
- package/dist-esm/html-editor/commands/ChangeFont.local.css +2 -0
- package/dist-esm/html-editor/commands/ChangeFont.local.css.map +1 -0
- package/dist-esm/html-editor/commands/ChangeFontSize.js +15 -5
- package/dist-esm/html-editor/commands/Command.js +34 -16
- package/dist-esm/html-editor/commands/CommandButton.js +51 -32
- package/dist-esm/html-editor/commands/Headings.js +25 -9
- package/dist-esm/html-editor/commands/HorizontalRule.js +9 -10
- package/dist-esm/html-editor/commands/HtmlCommands.js +160 -65
- package/dist-esm/html-editor/commands/IndentLess.js +10 -11
- package/dist-esm/html-editor/commands/IndentMore.js +10 -11
- package/dist-esm/html-editor/commands/Italic.js +10 -11
- package/dist-esm/html-editor/commands/NumberedList.js +10 -11
- package/dist-esm/html-editor/commands/Quote.js +10 -11
- package/dist-esm/html-editor/commands/RemoveFormat.js +10 -11
- package/dist-esm/html-editor/commands/Separator.global.css +2 -0
- package/dist-esm/html-editor/commands/Separator.global.css.map +1 -0
- package/dist-esm/html-editor/commands/Separator.js +5 -4
- package/dist-esm/html-editor/commands/Source.js +29 -25
- package/dist-esm/html-editor/commands/Source.local.css +2 -0
- package/dist-esm/html-editor/commands/Source.local.css.map +1 -0
- package/dist-esm/html-editor/commands/StrikeThrough.js +10 -11
- package/dist-esm/html-editor/commands/Toolbar.js +6 -4
- package/dist-esm/html-editor/commands/Underline.js +10 -11
- package/dist-esm/html-editor/commands/Unlink.js +10 -9
- package/dist-esm/html-editor/commands/UnorderedList.js +10 -11
- package/dist-esm/mobile-app/BottomPopup.js +137 -148
- package/dist-esm/mobile-app/MasterDetailPage.global.css +2 -0
- package/dist-esm/mobile-app/MasterDetailPage.global.css.map +1 -0
- package/dist-esm/mobile-app/MasterDetailPage.js +153 -152
- package/dist-esm/mobile-app/MobileApp.global.css +2 -0
- package/dist-esm/mobile-app/MobileApp.global.css.map +1 -0
- package/dist-esm/mobile-app/MobileApp.js +577 -569
- package/dist-esm/mobile-app/bottom-popup.global.css +2 -0
- package/dist-esm/mobile-app/bottom-popup.global.css.map +1 -0
- package/dist-esm/player/AtomVideoPlayer.global.css +2 -0
- package/dist-esm/player/AtomVideoPlayer.global.css.map +1 -0
- package/dist-esm/player/AtomVideoPlayer.js +316 -270
- package/dist-esm/player/TrackProgress.js +11 -7
- package/dist-esm/player/input-range-style.js +97 -98
- package/dist-esm/styles/atom-html-editor.global.css +2 -0
- package/dist-esm/styles/atom-html-editor.global.css.map +1 -0
- package/dist-esm/styles/button-bar.global.css +2 -0
- package/dist-esm/styles/button-bar.global.css.map +1 -0
- package/dist-esm/styles/desktop-app.global.css +2 -0
- package/dist-esm/styles/desktop-app.global.css.map +1 -0
- package/dist-esm/styles/form.global.css +2 -0
- package/dist-esm/styles/form.global.css.map +1 -0
- package/dist-esm/styles/html-editor-toolbar.global.css +2 -0
- package/dist-esm/styles/html-editor-toolbar.global.css.map +1 -0
- package/dist-esm/styles/inline-html-editor.global.css +2 -0
- package/dist-esm/styles/inline-html-editor.global.css.map +1 -0
- package/dist-esm/styles/limited-text.global.css +2 -0
- package/dist-esm/styles/limited-text.global.css.map +1 -0
- package/dist-esm/styles/resizable.global.css +2 -0
- package/dist-esm/styles/resizable.global.css.map +1 -0
- package/dist-esm/styles/track-progress.global.css +2 -0
- package/dist-esm/styles/track-progress.global.css.map +1 -0
- package/dist-esm/styles/type-writer.global.css +2 -0
- package/dist-esm/styles/type-writer.global.css.map +1 -0
- package/dist-esm/tests/app-test/AppTestApp.js +12 -15
- package/dist-esm/tests/app-test/AppTestApp.pack.js +54 -0
- package/dist-esm/tests/app-test/commands/AppCommands.js +14 -11
- package/dist-esm/tests/app-test/drawer/AppDrawer.js +4 -6
- package/dist-esm/tests/app-test/model/model.js +1 -2
- package/dist-esm/tests/app-test/pages/detail/DetailPage.js +21 -15
- package/dist-esm/tests/app-test/pages/home/HomePage.js +7 -8
- package/dist-esm/tests/app-test/pages/list/ListPage.js +79 -62
- package/dist-esm/tests/app-test/pages/list/ListPage.local.css +2 -0
- package/dist-esm/tests/app-test/pages/list/ListPage.local.css.map +1 -0
- package/dist-esm/tests/basic/PopupTest.js +9 -7
- package/dist-esm/tests/basic/TimeEditorTest.js +5 -9
- package/dist-esm/tests/basic/TimeEditorTest.pack.js +39 -0
- package/dist-esm/tests/basic/TimerTest.js +27 -37
- package/dist-esm/tests/basic/TimerTest.pack.js +40 -0
- package/dist-esm/tests/basic/basic-form/BasicForm.js +47 -27
- package/dist-esm/tests/basic/basic-form/BasicForm.pack.js +44 -0
- package/dist-esm/tests/basic/calendar/BasicCalendarTest.js +5 -9
- package/dist-esm/tests/basic/calendar/BasicCalendarTest.pack.js +53 -0
- package/dist-esm/tests/basic/chips/ChipsTest.js +25 -15
- package/dist-esm/tests/basic/chips/ChipsTest.local.css +2 -0
- package/dist-esm/tests/basic/chips/ChipsTest.local.css.map +1 -0
- package/dist-esm/tests/basic/chips/ChipsTest.pack.js +56 -0
- package/dist-esm/tests/basic/data-grid/DataGridTest.js +55 -60
- package/dist-esm/tests/basic/data-grid/DataGridTest.pack.js +58 -0
- package/dist-esm/tests/basic/date/DateFieldTest.js +21 -96
- package/dist-esm/tests/basic/date/DateFieldTest.pack.js +57 -0
- package/dist-esm/tests/basic/drop-down/DropDownTest.js +25 -19
- package/dist-esm/tests/basic/drop-down/DropDownTest.pack.js +52 -0
- package/dist-esm/tests/basic/drop-down-input/DropDownTest.js +32 -32
- package/dist-esm/tests/basic/drop-down-input/DropDownTest.pack.js +54 -0
- package/dist-esm/tests/basic/expander/ExpanderMenuTest.js +20 -14
- package/dist-esm/tests/basic/expander/ExpanderMenuTest.pack.js +38 -0
- package/dist-esm/tests/basic/expander/ExpanderTest.js +11 -12
- package/dist-esm/tests/basic/expander/ExpanderTest.pack.js +38 -0
- package/dist-esm/tests/basic/form2/Form2Test.js +26 -24
- package/dist-esm/tests/basic/form2/Form2Test.pack.js +46 -0
- package/dist-esm/tests/basic/limited-text/LimitedTextTest.js +14 -11
- package/dist-esm/tests/basic/limited-text/LimitedTextTest.pack.js +38 -0
- package/dist-esm/tests/basic/pinch-zoom/PinchZoomViewTest.global.css +2 -0
- package/dist-esm/tests/basic/pinch-zoom/PinchZoomViewTest.global.css.map +1 -0
- package/dist-esm/tests/basic/pinch-zoom/PinchZoomViewTest.js +14 -14
- package/dist-esm/tests/basic/pinch-zoom/PinchZoomViewTest.pack.js +38 -0
- package/dist-esm/tests/basic/repeater/DragDropRepater.js +30 -12
- package/dist-esm/tests/basic/repeater/DragDropRepater.pack.js +51 -0
- package/dist-esm/tests/basic/repeater/RepeaterTest.js +45 -35
- package/dist-esm/tests/basic/repeater/RepeaterTest.pack.js +52 -0
- package/dist-esm/tests/basic/swipe/SwipeTest.js +13 -13
- package/dist-esm/tests/basic/swipe/SwipeTest.local.css +2 -0
- package/dist-esm/tests/basic/swipe/SwipeTest.local.css.map +1 -0
- package/dist-esm/tests/basic/swipe/SwipeTest.pack.js +52 -0
- package/dist-esm/tests/basic/switch-test/SwitchTest.js +8 -10
- package/dist-esm/tests/basic/switch-test/SwitchTest.pack.js +38 -0
- package/dist-esm/tests/basic/title-editor/TitleEditorTest.js +8 -9
- package/dist-esm/tests/basic/title-editor/TitleEditorTest.pack.js +38 -0
- package/dist-esm/tests/basic/tooltip/TooltipTest.js +30 -24
- package/dist-esm/tests/basic/tooltip/TooltipTest.pack.js +52 -0
- package/dist-esm/tests/basic/typewriter/TypeWriter.js +10 -9
- package/dist-esm/tests/basic/typewriter/TypeWriter.pack.js +39 -0
- package/dist-esm/tests/basic/video/AtomVideoTest.js +13 -10
- package/dist-esm/tests/basic/video/AtomVideoTest.local.css +2 -0
- package/dist-esm/tests/basic/video/AtomVideoTest.local.css.map +1 -0
- package/dist-esm/tests/basic/video/AtomVideoTest.pack.js +38 -0
- package/dist-esm/tests/basic/zoom/ZoomViewTest.js +13 -13
- package/dist-esm/tests/basic/zoom/ZoomViewTest.local.css +2 -0
- package/dist-esm/tests/basic/zoom/ZoomViewTest.local.css.map +1 -0
- package/dist-esm/tests/basic/zoom/ZoomViewTest.pack.js +38 -0
- package/dist-esm/tests/check-box-list/CheckBoxListSample.js +13 -12
- package/dist-esm/tests/check-box-list/CheckBoxListSample.pack.js +52 -0
- package/dist-esm/tests/data-grid/GridTestViewModel.js +203 -227
- package/dist-esm/tests/form/CustomHelp.js +6 -9
- package/dist-esm/tests/form/FormViewModel.js +21 -28
- package/dist-esm/tests/html-editor/HtmlEditorTest.js +7 -37
- package/dist-esm/tests/html-editor/HtmlEditorTest.pack.js +83 -0
- package/dist-esm/tests/html-editor/InlineHtmlEdiorTest.js +9 -38
- package/dist-esm/tests/html-editor/InlineHtmlEdiorTest.pack.js +85 -0
- package/dist-esm/tests/mask/MaskedInputTest.js +11 -12
- package/dist-esm/tests/mask/MaskedInputTest.pack.js +38 -0
- package/dist-esm/tests/mobile-app/DesktopAppTest.js +8 -9
- package/dist-esm/tests/mobile-app/DesktopAppTest.pack.js +60 -0
- package/dist-esm/tests/mobile-app/MobileAppTest.js +64 -53
- package/dist-esm/tests/mobile-app/MobileAppTest.pack.js +55 -0
- package/dist-esm/tests/pop-over/PopOverTest.js +37 -77
- package/dist-esm/tests/switch/SwitchTest.js +9 -8
- package/dist-esm/tests/toggle-view/ToggleView.local.css +2 -0
- package/dist-esm/tests/toggle-view/ToggleView.local.css.map +1 -0
- package/dist-esm/tests/toggle-view/ToggleViewTest.js +15 -22
- package/dist-esm/tests/toggle-view/ToggleViewTest.pack.js +45 -0
- package/dist-esm/toggle-view/AtomToggleView.js +77 -73
- package/dist-esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@ import { AtomDisposableList } from "@web-atoms/core/dist/core/AtomDisposableList
|
|
|
2
2
|
import { CancelToken } from "@web-atoms/core/dist/core/types.js";
|
|
3
3
|
import XNode, { xnodeSymbol } from "@web-atoms/core/dist/core/XNode.js";
|
|
4
4
|
import { AtomControl, ElementValueSetters } from "@web-atoms/core/dist/web/controls/AtomControl.js";
|
|
5
|
-
import
|
|
5
|
+
ESMPack.installStyleSheet(import.meta.resolve("./AtomPopover.css"));
|
|
6
6
|
import { relativeRect } from "./relativeRect.js";
|
|
7
7
|
import getContainingBlock from "./getContainingBlock.js";
|
|
8
8
|
ElementValueSetters["anchor-left"] = (c, e, v) => e.setAttribute("anchor-left", v);
|
|
@@ -10,270 +10,287 @@ ElementValueSetters["anchor-right"] = (c, e, v) => e.setAttribute("anchor-right"
|
|
|
10
10
|
ElementValueSetters["anchor-top"] = (c, e, v) => e.setAttribute("anchor-top", v);
|
|
11
11
|
ElementValueSetters["anchor-bottom"] = (c, e, v) => e.setAttribute("anchor-bottom", v);
|
|
12
12
|
class AtomPopoverElement extends HTMLElement {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
this.lastParent = null;
|
|
33
|
-
const ce = new CustomEvent("removing", {
|
|
34
|
-
detail: { result: this.result, aborted: this.aborted },
|
|
35
|
-
bubbles: true,
|
|
36
|
-
cancelable: true
|
|
37
|
-
});
|
|
38
|
-
this.dispatchEvent(ce);
|
|
39
|
-
if (ce.defaultPrevented) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
this.dispatchEvent(new CustomEvent("removed", {
|
|
43
|
-
detail: { result: this.result, aborted: this.aborted },
|
|
44
|
-
bubbles: true,
|
|
45
|
-
}));
|
|
46
|
-
this.remove();
|
|
47
|
-
}, 250);
|
|
48
|
-
};
|
|
49
|
-
this.updatePosition = () => {
|
|
50
|
-
if (!this.parentElement) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const lastParent = this.lastParent = this.parentElement;
|
|
54
|
-
if (!lastParent) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const cb = getContainingBlock(lastParent);
|
|
58
|
-
if (!cb) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
this.containingBlock = cb;
|
|
62
|
-
const cbr = cb.getBoundingClientRect();
|
|
63
|
-
const rrSelf = relativeRect(this, cb);
|
|
64
|
-
const rrParent = relativeRect(this.parentElement, cb);
|
|
65
|
-
let anchorBottom = this.getAttribute("anchor-bottom");
|
|
66
|
-
let anchorRight = this.getAttribute("anchor-right");
|
|
67
|
-
let anchorTop = this.getAttribute("anchor-top");
|
|
68
|
-
let anchorLeft = this.getAttribute("anchor-left");
|
|
69
|
-
const firstChild = this.firstElementChild.getBoundingClientRect();
|
|
70
|
-
let diffTop = Math.min(window.visualViewport.height, cbr.height) - (rrParent.top + firstChild.height);
|
|
71
|
-
if (diffTop > 0) {
|
|
72
|
-
diffTop = 0;
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
diffTop -= 40;
|
|
76
|
-
if (!anchorBottom) {
|
|
77
|
-
anchorBottom = "parent-top";
|
|
78
|
-
anchorTop = void 0;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
let diffBottom = rrParent.top - firstChild.height;
|
|
82
|
-
if (diffBottom > 0) {
|
|
83
|
-
diffBottom = 0;
|
|
84
|
-
}
|
|
85
|
-
const topLeft = {
|
|
86
|
-
"parent-left": `${rrParent.left}px`,
|
|
87
|
-
"parent-right": `${rrSelf.left}px`,
|
|
88
|
-
"parent-top": `${rrParent.top + diffTop}px`,
|
|
89
|
-
"parent-bottom": `${rrParent.top + rrParent.height + diffTop}px`
|
|
90
|
-
};
|
|
91
|
-
const bottomRight = {
|
|
92
|
-
"parent-left": `${rrParent.right}px`,
|
|
93
|
-
"parent-right": `${rrSelf.right}px`,
|
|
94
|
-
"parent-top": `${rrParent.bottom + rrSelf.height + diffBottom}px`,
|
|
95
|
-
"parent-bottom": `${rrParent.bottom + rrParent.height + diffBottom}px`
|
|
96
|
-
};
|
|
97
|
-
const style = this.slotElement.style;
|
|
98
|
-
style.removeProperty("left");
|
|
99
|
-
style.removeProperty("top");
|
|
100
|
-
style.removeProperty("right");
|
|
101
|
-
style.removeProperty("bottom");
|
|
102
|
-
if (!anchorBottom) {
|
|
103
|
-
anchorTop ||= "parent-bottom";
|
|
104
|
-
}
|
|
105
|
-
if (!anchorRight) {
|
|
106
|
-
anchorLeft ||= "parent-right";
|
|
107
|
-
}
|
|
108
|
-
if (anchorTop) {
|
|
109
|
-
style.top = topLeft[anchorTop];
|
|
110
|
-
}
|
|
111
|
-
if (anchorLeft) {
|
|
112
|
-
style.left = topLeft[anchorLeft];
|
|
113
|
-
}
|
|
114
|
-
if (anchorBottom) {
|
|
115
|
-
style.bottom = bottomRight[anchorBottom];
|
|
116
|
-
}
|
|
117
|
-
if (anchorRight) {
|
|
118
|
-
style.right = bottomRight[anchorRight];
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
connectedCallback() {
|
|
123
|
-
if (!this.root) {
|
|
124
|
-
const root = this.root = this.attachShadow({ mode: "open" });
|
|
125
|
-
const slot = document.createElement("slot");
|
|
126
|
-
slot.setAttribute("part", "container");
|
|
127
|
-
this.slotElement = slot;
|
|
128
|
-
root.appendChild(slot);
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.aborted = "cancel";
|
|
16
|
+
this.closePopover = e => {
|
|
17
|
+
const cancelOnBlur = /^(true|yes|1)$/i.test(this.getAttribute("cancel-on-blur") || "true");
|
|
18
|
+
if (!cancelOnBlur) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
setTimeout(() => {
|
|
22
|
+
let target = e.target;
|
|
23
|
+
while (target) {
|
|
24
|
+
if (target.hasAttribute("data-close-on-click")) {
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
if (target === this.parentElement) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
target = target.parentElement;
|
|
129
31
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
32
|
+
this.lastParent = null;
|
|
33
|
+
const ce = new CustomEvent("removing", {
|
|
34
|
+
detail: {
|
|
35
|
+
result: this.result,
|
|
36
|
+
aborted: this.aborted
|
|
37
|
+
},
|
|
38
|
+
bubbles: true,
|
|
39
|
+
cancelable: true
|
|
40
|
+
});
|
|
41
|
+
this.dispatchEvent(ce);
|
|
42
|
+
if (ce.defaultPrevented) {
|
|
43
|
+
return;
|
|
142
44
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
45
|
+
this.dispatchEvent(new CustomEvent("removed", {
|
|
46
|
+
detail: {
|
|
47
|
+
result: this.result,
|
|
48
|
+
aborted: this.aborted
|
|
49
|
+
},
|
|
50
|
+
bubbles: true
|
|
51
|
+
}));
|
|
52
|
+
this.remove();
|
|
53
|
+
}, 250);
|
|
54
|
+
};
|
|
55
|
+
this.updatePosition = () => {
|
|
56
|
+
if (!this.parentElement) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const lastParent = this.lastParent = this.parentElement;
|
|
60
|
+
if (!lastParent) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const cb = getContainingBlock(lastParent);
|
|
64
|
+
if (!cb) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
this.containingBlock = cb;
|
|
68
|
+
const cbr = cb.getBoundingClientRect();
|
|
69
|
+
const rrSelf = relativeRect(this, cb);
|
|
70
|
+
const rrParent = relativeRect(this.parentElement, cb);
|
|
71
|
+
let anchorBottom = this.getAttribute("anchor-bottom");
|
|
72
|
+
let anchorRight = this.getAttribute("anchor-right");
|
|
73
|
+
let anchorTop = this.getAttribute("anchor-top");
|
|
74
|
+
let anchorLeft = this.getAttribute("anchor-left");
|
|
75
|
+
const firstChild = this.firstElementChild.getBoundingClientRect();
|
|
76
|
+
let diffTop = Math.min(window.visualViewport.height, cbr.height) - (rrParent.top + firstChild.height);
|
|
77
|
+
if (diffTop > 0) {
|
|
78
|
+
diffTop = 0;
|
|
79
|
+
} else {
|
|
80
|
+
diffTop -= 40;
|
|
81
|
+
if (!anchorBottom) {
|
|
82
|
+
anchorBottom = "parent-top";
|
|
83
|
+
anchorTop = void 0;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
let diffBottom = rrParent.top - firstChild.height;
|
|
87
|
+
if (diffBottom > 0) {
|
|
88
|
+
diffBottom = 0;
|
|
89
|
+
}
|
|
90
|
+
const topLeft = {
|
|
91
|
+
"parent-left": `${rrParent.left}px`,
|
|
92
|
+
"parent-right": `${rrSelf.left}px`,
|
|
93
|
+
"parent-top": `${rrParent.top + diffTop}px`,
|
|
94
|
+
"parent-bottom": `${rrParent.top + rrParent.height + diffTop}px`
|
|
95
|
+
};
|
|
96
|
+
const bottomRight = {
|
|
97
|
+
"parent-left": `${rrParent.right}px`,
|
|
98
|
+
"parent-right": `${rrSelf.right}px`,
|
|
99
|
+
"parent-top": `${rrParent.bottom + rrSelf.height + diffBottom}px`,
|
|
100
|
+
"parent-bottom": `${rrParent.bottom + rrParent.height + diffBottom}px`
|
|
101
|
+
};
|
|
102
|
+
const style = this.slotElement.style;
|
|
103
|
+
style.removeProperty("left");
|
|
104
|
+
style.removeProperty("top");
|
|
105
|
+
style.removeProperty("right");
|
|
106
|
+
style.removeProperty("bottom");
|
|
107
|
+
if (!anchorBottom) {
|
|
108
|
+
anchorTop ||= "parent-bottom";
|
|
109
|
+
}
|
|
110
|
+
if (!anchorRight) {
|
|
111
|
+
anchorLeft ||= "parent-right";
|
|
112
|
+
}
|
|
113
|
+
if (anchorTop) {
|
|
114
|
+
style.top = topLeft[anchorTop];
|
|
115
|
+
}
|
|
116
|
+
if (anchorLeft) {
|
|
117
|
+
style.left = topLeft[anchorLeft];
|
|
118
|
+
}
|
|
119
|
+
if (anchorBottom) {
|
|
120
|
+
style.bottom = bottomRight[anchorBottom];
|
|
121
|
+
}
|
|
122
|
+
if (anchorRight) {
|
|
123
|
+
style.right = bottomRight[anchorRight];
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
connectedCallback() {
|
|
128
|
+
if (!this.root) {
|
|
129
|
+
const root = this.root = this.attachShadow({
|
|
130
|
+
mode: "open"
|
|
131
|
+
});
|
|
132
|
+
const slot = document.createElement("slot");
|
|
133
|
+
slot.setAttribute("part", "container");
|
|
134
|
+
this.slotElement = slot;
|
|
135
|
+
root.appendChild(slot);
|
|
136
|
+
}
|
|
137
|
+
setTimeout(() => this.updatePosition(), 100);
|
|
138
|
+
window.addEventListener("scroll", this.updatePosition, {
|
|
139
|
+
passive: true,
|
|
140
|
+
capture: true
|
|
141
|
+
});
|
|
142
|
+
setTimeout(() => {
|
|
143
|
+
document.body.addEventListener("click", this.closePopover);
|
|
144
|
+
}, 100);
|
|
145
|
+
}
|
|
146
|
+
disconnectedCallback() {
|
|
147
|
+
if (this.lastParent?.isConnected) {
|
|
148
|
+
this.dispatchEvent(new CustomEvent("removed", {
|
|
149
|
+
detail: {
|
|
150
|
+
result: this.result,
|
|
151
|
+
aborted: this.aborted
|
|
152
|
+
},
|
|
153
|
+
bubbles: true
|
|
154
|
+
}));
|
|
146
155
|
}
|
|
156
|
+
document.body.removeEventListener("click", this.closePopover);
|
|
157
|
+
window.removeEventListener("scroll", this.updatePosition);
|
|
158
|
+
clearInterval(this.timer);
|
|
159
|
+
}
|
|
147
160
|
}
|
|
148
161
|
const existingPopup = Symbol("popup");
|
|
149
162
|
export default class AtomPopover {
|
|
150
|
-
|
|
151
|
-
|
|
163
|
+
static create(parent, options = {}) {
|
|
164
|
+
return parent[existingPopup] ??= new this(parent, options);
|
|
165
|
+
}
|
|
166
|
+
static show(parent, options = {}) {
|
|
167
|
+
const p = parent[existingPopup] ??= new this(parent, options);
|
|
168
|
+
return p.resultPromise;
|
|
169
|
+
}
|
|
170
|
+
static menu(parent, node, options = {}) {
|
|
171
|
+
const ct = new CancelToken();
|
|
172
|
+
options.nodeFactory = () => node;
|
|
173
|
+
const p = new this(parent, options);
|
|
174
|
+
p.result = 1;
|
|
175
|
+
p.disposables.add(p.owner.bindEvent(p.popover, "click", () => {
|
|
176
|
+
setTimeout(() => {
|
|
177
|
+
ct.cancel();
|
|
178
|
+
}, 10);
|
|
179
|
+
}));
|
|
180
|
+
return p;
|
|
181
|
+
}
|
|
182
|
+
set renderer(v) {
|
|
183
|
+
const owner = this.owner;
|
|
184
|
+
let first = this.popoverContainer.firstElementChild;
|
|
185
|
+
while (first) {
|
|
186
|
+
const next = first.nextElementSibling;
|
|
187
|
+
owner.dispose(first);
|
|
188
|
+
first.remove();
|
|
189
|
+
first = next;
|
|
152
190
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return p.resultPromise;
|
|
191
|
+
if (!v) {
|
|
192
|
+
return;
|
|
156
193
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
p.result = 1;
|
|
162
|
-
p.disposables.add(p.owner.bindEvent(p.popover, "click", () => {
|
|
163
|
-
setTimeout(() => {
|
|
164
|
-
ct.cancel();
|
|
165
|
-
}, 10);
|
|
166
|
-
}));
|
|
167
|
-
return p;
|
|
194
|
+
if (v[xnodeSymbol]) {
|
|
195
|
+
this.owner.render(XNode.create("div", null, " ", v, " "), this.popoverContainer, this.owner);
|
|
196
|
+
} else {
|
|
197
|
+
this.popoverContainer.appendChild(v);
|
|
168
198
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
199
|
+
this.popoverContainer.updatePosition?.();
|
|
200
|
+
}
|
|
201
|
+
constructor(parent, options = {}) {
|
|
202
|
+
this.disposables = new AtomDisposableList();
|
|
203
|
+
this.removing = ce => {
|
|
204
|
+
if (this.cancel) {
|
|
205
|
+
ce?.preventDefault();
|
|
206
|
+
const c = this.cancel?.();
|
|
207
|
+
if (c?.then) {
|
|
208
|
+
c.then(() => {
|
|
209
|
+
this.renderer = void 0;
|
|
210
|
+
this.remove();
|
|
211
|
+
}, console.warn);
|
|
180
212
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
this.
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
this.remove = () => {
|
|
216
|
+
const {
|
|
217
|
+
result
|
|
218
|
+
} = this.popover;
|
|
219
|
+
if (result === void 0) {
|
|
220
|
+
this.resultReject?.("canceled");
|
|
221
|
+
} else {
|
|
222
|
+
this.resultResolve?.(result);
|
|
223
|
+
}
|
|
224
|
+
this.disposables.dispose();
|
|
225
|
+
this.popover.remove();
|
|
226
|
+
};
|
|
227
|
+
const p1 = parent;
|
|
228
|
+
this.disposables.add(() => p1[existingPopup] = null);
|
|
229
|
+
if (parent instanceof AtomControl) {
|
|
230
|
+
this.owner = parent;
|
|
231
|
+
parent = this.owner.element;
|
|
232
|
+
} else {
|
|
233
|
+
this.owner = AtomControl.from(parent);
|
|
191
234
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const p1 = parent;
|
|
218
|
-
this.disposables.add(() => p1[existingPopup] = null);
|
|
219
|
-
if (parent instanceof AtomControl) {
|
|
220
|
-
this.owner = parent;
|
|
221
|
-
parent = this.owner.element;
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
this.owner = AtomControl.from(parent);
|
|
225
|
-
}
|
|
226
|
-
const popover = this.popover = document.createElement("atom-pop-over");
|
|
227
|
-
this.popoverContainer = popover;
|
|
228
|
-
parent.appendChild(popover);
|
|
229
|
-
const { cancelToken, nodeFactory, dataFactory, closeOnClick = true, "anchor-left": anchorLeft, "anchor-right": anchorRight, "anchor-top": anchorTop, "anchor-bottom": anchorBottom } = options;
|
|
230
|
-
cancelToken?.registerForCancel(this.removing);
|
|
231
|
-
if (anchorLeft) {
|
|
232
|
-
popover.setAttribute("anchor-left", anchorLeft);
|
|
233
|
-
}
|
|
234
|
-
if (anchorRight) {
|
|
235
|
-
popover.setAttribute("anchor-right", anchorRight);
|
|
236
|
-
}
|
|
237
|
-
if (anchorTop) {
|
|
238
|
-
popover.setAttribute("anchor-top", anchorTop);
|
|
239
|
-
}
|
|
240
|
-
if (anchorBottom) {
|
|
241
|
-
popover.setAttribute("anchor-bottom", anchorBottom);
|
|
242
|
-
}
|
|
243
|
-
if (closeOnClick) {
|
|
244
|
-
popover.setAttribute("data-close-on-click", "1");
|
|
245
|
-
}
|
|
246
|
-
popover.addEventListener("removing", this.removing);
|
|
247
|
-
popover.addEventListener("removed", this.remove);
|
|
248
|
-
this.disposables.add(() => {
|
|
249
|
-
popover.removeEventListener("removed", this.remove);
|
|
250
|
-
popover.removeEventListener("removing", this.removing);
|
|
251
|
-
});
|
|
252
|
-
this.init ??= (data) => {
|
|
253
|
-
if (nodeFactory) {
|
|
254
|
-
this.renderer = nodeFactory(data);
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
const p = this.init?.(dataFactory?.());
|
|
258
|
-
if (p?.then) {
|
|
259
|
-
p.then(() => void 0, console.warn);
|
|
260
|
-
}
|
|
261
|
-
this.resultPromise = new Promise((resolve, reject) => {
|
|
262
|
-
this.resultResolve = resolve;
|
|
263
|
-
this.resultReject = reject;
|
|
264
|
-
});
|
|
265
|
-
this.resultPromise.catch(() => void 0);
|
|
235
|
+
const popover = this.popover = document.createElement("atom-pop-over");
|
|
236
|
+
this.popoverContainer = popover;
|
|
237
|
+
parent.appendChild(popover);
|
|
238
|
+
const {
|
|
239
|
+
cancelToken,
|
|
240
|
+
nodeFactory,
|
|
241
|
+
dataFactory,
|
|
242
|
+
closeOnClick = true,
|
|
243
|
+
"anchor-left": anchorLeft,
|
|
244
|
+
"anchor-right": anchorRight,
|
|
245
|
+
"anchor-top": anchorTop,
|
|
246
|
+
"anchor-bottom": anchorBottom
|
|
247
|
+
} = options;
|
|
248
|
+
cancelToken?.registerForCancel(this.removing);
|
|
249
|
+
if (anchorLeft) {
|
|
250
|
+
popover.setAttribute("anchor-left", anchorLeft);
|
|
251
|
+
}
|
|
252
|
+
if (anchorRight) {
|
|
253
|
+
popover.setAttribute("anchor-right", anchorRight);
|
|
254
|
+
}
|
|
255
|
+
if (anchorTop) {
|
|
256
|
+
popover.setAttribute("anchor-top", anchorTop);
|
|
257
|
+
}
|
|
258
|
+
if (anchorBottom) {
|
|
259
|
+
popover.setAttribute("anchor-bottom", anchorBottom);
|
|
266
260
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
this.popover.result = r ?? null;
|
|
270
|
-
this.popover.remove();
|
|
261
|
+
if (closeOnClick) {
|
|
262
|
+
popover.setAttribute("data-close-on-click", "1");
|
|
271
263
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
264
|
+
popover.addEventListener("removing", this.removing);
|
|
265
|
+
popover.addEventListener("removed", this.remove);
|
|
266
|
+
this.disposables.add(() => {
|
|
267
|
+
popover.removeEventListener("removed", this.remove);
|
|
268
|
+
popover.removeEventListener("removing", this.removing);
|
|
269
|
+
});
|
|
270
|
+
this.init ??= data => {
|
|
271
|
+
if (nodeFactory) {
|
|
272
|
+
this.renderer = nodeFactory(data);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
const p = this.init?.(dataFactory?.());
|
|
276
|
+
if (p?.then) {
|
|
277
|
+
p.then(() => void 0, console.warn);
|
|
276
278
|
}
|
|
279
|
+
this.resultPromise = new Promise((resolve, reject) => {
|
|
280
|
+
this.resultResolve = resolve;
|
|
281
|
+
this.resultReject = reject;
|
|
282
|
+
});
|
|
283
|
+
this.resultPromise.catch(() => void 0);
|
|
284
|
+
}
|
|
285
|
+
close(r) {
|
|
286
|
+
this.removed = true;
|
|
287
|
+
this.popover.result = r ?? null;
|
|
288
|
+
this.popover.remove();
|
|
289
|
+
}
|
|
290
|
+
async cancel() {
|
|
291
|
+
this.removed = true;
|
|
292
|
+
delete this.popover.result;
|
|
293
|
+
this.popover.remove();
|
|
294
|
+
}
|
|
277
295
|
}
|
|
278
|
-
customElements.define("atom-pop-over", AtomPopoverElement);
|
|
279
|
-
//# sourceMappingURL=AtomPopover.js.map
|
|
296
|
+
customElements.define("atom-pop-over", AtomPopoverElement);
|
|
@@ -1,37 +1,36 @@
|
|
|
1
|
-
const getContainingBlock =
|
|
2
|
-
|
|
3
|
-
return document.body;
|
|
4
|
-
}
|
|
5
|
-
let start = node.parentElement;
|
|
6
|
-
while (start) {
|
|
7
|
-
const cs = getComputedStyle(start);
|
|
8
|
-
if (cs.filter !== "none") {
|
|
9
|
-
return start;
|
|
10
|
-
}
|
|
11
|
-
if (cs.backdropFilter !== "none") {
|
|
12
|
-
return start;
|
|
13
|
-
}
|
|
14
|
-
if (cs.transform !== "none") {
|
|
15
|
-
return start;
|
|
16
|
-
}
|
|
17
|
-
if (cs.perspective !== "none") {
|
|
18
|
-
return start;
|
|
19
|
-
}
|
|
20
|
-
if (/layout|paint|strict|content/i.test(cs.contain)) {
|
|
21
|
-
return start;
|
|
22
|
-
}
|
|
23
|
-
if (cs.containerType && cs.containerType !== "normal") {
|
|
24
|
-
return start;
|
|
25
|
-
}
|
|
26
|
-
if (/filter|transform/i.test(cs.willChange)) {
|
|
27
|
-
return start;
|
|
28
|
-
}
|
|
29
|
-
if (/auto/i.test(cs.contentVisibility)) {
|
|
30
|
-
return start;
|
|
31
|
-
}
|
|
32
|
-
start = start.parentElement;
|
|
33
|
-
}
|
|
1
|
+
const getContainingBlock = node => {
|
|
2
|
+
if (!node || !node.parentElement) {
|
|
34
3
|
return document.body;
|
|
4
|
+
}
|
|
5
|
+
let start = node.parentElement;
|
|
6
|
+
while (start) {
|
|
7
|
+
const cs = getComputedStyle(start);
|
|
8
|
+
if (cs.filter !== "none") {
|
|
9
|
+
return start;
|
|
10
|
+
}
|
|
11
|
+
if (cs.backdropFilter !== "none") {
|
|
12
|
+
return start;
|
|
13
|
+
}
|
|
14
|
+
if (cs.transform !== "none") {
|
|
15
|
+
return start;
|
|
16
|
+
}
|
|
17
|
+
if (cs.perspective !== "none") {
|
|
18
|
+
return start;
|
|
19
|
+
}
|
|
20
|
+
if (/layout|paint|strict|content/i.test(cs.contain)) {
|
|
21
|
+
return start;
|
|
22
|
+
}
|
|
23
|
+
if (cs.containerType && cs.containerType !== "normal") {
|
|
24
|
+
return start;
|
|
25
|
+
}
|
|
26
|
+
if (/filter|transform/i.test(cs.willChange)) {
|
|
27
|
+
return start;
|
|
28
|
+
}
|
|
29
|
+
if (/auto/i.test(cs.contentVisibility)) {
|
|
30
|
+
return start;
|
|
31
|
+
}
|
|
32
|
+
start = start.parentElement;
|
|
33
|
+
}
|
|
34
|
+
return document.body;
|
|
35
35
|
};
|
|
36
|
-
export default getContainingBlock;
|
|
37
|
-
//# sourceMappingURL=getContainingBlock.js.map
|
|
36
|
+
export default getContainingBlock;
|
|
@@ -1,24 +1,43 @@
|
|
|
1
1
|
const getScreenRect = (e, cbr = e.getBoundingClientRect()) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
const {
|
|
3
|
+
left,
|
|
4
|
+
top,
|
|
5
|
+
height,
|
|
6
|
+
width
|
|
7
|
+
} = cbr;
|
|
8
|
+
const right = visualViewport.width - left - width;
|
|
9
|
+
const bottom = visualViewport.height - top - height;
|
|
10
|
+
return {
|
|
11
|
+
left,
|
|
12
|
+
top,
|
|
13
|
+
right,
|
|
14
|
+
bottom,
|
|
15
|
+
height,
|
|
16
|
+
width
|
|
17
|
+
};
|
|
6
18
|
};
|
|
7
19
|
export function relativeRect(e, cb) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const ebr = getScreenRect(e);
|
|
21
|
+
const cbr = getScreenRect(cb);
|
|
22
|
+
let left = ebr.left;
|
|
23
|
+
let top = ebr.top;
|
|
24
|
+
let bottom = ebr.bottom;
|
|
25
|
+
let right = ebr.right;
|
|
26
|
+
if (cb.offsetParent) {
|
|
27
|
+
left -= cbr.left;
|
|
28
|
+
top -= cbr.top;
|
|
29
|
+
bottom -= cbr.bottom;
|
|
30
|
+
right -= cbr.right;
|
|
31
|
+
}
|
|
32
|
+
const height = e.offsetHeight;
|
|
33
|
+
const width = e.offsetWidth;
|
|
34
|
+
return {
|
|
35
|
+
left,
|
|
36
|
+
top,
|
|
37
|
+
bottom,
|
|
38
|
+
right,
|
|
39
|
+
width,
|
|
40
|
+
height,
|
|
41
|
+
e
|
|
42
|
+
};
|
|
43
|
+
}
|