FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
packages
/
blocks-next
/
build
/
blocks
/
product-page
Edit File: index.js
!function(){"use strict";var e,t={7005:function(e,t,r){var o=r(1609),a=Symbol.for("react.element"),n=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),l=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var o,s={},i=null,p=null;for(o in void 0!==r&&(i=""+r),void 0!==t.key&&(i=""+t.key),void 0!==t.ref&&(p=t.ref),t)n.call(t,o)&&!c.hasOwnProperty(o)&&(s[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===s[o]&&(s[o]=t[o]);return{$$typeof:a,type:e,key:i,ref:p,props:s,_owner:l.current}}t.jsx=s,t.jsxs=s},9255:function(e,t,r){e.exports=r(7005)},6935:function(e,t,r){var o=window.wp.blocks,a=window.wp.primitives,n=r(9255),l=(0,n.jsxs)(a.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[(0,n.jsx)(a.Path,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),(0,n.jsx)(a.Path,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})]}),c=window.wp.data,s=window.wp.element,i=window.wp.blockEditor,p=window.wp.coreData,u=window.wp.components,d=(0,n.jsx)(a.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,n.jsx)(a.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})}),m=window.wp.i18n,f=[["core/columns",{style:{spacing:{blockGap:{top:"30px",left:"60px"}}}},[["core/column",{width:"50%"},[["surecart/product-media"]]],["core/column",{width:"50%"},[["surecart/product-collection-tags",{count:1},[["surecart/product-collection-tag"]]],["core/group",{style:{spacing:{blockGap:"10px",padding:{right:"0px",left:"0px"}}},layout:{type:"flex",flexWrap:"nowrap"}},[["surecart/product-review-average-rating-stars"],["surecart/product-review-total-rating",{className:"is-style-plus-sign",style:{spacing:{blockGap:"4px"}}}]]],["surecart/product-title",{style:{typography:{fontSize:"32px"}}}],["core/group",{style:{spacing:{blockGap:"0",padding:{right:"0px",left:"0px"}}},layout:{type:"constrained"}},[["core/group",{style:{spacing:{blockGap:"0.5em",padding:{right:"0px",left:"0px"}}},layout:{type:"flex",flexWrap:"nowrap",justifyContent:"left"}},[["surecart/product-selected-price-scratch-amount",{style:{typography:{textDecoration:"line-through",fontSize:"24px"},color:{text:"#8a8a8a"},elements:{link:{color:{text:"#8a8a8a"}}}}}],["surecart/product-selected-price-amount",{style:{typography:{fontSize:"24px"}}}],["surecart/product-sale-badge",{text:"Sale",style:{border:{radius:"15px"},typography:{fontSize:"12px"},layout:{selfStretch:"fit",flexSize:null},elements:{link:{color:{text:"#fff"}}}},textColor:"white"}]]],["core/group",{style:{spacing:{blockGap:"0.5em",padding:{right:"0px",left:"0px"}}},layout:{type:"flex",flexWrap:"nowrap"}},[["surecart/product-selected-price-trial",{style:{color:{text:"#8a8a8a"},elements:{link:{color:{text:"#8a8a8a"}}}}}],["surecart/product-selected-price-fees",{style:{color:{text:"#8a8a8a"},elements:{link:{color:{text:"#8a8a8a"}}}}}]]]]],["surecart/product-description"],["surecart/product-variant-pills",[["surecart/product-variant-pills-wrapper",[["surecart/product-variant-pill"]]]]],["surecart/product-price-chooser",[["surecart/product-price-choice-template",{layout:{type:"flex",justifyContent:"left",flexWrap:"nowrap",orientation:"vertical"}},[["surecart/price-name"],["core/group",{style:{spacing:{blockGap:"0px",padding:{right:"0px",left:"0px"}}},layout:{type:"flex",orientation:"vertical",justifyContent:"right"}},[["core/group",{style:{spacing:{blockGap:"0.5rem",padding:{right:"0px",left:"0px"}}},layout:{type:"flex",flexWrap:"nowrap",justifyContent:"left"}},[["surecart/price-scratch-amount",{style:{elements:{link:{color:{text:"#686868"}}},typography:{fontStyle:"normal",fontWeight:"700",textDecoration:"line-through"}},textColor:"#686868"},[]],["surecart/price-amount",{style:{elements:{link:{color:{text:"var:preset|color|accent-3"}}},typography:{fontStyle:"normal",fontWeight:"700"}},textColor:"accent-3"},[]],["surecart/price-interval",{style:{elements:{link:{color:{text:"var:preset|color|accent-3"}}},typography:{fontStyle:"normal",fontWeight:"700"}},textColor:"accent-3"},[]]]],["surecart/price-trial",{style:{color:{text:"#8a8a8a"},elements:{link:{color:{text:"#8a8a8a"}}}},fontSize:"small"}],["surecart/price-setup-fee",{style:{color:{text:"#8a8a8a"},elements:{link:{color:{text:"#8a8a8a"}}}},fontSize:"small"}]]]]]]],["surecart/product-quantity"],["surecart/product-selected-price-ad-hoc-amount"],["surecart/product-buy-buttons",{class:"wp-block-surecart-product-buy-buttons wp-block-buttons sc-block-buttons is-layout-flex"},[["surecart/product-buy-button",{add_to_cart:!0,text:"Add To Cart"}],["surecart/product-buy-button",{text:"Buy Now",style:"outline"}]]]]]]]],y=(window.wp.htmlEntities,window.wp.compose);function g(e,t,r){const a=(0,c.useSelect)((e=>e(o.store).getActiveBlockVariation(r,t)?.name),[t]),n=`${r}/${a}`;return(0,c.useSelect)((t=>{if(!a)return!1;const{getBlockRootClientId:r,getPatternsByBlockTypes:o}=t(i.store),l=r(e);return o(n,l).length>0}),[e,a,n])?n:r}const h=(e,t)=>(0,c.useSelect)((r=>{const{getBlockRootClientId:o,getPatternsByBlockTypes:a}=r(i.store),n=o(e);return a(t,n)}),[t,e]);var _=e=>{let{openPatternSelectionModal:t,name:r,clientId:o}=e;const a=!!h(o,r).length;return React.createElement(React.Fragment,null,a&&React.createElement(u.ToolbarGroup,{className:"wp-block-template-part__block-control-group"},React.createElement(u.ToolbarButton,{onClick:t},(0,m.__)("Replace"))))},k=r(1609),x=r.n(k);function v(){return v=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)({}).hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},v.apply(null,arguments)}function w(e){let{name:t,...r}=e;const[o,a]=(0,k.useState)(null),n=window?.scData?.plugin_url+"/dist/icon-assets",l=/^[a-zA-Z0-9_-]+$/.test(t);if((0,k.useEffect)((()=>{l&&fetch(`${n}/${t}.svg`).then((e=>e.text())).then((e=>{const t=(new DOMParser).parseFromString(e,"image/svg+xml"),r=t?.documentElement;"svg"===r?.tagName?.toLowerCase()&&a(r)})).catch(console.error)}),[t,l]),!o)return null;const c={class:"className","clip-path":"clipPath","clip-rule":"clipRule","color-interpolation-filters":"colorInterpolationFilters","fill-opacity":"fillOpacity","fill-rule":"fillRule","flood-opacity":"floodOpacity","font-size":"fontSize","stop-color":"stopColor","stop-opacity":"stopOpacity","stroke-dasharray":"strokeDasharray","stroke-dashoffset":"strokeDashoffset","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","stroke-miterlimit":"strokeMiterlimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth"},s={};for(const e of o.attributes)s[c[e.name]||e.name]=e.value;return x().createElement("svg",v({},s,r,{dangerouslySetInnerHTML:{__html:o.innerHTML}}))}function b(e){let{title:t,subtitle:r,url:o,imageUrl:a,controls:n}=e;return React.createElement(u.__experimentalHStack,{spacing:3,align:"center",justify:"flex-start"},React.createElement("div",{style:{width:"48px",height:"48px",borderRadius:"4px",backgroundColor:"#f0f0f0",flexShrink:0,overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"}},a?React.createElement("img",{src:a,alt:(0,m.__)("Product image","surecart"),style:{width:"100%",height:"100%",objectFit:"cover"}}):React.createElement(w,{name:"image",width:"24",height:"24",style:{opacity:.5}})),React.createElement(u.FlexBlock,{style:{minWidth:0}},React.createElement(u.__experimentalVStack,{spacing:0},React.createElement("span",{style:{display:"flex",alignItems:"center",gap:"4px",fontWeight:500,fontSize:"13px",overflow:"hidden"}},React.createElement("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},t)),!!r&&React.createElement("span",{style:{fontSize:"12px",color:"#757575",display:"block",marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},r))),n)}function R(e){let{isVisible:t,post:r,onChoose:o,...a}=e;if(!t)return null;const n={type:"post",subtype:"sc_product",perPage:20};return React.createElement(u.Popover,a,React.createElement(i.LinkControl,{value:r?.link,onChange:o,showInitialSuggestions:!0,hasTextControl:!0,searchInputPlaceholder:(0,m.__)("Search for a product","surecart"),suggestionsQuery:{...n,initialSuggestionsSearchOptions:n}}))}function E(e,t){return(0,c.useSelect)((r=>{const{getCurrentPostType:o,getCurrentPostId:a}=r("core/editor")||{},n=o?.()||null,l=a?.();return e.includes(n)&&t.some((e=>l?.includes(e)))}),[e,t])}function S(e){let{name:t,clientId:r,openPatternSelectionModal:o,attributes:a,setAttributes:n}=e;const l=a?.product_post_id,[y,g]=(0,s.useState)(!1),h=(0,i.useBlockProps)({className:"sc-product-page__editor-container"}),k=(0,i.useInnerBlocksProps)(h,{template:f,renderAppender:i.InnerBlocks.ButtonBlockAppender}),x=E(["wp_template","wp_template_part"],["wp_template_part","wp_template","surecart/surecart//product-info","surecart/surecart//single-sc_product"]),{post:v,loading:w}=(0,c.useSelect)((e=>{if(!l)return{post:null,loading:!1};const t=["postType","sc_product",l];return{post:e(p.store).getEntityRecord(...t),loading:e(p.store).isResolving("getEntityRecord",t)}}),[l]);return React.createElement(React.Fragment,null,React.createElement(i.BlockControls,null,React.createElement(_,{name:t,clientId:r,openPatternSelectionModal:o})),!x&&React.createElement(i.InspectorControls,null,React.createElement(u.PanelBody,{title:(0,m.__)("Product","surecart")},React.createElement(u.Card,null,React.createElement(u.CardBody,{style:{padding:"var(--sc-spacing-medium)"}},w&&React.createElement("div",{style:{textAlign:"center"}},React.createElement(u.Spinner,null)),v?.id&&React.createElement(b,{title:v?.title?.rendered,subtitle:v?.link,url:v?.link,imageUrl:v?.gallery?.[0]?.url,controls:React.createElement(u.Button,{icon:d,label:(0,m.__)("Replace Product","surecart"),onClick:()=>g(!y),size:"compact",showTooltip:!0},React.createElement(R,{isVisible:y,post:v,onChoose:e=>{n({product_post_id:e.id}),g(!1)},onClose:()=>g(!1)}))}))))),React.createElement("div",k))}var C=(0,n.jsx)(a.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,n.jsx)(a.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"})});function B(e){let{attributes:t,setAttributes:r,clientId:a,name:n,openPatternSelectionModal:l}=e;const d=t?.product_post_id,[y,h]=(0,s.useState)(!1),{replaceInnerBlocks:_}=(0,c.useDispatch)(i.store),k=(0,i.useBlockProps)(),x=g(a,t,n),{blockType:v,activeBlockVariation:w,hasPatterns:S}=(0,c.useSelect)((e=>{const{getActiveBlockVariation:r,getBlockType:l}=e(o.store),{getBlockRootClientId:c,getPatternsByBlockTypes:s}=e(i.store),p=c(a);return{blockType:l(n),activeBlockVariation:r(n,t),hasPatterns:!!s(x,p).length}}),[n,x,a,t]),B=w?.icon?.src||w?.icon||v?.icon?.src,P=w?.title||v?.title,O=E(["wp_template","wp_template_part"],["wp_template_part","wp_template","surecart/surecart//product-info","surecart/surecart//single-sc_product"]),I=O?(0,m.__)("Choose a pattern for the product page or start with a basic layout.","surecart"):(0,m.__)("Choose a product & pattern for the product page or start with a basic layout."),{post:j,loading:T}=(0,c.useSelect)((e=>{if(!d)return{post:null,loading:!1};const t=["postType","sc_product",d];return{post:e(p.store).getEntityRecord(...t),loading:e(p.store).isResolving("getEntityRecord",t)}}),[d]),M=()=>j?.id||O?React.createElement(u.Flex,{gap:4,justify:"start"},React.createElement(u.Button,{variant:"primary",onClick:()=>{const e=(0,o.createBlocksFromInnerBlocksTemplate)(f);e.forEach((e=>{"surecart/product-page"===e.name&&(e.attributes={...e.attributes,product_post_id:t.product_post_id})})),_(a,e,!1)}},(0,m.__)("Start with Basic Layout","surecart")),!!S&&React.createElement(u.Button,{variant:"secondary",onClick:l},(0,m.__)("Choose a pattern","surecart"))):null;return React.createElement("div",k,React.createElement(u.Placeholder,{icon:B,label:P,instructions:I},O?M():React.createElement("div",null,j?.id?React.createElement("div",{style:{marginBottom:"var(--sc-spacing-medium)"}},React.createElement(u.Card,null,React.createElement(u.CardBody,{style:{padding:"var(--sc-spacing-medium)"}},React.createElement(b,{title:j?.title?.rendered,subtitle:j?.link,url:j?.link,imageUrl:j?.gallery?.[0]?.url,controls:React.createElement(u.Button,{icon:C,label:(0,m.__)("Remove","surecart"),onClick:()=>{r({product_post_id:null}),h(!1)},size:"compact",showTooltip:!0})})))):null,j?.id?null:React.createElement("div",{style:{minWidth:"500px"}},React.createElement(u.Button,{variant:"primary",onClick:()=>h(!y),isBusy:T},(0,m.__)("Choose Product","surecart"),React.createElement(R,{isVisible:y,post:j,onChoose:e=>{r({product_post_id:e?.id})},onClose:()=>h(!1)}))),M())))}function P(e){let{clientId:t,attributes:r,setIsPatternSelectionModalOpen:a,name:n}=e;const[l,p]=(0,s.useState)(""),{replaceBlock:d,selectBlock:f}=(0,c.useDispatch)(i.store),_=(0,s.useMemo)((()=>({previewPostType:"sc_product"})),["sc_product"]),k=g(t,r,n),x=h(t,k),v=(0,s.useMemo)((()=>function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(!t)return e;const r=e.map((e=>[e,getPatternSearchRank(e,t)])).filter((e=>{let[,t]=e;return t>0}));return r.sort(((e,t)=>{let[,r]=e,[,o]=t;return o-r})),r.map((e=>{let[t]=e;return t}))}(x,l)),[x,l]),w=(0,y.useAsyncList)(v);return React.createElement(u.Modal,{overlayClassName:"block-library-query-pattern__selection-modal",title:(0,m.__)("Choose a pattern","surecart"),onRequestClose:()=>a(!1),isFullScreen:!0},React.createElement("div",{className:"block-library-query-pattern__selection-content"},React.createElement("div",{className:"block-library-query-pattern__selection-search"},React.createElement(u.SearchControl,{__nextHasNoMarginBottom:!0,onChange:p,value:l,label:(0,m.__)("Search for patterns","surecart"),placeholder:(0,m.__)("Search","surecart")})),React.createElement(i.BlockContextProvider,{value:_},React.createElement(i.__experimentalBlockPatternsList,{blockPatterns:v,shownPatterns:w,onClickPattern:(e,a)=>{const{newBlocks:l,queryClientIds:c}=((e,t,r)=>{const{namespace:a}=t,n=e.map((e=>(0,o.cloneBlock)(e))),l=[],c=[...n];for(;c.length>0;){const e=c.shift();e.name===r&&(a&&(e.attributes.namespace=a),l.push(e.clientId)),e.innerBlocks?.forEach((e=>{c.push(e)}))}return{newBlocks:n,queryClientIds:l}})(a,r,n);l[0]&&(l[0].attributes={...l[0].attributes,...r}),d(t,l),c[0]&&f(c[0])}}))))}function O(){return O=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)({}).hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},O.apply(null,arguments)}var I=JSON.parse('{"UU":"surecart/product-page"}');(0,o.registerBlockType)(I.UU,{edit:e=>{const{clientId:t,attributes:r,name:o}=e,[a,n]=(0,s.useState)(!1),l=(0,c.useSelect)((e=>!!e(i.store).getBlocks(t).length),[t]),u=(0,c.useSelect)((e=>{const{getEntityRecord:t}=e(p.store),o=r?.product_post_id;return o?t("postType","sc_product",o):null}),[r?.product_post_id]),d=(0,s.useMemo)((()=>({...u?.type?{postType:u.type}:{},...u?.id?{postId:u.id}:{},...u?.class_list?{classList:u.class_list}:{},...o?{providerBlock:o}:{}})),[u,o]),m=l?S:B;return React.createElement(React.Fragment,null,React.createElement(i.BlockContextProvider,{key:d?.postId,value:d},React.createElement(m,O({},e,{openPatternSelectionModal:()=>n(!0)}))),a&&React.createElement(P,{clientId:t,attributes:r,setIsPatternSelectionModalOpen:n,name:o}))},save:function(){return React.createElement(i.InnerBlocks.Content,null)},icon:l})},1609:function(e){e.exports=window.React}},r={};function o(e){var a=r[e];if(void 0!==a)return a.exports;var n=r[e]={exports:{}};return t[e](n,n.exports,o),n.exports}o.m=t,e=[],o.O=function(t,r,a,n){if(!r){var l=1/0;for(p=0;p<e.length;p++){r=e[p][0],a=e[p][1],n=e[p][2];for(var c=!0,s=0;s<r.length;s++)(!1&n||l>=n)&&Object.keys(o.O).every((function(e){return o.O[e](r[s])}))?r.splice(s--,1):(c=!1,n<l&&(l=n));if(c){e.splice(p--,1);var i=a();void 0!==i&&(t=i)}}return t}n=n||0;for(var p=e.length;p>0&&e[p-1][2]>n;p--)e[p]=e[p-1];e[p]=[r,a,n]},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,{a:t}),t},o.d=function(e,t){for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e={8002:0,4710:0};o.O.j=function(t){return 0===e[t]};var t=function(t,r){var a,n,l=r[0],c=r[1],s=r[2],i=0;if(l.some((function(t){return 0!==e[t]}))){for(a in c)o.o(c,a)&&(o.m[a]=c[a]);if(s)var p=s(o)}for(t&&t(r);i<l.length;i++)n=l[i],o.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return o.O(p)},r=self.webpackChunk_surecart_blocks_next=self.webpackChunk_surecart_blocks_next||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))}();var a=o.O(void 0,[4710],(function(){return o(6935)}));a=o.O(a)}();
Save
Back