1 line
21 KiB
JavaScript
1 line
21 KiB
JavaScript
(()=>{"use strict";const e=window.ReactJSXRuntime,{__}=wp.i18n,{addFilter:t}=wp.hooks,{Fragment:o,Component:s}=wp.element,{InspectorControls:n,PanelColorSettings:l}=wp.editor,{createHigherOrderComponent:a}=wp.compose,{ToggleControl:i,PanelBody:u,SelectControl:r,__experimentalNumberControl:c}=wp.components,h=c,d=["core/button"],p=a(t=>class extends s{componentDidMount(){const{use_ls:e}=this.props.attributes;this.setState({products:[],stores:[],checkingApi:!1}),e&&(this.getStores(),this.checkApi())}getStores(){return wp.apiFetch({path:"lsq/v1/stores"}).then(e=>{if(1==e.success&&(this.setState({stores:e.stores}),e.stores.length)){let t=e.stores.findIndex(e=>e.value==this.props.attributes.store);-1===t&&(t=0),this.getProducts(e.stores[t].value)}})}checkApi(){return this.setState({checkingApi:!0}),wp.apiFetch({path:"lsq/v1/validate"}).then(e=>{let t=!1;1==e.success&&(t=!0),this.setState({isApiConnectable:t,checkingApi:!1})})}getProducts(e){return this.setState({products:[],isLoadingProducts:!0}),wp.apiFetch({path:`lsq/v1/products?store_id=${e}`}).then(e=>{if(1==e.success&&(this.setState({products:e.products}),e.products.length)){let t=e.products.findIndex(e=>e.value==this.props.attributes.product);-1===t&&(t=0),this.props.setAttributes({product:e.products[t].value})}}).finally(()=>{this.setState({isLoadingProducts:!1})})}onChangeProduct=e=>{this.props.setAttributes({product:e})};onChangeStore=e=>{this.props.setAttributes({store:e}),this.getProducts(e)};onChangeOverlay=e=>{this.props.setAttributes({overlay:e})};onChangeUserData=e=>{this.props.setAttributes({prefillUserData:e})};changeUseLS=e=>{this.props.setAttributes({use_ls:e}),e&&!this.state.stores.length&&(this.getStores(),this.checkApi())};onChangeURLData=e=>{this.props.setAttributes({prefillFromURL:e})};onAttributeChange=(e,t)=>{this.props.setAttributes({[e]:t})};render(){const{attributes:s}=this.props,{store:a,product:c,overlay:d,use_ls:p,prefillUserData:g,prefillFromURL:y,showLogo:m,showMedia:C,showDescription:b,showDiscount:k,quantity:z,checkoutBackgroundColor:x,checkoutLinksColor:j,checkoutButtonColor:D,checkoutButtonTextColor:w,checkoutTermsPrivacyColor:M}=s;return"core/button"!==this.props.name?(0,e.jsx)(t,{...this.props}):(0,e.jsxs)(o,{children:[(0,e.jsx)(t,{...this.props}),(0,e.jsx)(n,{children:(0,e.jsxs)(u,{title:__("Lemon Squeezy","lemon-squeezy"),initialOpen:!1,children:[(0,e.jsx)(o,{children:(0,e.jsx)("p",{children:(0,e.jsx)(i,{label:__("Apply Lemon Squeezy Checkout","lemon-squeezy"),checked:p,help:__(p?"Your button will be used for Lemon Squeezy Checkout.":"Your button will not be used for Lemon Squeezy Checkout.","lemon-squeezy"),onChange:this.changeUseLS})})}),p&&(()=>this.state?[this.state.isApiConnectable?(0,e.jsxs)(o,{children:[(0,e.jsx)(r,{label:__("Select Store","lemon-squeezy"),value:a,options:this.state.stores,onChange:this.onChangeStore}),this.state.isLoadingProducts?(0,e.jsx)("p",{style:{fontSize:"14px",color:"rgb(117, 117, 117)"},children:__("Loading...","lemon-squeezy")}):this.state.products.length?(0,e.jsx)(r,{label:__("Product","lemon-squeezy"),value:c,options:this.state.products,onChange:this.onChangeProduct}):(0,e.jsx)("p",{style:{fontSize:"14px",color:"rgb(117, 117, 117)"},children:__("No products found","lemon-squeezy")}),(0,e.jsx)(h,{label:__("Quantity","lemon-squeezy"),__next40pxDefaultSize:!0,isShiftStepEnabled:!0,shiftStep:1,value:z,onChange:this.onAttributeChange.bind(this,"quantity")}),(0,e.jsx)(i,{label:__("Use checkout overlay?","lemon-squeezy"),checked:d,help:__(d?"Your checkout will be opened in a modal window.":"Your customer will be redirected to your checkout page.","lemon-squeezy"),onChange:this.onChangeOverlay}),(0,e.jsx)(i,{label:__("Pre-fill User Data","lemon-squeezy"),checked:g,help:__(g?"If logged-in, pre-fill user's data on checkout.":"It won't pre-fill user's data on checkout.","lemon-squeezy"),onChange:this.onChangeUserData}),(0,e.jsx)(i,{label:__("Pre-fill from URL","lemon-squeezy"),checked:y,help:__(y?"If there are checkout query strings in URL, it'll pre-fill the checkout.":"It won't pre-fill URL data on checkout.","lemon-squeezy"),onChange:this.onChangeURLData}),(0,e.jsx)(i,{label:__("Show Logo","lemon-squeezy"),checked:m,help:__(m?"Show the Lemon Squeezy logo in the checkout.":"It won't show the Lemon Squeezy logo in the checkout.","lemon-squeezy"),onChange:this.onAttributeChange.bind(this,"showLogo")}),(0,e.jsx)(i,{label:__("Show Media","lemon-squeezy"),help:__(C?"Show the product media in the checkout.":"It won't show the product media in the checkout.","lemon-squeezy"),checked:C,onChange:this.onAttributeChange.bind(this,"showMedia")}),(0,e.jsx)(i,{label:__("Show Description","lemon-squeezy"),help:__(b?"Show the product description in the checkout.":"It won't show the product description in the checkout.","lemon-squeezy"),checked:b,onChange:this.onAttributeChange.bind(this,"showDescription")}),(0,e.jsx)(i,{label:__("Show Discount","lemon-squeezy"),help:__(k?"Show the product discount in the checkout.":"It won't show the product discount in the checkout.","lemon-squeezy"),checked:k,onChange:this.onAttributeChange.bind(this,"showDiscount")}),(0,e.jsx)(l,{title:__("Checkout colors","lemon-squeezy"),colorSettings:[{value:x,onChange:this.onAttributeChange.bind(this,"checkoutBackgroundColor"),label:__("Background","lemon-squeezy")},{value:j,onChange:this.onAttributeChange.bind(this,"checkoutLinksColor"),label:__("Links","lemon-squeezy")},{value:D,onChange:this.onAttributeChange.bind(this,"checkoutButtonColor"),label:__("Button","lemon-squeezy")},{value:w,onChange:this.onAttributeChange.bind(this,"checkoutButtonTextColor"),label:__("Button text","lemon-squeezy")},{value:M,onChange:this.onAttributeChange.bind(this,"checkoutTermsPrivacyColor"),label:__("Terms + Privacy","lemon-squeezy")}]})]}):(0,e.jsxs)("p",{children:[this.state.checkingApi&&(0,e.jsx)("small",{children:__("Checking connection status","lemon-squeezy")}),!this.state.checkingApi&&(0,e.jsxs)("small",{children:[__("Uh oh! Looks like you haven't connected your store yet! Please visit the","lemon-squeezy")," ",(0,e.jsx)("a",{href:lsData.settings_url,children:__("Lemon Squeezy Settings","lemon-squeezy")})," ",__("and connect to Lemon Squeezy.","lemon-squeezy")]})]})]:(0,e.jsx)("p",{children:(0,e.jsx)("small",{children:__("We're fetching your data, hold on for a second!","lemon-squeezy")})}))()]})})]})}},"extendControls");t("blocks.registerBlockType","lemon-squeezy/custom-attributes",function(e){return void 0!==e.attributes&&d.includes(e.name)&&(e.attributes=Object.assign(e.attributes,{overlay:{type:"boolean",default:!1},use_ls:{type:"boolean",default:!1},prefillUserData:{type:"boolean",default:!1},store:{type:"string",default:""},product:{type:"string",default:""},prefillFromURL:{type:"boolean",default:!1},showLogo:{type:"boolean",default:!0},showMedia:{type:"boolean",default:!0},showDescription:{type:"boolean",default:!0},showDiscount:{type:"boolean",default:!0},quantity:{type:"number",default:1},checkoutBackgroundColor:{type:"string"},checkoutLinksColor:{type:"string"},checkoutButtonColor:{type:"string"},checkoutButtonTextColor:{type:"string"},checkoutTermsPrivacyColor:{type:"string"}})),e}),t("editor.BlockEdit","lemon-squeezy/custom-advanced-control",p),t("blocks.getSaveContent.extraProps","lemon-squeezy/saveExtendedOptions",function(e,t,o){const{overlay:s,product:n}=o;return d.includes(t.name)&&(e.overlay=s,e.product=n),e});const g=window.wp.blocks,y=window.wp.blockEditor,m=window.wp.i18n;window.React;const C=window.wp.element,b=window.wp.components;class k extends C.Component{constructor(e){super(e),this.state={stores:[],products:[],isCheckingApi:!0,isApiConnectable:!1,isLoadingProducts:!1,newCustomDataKey:"",newCustomDataValue:""}}componentDidMount(){wp.apiFetch({path:"lsq/v1/stores"}).then(e=>{if(1==e.success&&(this.setState({stores:e.stores}),e.stores.length)){let t=e.stores.findIndex(e=>e.value==this.props.attributes.store);-1===t&&(t=0),this.getProducts(e.stores[t].value)}}),this.checkApi()}checkApi(){return wp.apiFetch({path:"lsq/v1/validate"}).then(e=>{1==e.success?this.setState({isApiConnectable:!0}):this.setState({isApiConnectable:!1})}).finally(()=>{this.setState({isCheckingApi:!1})})}getProducts(e){return this.setState({products:[],isLoadingProducts:!0}),wp.apiFetch({path:`lsq/v1/products?store_id=${e}`}).then(e=>{if(1==e.success&&(this.setState({products:e.products}),e.products.length)){let t=e.products.findIndex(e=>e.value==this.props.attributes.product);-1===t&&(t=0),this.props.setAttributes({product:e.products[t].value})}}).finally(()=>{this.setState({isLoadingProducts:!1})})}onChangeContent=e=>{this.props.setAttributes({content:e})};onChangeProduct=e=>{this.props.setAttributes({product:e})};onChangeStore=e=>{this.props.setAttributes({store:e}),this.getProducts(e)};onChangeOverlay=e=>{this.props.setAttributes({overlay:e})};onChangeUserData=e=>{this.props.setAttributes({prefillUserData:e})};onAttributeChange=(e,t)=>{this.props.setAttributes({[e]:t})};onChangeURLData=e=>{this.props.setAttributes({prefillFromURL:e})};handleRemoveCustomData=e=>{const t=[...this.props.attributes.customData];t.splice(e,1),this.props.setAttributes({customData:t})};handleCustomDataKeyChange=(e,t)=>{const o=[...this.props.attributes.customData];o[t].key=e,this.props.setAttributes({customData:o})};handleCustomDataValueChange=(e,t)=>{const o=[...this.props.attributes.customData];o[t].value=e,this.props.setAttributes({customData:o})};handleAddCustomData(){if(!this.state.newCustomDataKey||!this.state.newCustomDataValue)return void alert("Please Insert Key & Value");const e=[...this.props.attributes.customData];e.push({key:this.state.newCustomDataKey,value:this.state.newCustomDataValue}),this.setState({newCustomDataKey:"",newCustomDataValue:""}),this.props.setAttributes({customData:e})}render(){const{attributes:t,textColor:o,setTextColor:s,backgroundColor:n,setBackgroundColor:l}=this.props,{content:a,store:i,product:u,overlay:r,prefillUserData:c,prefillFromURL:h,customData:d,showLogo:p,showMedia:g,showDescription:k,showDiscount:z,quantity:x,checkoutBackgroundColor:j,checkoutLinksColor:D,checkoutButtonColor:w,checkoutButtonTextColor:M,checkoutTermsPrivacyColor:_}=t;let q=[];return d.length&&(q=d.map((t,o)=>(0,e.jsx)(C.Fragment,{children:(0,e.jsxs)("div",{className:"lemonsqueezy-custom-data-row",children:[(0,e.jsx)(b.TextControl,{placeholder:"Examples: user_name, user_id",value:t.key,onChange:e=>this.handleCustomDataKeyChange(e,o)}),(0,e.jsx)(b.TextControl,{placeholder:"Examples: JoshSmith, 123",value:t.value,onChange:e=>this.handleCustomDataValueChange(e,o)}),(0,e.jsx)(b.Button,{onClick:()=>this.handleRemoveCustomData(o),variant:"secondary",size:"small",children:"- Remove"})]})},o))),(0,e.jsxs)("div",{className:"lsq-block",children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("img",{src:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjBweCIgaGVpZ2h0PSIxOHB4IiB2aWV3Qm94PSIwIDAgMTI4IDE3NCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00My4yODY3IDEwNi43OTVMOTAuMjE1NSAxMjguMzc1Qzk2LjAzMTkgMTMxLjA1MSAxMDAuMTM4IDEzNS41NDIgMTAyLjM1NSAxNDAuNjk0QzEwNy45NjMgMTUzLjczOSAxMDAuMjk4IDE2Ny4wODEgODguMjY1OCAxNzEuODc5Qzc2LjIzMTYgMTc2LjY3NiA2My40MDYxIDE3My41ODkgNTcuNTc0NCAxNjAuMDIzTDM3LjE1MTEgMTEyLjM5NEMzNS41Njg0IDEwOC43MDIgMzkuNTQ0MSAxMDUuMDc0IDQzLjI4NjcgMTA2Ljc5NSIgZmlsbD0iI0ZGQzIzMyIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTQ2LjEwNTQgOTIuODI2NEw5NC41NDggNzQuNjEyNkMxMTAuNjQ4IDY4LjU1OTEgMTI4LjIzNSA4MC4wMTI3IDEyNy45OTggOTYuNjU0N0MxMjcuOTk0IDk2Ljg3MTkgMTI3Ljk5IDk3LjA4OTEgMTI3Ljk4NCA5Ny4zMDgxQzEyNy42MzYgMTEzLjUxNCAxMTAuNTM5IDEyNC40MDYgOTQuNzkyNyAxMTguNjczTDQ2LjE1MTMgMTAwLjk2NUM0Mi4yNzExIDk5LjU1MzUgNDIuMjQyNSA5NC4yNzg2IDQ2LjEwNTQgOTIuODI2NCIgZmlsbD0iI0ZGQzIzMyIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTQzLjM5IDg2LjUxNzVMOTEuMDEwNyA2Ni4zOTE0QzEwNi44MzUgNTkuNzAyOSAxMTAuODUxIDM5LjYyODMgOTguNDU3NSAyOC4wMjk0Qzk4LjI5NTEgMjcuODc2NiA5OC4xMzI2IDI3LjcyNTcgOTcuOTY4MiAyNy41NzQ3Qzg1LjgxNzQgMTYuMzU2NyA2NS43MzA1IDIwLjMwNjUgNTguODEzMSAzNS4wODIyTDM3LjQ0MzYgODAuNzMyOEMzNS43Mzg2IDg0LjM3MzMgMzkuNTkyIDg4LjEyMjUgNDMuMzkgODYuNTE3NSIgZmlsbD0iI0ZGQzIzMyIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTMxLjEzNTYgNzguNTY0Mkw0OC40NDkxIDMxLjM0NTZDNTAuNTk1NiAyNS40OTA5IDUwLjE5OCAxOS41MjAyIDQ3Ljk3ODkgMTQuMzY4NkM0Mi4zNTk0IDEuMzI4NDggMjcuMTQwOCAtMi44ODA4IDE1LjExMDQgMS45MjQ4MUMzLjA4MTkxIDYuNzMyMjYgLTMuNzE1MDQgMTcuNjUwMiAyLjEyODEyIDMxLjIxMTJMMjIuNjg1MyA3OC43ODg4QzI0LjI3OTQgODIuNDc1MyAyOS43NTU2IDgyLjMyOTkgMzEuMTM1NiA3OC41NjQyIiBmaWxsPSIjRkZDMjMzIi8+Cjwvc3ZnPg=="}),(0,m.__)("Lemon Squeezy Buy Button","lemon-squeezy")]}),this.state&&!this.state.isCheckingApi?[this.state.isApiConnectable?(0,e.jsxs)(C.Fragment,{children:[(0,e.jsxs)(y.InspectorControls,{children:[(0,e.jsx)(y.PanelColorSettings,{title:(0,m.__)("Button colors","lemon-squeezy"),colorSettings:[{value:o.color,onChange:s,label:(0,m.__)("Text","lemon-squeezy")},{value:n.color,onChange:l,label:(0,m.__)("Background","lemon-squeezy")}]}),(0,e.jsx)(y.PanelColorSettings,{title:(0,m.__)("Checkout colors","lemon-squeezy"),colorSettings:[{value:j,onChange:this.onAttributeChange.bind(this,"checkoutBackgroundColor"),label:(0,m.__)("Background","lemon-squeezy")},{value:D,onChange:this.onAttributeChange.bind(this,"checkoutLinksColor"),label:(0,m.__)("Links","lemon-squeezy")},{value:w,onChange:this.onAttributeChange.bind(this,"checkoutButtonColor"),label:(0,m.__)("Button","lemon-squeezy")},{value:M,onChange:this.onAttributeChange.bind(this,"checkoutButtonTextColor"),label:(0,m.__)("Button text","lemon-squeezy")},{value:_,onChange:this.onAttributeChange.bind(this,"checkoutTermsPrivacyColor"),label:(0,m.__)("Terms + Privacy","lemon-squeezy")}]})]}),(0,e.jsx)(b.SelectControl,{label:(0,m.__)("Store","lemon-squeezy"),value:i,options:this.state.stores,onChange:this.onChangeStore}),this.state.isLoadingProducts?(0,e.jsx)("span",{style:{fontSize:"14px",color:"rgb(117, 117, 117)"},children:(0,m.__)("Loading...","lemon-squeezy")}):this.state.products.length?(0,e.jsx)(b.SelectControl,{label:(0,m.__)("Product","lemon-squeezy"),value:u,options:this.state.products,onChange:this.onChangeProduct}):(0,e.jsx)("span",{style:{fontSize:"14px",color:"rgb(117, 117, 117)"},children:(0,m.__)("No products found","lemon-squeezy")}),(0,e.jsx)(b.BaseControl,{label:(0,m.__)("Button text","lemon-squeezy"),__nextHasNoMarginBottom:!0}),(0,e.jsx)(y.RichText,{placeholder:(0,m.__)("Button text","lemon-squeezy"),tagName:"p",className:"lsq-link-text",onChange:this.onChangeContent,value:a}),(0,e.jsx)(b.__experimentalNumberControl,{label:(0,m.__)("Quantity","lemon-squeezy"),__next40pxDefaultSize:!0,isShiftStepEnabled:!0,shiftStep:1,value:x,onChange:this.onAttributeChange.bind(this,"quantity")}),(0,e.jsxs)("div",{className:"lsq-block-settings",children:[(0,e.jsx)(b.ToggleControl,{label:(0,m.__)("Use checkout overlay?","lemon-squeezy"),help:r?(0,m.__)("Your checkout will be opened in a modal window.","lemon-squeezy"):(0,m.__)("Your customer will be redirected to your checkout page.","lemon-squeezy"),checked:r,onChange:this.onChangeOverlay}),(0,e.jsx)(b.ToggleControl,{label:(0,m.__)("Pre-fill User Data","lemon-squeezy"),checked:c,help:c?(0,m.__)("If logged-in, pre-fill user's data on checkout.","lemon-squeezy"):(0,m.__)("It won't pre-fill user's data on checkout.","lemon-squeezy"),onChange:this.onChangeUserData}),(0,e.jsx)(b.ToggleControl,{label:(0,m.__)("Pre-fill from URL","lemon-squeezy"),checked:h,help:h?(0,m.__)("If there are checkout query strings in URL, it'll pre-fill the checkout.","lemon-squeezy"):(0,m.__)("It won't pre-fill URL data on checkout.","lemon-squeezy"),onChange:this.onChangeURLData}),(0,e.jsx)(b.ToggleControl,{label:(0,m.__)("Show Logo","lemon-squeezy"),checked:p,help:p?(0,m.__)("Show the Lemon Squeezy logo in the checkout.","lemon-squeezy"):(0,m.__)("It won't show the Lemon Squeezy logo in the checkout.","lemon-squeezy"),onChange:this.onAttributeChange.bind(this,"showLogo")}),(0,e.jsx)(b.ToggleControl,{label:(0,m.__)("Show Media","lemon-squeezy"),help:g?(0,m.__)("Show the product media in the checkout.","lemon-squeezy"):(0,m.__)("It won't show the product media in the checkout.","lemon-squeezy"),checked:g,onChange:this.onAttributeChange.bind(this,"showMedia")}),(0,e.jsx)(b.ToggleControl,{label:(0,m.__)("Show Description","lemon-squeezy"),help:k?(0,m.__)("Show the product description in the checkout.","lemon-squeezy"):(0,m.__)("It won't show the product description in the checkout.","lemon-squeezy"),checked:k,onChange:this.onAttributeChange.bind(this,"showDescription")}),(0,e.jsx)(b.ToggleControl,{label:(0,m.__)("Show Discount","lemon-squeezy"),help:z?(0,m.__)("Show the product discount in the checkout.","lemon-squeezy"):(0,m.__)("It won't show the product discount in the checkout.","lemon-squeezy"),checked:z,onChange:this.onAttributeChange.bind(this,"showDiscount")})]}),(0,e.jsx)("p",{children:(0,e.jsxs)("small",{className:"lemonsqueezy-custom-data-header",children:[(0,e.jsx)("strong",{children:"Custom Data"}),(0,e.jsx)("br",{}),(0,e.jsx)(b.Button,{size:"small",variant:"link",href:"https://docs.lemonsqueezy.com/help/checkout/passing-custom-data",target:"_blank",children:"Read more about custom data"})]})}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"lemonsqueezy-custom-data-row",children:[(0,e.jsx)(b.TextControl,{label:(0,m.__)("Data Key","lemon-squeezy"),placeholder:(0,m.__)("Data Key","lemon-squeezy"),value:this.state.newCustomDataKey,onChange:e=>this.setState({newCustomDataKey:e})}),(0,e.jsx)(b.TextControl,{label:(0,m.__)("Data Value","lemon-squeezy"),placeholder:(0,m.__)("Data Value","lemon-squeezy"),value:this.state.newCustomDataValue,onChange:e=>this.setState({newCustomDataValue:e})}),(0,e.jsx)(b.Button,{onClick:()=>this.handleAddCustomData(),variant:"secondary",size:"small",children:"+ Add Data"})]}),q]})]}):(0,e.jsx)("p",{children:(0,e.jsxs)("small",{children:[(0,m.__)("Uh oh! Looks like you haven't connected your store yet! Please visit the","lemon-squeezy")," ",(0,e.jsx)("a",{href:lsData.settings_url,children:(0,m.__)("Lemon Squeezy Settings","lemon-squeezy")})," ",(0,m.__)("and connect to Lemon Squeezy.","lemon-squeezy")]})})]:(0,e.jsx)("p",{children:(0,e.jsx)("small",{children:(0,m.__)("We're fetching your data, hold on for a second!","lemon-squeezy")})})]})}}const z=(0,y.withColors)("backgroundColor",{textColor:"color"})(k),x={content:{type:"string"},overlay:{type:"boolean"},store:{type:"string"},product:{type:"string"},textColor:{type:"string"},customTextColor:{type:"string"},backgroundColor:{type:"string"},customBackgroundColor:{type:"string"},prefillUserData:{type:"boolean",default:!1},prefillFromURL:{type:"boolean",default:!1},showLogo:{type:"boolean",default:!0},showMedia:{type:"boolean",default:!0},showDescription:{type:"boolean",default:!0},showDiscount:{type:"boolean",default:!0},quantity:{type:"number",default:1},customData:{type:"array",default:[]},checkoutBackgroundColor:{type:"string"},checkoutLinksColor:{type:"string"},checkoutButtonColor:{type:"string"},checkoutButtonTextColor:{type:"string"},checkoutTermsPrivacyColor:{type:"string"}};(0,g.registerBlockType)("lemonsqueezy/ls-button",{title:"Lemon Squeezy",description:(0,m.__)("The Lemon Squeezy Product Block","lemon-squeezy"),category:"lemonsqueezy",icon:(0,e.jsxs)("svg",{width:"118",height:"160",viewBox:"0 0 118 160",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,e.jsx)("path",{d:"M39.5904 98.2021L82.512 118.046C87.8317 120.507 91.5868 124.636 93.6147 129.373C98.7439 141.369 91.7337 153.638 80.7288 158.05C69.7222 162.46 57.9919 159.622 52.6582 147.147L33.9787 103.35C32.5312 99.9554 36.1675 96.6196 39.5904 98.2021",fill:"#000000"}),(0,e.jsx)("path",{d:"M42.1685 85.3576L86.4746 68.6093C101.2 63.0429 117.285 73.5749 117.068 88.8779C117.064 89.0776 117.061 89.2773 117.056 89.4787C116.738 104.381 101.1 114.396 86.6984 109.124L42.2105 92.8416C38.6616 91.5435 38.6354 86.693 42.1685 85.3576",fill:"#000000"}),(0,e.jsx)("path",{d:"M39.6849 79.5563L83.2393 61.0496C97.7126 54.8992 101.386 36.4398 90.0502 25.7741C89.9017 25.6336 89.7531 25.4949 89.6027 25.3561C78.4895 15.0407 60.1177 18.6727 53.791 32.2595L34.2463 74.237C32.6869 77.5847 36.2112 81.0321 39.6849 79.5563",fill:"#000000"}),(0,e.jsx)("path",{d:"M28.4769 72.243L44.312 28.8235C46.2753 23.4399 45.9116 17.9496 43.882 13.2125C38.7423 1.22159 24.8232 -2.64901 13.8201 1.76994C2.81875 6.19058 -3.39781 16.2301 1.9464 28.7L20.7482 72.4494C22.2062 75.8394 27.2147 75.7057 28.4769 72.243",fill:"#000000"})]}),keywords:[(0,m.__)("ecommerce","lemon-squeezy"),(0,m.__)("product","lemon-squeezy"),(0,m.__)("digital","lemon-squeezy"),(0,m.__)("digital products","lemon-squeezy")],attributes:x,deprecated:[{attributes:x,save:({attributes:t})=>{const{content:o,overlay:s,product:n}=t;let l=n,a=["wp-block-button__link"];return s&&(a.push("lemonsqueezy-button"),l=n+"?embed=1"),(0,e.jsx)("div",{className:"wp-block-buttons",children:(0,e.jsx)("div",{className:"wp-block-button",children:(0,e.jsx)("a",{className:a.join(" "),href:l,children:o})})})}}],edit:z,save:({attributes:t})=>{const{content:o,overlay:s,product:n,textColor:l,customTextColor:a,backgroundColor:i,customBackgroundColor:u}=t;let r=n,c={},h=["wp-block-button__link"];return s&&(h.push("lemonsqueezy-button"),r=n+"?embed=1"),null!=l&&h.push((0,y.getColorClassName)("color",l)),null!=i&&h.push((0,y.getColorClassName)("background-color",i)),null!=a&&(c.color=a),null!=u&&(c.backgroundColor=u),(0,e.jsx)("div",{className:"wp-block-buttons",children:(0,e.jsx)("div",{className:"wp-block-button",children:(0,e.jsx)("a",{style:c,className:h.join(" "),href:r,children:o})})})}})})(); |