@movmo/express-checkout-button 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dts/index.d.ts +1 -0
- package/dist/index.cjs.css +4 -0
- package/dist/index.cjs.css.map +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.css +4 -0
- package/dist/index.es.css.map +1 -0
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/package.json +4 -2
package/dist/dts/index.d.ts
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }
|
|
2
|
+
|
|
3
|
+
/* ! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com */*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:normal;-webkit-tap-highlight-color:transparent;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-variation-settings:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:normal;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.fixed{position:fixed}.ml-2{margin-left:.5rem}.cursor-pointer{cursor:pointer}.rounded-md{border-radius:.375rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-none{border-style:none}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.bg-gradient-hover{background-image:linear-gradient(90deg,#e02f59,#c41d7e)}.bg-gradient-normal{background-image:linear-gradient(90deg,#f63d68,#dd2590)}.px-2{padding-left:.5rem;padding-right:.5rem}.px-7{padding-left:1.75rem;padding-right:1.75rem}.py-1{padding-bottom:.25rem;padding-top:.25rem}.py-5{padding-bottom:1.25rem;padding-top:1.25rem}.font-inter{font-family:Inter,sans-serif}.text-lg{font-size:1.125rem;line-height:1.75rem}.font-semibold{font-weight:600}.text-\[\#171412\]{--tw-text-opacity:1;color:rgb(23 20 18/var(--tw-text-opacity,1))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.outline-none{outline:2px solid transparent;outline-offset:2px}.transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.duration-200{transition-duration:.2s}.focus\:ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\:ring-\[\#F63D68\]:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(246 61 104/var(--tw-ring-opacity,1))}.focus\:ring-opacity-50:focus{--tw-ring-opacity:0.5}
|
|
4
|
+
/*# sourceMappingURL=index.cjs.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.css"],"names":[],"mappings":"AACA,+FAA+F,CAE/F,iBAAA,uBAAc,CAAd,uBAAc,CA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AAc,CAAd,qBAAA,cAAc,CAAd,UAAA,cAAc,CAAd,+CAAA,aAAc,CAAd,qBAAc,CAAd,UAAA,WAAc,CAAd,cAAc,CAAd,2CAAA,YAAc,CACd,WAAA,UAAoB,CAApB,yBAAA,WAAA,eAAoB,CAAA,CAApB,yBAAA,WAAA,eAAoB,CAAA,CAApB,0BAAA,WAAA,gBAAoB,CAAA,CAApB,0BAAA,WAAA,gBAAoB,CAAA,CAApB,0BAAA,WAAA,gBAAoB,CAAA,CACpB,OAAA,cAAmB,CAAnB,MAAA,iBAAmB,CAAnB,gBAAA,cAAmB,CAAnB,YAAA,qBAAmB,CAAnB,YAAA,oBAAmB,CAAnB,QAAA,gBAAmB,CAAnB,aAAA,iBAAmB,CAAnB,UAAA,iBAAmB,CAAnB,wDAAmB,CAAnB,mBAAA,uDAAmB,CAAnB,oBAAA,uDAAmB,CAAnB,MAAA,kBAAmB,CAAnB,mBAAmB,CAAnB,MAAA,oBAAmB,CAAnB,qBAAmB,CAAnB,MAAA,qBAAA,CAAA,kBAAmB,CAAnB,MAAA,sBAAA,CAAA,mBAAmB,CAAnB,YAAA,4BAAmB,CAAnB,SAAA,kBAAmB,CAAnB,mBAAmB,CAAnB,eAAA,eAAmB,CAAnB,mBAAA,mBAAmB,CAAnB,4CAAmB,CAAnB,YAAA,mBAAmB,CAAnB,+CAAmB,CAAnB,cAAA,6BAAmB,CAAnB,kBAAmB,CAAnB,gBAAA,wBAAA,CAAA,uBAAmB,CAAnB,kDAAmB,CAAnB,cAAA,uBAAmB,CALnB,qBAAA,0GAKoB,CALpB,wGAKoB,CALpB,wFAKoB,CALpB,gCAAA,mBAKoB,CALpB,wDAKoB,CALpB,8BAAA,qBAKoB","file":"index.cjs.css","sourcesContent":["/* Import Inter font from Google Fonts */\r\n@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');\r\n\r\n@tailwind base;\r\n@tailwind components;\r\n@tailwind utilities;"]}
|
package/dist/index.cjs.js
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* (c) 2025 Movmo
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var e=require("react/jsx-runtime"),t=require("react"),n=require("axios");function o(e){if(document.getElementById("movmo-checkout"))return;const t=document.createElement("div");t.id="movmo-checkout",t.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n ",t.innerHTML=`\n <iframe \n src="https://booking.e2e.movmo.io/booking?${e}"\n width="100%" \n height="100%" \n style="border: none;">\n </iframe>\n `,document.body.appendChild(t)}window.addEventListener("popstate",(()=>{const e=document.getElementById("movmo-checkout");!window.history.state?.checkoutOpen&&e&&e.remove()})),window.addEventListener("DOMContentLoaded",(()=>{if(window.location.pathname.startsWith("/movmo/checkout")){const e=window.location.search.substring(1);window.history.replaceState({checkoutOpen:!0},"",window.location.href),o(e)}}))
|
|
7
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react"),n=require("axios");function o(e){if(document.getElementById("movmo-checkout"))return;const t=document.createElement("div");t.id="movmo-checkout",t.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n ",t.innerHTML=`\n <iframe \n src="https://booking.e2e.movmo.io/booking?${e}"\n width="100%" \n height="100%" \n style="border: none;">\n </iframe>\n `,document.body.appendChild(t)}window.addEventListener("popstate",(()=>{const e=document.getElementById("movmo-checkout");!window.history.state?.checkoutOpen&&e&&e.remove()})),window.addEventListener("DOMContentLoaded",(()=>{if(window.location.pathname.startsWith("/movmo/checkout")){const e=window.location.search.substring(1);window.history.replaceState({checkoutOpen:!0},"",window.location.href),o(e)}}));exports.MovmoCheckoutButton=({customerId:i,apiKey:r,dataSource:a,flightOffer:c,isProd:s=!1})=>{const[d,u]=t.useState(!1),h=((e,t=!1)=>{const o=t?"https://api.movmo.io":"https://e2e.api.movmo.io";return n.create({baseURL:o,headers:{Accept:"application/json","Content-Type":"application/json","x-api-key":e},withCredentials:!0,timeout:3e4})})(r,s),m=`\n px-7 py-5 \n font-inter font-semibold text-lg \n rounded-xl \n text-white \n border-none\n cursor-pointer\n transition-all duration-200\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\n ${d?"bg-gradient-hover":"bg-gradient-normal"}\n `.trim(),p="\n ml-2 px-2 py-1\n bg-white \n text-[#171412] \n rounded-md \n text-lg\n ".trim();return e.jsxs("button",{onClick:async()=>{const e={dataSource:a,rawOffer:c},t=await(async(e,t)=>await t.post("/v1/flight_offers",e).then((e=>e.data.id)).catch((e=>null)))(e,h);if(!t)return;const n=new URLSearchParams({offerId:t,airlineRef:i}).toString();window.history.pushState({checkoutOpen:!0},"",`/movmo/checkout?${n}`),o(n)},onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),className:m,children:["Express Checkout",e.jsx("span",{className:p,children:"Movmo"})]})};
|
|
8
8
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/MovmoCheckoutOverlay.tsx","../src/
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/MovmoCheckoutOverlay.tsx","../src/MovmoCheckoutButton.tsx","../src/api.ts"],"sourcesContent":["export function showMovmoOverlay(queryParams: string) {\r\n if (document.getElementById('movmo-checkout')) return;\r\n\r\n const container = document.createElement('div');\r\n container.id = 'movmo-checkout';\r\n container.style.cssText = `\r\n position: fixed;\r\n top: 0;\r\n left: 0;\r\n width: 100vw;\r\n height: 100vh;\r\n background: white;\r\n z-index: 9999;\r\n `;\r\n\r\n container.innerHTML = `\r\n <iframe \r\n src=\"https://booking.e2e.movmo.io/booking?${queryParams}\"\r\n width=\"100%\" \r\n height=\"100%\" \r\n style=\"border: none;\">\r\n </iframe>\r\n `;\r\n\r\n document.body.appendChild(container);\r\n}\r\n\r\n// Clean up when back button is used\r\nwindow.addEventListener('popstate', () => {\r\n const container = document.getElementById('movmo-checkout');\r\n if (!window.history.state?.checkoutOpen && container) {\r\n container.remove();\r\n }\r\n});\r\n\r\n// Show overlay again if loaded directly\r\nwindow.addEventListener('DOMContentLoaded', () => {\r\n const isMovmoPath = window.location.pathname.startsWith('/movmo/checkout');\r\n if (isMovmoPath) {\r\n const queryParams = window.location.search.substring(1);\r\n window.history.replaceState({ checkoutOpen: true }, '', window.location.href);\r\n showMovmoOverlay(queryParams);\r\n }\r\n});\r\n","import React, { useState } from 'react';\r\n\r\nimport { createAxiosClient, FlightOfferRequest, saveFlightOffer } from './api';\r\nimport { showMovmoOverlay } from './MovmoCheckoutOverlay';\r\n\r\ninterface MovmoCheckoutButtonProps {\r\n customerId: string;\r\n apiKey: string;\r\n dataSource: \"amadeus\" | \"sabre\";\r\n // TODO: support fare splitting\r\n flightOffer: object;\r\n isProd?: boolean;\r\n}\r\n\r\nexport const MovmoCheckoutButton: React.FC<MovmoCheckoutButtonProps> = ({\r\n customerId,\r\n apiKey,\r\n dataSource,\r\n flightOffer,\r\n isProd = false,\r\n}) => {\r\n const [isHovered, setIsHovered] = useState(false);\r\n const client = createAxiosClient(apiKey, isProd);\r\n\r\n const handleClick = async () => {\r\n const payload: FlightOfferRequest = {\r\n dataSource,\r\n rawOffer: flightOffer,\r\n };\r\n const offerId = await saveFlightOffer(payload, client);\r\n if (!offerId) {\r\n // TODO: handle error by displaying a message to the user\r\n return;\r\n }\r\n\r\n const queryParams = new URLSearchParams({\r\n offerId,\r\n airlineRef: customerId,\r\n }).toString();\r\n\r\n window.history.pushState({ checkoutOpen: true }, '', `/movmo/checkout?${queryParams}`);\r\n showMovmoOverlay(queryParams);\r\n };\r\n\r\n const buttonClasses = `\r\n px-7 py-5 \r\n font-inter font-semibold text-lg \r\n rounded-xl \r\n text-white \r\n border-none\r\n cursor-pointer\r\n transition-all duration-200\r\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\r\n ${isHovered ? 'bg-gradient-hover' : 'bg-gradient-normal'}\r\n `.trim();\r\n\r\n const badgeClasses = `\r\n ml-2 px-2 py-1\r\n bg-white \r\n text-[#171412] \r\n rounded-md \r\n text-lg\r\n `.trim();\r\n\r\n return (\r\n <button\r\n onClick={handleClick}\r\n onMouseEnter={() => setIsHovered(true)}\r\n onMouseLeave={() => setIsHovered(false)}\r\n className={buttonClasses}\r\n >\r\n Express Checkout\r\n <span className={badgeClasses}>\r\n Movmo\r\n </span>\r\n </button>\r\n );\r\n};\r\n","import axios, { AxiosInstance } from \"axios\";\r\n\r\n\r\nexport const createAxiosClient = (apiKey: string, isProd: boolean = false) => {\r\n const baseUrl = isProd ? \"https://api.movmo.io\" : \"https://e2e.api.movmo.io\";\r\n\r\n const client = axios.create({\r\n baseURL: baseUrl,\r\n headers: {\r\n Accept: \"application/json\",\r\n \"Content-Type\": \"application/json\",\r\n \"x-api-key\": apiKey,\r\n },\r\n // Allow cookies to be sent with requests\r\n withCredentials: true,\r\n timeout: 30000,\r\n });\r\n\r\n return client;\r\n};\r\n\r\nexport interface FlightOfferRequest {\r\n dataSource: string;\r\n // The raw offer object from the data source; does not currently support fare splitting\r\n rawOffer: object;\r\n}\r\n\r\nexport const saveFlightOffer = async (payload: FlightOfferRequest, client: AxiosInstance): Promise<string | null> => {\r\n return await client.post(\"/v1/flight_offers\", payload)\r\n .then((res) => res.data.id)\r\n .catch((err) => {\r\n console.error(err);\r\n return null;\r\n });\r\n};\r\n"],"names":["showMovmoOverlay","queryParams","document","getElementById","container","createElement","id","style","cssText","innerHTML","body","appendChild","window","addEventListener","history","state","checkoutOpen","remove","location","pathname","startsWith","search","substring","replaceState","href","customerId","apiKey","dataSource","flightOffer","isProd","isHovered","setIsHovered","useState","client","baseUrl","axios","create","baseURL","headers","Accept","withCredentials","timeout","createAxiosClient","buttonClasses","trim","badgeClasses","_jsxs","onClick","async","payload","rawOffer","offerId","post","then","res","data","catch","err","saveFlightOffer","URLSearchParams","airlineRef","to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MAAMlD,EAAc,IAAI0D,gBAAgB,CACpCR,UACAS,WAAYnC,IACboC,WAEHjD,OAAOE,QAAQgD,UAAU,CAAE9C,cAAc,GAAQ,GAAI,mBAAmBf,KACxED,EAAiBC,EAAY,EA0BzB8D,aAAc,IAAMhC,GAAa,GACjCiC,aAAc,IAAMjC,GAAa,GACjCkC,UAAWtB,EAAauB,SAAA,CAAA,mBAGxBC,cAAMF,UAAWpB,EAEVqB,SAAA,YACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }
|
|
2
|
+
|
|
3
|
+
/* ! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com */*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:normal;-webkit-tap-highlight-color:transparent;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-variation-settings:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:normal;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.fixed{position:fixed}.ml-2{margin-left:.5rem}.cursor-pointer{cursor:pointer}.rounded-md{border-radius:.375rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-none{border-style:none}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.bg-gradient-hover{background-image:linear-gradient(90deg,#e02f59,#c41d7e)}.bg-gradient-normal{background-image:linear-gradient(90deg,#f63d68,#dd2590)}.px-2{padding-left:.5rem;padding-right:.5rem}.px-7{padding-left:1.75rem;padding-right:1.75rem}.py-1{padding-bottom:.25rem;padding-top:.25rem}.py-5{padding-bottom:1.25rem;padding-top:1.25rem}.font-inter{font-family:Inter,sans-serif}.text-lg{font-size:1.125rem;line-height:1.75rem}.font-semibold{font-weight:600}.text-\[\#171412\]{--tw-text-opacity:1;color:rgb(23 20 18/var(--tw-text-opacity,1))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.outline-none{outline:2px solid transparent;outline-offset:2px}.transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.duration-200{transition-duration:.2s}.focus\:ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\:ring-\[\#F63D68\]:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(246 61 104/var(--tw-ring-opacity,1))}.focus\:ring-opacity-50:focus{--tw-ring-opacity:0.5}
|
|
4
|
+
/*# sourceMappingURL=index.es.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.css"],"names":[],"mappings":"AACA,+FAA+F,CAE/F,iBAAA,uBAAc,CAAd,uBAAc,CAAd,kBAAc,CAAd,kBAAc,CAAd,aAAc,CAAd,aAAc,CAAd,aAAc,CAAd,cAAc,C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,CAAd,UAAA,WAAc,CAAd,cAAc,CAAd,2CAAA,YAAc,CACd,WAAA,UAAoB,CAApB,yBAAA,WAAA,eAAoB,CAAA,CAApB,yBAAA,WAAA,eAAoB,CAAA,CAApB,0BAAA,WAAA,gBAAoB,CAAA,CAApB,0BAAA,WAAA,gBAAoB,CAAA,CAApB,0BAAA,WAAA,gBAAoB,CAAA,CACpB,OAAA,cAAmB,CAAnB,MAAA,iBAAmB,CAAnB,gBAAA,cAAmB,CAAnB,YAAA,qBAAmB,CAAnB,YAAA,oBAAmB,CAAnB,QAAA,gBAAmB,CAAnB,aAAA,iBAAmB,CAAnB,UAAA,iBAAmB,CAAnB,wDAAmB,CAAnB,mBAAA,uDAAmB,CAAnB,oBAAA,uDAAmB,CAAnB,MAAA,kBAAmB,CAAnB,mBAAmB,CAAnB,MAAA,oBAAmB,CAAnB,qBAAmB,CAAnB,MAAA,qBAAA,CAAA,kBAAmB,CAAnB,MAAA,sBAAA,CAAA,mBAAmB,CAAnB,YAAA,4BAAmB,CAAnB,SAAA,kBAAmB,CAAnB,mBAAmB,CAAnB,eAAA,eAAmB,CAAnB,mBAAA,mBAAmB,CAAnB,4CAAmB,CAAnB,YAAA,mBAAmB,CAAnB,+CAAmB,CAAnB,cAAA,6BAAmB,CAAnB,kBAAmB,CAAnB,gBAAA,wBAAA,CAAA,uBAAmB,CAAnB,kDAAmB,CAAnB,cAAA,uBAAmB,CALnB,qBAAA,0GAKoB,CALpB,wGAKoB,CALpB,wFAKoB,CALpB,gCAAA,mBAKoB,CALpB,wDAKoB,CALpB,8BAAA,qBAKoB","file":"index.es.css","sourcesContent":["/* Import Inter font from Google Fonts */\r\n@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');\r\n\r\n@tailwind base;\r\n@tailwind components;\r\n@tailwind utilities;"]}
|
package/dist/index.es.js
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* (c) 2025 Movmo
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{jsxs as
|
|
7
|
+
import{jsxs as t,jsx as n}from"react/jsx-runtime";import{useState as e}from"react";import o from"axios";function i(t){if(document.getElementById("movmo-checkout"))return;const n=document.createElement("div");n.id="movmo-checkout",n.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n ",n.innerHTML=`\n <iframe \n src="https://booking.e2e.movmo.io/booking?${t}"\n width="100%" \n height="100%" \n style="border: none;">\n </iframe>\n `,document.body.appendChild(n)}window.addEventListener("popstate",(()=>{const t=document.getElementById("movmo-checkout");!window.history.state?.checkoutOpen&&t&&t.remove()})),window.addEventListener("DOMContentLoaded",(()=>{if(window.location.pathname.startsWith("/movmo/checkout")){const t=window.location.search.substring(1);window.history.replaceState({checkoutOpen:!0},"",window.location.href),i(t)}}));const r=({customerId:r,apiKey:a,dataSource:c,flightOffer:s,isProd:d=!1})=>{const[m,h]=e(!1),p=((t,n=!1)=>{const e=n?"https://api.movmo.io":"https://e2e.api.movmo.io";return o.create({baseURL:e,headers:{Accept:"application/json","Content-Type":"application/json","x-api-key":t},withCredentials:!0,timeout:3e4})})(a,d),u=`\n px-7 py-5 \n font-inter font-semibold text-lg \n rounded-xl \n text-white \n border-none\n cursor-pointer\n transition-all duration-200\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\n ${m?"bg-gradient-hover":"bg-gradient-normal"}\n `.trim(),l="\n ml-2 px-2 py-1\n bg-white \n text-[#171412] \n rounded-md \n text-lg\n ".trim();return t("button",{onClick:async()=>{const t={dataSource:c,rawOffer:s},n=await(async(t,n)=>await n.post("/v1/flight_offers",t).then((t=>t.data.id)).catch((t=>null)))(t,p);if(!n)return;const e=new URLSearchParams({offerId:n,airlineRef:r}).toString();window.history.pushState({checkoutOpen:!0},"",`/movmo/checkout?${e}`),i(e)},onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),className:u,children:["Express Checkout",n("span",{className:l,children:"Movmo"})]})};export{r as MovmoCheckoutButton};
|
|
8
8
|
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/MovmoCheckoutOverlay.tsx","../src/MovmoCheckoutButton.tsx","../src/api.ts"
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/MovmoCheckoutOverlay.tsx","../src/MovmoCheckoutButton.tsx","../src/api.ts"],"sourcesContent":["export function showMovmoOverlay(queryParams: string) {\r\n if (document.getElementById('movmo-checkout')) return;\r\n\r\n const container = document.createElement('div');\r\n container.id = 'movmo-checkout';\r\n container.style.cssText = `\r\n position: fixed;\r\n top: 0;\r\n left: 0;\r\n width: 100vw;\r\n height: 100vh;\r\n background: white;\r\n z-index: 9999;\r\n `;\r\n\r\n container.innerHTML = `\r\n <iframe \r\n src=\"https://booking.e2e.movmo.io/booking?${queryParams}\"\r\n width=\"100%\" \r\n height=\"100%\" \r\n style=\"border: none;\">\r\n </iframe>\r\n `;\r\n\r\n document.body.appendChild(container);\r\n}\r\n\r\n// Clean up when back button is used\r\nwindow.addEventListener('popstate', () => {\r\n const container = document.getElementById('movmo-checkout');\r\n if (!window.history.state?.checkoutOpen && container) {\r\n container.remove();\r\n }\r\n});\r\n\r\n// Show overlay again if loaded directly\r\nwindow.addEventListener('DOMContentLoaded', () => {\r\n const isMovmoPath = window.location.pathname.startsWith('/movmo/checkout');\r\n if (isMovmoPath) {\r\n const queryParams = window.location.search.substring(1);\r\n window.history.replaceState({ checkoutOpen: true }, '', window.location.href);\r\n showMovmoOverlay(queryParams);\r\n }\r\n});\r\n","import React, { useState } from 'react';\r\n\r\nimport { createAxiosClient, FlightOfferRequest, saveFlightOffer } from './api';\r\nimport { showMovmoOverlay } from './MovmoCheckoutOverlay';\r\n\r\ninterface MovmoCheckoutButtonProps {\r\n customerId: string;\r\n apiKey: string;\r\n dataSource: \"amadeus\" | \"sabre\";\r\n // TODO: support fare splitting\r\n flightOffer: object;\r\n isProd?: boolean;\r\n}\r\n\r\nexport const MovmoCheckoutButton: React.FC<MovmoCheckoutButtonProps> = ({\r\n customerId,\r\n apiKey,\r\n dataSource,\r\n flightOffer,\r\n isProd = false,\r\n}) => {\r\n const [isHovered, setIsHovered] = useState(false);\r\n const client = createAxiosClient(apiKey, isProd);\r\n\r\n const handleClick = async () => {\r\n const payload: FlightOfferRequest = {\r\n dataSource,\r\n rawOffer: flightOffer,\r\n };\r\n const offerId = await saveFlightOffer(payload, client);\r\n if (!offerId) {\r\n // TODO: handle error by displaying a message to the user\r\n return;\r\n }\r\n\r\n const queryParams = new URLSearchParams({\r\n offerId,\r\n airlineRef: customerId,\r\n }).toString();\r\n\r\n window.history.pushState({ checkoutOpen: true }, '', `/movmo/checkout?${queryParams}`);\r\n showMovmoOverlay(queryParams);\r\n };\r\n\r\n const buttonClasses = `\r\n px-7 py-5 \r\n font-inter font-semibold text-lg \r\n rounded-xl \r\n text-white \r\n border-none\r\n cursor-pointer\r\n transition-all duration-200\r\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\r\n ${isHovered ? 'bg-gradient-hover' : 'bg-gradient-normal'}\r\n `.trim();\r\n\r\n const badgeClasses = `\r\n ml-2 px-2 py-1\r\n bg-white \r\n text-[#171412] \r\n rounded-md \r\n text-lg\r\n `.trim();\r\n\r\n return (\r\n <button\r\n onClick={handleClick}\r\n onMouseEnter={() => setIsHovered(true)}\r\n onMouseLeave={() => setIsHovered(false)}\r\n className={buttonClasses}\r\n >\r\n Express Checkout\r\n <span className={badgeClasses}>\r\n Movmo\r\n </span>\r\n </button>\r\n );\r\n};\r\n","import axios, { AxiosInstance } from \"axios\";\r\n\r\n\r\nexport const createAxiosClient = (apiKey: string, isProd: boolean = false) => {\r\n const baseUrl = isProd ? \"https://api.movmo.io\" : \"https://e2e.api.movmo.io\";\r\n\r\n const client = axios.create({\r\n baseURL: baseUrl,\r\n headers: {\r\n Accept: \"application/json\",\r\n \"Content-Type\": \"application/json\",\r\n \"x-api-key\": apiKey,\r\n },\r\n // Allow cookies to be sent with requests\r\n withCredentials: true,\r\n timeout: 30000,\r\n });\r\n\r\n return client;\r\n};\r\n\r\nexport interface FlightOfferRequest {\r\n dataSource: string;\r\n // The raw offer object from the data source; does not currently support fare splitting\r\n rawOffer: object;\r\n}\r\n\r\nexport const saveFlightOffer = async (payload: FlightOfferRequest, client: AxiosInstance): Promise<string | null> => {\r\n return await client.post(\"/v1/flight_offers\", payload)\r\n .then((res) => res.data.id)\r\n .catch((err) => {\r\n console.error(err);\r\n return null;\r\n });\r\n};\r\n"],"names":["showMovmoOverlay","queryParams","document","getElementById","container","createElement","id","style","cssText","innerHTML","body","appendChild","window","addEventListener","history","state","checkoutOpen","remove","location","pathname","startsWith","search","substring","replaceState","href","MovmoCheckoutButton","customerId","apiKey","dataSource","flightOffer","isProd","isHovered","setIsHovered","useState","client","baseUrl","axios","create","baseURL","headers","Accept","withCredentials","timeout","createAxiosClient","buttonClasses","trim","badgeClasses","_jsxs","onClick","async","payload","rawOffer","offerId","post","then","res","data","catch","err","saveFlightOffer","URLSearchParams","airlineRef","toString","pushState","onMouseEnter","onMouseLeave","className","children","_jsx"],"mappings":";;;;;;wGAAM,SAAUA,EAAiBC,GAC7B,GAAIC,SAASC,eAAe,kBAAmB,OAE/C,MAAMC,EAAYF,SAASG,cAAc,OACzCD,EAAUE,GAAK,iBACfF,EAAUG,MAAMC,QAAU,yKAU1BJ,EAAUK,UAAY,6EAE8BR,yHAOpDC,SAASQ,KAAKC,YAAYP,EAC9B,CAGAQ,OAAOC,iBAAiB,YAAY,KAChC,MAAMT,EAAYF,SAASC,eAAe,mBACrCS,OAAOE,QAAQC,OAAOC,cAAgBZ,GACvCA,EAAUa,YAKlBL,OAAOC,iBAAiB,oBAAoB,KAExC,GADoBD,OAAOM,SAASC,SAASC,WAAW,mBACvC,CACb,MAAMnB,EAAcW,OAAOM,SAASG,OAAOC,UAAU,GACrDV,OAAOE,QAAQS,aAAa,CAAEP,cAAc,GAAQ,GAAIJ,OAAOM,SAASM,MACxExB,EAAiBC,OC3BZ,MAAAwB,EAA0D,EACnEC,aACAC,SACAC,aACAC,cACAC,UAAS,MAET,MAAOC,EAAWC,GAAgBC,GAAS,GACrCC,ECnBuB,EAACP,EAAgBG,GAAkB,KAChE,MAAMK,EAAUL,EAAS,uBAAyB,2BAclD,OAZeM,EAAMC,OAAO,CACxBC,QAASH,EACTI,QAAS,CACLC,OAAQ,mBACR,eAAgB,mBAChB,YAAab,GAGjBc,iBAAiB,EACjBC,QAAS,KAGA,EDIEC,CAAkBhB,EAAQG,GAsBnCc,EAAgB,sRAShBb,EAAY,oBAAsB,6BACtCc,OAEIC,EAAe,mHAMnBD,OAEF,OACIE,EACI,SAAA,CAAAC,QA1CYC,UAChB,MAAMC,EAA8B,CAChCtB,aACAuB,SAAUtB,GAERuB,OCFiBH,OAAOC,EAA6BhB,UAClDA,EAAOmB,KAAK,oBAAqBH,GACzCI,MAAMC,GAAQA,EAAIC,KAAKlD,KACvBmD,OAAOC,GAEG,ODHWC,CAAgBT,EAAShB,GAC/C,IAAKkB,EAED,OAGJ,MAAMnD,EAAc,IAAI2D,gBAAgB,CACpCR,UACAS,WAAYnC,IACboC,WAEHlD,OAAOE,QAAQiD,UAAU,CAAE/C,cAAc,GAAQ,GAAI,mBAAmBf,KACxED,EAAiBC,EAAY,EA0BzB+D,aAAc,IAAMhC,GAAa,GACjCiC,aAAc,IAAMjC,GAAa,GACjCkC,UAAWtB,EAAauB,SAAA,CAAA,mBAGxBC,UAAMF,UAAWpB,EAEVqB,SAAA,YACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@movmo/express-checkout-button",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "React component plugin for embedding Movmo Express Checkout on airline websites.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
|
-
"
|
|
13
|
+
"dist",
|
|
14
|
+
"dist/index.css"
|
|
14
15
|
],
|
|
15
16
|
"scripts": {
|
|
16
17
|
"build": "rollup -c && tsc --emitDeclarationOnly",
|
|
@@ -50,6 +51,7 @@
|
|
|
50
51
|
"rollup": "^4.0.0",
|
|
51
52
|
"rollup-plugin-dts": "^6.0.0",
|
|
52
53
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
54
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
53
55
|
"storybook": "^8.6.0",
|
|
54
56
|
"tailwindcss": "^3.4.0",
|
|
55
57
|
"tailwindcss-animate": "^1.0.0",
|