@south-paw/react-obfuscate-ts
Advanced tools
Comparing version 0.0.1-alpha.1 to 0.0.1-alpha.2
@@ -54,3 +54,13 @@ 'use strict'; | ||
var reverse = function reverse(content) { | ||
return content.split('').reverse().join(''); | ||
return content.split('').reverse().map(function (s) { | ||
if (s === '(') return ')'; | ||
if (s === ')') return '('; | ||
if (s === '[') return ']'; | ||
if (s === ']') return '['; | ||
if (s === '{') return '}'; | ||
if (s === '}') return '{'; | ||
if (s === '<') return '>'; | ||
if (s === '>') return '<'; | ||
return s; | ||
}).join(''); | ||
}; | ||
@@ -82,7 +92,3 @@ var isString = function isString(s) { | ||
if (href) { | ||
if (isString(href)) return href; | ||
if (children) return children; | ||
} | ||
if (href) return href; | ||
return undefined; | ||
@@ -89,0 +95,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=require("styled-components"))&&"object"==typeof e&&"default"in e?e.default:e;function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var o=function(){},i=function(e){return"string"==typeof e};function u(){var e,t,n=(e=[""],t||(t=e.slice(0)),e.raw=t,e);return u=function(){return n},n}var a=n("a")(u()),l=function(e){var n=e.email,u=e.tel,l=e.sms,s=e.href,c=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,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t.indexOf(n=i[r])>=0||(o[n]=e[n]);return o}(e,["email","tel","sms","href","children","aria-label","obfuscateText","style","onClick","onFocus","onMouseOver","onContextMenu"]),j=t.useState(!1),w=j[0],F=j[1],q=t.useMemo((function(){return r({},m,{unicodeBidi:"bidi-override",direction:w?"ltr":"rtl"})}),[m,w]),P=t.useMemo((function(){return c||(i(n)?n:i(u)?u:i(l)?l:i(s)?s:"")}),[c,n,u,l,s]),T=t.useMemo((function(){return function(e){var t=e.email,n=e.tel,r=e.sms,o=e.href,u=e.children;if(t){if(i(t))return"mailto:"+t;if(u)return"mailto:"+u}if(n){if(i(n))return"tel:"+n.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){if(i(o))return o;if(u)return u}}({email:n,tel:u,sms:l,href:s,children:c})}),[n,u,l,s,c]),_=t.useMemo((function(){return w?T:b}),[w,T,b]),B=t.useCallback((function(e){h(e),!w&&T&&(window.location.href=T)}),[T,h]),E=t.useCallback((function(e){O(e),F(!0)}),[]),N=t.useCallback((function(e){C(e),F(!0)}),[]),S=t.useCallback((function(e){k(e),F(!0)}),[]);return t.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().join("")}(P))};l.displayName="Obfuscate",exports.Obfuscate=l; | ||
"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; | ||
//# sourceMappingURL=react-obfuscate-ts.cjs.production.min.js.map |
@@ -48,3 +48,13 @@ import { useState, useMemo, useCallback, createElement } from 'react'; | ||
var reverse = function reverse(content) { | ||
return content.split('').reverse().join(''); | ||
return content.split('').reverse().map(function (s) { | ||
if (s === '(') return ')'; | ||
if (s === ')') return '('; | ||
if (s === '[') return ']'; | ||
if (s === ']') return '['; | ||
if (s === '{') return '}'; | ||
if (s === '}') return '{'; | ||
if (s === '<') return '>'; | ||
if (s === '>') return '<'; | ||
return s; | ||
}).join(''); | ||
}; | ||
@@ -76,7 +86,3 @@ var isString = function isString(s) { | ||
if (href) { | ||
if (isString(href)) return href; | ||
if (children) return children; | ||
} | ||
if (href) return href; | ||
return undefined; | ||
@@ -83,0 +89,0 @@ }; |
{ | ||
"name": "@south-paw/react-obfuscate-ts", | ||
"version": "0.0.1-alpha.1", | ||
"version": "0.0.1-alpha.2", | ||
"description": "A React component to obfuscate your website's contact links", | ||
@@ -45,22 +45,24 @@ "keywords": [ | ||
"devDependencies": { | ||
"@babel/core": "^7.10.5", | ||
"@storybook/addon-actions": "^6.0.0-rc.14", | ||
"@storybook/addon-docs": "^6.0.0-rc.14", | ||
"@storybook/addon-knobs": "^6.0.0-rc.14", | ||
"@storybook/react": "^6.0.0-rc.14", | ||
"@types/react": "^16.9.43", | ||
"@babel/core": "^7.11.4", | ||
"@storybook/addon-actions": "^6.0.18", | ||
"@storybook/addon-docs": "^6.0.18", | ||
"@storybook/addon-knobs": "^6.0.18", | ||
"@storybook/react": "^6.0.18", | ||
"@testing-library/jest-dom": "^5.11.4", | ||
"@testing-library/react": "^10.4.9", | ||
"@types/react": "^16.9.47", | ||
"@types/react-dom": "^16.9.8", | ||
"@types/styled-components": "^5.1.1", | ||
"@typescript-eslint/eslint-plugin": "^3.6.1", | ||
"@typescript-eslint/parser": "^3.6.1", | ||
"eslint": "^7.4.0", | ||
"eslint-config-airbnb-typescript": "^8.0.2", | ||
"@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.18.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.3", | ||
"eslint-plugin-react-hooks": "^4.0.8", | ||
"prettier": "^2.0.5", | ||
"eslint-plugin-react": "^7.20.6", | ||
"eslint-plugin-react-hooks": "^4.1.0", | ||
"prettier": "^2.1.1", | ||
"react": "^16.13.1", | ||
@@ -70,9 +72,9 @@ "react-dom": "^16.13.1", | ||
"styled-components": "^5.1.1", | ||
"tsdx": "^0.13.2", | ||
"tslib": "^2.0.0", | ||
"typescript": "^3.9.6" | ||
"tsdx": "^0.13.3", | ||
"tslib": "^2.0.1", | ||
"typescript": "^4.0.2" | ||
}, | ||
"peerDependencies": { | ||
"react": ">=16.13.0", | ||
"styled-components": ">=5.1.0" | ||
"styled-components": ">=5.1.2" | ||
}, | ||
@@ -79,0 +81,0 @@ "publishConfig": { |
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
49574
14
411
29