@react-aria/link 3.6.4 → 3.7.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 CHANGED
@@ -1,18 +1,6 @@
1
- import {filterDOMProps as $kKV4x$filterDOMProps, mergeProps as $kKV4x$mergeProps, useRouter as $kKV4x$useRouter, shouldClientNavigate as $kKV4x$shouldClientNavigate} from "@react-aria/utils";
2
- import {useFocusable as $kKV4x$useFocusable} from "@react-aria/focus";
3
- import {usePress as $kKV4x$usePress} from "@react-aria/interactions";
1
+ import {useLink as $298d61e98472621b$export$dcf14c9974fe2767} from "./useLink.mjs";
4
2
 
5
3
  /*
6
- * Copyright 2020 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
4
  * Copyright 2020 Adobe. All rights reserved.
17
5
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
6
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -25,55 +13,5 @@ import {usePress as $kKV4x$usePress} from "@react-aria/interactions";
25
13
  */
26
14
 
27
15
 
28
- function $298d61e98472621b$export$dcf14c9974fe2767(props, ref) {
29
- let { elementType: elementType = "a", onPress: onPress, onPressStart: onPressStart, onPressEnd: onPressEnd, // @ts-ignore
30
- onClick: deprecatedOnClick, isDisabled: isDisabled, ...otherProps } = props;
31
- let linkProps = {};
32
- if (elementType !== "a") linkProps = {
33
- role: "link",
34
- tabIndex: !isDisabled ? 0 : undefined
35
- };
36
- let { focusableProps: focusableProps } = (0, $kKV4x$useFocusable)(props, ref);
37
- let { pressProps: pressProps, isPressed: isPressed } = (0, $kKV4x$usePress)({
38
- onPress: onPress,
39
- onPressStart: onPressStart,
40
- onPressEnd: onPressEnd,
41
- isDisabled: isDisabled,
42
- ref: ref
43
- });
44
- let domProps = (0, $kKV4x$filterDOMProps)(otherProps, {
45
- labelable: true,
46
- isLink: elementType === "a"
47
- });
48
- let interactionHandlers = (0, $kKV4x$mergeProps)(focusableProps, pressProps);
49
- let router = (0, $kKV4x$useRouter)();
50
- return {
51
- isPressed: isPressed,
52
- linkProps: (0, $kKV4x$mergeProps)(domProps, {
53
- ...interactionHandlers,
54
- ...linkProps,
55
- "aria-disabled": isDisabled || undefined,
56
- "aria-current": props["aria-current"],
57
- onClick: (e)=>{
58
- var _pressProps_onClick;
59
- (_pressProps_onClick = pressProps.onClick) === null || _pressProps_onClick === void 0 ? void 0 : _pressProps_onClick.call(pressProps, e);
60
- if (deprecatedOnClick) {
61
- deprecatedOnClick(e);
62
- console.warn("onClick is deprecated, please use onPress");
63
- }
64
- // If a custom router is provided, prevent default and forward if this link should client navigate.
65
- 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.
66
- !e.isDefaultPrevented() && (0, $kKV4x$shouldClientNavigate)(e.currentTarget, e)) {
67
- e.preventDefault();
68
- router.open(e.currentTarget, e);
69
- }
70
- }
71
- })
72
- };
73
- }
74
-
75
-
76
-
77
-
78
16
  export {$298d61e98472621b$export$dcf14c9974fe2767 as useLink};
79
17
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,24 +1,12 @@
1
- var $3NNeN$reactariautils = require("@react-aria/utils");
2
- var $3NNeN$reactariafocus = require("@react-aria/focus");
3
- var $3NNeN$reactariainteractions = require("@react-aria/interactions");
1
+ var $fbe6b19572273b2f$exports = require("./useLink.main.js");
4
2
 
5
3
 
6
4
  function $parcel$export(e, n, v, s) {
7
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
6
  }
9
7
 
10
- $parcel$export(module.exports, "useLink", () => $fbe6b19572273b2f$export$dcf14c9974fe2767);
8
+ $parcel$export(module.exports, "useLink", () => $fbe6b19572273b2f$exports.useLink);
11
9
  /*
12
- * Copyright 2020 Adobe. All rights reserved.
13
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
- * you may not use this file except in compliance with the License. You may obtain a copy
15
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software distributed under
18
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
- * OF ANY KIND, either express or implied. See the License for the specific language
20
- * governing permissions and limitations under the License.
21
- */ /*
22
10
  * Copyright 2020 Adobe. All rights reserved.
23
11
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
24
12
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -31,54 +19,4 @@ $parcel$export(module.exports, "useLink", () => $fbe6b19572273b2f$export$dcf14c9
31
19
  */
32
20
 
33
21
 
