@formspree/react
Advanced tools
Comparing version 2.3.4-beta.1 to 2.3.4-beta.2
@@ -1,1 +0,1 @@ | ||
var W=Object.create;var P=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var oe=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),se=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},N=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ee(t))!re.call(e,o)&&o!==r&&P(e,o,{get:()=>t[o],enumerable:!(s=X(t,o))||s.enumerable});return e};var b=(e,t,r)=>(r=e!=null?W(te(e)):{},N(t||!e||!e.__esModule?P(r,"default",{value:e,enumerable:!0}):r,e)),ne=e=>N(P({},"__esModule",{value:!0}),e);var T=oe((Re,K)=>{"use strict";var _=Object.defineProperty,ie=Object.getOwnPropertyDescriptor,ae=Object.getOwnPropertyNames,de=Object.prototype.hasOwnProperty,pe=(e,t)=>{for(var r in t)_(e,r,{get:t[r],enumerable:!0})},me=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ae(t))!de.call(e,o)&&o!==r&&_(e,o,{get:()=>t[o],enumerable:!(s=ie(t,o))||s.enumerable});return e},le=e=>me(_({},"__esModule",{value:!0}),e),V={};pe(V,{Client:()=>L,createClient:()=>k,getDefaultClient:()=>Pe,isFieldError:()=>Se});K.exports=le(V);var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",ce=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;function ue(e){e=String(e);for(var t,r,s,o,a="",c=0,l=e.length%3;c<e.length;){if((r=e.charCodeAt(c++))>255||(s=e.charCodeAt(c++))>255||(o=e.charCodeAt(c++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");t=r<<16|s<<8|o,a+=h.charAt(t>>18&63)+h.charAt(t>>12&63)+h.charAt(t>>6&63)+h.charAt(t&63)}return l?a.slice(0,l-3)+"===".substring(l):a}function fe(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!ce.test(e))throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");e+="==".slice(2-(e.length&3));for(var t,r="",s,o,a=0;a<e.length;)t=h.indexOf(e.charAt(a++))<<18|h.indexOf(e.charAt(a++))<<12|(s=h.indexOf(e.charAt(a++)))<<6|(o=h.indexOf(e.charAt(a++))),r+=s===64?String.fromCharCode(t>>16&255):o===64?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,t&255);return r}var ye="2.7.2-beta.0",he=e=>ue(JSON.stringify(e)),Ee=e=>{let t=`@formspree/core@${ye}`;return e?`${e} ${t}`:t},ge=()=>1*new Date,S=(e,t,r)=>{e instanceof FormData?e.append(t,r):e=Object.assign(e,{[t]:r})},be=async({stripePromise:e,response:t,responseData:r,payload:s,data:o,fetchImpl:a,request:c,url:l})=>{let f=await e.handleCardAction(r.stripe.paymentIntentClientSecret);if(f.error)return{response:t,body:{errors:[{code:"STRIPE_CLIENT_ERROR",message:"Stripe SCA error",field:"paymentMethod"}]}};{s.paymentMethod.id||S(o,"paymentMethod",s.paymentMethod.id),S(o,"paymentIntent",f.paymentIntent.id),S(o,"resubmitKey",r.resubmitKey);let p=await a(l,{...c,body:JSON.stringify({paymentIntent:f.paymentIntent.id,resubmitKey:r.resubmitKey})}),u=await p.json();return{response:p,body:u}}},Fe=()=>navigator.webdriver||!!document.documentElement.getAttribute(fe("d2ViZHJpdmVy"))||!!window.callPhantom||!!window._phantom,xe=class{constructor(){this.loadedAt=ge(),this.webdriver=Fe()}teardown(){}data(){return{loadedAt:this.loadedAt,webdriver:this.webdriver}}},L=class{constructor(e={}){this.project=e.project,this.stripePromise=e.stripePromise,typeof window<"u"&&this.startBrowserSession()}startBrowserSession(){this.session||(this.session=new xe)}teardown(){this.session&&this.session.teardown()}async submitForm(e,t,r={}){let s=r.endpoint||"https://formspree.io",o=r.fetchImpl||fetch,a=this.project?`${s}/p/${this.project}/f/${e}`:`${s}/f/${e}`,c=p=>p instanceof FormData?p:JSON.stringify(p),l={Accept:"application/json","Formspree-Client":Ee(r.clientName)};this.session&&(l["Formspree-Session-Data"]=he(this.session.data())),t instanceof FormData||(l["Content-Type"]="application/json");let f={method:"POST",mode:"cors",body:c(t),headers:l};if(this.stripePromise&&r.createPaymentMethod){let p=await r.createPaymentMethod();if(p.error)return{response:null,body:{errors:[{code:"STRIPE_CLIENT_ERROR",message:"Error creating payment method",field:"paymentMethod"}]}};S(t,"paymentMethod",p.paymentMethod.id);let u=await o(a,{...f,body:t}),y=await u.json();return y&&y.stripe&&y.stripe.requiresAction&&y.resubmitKey?await be({stripePromise:this.stripePromise,responseData:y,response:u,payload:p,data:t,fetchImpl:o,request:f,url:a}):{response:u,body:y}}else return o(a,f).then(p=>p.json().then(u=>({body:u,response:p})))}},k=e=>new L(e),Pe=()=>(j||(j=k()),j),j,U=(e=>(e.REQUIRED_FIELD_MISSING="REQUIRED_FIELD_MISSING",e.REQUIRED_FIELD_EMPTY="REQUIRED_FIELD_EMPTY",e.TYPE_EMAIL="TYPE_EMAIL",e.TYPE_NUMERIC="TYPE_NUMERIC",e.TYPE_TEXT="TYPE_TEXT",e))(U||{});function Se(e){return e.code in U&&e.field!==void 0}});var je={};se(je,{CardElement:()=>E.CardElement,FormspreeProvider:()=>z,ValidationError:()=>Q,isFieldError:()=>Z.isFieldError,useForm:()=>H,useFormspree:()=>v});module.exports=ne(je);var i=b(require("react")),w=b(T()),$=require("@stripe/stripe-js/pure"),we=(0,i.lazy)(()=>import("@stripe/react-stripe-js").then(e=>({default:e.Elements}))),R=i.default.createContext({client:void 0});R.displayName="Formspree";var I,ve=e=>(I||(I=(0,$.loadStripe)(e)),I),Y=(e,t)=>{let r={};return e&&(r.stripePromise=e),t&&(r.project=t),(0,w.createClient)(r)},z=e=>{let[t,r]=(0,i.useState)(void 0),[s,o]=(0,i.useState)(Y(t,e.project));return(0,i.useEffect)(()=>(s.startBrowserSession(),()=>{s.teardown()}),[]),(0,i.useEffect)(()=>{let a=async()=>{let c=await ve(e.stripePK);r(c)};e.stripePK&&a()},[e.stripePK]),(0,i.useEffect)(()=>{t&&o(Y(t,e.project))},[t]),i.default.createElement(R.Provider,{value:{client:s}},e.stripePK?i.default.createElement(i.default.Fragment,null,t&&i.default.createElement(i.Suspense,{fallback:i.default.createElement("p",null,"....")},i.default.createElement(we,{stripe:t},i.default.createElement(i.default.Fragment,null,e.children)))):i.default.createElement(i.default.Fragment,null,e.children))};function v(){let e=(0,i.useContext)(R);return e.client?e:{client:(0,w.getDefaultClient)()}}var F=require("react"),E=require("@stripe/react-stripe-js");var B="2.3.4-beta.1";var De=e=>e.preventDefault!==void 0,H=(e,t={})=>{let[r,s]=(0,F.useState)(null),[o,a]=(0,F.useState)(!1),[c,l]=(0,F.useState)(!1),[f,p]=(0,F.useState)([]),u=v(),y=t.client||u,M,A;if(!y)throw new Error("You must provide a Formspree client");if(!e)throw new Error('You must provide a form key or hashid (e.g. useForm("myForm") or useForm("123xyz")');u.client&&u.client.stripePromise&&(M=(0,E.useStripe)(),A=(0,E.useElements)());let x=!!t.debug,g=t.data;return[{result:r,submitting:o,succeeded:c,errors:f},async C=>{let q=async n=>{n.preventDefault();let m=n.target;if(m.tagName!="FORM")throw new Error("submit was triggered for a non-form element");return new FormData(m)},d=De(C)?await q(C):C,O=(n,m)=>{d instanceof FormData?d.append(n,m):d=Object.assign(d,{[n]:m})};if(typeof g=="object")for(let n in g)if(typeof g[n]=="function"){let m=g[n].call(null);m instanceof Promise&&(m=await m),m!==void 0&&O(n,m)}else O(n,g[n]);let G=async()=>{let n={...d.address_line1&&{line1:d.address_line1},...d.address_line2&&{line2:d.address_line2},...d.address_city&&{city:d.address_city},...d.address_country&&{country:d.address_country},...d.address_state&&{state:d.address_state},...d.address_postal_code&&{postal_code:d.address_postal_code}};return await M.createPaymentMethod({type:"card",card:A.getElement(E.CardElement),billing_details:{...d.name&&{name:d.name},...d.email&&{email:d.email},...d.phone&&{phone:d.phone},...n&&{address:n}}})};return a(!0),u.client.submitForm(e,d,{endpoint:t.endpoint,clientName:`@formspree/react@${B}`,createPaymentMethod:u.client&&u.client.stripePromise?G:void 0}).then(n=>{let m=n.response.status,D;return m===200?(x&&console.log("Form submitted",n),l(!0),s(n),p([])):m>=400&&m<500?(D=n.body,D.errors&&p(D.errors),x&&console.log("Validation error",n),l(!1)):(x&&console.log("Unexpected error",n),l(!1)),n}).catch(n=>{throw x&&console.log("Unexpected error",n),l(!1),n}).finally(()=>{a(!1)})},()=>{a(!1),l(!1),p([])}]};var J=b(require("react")),Q=e=>{let{prefix:t,field:r,errors:s,...o}=e,a=(s||[]).find(c=>c.field===r);return a?J.default.createElement("div",{...o},t," ",a.message):null};var Z=b(T());0&&(module.exports={CardElement,FormspreeProvider,ValidationError,isFieldError,useForm,useFormspree}); | ||
var W=Object.create;var P=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var oe=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),se=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},N=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ee(t))!re.call(e,o)&&o!==r&&P(e,o,{get:()=>t[o],enumerable:!(s=X(t,o))||s.enumerable});return e};var b=(e,t,r)=>(r=e!=null?W(te(e)):{},N(t||!e||!e.__esModule?P(r,"default",{value:e,enumerable:!0}):r,e)),ne=e=>N(P({},"__esModule",{value:!0}),e);var T=oe((Re,K)=>{"use strict";var _=Object.defineProperty,ie=Object.getOwnPropertyDescriptor,ae=Object.getOwnPropertyNames,de=Object.prototype.hasOwnProperty,pe=(e,t)=>{for(var r in t)_(e,r,{get:t[r],enumerable:!0})},me=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ae(t))!de.call(e,o)&&o!==r&&_(e,o,{get:()=>t[o],enumerable:!(s=ie(t,o))||s.enumerable});return e},le=e=>me(_({},"__esModule",{value:!0}),e),V={};pe(V,{Client:()=>L,createClient:()=>k,getDefaultClient:()=>Pe,isFieldError:()=>Se});K.exports=le(V);var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",ce=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;function ue(e){e=String(e);for(var t,r,s,o,a="",c=0,l=e.length%3;c<e.length;){if((r=e.charCodeAt(c++))>255||(s=e.charCodeAt(c++))>255||(o=e.charCodeAt(c++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");t=r<<16|s<<8|o,a+=h.charAt(t>>18&63)+h.charAt(t>>12&63)+h.charAt(t>>6&63)+h.charAt(t&63)}return l?a.slice(0,l-3)+"===".substring(l):a}function fe(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!ce.test(e))throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");e+="==".slice(2-(e.length&3));for(var t,r="",s,o,a=0;a<e.length;)t=h.indexOf(e.charAt(a++))<<18|h.indexOf(e.charAt(a++))<<12|(s=h.indexOf(e.charAt(a++)))<<6|(o=h.indexOf(e.charAt(a++))),r+=s===64?String.fromCharCode(t>>16&255):o===64?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,t&255);return r}var ye="2.7.2",he=e=>ue(JSON.stringify(e)),Ee=e=>{let t=`@formspree/core@${ye}`;return e?`${e} ${t}`:t},ge=()=>1*new Date,S=(e,t,r)=>{e instanceof FormData?e.append(t,r):e=Object.assign(e,{[t]:r})},be=async({stripePromise:e,response:t,responseData:r,payload:s,data:o,fetchImpl:a,request:c,url:l})=>{let f=await e.handleCardAction(r.stripe.paymentIntentClientSecret);if(f.error)return{response:t,body:{errors:[{code:"STRIPE_CLIENT_ERROR",message:"Stripe SCA error",field:"paymentMethod"}]}};{s.paymentMethod.id||S(o,"paymentMethod",s.paymentMethod.id),S(o,"paymentIntent",f.paymentIntent.id),S(o,"resubmitKey",r.resubmitKey);let p=await a(l,{...c,body:JSON.stringify({paymentIntent:f.paymentIntent.id,resubmitKey:r.resubmitKey})}),u=await p.json();return{response:p,body:u}}},Fe=()=>navigator.webdriver||!!document.documentElement.getAttribute(fe("d2ViZHJpdmVy"))||!!window.callPhantom||!!window._phantom,xe=class{constructor(){this.loadedAt=ge(),this.webdriver=Fe()}teardown(){}data(){return{loadedAt:this.loadedAt,webdriver:this.webdriver}}},L=class{constructor(e={}){this.project=e.project,this.stripePromise=e.stripePromise,typeof window<"u"&&this.startBrowserSession()}startBrowserSession(){this.session||(this.session=new xe)}teardown(){this.session&&this.session.teardown()}async submitForm(e,t,r={}){let s=r.endpoint||"https://formspree.io",o=r.fetchImpl||fetch,a=this.project?`${s}/p/${this.project}/f/${e}`:`${s}/f/${e}`,c=p=>p instanceof FormData?p:JSON.stringify(p),l={Accept:"application/json","Formspree-Client":Ee(r.clientName)};this.session&&(l["Formspree-Session-Data"]=he(this.session.data())),t instanceof FormData||(l["Content-Type"]="application/json");let f={method:"POST",mode:"cors",body:c(t),headers:l};if(this.stripePromise&&r.createPaymentMethod){let p=await r.createPaymentMethod();if(p.error)return{response:null,body:{errors:[{code:"STRIPE_CLIENT_ERROR",message:"Error creating payment method",field:"paymentMethod"}]}};S(t,"paymentMethod",p.paymentMethod.id);let u=await o(a,{...f,body:t}),y=await u.json();return y&&y.stripe&&y.stripe.requiresAction&&y.resubmitKey?await be({stripePromise:this.stripePromise,responseData:y,response:u,payload:p,data:t,fetchImpl:o,request:f,url:a}):{response:u,body:y}}else return o(a,f).then(p=>p.json().then(u=>({body:u,response:p})))}},k=e=>new L(e),Pe=()=>(j||(j=k()),j),j,U=(e=>(e.REQUIRED_FIELD_MISSING="REQUIRED_FIELD_MISSING",e.REQUIRED_FIELD_EMPTY="REQUIRED_FIELD_EMPTY",e.TYPE_EMAIL="TYPE_EMAIL",e.TYPE_NUMERIC="TYPE_NUMERIC",e.TYPE_TEXT="TYPE_TEXT",e))(U||{});function Se(e){return e.code in U&&e.field!==void 0}});var je={};se(je,{CardElement:()=>E.CardElement,FormspreeProvider:()=>z,ValidationError:()=>Q,isFieldError:()=>Z.isFieldError,useForm:()=>H,useFormspree:()=>v});module.exports=ne(je);var i=b(require("react")),w=b(T()),$=require("@stripe/stripe-js/pure"),we=(0,i.lazy)(()=>import("@stripe/react-stripe-js").then(e=>({default:e.Elements}))),R=i.default.createContext({client:void 0});R.displayName="Formspree";var I,ve=e=>(I||(I=(0,$.loadStripe)(e)),I),Y=(e,t)=>{let r={};return e&&(r.stripePromise=e),t&&(r.project=t),(0,w.createClient)(r)},z=e=>{let[t,r]=(0,i.useState)(void 0),[s,o]=(0,i.useState)(Y(t,e.project));return(0,i.useEffect)(()=>(s.startBrowserSession(),()=>{s.teardown()}),[]),(0,i.useEffect)(()=>{let a=async()=>{let c=await ve(e.stripePK);r(c)};e.stripePK&&a()},[e.stripePK]),(0,i.useEffect)(()=>{t&&o(Y(t,e.project))},[t]),i.default.createElement(R.Provider,{value:{client:s}},e.stripePK?i.default.createElement(i.default.Fragment,null,t&&i.default.createElement(i.Suspense,{fallback:i.default.createElement("p",null,"....")},i.default.createElement(we,{stripe:t},i.default.createElement(i.default.Fragment,null,e.children)))):i.default.createElement(i.default.Fragment,null,e.children))};function v(){let e=(0,i.useContext)(R);return e.client?e:{client:(0,w.getDefaultClient)()}}var F=require("react"),E=require("@stripe/react-stripe-js");var B="2.3.4-beta.2";var De=e=>e.preventDefault!==void 0,H=(e,t={})=>{let[r,s]=(0,F.useState)(null),[o,a]=(0,F.useState)(!1),[c,l]=(0,F.useState)(!1),[f,p]=(0,F.useState)([]),u=v(),y=t.client||u,M,A;if(!y)throw new Error("You must provide a Formspree client");if(!e)throw new Error('You must provide a form key or hashid (e.g. useForm("myForm") or useForm("123xyz")');u.client&&u.client.stripePromise&&(M=(0,E.useStripe)(),A=(0,E.useElements)());let x=!!t.debug,g=t.data;return[{result:r,submitting:o,succeeded:c,errors:f},async C=>{let q=async n=>{n.preventDefault();let m=n.target;if(m.tagName!="FORM")throw new Error("submit was triggered for a non-form element");return new FormData(m)},d=De(C)?await q(C):C,O=(n,m)=>{d instanceof FormData?d.append(n,m):d=Object.assign(d,{[n]:m})};if(typeof g=="object")for(let n in g)if(typeof g[n]=="function"){let m=g[n].call(null);m instanceof Promise&&(m=await m),m!==void 0&&O(n,m)}else O(n,g[n]);let G=async()=>{let n={...d.address_line1&&{line1:d.address_line1},...d.address_line2&&{line2:d.address_line2},...d.address_city&&{city:d.address_city},...d.address_country&&{country:d.address_country},...d.address_state&&{state:d.address_state},...d.address_postal_code&&{postal_code:d.address_postal_code}};return await M.createPaymentMethod({type:"card",card:A.getElement(E.CardElement),billing_details:{...d.name&&{name:d.name},...d.email&&{email:d.email},...d.phone&&{phone:d.phone},...n&&{address:n}}})};return a(!0),u.client.submitForm(e,d,{endpoint:t.endpoint,clientName:`@formspree/react@${B}`,createPaymentMethod:u.client&&u.client.stripePromise?G:void 0}).then(n=>{let m=n.response.status,D;return m===200?(x&&console.log("Form submitted",n),l(!0),s(n),p([])):m>=400&&m<500?(D=n.body,D.errors&&p(D.errors),x&&console.log("Validation error",n),l(!1)):(x&&console.log("Unexpected error",n),l(!1)),n}).catch(n=>{throw x&&console.log("Unexpected error",n),l(!1),n}).finally(()=>{a(!1)})},()=>{a(!1),l(!1),p([])}]};var J=b(require("react")),Q=e=>{let{prefix:t,field:r,errors:s,...o}=e,a=(s||[]).find(c=>c.field===r);return a?J.default.createElement("div",{...o},t," ",a.message):null};var Z=b(T());0&&(module.exports={CardElement,FormspreeProvider,ValidationError,isFieldError,useForm,useFormspree}); |
{ | ||
"name": "@formspree/react", | ||
"version": "2.3.4-beta.1", | ||
"version": "2.3.4-beta.2", | ||
"description": "The React component library for Formspree", | ||
@@ -49,3 +49,4 @@ "private": false, | ||
"dependencies": { | ||
"@stripe/react-stripe-js": "^1.7.1" | ||
"@stripe/react-stripe-js": "^1.7.1", | ||
"@stripe/stripe-js": "^1.35.0" | ||
}, | ||
@@ -70,5 +71,2 @@ "devDependencies": { | ||
}, | ||
"peerDependencies": { | ||
"@stripe/stripe-js": "^1.29.0" | ||
}, | ||
"publishConfig": { | ||
@@ -75,0 +73,0 @@ "access": "public", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21799
+ Added@stripe/stripe-js@^1.35.0