@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/dist/openLink.main.js
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
var $1117b6c0d4c4c164$exports = require("./focusWithoutScrolling.main.js");
|
|
2
|
-
var $9e20cff0af27e8cc$exports = require("./platform.main.js");
|
|
3
|
-
var $6kLG7$react = require("react");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function $parcel$interopDefault(a) {
|
|
7
|
-
return a && a.__esModule ? a.default : a;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function $parcel$export(e, n, v, s) {
|
|
11
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
$parcel$export(module.exports, "RouterProvider", () => $4068a0fae83b6d84$export$323e4fc2fa4753fb);
|
|
15
|
-
$parcel$export(module.exports, "shouldClientNavigate", () => $4068a0fae83b6d84$export$efa8c9099e530235);
|
|
16
|
-
$parcel$export(module.exports, "openLink", () => $4068a0fae83b6d84$export$95185d699e05d4d7);
|
|
17
|
-
$parcel$export(module.exports, "useRouter", () => $4068a0fae83b6d84$export$9a302a45f65d0572);
|
|
18
|
-
$parcel$export(module.exports, "useSyntheticLinkProps", () => $4068a0fae83b6d84$export$bdc77b0c0a3a85d6);
|
|
19
|
-
$parcel$export(module.exports, "getSyntheticLinkProps", () => $4068a0fae83b6d84$export$51437d503373d223);
|
|
20
|
-
$parcel$export(module.exports, "useLinkProps", () => $4068a0fae83b6d84$export$7e924b3091a3bd18);
|
|
21
|
-
$parcel$export(module.exports, "handleLinkClick", () => $4068a0fae83b6d84$export$13aea1a3cb5e3f1f);
|
|
22
|
-
/*
|
|
23
|
-
* Copyright 2023 Adobe. All rights reserved.
|
|
24
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
25
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
26
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
27
|
-
*
|
|
28
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
29
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
30
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
31
|
-
* governing permissions and limitations under the License.
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const $4068a0fae83b6d84$var$RouterContext = /*#__PURE__*/ (0, $6kLG7$react.createContext)({
|
|
36
|
-
isNative: true,
|
|
37
|
-
open: $4068a0fae83b6d84$var$openSyntheticLink,
|
|
38
|
-
useHref: (href)=>href
|
|
39
|
-
});
|
|
40
|
-
function $4068a0fae83b6d84$export$323e4fc2fa4753fb(props) {
|
|
41
|
-
let { children: children, navigate: navigate, useHref: useHref } = props;
|
|
42
|
-
let ctx = (0, $6kLG7$react.useMemo)(()=>({
|
|
43
|
-
isNative: false,
|
|
44
|
-
open: (target, modifiers, href, routerOptions)=>{
|
|
45
|
-
$4068a0fae83b6d84$var$getSyntheticLink(target, (link)=>{
|
|
46
|
-
if ($4068a0fae83b6d84$export$efa8c9099e530235(link, modifiers)) navigate(href, routerOptions);
|
|
47
|
-
else $4068a0fae83b6d84$export$95185d699e05d4d7(link, modifiers);
|
|
48
|
-
});
|
|
49
|
-
},
|
|
50
|
-
useHref: useHref || ((href)=>href)
|
|
51
|
-
}), [
|
|
52
|
-
navigate,
|
|
53
|
-
useHref
|
|
54
|
-
]);
|
|
55
|
-
return /*#__PURE__*/ (0, ($parcel$interopDefault($6kLG7$react))).createElement($4068a0fae83b6d84$var$RouterContext.Provider, {
|
|
56
|
-
value: ctx
|
|
57
|
-
}, children);
|
|
58
|
-
}
|
|
59
|
-
function $4068a0fae83b6d84$export$9a302a45f65d0572() {
|
|
60
|
-
return (0, $6kLG7$react.useContext)($4068a0fae83b6d84$var$RouterContext);
|
|
61
|
-
}
|
|
62
|
-
function $4068a0fae83b6d84$export$efa8c9099e530235(link, modifiers) {
|
|
63
|
-
// Use getAttribute here instead of link.target. Firefox will default link.target to "_parent" when inside an iframe.
|
|
64
|
-
let target = link.getAttribute('target');
|
|
65
|
-
return (!target || target === '_self') && link.origin === location.origin && !link.hasAttribute('download') && !modifiers.metaKey && // open in new tab (mac)
|
|
66
|
-
!modifiers.ctrlKey && // open in new tab (windows)
|
|
67
|
-
!modifiers.altKey && // download
|
|
68
|
-
!modifiers.shiftKey;
|
|
69
|
-
}
|
|
70
|
-
function $4068a0fae83b6d84$export$95185d699e05d4d7(target, modifiers, setOpening = true) {
|
|
71
|
-
var _window_event_type, _window_event;
|
|
72
|
-
let { metaKey: metaKey, ctrlKey: ctrlKey, altKey: altKey, shiftKey: shiftKey } = modifiers;
|
|
73
|
-
// Firefox does not recognize keyboard events as a user action by default, and the popup blocker
|
|
74
|
-
// will prevent links with target="_blank" from opening. However, it does allow the event if the
|
|
75
|
-
// Command/Control key is held, which opens the link in a background tab. This seems like the best we can do.
|
|
76
|
-
// See https://bugzilla.mozilla.org/show_bug.cgi?id=257870 and https://bugzilla.mozilla.org/show_bug.cgi?id=746640.
|
|
77
|
-
if ((0, $9e20cff0af27e8cc$exports.isFirefox)() && ((_window_event = window.event) === null || _window_event === void 0 ? void 0 : (_window_event_type = _window_event.type) === null || _window_event_type === void 0 ? void 0 : _window_event_type.startsWith('key')) && target.target === '_blank') {
|
|
78
|
-
if ((0, $9e20cff0af27e8cc$exports.isMac)()) metaKey = true;
|
|
79
|
-
else ctrlKey = true;
|
|
80
|
-
}
|
|
81
|
-
// WebKit does not support firing click events with modifier keys, but does support keyboard events.
|
|
82
|
-
// https://github.com/WebKit/WebKit/blob/c03d0ac6e6db178f90923a0a63080b5ca210d25f/Source/WebCore/html/HTMLAnchorElement.cpp#L184
|
|
83
|
-
let event = (0, $9e20cff0af27e8cc$exports.isWebKit)() && (0, $9e20cff0af27e8cc$exports.isMac)() && !(0, $9e20cff0af27e8cc$exports.isIPad)() && process.env.NODE_ENV !== 'test' ? new KeyboardEvent('keydown', {
|
|
84
|
-
keyIdentifier: 'Enter',
|
|
85
|
-
metaKey: metaKey,
|
|
86
|
-
ctrlKey: ctrlKey,
|
|
87
|
-
altKey: altKey,
|
|
88
|
-
shiftKey: shiftKey
|
|
89
|
-
}) : new MouseEvent('click', {
|
|
90
|
-
metaKey: metaKey,
|
|
91
|
-
ctrlKey: ctrlKey,
|
|
92
|
-
altKey: altKey,
|
|
93
|
-
shiftKey: shiftKey,
|
|
94
|
-
detail: 1,
|
|
95
|
-
bubbles: true,
|
|
96
|
-
cancelable: true
|
|
97
|
-
});
|
|
98
|
-
$4068a0fae83b6d84$export$95185d699e05d4d7.isOpening = setOpening;
|
|
99
|
-
(0, $1117b6c0d4c4c164$exports.focusWithoutScrolling)(target);
|
|
100
|
-
target.dispatchEvent(event);
|
|
101
|
-
$4068a0fae83b6d84$export$95185d699e05d4d7.isOpening = false;
|
|
102
|
-
}
|
|
103
|
-
// https://github.com/parcel-bundler/parcel/issues/8724
|
|
104
|
-
$4068a0fae83b6d84$export$95185d699e05d4d7.isOpening = false;
|
|
105
|
-
function $4068a0fae83b6d84$var$getSyntheticLink(target, open) {
|
|
106
|
-
if (target instanceof HTMLAnchorElement) open(target);
|
|
107
|
-
else if (target.hasAttribute('data-href')) {
|
|
108
|
-
let link = document.createElement('a');
|
|
109
|
-
link.href = target.getAttribute('data-href');
|
|
110
|
-
if (target.hasAttribute('data-target')) link.target = target.getAttribute('data-target');
|
|
111
|
-
if (target.hasAttribute('data-rel')) link.rel = target.getAttribute('data-rel');
|
|
112
|
-
if (target.hasAttribute('data-download')) link.download = target.getAttribute('data-download');
|
|
113
|
-
if (target.hasAttribute('data-ping')) link.ping = target.getAttribute('data-ping');
|
|
114
|
-
if (target.hasAttribute('data-referrer-policy')) link.referrerPolicy = target.getAttribute('data-referrer-policy');
|
|
115
|
-
target.appendChild(link);
|
|
116
|
-
open(link);
|
|
117
|
-
target.removeChild(link);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function $4068a0fae83b6d84$var$openSyntheticLink(target, modifiers) {
|
|
121
|
-
$4068a0fae83b6d84$var$getSyntheticLink(target, (link)=>$4068a0fae83b6d84$export$95185d699e05d4d7(link, modifiers));
|
|
122
|
-
}
|
|
123
|
-
function $4068a0fae83b6d84$export$bdc77b0c0a3a85d6(props) {
|
|
124
|
-
let router = $4068a0fae83b6d84$export$9a302a45f65d0572();
|
|
125
|
-
var _props_href;
|
|
126
|
-
const href = router.useHref((_props_href = props.href) !== null && _props_href !== void 0 ? _props_href : '');
|
|
127
|
-
return {
|
|
128
|
-
'data-href': props.href ? href : undefined,
|
|
129
|
-
'data-target': props.target,
|
|
130
|
-
'data-rel': props.rel,
|
|
131
|
-
'data-download': props.download,
|
|
132
|
-
'data-ping': props.ping,
|
|
133
|
-
'data-referrer-policy': props.referrerPolicy
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
function $4068a0fae83b6d84$export$51437d503373d223(props) {
|
|
137
|
-
return {
|
|
138
|
-
'data-href': props.href,
|
|
139
|
-
'data-target': props.target,
|
|
140
|
-
'data-rel': props.rel,
|
|
141
|
-
'data-download': props.download,
|
|
142
|
-
'data-ping': props.ping,
|
|
143
|
-
'data-referrer-policy': props.referrerPolicy
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
function $4068a0fae83b6d84$export$7e924b3091a3bd18(props) {
|
|
147
|
-
let router = $4068a0fae83b6d84$export$9a302a45f65d0572();
|
|
148
|
-
var _props_href;
|
|
149
|
-
const href = router.useHref((_props_href = props === null || props === void 0 ? void 0 : props.href) !== null && _props_href !== void 0 ? _props_href : '');
|
|
150
|
-
return {
|
|
151
|
-
href: (props === null || props === void 0 ? void 0 : props.href) ? href : undefined,
|
|
152
|
-
target: props === null || props === void 0 ? void 0 : props.target,
|
|
153
|
-
rel: props === null || props === void 0 ? void 0 : props.rel,
|
|
154
|
-
download: props === null || props === void 0 ? void 0 : props.download,
|
|
155
|
-
ping: props === null || props === void 0 ? void 0 : props.ping,
|
|
156
|
-
referrerPolicy: props === null || props === void 0 ? void 0 : props.referrerPolicy
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
function $4068a0fae83b6d84$export$13aea1a3cb5e3f1f(e, router, href, routerOptions) {
|
|
160
|
-
// If a custom router is provided, prevent default and forward if this link should client navigate.
|
|
161
|
-
if (!router.isNative && e.currentTarget instanceof HTMLAnchorElement && e.currentTarget.href && // If props are applied to a router Link component, it may have already prevented default.
|
|
162
|
-
!e.isDefaultPrevented() && $4068a0fae83b6d84$export$efa8c9099e530235(e.currentTarget, e) && href) {
|
|
163
|
-
e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EAAE,kBAAA,4BAAA,MAAO,IAAI;QACjB,cAAc,EAAE,kBAAA,4BAAA,MAAO,cAAc;IACvC;AACF;AAEO,SAAS,0CAAgB,CAAkB,EAAE,MAAc,EAAE,IAAsB,EAAE,aAAwC;IAClI,mGAAmG;IACnG,IACE,CAAC,OAAO,QAAQ,IAChB,EAAE,aAAa,YAAY,qBAC3B,EAAE,aAAa,CAAC,IAAI,IACpB,0FAA0F;IAC1F,CAAC,EAAE,kBAAkB,MACrB,0CAAqB,EAAE,aAAa,EAAE,MACtC,MACA;QACA,EAAE,cAAc;QAChB,OAAO,IAAI,CAAC,EAAE,aAAa,EAAE,GAAG,MAAM;IACxC;AACF","sources":["packages/@react-aria/utils/src/openLink.tsx"],"sourcesContent":["/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {focusWithoutScrolling, isMac, isWebKit} from './index';\nimport {Href, LinkDOMProps, RouterOptions} from '@react-types/shared';\nimport {isFirefox, isIPad} from './platform';\nimport React, {createContext, DOMAttributes, JSX, MouseEvent as ReactMouseEvent, ReactNode, useContext, useMemo} from 'react';\n\ninterface Router {\n isNative: boolean,\n open: (target: Element, modifiers: Modifiers, href: Href, routerOptions: RouterOptions | undefined) => void,\n useHref: (href: Href) => string\n}\n\nconst RouterContext = createContext<Router>({\n isNative: true,\n open: openSyntheticLink,\n useHref: (href) => href\n});\n\ninterface RouterProviderProps {\n navigate: (path: Href, routerOptions: RouterOptions | undefined) => void,\n useHref?: (href: Href) => string,\n children: ReactNode\n}\n\n/**\n * A RouterProvider accepts a `navigate` function from a framework or client side router,\n * and provides it to all nested React Aria links to enable client side navigation.\n */\nexport function RouterProvider(props: RouterProviderProps): JSX.Element {\n let {children, navigate, useHref} = props;\n\n let ctx = useMemo(() => ({\n isNative: false,\n open: (target: Element, modifiers: Modifiers, href: Href, routerOptions: RouterOptions | undefined) => {\n getSyntheticLink(target, link => {\n if (shouldClientNavigate(link, modifiers)) {\n navigate(href, routerOptions);\n } else {\n openLink(link, modifiers);\n }\n });\n },\n useHref: useHref || ((href) => href)\n }), [navigate, useHref]);\n\n return (\n <RouterContext.Provider value={ctx}>\n {children}\n </RouterContext.Provider>\n );\n}\n\nexport function useRouter(): Router {\n return useContext(RouterContext);\n}\n\ninterface Modifiers {\n metaKey?: boolean,\n ctrlKey?: boolean,\n altKey?: boolean,\n shiftKey?: boolean\n}\n\nexport function shouldClientNavigate(link: HTMLAnchorElement, modifiers: Modifiers): boolean {\n // Use getAttribute here instead of link.target. Firefox will default link.target to \"_parent\" when inside an iframe.\n let target = link.getAttribute('target');\n return (\n (!target || target === '_self') &&\n link.origin === location.origin &&\n !link.hasAttribute('download') &&\n !modifiers.metaKey && // open in new tab (mac)\n !modifiers.ctrlKey && // open in new tab (windows)\n !modifiers.altKey && // download\n !modifiers.shiftKey\n );\n}\n\nexport function openLink(target: HTMLAnchorElement, modifiers: Modifiers, setOpening = true): void {\n let {metaKey, ctrlKey, altKey, shiftKey} = modifiers;\n\n // Firefox does not recognize keyboard events as a user action by default, and the popup blocker\n // will prevent links with target=\"_blank\" from opening. However, it does allow the event if the\n // Command/Control key is held, which opens the link in a background tab. This seems like the best we can do.\n // See https://bugzilla.mozilla.org/show_bug.cgi?id=257870 and https://bugzilla.mozilla.org/show_bug.cgi?id=746640.\n if (isFirefox() && window.event?.type?.startsWith('key') && target.target === '_blank') {\n if (isMac()) {\n metaKey = true;\n } else {\n ctrlKey = true;\n }\n }\n\n // WebKit does not support firing click events with modifier keys, but does support keyboard events.\n // https://github.com/WebKit/WebKit/blob/c03d0ac6e6db178f90923a0a63080b5ca210d25f/Source/WebCore/html/HTMLAnchorElement.cpp#L184\n let event = isWebKit() && isMac() && !isIPad() && process.env.NODE_ENV !== 'test'\n // @ts-ignore - keyIdentifier is a non-standard property, but it's what webkit expects\n ? new KeyboardEvent('keydown', {keyIdentifier: 'Enter', metaKey, ctrlKey, altKey, shiftKey})\n : new MouseEvent('click', {metaKey, ctrlKey, altKey, shiftKey, detail: 1, bubbles: true, cancelable: true});\n (openLink as any).isOpening = setOpening;\n focusWithoutScrolling(target);\n target.dispatchEvent(event);\n (openLink as any).isOpening = false;\n}\n// https://github.com/parcel-bundler/parcel/issues/8724\n(openLink as any).isOpening = false;\n\nfunction getSyntheticLink(target: Element, open: (link: HTMLAnchorElement) => void) {\n if (target instanceof HTMLAnchorElement) {\n open(target);\n } else if (target.hasAttribute('data-href')) {\n let link = document.createElement('a');\n link.href = target.getAttribute('data-href')!;\n if (target.hasAttribute('data-target')) {\n link.target = target.getAttribute('data-target')!;\n }\n if (target.hasAttribute('data-rel')) {\n link.rel = target.getAttribute('data-rel')!;\n }\n if (target.hasAttribute('data-download')) {\n link.download = target.getAttribute('data-download')!;\n }\n if (target.hasAttribute('data-ping')) {\n link.ping = target.getAttribute('data-ping')!;\n }\n if (target.hasAttribute('data-referrer-policy')) {\n link.referrerPolicy = target.getAttribute('data-referrer-policy')!;\n }\n target.appendChild(link);\n open(link);\n target.removeChild(link);\n }\n}\n\nfunction openSyntheticLink(target: Element, modifiers: Modifiers) {\n getSyntheticLink(target, link => openLink(link, modifiers));\n}\n\nexport function useSyntheticLinkProps(props: LinkDOMProps): DOMAttributes<HTMLElement> {\n let router = useRouter();\n const href = router.useHref(props.href ?? '');\n return {\n 'data-href': props.href ? href : undefined,\n 'data-target': props.target,\n 'data-rel': props.rel,\n 'data-download': props.download,\n 'data-ping': props.ping,\n 'data-referrer-policy': props.referrerPolicy\n } as DOMAttributes<HTMLElement>;\n}\n\n/** @deprecated - For backward compatibility. */\nexport function getSyntheticLinkProps(props: LinkDOMProps): DOMAttributes<HTMLElement> {\n return {\n 'data-href': props.href,\n 'data-target': props.target,\n 'data-rel': props.rel,\n 'data-download': props.download,\n 'data-ping': props.ping,\n 'data-referrer-policy': props.referrerPolicy\n } as DOMAttributes<HTMLElement>;\n}\n\nexport function useLinkProps(props?: LinkDOMProps): LinkDOMProps {\n let router = useRouter();\n const href = router.useHref(props?.href ?? '');\n return {\n href: props?.href ? href : undefined,\n target: props?.target,\n rel: props?.rel,\n download: props?.download,\n ping: props?.ping,\n referrerPolicy: props?.referrerPolicy\n };\n}\n\nexport function handleLinkClick(e: ReactMouseEvent, router: Router, href: Href | undefined, routerOptions: RouterOptions | undefined): void {\n // If a custom router is provided, prevent default and forward if this link should client navigate.\n if (\n !router.isNative &&\n e.currentTarget instanceof HTMLAnchorElement &&\n e.currentTarget.href &&\n // If props are applied to a router Link component, it may have already prevented default.\n !e.isDefaultPrevented() &&\n shouldClientNavigate(e.currentTarget, e) &&\n href\n ) {\n e.preventDefault();\n router.open(e.currentTarget, e, href, routerOptions);\n }\n}\n"],"names":[],"version":3,"file":"openLink.main.js.map"}
|
package/dist/openLink.mjs
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import {focusWithoutScrolling as $7215afc6de606d6b$export$de79e2c695e052f3} from "./focusWithoutScrolling.mjs";
|
|
2
|
-
import {isMac as $c87311424ea30a05$export$9ac100e40613ea10, isWebKit as $c87311424ea30a05$export$78551043582a6a98, isFirefox as $c87311424ea30a05$export$b7d78993b74f766d, isIPad as $c87311424ea30a05$export$7bef049ce92e4224} from "./platform.mjs";
|
|
3
|
-
import $g3jFn$react, {createContext as $g3jFn$createContext, useMemo as $g3jFn$useMemo, useContext as $g3jFn$useContext} from "react";
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* Copyright 2023 Adobe. All rights reserved.
|
|
7
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
-
* governing permissions and limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const $ea8dcbcb9ea1b556$var$RouterContext = /*#__PURE__*/ (0, $g3jFn$createContext)({
|
|
19
|
-
isNative: true,
|
|
20
|
-
open: $ea8dcbcb9ea1b556$var$openSyntheticLink,
|
|
21
|
-
useHref: (href)=>href
|
|
22
|
-
});
|
|
23
|
-
function $ea8dcbcb9ea1b556$export$323e4fc2fa4753fb(props) {
|
|
24
|
-
let { children: children, navigate: navigate, useHref: useHref } = props;
|
|
25
|
-
let ctx = (0, $g3jFn$useMemo)(()=>({
|
|
26
|
-
isNative: false,
|
|
27
|
-
open: (target, modifiers, href, routerOptions)=>{
|
|
28
|
-
$ea8dcbcb9ea1b556$var$getSyntheticLink(target, (link)=>{
|
|
29
|
-
if ($ea8dcbcb9ea1b556$export$efa8c9099e530235(link, modifiers)) navigate(href, routerOptions);
|
|
30
|
-
else $ea8dcbcb9ea1b556$export$95185d699e05d4d7(link, modifiers);
|
|
31
|
-
});
|
|
32
|
-
},
|
|
33
|
-
useHref: useHref || ((href)=>href)
|
|
34
|
-
}), [
|
|
35
|
-
navigate,
|
|
36
|
-
useHref
|
|
37
|
-
]);
|
|
38
|
-
return /*#__PURE__*/ (0, $g3jFn$react).createElement($ea8dcbcb9ea1b556$var$RouterContext.Provider, {
|
|
39
|
-
value: ctx
|
|
40
|
-
}, children);
|
|
41
|
-
}
|
|
42
|
-
function $ea8dcbcb9ea1b556$export$9a302a45f65d0572() {
|
|
43
|
-
return (0, $g3jFn$useContext)($ea8dcbcb9ea1b556$var$RouterContext);
|
|
44
|
-
}
|
|
45
|
-
function $ea8dcbcb9ea1b556$export$efa8c9099e530235(link, modifiers) {
|
|
46
|
-
// Use getAttribute here instead of link.target. Firefox will default link.target to "_parent" when inside an iframe.
|
|
47
|
-
let target = link.getAttribute('target');
|
|
48
|
-
return (!target || target === '_self') && link.origin === location.origin && !link.hasAttribute('download') && !modifiers.metaKey && // open in new tab (mac)
|
|
49
|
-
!modifiers.ctrlKey && // open in new tab (windows)
|
|
50
|
-
!modifiers.altKey && // download
|
|
51
|
-
!modifiers.shiftKey;
|
|
52
|
-
}
|
|
53
|
-
function $ea8dcbcb9ea1b556$export$95185d699e05d4d7(target, modifiers, setOpening = true) {
|
|
54
|
-
var _window_event_type, _window_event;
|
|
55
|
-
let { metaKey: metaKey, ctrlKey: ctrlKey, altKey: altKey, shiftKey: shiftKey } = modifiers;
|
|
56
|
-
// Firefox does not recognize keyboard events as a user action by default, and the popup blocker
|
|
57
|
-
// will prevent links with target="_blank" from opening. However, it does allow the event if the
|
|
58
|
-
// Command/Control key is held, which opens the link in a background tab. This seems like the best we can do.
|
|
59
|
-
// See https://bugzilla.mozilla.org/show_bug.cgi?id=257870 and https://bugzilla.mozilla.org/show_bug.cgi?id=746640.
|
|
60
|
-
if ((0, $c87311424ea30a05$export$b7d78993b74f766d)() && ((_window_event = window.event) === null || _window_event === void 0 ? void 0 : (_window_event_type = _window_event.type) === null || _window_event_type === void 0 ? void 0 : _window_event_type.startsWith('key')) && target.target === '_blank') {
|
|
61
|
-
if ((0, $c87311424ea30a05$export$9ac100e40613ea10)()) metaKey = true;
|
|
62
|
-
else ctrlKey = true;
|
|
63
|
-
}
|
|
64
|
-
// WebKit does not support firing click events with modifier keys, but does support keyboard events.
|
|
65
|
-
// https://github.com/WebKit/WebKit/blob/c03d0ac6e6db178f90923a0a63080b5ca210d25f/Source/WebCore/html/HTMLAnchorElement.cpp#L184
|
|
66
|
-
let event = (0, $c87311424ea30a05$export$78551043582a6a98)() && (0, $c87311424ea30a05$export$9ac100e40613ea10)() && !(0, $c87311424ea30a05$export$7bef049ce92e4224)() && process.env.NODE_ENV !== 'test' ? new KeyboardEvent('keydown', {
|
|
67
|
-
keyIdentifier: 'Enter',
|
|
68
|
-
metaKey: metaKey,
|
|
69
|
-
ctrlKey: ctrlKey,
|
|
70
|
-
altKey: altKey,
|
|
71
|
-
shiftKey: shiftKey
|
|
72
|
-
}) : new MouseEvent('click', {
|
|
73
|
-
metaKey: metaKey,
|
|
74
|
-
ctrlKey: ctrlKey,
|
|
75
|
-
altKey: altKey,
|
|
76
|
-
shiftKey: shiftKey,
|
|
77
|
-
detail: 1,
|
|
78
|
-
bubbles: true,
|
|
79
|
-
cancelable: true
|
|
80
|
-
});
|
|
81
|
-
$ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening = setOpening;
|
|
82
|
-
(0, $7215afc6de606d6b$export$de79e2c695e052f3)(target);
|
|
83
|
-
target.dispatchEvent(event);
|
|
84
|
-
$ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening = false;
|
|
85
|
-
}
|
|
86
|
-
// https://github.com/parcel-bundler/parcel/issues/8724
|
|
87
|
-
$ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening = false;
|
|
88
|
-
function $ea8dcbcb9ea1b556$var$getSyntheticLink(target, open) {
|
|
89
|
-
if (target instanceof HTMLAnchorElement) open(target);
|
|
90
|
-
else if (target.hasAttribute('data-href')) {
|
|
91
|
-
let link = document.createElement('a');
|
|
92
|
-
link.href = target.getAttribute('data-href');
|
|
93
|
-
if (target.hasAttribute('data-target')) link.target = target.getAttribute('data-target');
|
|
94
|
-
if (target.hasAttribute('data-rel')) link.rel = target.getAttribute('data-rel');
|
|
95
|
-
if (target.hasAttribute('data-download')) link.download = target.getAttribute('data-download');
|
|
96
|
-
if (target.hasAttribute('data-ping')) link.ping = target.getAttribute('data-ping');
|
|
97
|
-
if (target.hasAttribute('data-referrer-policy')) link.referrerPolicy = target.getAttribute('data-referrer-policy');
|
|
98
|
-
target.appendChild(link);
|
|
99
|
-
open(link);
|
|
100
|
-
target.removeChild(link);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function $ea8dcbcb9ea1b556$var$openSyntheticLink(target, modifiers) {
|
|
104
|
-
$ea8dcbcb9ea1b556$var$getSyntheticLink(target, (link)=>$ea8dcbcb9ea1b556$export$95185d699e05d4d7(link, modifiers));
|
|
105
|
-
}
|
|
106
|
-
function $ea8dcbcb9ea1b556$export$bdc77b0c0a3a85d6(props) {
|
|
107
|
-
let router = $ea8dcbcb9ea1b556$export$9a302a45f65d0572();
|
|
108
|
-
var _props_href;
|
|
109
|
-
const href = router.useHref((_props_href = props.href) !== null && _props_href !== void 0 ? _props_href : '');
|
|
110
|
-
return {
|
|
111
|
-
'data-href': props.href ? href : undefined,
|
|
112
|
-
'data-target': props.target,
|
|
113
|
-
'data-rel': props.rel,
|
|
114
|
-
'data-download': props.download,
|
|
115
|
-
'data-ping': props.ping,
|
|
116
|
-
'data-referrer-policy': props.referrerPolicy
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
function $ea8dcbcb9ea1b556$export$51437d503373d223(props) {
|
|
120
|
-
return {
|
|
121
|
-
'data-href': props.href,
|
|
122
|
-
'data-target': props.target,
|
|
123
|
-
'data-rel': props.rel,
|
|
124
|
-
'data-download': props.download,
|
|
125
|
-
'data-ping': props.ping,
|
|
126
|
-
'data-referrer-policy': props.referrerPolicy
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function $ea8dcbcb9ea1b556$export$7e924b3091a3bd18(props) {
|
|
130
|
-
let router = $ea8dcbcb9ea1b556$export$9a302a45f65d0572();
|
|
131
|
-
var _props_href;
|
|
132
|
-
const href = router.useHref((_props_href = props === null || props === void 0 ? void 0 : props.href) !== null && _props_href !== void 0 ? _props_href : '');
|
|
133
|
-
return {
|
|
134
|
-
href: (props === null || props === void 0 ? void 0 : props.href) ? href : undefined,
|
|
135
|
-
target: props === null || props === void 0 ? void 0 : props.target,
|
|
136
|
-
rel: props === null || props === void 0 ? void 0 : props.rel,
|
|
137
|
-
download: props === null || props === void 0 ? void 0 : props.download,
|
|
138
|
-
ping: props === null || props === void 0 ? void 0 : props.ping,
|
|
139
|
-
referrerPolicy: props === null || props === void 0 ? void 0 : props.referrerPolicy
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
function $ea8dcbcb9ea1b556$export$13aea1a3cb5e3f1f(e, router, href, routerOptions) {
|
|
143
|
-
// If a custom router is provided, prevent default and forward if this link should client navigate.
|
|
144
|
-
if (!router.isNative && e.currentTarget instanceof HTMLAnchorElement && e.currentTarget.href && // If props are applied to a router Link component, it may have already prevented default.
|
|
145
|
-
!e.isDefaultPrevented() && $ea8dcbcb9ea1b556$export$efa8c9099e530235(e.currentTarget, e) && href) {
|
|
146
|
-
e.preventDefault();
|
|
147
|
-
router.open(e.currentTarget, e, href, routerOptions);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
export {$ea8dcbcb9ea1b556$export$323e4fc2fa4753fb as RouterProvider, $ea8dcbcb9ea1b556$export$efa8c9099e530235 as shouldClientNavigate, $ea8dcbcb9ea1b556$export$95185d699e05d4d7 as openLink, $ea8dcbcb9ea1b556$export$9a302a45f65d0572 as useRouter, $ea8dcbcb9ea1b556$export$bdc77b0c0a3a85d6 as useSyntheticLinkProps, $ea8dcbcb9ea1b556$export$51437d503373d223 as getSyntheticLinkProps, $ea8dcbcb9ea1b556$export$7e924b3091a3bd18 as useLinkProps, $ea8dcbcb9ea1b556$export$13aea1a3cb5e3f1f as handleLinkClick};
|
|
153
|
-
//# sourceMappingURL=openLink.module.js.map
|
package/dist/openLink.module.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import {focusWithoutScrolling as $7215afc6de606d6b$export$de79e2c695e052f3} from "./focusWithoutScrolling.module.js";
|
|
2
|
-
import {isMac as $c87311424ea30a05$export$9ac100e40613ea10, isWebKit as $c87311424ea30a05$export$78551043582a6a98, isFirefox as $c87311424ea30a05$export$b7d78993b74f766d, isIPad as $c87311424ea30a05$export$7bef049ce92e4224} from "./platform.module.js";
|
|
3
|
-
import $g3jFn$react, {createContext as $g3jFn$createContext, useMemo as $g3jFn$useMemo, useContext as $g3jFn$useContext} from "react";
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* Copyright 2023 Adobe. All rights reserved.
|
|
7
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
-
* governing permissions and limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const $ea8dcbcb9ea1b556$var$RouterContext = /*#__PURE__*/ (0, $g3jFn$createContext)({
|
|
19
|
-
isNative: true,
|
|
20
|
-
open: $ea8dcbcb9ea1b556$var$openSyntheticLink,
|
|
21
|
-
useHref: (href)=>href
|
|
22
|
-
});
|
|
23
|
-
function $ea8dcbcb9ea1b556$export$323e4fc2fa4753fb(props) {
|
|
24
|
-
let { children: children, navigate: navigate, useHref: useHref } = props;
|
|
25
|
-
let ctx = (0, $g3jFn$useMemo)(()=>({
|
|
26
|
-
isNative: false,
|
|
27
|
-
open: (target, modifiers, href, routerOptions)=>{
|
|
28
|
-
$ea8dcbcb9ea1b556$var$getSyntheticLink(target, (link)=>{
|
|
29
|
-
if ($ea8dcbcb9ea1b556$export$efa8c9099e530235(link, modifiers)) navigate(href, routerOptions);
|
|
30
|
-
else $ea8dcbcb9ea1b556$export$95185d699e05d4d7(link, modifiers);
|
|
31
|
-
});
|
|
32
|
-
},
|
|
33
|
-
useHref: useHref || ((href)=>href)
|
|
34
|
-
}), [
|
|
35
|
-
navigate,
|
|
36
|
-
useHref
|
|
37
|
-
]);
|
|
38
|
-
return /*#__PURE__*/ (0, $g3jFn$react).createElement($ea8dcbcb9ea1b556$var$RouterContext.Provider, {
|
|
39
|
-
value: ctx
|
|
40
|
-
}, children);
|
|
41
|
-
}
|
|
42
|
-
function $ea8dcbcb9ea1b556$export$9a302a45f65d0572() {
|
|
43
|
-
return (0, $g3jFn$useContext)($ea8dcbcb9ea1b556$var$RouterContext);
|
|
44
|
-
}
|
|
45
|
-
function $ea8dcbcb9ea1b556$export$efa8c9099e530235(link, modifiers) {
|
|
46
|
-
// Use getAttribute here instead of link.target. Firefox will default link.target to "_parent" when inside an iframe.
|
|
47
|
-
let target = link.getAttribute('target');
|
|
48
|
-
return (!target || target === '_self') && link.origin === location.origin && !link.hasAttribute('download') && !modifiers.metaKey && // open in new tab (mac)
|
|
49
|
-
!modifiers.ctrlKey && // open in new tab (windows)
|
|
50
|
-
!modifiers.altKey && // download
|
|
51
|
-
!modifiers.shiftKey;
|
|
52
|
-
}
|
|
53
|
-
function $ea8dcbcb9ea1b556$export$95185d699e05d4d7(target, modifiers, setOpening = true) {
|
|
54
|
-
var _window_event_type, _window_event;
|
|
55
|
-
let { metaKey: metaKey, ctrlKey: ctrlKey, altKey: altKey, shiftKey: shiftKey } = modifiers;
|
|
56
|
-
// Firefox does not recognize keyboard events as a user action by default, and the popup blocker
|
|
57
|
-
// will prevent links with target="_blank" from opening. However, it does allow the event if the
|
|
58
|
-
// Command/Control key is held, which opens the link in a background tab. This seems like the best we can do.
|
|
59
|
-
// See https://bugzilla.mozilla.org/show_bug.cgi?id=257870 and https://bugzilla.mozilla.org/show_bug.cgi?id=746640.
|
|
60
|
-
if ((0, $c87311424ea30a05$export$b7d78993b74f766d)() && ((_window_event = window.event) === null || _window_event === void 0 ? void 0 : (_window_event_type = _window_event.type) === null || _window_event_type === void 0 ? void 0 : _window_event_type.startsWith('key')) && target.target === '_blank') {
|
|
61
|
-
if ((0, $c87311424ea30a05$export$9ac100e40613ea10)()) metaKey = true;
|
|
62
|
-
else ctrlKey = true;
|
|
63
|
-
}
|
|
64
|
-
// WebKit does not support firing click events with modifier keys, but does support keyboard events.
|
|
65
|
-
// https://github.com/WebKit/WebKit/blob/c03d0ac6e6db178f90923a0a63080b5ca210d25f/Source/WebCore/html/HTMLAnchorElement.cpp#L184
|
|
66
|
-
let event = (0, $c87311424ea30a05$export$78551043582a6a98)() && (0, $c87311424ea30a05$export$9ac100e40613ea10)() && !(0, $c87311424ea30a05$export$7bef049ce92e4224)() && process.env.NODE_ENV !== 'test' ? new KeyboardEvent('keydown', {
|
|
67
|
-
keyIdentifier: 'Enter',
|
|
68
|
-
metaKey: metaKey,
|
|
69
|
-
ctrlKey: ctrlKey,
|
|
70
|
-
altKey: altKey,
|
|
71
|
-
shiftKey: shiftKey
|
|
72
|
-
}) : new MouseEvent('click', {
|
|
73
|
-
metaKey: metaKey,
|
|
74
|
-
ctrlKey: ctrlKey,
|
|
75
|
-
altKey: altKey,
|
|
76
|
-
shiftKey: shiftKey,
|
|
77
|
-
detail: 1,
|
|
78
|
-
bubbles: true,
|
|
79
|
-
cancelable: true
|
|
80
|
-
});
|
|
81
|
-
$ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening = setOpening;
|
|
82
|
-
(0, $7215afc6de606d6b$export$de79e2c695e052f3)(target);
|
|
83
|
-
target.dispatchEvent(event);
|
|
84
|
-
$ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening = false;
|
|
85
|
-
}
|
|
86
|
-
// https://github.com/parcel-bundler/parcel/issues/8724
|
|
87
|
-
$ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening = false;
|
|
88
|
-
function $ea8dcbcb9ea1b556$var$getSyntheticLink(target, open) {
|
|
89
|
-
if (target instanceof HTMLAnchorElement) open(target);
|
|
90
|
-
else if (target.hasAttribute('data-href')) {
|
|
91
|
-
let link = document.createElement('a');
|
|
92
|
-
link.href = target.getAttribute('data-href');
|
|
93
|
-
if (target.hasAttribute('data-target')) link.target = target.getAttribute('data-target');
|
|
94
|
-
if (target.hasAttribute('data-rel')) link.rel = target.getAttribute('data-rel');
|
|
95
|
-
if (target.hasAttribute('data-download')) link.download = target.getAttribute('data-download');
|
|
96
|
-
if (target.hasAttribute('data-ping')) link.ping = target.getAttribute('data-ping');
|
|
97
|
-
if (target.hasAttribute('data-referrer-policy')) link.referrerPolicy = target.getAttribute('data-referrer-policy');
|
|
98
|
-
target.appendChild(link);
|
|
99
|
-
open(link);
|
|
100
|
-
target.removeChild(link);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function $ea8dcbcb9ea1b556$var$openSyntheticLink(target, modifiers) {
|
|
104
|
-
$ea8dcbcb9ea1b556$var$getSyntheticLink(target, (link)=>$ea8dcbcb9ea1b556$export$95185d699e05d4d7(link, modifiers));
|
|
105
|
-
}
|
|
106
|
-
function $ea8dcbcb9ea1b556$export$bdc77b0c0a3a85d6(props) {
|
|
107
|
-
let router = $ea8dcbcb9ea1b556$export$9a302a45f65d0572();
|
|
108
|
-
var _props_href;
|
|
109
|
-
const href = router.useHref((_props_href = props.href) !== null && _props_href !== void 0 ? _props_href : '');
|
|
110
|
-
return {
|
|
111
|
-
'data-href': props.href ? href : undefined,
|
|
112
|
-
'data-target': props.target,
|
|
113
|
-
'data-rel': props.rel,
|
|
114
|
-
'data-download': props.download,
|
|
115
|
-
'data-ping': props.ping,
|
|
116
|
-
'data-referrer-policy': props.referrerPolicy
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
function $ea8dcbcb9ea1b556$export$51437d503373d223(props) {
|
|
120
|
-
return {
|
|
121
|
-
'data-href': props.href,
|
|
122
|
-
'data-target': props.target,
|
|
123
|
-
'data-rel': props.rel,
|
|
124
|
-
'data-download': props.download,
|
|
125
|
-
'data-ping': props.ping,
|
|
126
|
-
'data-referrer-policy': props.referrerPolicy
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function $ea8dcbcb9ea1b556$export$7e924b3091a3bd18(props) {
|
|
130
|
-
let router = $ea8dcbcb9ea1b556$export$9a302a45f65d0572();
|
|
131
|
-
var _props_href;
|
|
132
|
-
const href = router.useHref((_props_href = props === null || props === void 0 ? void 0 : props.href) !== null && _props_href !== void 0 ? _props_href : '');
|
|
133
|
-
return {
|
|
134
|
-
href: (props === null || props === void 0 ? void 0 : props.href) ? href : undefined,
|
|
135
|
-
target: props === null || props === void 0 ? void 0 : props.target,
|
|
136
|
-
rel: props === null || props === void 0 ? void 0 : props.rel,
|
|
137
|
-
download: props === null || props === void 0 ? void 0 : props.download,
|
|
138
|
-
ping: props === null || props === void 0 ? void 0 : props.ping,
|
|
139
|
-
referrerPolicy: props === null || props === void 0 ? void 0 : props.referrerPolicy
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
function $ea8dcbcb9ea1b556$export$13aea1a3cb5e3f1f(e, router, href, routerOptions) {
|
|
143
|
-
// If a custom router is provided, prevent default and forward if this link should client navigate.
|
|
144
|
-
if (!router.isNative && e.currentTarget instanceof HTMLAnchorElement && e.currentTarget.href && // If props are applied to a router Link component, it may have already prevented default.
|
|
145
|
-
!e.isDefaultPrevented() && $ea8dcbcb9ea1b556$export$efa8c9099e530235(e.currentTarget, e) && href) {
|
|
146
|
-
e.preventDefault();
|
|
147
|
-
router.open(e.currentTarget, e, href, routerOptions);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
export {$ea8dcbcb9ea1b556$export$323e4fc2fa4753fb as RouterProvider, $ea8dcbcb9ea1b556$export$efa8c9099e530235 as shouldClientNavigate, $ea8dcbcb9ea1b556$export$95185d699e05d4d7 as openLink, $ea8dcbcb9ea1b556$export$9a302a45f65d0572 as useRouter, $ea8dcbcb9ea1b556$export$bdc77b0c0a3a85d6 as useSyntheticLinkProps, $ea8dcbcb9ea1b556$export$51437d503373d223 as getSyntheticLinkProps, $ea8dcbcb9ea1b556$export$7e924b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AA,4BAAA,MAAO,cAAc;IACvC;AACF;AAEO,SAAS,0CAAgB,CAAkB,EAAE,MAAc,EAAE,IAAsB,EAAE,aAAwC;IAClI,mGAAmG;IACnG,IACE,CAAC,OAAO,QAAQ,IAChB,EAAE,aAAa,YAAY,qBAC3B,EAAE,aAAa,CAAC,IAAI,IACpB,0FAA0F;IAC1F,CAAC,EAAE,kBAAkB,MACrB,0CAAqB,EAAE,aAAa,EAAE,MACtC,MACA;QACA,EAAE,cAAc;QAChB,OAAO,IAAI,CAAC,EAAE,aAAa,EAAE,GAAG,MAAM;IACxC;AACF","sources":["packages/@react-aria/utils/src/openLink.tsx"],"sourcesContent":["/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {focusWithoutScrolling, isMac, isWebKit} from './index';\nimport {Href, LinkDOMProps, RouterOptions} from '@react-types/shared';\nimport {isFirefox, isIPad} from './platform';\nimport React, {createContext, DOMAttributes, JSX, MouseEvent as ReactMouseEvent, ReactNode, useContext, useMemo} from 'react';\n\ninterface Router {\n isNative: boolean,\n open: (target: Element, modifiers: Modifiers, href: Href, routerOptions: RouterOptions | undefined) => void,\n useHref: (href: Href) => string\n}\n\nconst RouterContext = createContext<Router>({\n isNative: true,\n open: openSyntheticLink,\n useHref: (href) => href\n});\n\ninterface RouterProviderProps {\n navigate: (path: Href, routerOptions: RouterOptions | undefined) => void,\n useHref?: (href: Href) => string,\n children: ReactNode\n}\n\n/**\n * A RouterProvider accepts a `navigate` function from a framework or client side router,\n * and provides it to all nested React Aria links to enable client side navigation.\n */\nexport function RouterProvider(props: RouterProviderProps): JSX.Element {\n let {children, navigate, useHref} = props;\n\n let ctx = useMemo(() => ({\n isNative: false,\n open: (target: Element, modifiers: Modifiers, href: Href, routerOptions: RouterOptions | undefined) => {\n getSyntheticLink(target, link => {\n if (shouldClientNavigate(link, modifiers)) {\n navigate(href, routerOptions);\n } else {\n openLink(link, modifiers);\n }\n });\n },\n useHref: useHref || ((href) => href)\n }), [navigate, useHref]);\n\n return (\n <RouterContext.Provider value={ctx}>\n {children}\n </RouterContext.Provider>\n );\n}\n\nexport function useRouter(): Router {\n return useContext(RouterContext);\n}\n\ninterface Modifiers {\n metaKey?: boolean,\n ctrlKey?: boolean,\n altKey?: boolean,\n shiftKey?: boolean\n}\n\nexport function shouldClientNavigate(link: HTMLAnchorElement, modifiers: Modifiers): boolean {\n // Use getAttribute here instead of link.target. Firefox will default link.target to \"_parent\" when inside an iframe.\n let target = link.getAttribute('target');\n return (\n (!target || target === '_self') &&\n link.origin === location.origin &&\n !link.hasAttribute('download') &&\n !modifiers.metaKey && // open in new tab (mac)\n !modifiers.ctrlKey && // open in new tab (windows)\n !modifiers.altKey && // download\n !modifiers.shiftKey\n );\n}\n\nexport function openLink(target: HTMLAnchorElement, modifiers: Modifiers, setOpening = true): void {\n let {metaKey, ctrlKey, altKey, shiftKey} = modifiers;\n\n // Firefox does not recognize keyboard events as a user action by default, and the popup blocker\n // will prevent links with target=\"_blank\" from opening. However, it does allow the event if the\n // Command/Control key is held, which opens the link in a background tab. This seems like the best we can do.\n // See https://bugzilla.mozilla.org/show_bug.cgi?id=257870 and https://bugzilla.mozilla.org/show_bug.cgi?id=746640.\n if (isFirefox() && window.event?.type?.startsWith('key') && target.target === '_blank') {\n if (isMac()) {\n metaKey = true;\n } else {\n ctrlKey = true;\n }\n }\n\n // WebKit does not support firing click events with modifier keys, but does support keyboard events.\n // https://github.com/WebKit/WebKit/blob/c03d0ac6e6db178f90923a0a63080b5ca210d25f/Source/WebCore/html/HTMLAnchorElement.cpp#L184\n let event = isWebKit() && isMac() && !isIPad() && process.env.NODE_ENV !== 'test'\n // @ts-ignore - keyIdentifier is a non-standard property, but it's what webkit expects\n ? new KeyboardEvent('keydown', {keyIdentifier: 'Enter', metaKey, ctrlKey, altKey, shiftKey})\n : new MouseEvent('click', {metaKey, ctrlKey, altKey, shiftKey, detail: 1, bubbles: true, cancelable: true});\n (openLink as any).isOpening = setOpening;\n focusWithoutScrolling(target);\n target.dispatchEvent(event);\n (openLink as any).isOpening = false;\n}\n// https://github.com/parcel-bundler/parcel/issues/8724\n(openLink as any).isOpening = false;\n\nfunction getSyntheticLink(target: Element, open: (link: HTMLAnchorElement) => void) {\n if (target instanceof HTMLAnchorElement) {\n open(target);\n } else if (target.hasAttribute('data-href')) {\n let link = document.createElement('a');\n link.href = target.getAttribute('data-href')!;\n if (target.hasAttribute('data-target')) {\n link.target = target.getAttribute('data-target')!;\n }\n if (target.hasAttribute('data-rel')) {\n link.rel = target.getAttribute('data-rel')!;\n }\n if (target.hasAttribute('data-download')) {\n link.download = target.getAttribute('data-download')!;\n }\n if (target.hasAttribute('data-ping')) {\n link.ping = target.getAttribute('data-ping')!;\n }\n if (target.hasAttribute('data-referrer-policy')) {\n link.referrerPolicy = target.getAttribute('data-referrer-policy')!;\n }\n target.appendChild(link);\n open(link);\n target.removeChild(link);\n }\n}\n\nfunction openSyntheticLink(target: Element, modifiers: Modifiers) {\n getSyntheticLink(target, link => openLink(link, modifiers));\n}\n\nexport function useSyntheticLinkProps(props: LinkDOMProps): DOMAttributes<HTMLElement> {\n let router = useRouter();\n const href = router.useHref(props.href ?? '');\n return {\n 'data-href': props.href ? href : undefined,\n 'data-target': props.target,\n 'data-rel': props.rel,\n 'data-download': props.download,\n 'data-ping': props.ping,\n 'data-referrer-policy': props.referrerPolicy\n } as DOMAttributes<HTMLElement>;\n}\n\n/** @deprecated - For backward compatibility. */\nexport function getSyntheticLinkProps(props: LinkDOMProps): DOMAttributes<HTMLElement> {\n return {\n 'data-href': props.href,\n 'data-target': props.target,\n 'data-rel': props.rel,\n 'data-download': props.download,\n 'data-ping': props.ping,\n 'data-referrer-policy': props.referrerPolicy\n } as DOMAttributes<HTMLElement>;\n}\n\nexport function useLinkProps(props?: LinkDOMProps): LinkDOMProps {\n let router = useRouter();\n const href = router.useHref(props?.href ?? '');\n return {\n href: props?.href ? href : undefined,\n target: props?.target,\n rel: props?.rel,\n download: props?.download,\n ping: props?.ping,\n referrerPolicy: props?.referrerPolicy\n };\n}\n\nexport function handleLinkClick(e: ReactMouseEvent, router: Router, href: Href | undefined, routerOptions: RouterOptions | undefined): void {\n // If a custom router is provided, prevent default and forward if this link should client navigate.\n if (\n !router.isNative &&\n e.currentTarget instanceof HTMLAnchorElement &&\n e.currentTarget.href &&\n // If props are applied to a router Link component, it may have already prevented default.\n !e.isDefaultPrevented() &&\n shouldClientNavigate(e.currentTarget, e) &&\n href\n ) {\n e.preventDefault();\n router.open(e.currentTarget, e, href, routerOptions);\n }\n}\n"],"names":[],"version":3,"file":"openLink.module.js.map"}
|
package/dist/platform.main.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
function $parcel$export(e, n, v, s) {
|
|
3
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
$parcel$export(module.exports, "isMac", () => $9e20cff0af27e8cc$export$9ac100e40613ea10);
|
|
7
|
-
$parcel$export(module.exports, "isIPhone", () => $9e20cff0af27e8cc$export$186c6964ca17d99);
|
|
8
|
-
$parcel$export(module.exports, "isIPad", () => $9e20cff0af27e8cc$export$7bef049ce92e4224);
|
|
9
|
-
$parcel$export(module.exports, "isIOS", () => $9e20cff0af27e8cc$export$fedb369cb70207f1);
|
|
10
|
-
$parcel$export(module.exports, "isAppleDevice", () => $9e20cff0af27e8cc$export$e1865c3bedcd822b);
|
|
11
|
-
$parcel$export(module.exports, "isWebKit", () => $9e20cff0af27e8cc$export$78551043582a6a98);
|
|
12
|
-
$parcel$export(module.exports, "isChrome", () => $9e20cff0af27e8cc$export$6446a186d09e379e);
|
|
13
|
-
$parcel$export(module.exports, "isAndroid", () => $9e20cff0af27e8cc$export$a11b0059900ceec8);
|
|
14
|
-
$parcel$export(module.exports, "isFirefox", () => $9e20cff0af27e8cc$export$b7d78993b74f766d);
|
|
15
|
-
/*
|
|
16
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
17
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
18
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
19
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
-
*
|
|
21
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
22
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
23
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
24
|
-
* governing permissions and limitations under the License.
|
|
25
|
-
*/ function $9e20cff0af27e8cc$var$testUserAgent(re) {
|
|
26
|
-
var _window_navigator_userAgentData;
|
|
27
|
-
if (typeof window === 'undefined' || window.navigator == null) return false;
|
|
28
|
-
let brands = (_window_navigator_userAgentData = window.navigator['userAgentData']) === null || _window_navigator_userAgentData === void 0 ? void 0 : _window_navigator_userAgentData.brands;
|
|
29
|
-
return Array.isArray(brands) && brands.some((brand)=>re.test(brand.brand)) || re.test(window.navigator.userAgent);
|
|
30
|
-
}
|
|
31
|
-
function $9e20cff0af27e8cc$var$testPlatform(re) {
|
|
32
|
-
var _window_navigator_userAgentData;
|
|
33
|
-
return typeof window !== 'undefined' && window.navigator != null ? re.test(((_window_navigator_userAgentData = window.navigator['userAgentData']) === null || _window_navigator_userAgentData === void 0 ? void 0 : _window_navigator_userAgentData.platform) || window.navigator.platform) : false;
|
|
34
|
-
}
|
|
35
|
-
function $9e20cff0af27e8cc$var$cached(fn) {
|
|
36
|
-
if (process.env.NODE_ENV === 'test') return fn;
|
|
37
|
-
let res = null;
|
|
38
|
-
return ()=>{
|
|
39
|
-
if (res == null) res = fn();
|
|
40
|
-
return res;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
const $9e20cff0af27e8cc$export$9ac100e40613ea10 = $9e20cff0af27e8cc$var$cached(function() {
|
|
44
|
-
return $9e20cff0af27e8cc$var$testPlatform(/^Mac/i);
|
|
45
|
-
});
|
|
46
|
-
const $9e20cff0af27e8cc$export$186c6964ca17d99 = $9e20cff0af27e8cc$var$cached(function() {
|
|
47
|
-
return $9e20cff0af27e8cc$var$testPlatform(/^iPhone/i);
|
|
48
|
-
});
|
|
49
|
-
const $9e20cff0af27e8cc$export$7bef049ce92e4224 = $9e20cff0af27e8cc$var$cached(function() {
|
|
50
|
-
return $9e20cff0af27e8cc$var$testPlatform(/^iPad/i) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
|
|
51
|
-
$9e20cff0af27e8cc$export$9ac100e40613ea10() && navigator.maxTouchPoints > 1;
|
|
52
|
-
});
|
|
53
|
-
const $9e20cff0af27e8cc$export$fedb369cb70207f1 = $9e20cff0af27e8cc$var$cached(function() {
|
|
54
|
-
return $9e20cff0af27e8cc$export$186c6964ca17d99() || $9e20cff0af27e8cc$export$7bef049ce92e4224();
|
|
55
|
-
});
|
|
56
|
-
const $9e20cff0af27e8cc$export$e1865c3bedcd822b = $9e20cff0af27e8cc$var$cached(function() {
|
|
57
|
-
return $9e20cff0af27e8cc$export$9ac100e40613ea10() || $9e20cff0af27e8cc$export$fedb369cb70207f1();
|
|
58
|
-
});
|
|
59
|
-
const $9e20cff0af27e8cc$export$78551043582a6a98 = $9e20cff0af27e8cc$var$cached(function() {
|
|
60
|
-
return $9e20cff0af27e8cc$var$testUserAgent(/AppleWebKit/i) && !$9e20cff0af27e8cc$export$6446a186d09e379e();
|
|
61
|
-
});
|
|
62
|
-
const $9e20cff0af27e8cc$export$6446a186d09e379e = $9e20cff0af27e8cc$var$cached(function() {
|
|
63
|
-
return $9e20cff0af27e8cc$var$testUserAgent(/Chrome/i);
|
|
64
|
-
});
|
|
65
|
-
const $9e20cff0af27e8cc$export$a11b0059900ceec8 = $9e20cff0af27e8cc$var$cached(function() {
|
|
66
|
-
return $9e20cff0af27e8cc$var$testUserAgent(/Android/i);
|
|
67
|
-
});
|
|
68
|
-
const $9e20cff0af27e8cc$export$b7d78993b74f766d = $9e20cff0af27e8cc$var$cached(function() {
|
|
69
|
-
return $9e20cff0af27e8cc$var$testUserAgent(/Firefox/i);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
//# sourceMappingURL=platform.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,SAAS,oCAAc,EAAU;QAIlB;IAHb,IAAI,OAAO,WAAW,eAAe,OAAO,SAAS,IAAI,MACvD,OAAO;IAET,IAAI,UAAS,kCAAA,OAAO,SAAS,CAAC,gBAAgB,cAAjC,sDAAA,gCAAmC,MAAM;IACtD,OAAO,MAAM,OAAO,CAAC,WAAW,OAAO,IAAI,CAAC,CAAC,QAA4C,GAAG,IAAI,CAAC,MAAM,KAAK,MAC1G,GAAG,IAAI,CAAC,OAAO,SAAS,CAAC,SAAS;AACtC;AAEA,SAAS,mCAAa,EAAU;QAElB;IADZ,OAAO,OAAO,WAAW,eAAe,OAAO,SAAS,IAAI,OACxD,GAAG,IAAI,CAAC,EAAA,kCAAA,OAAO,SAAS,CAAC,gBAAgB,cAAjC,sDAAA,gCAAmC,QAAQ,KAAI,OAAO,SAAS,CAAC,QAAQ,IAChF;AACN;AAEA,SAAS,6BAAO,EAAiB;IAC/B,IAAI,QAAQ,GAAG,CAAC,QAAQ,KAAK,QAC3B,OAAO;IAGT,IAAI,MAAsB;IAC1B,OAAO;QACL,IAAI,OAAO,MACT,MAAM;QAER,OAAO;IACT;AACF;AAEO,MAAM,4CAAuB,6BAAO;IACzC,OAAO,mCAAa;AACtB;AAEO,MAAM,2CAA0B,6BAAO;IAC5C,OAAO,mCAAa;AACtB;AAEO,MAAM,4CAAwB,6BAAO;IAC1C,OAAO,mCAAa,aAClB,yFAAyF;IACxF,+CAAW,UAAU,cAAc,GAAG;AAC3C;AAEO,MAAM,4CAAuB,6BAAO;IACzC,OAAO,8CAAc;AACvB;AAEO,MAAM,4CAA+B,6BAAO;IACjD,OAAO,+CAAW;AACpB;AAEO,MAAM,4CAA0B,6BAAO;IAC5C,OAAO,oCAAc,mBAAmB,CAAC;AAC3C;AAEO,MAAM,4CAA0B,6BAAO;IAC5C,OAAO,oCAAc;AACvB;AAEO,MAAM,4CAA2B,6BAAO;IAC7C,OAAO,oCAAc;AACvB;AAEO,MAAM,4CAA2B,6BAAO;IAC7C,OAAO,oCAAc;AACvB","sources":["packages/@react-aria/utils/src/platform.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nfunction testUserAgent(re: RegExp) {\n if (typeof window === 'undefined' || window.navigator == null) {\n return false;\n }\n let brands = window.navigator['userAgentData']?.brands;\n return Array.isArray(brands) && brands.some((brand: {brand: string, version: string}) => re.test(brand.brand)) ||\n re.test(window.navigator.userAgent);\n}\n\nfunction testPlatform(re: RegExp) {\n return typeof window !== 'undefined' && window.navigator != null\n ? re.test(window.navigator['userAgentData']?.platform || window.navigator.platform)\n : false;\n}\n\nfunction cached(fn: () => boolean) {\n if (process.env.NODE_ENV === 'test') {\n return fn;\n }\n\n let res: boolean | null = null;\n return () => {\n if (res == null) {\n res = fn();\n }\n return res;\n };\n}\n\nexport const isMac: () => boolean = cached(function () {\n return testPlatform(/^Mac/i);\n});\n\nexport const isIPhone: () => boolean = cached(function () {\n return testPlatform(/^iPhone/i);\n});\n\nexport const isIPad: () => boolean = cached(function () {\n return testPlatform(/^iPad/i) ||\n // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.\n (isMac() && navigator.maxTouchPoints > 1);\n});\n\nexport const isIOS: () => boolean = cached(function () {\n return isIPhone() || isIPad();\n});\n\nexport const isAppleDevice: () => boolean = cached(function () {\n return isMac() || isIOS();\n});\n\nexport const isWebKit: () => boolean = cached(function () {\n return testUserAgent(/AppleWebKit/i) && !isChrome();\n});\n\nexport const isChrome: () => boolean = cached(function () {\n return testUserAgent(/Chrome/i);\n});\n\nexport const isAndroid: () => boolean = cached(function () {\n return testUserAgent(/Android/i);\n});\n\nexport const isFirefox: () => boolean = cached(function () {\n return testUserAgent(/Firefox/i);\n});\n"],"names":[],"version":3,"file":"platform.main.js.map"}
|