34
- function $fbe6b19572273b2f$export$dcf14c9974fe2767(props, ref) {
35
- let { elementType: elementType = "a", onPress: onPress, onPressStart: onPressStart, onPressEnd: onPressEnd, // @ts-ignore
36
- onClick: deprecatedOnClick, isDisabled: isDisabled, ...otherProps } = props;
37
- let linkProps = {};
38
- if (elementType !== "a") linkProps = {
39
- role: "link",
40
- tabIndex: !isDisabled ? 0 : undefined
41
- };
42
- let { focusableProps: focusableProps } = (0, $3NNeN$reactariafocus.useFocusable)(props, ref);
43
- let { pressProps: pressProps, isPressed: isPressed } = (0, $3NNeN$reactariainteractions.usePress)({
44
- onPress: onPress,
45
- onPressStart: onPressStart,
46
- onPressEnd: onPressEnd,
47
- isDisabled: isDisabled,
48
- ref: ref
49
- });
50
- let domProps = (0, $3NNeN$reactariautils.filterDOMProps)(otherProps, {
51
- labelable: true,
52
- isLink: elementType === "a"
53
- });
54
- let interactionHandlers = (0, $3NNeN$reactariautils.mergeProps)(focusableProps, pressProps);
55
- let router = (0, $3NNeN$reactariautils.useRouter)();
56
- return {
57
- isPressed: isPressed,
58
- linkProps: (0, $3NNeN$reactariautils.mergeProps)(domProps, {
59
- ...interactionHandlers,
60
- ...linkProps,
61
- "aria-disabled": isDisabled || undefined,
62
- "aria-current": props["aria-current"],
63
- onClick: (e)=>{
64
- var _pressProps_onClick;
65
- (_pressProps_onClick = pressProps.onClick) === null || _pressProps_onClick === void 0 ? void 0 : _pressProps_onClick.call(pressProps, e);
66
- if (deprecatedOnClick) {
67
- deprecatedOnClick(e);
68
- console.warn("onClick is deprecated, please use onPress");
69
- }
70
- // If a custom router is provided, prevent default and forward if this link should client navigate.
71
- 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.
72
- !e.isDefaultPrevented() && (0, $3NNeN$reactariautils.shouldClientNavigate)(e.currentTarget, e)) {
73
- e.preventDefault();
74
- router.open(e.currentTarget, e);
75
- }
76
- }
77
- })
78
- };
79
- }
80
-
81
-
82
-
83
-
84
22
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;;AA+BM,SAAS,0CAAQ,KAAsB,EAAE,GAAgC;IAC9E,IAAI,eACF,cAAc,cACd,OAAO,gBACP,YAAY,cACZ,UAAU,EACV,aAAa;IACb,SAAS,iBAAiB,cAC1B,UAAU,EACV,GAAG,YACJ,GAAG;IAEJ,IAAI,YAA2B,CAAC;IAChC,IAAI,gBAAgB,KAClB,YAAY;QACV,MAAM;QACN,UAAU,CAAC,aAAa,IAAI;IAC9B;IAEF,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,kCAAW,EAAE,OAAO;IAC3C,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;iBAAC;sBAAS;oBAAc;oBAAY;aAAY;IAAG;IAC1F,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,YAAY;QAAC,WAAW;QAAM,QAAQ,gBAAgB;IAAG;IACvF,IAAI,sBAAsB,CAAA,GAAA,gCAAS,EAAE,gBAAgB;IACrD,IAAI,SAAS,CAAA,GAAA,+BAAQ;IAErB,OAAO;mBACL;QACA,WAAW,CAAA,GAAA,gCAAS,EAAE,UAAU;YAC9B,GAAG,mBAAmB;YACtB,GAAG,SAAS;YACZ,iBAAiB,cAAc;YAC/B,gBAAgB,KAAK,CAAC,eAAe;YACrC,SAAS,CAAC;oBACR;iBAAA,sBAAA,WAAW,OAAO,cAAlB,0CAAA,yBAAA,YAAqB;gBACrB,IAAI,mBAAmB;oBACrB,kBAAkB;oBAClB,QAAQ,IAAI,CAAC;gBACf;gBAEA,mGAAmG;gBACnG,IACE,CAAC,OAAO,QAAQ,IAChB,EAAE,aAAa,YAAY,qBAC3B,EAAE,aAAa,CAAC,IAAI,IACpB,0FAA0F;gBAC1F,CAAC,EAAE,kBAAkB,MACrB,CAAA,GAAA,0CAAmB,EAAE,EAAE,aAAa,EAAE,IACtC;oBACA,EAAE,cAAc;oBAChB,OAAO,IAAI,CAAC,EAAE,aAAa,EAAE;gBAC/B;YACF;QACF;IACF;AACF;;CDrFC","sources":["packages/@react-aria/link/src/index.ts","packages/@react-aria/link/src/useLink.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 */\nexport type {AriaLinkOptions, LinkAria} from './useLink';\nexport {useLink} from './useLink';\n","/*\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\nimport {AriaLinkProps} from '@react-types/link';\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, shouldClientNavigate, useRouter} from '@react-aria/utils';\nimport React, {RefObject} from 'react';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface AriaLinkOptions extends AriaLinkProps {\n /** Whether the link is disabled. */\n isDisabled?: boolean,\n /**\n * The HTML element used to render the link, e.g. 'a', or 'span'.\n * @default 'a'\n */\n elementType?: string\n}\n\nexport interface LinkAria {\n /** Props for the link element. */\n linkProps: DOMAttributes,\n /** Whether the link is currently pressed. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a link component.\n * A link allows a user to navigate to another page or resource within a web page\n * or application.\n */\nexport function useLink(props: AriaLinkOptions, ref: RefObject<FocusableElement>): LinkAria {\n let {\n elementType = 'a',\n onPress,\n onPressStart,\n onPressEnd,\n // @ts-ignore\n onClick: deprecatedOnClick,\n isDisabled,\n ...otherProps\n } = props;\n\n let linkProps: DOMAttributes = {};\n if (elementType !== 'a') {\n linkProps = {\n role: 'link',\n tabIndex: !isDisabled ? 0 : undefined\n };\n }\n let {focusableProps} = useFocusable(props, ref);\n let {pressProps, isPressed} = usePress({onPress, onPressStart, onPressEnd, isDisabled, ref});\n let domProps = filterDOMProps(otherProps, {labelable: true, isLink: elementType === 'a'});\n let interactionHandlers = mergeProps(focusableProps, pressProps);\n let router = useRouter();\n\n return {\n isPressed, // Used to indicate press state for visual\n linkProps: mergeProps(domProps, {\n ...interactionHandlers,\n ...linkProps,\n 'aria-disabled': isDisabled || undefined,\n 'aria-current': props['aria-current'],\n onClick: (e: React.MouseEvent<HTMLAnchorElement>) => {\n pressProps.onClick?.(e);\n if (deprecatedOnClick) {\n deprecatedOnClick(e);\n console.warn('onClick is deprecated, please use onPress');\n }\n\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 ) {\n e.preventDefault();\n router.open(e.currentTarget, e);\n }\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/link/src/index.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 */\nexport type {AriaLinkOptions, LinkAria} from './useLink';\nexport {useLink} from './useLink';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,18 +1,6 @@
1
- import {filterDOMProps as $kKV4x$filterDOMProps, mergeProps as $kKV4x$mergeProps, useRouter as $kKV4x$useRouter, shouldClientNavigate as $kKV4x$shouldClientNavigate} from "@react-aria/utils";
2
- import {useFocusable as $kKV4x$useFocusable} from "@react-aria/focus";
3
- import {usePress as $kKV4x$usePress} from "@react-aria/interactions";
1
+ import {useLink as $298d61e98472621b$export$dcf14c9974fe2767} from "./useLink.module.js";
4
2
 
5
3
  /*
6
- * Copyright 2020 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
4
  * Copyright 2020 Adobe. All rights reserved.
17
5
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
6
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -25,55 +13,5 @@ import {usePress as $kKV4x$usePress} from "@react-aria/interactions";
25
13
  */
26
14
 
27
15
 
28
- function $298d61e98472621b$export$dcf14c9974fe2767(props, ref) {
29
- let { elementType: elementType = "a", onPress: onPress, onPressStart: onPressStart, onPressEnd: onPressEnd, // @ts-ignore
30
- onClick: deprecatedOnClick, isDisabled: isDisabled, ...otherProps } = props;
31
- let linkProps = {};
32
- if (elementType !== "a") linkProps = {
33
- role: "link",
34
- tabIndex: !isDisabled ? 0 : undefined
35
- };
36
- let { focusableProps: focusableProps } = (0, $kKV4x$useFocusable)(props, ref);
37
- let { pressProps: pressProps, isPressed: isPressed } = (0, $kKV4x$usePress)({
38
- onPress: onPress,
39
- onPressStart: onPressStart,
40
- onPressEnd: onPressEnd,
41
- isDisabled: isDisabled,
42
- ref: ref
43
- });
44
- let domProps = (0, $kKV4x$filterDOMProps)(otherProps, {
45
- labelable: true,
46
- isLink: elementType === "a"
47
- });
48
- let interactionHandlers = (0, $kKV4x$mergeProps)(focusableProps, pressProps);
49
- let router = (0, $kKV4x$useRouter)();
50
- return {
51
- isPressed: isPressed,
52
- linkProps: (0, $kKV4x$mergeProps)(domProps, {
53
- ...interactionHandlers,
54
- ...linkProps,
55
- "aria-disabled": isDisabled || undefined,
56
- "aria-current": props["aria-current"],
57
- onClick: (e)=>{
58
- var _pressProps_onClick;
59
- (_pressProps_onClick = pressProps.onClick) === null || _pressProps_onClick === void 0 ? void 0 : _pressProps_onClick.call(pressProps, e);
60
- if (deprecatedOnClick) {
61
- deprecatedOnClick(e);
62
- console.warn("onClick is deprecated, please use onPress");
63
- }
64
- // If a custom router is provided, prevent default and forward if this link should client navigate.
65
- 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.
66
- !e.isDefaultPrevented() && (0, $kKV4x$shouldClientNavigate)(e.currentTarget, e)) {
67
- e.preventDefault();
68
- router.open(e.currentTarget, e);
69
- }
70
- }
71
- })
72
- };
73
- }
74
-
75
-
76
-
77
-
78
16
  export {$298d61e98472621b$export$dcf14c9974fe2767 as useLink};
79
17
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;;AA+BM,SAAS,0CAAQ,KAAsB,EAAE,GAAgC;IAC9E,IAAI,eACF,cAAc,cACd,OAAO,gBACP,YAAY,cACZ,UAAU,EACV,aAAa;IACb,SAAS,iBAAiB,cAC1B,UAAU,EACV,GAAG,YACJ,GAAG;IAEJ,IAAI,YAA2B,CAAC;IAChC,IAAI,gBAAgB,KAClB,YAAY;QACV,MAAM;QACN,UAAU,CAAC,aAAa,IAAI;IAC9B;IAEF,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,mBAAW,EAAE,OAAO;IAC3C,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;iBAAC;sBAAS;oBAAc;oBAAY;aAAY;IAAG;IAC1F,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,YAAY;QAAC,WAAW;QAAM,QAAQ,gBAAgB;IAAG;IACvF,IAAI,sBAAsB,CAAA,GAAA,iBAAS,EAAE,gBAAgB;IACrD,IAAI,SAAS,CAAA,GAAA,gBAAQ;IAErB,OAAO;mBACL;QACA,WAAW,CAAA,GAAA,iBAAS,EAAE,UAAU;YAC9B,GAAG,mBAAmB;YACtB,GAAG,SAAS;YACZ,iBAAiB,cAAc;YAC/B,gBAAgB,KAAK,CAAC,eAAe;YACrC,SAAS,CAAC;oBACR;iBAAA,sBAAA,WAAW,OAAO,cAAlB,0CAAA,yBAAA,YAAqB;gBACrB,IAAI,mBAAmB;oBACrB,kBAAkB;oBAClB,QAAQ,IAAI,CAAC;gBACf;gBAEA,mGAAmG;gBACnG,IACE,CAAC,OAAO,QAAQ,IAChB,EAAE,aAAa,YAAY,qBAC3B,EAAE,aAAa,CAAC,IAAI,IACpB,0FAA0F;gBAC1F,CAAC,EAAE,kBAAkB,MACrB,CAAA,GAAA,2BAAmB,EAAE,EAAE,aAAa,EAAE,IACtC;oBACA,EAAE,cAAc;oBAChB,OAAO,IAAI,CAAC,EAAE,aAAa,EAAE;gBAC/B;YACF;QACF;IACF;AACF;;CDrFC","sources":["packages/@react-aria/link/src/index.ts","packages/@react-aria/link/src/useLink.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 */\nexport type {AriaLinkOptions, LinkAria} from './useLink';\nexport {useLink} from './useLink';\n","/*\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\nimport {AriaLinkProps} from '@react-types/link';\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, shouldClientNavigate, useRouter} from '@react-aria/utils';\nimport React, {RefObject} from 'react';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface AriaLinkOptions extends AriaLinkProps {\n /** Whether the link is disabled. */\n isDisabled?: boolean,\n /**\n * The HTML element used to render the link, e.g. 'a', or 'span'.\n * @default 'a'\n */\n elementType?: string\n}\n\nexport interface LinkAria {\n /** Props for the link element. */\n linkProps: DOMAttributes,\n /** Whether the link is currently pressed. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a link component.\n * A link allows a user to navigate to another page or resource within a web page\n * or application.\n */\nexport function useLink(props: AriaLinkOptions, ref: RefObject<FocusableElement>): LinkAria {\n let {\n elementType = 'a',\n onPress,\n onPressStart,\n onPressEnd,\n // @ts-ignore\n onClick: deprecatedOnClick,\n isDisabled,\n ...otherProps\n } = props;\n\n let linkProps: DOMAttributes = {};\n if (elementType !== 'a') {\n linkProps = {\n role: 'link',\n tabIndex: !isDisabled ? 0 : undefined\n };\n }\n let {focusableProps} = useFocusable(props, ref);\n let {pressProps, isPressed} = usePress({onPress, onPressStart, onPressEnd, isDisabled, ref});\n let domProps = filterDOMProps(otherProps, {labelable: true, isLink: elementType === 'a'});\n let interactionHandlers = mergeProps(focusableProps, pressProps);\n let router = useRouter();\n\n return {\n isPressed, // Used to indicate press state for visual\n linkProps: mergeProps(domProps, {\n ...interactionHandlers,\n ...linkProps,\n 'aria-disabled': isDisabled || undefined,\n 'aria-current': props['aria-current'],\n onClick: (e: React.MouseEvent<HTMLAnchorElement>) => {\n pressProps.onClick?.(e);\n if (deprecatedOnClick) {\n deprecatedOnClick(e);\n console.warn('onClick is deprecated, please use onPress');\n }\n\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 ) {\n e.preventDefault();\n router.open(e.currentTarget, e);\n }\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/link/src/index.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 */\nexport type {AriaLinkOptions, LinkAria} from './useLink';\nexport {useLink} from './useLink';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;AAmBA,gCAAiC,SAAQ,aAAa;IACpD,oCAAoC;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;IACE,kCAAkC;IAClC,SAAS,EAAE,aAAa,CAAC;IACzB,6CAA6C;IAC7C,SAAS,EAAE,OAAO,CAAA;CACnB;AAED;;;;GAIG;AACH,wBAAwB,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,UAAU,gBAAgB,CAAC,GAAG,QAAQ,CAsD1F","sources":["packages/@react-aria/link/src/packages/@react-aria/link/src/useLink.ts","packages/@react-aria/link/src/packages/@react-aria/link/src/index.ts","packages/@react-aria/link/src/index.ts"],"sourcesContent":[null,null,"/*\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 */\nexport type {AriaLinkOptions, LinkAria} from './useLink';\nexport {useLink} from './useLink';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;AAmBA,gCAAiC,SAAQ,aAAa;IACpD,oCAAoC;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;IACE,kCAAkC;IAClC,SAAS,EAAE,aAAa,CAAC;IACzB,6CAA6C;IAC7C,SAAS,EAAE,OAAO,CAAA;CACnB;AAED;;;;GAIG;AACH,wBAAwB,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,UAAU,gBAAgB,CAAC,GAAG,QAAQ,CAwD1F","sources":["packages/@react-aria/link/src/packages/@react-aria/link/src/useLink.ts","packages/@react-aria/link/src/packages/@react-aria/link/src/index.ts","packages/@react-aria/link/src/index.ts"],"sourcesContent":[null,null,"/*\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 */\nexport type {AriaLinkOptions, LinkAria} from './useLink';\nexport {useLink} from './useLink';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -0,0 +1,72 @@
1
+ var $8TwZf$reactariautils = require("@react-aria/utils");
2
+ var $8TwZf$reactariafocus = require("@react-aria/focus");
3
+ var $8TwZf$reactariainteractions = require("@react-aria/interactions");
4
+
5
+
6
+ function $parcel$export(e, n, v, s) {
7
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
+ }
9
+
10
+ $parcel$export(module.exports, "useLink", () => $fbe6b19572273b2f$export$dcf14c9974fe2767);
11
+ /*
12
+ * Copyright 2020 Adobe. All rights reserved.
13
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License. You may obtain a copy
15
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software distributed under
18
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
+ * OF ANY KIND, either express or implied. See the License for the specific language
20
+ * governing permissions and limitations under the License.
21
+ */
22
+
23
+
24
+ function $fbe6b19572273b2f$export$dcf14c9974fe2767(props, ref) {
25
+ let { elementType: elementType = "a", onPress: onPress, onPressStart: onPressStart, onPressEnd: onPressEnd, // @ts-ignore
26
+ onClick: deprecatedOnClick, isDisabled: isDisabled, ...otherProps } = props;
27
+ let linkProps = {};
28
+ if (elementType !== "a") linkProps = {
29
+ role: "link",
30
+ tabIndex: !isDisabled ? 0 : undefined
31
+ };
32
+ let { focusableProps: focusableProps } = (0, $8TwZf$reactariafocus.useFocusable)(props, ref);
33
+ let { pressProps: pressProps, isPressed: isPressed } = (0, $8TwZf$reactariainteractions.usePress)({
34
+ onPress: onPress,
35
+ onPressStart: onPressStart,
36
+ onPressEnd: onPressEnd,
37
+ isDisabled: isDisabled,
38
+ ref: ref
39
+ });
40
+ let domProps = (0, $8TwZf$reactariautils.filterDOMProps)(otherProps, {
41
+ labelable: true
42
+ });
43
+ let interactionHandlers = (0, $8TwZf$reactariautils.mergeProps)(focusableProps, pressProps);
44
+ let router = (0, $8TwZf$reactariautils.useRouter)();
45
+ let routerLinkProps = (0, $8TwZf$reactariautils.useLinkProps)(props);
46
+ return {
47
+ isPressed: isPressed,
48
+ linkProps: (0, $8TwZf$reactariautils.mergeProps)(domProps, routerLinkProps, {
49
+ ...interactionHandlers,
50
+ ...linkProps,
51
+ "aria-disabled": isDisabled || undefined,
52
+ "aria-current": props["aria-current"],
53
+ onClick: (e)=>{
54
+ var _pressProps_onClick;
55
+ (_pressProps_onClick = pressProps.onClick) === null || _pressProps_onClick === void 0 ? void 0 : _pressProps_onClick.call(pressProps, e);
56
+ if (deprecatedOnClick) {
57
+ deprecatedOnClick(e);
58
+ console.warn("onClick is deprecated, please use onPress");
59
+ }
60
+ // If a custom router is provided, prevent default and forward if this link should client navigate.
61
+ 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.
62
+ !e.isDefaultPrevented() && (0, $8TwZf$reactariautils.shouldClientNavigate)(e.currentTarget, e) && props.href) {
63
+ e.preventDefault();
64
+ router.open(e.currentTarget, e, props.href, props.routerOptions);
65
+ }
66
+ }
67
+ })
68
+ };
69
+ }
70
+
71
+
72
+ //# sourceMappingURL=useLink.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AA+BM,SAAS,0CAAQ,KAAsB,EAAE,GAAgC;IAC9E,IAAI,eACF,cAAc,cACd,OAAO,gBACP,YAAY,cACZ,UAAU,EACV,aAAa;IACb,SAAS,iBAAiB,cAC1B,UAAU,EACV,GAAG,YACJ,GAAG;IAEJ,IAAI,YAA2B,CAAC;IAChC,IAAI,gBAAgB,KAClB,YAAY;QACV,MAAM;QACN,UAAU,CAAC,aAAa,IAAI;IAC9B;IAEF,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,kCAAW,EAAE,OAAO;IAC3C,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;iBAAC;sBAAS;oBAAc;oBAAY;aAAY;IAAG;IAC1F,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,YAAY;QAAC,WAAW;IAAI;IAC1D,IAAI,sBAAsB,CAAA,GAAA,gCAAS,EAAE,gBAAgB;IACrD,IAAI,SAAS,CAAA,GAAA,+BAAQ;IACrB,IAAI,kBAAkB,CAAA,GAAA,kCAAW,EAAE;IAEnC,OAAO;mBACL;QACA,WAAW,CAAA,GAAA,gCAAS,EAAE,UAAU,iBAAiB;YAC/C,GAAG,mBAAmB;YACtB,GAAG,SAAS;YACZ,iBAAiB,cAAc;YAC/B,gBAAgB,KAAK,CAAC,eAAe;YACrC,SAAS,CAAC;oBACR;iBAAA,sBAAA,WAAW,OAAO,cAAlB,0CAAA,yBAAA,YAAqB;gBACrB,IAAI,mBAAmB;oBACrB,kBAAkB;oBAClB,QAAQ,IAAI,CAAC;gBACf;gBAEA,mGAAmG;gBACnG,IACE,CAAC,OAAO,QAAQ,IAChB,EAAE,aAAa,YAAY,qBAC3B,EAAE,aAAa,CAAC,IAAI,IACpB,0FAA0F;gBAC1F,CAAC,EAAE,kBAAkB,MACrB,CAAA,GAAA,0CAAmB,EAAE,EAAE,aAAa,EAAE,MACtC,MAAM,IAAI,EACV;oBACA,EAAE,cAAc;oBAChB,OAAO,IAAI,CAAC,EAAE,aAAa,EAAE,GAAG,MAAM,IAAI,EAAE,MAAM,aAAa;gBACjE;YACF;QACF;IACF;AACF","sources":["packages/@react-aria/link/src/useLink.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\nimport {AriaLinkProps} from '@react-types/link';\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, shouldClientNavigate, useLinkProps, useRouter} from '@react-aria/utils';\nimport React, {RefObject} from 'react';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface AriaLinkOptions extends AriaLinkProps {\n /** Whether the link is disabled. */\n isDisabled?: boolean,\n /**\n * The HTML element used to render the link, e.g. 'a', or 'span'.\n * @default 'a'\n */\n elementType?: string\n}\n\nexport interface LinkAria {\n /** Props for the link element. */\n linkProps: DOMAttributes,\n /** Whether the link is currently pressed. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a link component.\n * A link allows a user to navigate to another page or resource within a web page\n * or application.\n */\nexport function useLink(props: AriaLinkOptions, ref: RefObject<FocusableElement>): LinkAria {\n let {\n elementType = 'a',\n onPress,\n onPressStart,\n onPressEnd,\n // @ts-ignore\n onClick: deprecatedOnClick,\n isDisabled,\n ...otherProps\n } = props;\n\n let linkProps: DOMAttributes = {};\n if (elementType !== 'a') {\n linkProps = {\n role: 'link',\n tabIndex: !isDisabled ? 0 : undefined\n };\n }\n let {focusableProps} = useFocusable(props, ref);\n let {pressProps, isPressed} = usePress({onPress, onPressStart, onPressEnd, isDisabled, ref});\n let domProps = filterDOMProps(otherProps, {labelable: true});\n let interactionHandlers = mergeProps(focusableProps, pressProps);\n let router = useRouter();\n let routerLinkProps = useLinkProps(props);\n\n return {\n isPressed, // Used to indicate press state for visual\n linkProps: mergeProps(domProps, routerLinkProps, {\n ...interactionHandlers,\n ...linkProps,\n 'aria-disabled': isDisabled || undefined,\n 'aria-current': props['aria-current'],\n onClick: (e: React.MouseEvent<HTMLAnchorElement>) => {\n pressProps.onClick?.(e);\n if (deprecatedOnClick) {\n deprecatedOnClick(e);\n console.warn('onClick is deprecated, please use onPress');\n }\n\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 props.href\n ) {\n e.preventDefault();\n router.open(e.currentTarget, e, props.href, props.routerOptions);\n }\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"useLink.main.js.map"}
@@ -0,0 +1,67 @@
1
+ import {filterDOMProps as $5Ot33$filterDOMProps, mergeProps as $5Ot33$mergeProps, useRouter as $5Ot33$useRouter, useLinkProps as $5Ot33$useLinkProps, shouldClientNavigate as $5Ot33$shouldClientNavigate} from "@react-aria/utils";
2
+ import {useFocusable as $5Ot33$useFocusable} from "@react-aria/focus";
3
+ import {usePress as $5Ot33$usePress} from "@react-aria/interactions";
4
+
5
+ /*
6
+ * Copyright 2020 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
+ function $298d61e98472621b$export$dcf14c9974fe2767(props, ref) {
19
+ let { elementType: elementType = "a", onPress: onPress, onPressStart: onPressStart, onPressEnd: onPressEnd, // @ts-ignore
20
+ onClick: deprecatedOnClick, isDisabled: isDisabled, ...otherProps } = props;
21
+ let linkProps = {};
22
+ if (elementType !== "a") linkProps = {
23
+ role: "link",
24
+ tabIndex: !isDisabled ? 0 : undefined
25
+ };
26
+ let { focusableProps: focusableProps } = (0, $5Ot33$useFocusable)(props, ref);
27
+ let { pressProps: pressProps, isPressed: isPressed } = (0, $5Ot33$usePress)({
28
+ onPress: onPress,
29
+ onPressStart: onPressStart,
30
+ onPressEnd: onPressEnd,
31
+ isDisabled: isDisabled,
32
+ ref: ref
33
+ });
34
+ let domProps = (0, $5Ot33$filterDOMProps)(otherProps, {
35
+ labelable: true
36
+ });
37
+ let interactionHandlers = (0, $5Ot33$mergeProps)(focusableProps, pressProps);
38
+ let router = (0, $5Ot33$useRouter)();
39
+ let routerLinkProps = (0, $5Ot33$useLinkProps)(props);
40
+ return {
41
+ isPressed: isPressed,
42
+ linkProps: (0, $5Ot33$mergeProps)(domProps, routerLinkProps, {
43
+ ...interactionHandlers,
44
+ ...linkProps,
45
+ "aria-disabled": isDisabled || undefined,
46
+ "aria-current": props["aria-current"],
47
+ onClick: (e)=>{
48
+ var _pressProps_onClick;
49
+ (_pressProps_onClick = pressProps.onClick) === null || _pressProps_onClick === void 0 ? void 0 : _pressProps_onClick.call(pressProps, e);
50
+ if (deprecatedOnClick) {
51
+ deprecatedOnClick(e);
52
+ console.warn("onClick is deprecated, please use onPress");
53
+ }
54
+ // If a custom router is provided, prevent default and forward if this link should client navigate.
55
+ 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.
56
+ !e.isDefaultPrevented() && (0, $5Ot33$shouldClientNavigate)(e.currentTarget, e) && props.href) {
57
+ e.preventDefault();
58
+ router.open(e.currentTarget, e, props.href, props.routerOptions);
59
+ }
60
+ }
61
+ })
62
+ };
63
+ }
64
+
65
+
66
+ export {$298d61e98472621b$export$dcf14c9974fe2767 as useLink};
67
+ //# sourceMappingURL=useLink.mjs.map
@@ -0,0 +1,67 @@
1
+ import {filterDOMProps as $5Ot33$filterDOMProps, mergeProps as $5Ot33$mergeProps, useRouter as $5Ot33$useRouter, useLinkProps as $5Ot33$useLinkProps, shouldClientNavigate as $5Ot33$shouldClientNavigate} from "@react-aria/utils";
2
+ import {useFocusable as $5Ot33$useFocusable} from "@react-aria/focus";
3
+ import {usePress as $5Ot33$usePress} from "@react-aria/interactions";
4
+
5
+ /*
6
+ * Copyright 2020 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
+ function $298d61e98472621b$export$dcf14c9974fe2767(props, ref) {
19
+ let { elementType: elementType = "a", onPress: onPress, onPressStart: onPressStart, onPressEnd: onPressEnd, // @ts-ignore
20
+ onClick: deprecatedOnClick, isDisabled: isDisabled, ...otherProps } = props;
21
+ let linkProps = {};
22
+ if (elementType !== "a") linkProps = {
23
+ role: "link",
24
+ tabIndex: !isDisabled ? 0 : undefined
25
+ };
26
+ let { focusableProps: focusableProps } = (0, $5Ot33$useFocusable)(props, ref);
27
+ let { pressProps: pressProps, isPressed: isPressed } = (0, $5Ot33$usePress)({
28
+ onPress: onPress,
29
+ onPressStart: onPressStart,
30
+ onPressEnd: onPressEnd,
31
+ isDisabled: isDisabled,
32
+ ref: ref
33
+ });
34
+ let domProps = (0, $5Ot33$filterDOMProps)(otherProps, {
35
+ labelable: true
36
+ });
37
+ let interactionHandlers = (0, $5Ot33$mergeProps)(focusableProps, pressProps);
38
+ let router = (0, $5Ot33$useRouter)();
39
+ let routerLinkProps = (0, $5Ot33$useLinkProps)(props);
40
+ return {
41
+ isPressed: isPressed,
42
+ linkProps: (0, $5Ot33$mergeProps)(domProps, routerLinkProps, {
43
+ ...interactionHandlers,
44
+ ...linkProps,
45
+ "aria-disabled": isDisabled || undefined,
46
+ "aria-current": props["aria-current"],
47
+ onClick: (e)=>{
48
+ var _pressProps_onClick;
49
+ (_pressProps_onClick = pressProps.onClick) === null || _pressProps_onClick === void 0 ? void 0 : _pressProps_onClick.call(pressProps, e);
50
+ if (deprecatedOnClick) {
51
+ deprecatedOnClick(e);
52
+ console.warn("onClick is deprecated, please use onPress");
53
+ }
54
+ // If a custom router is provided, prevent default and forward if this link should client navigate.
55
+ 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.
56
+ !e.isDefaultPrevented() && (0, $5Ot33$shouldClientNavigate)(e.currentTarget, e) && props.href) {
57
+ e.preventDefault();
58
+ router.open(e.currentTarget, e, props.href, props.routerOptions);
59
+ }
60
+ }
61
+ })
62
+ };
63
+ }
64
+
65
+
66
+ export {$298d61e98472621b$export$dcf14c9974fe2767 as useLink};
67
+ //# sourceMappingURL=useLink.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AA+BM,SAAS,0CAAQ,KAAsB,EAAE,GAAgC;IAC9E,IAAI,eACF,cAAc,cACd,OAAO,gBACP,YAAY,cACZ,UAAU,EACV,aAAa;IACb,SAAS,iBAAiB,cAC1B,UAAU,EACV,GAAG,YACJ,GAAG;IAEJ,IAAI,YAA2B,CAAC;IAChC,IAAI,gBAAgB,KAClB,YAAY;QACV,MAAM;QACN,UAAU,CAAC,aAAa,IAAI;IAC9B;IAEF,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,mBAAW,EAAE,OAAO;IAC3C,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;iBAAC;sBAAS;oBAAc;oBAAY;aAAY;IAAG;IAC1F,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,YAAY;QAAC,WAAW;IAAI;IAC1D,IAAI,sBAAsB,CAAA,GAAA,iBAAS,EAAE,gBAAgB;IACrD,IAAI,SAAS,CAAA,GAAA,gBAAQ;IACrB,IAAI,kBAAkB,CAAA,GAAA,mBAAW,EAAE;IAEnC,OAAO;mBACL;QACA,WAAW,CAAA,GAAA,iBAAS,EAAE,UAAU,iBAAiB;YAC/C,GAAG,mBAAmB;YACtB,GAAG,SAAS;YACZ,iBAAiB,cAAc;YAC/B,gBAAgB,KAAK,CAAC,eAAe;YACrC,SAAS,CAAC;oBACR;iBAAA,sBAAA,WAAW,OAAO,cAAlB,0CAAA,yBAAA,YAAqB;gBACrB,IAAI,mBAAmB;oBACrB,kBAAkB;oBAClB,QAAQ,IAAI,CAAC;gBACf;gBAEA,mGAAmG;gBACnG,IACE,CAAC,OAAO,QAAQ,IAChB,EAAE,aAAa,YAAY,qBAC3B,EAAE,aAAa,CAAC,IAAI,IACpB,0FAA0F;gBAC1F,CAAC,EAAE,kBAAkB,MACrB,CAAA,GAAA,2BAAmB,EAAE,EAAE,aAAa,EAAE,MACtC,MAAM,IAAI,EACV;oBACA,EAAE,cAAc;oBAChB,OAAO,IAAI,CAAC,EAAE,aAAa,EAAE,GAAG,MAAM,IAAI,EAAE,MAAM,aAAa;gBACjE;YACF;QACF;IACF;AACF","sources":["packages/@react-aria/link/src/useLink.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\nimport {AriaLinkProps} from '@react-types/link';\nimport {DOMAttributes, FocusableElement} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, shouldClientNavigate, useLinkProps, useRouter} from '@react-aria/utils';\nimport React, {RefObject} from 'react';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface AriaLinkOptions extends AriaLinkProps {\n /** Whether the link is disabled. */\n isDisabled?: boolean,\n /**\n * The HTML element used to render the link, e.g. 'a', or 'span'.\n * @default 'a'\n */\n elementType?: string\n}\n\nexport interface LinkAria {\n /** Props for the link element. */\n linkProps: DOMAttributes,\n /** Whether the link is currently pressed. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a link component.\n * A link allows a user to navigate to another page or resource within a web page\n * or application.\n */\nexport function useLink(props: AriaLinkOptions, ref: RefObject<FocusableElement>): LinkAria {\n let {\n elementType = 'a',\n onPress,\n onPressStart,\n onPressEnd,\n // @ts-ignore\n onClick: deprecatedOnClick,\n isDisabled,\n ...otherProps\n } = props;\n\n let linkProps: DOMAttributes = {};\n if (elementType !== 'a') {\n linkProps = {\n role: 'link',\n tabIndex: !isDisabled ? 0 : undefined\n };\n }\n let {focusableProps} = useFocusable(props, ref);\n let {pressProps, isPressed} = usePress({onPress, onPressStart, onPressEnd, isDisabled, ref});\n let domProps = filterDOMProps(otherProps, {labelable: true});\n let interactionHandlers = mergeProps(focusableProps, pressProps);\n let router = useRouter();\n let routerLinkProps = useLinkProps(props);\n\n return {\n isPressed, // Used to indicate press state for visual\n linkProps: mergeProps(domProps, routerLinkProps, {\n ...interactionHandlers,\n ...linkProps,\n 'aria-disabled': isDisabled || undefined,\n 'aria-current': props['aria-current'],\n onClick: (e: React.MouseEvent<HTMLAnchorElement>) => {\n pressProps.onClick?.(e);\n if (deprecatedOnClick) {\n deprecatedOnClick(e);\n console.warn('onClick is deprecated, please use onPress');\n }\n\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 props.href\n ) {\n e.preventDefault();\n router.open(e.currentTarget, e, props.href, props.routerOptions);\n }\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"useLink.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/link",
3
- "version": "3.6.4",
3
+ "version": "3.7.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,11 +22,11 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/focus": "^3.16.1",
26
- "@react-aria/interactions": "^3.21.0",
27
- "@react-aria/utils": "^3.23.1",
28
- "@react-types/link": "^3.5.2",
29
- "@react-types/shared": "^3.22.0",
25
+ "@react-aria/focus": "^3.17.0",
26
+ "@react-aria/interactions": "^3.21.2",
27
+ "@react-aria/utils": "^3.24.0",
28
+ "@react-types/link": "^3.5.4",
29
+ "@react-types/shared": "^3.23.0",
30
30
  "@swc/helpers": "^0.5.0"
31
31
  },
32
32
  "peerDependencies": {
@@ -35,5 +35,5 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "f040ff62678e6a31375b96c05396df0bae660350"
38
+ "gitHead": "f645f29edc1322153fd60af4640cbcab1d992dbd"
39
39
  }
package/src/useLink.ts CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  import {AriaLinkProps} from '@react-types/link';
14
14
  import {DOMAttributes, FocusableElement} from '@react-types/shared';
15
- import {filterDOMProps, mergeProps, shouldClientNavigate, useRouter} from '@react-aria/utils';
15
+ import {filterDOMProps, mergeProps, shouldClientNavigate, useLinkProps, useRouter} from '@react-aria/utils';
16
16
  import React, {RefObject} from 'react';
17
17
  import {useFocusable} from '@react-aria/focus';
18
18
  import {usePress} from '@react-aria/interactions';
@@ -60,13 +60,14 @@ export function useLink(props: AriaLinkOptions, ref: RefObject<FocusableElement>
60
60
  }
61
61
  let {focusableProps} = useFocusable(props, ref);
62
62
  let {pressProps, isPressed} = usePress({onPress, onPressStart, onPressEnd, isDisabled, ref});
63
- let domProps = filterDOMProps(otherProps, {labelable: true, isLink: elementType === 'a'});
63
+ let domProps = filterDOMProps(otherProps, {labelable: true});
64
64
  let interactionHandlers = mergeProps(focusableProps, pressProps);
65
65
  let router = useRouter();
66
+ let routerLinkProps = useLinkProps(props);
66
67
 
67
68
  return {
68
69
  isPressed, // Used to indicate press state for visual
69
- linkProps: mergeProps(domProps, {
70
+ linkProps: mergeProps(domProps, routerLinkProps, {
70
71
  ...interactionHandlers,
71
72
  ...linkProps,
72
73
  'aria-disabled': isDisabled || undefined,
@@ -85,10 +86,11 @@ export function useLink(props: AriaLinkOptions, ref: RefObject<FocusableElement>
85
86
  e.currentTarget.href &&
86
87
  // If props are applied to a router Link component, it may have already prevented default.
87
88
  !e.isDefaultPrevented() &&
88
- shouldClientNavigate(e.currentTarget, e)
89
+ shouldClientNavigate(e.currentTarget, e) &&
90
+ props.href
89
91
  ) {
90
92
  e.preventDefault();
91
- router.open(e.currentTarget, e);
93
+ router.open(e.currentTarget, e, props.href, props.routerOptions);
92
94
  }
93
95
  }
94
96
  })