@react-aria/utils 3.33.0 → 3.34.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/import.mjs +47 -43
- package/dist/main.js +120 -114
- package/dist/main.js.map +1 -1
- package/dist/module.js +47 -43
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +45 -0
- package/package.json +15 -15
- package/src/index.ts +45 -43
- package/dist/DOMFunctions.main.js +0 -44
- package/dist/DOMFunctions.main.js.map +0 -1
- package/dist/DOMFunctions.mjs +0 -37
- package/dist/DOMFunctions.module.js +0 -37
- package/dist/DOMFunctions.module.js.map +0 -1
- package/dist/ShadowTreeWalker.main.js +0 -200
- package/dist/ShadowTreeWalker.main.js.map +0 -1
- package/dist/ShadowTreeWalker.mjs +0 -194
- package/dist/ShadowTreeWalker.module.js +0 -194
- package/dist/ShadowTreeWalker.module.js.map +0 -1
- package/dist/animation.main.js +0 -97
- package/dist/animation.main.js.map +0 -1
- package/dist/animation.mjs +0 -91
- package/dist/animation.module.js +0 -91
- package/dist/animation.module.js.map +0 -1
- package/dist/chain.main.js +0 -26
- package/dist/chain.main.js.map +0 -1
- package/dist/chain.mjs +0 -21
- package/dist/chain.module.js +0 -21
- package/dist/chain.module.js.map +0 -1
- package/dist/constants.main.js +0 -23
- package/dist/constants.main.js.map +0 -1
- package/dist/constants.mjs +0 -17
- package/dist/constants.module.js +0 -17
- package/dist/constants.module.js.map +0 -1
- package/dist/domHelpers.main.js +0 -28
- package/dist/domHelpers.main.js.map +0 -1
- package/dist/domHelpers.mjs +0 -21
- package/dist/domHelpers.module.js +0 -21
- package/dist/domHelpers.module.js.map +0 -1
- package/dist/filterDOMProps.main.js +0 -88
- package/dist/filterDOMProps.main.js.map +0 -1
- package/dist/filterDOMProps.mjs +0 -83
- package/dist/filterDOMProps.module.js +0 -83
- package/dist/filterDOMProps.module.js.map +0 -1
- package/dist/focusWithoutScrolling.main.js +0 -72
- package/dist/focusWithoutScrolling.main.js.map +0 -1
- package/dist/focusWithoutScrolling.mjs +0 -67
- package/dist/focusWithoutScrolling.module.js +0 -67
- package/dist/focusWithoutScrolling.module.js.map +0 -1
- package/dist/getOffset.main.js +0 -24
- package/dist/getOffset.main.js.map +0 -1
- package/dist/getOffset.mjs +0 -19
- package/dist/getOffset.module.js +0 -19
- package/dist/getOffset.module.js.map +0 -1
- package/dist/getScrollParent.main.js +0 -28
- package/dist/getScrollParent.main.js.map +0 -1
- package/dist/getScrollParent.mjs +0 -23
- package/dist/getScrollParent.module.js +0 -23
- package/dist/getScrollParent.module.js.map +0 -1
- package/dist/getScrollParents.main.js +0 -30
- package/dist/getScrollParents.main.js.map +0 -1
- package/dist/getScrollParents.mjs +0 -25
- package/dist/getScrollParents.module.js +0 -25
- package/dist/getScrollParents.module.js.map +0 -1
- package/dist/inertValue.main.js +0 -19
- package/dist/inertValue.main.js.map +0 -1
- package/dist/inertValue.mjs +0 -14
- package/dist/inertValue.module.js +0 -14
- package/dist/inertValue.module.js.map +0 -1
- package/dist/isElementVisible.main.js +0 -45
- package/dist/isElementVisible.main.js.map +0 -1
- package/dist/isElementVisible.mjs +0 -40
- package/dist/isElementVisible.module.js +0 -40
- package/dist/isElementVisible.module.js.map +0 -1
- package/dist/isFocusable.main.js +0 -56
- package/dist/isFocusable.main.js.map +0 -1
- package/dist/isFocusable.mjs +0 -50
- package/dist/isFocusable.module.js +0 -50
- package/dist/isFocusable.module.js.map +0 -1
- package/dist/isScrollable.main.js +0 -26
- package/dist/isScrollable.main.js.map +0 -1
- package/dist/isScrollable.mjs +0 -21
- package/dist/isScrollable.module.js +0 -21
- package/dist/isScrollable.module.js.map +0 -1
- package/dist/isVirtualEvent.main.js +0 -41
- package/dist/isVirtualEvent.main.js.map +0 -1
- package/dist/isVirtualEvent.mjs +0 -35
- package/dist/isVirtualEvent.module.js +0 -35
- package/dist/isVirtualEvent.module.js.map +0 -1
- package/dist/keyboard.main.js +0 -42
- package/dist/keyboard.main.js.map +0 -1
- package/dist/keyboard.mjs +0 -36
- package/dist/keyboard.module.js +0 -36
- package/dist/keyboard.module.js.map +0 -1
- package/dist/mergeProps.main.js +0 -54
- package/dist/mergeProps.main.js.map +0 -1
- package/dist/mergeProps.mjs +0 -45
- package/dist/mergeProps.module.js +0 -45
- package/dist/mergeProps.module.js.map +0 -1
- package/dist/mergeRefs.main.js +0 -40
- package/dist/mergeRefs.main.js.map +0 -1
- package/dist/mergeRefs.mjs +0 -35
- package/dist/mergeRefs.module.js +0 -35
- package/dist/mergeRefs.module.js.map +0 -1
- package/dist/openLink.main.js +0 -169
- package/dist/openLink.main.js.map +0 -1
- package/dist/openLink.mjs +0 -153
- package/dist/openLink.module.js +0 -153
- package/dist/openLink.module.js.map +0 -1
- package/dist/platform.main.js +0 -73
- package/dist/platform.main.js.map +0 -1
- package/dist/platform.mjs +0 -60
- package/dist/platform.module.js +0 -60
- package/dist/platform.module.js.map +0 -1
- package/dist/runAfterTransition.main.js +0 -92
- package/dist/runAfterTransition.main.js.map +0 -1
- package/dist/runAfterTransition.mjs +0 -87
- package/dist/runAfterTransition.module.js +0 -87
- package/dist/runAfterTransition.module.js.map +0 -1
- package/dist/scrollIntoView.main.js +0 -105
- package/dist/scrollIntoView.main.js.map +0 -1
- package/dist/scrollIntoView.mjs +0 -99
- package/dist/scrollIntoView.module.js +0 -99
- package/dist/scrollIntoView.module.js.map +0 -1
- package/dist/types.d.ts +0 -286
- package/dist/types.d.ts.map +0 -1
- package/dist/useDeepMemo.main.js +0 -30
- package/dist/useDeepMemo.main.js.map +0 -1
- package/dist/useDeepMemo.mjs +0 -25
- package/dist/useDeepMemo.module.js +0 -25
- package/dist/useDeepMemo.module.js.map +0 -1
- package/dist/useDescription.main.js +0 -59
- package/dist/useDescription.main.js.map +0 -1
- package/dist/useDescription.mjs +0 -54
- package/dist/useDescription.module.js +0 -54
- package/dist/useDescription.module.js.map +0 -1
- package/dist/useDrag1D.main.js +0 -141
- package/dist/useDrag1D.main.js.map +0 -1
- package/dist/useDrag1D.mjs +0 -136
- package/dist/useDrag1D.module.js +0 -136
- package/dist/useDrag1D.module.js.map +0 -1
- package/dist/useEffectEvent.main.js +0 -45
- package/dist/useEffectEvent.main.js.map +0 -1
- package/dist/useEffectEvent.mjs +0 -36
- package/dist/useEffectEvent.module.js +0 -36
- package/dist/useEffectEvent.module.js.map +0 -1
- package/dist/useEvent.main.js +0 -41
- package/dist/useEvent.main.js.map +0 -1
- package/dist/useEvent.mjs +0 -36
- package/dist/useEvent.module.js +0 -36
- package/dist/useEvent.module.js.map +0 -1
- package/dist/useFormReset.main.js +0 -39
- package/dist/useFormReset.main.js.map +0 -1
- package/dist/useFormReset.mjs +0 -34
- package/dist/useFormReset.module.js +0 -34
- package/dist/useFormReset.module.js.map +0 -1
- package/dist/useGlobalListeners.main.js +0 -62
- package/dist/useGlobalListeners.main.js.map +0 -1
- package/dist/useGlobalListeners.mjs +0 -57
- package/dist/useGlobalListeners.module.js +0 -57
- package/dist/useGlobalListeners.module.js.map +0 -1
- package/dist/useId.main.js +0 -108
- package/dist/useId.main.js.map +0 -1
- package/dist/useId.mjs +0 -101
- package/dist/useId.module.js +0 -101
- package/dist/useId.module.js.map +0 -1
- package/dist/useLabels.main.js +0 -44
- package/dist/useLabels.main.js.map +0 -1
- package/dist/useLabels.mjs +0 -39
- package/dist/useLabels.module.js +0 -39
- package/dist/useLabels.module.js.map +0 -1
- package/dist/useLayoutEffect.main.js +0 -27
- package/dist/useLayoutEffect.main.js.map +0 -1
- package/dist/useLayoutEffect.mjs +0 -18
- package/dist/useLayoutEffect.module.js +0 -18
- package/dist/useLayoutEffect.module.js.map +0 -1
- package/dist/useLoadMore.main.js +0 -73
- package/dist/useLoadMore.main.js.map +0 -1
- package/dist/useLoadMore.mjs +0 -68
- package/dist/useLoadMore.module.js +0 -68
- package/dist/useLoadMore.module.js.map +0 -1
- package/dist/useLoadMoreSentinel.main.js +0 -58
- package/dist/useLoadMoreSentinel.main.js.map +0 -1
- package/dist/useLoadMoreSentinel.mjs +0 -53
- package/dist/useLoadMoreSentinel.module.js +0 -53
- package/dist/useLoadMoreSentinel.module.js.map +0 -1
- package/dist/useObjectRef.main.js +0 -58
- package/dist/useObjectRef.main.js.map +0 -1
- package/dist/useObjectRef.mjs +0 -53
- package/dist/useObjectRef.module.js +0 -53
- package/dist/useObjectRef.module.js.map +0 -1
- package/dist/useResizeObserver.main.js +0 -47
- package/dist/useResizeObserver.main.js.map +0 -1
- package/dist/useResizeObserver.mjs +0 -42
- package/dist/useResizeObserver.module.js +0 -42
- package/dist/useResizeObserver.module.js.map +0 -1
- package/dist/useSyncRef.main.js +0 -32
- package/dist/useSyncRef.main.js.map +0 -1
- package/dist/useSyncRef.mjs +0 -27
- package/dist/useSyncRef.module.js +0 -27
- package/dist/useSyncRef.module.js.map +0 -1
- package/dist/useUpdateEffect.main.js +0 -42
- package/dist/useUpdateEffect.main.js.map +0 -1
- package/dist/useUpdateEffect.mjs +0 -37
- package/dist/useUpdateEffect.module.js +0 -37
- package/dist/useUpdateEffect.module.js.map +0 -1
- package/dist/useUpdateLayoutEffect.main.js +0 -40
- package/dist/useUpdateLayoutEffect.main.js.map +0 -1
- package/dist/useUpdateLayoutEffect.mjs +0 -35
- package/dist/useUpdateLayoutEffect.module.js +0 -35
- package/dist/useUpdateLayoutEffect.module.js.map +0 -1
- package/dist/useValueEffect.main.js +0 -63
- package/dist/useValueEffect.main.js.map +0 -1
- package/dist/useValueEffect.mjs +0 -58
- package/dist/useValueEffect.module.js +0 -58
- package/dist/useValueEffect.module.js.map +0 -1
- package/dist/useViewportSize.main.js +0 -79
- package/dist/useViewportSize.main.js.map +0 -1
- package/dist/useViewportSize.mjs +0 -74
- package/dist/useViewportSize.module.js +0 -74
- package/dist/useViewportSize.module.js.map +0 -1
- package/src/animation.ts +0 -103
- package/src/chain.ts +0 -24
- package/src/constants.ts +0 -15
- package/src/domHelpers.ts +0 -33
- package/src/filterDOMProps.ts +0 -127
- package/src/focusWithoutScrolling.ts +0 -96
- package/src/getOffset.ts +0 -21
- package/src/getScrollParent.ts +0 -27
- package/src/getScrollParents.ts +0 -26
- package/src/inertValue.ts +0 -11
- package/src/isElementVisible.ts +0 -75
- package/src/isFocusable.ts +0 -56
- package/src/isScrollable.ts +0 -25
- package/src/isVirtualEvent.ts +0 -58
- package/src/keyboard.tsx +0 -48
- package/src/mergeProps.ts +0 -77
- package/src/mergeRefs.ts +0 -52
- package/src/openLink.tsx +0 -201
- package/src/platform.ts +0 -78
- package/src/runAfterTransition.ts +0 -121
- package/src/scrollIntoView.ts +0 -129
- package/src/shadowdom/DOMFunctions.ts +0 -71
- package/src/shadowdom/ShadowTreeWalker.ts +0 -319
- package/src/useDeepMemo.ts +0 -27
- package/src/useDescription.ts +0 -56
- package/src/useDrag1D.ts +0 -191
- package/src/useEffectEvent.ts +0 -30
- package/src/useEvent.ts +0 -37
- package/src/useFormReset.ts +0 -36
- package/src/useGlobalListeners.ts +0 -52
- package/src/useId.ts +0 -129
- package/src/useLabels.ts +0 -48
- package/src/useLayoutEffect.ts +0 -20
- package/src/useLoadMore.ts +0 -82
- package/src/useLoadMoreSentinel.ts +0 -63
- package/src/useObjectRef.ts +0 -69
- package/src/useResizeObserver.ts +0 -52
- package/src/useSyncRef.ts +0 -33
- package/src/useUpdateEffect.ts +0 -39
- package/src/useUpdateLayoutEffect.ts +0 -37
- package/src/useValueEffect.ts +0 -68
- package/src/useViewportSize.ts +0 -96
package/src/openLink.tsx
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2023 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {focusWithoutScrolling, isMac, isWebKit} from './index';
|
|
14
|
-
import {Href, LinkDOMProps, RouterOptions} from '@react-types/shared';
|
|
15
|
-
import {isFirefox, isIPad} from './platform';
|
|
16
|
-
import React, {createContext, DOMAttributes, JSX, MouseEvent as ReactMouseEvent, ReactNode, useContext, useMemo} from 'react';
|
|
17
|
-
|
|
18
|
-
interface Router {
|
|
19
|
-
isNative: boolean,
|
|
20
|
-
open: (target: Element, modifiers: Modifiers, href: Href, routerOptions: RouterOptions | undefined) => void,
|
|
21
|
-
useHref: (href: Href) => string
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const RouterContext = createContext<Router>({
|
|
25
|
-
isNative: true,
|
|
26
|
-
open: openSyntheticLink,
|
|
27
|
-
useHref: (href) => href
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
interface RouterProviderProps {
|
|
31
|
-
navigate: (path: Href, routerOptions: RouterOptions | undefined) => void,
|
|
32
|
-
useHref?: (href: Href) => string,
|
|
33
|
-
children: ReactNode
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* A RouterProvider accepts a `navigate` function from a framework or client side router,
|
|
38
|
-
* and provides it to all nested React Aria links to enable client side navigation.
|
|
39
|
-
*/
|
|
40
|
-
export function RouterProvider(props: RouterProviderProps): JSX.Element {
|
|
41
|
-
let {children, navigate, useHref} = props;
|
|
42
|
-
|
|
43
|
-
let ctx = useMemo(() => ({
|
|
44
|
-
isNative: false,
|
|
45
|
-
open: (target: Element, modifiers: Modifiers, href: Href, routerOptions: RouterOptions | undefined) => {
|
|
46
|
-
getSyntheticLink(target, link => {
|
|
47
|
-
if (shouldClientNavigate(link, modifiers)) {
|
|
48
|
-
navigate(href, routerOptions);
|
|
49
|
-
} else {
|
|
50
|
-
openLink(link, modifiers);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
useHref: useHref || ((href) => href)
|
|
55
|
-
}), [navigate, useHref]);
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<RouterContext.Provider value={ctx}>
|
|
59
|
-
{children}
|
|
60
|
-
</RouterContext.Provider>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function useRouter(): Router {
|
|
65
|
-
return useContext(RouterContext);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
interface Modifiers {
|
|
69
|
-
metaKey?: boolean,
|
|
70
|
-
ctrlKey?: boolean,
|
|
71
|
-
altKey?: boolean,
|
|
72
|
-
shiftKey?: boolean
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function shouldClientNavigate(link: HTMLAnchorElement, modifiers: Modifiers): boolean {
|
|
76
|
-
// Use getAttribute here instead of link.target. Firefox will default link.target to "_parent" when inside an iframe.
|
|
77
|
-
let target = link.getAttribute('target');
|
|
78
|
-
return (
|
|
79
|
-
(!target || target === '_self') &&
|
|
80
|
-
link.origin === location.origin &&
|
|
81
|
-
!link.hasAttribute('download') &&
|
|
82
|
-
!modifiers.metaKey && // open in new tab (mac)
|
|
83
|
-
!modifiers.ctrlKey && // open in new tab (windows)
|
|
84
|
-
!modifiers.altKey && // download
|
|
85
|
-
!modifiers.shiftKey
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function openLink(target: HTMLAnchorElement, modifiers: Modifiers, setOpening = true): void {
|
|
90
|
-
let {metaKey, ctrlKey, altKey, shiftKey} = modifiers;
|
|
91
|
-
|
|
92
|
-
// Firefox does not recognize keyboard events as a user action by default, and the popup blocker
|
|
93
|
-
// will prevent links with target="_blank" from opening. However, it does allow the event if the
|
|
94
|
-
// Command/Control key is held, which opens the link in a background tab. This seems like the best we can do.
|
|
95
|
-
// See https://bugzilla.mozilla.org/show_bug.cgi?id=257870 and https://bugzilla.mozilla.org/show_bug.cgi?id=746640.
|
|
96
|
-
if (isFirefox() && window.event?.type?.startsWith('key') && target.target === '_blank') {
|
|
97
|
-
if (isMac()) {
|
|
98
|
-
metaKey = true;
|
|
99
|
-
} else {
|
|
100
|
-
ctrlKey = true;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// WebKit does not support firing click events with modifier keys, but does support keyboard events.
|
|
105
|
-
// https://github.com/WebKit/WebKit/blob/c03d0ac6e6db178f90923a0a63080b5ca210d25f/Source/WebCore/html/HTMLAnchorElement.cpp#L184
|
|
106
|
-
let event = isWebKit() && isMac() && !isIPad() && process.env.NODE_ENV !== 'test'
|
|
107
|
-
// @ts-ignore - keyIdentifier is a non-standard property, but it's what webkit expects
|
|
108
|
-
? new KeyboardEvent('keydown', {keyIdentifier: 'Enter', metaKey, ctrlKey, altKey, shiftKey})
|
|
109
|
-
: new MouseEvent('click', {metaKey, ctrlKey, altKey, shiftKey, detail: 1, bubbles: true, cancelable: true});
|
|
110
|
-
(openLink as any).isOpening = setOpening;
|
|
111
|
-
focusWithoutScrolling(target);
|
|
112
|
-
target.dispatchEvent(event);
|
|
113
|
-
(openLink as any).isOpening = false;
|
|
114
|
-
}
|
|
115
|
-
// https://github.com/parcel-bundler/parcel/issues/8724
|
|
116
|
-
(openLink as any).isOpening = false;
|
|
117
|
-
|
|
118
|
-
function getSyntheticLink(target: Element, open: (link: HTMLAnchorElement) => void) {
|
|
119
|
-
if (target instanceof HTMLAnchorElement) {
|
|
120
|
-
open(target);
|
|
121
|
-
} else if (target.hasAttribute('data-href')) {
|
|
122
|
-
let link = document.createElement('a');
|
|
123
|
-
link.href = target.getAttribute('data-href')!;
|
|
124
|
-
if (target.hasAttribute('data-target')) {
|
|
125
|
-
link.target = target.getAttribute('data-target')!;
|
|
126
|
-
}
|
|
127
|
-
if (target.hasAttribute('data-rel')) {
|
|
128
|
-
link.rel = target.getAttribute('data-rel')!;
|
|
129
|
-
}
|
|
130
|
-
if (target.hasAttribute('data-download')) {
|
|
131
|
-
link.download = target.getAttribute('data-download')!;
|
|
132
|
-
}
|
|
133
|
-
if (target.hasAttribute('data-ping')) {
|
|
134
|
-
link.ping = target.getAttribute('data-ping')!;
|
|
135
|
-
}
|
|
136
|
-
if (target.hasAttribute('data-referrer-policy')) {
|
|
137
|
-
link.referrerPolicy = target.getAttribute('data-referrer-policy')!;
|
|
138
|
-
}
|
|
139
|
-
target.appendChild(link);
|
|
140
|
-
open(link);
|
|
141
|
-
target.removeChild(link);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function openSyntheticLink(target: Element, modifiers: Modifiers) {
|
|
146
|
-
getSyntheticLink(target, link => openLink(link, modifiers));
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export function useSyntheticLinkProps(props: LinkDOMProps): DOMAttributes<HTMLElement> {
|
|
150
|
-
let router = useRouter();
|
|
151
|
-
const href = router.useHref(props.href ?? '');
|
|
152
|
-
return {
|
|
153
|
-
'data-href': props.href ? href : undefined,
|
|
154
|
-
'data-target': props.target,
|
|
155
|
-
'data-rel': props.rel,
|
|
156
|
-
'data-download': props.download,
|
|
157
|
-
'data-ping': props.ping,
|
|
158
|
-
'data-referrer-policy': props.referrerPolicy
|
|
159
|
-
} as DOMAttributes<HTMLElement>;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/** @deprecated - For backward compatibility. */
|
|
163
|
-
export function getSyntheticLinkProps(props: LinkDOMProps): DOMAttributes<HTMLElement> {
|
|
164
|
-
return {
|
|
165
|
-
'data-href': props.href,
|
|
166
|
-
'data-target': props.target,
|
|
167
|
-
'data-rel': props.rel,
|
|
168
|
-
'data-download': props.download,
|
|
169
|
-
'data-ping': props.ping,
|
|
170
|
-
'data-referrer-policy': props.referrerPolicy
|
|
171
|
-
} as DOMAttributes<HTMLElement>;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export function useLinkProps(props?: LinkDOMProps): LinkDOMProps {
|
|
175
|
-
let router = useRouter();
|
|
176
|
-
const href = router.useHref(props?.href ?? '');
|
|
177
|
-
return {
|
|
178
|
-
href: props?.href ? href : undefined,
|
|
179
|
-
target: props?.target,
|
|
180
|
-
rel: props?.rel,
|
|
181
|
-
download: props?.download,
|
|
182
|
-
ping: props?.ping,
|
|
183
|
-
referrerPolicy: props?.referrerPolicy
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export function handleLinkClick(e: ReactMouseEvent, router: Router, href: Href | undefined, routerOptions: RouterOptions | undefined): void {
|
|
188
|
-
// If a custom router is provided, prevent default and forward if this link should client navigate.
|
|
189
|
-
if (
|
|
190
|
-
!router.isNative &&
|
|
191
|
-
e.currentTarget instanceof HTMLAnchorElement &&
|
|
192
|
-
e.currentTarget.href &&
|
|
193
|
-
// If props are applied to a router Link component, it may have already prevented default.
|
|
194
|
-
!e.isDefaultPrevented() &&
|
|
195
|
-
shouldClientNavigate(e.currentTarget, e) &&
|
|
196
|
-
href
|
|
197
|
-
) {
|
|
198
|
-
e.preventDefault();
|
|
199
|
-
router.open(e.currentTarget, e, href, routerOptions);
|
|
200
|
-
}
|
|
201
|
-
}
|
package/src/platform.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
function testUserAgent(re: RegExp) {
|
|
14
|
-
if (typeof window === 'undefined' || window.navigator == null) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
let brands = window.navigator['userAgentData']?.brands;
|
|
18
|
-
return Array.isArray(brands) && brands.some((brand: {brand: string, version: string}) => re.test(brand.brand)) ||
|
|
19
|
-
re.test(window.navigator.userAgent);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function testPlatform(re: RegExp) {
|
|
23
|
-
return typeof window !== 'undefined' && window.navigator != null
|
|
24
|
-
? re.test(window.navigator['userAgentData']?.platform || window.navigator.platform)
|
|
25
|
-
: false;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function cached(fn: () => boolean) {
|
|
29
|
-
if (process.env.NODE_ENV === 'test') {
|
|
30
|
-
return fn;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let res: boolean | null = null;
|
|
34
|
-
return () => {
|
|
35
|
-
if (res == null) {
|
|
36
|
-
res = fn();
|
|
37
|
-
}
|
|
38
|
-
return res;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export const isMac: () => boolean = cached(function () {
|
|
43
|
-
return testPlatform(/^Mac/i);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
export const isIPhone: () => boolean = cached(function () {
|
|
47
|
-
return testPlatform(/^iPhone/i);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
export const isIPad: () => boolean = cached(function () {
|
|
51
|
-
return testPlatform(/^iPad/i) ||
|
|
52
|
-
// iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
|
|
53
|
-
(isMac() && navigator.maxTouchPoints > 1);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
export const isIOS: () => boolean = cached(function () {
|
|
57
|
-
return isIPhone() || isIPad();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
export const isAppleDevice: () => boolean = cached(function () {
|
|
61
|
-
return isMac() || isIOS();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
export const isWebKit: () => boolean = cached(function () {
|
|
65
|
-
return testUserAgent(/AppleWebKit/i) && !isChrome();
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
export const isChrome: () => boolean = cached(function () {
|
|
69
|
-
return testUserAgent(/Chrome/i);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
export const isAndroid: () => boolean = cached(function () {
|
|
73
|
-
return testUserAgent(/Android/i);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
export const isFirefox: () => boolean = cached(function () {
|
|
77
|
-
return testUserAgent(/Firefox/i);
|
|
78
|
-
});
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
// We store a global list of elements that are currently transitioning,
|
|
14
|
-
// mapped to a set of CSS properties that are transitioning for that element.
|
|
15
|
-
// This is necessary rather than a simple count of transitions because of browser
|
|
16
|
-
// bugs, e.g. Chrome sometimes fires both transitionend and transitioncancel rather
|
|
17
|
-
// than one or the other. So we need to track what's actually transitioning so that
|
|
18
|
-
// we can ignore these duplicate events.
|
|
19
|
-
let transitionsByElement = new Map<EventTarget, Set<string>>();
|
|
20
|
-
|
|
21
|
-
// A list of callbacks to call once there are no transitioning elements.
|
|
22
|
-
let transitionCallbacks = new Set<() => void>();
|
|
23
|
-
|
|
24
|
-
function setupGlobalEvents() {
|
|
25
|
-
if (typeof window === 'undefined') {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function isTransitionEvent(event: Event): event is TransitionEvent {
|
|
30
|
-
return 'propertyName' in event;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let onTransitionStart = (e: Event) => {
|
|
34
|
-
if (!isTransitionEvent(e) || !e.target) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
// Add the transitioning property to the list for this element.
|
|
38
|
-
let transitions = transitionsByElement.get(e.target);
|
|
39
|
-
if (!transitions) {
|
|
40
|
-
transitions = new Set();
|
|
41
|
-
transitionsByElement.set(e.target, transitions);
|
|
42
|
-
|
|
43
|
-
// The transitioncancel event must be registered on the element itself, rather than as a global
|
|
44
|
-
// event. This enables us to handle when the node is deleted from the document while it is transitioning.
|
|
45
|
-
// In that case, the cancel event would have nowhere to bubble to so we need to handle it directly.
|
|
46
|
-
e.target.addEventListener('transitioncancel', onTransitionEnd, {
|
|
47
|
-
once: true
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
transitions.add(e.propertyName);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
let onTransitionEnd = (e: Event) => {
|
|
55
|
-
if (!isTransitionEvent(e) || !e.target) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
// Remove property from list of transitioning properties.
|
|
59
|
-
let properties = transitionsByElement.get(e.target);
|
|
60
|
-
if (!properties) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
properties.delete(e.propertyName);
|
|
65
|
-
|
|
66
|
-
// If empty, remove transitioncancel event, and remove the element from the list of transitioning elements.
|
|
67
|
-
if (properties.size === 0) {
|
|
68
|
-
e.target.removeEventListener('transitioncancel', onTransitionEnd);
|
|
69
|
-
transitionsByElement.delete(e.target);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// If no transitioning elements, call all of the queued callbacks.
|
|
73
|
-
if (transitionsByElement.size === 0) {
|
|
74
|
-
for (let cb of transitionCallbacks) {
|
|
75
|
-
cb();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
transitionCallbacks.clear();
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
document.body.addEventListener('transitionrun', onTransitionStart);
|
|
83
|
-
document.body.addEventListener('transitionend', onTransitionEnd);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (typeof document !== 'undefined') {
|
|
87
|
-
if (document.readyState !== 'loading') {
|
|
88
|
-
setupGlobalEvents();
|
|
89
|
-
} else {
|
|
90
|
-
document.addEventListener('DOMContentLoaded', setupGlobalEvents);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Cleans up any elements that are no longer in the document.
|
|
96
|
-
* This is necessary because we can't rely on transitionend events to fire
|
|
97
|
-
* for elements that are removed from the document while transitioning.
|
|
98
|
-
*/
|
|
99
|
-
function cleanupDetachedElements() {
|
|
100
|
-
for (const [eventTarget] of transitionsByElement) {
|
|
101
|
-
// Similar to `eventTarget instanceof Element && !eventTarget.isConnected`, but avoids
|
|
102
|
-
// the explicit instanceof check, since it may be different in different contexts.
|
|
103
|
-
if ('isConnected' in eventTarget && !eventTarget.isConnected) {
|
|
104
|
-
transitionsByElement.delete(eventTarget);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export function runAfterTransition(fn: () => void): void {
|
|
110
|
-
// Wait one frame to see if an animation starts, e.g. a transition on mount.
|
|
111
|
-
requestAnimationFrame(() => {
|
|
112
|
-
cleanupDetachedElements();
|
|
113
|
-
// If no transitions are running, call the function immediately.
|
|
114
|
-
// Otherwise, add it to a list of callbacks to run at the end of the animation.
|
|
115
|
-
if (transitionsByElement.size === 0) {
|
|
116
|
-
fn();
|
|
117
|
-
} else {
|
|
118
|
-
transitionCallbacks.add(fn);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
package/src/scrollIntoView.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {getScrollParents} from './getScrollParents';
|
|
14
|
-
import {nodeContains} from './shadowdom/DOMFunctions';
|
|
15
|
-
|
|
16
|
-
interface ScrollIntoViewportOpts {
|
|
17
|
-
/** The optional containing element of the target to be centered in the viewport. */
|
|
18
|
-
containingElement?: Element | null
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Scrolls `scrollView` so that `element` is visible.
|
|
23
|
-
* Similar to `element.scrollIntoView({block: 'nearest'})` (not supported in Edge),
|
|
24
|
-
* but doesn't affect parents above `scrollView`.
|
|
25
|
-
*/
|
|
26
|
-
export function scrollIntoView(scrollView: HTMLElement, element: HTMLElement): void {
|
|
27
|
-
let offsetX = relativeOffset(scrollView, element, 'left');
|
|
28
|
-
let offsetY = relativeOffset(scrollView, element, 'top');
|
|
29
|
-
let width = element.offsetWidth;
|
|
30
|
-
let height = element.offsetHeight;
|
|
31
|
-
let x = scrollView.scrollLeft;
|
|
32
|
-
let y = scrollView.scrollTop;
|
|
33
|
-
|
|
34
|
-
// Account for top/left border offsetting the scroll top/Left + scroll padding
|
|
35
|
-
let {
|
|
36
|
-
borderTopWidth,
|
|
37
|
-
borderLeftWidth,
|
|
38
|
-
scrollPaddingTop,
|
|
39
|
-
scrollPaddingRight,
|
|
40
|
-
scrollPaddingBottom,
|
|
41
|
-
scrollPaddingLeft
|
|
42
|
-
} = getComputedStyle(scrollView);
|
|
43
|
-
|
|
44
|
-
let borderAdjustedX = x + parseInt(borderLeftWidth, 10);
|
|
45
|
-
let borderAdjustedY = y + parseInt(borderTopWidth, 10);
|
|
46
|
-
// Ignore end/bottom border via clientHeight/Width instead of offsetHeight/Width
|
|
47
|
-
let maxX = borderAdjustedX + scrollView.clientWidth;
|
|
48
|
-
let maxY = borderAdjustedY + scrollView.clientHeight;
|
|
49
|
-
|
|
50
|
-
// Get scroll padding values as pixels - defaults to 0 if no scroll padding
|
|
51
|
-
// is used.
|
|
52
|
-
let scrollPaddingTopNumber = parseInt(scrollPaddingTop, 10) || 0;
|
|
53
|
-
let scrollPaddingBottomNumber = parseInt(scrollPaddingBottom, 10) || 0;
|
|
54
|
-
let scrollPaddingRightNumber = parseInt(scrollPaddingRight, 10) || 0;
|
|
55
|
-
let scrollPaddingLeftNumber = parseInt(scrollPaddingLeft, 10) || 0;
|
|
56
|
-
|
|
57
|
-
if (offsetX <= x + scrollPaddingLeftNumber) {
|
|
58
|
-
x = offsetX - parseInt(borderLeftWidth, 10) - scrollPaddingLeftNumber;
|
|
59
|
-
} else if (offsetX + width > maxX - scrollPaddingRightNumber) {
|
|
60
|
-
x += offsetX + width - maxX + scrollPaddingRightNumber;
|
|
61
|
-
}
|
|
62
|
-
if (offsetY <= borderAdjustedY + scrollPaddingTopNumber) {
|
|
63
|
-
y = offsetY - parseInt(borderTopWidth, 10) - scrollPaddingTopNumber;
|
|
64
|
-
} else if (offsetY + height > maxY - scrollPaddingBottomNumber) {
|
|
65
|
-
y += offsetY + height - maxY + scrollPaddingBottomNumber;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
scrollView.scrollLeft = x;
|
|
69
|
-
scrollView.scrollTop = y;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Computes the offset left or top from child to ancestor by accumulating
|
|
74
|
-
* offsetLeft or offsetTop through intervening offsetParents.
|
|
75
|
-
*/
|
|
76
|
-
function relativeOffset(ancestor: HTMLElement, child: HTMLElement, axis: 'left'|'top') {
|
|
77
|
-
const prop = axis === 'left' ? 'offsetLeft' : 'offsetTop';
|
|
78
|
-
let sum = 0;
|
|
79
|
-
while (child.offsetParent) {
|
|
80
|
-
sum += child[prop];
|
|
81
|
-
if (child.offsetParent === ancestor) {
|
|
82
|
-
// Stop once we have found the ancestor we are interested in.
|
|
83
|
-
break;
|
|
84
|
-
} else if (nodeContains(child.offsetParent, ancestor)) {
|
|
85
|
-
// If the ancestor is not `position:relative`, then we stop at
|
|
86
|
-
// _its_ offset parent, and we subtract off _its_ offset, so that
|
|
87
|
-
// we end up with the proper offset from child to ancestor.
|
|
88
|
-
sum -= ancestor[prop];
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
child = child.offsetParent as HTMLElement;
|
|
92
|
-
}
|
|
93
|
-
return sum;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Scrolls the `targetElement` so it is visible in the viewport. Accepts an optional `opts.containingElement`
|
|
98
|
-
* that will be centered in the viewport prior to scrolling the targetElement into view. If scrolling is prevented on
|
|
99
|
-
* the body (e.g. targetElement is in a popover), this will only scroll the scroll parents of the targetElement up to but not including the body itself.
|
|
100
|
-
*/
|
|
101
|
-
export function scrollIntoViewport(targetElement: Element | null, opts?: ScrollIntoViewportOpts): void {
|
|
102
|
-
if (targetElement && nodeContains(document, targetElement)) {
|
|
103
|
-
let root = document.scrollingElement || document.documentElement;
|
|
104
|
-
let isScrollPrevented = window.getComputedStyle(root).overflow === 'hidden';
|
|
105
|
-
// If scrolling is not currently prevented then we aren’t in a overlay nor is a overlay open, just use element.scrollIntoView to bring the element into view
|
|
106
|
-
if (!isScrollPrevented) {
|
|
107
|
-
let {left: originalLeft, top: originalTop} = targetElement.getBoundingClientRect();
|
|
108
|
-
|
|
109
|
-
// use scrollIntoView({block: 'nearest'}) instead of .focus to check if the element is fully in view or not since .focus()
|
|
110
|
-
// won't cause a scroll if the element is already focused and doesn't behave consistently when an element is partially out of view horizontally vs vertically
|
|
111
|
-
targetElement?.scrollIntoView?.({block: 'nearest'});
|
|
112
|
-
let {left: newLeft, top: newTop} = targetElement.getBoundingClientRect();
|
|
113
|
-
// Account for sub pixel differences from rounding
|
|
114
|
-
if ((Math.abs(originalLeft - newLeft) > 1) || (Math.abs(originalTop - newTop) > 1)) {
|
|
115
|
-
opts?.containingElement?.scrollIntoView?.({block: 'center', inline: 'center'});
|
|
116
|
-
targetElement.scrollIntoView?.({block: 'nearest'});
|
|
117
|
-
}
|
|
118
|
-
} else {
|
|
119
|
-
let scrollParents = getScrollParents(targetElement);
|
|
120
|
-
// If scrolling is prevented, we don't want to scroll the body since it might move the overlay partially offscreen and the user can't scroll it back into view.
|
|
121
|
-
if (!isScrollPrevented) {
|
|
122
|
-
scrollParents.push(root);
|
|
123
|
-
}
|
|
124
|
-
for (let scrollParent of scrollParents) {
|
|
125
|
-
scrollIntoView(scrollParent as HTMLElement, targetElement as HTMLElement);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// Source: https://github.com/microsoft/tabster/blob/a89fc5d7e332d48f68d03b1ca6e344489d1c3898/src/Shadowdomize/DOMFunctions.ts#L16
|
|
2
|
-
/* eslint-disable rsp-rules/no-non-shadow-contains */
|
|
3
|
-
|
|
4
|
-
import {isShadowRoot} from '../domHelpers';
|
|
5
|
-
import {shadowDOM} from '@react-stately/flags';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* ShadowDOM safe version of Node.contains.
|
|
9
|
-
*/
|
|
10
|
-
export function nodeContains(
|
|
11
|
-
node: Node | null | undefined,
|
|
12
|
-
otherNode: Node | null | undefined
|
|
13
|
-
): boolean {
|
|
14
|
-
if (!shadowDOM()) {
|
|
15
|
-
return otherNode && node ? node.contains(otherNode) : false;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (!node || !otherNode) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let currentNode: HTMLElement | Node | null | undefined = otherNode;
|
|
23
|
-
|
|
24
|
-
while (currentNode !== null) {
|
|
25
|
-
if (currentNode === node) {
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if ((currentNode as HTMLSlotElement).tagName === 'SLOT' &&
|
|
30
|
-
(currentNode as HTMLSlotElement).assignedSlot) {
|
|
31
|
-
// Element is slotted
|
|
32
|
-
currentNode = (currentNode as HTMLSlotElement).assignedSlot!.parentNode;
|
|
33
|
-
} else if (isShadowRoot(currentNode)) {
|
|
34
|
-
// Element is in shadow root
|
|
35
|
-
currentNode = currentNode.host;
|
|
36
|
-
} else {
|
|
37
|
-
currentNode = currentNode.parentNode;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* ShadowDOM safe version of document.activeElement.
|
|
46
|
-
*/
|
|
47
|
-
export const getActiveElement = (doc: Document = document): Element | null => {
|
|
48
|
-
if (!shadowDOM()) {
|
|
49
|
-
return doc.activeElement;
|
|
50
|
-
}
|
|
51
|
-
let activeElement: Element | null = doc.activeElement;
|
|
52
|
-
|
|
53
|
-
while (activeElement && 'shadowRoot' in activeElement &&
|
|
54
|
-
activeElement.shadowRoot?.activeElement) {
|
|
55
|
-
activeElement = activeElement.shadowRoot.activeElement;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return activeElement;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* ShadowDOM safe version of event.target.
|
|
63
|
-
*/
|
|
64
|
-
export function getEventTarget<T extends Event>(event: T): Element {
|
|
65
|
-
if (shadowDOM() && (event.target as HTMLElement).shadowRoot) {
|
|
66
|
-
if (event.composedPath) {
|
|
67
|
-
return event.composedPath()[0] as Element;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return event.target as Element;
|
|
71
|
-
}
|