@react-aria/link
Advanced tools
+9
-1
@@ -6,2 +6,6 @@ var { | ||
| var { | ||
| useFocusable | ||
| } = require("@react-aria/focus"); | ||
| var { | ||
| filterDOMProps, | ||
@@ -46,2 +50,5 @@ mergeProps | ||
| let { | ||
| focusableProps | ||
| } = useFocusable(props, ref); | ||
| let { | ||
| pressProps, | ||
@@ -59,6 +66,7 @@ isPressed | ||
| }); | ||
| let interactionHandlers = mergeProps(focusableProps, pressProps); | ||
| return { | ||
| isPressed, | ||
| // Used to indicate press state for visual | ||
| linkProps: mergeProps(domProps, _babelRuntimeHelpersExtends({}, pressProps, linkProps, { | ||
| linkProps: mergeProps(domProps, _babelRuntimeHelpersExtends({}, interactionHandlers, linkProps, { | ||
| 'aria-disabled': isDisabled || undefined, | ||
@@ -65,0 +73,0 @@ onClick: e => { |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"mappings":";;;;;;;;;;;;;AAAA,SAASA,sBAAT,CAAgCC,CAAhC,EAAmC;AACjC,SAAOA,CAAC,IAAIA,CAAC,CAACC,UAAP,GAAoBD,CAAC,CAACE,OAAtB,GAAgCF,CAAvC;AACD;;ACgCD;;;;;AAKO,SAASG,OAAT,CAAiBC,KAAjB,EAAyCC,GAAzC,EAAgF;AACrF,MAAI;AACFC,IAAAA,WAAW,GAAG,GADZ;AAEFC,IAAAA,OAFE;AAGFC,IAAAA,YAHE;AAIFC,IAAAA,UAJE;AAKF;AACAC,IAAAA,OAAO,EAAEC,iBANP;AAOFC,IAAAA;AAPE,MASAR,KATJ;AAAA,MAQKS,UARL,oDASIT,KATJ;;AAWA,MAAIU,SAAJ;;AACA,MAAIR,WAAW,KAAK,GAApB,EAAyB;AACvBQ,IAAAA,SAAS,GAAG;AACVC,MAAAA,IAAI,EAAE,MADI;AAEVC,MAAAA,QAAQ,EAAE,CAACJ,UAAD,GAAc,CAAd,GAAkBK;AAFlB,KAAZ;AAID;;AAED,MAAI;AAACC,IAAAA,UAAD;AAAaC,IAAAA;AAAb,MAA0BC,QAAQ,CAAC;AAACb,IAAAA,OAAD;AAAUC,IAAAA,YAAV;AAAwBC,IAAAA,UAAxB;AAAoCG,IAAAA,UAApC;AAAgDP,IAAAA;AAAhD,GAAD,CAAtC;AACA,MAAIgB,QAAQ,GAAGC,cAAc,CAACT,UAAD,EAAa;AAACU,IAAAA,SAAS,EAAE;AAAZ,GAAb,CAA7B;AAEA,SAAO;AACLJ,IAAAA,SADK;AACM;AACXL,IAAAA,SAAS,EAAEU,UAAU,CAACH,QAAD,kCAChBH,UADgB,EAEhBJ,SAFgB;AAGnB,uBAAiBF,UAAU,IAAIK,SAHZ;AAInBP,MAAAA,OAAO,EAAGe,CAAD,IAAO;AACdP,QAAAA,UAAU,CAACR,OAAX,CAAmBe,CAAnB;;AACA,YAAId,iBAAJ,EAAuB;AACrBA,UAAAA,iBAAiB,CAACc,CAAD,CAAjB;AACAC,UAAAA,OAAO,CAACC,IAAR,CAAa,2CAAb;AACD;AACF;AAVkB;AAFhB,GAAP;AAeD","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/@react-aria/link/src/useLink.ts"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\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 {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {HTMLAttributes, RefObject} from 'react';\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: HTMLAttributes<HTMLElement>,\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<HTMLElement>): 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: HTMLAttributes<HTMLElement>;\n if (elementType !== 'a') {\n linkProps = {\n role: 'link',\n tabIndex: !isDisabled ? 0 : undefined\n };\n }\n\n let {pressProps, isPressed} = usePress({onPress, onPressStart, onPressEnd, isDisabled, ref});\n let domProps = filterDOMProps(otherProps, {labelable: true});\n\n return {\n isPressed, // Used to indicate press state for visual\n linkProps: mergeProps(domProps, {\n ...pressProps,\n ...linkProps,\n 'aria-disabled': isDisabled || undefined,\n onClick: (e) => {\n pressProps.onClick(e);\n if (deprecatedOnClick) {\n deprecatedOnClick(e);\n console.warn('onClick is deprecated, please use onPress');\n }\n }\n })\n };\n}\n"],"names":["$parcel$interopDefault","a","__esModule","default","useLink","props","ref","elementType","onPress","onPressStart","onPressEnd","onClick","deprecatedOnClick","isDisabled","otherProps","linkProps","role","tabIndex","undefined","pressProps","isPressed","usePress","domProps","filterDOMProps","labelable","mergeProps","e","console","warn"],"version":3,"file":"main.js.map"} | ||
| {"mappings":";;;;;;;;;;;;;;;;;AAAA,SAASA,sBAAT,CAAgCC,CAAhC,EAAmC;AACjC,SAAOA,CAAC,IAAIA,CAAC,CAACC,UAAP,GAAoBD,CAAC,CAACE,OAAtB,GAAgCF,CAAvC;AACD;;ACiCD;;;;;AAKO,SAASG,OAAT,CAAiBC,KAAjB,EAAyCC,GAAzC,EAAgF;AACrF,MAAI;AACFC,IAAAA,WAAW,GAAG,GADZ;AAEFC,IAAAA,OAFE;AAGFC,IAAAA,YAHE;AAIFC,IAAAA,UAJE;AAKF;AACAC,IAAAA,OAAO,EAAEC,iBANP;AAOFC,IAAAA;AAPE,MASAR,KATJ;AAAA,MAQKS,UARL,oDASIT,KATJ;;AAWA,MAAIU,SAAJ;;AACA,MAAIR,WAAW,KAAK,GAApB,EAAyB;AACvBQ,IAAAA,SAAS,GAAG;AACVC,MAAAA,IAAI,EAAE,MADI;AAEVC,MAAAA,QAAQ,EAAE,CAACJ,UAAD,GAAc,CAAd,GAAkBK;AAFlB,KAAZ;AAID;;AACD,MAAI;AAACC,IAAAA;AAAD,MAAmBC,YAAY,CAACf,KAAD,EAAQC,GAAR,CAAnC;AACA,MAAI;AAACe,IAAAA,UAAD;AAAaC,IAAAA;AAAb,MAA0BC,QAAQ,CAAC;AAACf,IAAAA,OAAD;AAAUC,IAAAA,YAAV;AAAwBC,IAAAA,UAAxB;AAAoCG,IAAAA,UAApC;AAAgDP,IAAAA;AAAhD,GAAD,CAAtC;AACA,MAAIkB,QAAQ,GAAGC,cAAc,CAACX,UAAD,EAAa;AAACY,IAAAA,SAAS,EAAE;AAAZ,GAAb,CAA7B;AACA,MAAIC,mBAAmB,GAAGC,UAAU,CAACT,cAAD,EAAiBE,UAAjB,CAApC;AAEA,SAAO;AACLC,IAAAA,SADK;AACM;AACXP,IAAAA,SAAS,EAAEa,UAAU,CAACJ,QAAD,kCAChBG,mBADgB,EAEhBZ,SAFgB;AAGnB,uBAAiBF,UAAU,IAAIK,SAHZ;AAInBP,MAAAA,OAAO,EAAGkB,CAAD,IAAO;AACdR,QAAAA,UAAU,CAACV,OAAX,CAAmBkB,CAAnB;;AACA,YAAIjB,iBAAJ,EAAuB;AACrBA,UAAAA,iBAAiB,CAACiB,CAAD,CAAjB;AACAC,UAAAA,OAAO,CAACC,IAAR,CAAa,2CAAb;AACD;AACF;AAVkB;AAFhB,GAAP;AAeD","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/@react-aria/link/src/useLink.ts"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\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 {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {HTMLAttributes, 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: HTMLAttributes<HTMLElement>,\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<HTMLElement>): 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: HTMLAttributes<HTMLElement>;\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\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 onClick: (e) => {\n pressProps.onClick(e);\n if (deprecatedOnClick) {\n deprecatedOnClick(e);\n console.warn('onClick is deprecated, please use onPress');\n }\n }\n })\n };\n}\n"],"names":["$parcel$interopDefault","a","__esModule","default","useLink","props","ref","elementType","onPress","onPressStart","onPressEnd","onClick","deprecatedOnClick","isDisabled","otherProps","linkProps","role","tabIndex","undefined","focusableProps","useFocusable","pressProps","isPressed","usePress","domProps","filterDOMProps","labelable","interactionHandlers","mergeProps","e","console","warn"],"version":3,"file":"main.js.map"} |
+6
-1
| import { usePress } from "@react-aria/interactions"; | ||
| import { useFocusable } from "@react-aria/focus"; | ||
| import { filterDOMProps, mergeProps } from "@react-aria/utils"; | ||
@@ -33,2 +34,5 @@ import _babelRuntimeHelpersEsmObjectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; | ||
| let { | ||
| focusableProps | ||
| } = useFocusable(props, ref); | ||
| let { | ||
| pressProps, | ||
@@ -46,6 +50,7 @@ isPressed | ||
| }); | ||
| let interactionHandlers = mergeProps(focusableProps, pressProps); | ||
| return { | ||
| isPressed, | ||
| // Used to indicate press state for visual | ||
| linkProps: mergeProps(domProps, _babelRuntimeHelpersEsmExtends({}, pressProps, linkProps, { | ||
| linkProps: mergeProps(domProps, _babelRuntimeHelpersEsmExtends({}, interactionHandlers, linkProps, { | ||
| 'aria-disabled': isDisabled || undefined, | ||
@@ -52,0 +57,0 @@ onClick: e => { |
@@ -1,1 +0,1 @@ | ||
| {"mappings":";;;;;AAkCA;;;;;OAKO,SAASA,OAAT,CAAiBC,KAAjB,EAAyCC,GAAzC,EAAgF;AACrF,MAAI;AACFC,IAAAA,WAAW,GAAG,GADZ;AAEFC,IAAAA,OAFE;AAGFC,IAAAA,YAHE;AAIFC,IAAAA,UAJE;AAKF;AACAC,IAAAA,OAAO,EAAEC,iBANP;AAOFC,IAAAA;AAPE,MASAR,KATJ;AAAA,MAQKS,UARL,uDASIT,KATJ;;AAWA,MAAIU,SAAJ;;AACA,MAAIR,WAAW,KAAK,GAApB,EAAyB;AACvBQ,IAAAA,SAAS,GAAG;AACVC,MAAAA,IAAI,EAAE,MADI;AAEVC,MAAAA,QAAQ,EAAE,CAACJ,UAAD,GAAc,CAAd,GAAkBK;AAFlB,KAAZ;AAID;;AAED,MAAI;AAACC,IAAAA,UAAD;AAAaC,IAAAA;AAAb,MAA0BC,QAAQ,CAAC;AAACb,IAAAA,OAAD;AAAUC,IAAAA,YAAV;AAAwBC,IAAAA,UAAxB;AAAoCG,IAAAA,UAApC;AAAgDP,IAAAA;AAAhD,GAAD,CAAtC;AACA,MAAIgB,QAAQ,GAAGC,cAAc,CAACT,UAAD,EAAa;AAACU,IAAAA,SAAS,EAAE;AAAZ,GAAb,CAA7B;AAEA,SAAO;AACLJ,IAAAA,SADK;AACM;AACXL,IAAAA,SAAS,EAAEU,UAAU,CAACH,QAAD,qCAChBH,UADgB,EAEhBJ,SAFgB;AAGnB,uBAAiBF,UAAU,IAAIK,SAHZ;AAInBP,MAAAA,OAAO,EAAGe,CAAD,IAAO;AACdP,QAAAA,UAAU,CAACR,OAAX,CAAmBe,CAAnB;;AACA,YAAId,iBAAJ,EAAuB;AACrBA,UAAAA,iBAAiB,CAACc,CAAD,CAAjB;AACAC,UAAAA,OAAO,CAACC,IAAR,CAAa,2CAAb;AACD;AACF;AAVkB;AAFhB,GAAP;AAeD","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 {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {HTMLAttributes, RefObject} from 'react';\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: HTMLAttributes<HTMLElement>,\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<HTMLElement>): 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: HTMLAttributes<HTMLElement>;\n if (elementType !== 'a') {\n linkProps = {\n role: 'link',\n tabIndex: !isDisabled ? 0 : undefined\n };\n }\n\n let {pressProps, isPressed} = usePress({onPress, onPressStart, onPressEnd, isDisabled, ref});\n let domProps = filterDOMProps(otherProps, {labelable: true});\n\n return {\n isPressed, // Used to indicate press state for visual\n linkProps: mergeProps(domProps, {\n ...pressProps,\n ...linkProps,\n 'aria-disabled': isDisabled || undefined,\n onClick: (e) => {\n pressProps.onClick(e);\n if (deprecatedOnClick) {\n deprecatedOnClick(e);\n console.warn('onClick is deprecated, please use onPress');\n }\n }\n })\n };\n}\n"],"names":["useLink","props","ref","elementType","onPress","onPressStart","onPressEnd","onClick","deprecatedOnClick","isDisabled","otherProps","linkProps","role","tabIndex","undefined","pressProps","isPressed","usePress","domProps","filterDOMProps","labelable","mergeProps","e","console","warn"],"version":3,"file":"module.js.map"} | ||
| {"mappings":";;;;;;AAmCA;;;;;OAKO,SAASA,OAAT,CAAiBC,KAAjB,EAAyCC,GAAzC,EAAgF;AACrF,MAAI;AACFC,IAAAA,WAAW,GAAG,GADZ;AAEFC,IAAAA,OAFE;AAGFC,IAAAA,YAHE;AAIFC,IAAAA,UAJE;AAKF;AACAC,IAAAA,OAAO,EAAEC,iBANP;AAOFC,IAAAA;AAPE,MASAR,KATJ;AAAA,MAQKS,UARL,uDASIT,KATJ;;AAWA,MAAIU,SAAJ;;AACA,MAAIR,WAAW,KAAK,GAApB,EAAyB;AACvBQ,IAAAA,SAAS,GAAG;AACVC,MAAAA,IAAI,EAAE,MADI;AAEVC,MAAAA,QAAQ,EAAE,CAACJ,UAAD,GAAc,CAAd,GAAkBK;AAFlB,KAAZ;AAID;;AACD,MAAI;AAACC,IAAAA;AAAD,MAAmBC,YAAY,CAACf,KAAD,EAAQC,GAAR,CAAnC;AACA,MAAI;AAACe,IAAAA,UAAD;AAAaC,IAAAA;AAAb,MAA0BC,QAAQ,CAAC;AAACf,IAAAA,OAAD;AAAUC,IAAAA,YAAV;AAAwBC,IAAAA,UAAxB;AAAoCG,IAAAA,UAApC;AAAgDP,IAAAA;AAAhD,GAAD,CAAtC;AACA,MAAIkB,QAAQ,GAAGC,cAAc,CAACX,UAAD,EAAa;AAACY,IAAAA,SAAS,EAAE;AAAZ,GAAb,CAA7B;AACA,MAAIC,mBAAmB,GAAGC,UAAU,CAACT,cAAD,EAAiBE,UAAjB,CAApC;AAEA,SAAO;AACLC,IAAAA,SADK;AACM;AACXP,IAAAA,SAAS,EAAEa,UAAU,CAACJ,QAAD,qCAChBG,mBADgB,EAEhBZ,SAFgB;AAGnB,uBAAiBF,UAAU,IAAIK,SAHZ;AAInBP,MAAAA,OAAO,EAAGkB,CAAD,IAAO;AACdR,QAAAA,UAAU,CAACV,OAAX,CAAmBkB,CAAnB;;AACA,YAAIjB,iBAAJ,EAAuB;AACrBA,UAAAA,iBAAiB,CAACiB,CAAD,CAAjB;AACAC,UAAAA,OAAO,CAACC,IAAR,CAAa,2CAAb;AACD;AACF;AAVkB;AAFhB,GAAP;AAeD","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 {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {HTMLAttributes, 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: HTMLAttributes<HTMLElement>,\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<HTMLElement>): 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: HTMLAttributes<HTMLElement>;\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\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 onClick: (e) => {\n pressProps.onClick(e);\n if (deprecatedOnClick) {\n deprecatedOnClick(e);\n console.warn('onClick is deprecated, please use onPress');\n }\n }\n })\n };\n}\n"],"names":["useLink","props","ref","elementType","onPress","onPressStart","onPressEnd","onClick","deprecatedOnClick","isDisabled","otherProps","linkProps","role","tabIndex","undefined","focusableProps","useFocusable","pressProps","isPressed","usePress","domProps","filterDOMProps","labelable","interactionHandlers","mergeProps","e","console","warn"],"version":3,"file":"module.js.map"} |
@@ -1,1 +0,1 @@ | ||
| {"mappings":"A;A;AAiBA,gCAAiC,SAAQ,aAAa;IACpD,oCAAoC;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;A;A;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;IACE,kCAAkC;IAClC,SAAS,EAAE,eAAe,WAAW,CAAC,CAAC;IACvC,6CAA6C;IAC7C,SAAS,EAAE,OAAO,CAAA;CACnB;AAED;A;A;A;GAIG;AACH,wBAAwB,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,QAAQ,CAsCrF","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"],"sourcesContent":[null,null],"names":[],"version":3,"file":"types.d.ts.map"} | ||
| {"mappings":"A;A;AAkBA,gCAAiC,SAAQ,aAAa;IACpD,oCAAoC;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;A;A;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;IACE,kCAAkC;IAClC,SAAS,EAAE,eAAe,WAAW,CAAC,CAAC;IACvC,6CAA6C;IAC7C,SAAS,EAAE,OAAO,CAAA;CACnB;AAED;A;A;A;GAIG;AACH,wBAAwB,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,QAAQ,CAuCrF","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"],"sourcesContent":[null,null],"names":[],"version":3,"file":"types.d.ts.map"} |
+7
-6
| { | ||
| "name": "@react-aria/link", | ||
| "version": "3.0.0-nightly.1245+25c8f46f4", | ||
| "version": "3.0.0-nightly.1246+b49c14b74", | ||
| "description": "Spectrum UI components in React", | ||
@@ -21,6 +21,7 @@ "license": "Apache-2.0", | ||
| "@babel/runtime": "^7.6.2", | ||
| "@react-aria/interactions": "3.0.0-nightly.1245+25c8f46f4", | ||
| "@react-aria/utils": "3.0.0-nightly.1245+25c8f46f4", | ||
| "@react-types/link": "3.0.0-nightly.1245+25c8f46f4", | ||
| "@react-types/shared": "3.0.0-nightly.1245+25c8f46f4" | ||
| "@react-aria/focus": "3.0.0-nightly.1246+b49c14b74", | ||
| "@react-aria/interactions": "3.0.0-nightly.1246+b49c14b74", | ||
| "@react-aria/utils": "3.0.0-nightly.1246+b49c14b74", | ||
| "@react-types/link": "3.0.0-nightly.1246+b49c14b74", | ||
| "@react-types/shared": "3.0.0-nightly.1246+b49c14b74" | ||
| }, | ||
@@ -33,3 +34,3 @@ "peerDependencies": { | ||
| }, | ||
| "gitHead": "25c8f46f4bb49e95e9b52f6fa624f0a3a4e07035" | ||
| "gitHead": "b49c14b74a770d3dbc98d850a5c13552ad821f46" | ||
| } |
+4
-2
@@ -16,2 +16,3 @@ /* | ||
| import {HTMLAttributes, RefObject} from 'react'; | ||
| import {useFocusable} from '@react-aria/focus'; | ||
| import {usePress} from '@react-aria/interactions'; | ||
@@ -60,5 +61,6 @@ | ||
| } | ||
| let {focusableProps} = useFocusable(props, ref); | ||
| let {pressProps, isPressed} = usePress({onPress, onPressStart, onPressEnd, isDisabled, ref}); | ||
| let domProps = filterDOMProps(otherProps, {labelable: true}); | ||
| let interactionHandlers = mergeProps(focusableProps, pressProps); | ||
@@ -68,3 +70,3 @@ return { | ||
| linkProps: mergeProps(domProps, { | ||
| ...pressProps, | ||
| ...interactionHandlers, | ||
| ...linkProps, | ||
@@ -71,0 +73,0 @@ 'aria-disabled': isDisabled || undefined, |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
30824
4.54%243
6.58%7
16.67%