Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-credit-cards-2

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-credit-cards-2 - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0-rc1

src/index.ts

2

dist/es/index.js

@@ -1,2 +0,2 @@

import e from"react";var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t={visa:{niceType:"Visa",type:"visa",patterns:[4],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}},mastercard:{niceType:"Mastercard",type:"mastercard",patterns:[[51,55],[2221,2229],[223,229],[23,26],[270,271],2720],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},"american-express":{niceType:"American Express",type:"american-express",patterns:[34,37],gaps:[4,10],lengths:[15],code:{name:"CID",size:4}},"diners-club":{niceType:"Diners Club",type:"diners-club",patterns:[[300,305],36,38,39],gaps:[4,10],lengths:[14,16,19],code:{name:"CVV",size:3}},discover:{niceType:"Discover",type:"discover",patterns:[6011,[644,649],65],gaps:[4,8,12],lengths:[16,19],code:{name:"CID",size:3}},jcb:{niceType:"JCB",type:"jcb",patterns:[2131,1800,[3528,3589]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVV",size:3}},unionpay:{niceType:"UnionPay",type:"unionpay",patterns:[620,[624,626],[62100,62182],[62184,62187],[62185,62197],[62200,62205],[622010,622999],622018,[622019,622999],[62207,62209],[622126,622925],[623,626],6270,6272,6276,[627700,627779],[627781,627799],[6282,6289],6291,6292,810,[8110,8131],[8132,8151],[8152,8163],[8164,8171]],gaps:[4,8,12],lengths:[14,15,16,17,18,19],code:{name:"CVN",size:3}},maestro:{niceType:"Maestro",type:"maestro",patterns:[493698,[5e5,504174],[504176,506698],[506779,508999],[56,59],63,67,6],gaps:[4,8,12],lengths:[12,13,14,15,16,17,18,19],code:{name:"CVC",size:3}},elo:{niceType:"Elo",type:"elo",patterns:[401178,401179,438935,457631,457632,431274,451416,457393,504175,[506699,506778],[509e3,509999],627780,636297,636368,[650031,650033],[650035,650051],[650405,650439],[650485,650538],[650541,650598],[650700,650718],[650720,650727],[650901,650978],[651652,651679],[655e3,655019],[655021,655058]],gaps:[4,8,12],lengths:[16],code:{name:"CVE",size:3}},mir:{niceType:"Mir",type:"mir",patterns:[[2200,2204]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVP2",size:3}},hiper:{niceType:"Hiper",type:"hiper",patterns:[637095,63737423,63743358,637568,637599,637609,637612],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},hipercard:{niceType:"Hipercard",type:"hipercard",patterns:[606282],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}}},n={},a={};Object.defineProperty(a,"__esModule",{value:!0}),a.clone=void 0,a.clone=function(e){return e?JSON.parse(JSON.stringify(e)):null};var s={};Object.defineProperty(s,"__esModule",{value:!0}),s.matches=void 0,s.matches=function(e,r){return Array.isArray(r)?function(e,r,t){var n=String(r).length,a=e.substr(0,n),s=parseInt(a,10);return r=parseInt(String(r).substr(0,a.length),10),t=parseInt(String(t).substr(0,a.length),10),s>=r&&s<=t}(e,r[0],r[1]):function(e,r){return(r=String(r)).substring(0,e.length)===e.substring(0,r.length)}(e,r)},Object.defineProperty(n,"__esModule",{value:!0}),n.addMatchingCardsToResults=void 0;var c=a,i=s;n.addMatchingCardsToResults=function(e,r,t){var n,a;for(n=0;n<r.patterns.length;n++){var s=r.patterns[n];if(i.matches(e,s)){var o=c.clone(r);a=Array.isArray(s)?String(s[0]).length:String(s).length,e.length>=a&&(o.matchStrength=a),t.push(o);break}}};var o={};Object.defineProperty(o,"__esModule",{value:!0}),o.isValidInputType=void 0,o.isValidInputType=function(e){return"string"==typeof e||e instanceof String};var l={};Object.defineProperty(l,"__esModule",{value:!0}),l.findBestMatch=void 0,l.findBestMatch=function(e){return function(e){var r=e.filter((function(e){return e.matchStrength})).length;return r>0&&r===e.length}(e)?e.reduce((function(e,r){return e?Number(e.matchStrength)<Number(r.matchStrength)?r:e:r})):null};var u=r&&r.__assign||function(){return u=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},u.apply(this,arguments)},d=t,p=n,m=o,f=l,v=a,g={},h={VISA:"visa",MASTERCARD:"mastercard",AMERICAN_EXPRESS:"american-express",DINERS_CLUB:"diners-club",DISCOVER:"discover",JCB:"jcb",UNIONPAY:"unionpay",MAESTRO:"maestro",ELO:"elo",MIR:"mir",HIPER:"hiper",HIPERCARD:"hipercard"},y=[h.VISA,h.MASTERCARD,h.AMERICAN_EXPRESS,h.DINERS_CLUB,h.DISCOVER,h.JCB,h.UNIONPAY,h.MAESTRO,h.ELO,h.MIR,h.HIPER,h.HIPERCARD],_=v.clone(y);function b(e){return g[e]||d[e]}function C(e,r){void 0===r&&(r=!1);var t=_.indexOf(e);if(!r&&-1===t)throw new Error('"'+e+'" is not a supported card type.');return t}function E(e){var r=[];if(!m.isValidInputType(e))return r;if(0===e.length)return _.map((function(e){return v.clone(b(e))}));_.forEach((function(t){var n=b(t);p.addMatchingCardsToResults(e,n,r)}));var t=f.findBestMatch(r);return t?[t]:r}E.getTypeInfo=function(e){return v.clone(b(e))},E.removeCard=function(e){var r=C(e);_.splice(r,1)},E.addCard=function(e){var r=C(e.type,!0);g[e.type]=e,-1===r&&_.push(e.type)},E.updateCard=function(e,r){var t=g[e]||d[e];if(!t)throw new Error('"'+e+"\" is not a recognized type. Use `addCard` instead.'");if(r.type&&t.type!==r.type)throw new Error("Cannot overwrite type parameter.");var n=v.clone(t);n=u(u({},n),r),g[n.type]=n},E.changeOrder=function(e,r){var t=C(e);_.splice(t,1),_.splice(r,0,e)},E.resetModifications=function(){_=v.clone(y),g={}},E.types=h;var S=E,N={niceType:"Dankort",type:"dankort",patterns:[5019],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},M={niceType:"Laser",type:"laser",patterns:[6706,6771,6709],gaps:[4,8,12],lengths:[16,19],code:{name:"CVV",size:3}},R={niceType:"Visa Electron",type:"visa-electron",patterns:[4026,417500,4405,4508,4844,49137],gaps:[4,8,12],lengths:[16],code:{name:"CVV",size:3}},T={validate:function(e){var r,t,n=String(e).replace(/[\s]/g,""),a=n.length,s=!1,c=0;if(!/^[0-9]+$/.test(n))return!1;for(var i=a;i>0;i--){if(r=parseInt(n.charAt(i-1)),s){switch(t=2*r){case 10:t=1;break;case 12:t=3;break;case 14:t=5;break;case 16:t=7;break;case 18:t=9}c+=t}else c+=r;s=!s}return 0!==c&&c%10==0}}.validate,I=function(e){var r=S(e.toString().trim().replace(" ",""));if(1===r.length){var t=r.shift();return(null==t?void 0:t.type)||"unknown"}return"unknown"},V=function(){return S.updateCard(S.types.MAESTRO,{patterns:[493698,[5e3,5018],[502e3,506698],[506779,508999],[56,59],63,67,6]}),S.updateCard(S.types.HIPERCARD,{patterns:[384100,384140,384160,606282,637095,637568]}),S.addCard(N),S.addCard(M),S.addCard(R),Object.values(S.types).concat(["dankort","laser","visa-electron"])},A={amex:["amex","americanexpress","american-express"],dinersclub:["diners","dinersclub","diners-club"],visaelectron:["visaelectron","visa-electron"]};function O(r){var t=r.acceptedCards,n=void 0===t?[]:t,a=r.number,s=r.issuer,c=r.preview,i=void 0!==c&&c,o=r.expiry,l=r.cvc,u=r.focused,d=r.locale,p=void 0===d?{valid:"valid thru"}:d,m=r.name,f=r.placeholders,v=void 0===f?{name:"YOUR NAME HERE"}:f,g=r.callback,h=e.useState(V()),y=h[0],_=h[1],b=e.useMemo((function(){return(null==n?void 0:n.length)?y.filter((function(e){return n.includes(e)})):y}),[n,y]),C=e.useMemo((function(){var e="unknown";if(a){var r=I(a);b.includes(r)&&(e=r)}var t=16;return A.amex.includes(e)?t=15:(null==A?void 0:A.dinersclub.includes(e))?t=14:["hipercard","mastercard","visa"].includes(e)&&(t=19),{issuer:e,maxLength:t}}),[a,b]),E=e.useMemo((function(){return i&&s?s.toLowerCase():C.issuer}),[C.issuer,s,i]),S=e.useMemo((function(){var e=i?19:C.maxLength,r="number"==typeof a?a.toString():String(a).replace(/[A-Za-z]| /g,"");for(isNaN(parseInt(r,10))&&!i&&(r=""),e>16&&(e=r.length<=16?16:e),r.length>e&&(r=r.slice(0,e));r.length<e;)r+="•";if(A.amex.includes(E)||A.dinersclub.includes(E)){var t=[0,4,10],n=[4,6,5];r="".concat(r.substr(t[0],n[0])," ").concat(r.substr(t[1],n[1])," ").concat(r.substr(t[2],n[2]))}else if(r.length>16){t=[0,4,8,12],n=[4,7];r="".concat(r.substr(t[0],n[0])," ").concat(r.substr(t[1],n[0])," ").concat(r.substr(t[2],n[0])," ").concat(r.substr(t[3],n[1]))}else for(var s=1;s<e/4;s++){var c=4*s+(s-1);r="".concat(r.slice(0,c)," ").concat(r.slice(c))}return r}),[C.maxLength,E,a,i]),N=e.useMemo((function(){var e,r="number"==typeof o?o.toString():o,t="",n="";for(r.includes("/")?(t=(e=r.split("/"))[0],n=e[1]):r.length&&(t=r.substr(0,2),n=r.substr(2,6));t.length<2;)t+="•";for(n.length>2&&(n=n.substr(2,4));n.length<2;)n+="•";return"".concat(t,"/").concat(n)}),[o]),M=e.useCallback((function(e){if(e.length)_(y.filter((function(r){return e.includes(r)})));else{var r=V();_(r)}}),[y]);return e.useEffect((function(){S!==a&&"function"==typeof g&&g(C,T(String(a))),V().toString()!==y.toString()&&M(n)}),[n,g,C,S,M,a,y]),e.createElement("div",{key:"Cards",className:"rccs"},e.createElement("div",{className:["rccs__card","rccs__card--".concat(E),"cvc"===u&&"american-express"!==E?"rccs__card--flipped":""].join(" ").trim()},e.createElement("div",{className:"rccs__card--front"},e.createElement("div",{className:"rccs__card__background"}),e.createElement("div",{className:"rccs__issuer"}),e.createElement("div",{className:["rccs__cvc__front","cvc"===u?"rccs--focused":""].join(" ").trim()},l),e.createElement("div",{className:["rccs__number",S.replace(/ /g,"").length>16?"rccs__number--large":"","number"===u?"rccs--focused":"","•"!==S.substr(0,1)?"rccs--filled":""].join(" ").trim()},S),e.createElement("div",{className:["rccs__name","name"===u?"rccs--focused":"",m?"rccs--filled":""].join(" ").trim()},m||v.name),e.createElement("div",{className:["rccs__expiry","expiry"===u?"rccs--focused":"","•"!==N.substr(0,1)?"rccs--filled":""].join(" ").trim()},e.createElement("div",{className:"rccs__expiry__valid"},p.valid),e.createElement("div",{className:"rccs__expiry__value"},N)),e.createElement("div",{className:"rccs__chip"})),e.createElement("div",{className:"rccs__card--back"},e.createElement("div",{className:"rccs__card__background"}),e.createElement("div",{className:"rccs__stripe"}),e.createElement("div",{className:"rccs__signature"}),e.createElement("div",{className:["rccs__cvc","cvc"===u?"rccs--focused":""].join(" ").trim()},l),e.createElement("div",{className:"rccs__issuer"}))))}export{O as default};
import e from"react";var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t={visa:{niceType:"Visa",type:"visa",patterns:[4],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}},mastercard:{niceType:"Mastercard",type:"mastercard",patterns:[[51,55],[2221,2229],[223,229],[23,26],[270,271],2720],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},"american-express":{niceType:"American Express",type:"american-express",patterns:[34,37],gaps:[4,10],lengths:[15],code:{name:"CID",size:4}},"diners-club":{niceType:"Diners Club",type:"diners-club",patterns:[[300,305],36,38,39],gaps:[4,10],lengths:[14,16,19],code:{name:"CVV",size:3}},discover:{niceType:"Discover",type:"discover",patterns:[6011,[644,649],65],gaps:[4,8,12],lengths:[16,19],code:{name:"CID",size:3}},jcb:{niceType:"JCB",type:"jcb",patterns:[2131,1800,[3528,3589]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVV",size:3}},unionpay:{niceType:"UnionPay",type:"unionpay",patterns:[620,[624,626],[62100,62182],[62184,62187],[62185,62197],[62200,62205],[622010,622999],622018,[622019,622999],[62207,62209],[622126,622925],[623,626],6270,6272,6276,[627700,627779],[627781,627799],[6282,6289],6291,6292,810,[8110,8131],[8132,8151],[8152,8163],[8164,8171]],gaps:[4,8,12],lengths:[14,15,16,17,18,19],code:{name:"CVN",size:3}},maestro:{niceType:"Maestro",type:"maestro",patterns:[493698,[5e5,504174],[504176,506698],[506779,508999],[56,59],63,67,6],gaps:[4,8,12],lengths:[12,13,14,15,16,17,18,19],code:{name:"CVC",size:3}},elo:{niceType:"Elo",type:"elo",patterns:[401178,401179,438935,457631,457632,431274,451416,457393,504175,[506699,506778],[509e3,509999],627780,636297,636368,[650031,650033],[650035,650051],[650405,650439],[650485,650538],[650541,650598],[650700,650718],[650720,650727],[650901,650978],[651652,651679],[655e3,655019],[655021,655058]],gaps:[4,8,12],lengths:[16],code:{name:"CVE",size:3}},mir:{niceType:"Mir",type:"mir",patterns:[[2200,2204]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVP2",size:3}},hiper:{niceType:"Hiper",type:"hiper",patterns:[637095,63737423,63743358,637568,637599,637609,637612],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},hipercard:{niceType:"Hipercard",type:"hipercard",patterns:[606282],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}}},n={},a={};Object.defineProperty(a,"__esModule",{value:!0}),a.clone=void 0,a.clone=function(e){return e?JSON.parse(JSON.stringify(e)):null};var s={};Object.defineProperty(s,"__esModule",{value:!0}),s.matches=void 0,s.matches=function(e,r){return Array.isArray(r)?function(e,r,t){var n=String(r).length,a=e.substr(0,n),s=parseInt(a,10);return r=parseInt(String(r).substr(0,a.length),10),t=parseInt(String(t).substr(0,a.length),10),s>=r&&s<=t}(e,r[0],r[1]):function(e,r){return(r=String(r)).substring(0,e.length)===e.substring(0,r.length)}(e,r)},Object.defineProperty(n,"__esModule",{value:!0}),n.addMatchingCardsToResults=void 0;var c=a,i=s;n.addMatchingCardsToResults=function(e,r,t){var n,a;for(n=0;n<r.patterns.length;n++){var s=r.patterns[n];if(i.matches(e,s)){var o=c.clone(r);a=Array.isArray(s)?String(s[0]).length:String(s).length,e.length>=a&&(o.matchStrength=a),t.push(o);break}}};var o={};Object.defineProperty(o,"__esModule",{value:!0}),o.isValidInputType=void 0,o.isValidInputType=function(e){return"string"==typeof e||e instanceof String};var l={};Object.defineProperty(l,"__esModule",{value:!0}),l.findBestMatch=void 0,l.findBestMatch=function(e){return function(e){var r=e.filter((function(e){return e.matchStrength})).length;return r>0&&r===e.length}(e)?e.reduce((function(e,r){return e?Number(e.matchStrength)<Number(r.matchStrength)?r:e:r})):null};var d=r&&r.__assign||function(){return d=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},d.apply(this,arguments)},u=t,p=n,m=o,f=l,v=a,g={},h={VISA:"visa",MASTERCARD:"mastercard",AMERICAN_EXPRESS:"american-express",DINERS_CLUB:"diners-club",DISCOVER:"discover",JCB:"jcb",UNIONPAY:"unionpay",MAESTRO:"maestro",ELO:"elo",MIR:"mir",HIPER:"hiper",HIPERCARD:"hipercard"},y=[h.VISA,h.MASTERCARD,h.AMERICAN_EXPRESS,h.DINERS_CLUB,h.DISCOVER,h.JCB,h.UNIONPAY,h.MAESTRO,h.ELO,h.MIR,h.HIPER,h.HIPERCARD],_=v.clone(y);function b(e){return g[e]||u[e]}function C(e,r){void 0===r&&(r=!1);var t=_.indexOf(e);if(!r&&-1===t)throw new Error('"'+e+'" is not a supported card type.');return t}function E(e){var r=[];if(!m.isValidInputType(e))return r;if(0===e.length)return _.map((function(e){return v.clone(b(e))}));_.forEach((function(t){var n=b(t);p.addMatchingCardsToResults(e,n,r)}));var t=f.findBestMatch(r);return t?[t]:r}E.getTypeInfo=function(e){return v.clone(b(e))},E.removeCard=function(e){var r=C(e);_.splice(r,1)},E.addCard=function(e){var r=C(e.type,!0);g[e.type]=e,-1===r&&_.push(e.type)},E.updateCard=function(e,r){var t=g[e]||u[e];if(!t)throw new Error('"'+e+"\" is not a recognized type. Use `addCard` instead.'");if(r.type&&t.type!==r.type)throw new Error("Cannot overwrite type parameter.");var n=v.clone(t);n=d(d({},n),r),g[n.type]=n},E.changeOrder=function(e,r){var t=C(e);_.splice(t,1),_.splice(r,0,e)},E.resetModifications=function(){_=v.clone(y),g={}},E.types=h;var S=E,N={niceType:"Dankort",type:"dankort",patterns:[5019],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},M={niceType:"Laser",type:"laser",patterns:[6706,6771,6709],gaps:[4,8,12],lengths:[16,19],code:{name:"CVV",size:3}},R={niceType:"Visa Electron",type:"visa-electron",patterns:[4026,417500,4405,4508,4844,49137],gaps:[4,8,12],lengths:[16],code:{name:"CVV",size:3}},T={validate:function(e){var r,t,n=String(e).replace(/[\s]/g,""),a=n.length,s=!1,c=0;if(!/^[0-9]+$/.test(n))return!1;for(var i=a;i>0;i--){if(r=parseInt(n.charAt(i-1)),s){switch(t=2*r){case 10:t=1;break;case 12:t=3;break;case 14:t=5;break;case 16:t=7;break;case 18:t=9}c+=t}else c+=r;s=!s}return 0!==c&&c%10==0}}.validate,I=function(e){var r=S(e.toString().trim().replace(" ",""));if(1===r.length){var t=r.shift();return(null==t?void 0:t.type)||"unknown"}return"unknown"},V=function(){return S.updateCard(S.types.MAESTRO,{patterns:[493698,[5e3,5018],[502e3,506698],[506779,508999],[56,59],63,67,6]}),S.updateCard(S.types.HIPERCARD,{patterns:[384100,384140,384160,606282,637095,637568]}),S.addCard(N),S.addCard(M),S.addCard(R),Object.values(S.types).concat(["dankort","laser","visa-electron"])},A={amex:["amex","americanexpress","american-express"],dinersclub:["diners","dinersclub","diners-club"],visaelectron:["visaelectron","visa-electron"]};function O(r){var t=r.acceptedCards,n=void 0===t?[]:t,a=r.number,s=r.issuer,c=r.preview,i=void 0!==c&&c,o=r.expiry,l=r.cvc,d=r.focused,u=r.locale,p=void 0===u?{valid:"valid thru"}:u,m=r.name,f=r.placeholders,v=void 0===f?{name:"YOUR NAME HERE"}:f,g=r.callback,h=e.useState(V()),y=h[0],_=h[1],b=e.useMemo((function(){return(null==n?void 0:n.length)?y.filter((function(e){return n.includes(e)})):y}),[n,y]),C=e.useMemo((function(){var e="unknown";if(a){var r=I(a);b.includes(r)&&(e=r)}var t=16;return A.amex.includes(e)?t=15:(null==A?void 0:A.dinersclub.includes(e))?t=14:["hipercard","mastercard","visa"].includes(e)&&(t=19),{issuer:e,maxLength:t}}),[a,b]),E=e.useMemo((function(){return i&&s?s.toLowerCase():C.issuer}),[C.issuer,s,i]),S=e.useMemo((function(){var e=i?19:C.maxLength,r="number"==typeof a?a.toString():String(a).replace(/[A-Za-z]| /g,"");for(isNaN(parseInt(r,10))&&!i&&(r=""),e>16&&(e=r.length<=16?16:e),r.length>e&&(r=r.slice(0,e));r.length<e;)r+="•";if(A.amex.includes(E)||A.dinersclub.includes(E)){var t=[0,4,10],n=[4,6,5];r="".concat(r.substr(t[0],n[0])," ").concat(r.substr(t[1],n[1])," ").concat(r.substr(t[2],n[2]))}else if(r.length>16){t=[0,4,8,12],n=[4,7];r="".concat(r.substr(t[0],n[0])," ").concat(r.substr(t[1],n[0])," ").concat(r.substr(t[2],n[0])," ").concat(r.substr(t[3],n[1]))}else for(var s=1;s<e/4;s++){var c=4*s+(s-1);r="".concat(r.slice(0,c)," ").concat(r.slice(c))}return r}),[C.maxLength,E,a,i]),N=e.useMemo((function(){var e,r="number"==typeof o?o.toString():o,t="",n="";for(r.includes("/")?(t=(e=r.split("/"))[0],n=e[1]):r.length&&(t=r.substr(0,2),n=r.substr(2,6));t.length<2;)t+="•";for(n.length>2&&(n=n.substr(2,4));n.length<2;)n+="•";return"".concat(t,"/").concat(n)}),[o]),M=e.useCallback((function(e){if(e.length)_(y.filter((function(r){return e.includes(r)})));else{var r=V();_(r)}}),[y]);return e.useEffect((function(){S!==a&&"function"==typeof g&&g(C,T(String(a))),V().toString()!==y.toString()&&M(n)}),[n,g,C,S,M,a,y]),e.createElement("div",{key:"Cards",className:"rccs","data-testid":"rccs"},e.createElement("div",{"data-testid":"rccs__card",className:["rccs__card","rccs__card--".concat(E),"cvc"===d&&"american-express"!==E?"rccs__card--flipped":""].join(" ").trim()},e.createElement("div",{className:"rccs__card--front"},e.createElement("div",{className:"rccs__card__background"}),e.createElement("div",{className:"rccs__issuer"}),e.createElement("div",{className:["rccs__cvc__front","cvc"===d?"rccs--focused":""].join(" ").trim()},l),e.createElement("div",{className:["rccs__number",S.replace(/ /g,"").length>16?"rccs__number--large":"","number"===d?"rccs--focused":"","•"!==S.substr(0,1)?"rccs--filled":""].join(" ").trim()},S),e.createElement("div",{className:["rccs__name","name"===d?"rccs--focused":"",m?"rccs--filled":""].join(" ").trim()},m||v.name),e.createElement("div",{className:["rccs__expiry","expiry"===d?"rccs--focused":"","•"!==N.substr(0,1)?"rccs--filled":""].join(" ").trim()},e.createElement("div",{className:"rccs__expiry__valid"},p.valid),e.createElement("div",{className:"rccs__expiry__value"},N)),e.createElement("div",{className:"rccs__chip"})),e.createElement("div",{className:"rccs__card--back"},e.createElement("div",{className:"rccs__card__background"}),e.createElement("div",{className:"rccs__stripe"}),e.createElement("div",{className:"rccs__signature"}),e.createElement("div",{className:["rccs__cvc","cvc"===d?"rccs--focused":""].join(" ").trim()},l),e.createElement("div",{className:"rccs__issuer"}))))}export{O as default};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,1 @@

