@south-paw/react-obfuscate-ts
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -176,15 +176,15 @@ 'use strict'; | ||
} | ||
}, [uri, onClick]); | ||
}, [humanInteraction, uri, onClick]); | ||
var handleOnFocus = React.useCallback(function (e) { | ||
onFocus(e); | ||
setHumanInteraction(true); | ||
}, []); | ||
}, [onFocus]); | ||
var handleOnMouseOver = React.useCallback(function (e) { | ||
onMouseOver(e); | ||
setHumanInteraction(true); | ||
}, []); | ||
}, [onMouseOver]); | ||
var handleOnContextMenu = React.useCallback(function (e) { | ||
onContextMenu(e); | ||
setHumanInteraction(true); | ||
}, []); | ||
}, [onContextMenu]); | ||
return React.createElement(Component, Object.assign({ | ||
@@ -191,0 +191,0 @@ style: componentStyle, |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("react"),t=(e=require("styled-components"))&&"object"==typeof e&&"default"in e?e.default:e;function r(){return(r=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}var o=function(){},i=function(e){return"string"==typeof e};function u(){var e,n,t=(e=[""],n||(n=e.slice(0)),e.raw=n,e);return u=function(){return t},t}var a=t("a")(u()),c=function(e){var t=e.email,u=e.tel,c=e.sms,l=e.href,s=e.children,f=e["aria-label"],d=void 0===f?"focus to reveal obfuscated content":f,v=e.obfuscateText,b=void 0===v?"obfuscated":v,m=e.style,p=e.onClick,h=void 0===p?o:p,y=e.onFocus,O=void 0===y?o:y,M=e.onMouseOver,C=void 0===M?o:M,g=e.onContextMenu,k=void 0===g?o:g,x=function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n.indexOf(t=i[r])>=0||(o[t]=e[t]);return o}(e,["email","tel","sms","href","children","aria-label","obfuscateText","style","onClick","onFocus","onMouseOver","onContextMenu"]),j=n.useState(!1),w=j[0],F=j[1],q=n.useMemo((function(){return r({},m,{unicodeBidi:"bidi-override",direction:w?"ltr":"rtl"})}),[m,w]),P=n.useMemo((function(){return s||(i(t)?t:i(u)?u:i(c)?c:i(l)?l:"")}),[s,t,u,c,l]),T=n.useMemo((function(){return function(e){var n=e.email,t=e.tel,r=e.sms,o=e.href,u=e.children;if(n){if(i(n))return"mailto:"+n;if(u)return"mailto:"+u}if(t){if(i(t))return"tel:"+t.replace(/\s/g,"");if(u)return"tel:"+u.replace(/\s/g,"")}if(r){if(i(r))return"sms:"+r.replace(/\s/g,"");if(u)return"sms:"+u.replace(/\s/g,"")}if(o)return o}({email:t,tel:u,sms:c,href:l,children:s})}),[t,u,c,l,s]),_=n.useMemo((function(){return w?T:b}),[w,T,b]),B=n.useCallback((function(e){h(e),!w&&T&&(window.location.href=T)}),[T,h]),E=n.useCallback((function(e){O(e),F(!0)}),[]),N=n.useCallback((function(e){C(e),F(!0)}),[]),S=n.useCallback((function(e){k(e),F(!0)}),[]);return n.createElement(a,Object.assign({style:q,href:T?_:void 0,"aria-label":w?void 0:d,onClick:B,onFocus:E,onMouseOver:N,onContextMenu:S},x),w?P:function(e){return e.split("").reverse().map((function(e){return"("===e?")":")"===e?"(":"["===e?"]":"]"===e?"[":"{"===e?"}":"}"===e?"{":"<"===e?">":">"===e?"<":e})).join("")}(P))};c.displayName="Obfuscate",exports.Obfuscate=c; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("react"),t=(e=require("styled-components"))&&"object"==typeof e&&"default"in e?e.default:e;function r(){return(r=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}var o=function(){},i=function(e){return"string"==typeof e};function u(){var e,n,t=(e=[""],n||(n=e.slice(0)),e.raw=n,e);return u=function(){return t},t}var a=t("a")(u()),c=function(e){var t=e.email,u=e.tel,c=e.sms,l=e.href,s=e.children,f=e["aria-label"],d=void 0===f?"focus to reveal obfuscated content":f,v=e.obfuscateText,b=void 0===v?"obfuscated":v,m=e.style,p=e.onClick,h=void 0===p?o:p,y=e.onFocus,O=void 0===y?o:y,M=e.onMouseOver,C=void 0===M?o:M,g=e.onContextMenu,k=void 0===g?o:g,x=function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n.indexOf(t=i[r])>=0||(o[t]=e[t]);return o}(e,["email","tel","sms","href","children","aria-label","obfuscateText","style","onClick","onFocus","onMouseOver","onContextMenu"]),j=n.useState(!1),w=j[0],F=j[1],q=n.useMemo((function(){return r({},m,{unicodeBidi:"bidi-override",direction:w?"ltr":"rtl"})}),[m,w]),P=n.useMemo((function(){return s||(i(t)?t:i(u)?u:i(c)?c:i(l)?l:"")}),[s,t,u,c,l]),T=n.useMemo((function(){return function(e){var n=e.email,t=e.tel,r=e.sms,o=e.href,u=e.children;if(n){if(i(n))return"mailto:"+n;if(u)return"mailto:"+u}if(t){if(i(t))return"tel:"+t.replace(/\s/g,"");if(u)return"tel:"+u.replace(/\s/g,"")}if(r){if(i(r))return"sms:"+r.replace(/\s/g,"");if(u)return"sms:"+u.replace(/\s/g,"")}if(o)return o}({email:t,tel:u,sms:c,href:l,children:s})}),[t,u,c,l,s]),_=n.useMemo((function(){return w?T:b}),[w,T,b]),B=n.useCallback((function(e){h(e),!w&&T&&(window.location.href=T)}),[w,T,h]),E=n.useCallback((function(e){O(e),F(!0)}),[O]),N=n.useCallback((function(e){C(e),F(!0)}),[C]),S=n.useCallback((function(e){k(e),F(!0)}),[k]);return n.createElement(a,Object.assign({style:q,href:T?_:void 0,"aria-label":w?void 0:d,onClick:B,onFocus:E,onMouseOver:N,onContextMenu:S},x),w?P:function(e){return e.split("").reverse().map((function(e){return"("===e?")":")"===e?"(":"["===e?"]":"]"===e?"[":"{"===e?"}":"}"===e?"{":"<"===e?">":">"===e?"<":e})).join("")}(P))};c.displayName="Obfuscate",exports.Obfuscate=c; | ||
//# sourceMappingURL=react-obfuscate-ts.cjs.production.min.js.map |
@@ -170,15 +170,15 @@ import { useState, useMemo, useCallback, createElement } from 'react'; | ||
} | ||
}, [uri, onClick]); | ||
}, [humanInteraction, uri, onClick]); | ||
var handleOnFocus = useCallback(function (e) { | ||
onFocus(e); | ||
setHumanInteraction(true); | ||
}, []); | ||
}, [onFocus]); | ||
var handleOnMouseOver = useCallback(function (e) { | ||
onMouseOver(e); | ||
setHumanInteraction(true); | ||
}, []); | ||
}, [onMouseOver]); | ||
var handleOnContextMenu = useCallback(function (e) { | ||
onContextMenu(e); | ||
setHumanInteraction(true); | ||
}, []); | ||
}, [onContextMenu]); | ||
return createElement(Component, Object.assign({ | ||
@@ -185,0 +185,0 @@ style: componentStyle, |
{ | ||
"name": "@south-paw/react-obfuscate-ts", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A React component to obfuscate contact links and text", | ||
@@ -40,36 +40,33 @@ "keywords": [ | ||
"lint": "eslint ./src", | ||
"test": "tsdx test --passWithNoTests", | ||
"prepublishOnly": "yarn clean && yarn build" | ||
"test": "tsdx test --passWithNoTests" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@babel/core": "^7.11.4", | ||
"@storybook/addon-actions": "^6.0.19", | ||
"@storybook/addon-docs": "^6.0.19", | ||
"@storybook/addon-knobs": "^6.0.19", | ||
"@storybook/react": "^6.0.19", | ||
"@testing-library/jest-dom": "^5.11.4", | ||
"@testing-library/react": "^10.4.9", | ||
"@types/react": "^16.9.48", | ||
"@types/react-dom": "^16.9.8", | ||
"@types/styled-components": "^5.1.2", | ||
"@typescript-eslint/eslint-plugin": "^3.10.1", | ||
"@typescript-eslint/parser": "^3.10.1", | ||
"eslint": "^7.7.0", | ||
"eslint-config-airbnb-typescript": "^9.0.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-import": "^2.22.0", | ||
"eslint-plugin-jest": "^23.20.0", | ||
"eslint-plugin-jsx-a11y": "^6.3.1", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"eslint-plugin-react": "^7.20.6", | ||
"eslint-plugin-react-hooks": "^4.1.0", | ||
"prettier": "^2.1.1", | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1", | ||
"@babel/core": "^7.12.10", | ||
"@storybook/addon-essentials": "^6.1.14", | ||
"@storybook/react": "^6.1.14", | ||
"@testing-library/jest-dom": "^5.11.9", | ||
"@testing-library/react": "^11.2.3", | ||
"@types/react": "^17.0.0", | ||
"@types/react-dom": "^17.0.0", | ||
"@types/styled-components": "^5.1.7", | ||
"@typescript-eslint/eslint-plugin": "^4.13.0", | ||
"@typescript-eslint/parser": "^4.13.0", | ||
"eslint": "^7.17.0", | ||
"eslint-config-airbnb-typescript": "^12.0.0", | ||
"eslint-config-prettier": "^7.1.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jest": "^24.1.3", | ||
"eslint-plugin-jsx-a11y": "^6.4.1", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"eslint-plugin-react": "^7.22.0", | ||
"eslint-plugin-react-hooks": "^4.2.0", | ||
"prettier": "^2.2.1", | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1", | ||
"rimraf": "^3.0.2", | ||
"styled-components": "^5.1.1", | ||
"tsdx": "^0.13.3", | ||
"tslib": "^2.0.1", | ||
"typescript": "^4.0.2" | ||
"styled-components": "^5.2.1", | ||
"tsdx": "^0.14.1", | ||
"tslib": "^2.1.0", | ||
"typescript": "^4.1.3" | ||
}, | ||
@@ -76,0 +73,0 @@ "peerDependencies": { |
@@ -6,2 +6,4 @@ # @south-paw/react-obfuscate-ts | ||
[![npm](https://img.shields.io/npm/v/@south-paw/react-obfuscate-ts.svg)](https://www.npmjs.com/package/@south-paw/react-obfuscate-ts) | ||
[![Dependencies](https://david-dm.org/south-paw/react-obfuscate-ts/status.svg)](https://david-dm.org/south-paw/react-obfuscate-ts) | ||
[![Dev Dependencies](https://david-dm.org/south-paw/react-obfuscate-ts/dev-status.svg)](https://david-dm.org/south-paw/react-obfuscate-ts?type=dev) | ||
@@ -13,3 +15,3 @@ ## Features | ||
- Out of the box `aria-label` for screen readers to identify the obfuscated element. | ||
- Supports the styled-components `as` prop for use with other Link components (such as your own UI libraries link). | ||
- Supports the styled-components `as` prop for use with other Link components (such as your own UI libraries link component). | ||
@@ -35,3 +37,3 @@ ## How it works | ||
I was inspired to create this package after using the [coston/react-obfuscate](https://github.com/coston/react-obfuscate) package for two years. After switching the majority of my own code bases to TypeScript, I was disapointed to see there was no `@types` package for this original version and that it wasn't reliably obfuscating in some of my usages of the component. I decided that I'd do a variant of that component with a new API, a few minor bug fixes and one that included types as well. | ||
I was inspired to create this package after using the [coston/react-obfuscate](https://github.com/coston/react-obfuscate) package for two years. After switching the majority of my own code bases to TypeScript, I was disappointed to see there was no `@types` package for this original version and that it wasn't reliably obfuscating in some of my usages of the component. I decided that I'd do a variant of that component with a new API, a few minor bug fixes and one that included types as well. | ||
@@ -38,0 +40,0 @@ ## Issues and Bugs |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
52901
27
44