/// <reference types="react" />
export interface CallbackArgument {

@@ -3,0 +2,0 @@ issuer: string;

@@ -1,2 +0,1 @@

/// <reference types="react" />
interface CallbackArgument {

@@ -3,0 +2,0 @@ issuer: string;

@@ -1,2 +0,2 @@

"use strict";var e=require("react"),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t={visa:{niceType:"Visa",type:"visa",patterns:[4],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}},mastercard:{niceType:"Mastercard",type:"mastercard",patterns:[[51,55],[2221,2229],[223,229],[23,26],[270,271],2720],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},"american-express":{niceType:"American Express",type:"american-express",patterns:[34,37],gaps:[4,10],lengths:[15],code:{name:"CID",size:4}},"diners-club":{niceType:"Diners Club",type:"diners-club",patterns:[[300,305],36,38,39],gaps:[4,10],lengths:[14,16,19],code:{name:"CVV",size:3}},discover:{niceType:"Discover",type:"discover",patterns:[6011,[644,649],65],gaps:[4,8,12],lengths:[16,19],code:{name:"CID",size:3}},jcb:{niceType:"JCB",type:"jcb",patterns:[2131,1800,[3528,3589]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVV",size:3}},unionpay:{niceType:"UnionPay",type:"unionpay",patterns:[620,[624,626],[62100,62182],[62184,62187],[62185,62197],[62200,62205],[622010,622999],622018,[622019,622999],[62207,62209],[622126,622925],[623,626],6270,6272,6276,[627700,627779],[627781,627799],[6282,6289],6291,6292,810,[8110,8131],[8132,8151],[8152,8163],[8164,8171]],gaps:[4,8,12],lengths:[14,15,16,17,18,19],code:{name:"CVN",size:3}},maestro:{niceType:"Maestro",type:"maestro",patterns:[493698,[5e5,504174],[504176,506698],[506779,508999],[56,59],63,67,6],gaps:[4,8,12],lengths:[12,13,14,15,16,17,18,19],code:{name:"CVC",size:3}},elo:{niceType:"Elo",type:"elo",patterns:[401178,401179,438935,457631,457632,431274,451416,457393,504175,[506699,506778],[509e3,509999],627780,636297,636368,[650031,650033],[650035,650051],[650405,650439],[650485,650538],[650541,650598],[650700,650718],[650720,650727],[650901,650978],[651652,651679],[655e3,655019],[655021,655058]],gaps:[4,8,12],lengths:[16],code:{name:"CVE",size:3}},mir:{niceType:"Mir",type:"mir",patterns:[[2200,2204]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVP2",size:3}},hiper:{niceType:"Hiper",type:"hiper",patterns:[637095,63737423,63743358,637568,637599,637609,637612],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},hipercard:{niceType:"Hipercard",type:"hipercard",patterns:[606282],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}}},n={},a={};Object.defineProperty(a,"__esModule",{value:!0}),a.clone=void 0,a.clone=function(e){return e?JSON.parse(JSON.stringify(e)):null};var s={};Object.defineProperty(s,"__esModule",{value:!0}),s.matches=void 0,s.matches=function(e,r){return Array.isArray(r)?function(e,r,t){var n=String(r).length,a=e.substr(0,n),s=parseInt(a,10);return r=parseInt(String(r).substr(0,a.length),10),t=parseInt(String(t).substr(0,a.length),10),s>=r&&s<=t}(e,r[0],r[1]):function(e,r){return(r=String(r)).substring(0,e.length)===e.substring(0,r.length)}(e,r)},Object.defineProperty(n,"__esModule",{value:!0}),n.addMatchingCardsToResults=void 0;var c=a,i=s;n.addMatchingCardsToResults=function(e,r,t){var n,a;for(n=0;n<r.patterns.length;n++){var s=r.patterns[n];if(i.matches(e,s)){var o=c.clone(r);a=Array.isArray(s)?String(s[0]).length:String(s).length,e.length>=a&&(o.matchStrength=a),t.push(o);break}}};var o={};Object.defineProperty(o,"__esModule",{value:!0}),o.isValidInputType=void 0,o.isValidInputType=function(e){return"string"==typeof e||e instanceof String};var l={};Object.defineProperty(l,"__esModule",{value:!0}),l.findBestMatch=void 0,l.findBestMatch=function(e){return function(e){var r=e.filter((function(e){return e.matchStrength})).length;return r>0&&r===e.length}(e)?e.reduce((function(e,r){return e?Number(e.matchStrength)<Number(r.matchStrength)?r:e:r})):null};var u=r&&r.__assign||function(){return u=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},u.apply(this,arguments)},d=t,p=n,m=o,f=l,v=a,g={},h={VISA:"visa",MASTERCARD:"mastercard",AMERICAN_EXPRESS:"american-express",DINERS_CLUB:"diners-club",DISCOVER:"discover",JCB:"jcb",UNIONPAY:"unionpay",MAESTRO:"maestro",ELO:"elo",MIR:"mir",HIPER:"hiper",HIPERCARD:"hipercard"},y=[h.VISA,h.MASTERCARD,h.AMERICAN_EXPRESS,h.DINERS_CLUB,h.DISCOVER,h.JCB,h.UNIONPAY,h.MAESTRO,h.ELO,h.MIR,h.HIPER,h.HIPERCARD],_=v.clone(y);function b(e){return g[e]||d[e]}function C(e,r){void 0===r&&(r=!1);var t=_.indexOf(e);if(!r&&-1===t)throw new Error('"'+e+'" is not a supported card type.');return t}function E(e){var r=[];if(!m.isValidInputType(e))return r;if(0===e.length)return _.map((function(e){return v.clone(b(e))}));_.forEach((function(t){var n=b(t);p.addMatchingCardsToResults(e,n,r)}));var t=f.findBestMatch(r);return t?[t]:r}E.getTypeInfo=function(e){return v.clone(b(e))},E.removeCard=function(e){var r=C(e);_.splice(r,1)},E.addCard=function(e){var r=C(e.type,!0);g[e.type]=e,-1===r&&_.push(e.type)},E.updateCard=function(e,r){var t=g[e]||d[e];if(!t)throw new Error('"'+e+"\" is not a recognized type. Use `addCard` instead.'");if(r.type&&t.type!==r.type)throw new Error("Cannot overwrite type parameter.");var n=v.clone(t);n=u(u({},n),r),g[n.type]=n},E.changeOrder=function(e,r){var t=C(e);_.splice(t,1),_.splice(r,0,e)},E.resetModifications=function(){_=v.clone(y),g={}},E.types=h;var S=E,N={niceType:"Dankort",type:"dankort",patterns:[5019],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},M={niceType:"Laser",type:"laser",patterns:[6706,6771,6709],gaps:[4,8,12],lengths:[16,19],code:{name:"CVV",size:3}},R={niceType:"Visa Electron",type:"visa-electron",patterns:[4026,417500,4405,4508,4844,49137],gaps:[4,8,12],lengths:[16],code:{name:"CVV",size:3}},T={validate:function(e){var r,t,n=String(e).replace(/[\s]/g,""),a=n.length,s=!1,c=0;if(!/^[0-9]+$/.test(n))return!1;for(var i=a;i>0;i--){if(r=parseInt(n.charAt(i-1)),s){switch(t=2*r){case 10:t=1;break;case 12:t=3;break;case 14:t=5;break;case 16:t=7;break;case 18:t=9}c+=t}else c+=r;s=!s}return 0!==c&&c%10==0}}.validate,I=function(e){var r=S(e.toString().trim().replace(" ",""));if(1===r.length){var t=r.shift();return(null==t?void 0:t.type)||"unknown"}return"unknown"},V=function(){return S.updateCard(S.types.MAESTRO,{patterns:[493698,[5e3,5018],[502e3,506698],[506779,508999],[56,59],63,67,6]}),S.updateCard(S.types.HIPERCARD,{patterns:[384100,384140,384160,606282,637095,637568]}),S.addCard(N),S.addCard(M),S.addCard(R),Object.values(S.types).concat(["dankort","laser","visa-electron"])},A={amex:["amex","americanexpress","american-express"],dinersclub:["diners","dinersclub","diners-club"],visaelectron:["visaelectron","visa-electron"]};module.exports=function(r){var t=r.acceptedCards,n=void 0===t?[]:t,a=r.number,s=r.issuer,c=r.preview,i=void 0!==c&&c,o=r.expiry,l=r.cvc,u=r.focused,d=r.locale,p=void 0===d?{valid:"valid thru"}:d,m=r.name,f=r.placeholders,v=void 0===f?{name:"YOUR NAME HERE"}:f,g=r.callback,h=e.useState(V()),y=h[0],_=h[1],b=e.useMemo((function(){return(null==n?void 0:n.length)?y.filter((function(e){return n.includes(e)})):y}),[n,y]),C=e.useMemo((function(){var e="unknown";if(a){var r=I(a);b.includes(r)&&(e=r)}var t=16;return A.amex.includes(e)?t=15:(null==A?void 0:A.dinersclub.includes(e))?t=14:["hipercard","mastercard","visa"].includes(e)&&(t=19),{issuer:e,maxLength:t}}),[a,b]),E=e.useMemo((function(){return i&&s?s.toLowerCase():C.issuer}),[C.issuer,s,i]),S=e.useMemo((function(){var e=i?19:C.maxLength,r="number"==typeof a?a.toString():String(a).replace(/[A-Za-z]| /g,"");for(isNaN(parseInt(r,10))&&!i&&(r=""),e>16&&(e=r.length<=16?16:e),r.length>e&&(r=r.slice(0,e));r.length<e;)r+="•";if(A.amex.includes(E)||A.dinersclub.includes(E)){var t=[0,4,10],n=[4,6,5];r="".concat(r.substr(t[0],n[0])," ").concat(r.substr(t[1],n[1])," ").concat(r.substr(t[2],n[2]))}else if(r.length>16){t=[0,4,8,12],n=[4,7];r="".concat(r.substr(t[0],n[0])," ").concat(r.substr(t[1],n[0])," ").concat(r.substr(t[2],n[0])," ").concat(r.substr(t[3],n[1]))}else for(var s=1;s<e/4;s++){var c=4*s+(s-1);r="".concat(r.slice(0,c)," ").concat(r.slice(c))}return r}),[C.maxLength,E,a,i]),N=e.useMemo((function(){var e,r="number"==typeof o?o.toString():o,t="",n="";for(r.includes("/")?(t=(e=r.split("/"))[0],n=e[1]):r.length&&(t=r.substr(0,2),n=r.substr(2,6));t.length<2;)t+="•";for(n.length>2&&(n=n.substr(2,4));n.length<2;)n+="•";return"".concat(t,"/").concat(n)}),[o]),M=e.useCallback((function(e){if(e.length)_(y.filter((function(r){return e.includes(r)})));else{var r=V();_(r)}}),[y]);return e.useEffect((function(){S!==a&&"function"==typeof g&&g(C,T(String(a))),V().toString()!==y.toString()&&M(n)}),[n,g,C,S,M,a,y]),e.createElement("div",{key:"Cards",className:"rccs"},e.createElement("div",{className:["rccs__card","rccs__card--".concat(E),"cvc"===u&&"american-express"!==E?"rccs__card--flipped":""].join(" ").trim()},e.createElement("div",{className:"rccs__card--front"},e.createElement("div",{className:"rccs__card__background"}),e.createElement("div",{className:"rccs__issuer"}),e.createElement("div",{className:["rccs__cvc__front","cvc"===u?"rccs--focused":""].join(" ").trim()},l),e.createElement("div",{className:["rccs__number",S.replace(/ /g,"").length>16?"rccs__number--large":"","number"===u?"rccs--focused":"","•"!==S.substr(0,1)?"rccs--filled":""].join(" ").trim()},S),e.createElement("div",{className:["rccs__name","name"===u?"rccs--focused":"",m?"rccs--filled":""].join(" ").trim()},m||v.name),e.createElement("div",{className:["rccs__expiry","expiry"===u?"rccs--focused":"","•"!==N.substr(0,1)?"rccs--filled":""].join(" ").trim()},e.createElement("div",{className:"rccs__expiry__valid"},p.valid),e.createElement("div",{className:"rccs__expiry__value"},N)),e.createElement("div",{className:"rccs__chip"})),e.createElement("div",{className:"rccs__card--back"},e.createElement("div",{className:"rccs__card__background"}),e.createElement("div",{className:"rccs__stripe"}),e.createElement("div",{className:"rccs__signature"}),e.createElement("div",{className:["rccs__cvc","cvc"===u?"rccs--focused":""].join(" ").trim()},l),e.createElement("div",{className:"rccs__issuer"}))))};
"use strict";var e=require("react"),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t={visa:{niceType:"Visa",type:"visa",patterns:[4],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}},mastercard:{niceType:"Mastercard",type:"mastercard",patterns:[[51,55],[2221,2229],[223,229],[23,26],[270,271],2720],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},"american-express":{niceType:"American Express",type:"american-express",patterns:[34,37],gaps:[4,10],lengths:[15],code:{name:"CID",size:4}},"diners-club":{niceType:"Diners Club",type:"diners-club",patterns:[[300,305],36,38,39],gaps:[4,10],lengths:[14,16,19],code:{name:"CVV",size:3}},discover:{niceType:"Discover",type:"discover",patterns:[6011,[644,649],65],gaps:[4,8,12],lengths:[16,19],code:{name:"CID",size:3}},jcb:{niceType:"JCB",type:"jcb",patterns:[2131,1800,[3528,3589]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVV",size:3}},unionpay:{niceType:"UnionPay",type:"unionpay",patterns:[620,[624,626],[62100,62182],[62184,62187],[62185,62197],[62200,62205],[622010,622999],622018,[622019,622999],[62207,62209],[622126,622925],[623,626],6270,6272,6276,[627700,627779],[627781,627799],[6282,6289],6291,6292,810,[8110,8131],[8132,8151],[8152,8163],[8164,8171]],gaps:[4,8,12],lengths:[14,15,16,17,18,19],code:{name:"CVN",size:3}},maestro:{niceType:"Maestro",type:"maestro",patterns:[493698,[5e5,504174],[504176,506698],[506779,508999],[56,59],63,67,6],gaps:[4,8,12],lengths:[12,13,14,15,16,17,18,19],code:{name:"CVC",size:3}},elo:{niceType:"Elo",type:"elo",patterns:[401178,401179,438935,457631,457632,431274,451416,457393,504175,[506699,506778],[509e3,509999],627780,636297,636368,[650031,650033],[650035,650051],[650405,650439],[650485,650538],[650541,650598],[650700,650718],[650720,650727],[650901,650978],[651652,651679],[655e3,655019],[655021,655058]],gaps:[4,8,12],lengths:[16],code:{name:"CVE",size:3}},mir:{niceType:"Mir",type:"mir",patterns:[[2200,2204]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVP2",size:3}},hiper:{niceType:"Hiper",type:"hiper",patterns:[637095,63737423,63743358,637568,637599,637609,637612],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},hipercard:{niceType:"Hipercard",type:"hipercard",patterns:[606282],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}}},n={},a={};Object.defineProperty(a,"__esModule",{value:!0}),a.clone=void 0,a.clone=function(e){return e?JSON.parse(JSON.stringify(e)):null};var s={};Object.defineProperty(s,"__esModule",{value:!0}),s.matches=void 0,s.matches=function(e,r){return Array.isArray(r)?function(e,r,t){var n=String(r).length,a=e.substr(0,n),s=parseInt(a,10);return r=parseInt(String(r).substr(0,a.length),10),t=parseInt(String(t).substr(0,a.length),10),s>=r&&s<=t}(e,r[0],r[1]):function(e,r){return(r=String(r)).substring(0,e.length)===e.substring(0,r.length)}(e,r)},Object.defineProperty(n,"__esModule",{value:!0}),n.addMatchingCardsToResults=void 0;var c=a,i=s;n.addMatchingCardsToResults=function(e,r,t){var n,a;for(n=0;n<r.patterns.length;n++){var s=r.patterns[n];if(i.matches(e,s)){var o=c.clone(r);a=Array.isArray(s)?String(s[0]).length:String(s).length,e.length>=a&&(o.matchStrength=a),t.push(o);break}}};var o={};Object.defineProperty(o,"__esModule",{value:!0}),o.isValidInputType=void 0,o.isValidInputType=function(e){return"string"==typeof e||e instanceof String};var l={};Object.defineProperty(l,"__esModule",{value:!0}),l.findBestMatch=void 0,l.findBestMatch=function(e){return function(e){var r=e.filter((function(e){return e.matchStrength})).length;return r>0&&r===e.length}(e)?e.reduce((function(e,r){return e?Number(e.matchStrength)<Number(r.matchStrength)?r:e:r})):null};var d=r&&r.__assign||function(){return d=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},d.apply(this,arguments)},u=t,p=n,m=o,f=l,v=a,g={},h={VISA:"visa",MASTERCARD:"mastercard",AMERICAN_EXPRESS:"american-express",DINERS_CLUB:"diners-club",DISCOVER:"discover",JCB:"jcb",UNIONPAY:"unionpay",MAESTRO:"maestro",ELO:"elo",MIR:"mir",HIPER:"hiper",HIPERCARD:"hipercard"},y=[h.VISA,h.MASTERCARD,h.AMERICAN_EXPRESS,h.DINERS_CLUB,h.DISCOVER,h.JCB,h.UNIONPAY,h.MAESTRO,h.ELO,h.MIR,h.HIPER,h.HIPERCARD],_=v.clone(y);function b(e){return g[e]||u[e]}function C(e,r){void 0===r&&(r=!1);var t=_.indexOf(e);if(!r&&-1===t)throw new Error('"'+e+'" is not a supported card type.');return t}function E(e){var r=[];if(!m.isValidInputType(e))return r;if(0===e.length)return _.map((function(e){return v.clone(b(e))}));_.forEach((function(t){var n=b(t);p.addMatchingCardsToResults(e,n,r)}));var t=f.findBestMatch(r);return t?[t]:r}E.getTypeInfo=function(e){return v.clone(b(e))},E.removeCard=function(e){var r=C(e);_.splice(r,1)},E.addCard=function(e){var r=C(e.type,!0);g[e.type]=e,-1===r&&_.push(e.type)},E.updateCard=function(e,r){var t=g[e]||u[e];if(!t)throw new Error('"'+e+"\" is not a recognized type. Use `addCard` instead.'");if(r.type&&t.type!==r.type)throw new Error("Cannot overwrite type parameter.");var n=v.clone(t);n=d(d({},n),r),g[n.type]=n},E.changeOrder=function(e,r){var t=C(e);_.splice(t,1),_.splice(r,0,e)},E.resetModifications=function(){_=v.clone(y),g={}},E.types=h;var S=E,N={niceType:"Dankort",type:"dankort",patterns:[5019],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},M={niceType:"Laser",type:"laser",patterns:[6706,6771,6709],gaps:[4,8,12],lengths:[16,19],code:{name:"CVV",size:3}},R={niceType:"Visa Electron",type:"visa-electron",patterns:[4026,417500,4405,4508,4844,49137],gaps:[4,8,12],lengths:[16],code:{name:"CVV",size:3}},T={validate:function(e){var r,t,n=String(e).replace(/[\s]/g,""),a=n.length,s=!1,c=0;if(!/^[0-9]+$/.test(n))return!1;for(var i=a;i>0;i--){if(r=parseInt(n.charAt(i-1)),s){switch(t=2*r){case 10:t=1;break;case 12:t=3;break;case 14:t=5;break;case 16:t=7;break;case 18:t=9}c+=t}else c+=r;s=!s}return 0!==c&&c%10==0}}.validate,I=function(e){var r=S(e.toString().trim().replace(" ",""));if(1===r.length){var t=r.shift();return(null==t?void 0:t.type)||"unknown"}return"unknown"},V=function(){return S.updateCard(S.types.MAESTRO,{patterns:[493698,[5e3,5018],[502e3,506698],[506779,508999],[56,59],63,67,6]}),S.updateCard(S.types.HIPERCARD,{patterns:[384100,384140,384160,606282,637095,637568]}),S.addCard(N),S.addCard(M),S.addCard(R),Object.values(S.types).concat(["dankort","laser","visa-electron"])},A={amex:["amex","americanexpress","american-express"],dinersclub:["diners","dinersclub","diners-club"],visaelectron:["visaelectron","visa-electron"]};module.exports=function(r){var t=r.acceptedCards,n=void 0===t?[]:t,a=r.number,s=r.issuer,c=r.preview,i=void 0!==c&&c,o=r.expiry,l=r.cvc,d=r.focused,u=r.locale,p=void 0===u?{valid:"valid thru"}:u,m=r.name,f=r.placeholders,v=void 0===f?{name:"YOUR NAME HERE"}:f,g=r.callback,h=e.useState(V()),y=h[0],_=h[1],b=e.useMemo((function(){return(null==n?void 0:n.length)?y.filter((function(e){return n.includes(e)})):y}),[n,y]),C=e.useMemo((function(){var e="unknown";if(a){var r=I(a);b.includes(r)&&(e=r)}var t=16;return A.amex.includes(e)?t=15:(null==A?void 0:A.dinersclub.includes(e))?t=14:["hipercard","mastercard","visa"].includes(e)&&(t=19),{issuer:e,maxLength:t}}),[a,b]),E=e.useMemo((function(){return i&&s?s.toLowerCase():C.issuer}),[C.issuer,s,i]),S=e.useMemo((function(){var e=i?19:C.maxLength,r="number"==typeof a?a.toString():String(a).replace(/[A-Za-z]| /g,"");for(isNaN(parseInt(r,10))&&!i&&(r=""),e>16&&(e=r.length<=16?16:e),r.length>e&&(r=r.slice(0,e));r.length<e;)r+="•";if(A.amex.includes(E)||A.dinersclub.includes(E)){var t=[0,4,10],n=[4,6,5];r="".concat(r.substr(t[0],n[0])," ").concat(r.substr(t[1],n[1])," ").concat(r.substr(t[2],n[2]))}else if(r.length>16){t=[0,4,8,12],n=[4,7];r="".concat(r.substr(t[0],n[0])," ").concat(r.substr(t[1],n[0])," ").concat(r.substr(t[2],n[0])," ").concat(r.substr(t[3],n[1]))}else for(var s=1;s<e/4;s++){var c=4*s+(s-1);r="".concat(r.slice(0,c)," ").concat(r.slice(c))}return r}),[C.maxLength,E,a,i]),N=e.useMemo((function(){var e,r="number"==typeof o?o.toString():o,t="",n="";for(r.includes("/")?(t=(e=r.split("/"))[0],n=e[1]):r.length&&(t=r.substr(0,2),n=r.substr(2,6));t.length<2;)t+="•";for(n.length>2&&(n=n.substr(2,4));n.length<2;)n+="•";return"".concat(t,"/").concat(n)}),[o]),M=e.useCallback((function(e){if(e.length)_(y.filter((function(r){return e.includes(r)})));else{var r=V();_(r)}}),[y]);return e.useEffect((function(){S!==a&&"function"==typeof g&&g(C,T(String(a))),V().toString()!==y.toString()&&M(n)}),[n,g,C,S,M,a,y]),e.createElement("div",{key:"Cards",className:"rccs","data-testid":"rccs"},e.createElement("div",{"data-testid":"rccs__card",className:["rccs__card","rccs__card--".concat(E),"cvc"===d&&"american-express"!==E?"rccs__card--flipped":""].join(" ").trim()},e.createElement("div",{className:"rccs__card--front"},e.createElement("div",{className:"rccs__card__background"}),e.createElement("div",{className:"rccs__issuer"}),e.createElement("div",{className:["rccs__cvc__front","cvc"===d?"rccs--focused":""].join(" ").trim()},l),e.createElement("div",{className:["rccs__number",S.replace(/ /g,"").length>16?"rccs__number--large":"","number"===d?"rccs--focused":"","•"!==S.substr(0,1)?"rccs--filled":""].join(" ").trim()},S),e.createElement("div",{className:["rccs__name","name"===d?"rccs--focused":"",m?"rccs--filled":""].join(" ").trim()},m||v.name),e.createElement("div",{className:["rccs__expiry","expiry"===d?"rccs--focused":"","•"!==N.substr(0,1)?"rccs--filled":""].join(" ").trim()},e.createElement("div",{className:"rccs__expiry__valid"},p.valid),e.createElement("div",{className:"rccs__expiry__value"},N)),e.createElement("div",{className:"rccs__chip"})),e.createElement("div",{className:"rccs__card--back"},e.createElement("div",{className:"rccs__card__background"}),e.createElement("div",{className:"rccs__stripe"}),e.createElement("div",{className:"rccs__signature"}),e.createElement("div",{className:["rccs__cvc","cvc"===d?"rccs--focused":""].join(" ").trim()},l),e.createElement("div",{className:"rccs__issuer"}))))};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,1 @@

/// <reference types="react" />
export interface CallbackArgument {

@@ -3,0 +2,0 @@ issuer: string;

{
"name": "react-credit-cards-2",
"version": "1.0.2",
"version": "2.0.0-rc1",
"description": "Beautiful credit cards for your payment forms",

@@ -29,3 +29,4 @@ "author": "AMARO Fashion <tech@amaro.com>",

"files": [
"dist"
"dist",
"src"
],

@@ -74,2 +75,4 @@ "keywords": [

"@size-limit/preset-small-lib": "^8.2.4",
"@testing-library/jest-dom": "^6.1.3",
"@testing-library/react": "^12.1.5",
"@types/jest": "^29.4.0",

@@ -79,3 +82,2 @@ "@types/react": "^18.0.28",

"@typescript-eslint/parser": "^5.52.0",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.6",
"autoprefixer": "^10.2.6",

@@ -87,4 +89,2 @@ "babel-core": "^7.0.0-bridge.0",

"cross-env": "^7.0.3",
"enzyme": "^3.11.0",
"enzyme-to-json": "^3.6.2",
"eslint": "^8.34.0",

@@ -91,0 +91,0 @@ "eslint-config-prettier": "^8.6.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc