efficient-storefront-blocks 0.23.0 → 0.24.0

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.
Files changed (30) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +3 -0
  3. package/dist/chunks/{EditorPreviewCheckout-54OF6GQB.js → EditorPreviewCheckout-URFSPLP6.js} +1 -1
  4. package/dist/chunks/PreviewFooter-O62NXXGX.js +1 -0
  5. package/dist/chunks/SiteEditorProvider-ZSJ42NW3.js +1 -0
  6. package/dist/chunks/{chunk-YSV4ASRS.js → chunk-5FWFXNTA.js} +1 -1
  7. package/dist/chunks/chunk-6LQRNNZN.js +154 -0
  8. package/dist/chunks/chunk-D42IBF3T.js +230 -0
  9. package/dist/chunks/chunk-E27PWVTV.js +16 -0
  10. package/dist/chunks/{chunk-HURDX4EH.js.LEGAL.txt → chunk-E27PWVTV.js.LEGAL.txt} +3 -0
  11. package/dist/chunks/{chunk-NYX4XTRE.js → chunk-RVAMC6AG.js} +1 -1
  12. package/dist/chunks/chunk-XMRDC5JK.js +1 -0
  13. package/dist/chunks/{fitment-data-AFUGFEWT.js → fitment-data-QCRJYMQI.js} +1 -1
  14. package/dist/chunks/render-client-MWQL3FXI.js +1 -0
  15. package/dist/contract.js +1 -1
  16. package/dist/editor.css +1 -1
  17. package/dist/index.d.ts +8 -0
  18. package/dist/index.js +21 -123
  19. package/dist/links.js +1 -1
  20. package/package.json +3 -3
  21. package/dist/chunks/PreviewFooter-FVRZAZLF.js +0 -1
  22. package/dist/chunks/SiteEditorProvider-F6KKDLMD.js +0 -1
  23. package/dist/chunks/chunk-6EH27IKS.js +0 -230
  24. package/dist/chunks/chunk-HURDX4EH.js +0 -16
  25. package/dist/chunks/chunk-HYLRHFHP.js +0 -1
  26. package/dist/chunks/chunk-MZOOSHH4.js +0 -153
  27. package/dist/chunks/render-client-KQRL2HNU.js +0 -1
  28. /package/dist/chunks/{SectionEditorShell-6KCRQP6C.js → SectionEditorShell-KPJJGNME.js} +0 -0
  29. /package/dist/chunks/{chunk-MZOOSHH4.js.LEGAL.txt → chunk-6LQRNNZN.js.LEGAL.txt} +0 -0
  30. /package/dist/chunks/{chunk-EJ2NLQYY.js → chunk-BXKNNBHR.js} +0 -0
package/dist/links.js CHANGED
@@ -1 +1 @@
1
- var j=["width","profile","rim"];var _e=/^\s*(\d{2,3})\s*\/\s*(\d{2,3})\s*[A-Za-z]*\s*(\d{2}(?:\.\d+)?)\s*$/,Ae={width:[100,500],profile:[20,100],rim:[10,30]};function N(e){let n=_e.exec(e??"");if(!n)return null;let t={width:Number(n[1]),profile:Number(n[2]),rim:Number(n[3])};return j.every(o=>{let[l,a]=Ae[o];return t[o]>=l&&t[o]<=a})?t:null}function x(e){if(e.width==null)return"";if(e.profile==null)return String(e.width);let n=`${e.width}/${e.profile}`;return e.rim==null?n:`${n} R${e.rim}`}function V(e){return[x({width:e.width}),x({width:e.width,profile:e.profile}),x(e)]}var h=["alloy-wheel","tyre"],Z=["alloy-wheel"],k={"alloy-wheel":"Alloy wheels",tyre:"Tyres"};var Qe=h.map(e=>({value:e,label:k[e]}));function O(e){return e==null?[...Z]:Array.isArray(e)?h.filter(n=>e.includes(n)):[...Z]}var f=e=>e;function d(e){return f(e).kind==="tyre"?"tyre":"alloy-wheel"}function U(e){return f(e).brand??""}function X(e){return f(e).prices??void 0}function J(e){return f(e).inStock!==!1}function Q(e){let n=f(e),t=d(e)==="tyre"?n.rimDiameters:n.sizes;return Array.isArray(t)?t.filter(r=>typeof r=="number"&&Number.isFinite(r)):[]}function z(e){return d(e)==="tyre"?[]:(f(e).finishes??[]).filter(n=>typeof n?.family=="string").map(n=>({family:n.family,color:n.color??null}))}function ee(e){return z(e).map(n=>n.family)}function ne(e){if(d(e)==="tyre")return[];let n=f(e),t=n.categories;return t&&t.length>0?t:n.process?[n.process]:[]}function te(e){return d(e)==="tyre"?[]:f(e).spec?.pcds??[]}function re(e){return d(e)!=="tyre"?[]:f(e).tyreTypes??[]}function ie(e){return d(e)!=="tyre"?[]:f(e).speedRatings??[]}function oe(e){if(d(e)!=="tyre")return[];let n=f(e).sizes;return Array.isArray(n)?n.map(t=>N(typeof t=="string"?t:null)).filter(t=>t!==null):[]}var se="homepage";function le(e){return(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}var L=[{value:"page",label:"Page"},{value:"anchor",label:"Anchor"},{value:"blog",label:"Blog post",needs:"service"},{value:"product",label:"Product",needs:"commerce"},{value:"custom",label:"Custom URL"}];function F(e){return e.offersCommerce&&e.offersService?L:L.filter(n=>!n.needs||(n.needs==="commerce"?e.offersCommerce:e.offersService))}function g(e){return e===se?"/":`/${e}`}function w(e){return`/journal/${e}`}function T(e){return`/wheels/${e}`}function _(e,n){return`${g(e)}#${n}`}function D(e){return le(e)}function Ie(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.text=="string"?e.text.trim():""}function A(...e){let n=new Set,t=[];for(let r of e)for(let o of r?.content??[]){let l=Ie(o?.props?.anchor);if(!l)continue;let a=D(l);!a||n.has(a)||(n.add(a),t.push({slug:a,name:l}))}return t}var Re=["http","https","mailto","tel"];function S(e){let n=e.trim();if(!n||/\s/.test(n))return!1;let t=/^([a-z][a-z0-9+.-]*):/i.exec(n);return!t||Re.includes(t[1].toLowerCase())}var P={choosePage:"Choose a page",chooseSection:"Choose a section",noSections:"No section anchors yet",sectionHint:"Jumps to a section on that page.",choosePost:"Choose a post",chooseProduct:"Choose a product"};function I(e,n,t){if(!e)return"page";if(e.startsWith("/journal/"))return"blog";if(e.startsWith("/wheels/"))return"product";if(e.includes("#")){let r=e.slice(0,e.indexOf("#"));if(r===""||r==="/"||n.includes(r))return"anchor"}return e==="/"||n.includes(e)||t&&t.listingPaths.includes(t.targetOf(e))?"page":"custom"}function ae(e,n){let t=e.pages.map(i=>({value:g(i.slug),label:i.title})),r=n?.pageOptions?n.pageOptions(t):t,o=r.map(i=>i.value),l=e.pages.map(i=>({label:i.title,options:A(...i.docs).map(u=>({value:_(i.slug,u.slug),label:u.name}))})).filter(i=>i.options.length>0),a=i=>{switch(i){case"page":return{type:"select",options:r,placeholder:P.choosePage};case"anchor":return{type:"groups",groups:l,placeholder:l.length?P.chooseSection:P.noSections};case"blog":return{type:"select",options:e.posts.map(u=>({value:w(u.slug),label:u.title||u.slug})),placeholder:P.choosePost};case"product":return{type:"select",options:e.products.map(u=>({value:u.href,label:u.name||u.href})),placeholder:P.chooseProduct};case"custom":return{type:"text"}}},c=F(e.offers).map(i=>({value:i.value,label:i.label,target:a(i.value),...i.value==="anchor"?{hint:P.sectionHint}:{},...i.value==="blog"||i.value==="product"?{hideWhenEmpty:!0}:{}}));if(!n)return{kinds:c,rules:{kindOf:i=>I(i,o),targetOf:i=>i,readFilter:()=>null,withFilter:i=>i,isSafe:S}};let s=i=>{let u=n.withFilter(i,null);return n.listingPaths.includes(u)?u:i};return{kinds:c,rules:{kindOf:i=>I(i,o,{listingPaths:n.listingPaths,targetOf:s}),targetOf:s,readFilter:n.readFilter,withFilter:n.withFilter,isSafe:S},filtersFor:i=>n.listingPaths.includes(i)?n.filtersFor(i):null}}function v(e,n){return e.length===0?e:e.filter(t=>t.kind===void 0||t.kind===n)}function ue(e,n){let t=n==="filter"?"filterOrder":"cardOrder",r=new Map;for(let o of e){let l=o[t];if(typeof l!="number"||!Number.isFinite(l))continue;let a=r.get(o.fieldKey);(a===void 0||l<a)&&r.set(o.fieldKey,l)}return o=>o?r.get(o):void 0}function ce(e,n,t,r){let o=new Map;for(let s of t){let i=s[r];typeof i=="number"&&o.set(s.fieldKey,i)}if(o.size===0)return e;let l=[],a=[];e.forEach((s,i)=>{let u=n(s);u&&(l.push(i),a.push({item:s,index:i,order:o.get(u)}))}),a.sort((s,i)=>s.order!==void 0&&i.order!==void 0?s.order-i.order||s.index-i.index:s.order!==void 0?-1:i.order!==void 0?1:s.index-i.index);let c=[...e];return l.forEach((s,i)=>{c[s]=a[i].item}),c.every((s,i)=>s===e[i])?e:c}function pe(e){return Ce(e,"filter")}var Ke="collection";function M(e,n){return{tyreSizes:{},brands:{"alloy-wheel":"brand",tyre:"brand"},finishes:{"alloy-wheel":"wheel_finish_ref"},diameters:{"alloy-wheel":"diameter",tyre:"rim_diameter"},collections:{"alloy-wheel":Ke},pcds:{"alloy-wheel":"pcd"},tyreTypes:{tyre:"tire_type"},speedRatings:{tyre:"speed_rating"}}[e]?.[n]}function Ce(e,n){let t=new Set(e.filter(r=>r[n]===!1).map(r=>r.fieldKey));return r=>!r||!t.has(r)}function Ee(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function de(e,n){let t=e?.[n];return Ee(t)?t:null}function fe(e,n,t,r){if(t==null&&r==null)return!0;let o=de(e,n);return!(o===null||t!=null&&o<t||r!=null&&o>r)}var Ne={recommended:"Recommended","price-asc":"Price \xB7 low to high","price-desc":"Price \xB7 high to low",new:"Newest",name:"Name A\u2013Z"},Kn=Object.keys(Ne);var me=["tyreSizes","brands","finishes","diameters","collections","pcds","tyreTypes","speedRatings"],Oe={tyreSizes:["tyre"],brands:["alloy-wheel","tyre"],finishes:["alloy-wheel"],diameters:["alloy-wheel","tyre"],collections:["alloy-wheel"],pcds:["alloy-wheel"],tyreTypes:["tyre"],speedRatings:["tyre"]},Ue={diameters:"tyreSizes"};function ze(e){if(e.length===0)return[];let n=me.filter(t=>e.every(r=>Oe[t].includes(r)));return n.filter(t=>{let r=Ue[t];return!r||!n.includes(r)})}function De(e){let n=new Set;for(let t of e)n.add(d(t));return[...n]}var ge={tyreSizes:[],brands:[],finishes:[],diameters:[],collections:[],pcds:[],tyreTypes:[],speedRatings:[],priceMax:null,inStockOnly:!1,kind:null,sort:"recommended",page:1};function ve(e,n,t,r=null){if(r!=="kind"&&n.kind&&d(e)!==n.kind)return!1;for(let o of me){if(r===o)continue;let l=n[o];if(l.length===0)continue;let a=l.map(String);if(!ye(e,o).some(c=>a.includes(c)))return!1}return!(r!=="price"&&!fe(X(e),t,null,n.priceMax)||r!=="inStock"&&n.inStockOnly&&!J(e))}var Me={tyreSizes:"Size",brands:"Brand",finishes:"Colour",diameters:"Size \xB7 diameter",collections:"Collection",pcds:"PCD \xB7 fitment",tyreTypes:"Tyre type",speedRatings:"Speed rating"};function ye(e,n){switch(n){case"tyreSizes":return[...new Set(oe(e).flatMap(V))];case"brands":return U(e)?[U(e)]:[];case"finishes":return ee(e);case"diameters":return Q(e).map(String);case"collections":return ne(e);case"pcds":return te(e);case"tyreTypes":return re(e);case"speedRatings":return ie(e)}}function Be(e){let n=new Map;for(let t of e)for(let r of z(t))r.color&&!n.has(r.family)&&n.set(r.family,r.color);return n}function Pe(e,n,t,r=De(e),o=[]){let l=i=>$e(i,r,o),a=Be(e),c=ze(r).filter(i=>i!=="tyreSizes").filter(l).map(i=>{let u=n[i].map(String),q=new Set,E=new Map,b=new Map;for(let p of e){let y=ye(p,i);for(let m of y)q.add(m);for(let m of new Set(y))b.set(m,(b.get(m)??0)+1);if(ve(p,n,t,i))for(let m of new Set(y))E.set(m,(E.get(m)??0)+1)}let Te=[...q].map(p=>({value:p,label:i==="diameters"?`${p}\u2033`:p,count:E.get(p)??0,checked:u.includes(p),swatch:i==="finishes"?a.get(p)??null:null})).sort((p,y)=>{if(i==="diameters")return Number(p.value)-Number(y.value);let m=(b.get(y.value)??0)-(b.get(p.value)??0);return m!==0?m:p.value.localeCompare(y.value)});return{key:i,label:Me[i],options:Te}}).filter(i=>i.options.length>We),s=[];for(let i of c){let u=Ye(i.key,r,o);u!==void 0&&s.push({fieldKey:i.key,filterOrder:u})}return[...ce(c,i=>i.key,s,"filterOrder")]}var We=1;function he(e){return e.showCollection===!1?["collections"]:[]}function $e(e,n,t){return n.length===0||t.length===0?!0:n.some(r=>pe(v(t,r))(M(e,r)))}function Ye(e,n,t){if(t.length===0)return;let r;for(let o of n){let l=ue(v(t,o),"filter")(M(e,o));l!==void 0&&(r===void 0||l<r)&&(r=l)}return r}var B={tyreSizes:"tyreSize",brands:"brand",finishes:"colour",diameters:"size",collections:"collection",pcds:"pcd",tyreTypes:"tyreType",speedRatings:"speed"},W="type";var Se="AlloyWheelsListing";var R="/wheels",K="Products";function be(e,n){return n>1?`${K} \xB7 ${e}`:K}function $(...e){for(let n of e){let t=(n?.content??[]).find(r=>r?.type===Se);if(t)return t.props??{}}return null}function C(...e){return $(...e)!==null}function xe(e,n){let t=e.filter(r=>C(...r.docs)).map(r=>g(r.slug));return t.length===0&&n.fallback?[R]:t}var Y=[W,...Object.entries(B).filter(([e])=>e!=="tyreSizes").map(([,e])=>e)];function ke(e){let n=e.indexOf("#"),t=n===-1?"":e.slice(n),r=n===-1?e:e.slice(0,n),o=r.indexOf("?");return{path:o===-1?r:r.slice(0,o),query:o===-1?"":r.slice(o+1),hash:t}}function Ge(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return e}}function Le(e){let n=new URLSearchParams(ke(e).query);for(let t of Y){let r=n.get(t);if(r)return{param:t,value:r}}return null}function G(e,n){let{path:t,query:r,hash:o}=ke(e),l=r.split("&").filter(a=>a&&!Y.includes(Ge(a.split("=")[0])));return n?.value&&l.push(`${encodeURIComponent(n.param)}=${encodeURIComponent(n.value)}`),`${t}${l.length?`?${l.join("&")}`:""}${o}`}function Fe(e,n){let t=G(e,null);return n.includes(t)?t:e}function He(e,n,t=[]){return I(e,n,{listingPaths:t,targetOf:r=>Fe(r,t)})}function qe(e){return Array.isArray(e)?e.filter(n=>typeof n?.kind=="string"&&typeof n.field_key=="string").map(n=>({kind:n.kind,fieldKey:n.field_key,...typeof n.filter=="boolean"?{filter:n.filter}:{},filterOrder:n.filter_order??null})):[]}var we="Product type",je="AUD";function H(e,n){let t=n.listing??{},r=O(t.kinds),o=e.filter(s=>r.includes(d(s))),l=he(t),a=Pe(o,ge,je,r,n.fieldUsage).filter(s=>!l.includes(s.key)).map(s=>({param:B[s.key],label:s.label,values:s.options.filter(i=>!i.value.includes(",")).map(i=>({value:i.value,label:i.label}))})).filter(s=>s.values.length>0),c=h.filter(s=>r.includes(s)&&o.some(i=>d(i)===s));return c.length>1&&a.unshift({param:W,label:we,values:c.map(s=>({value:s,label:k[s]}))}),a}function Ve(e){return n=>{let t=xe(n,{fallback:e.offersCommerce}),r=n.filter(o=>C(...o.docs)).length;return{listingPaths:t,pageOptions:o=>{let l=o.map(a=>{let c=n.find(s=>g(s.slug)===a.value);return c&&C(...c.docs)?{...a,label:be(c.title,r)}:a});return r===0&&e.offersCommerce&&!l.some(a=>a.value===R)&&l.push({value:R,label:K}),l},filtersFor:o=>{if(!t.includes(o))return null;let l=n.find(a=>g(a.slug)===o);return H(e.catalogue,{listing:l?$(...l.docs):null,fieldUsage:e.fieldUsage})},readFilter:Le,withFilter:G}}}function Ze(e){let n=Ve({catalogue:e.catalogue,fieldUsage:e.fieldUsage,offersCommerce:e.offers.offersCommerce})(e.pages),t=ae({pages:e.pages,posts:e.posts,products:e.products.map(r=>({href:T(r.slug),name:r.name||r.slug})),offers:e.offers},n);return{...t,filtersFor:t.filtersFor??(()=>null)}}function qn(e,n){return H(e,n)}export{R as BUILT_IN_LISTING_PATH,L as LINK_KINDS,Y as LISTING_FILTER_PARAMS,K as LISTING_PAGE_LABEL,we as PRODUCT_TYPE_FILTER_LABEL,_ as anchorPath,qe as fieldUsageFromAdminRows,He as inferLinkKind,C as isProductListingPage,S as isSafeLink,F as linkKindsFor,Ze as linkPickerSetup,qn as listingFilterFields,$ as listingNode,be as listingPageLabel,Fe as listingTarget,A as pageAnchors,g as pagePath,w as postPath,xe as productListingPaths,Le as readListingFilter,D as slugifyAnchor,T as wheelPath,G as withListingFilter};
1
+ var h={bold:{open:"**",close:"**",placeholder:"bold text"},italic:{open:"_",close:"_",placeholder:"italic text"},strike:{open:"~~",close:"~~",placeholder:"struck out"},code:{open:"`",close:"`",placeholder:"code"},highlight:{open:"==",close:"==",placeholder:"highlighted text"},quiet:{open:"^^",close:"^^",placeholder:"quiet text"},underline:{open:"[",close:"]{underline}",placeholder:"underlined text"},sup:{open:"[",close:"]{sup}",placeholder:"superscript"},sub:{open:"[",close:"]{sub}",placeholder:"subscript"}};var Ke={bold:h.bold.placeholder,italic:h.italic.placeholder,strike:h.strike.placeholder,code:h.code.placeholder,highlight:h.highlight.placeholder,quiet:h.quiet.placeholder,link:"link text",underline:h.underline.placeholder,sup:h.sup.placeholder,sub:h.sub.placeholder,color:"colored text"};var Z=[{style:"bold",label:"B",name:"Strong",title:"Strong \xB7 **words** \xB7 \u2318B",shortcut:"b"},{style:"italic",label:"I",name:"Italic",title:"Italic \xB7 _words_ \xB7 \u2318I",shortcut:"i"},{style:"strike",label:"S",name:"Strikethrough",title:"Strikethrough \xB7 ~~words~~"},{style:"highlight",label:"\u25C6",name:"Emphasis",title:"Emphasis \xB7 ==words=="},{style:"quiet",label:"a",name:"Quiet",title:"Quiet \xB7 ^^words^^"},{style:"code",label:"\u2039\u203A",name:"Code",title:"Code"},{style:"link",label:"\u{1F517}",name:"Link",title:"Link \xB7 [words](https://\u2026) \xB7 \u2318K",shortcut:"k"},{style:"bullet",label:"\u2022",name:"Bulleted list",title:"Bulleted list"},{style:"number",label:"1.",name:"Numbered list",title:"Numbered list"},{style:"quote",label:"\u275D",name:"Quote",title:"Quote"},{style:"clear",label:"T\xD7",name:"Clear marks",title:"Clear marks \xB7 \u2318\u21E7X",shortcut:"shift+x"}];var S=[{open:"**",close:"**",kind:"bold"},{open:"==",close:"==",kind:"highlight"},{open:"~~",close:"~~",kind:"strike"},{open:"_",close:"_",kind:"italic",wordBoundary:!0},{open:"^^",close:"^^",kind:"quiet"},{open:"@@",close:"@@",kind:"highlight"},{open:"++",close:"++",kind:"bold",wordStart:!0}],Q=["highlight","quiet"],Ce=Z.map(e=>e.style).filter(e=>S.some(n=>n.kind===e)).filter(e=>!Q.includes(e)),Oe=[...S,{open:"*",close:"*",kind:"accent"}],Ne=[...S,{open:"*",close:"*",kind:"accent"},{open:"#",close:"#",kind:"bold",notBefore:"0123456789"},{open:"[",close:"]",kind:"italic",notBefore:"(",notBeforeBlock:!0}];var ve=["http","https","mailto","tel"];function N(e){if(e===""||/[\s\u0000-\u001f\u007f]/.test(e))return!1;let n=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!n||ve.includes(n[1].toLowerCase())}var X=["width","profile","rim"];var Me=/^\s*(\d{2,3})\s*\/\s*(\d{2,3})\s*[A-Za-z]*\s*(\d{2}(?:\.\d+)?)\s*$/,ze={width:[100,500],profile:[20,100],rim:[10,30]};function v(e){let n=Me.exec(e??"");if(!n)return null;let t={width:Number(n[1]),profile:Number(n[2]),rim:Number(n[3])};return X.every(l=>{let[s,a]=ze[l];return t[l]>=s&&t[l]<=a})?t:null}function x(e){if(e.width==null)return"";if(e.profile==null)return String(e.width);let n=`${e.width}/${e.profile}`;return e.rim==null?n:`${n} R${e.rim}`}function J(e){return[x({width:e.width}),x({width:e.width,profile:e.profile}),x(e)]}var b=["alloy-wheel","tyre"],ee=["alloy-wheel"],L={"alloy-wheel":"Alloy wheels",tyre:"Tyres"};var Dn=b.map(e=>({value:e,label:L[e]}));function M(e){return e==null?[...ee]:Array.isArray(e)?b.filter(n=>e.includes(n)):[...ee]}var f=e=>e;function d(e){return f(e).kind==="tyre"?"tyre":"alloy-wheel"}function z(e){return f(e).brand??""}function ne(e){return f(e).prices??void 0}function te(e){return f(e).inStock!==!1}function re(e){let n=f(e),t=d(e)==="tyre"?n.rimDiameters:n.sizes;return Array.isArray(t)?t.filter(r=>typeof r=="number"&&Number.isFinite(r)):[]}function U(e){return d(e)==="tyre"?[]:(f(e).finishes??[]).filter(n=>typeof n?.family=="string").map(n=>({family:n.family,color:n.color??null}))}function ie(e){return U(e).map(n=>n.family)}function le(e){if(d(e)==="tyre")return[];let n=f(e),t=n.categories;return t&&t.length>0?t:n.process?[n.process]:[]}function oe(e){return d(e)==="tyre"?[]:f(e).spec?.pcds??[]}function se(e){return d(e)!=="tyre"?[]:f(e).tyreTypes??[]}function ae(e){return d(e)!=="tyre"?[]:f(e).speedRatings??[]}function ue(e){if(d(e)!=="tyre")return[];let n=f(e).sizes;return Array.isArray(n)?n.map(t=>v(typeof t=="string"?t:null)).filter(t=>t!==null):[]}var ce="homepage";function pe(e){return(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}var w=[{value:"page",label:"Page"},{value:"anchor",label:"Anchor"},{value:"blog",label:"Blog post",needs:"service"},{value:"product",label:"Product",needs:"commerce"},{value:"custom",label:"Custom URL"}];function F(e){return e.offersCommerce&&e.offersService?w:w.filter(n=>!n.needs||(n.needs==="commerce"?e.offersCommerce:e.offersService))}function g(e){return e===ce?"/":`/${e}`}function T(e){return`/journal/${e}`}function _(e){return`/wheels/${e}`}function A(e,n){return`${g(e)}#${n}`}function D(e){return pe(e)}function Ue(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.text=="string"?e.text.trim():""}function R(...e){let n=new Set,t=[];for(let r of e)for(let l of r?.content??[]){let s=Ue(l?.props?.anchor);if(!s)continue;let a=D(s);!a||n.has(a)||(n.add(a),t.push({slug:a,name:s}))}return t}var P={choosePage:"Choose a page",chooseSection:"Choose a section",noSections:"No section anchors yet",sectionHint:"Jumps to a section on that page.",choosePost:"Choose a post",chooseProduct:"Choose a product"};function E(e,n,t){if(!e)return"page";if(e.startsWith("/journal/"))return"blog";if(e.startsWith("/wheels/"))return"product";if(e.includes("#")){let r=e.slice(0,e.indexOf("#"));if(r===""||r==="/"||n.includes(r))return"anchor"}return e==="/"||n.includes(e)||t&&t.listingPaths.includes(t.targetOf(e))?"page":"custom"}function de(e,n){let t=e.pages.map(i=>({value:g(i.slug),label:i.title})),r=n?.pageOptions?n.pageOptions(t):t,l=r.map(i=>i.value),s=e.pages.map(i=>({label:i.title,options:R(...i.docs).map(u=>({value:A(i.slug,u.slug),label:u.name}))})).filter(i=>i.options.length>0),a=i=>{switch(i){case"page":return{type:"select",options:r,placeholder:P.choosePage};case"anchor":return{type:"groups",groups:s,placeholder:s.length?P.chooseSection:P.noSections};case"blog":return{type:"select",options:e.posts.map(u=>({value:T(u.slug),label:u.title||u.slug})),placeholder:P.choosePost};case"product":return{type:"select",options:e.products.map(u=>({value:u.href,label:u.name||u.href})),placeholder:P.chooseProduct};case"custom":return{type:"text"}}},c=F(e.offers).map(i=>({value:i.value,label:i.label,target:a(i.value),...i.value==="anchor"?{hint:P.sectionHint}:{},...i.value==="blog"||i.value==="product"?{hideWhenEmpty:!0}:{}}));if(!n)return{kinds:c,rules:{kindOf:i=>E(i,l),targetOf:i=>i,readFilter:()=>null,withFilter:i=>i}};let o=i=>{let u=n.withFilter(i,null);return n.listingPaths.includes(u)?u:i};return{kinds:c,rules:{kindOf:i=>E(i,l,{listingPaths:n.listingPaths,targetOf:o}),targetOf:o,readFilter:n.readFilter,withFilter:n.withFilter},filtersFor:i=>n.listingPaths.includes(i)?n.filtersFor(i):null}}function B(e,n){return e.length===0?e:e.filter(t=>t.kind===void 0||t.kind===n)}function fe(e,n){let t=n==="filter"?"filterOrder":"cardOrder",r=new Map;for(let l of e){let s=l[t];if(typeof s!="number"||!Number.isFinite(s))continue;let a=r.get(l.fieldKey);(a===void 0||s<a)&&r.set(l.fieldKey,s)}return l=>l?r.get(l):void 0}function me(e,n,t,r){let l=new Map;for(let o of t){let i=o[r];typeof i=="number"&&l.set(o.fieldKey,i)}if(l.size===0)return e;let s=[],a=[];e.forEach((o,i)=>{let u=n(o);u&&(s.push(i),a.push({item:o,index:i,order:l.get(u)}))}),a.sort((o,i)=>o.order!==void 0&&i.order!==void 0?o.order-i.order||o.index-i.index:o.order!==void 0?-1:i.order!==void 0?1:o.index-i.index);let c=[...e];return s.forEach((o,i)=>{c[o]=a[i].item}),c.every((o,i)=>o===e[i])?e:c}function he(e){return Be(e,"filter")}var De="collection";function $(e,n){return{tyreSizes:{},brands:{"alloy-wheel":"brand",tyre:"brand"},finishes:{"alloy-wheel":"wheel_finish_ref"},diameters:{"alloy-wheel":"diameter",tyre:"rim_diameter"},collections:{"alloy-wheel":De},pcds:{"alloy-wheel":"pcd"},tyreTypes:{tyre:"tire_type"},speedRatings:{tyre:"speed_rating"}}[e]?.[n]}function Be(e,n){let t=new Set(e.filter(r=>r[n]===!1).map(r=>r.fieldKey));return r=>!r||!t.has(r)}function $e(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function ge(e,n){let t=e?.[n];return $e(t)?t:null}function ye(e,n,t,r){if(t==null&&r==null)return!0;let l=ge(e,n);return!(l===null||t!=null&&l<t||r!=null&&l>r)}var We={recommended:"Recommended","price-asc":"Price \xB7 low to high","price-desc":"Price \xB7 high to low",new:"Newest",name:"Name A\u2013Z"},yt=Object.keys(We);var Pe=["tyreSizes","brands","finishes","diameters","collections","pcds","tyreTypes","speedRatings"],Ye={tyreSizes:["tyre"],brands:["alloy-wheel","tyre"],finishes:["alloy-wheel"],diameters:["alloy-wheel","tyre"],collections:["alloy-wheel"],pcds:["alloy-wheel"],tyreTypes:["tyre"],speedRatings:["tyre"]},Ge={diameters:"tyreSizes"};function qe(e){if(e.length===0)return[];let n=Pe.filter(t=>e.every(r=>Ye[t].includes(r)));return n.filter(t=>{let r=Ge[t];return!r||!n.includes(r)})}function He(e){let n=new Set;for(let t of e)n.add(d(t));return[...n]}var be={tyreSizes:[],brands:[],finishes:[],diameters:[],collections:[],pcds:[],tyreTypes:[],speedRatings:[],priceMax:null,inStockOnly:!1,kind:null,sort:"recommended",page:1};function je(e,n,t,r=null){if(r!=="kind"&&n.kind&&d(e)!==n.kind)return!1;for(let l of Pe){if(r===l)continue;let s=n[l];if(s.length===0)continue;let a=s.map(String);if(!ke(e,l).some(c=>a.includes(c)))return!1}return!(r!=="price"&&!ye(ne(e),t,null,n.priceMax)||r!=="inStock"&&n.inStockOnly&&!te(e))}var Ve={tyreSizes:"Size",brands:"Brand",finishes:"Colour",diameters:"Size \xB7 diameter",collections:"Collection",pcds:"PCD \xB7 fitment",tyreTypes:"Tyre type",speedRatings:"Speed rating"};function ke(e,n){switch(n){case"tyreSizes":return[...new Set(ue(e).flatMap(J))];case"brands":return z(e)?[z(e)]:[];case"finishes":return ie(e);case"diameters":return re(e).map(String);case"collections":return le(e);case"pcds":return oe(e);case"tyreTypes":return se(e);case"speedRatings":return ae(e)}}function Ze(e){let n=new Map;for(let t of e)for(let r of U(t))r.color&&!n.has(r.family)&&n.set(r.family,r.color);return n}function Se(e,n,t,r=He(e),l=[]){let s=i=>Xe(i,r,l),a=Ze(e),c=qe(r).filter(i=>i!=="tyreSizes").filter(s).map(i=>{let u=n[i].map(String),V=new Set,O=new Map,k=new Map;for(let p of e){let y=ke(p,i);for(let m of y)V.add(m);for(let m of new Set(y))k.set(m,(k.get(m)??0)+1);if(je(p,n,t,i))for(let m of new Set(y))O.set(m,(O.get(m)??0)+1)}let Ie=[...V].map(p=>({value:p,label:i==="diameters"?`${p}\u2033`:p,count:O.get(p)??0,checked:u.includes(p),swatch:i==="finishes"?a.get(p)??null:null})).sort((p,y)=>{if(i==="diameters")return Number(p.value)-Number(y.value);let m=(k.get(y.value)??0)-(k.get(p.value)??0);return m!==0?m:p.value.localeCompare(y.value)});return{key:i,label:Ve[i],options:Ie}}).filter(i=>i.options.length>Qe),o=[];for(let i of c){let u=Je(i.key,r,l);u!==void 0&&o.push({fieldKey:i.key,filterOrder:u})}return[...me(c,i=>i.key,o,"filterOrder")]}var Qe=1;function xe(e){return e.showCollection===!1?["collections"]:[]}function Xe(e,n,t){return n.length===0||t.length===0?!0:n.some(r=>he(B(t,r))($(e,r)))}function Je(e,n,t){if(t.length===0)return;let r;for(let l of n){let s=fe(B(t,l),"filter")($(e,l));s!==void 0&&(r===void 0||s<r)&&(r=s)}return r}var W={tyreSizes:"tyreSize",brands:"brand",finishes:"colour",diameters:"size",collections:"collection",pcds:"pcd",tyreTypes:"tyreType",speedRatings:"speed"},Y="type";var Le="AlloyWheelsListing";function we(e){return N(e.trim())}var I="/wheels",K="Products";function Fe(e,n){return n>1?`${K} \xB7 ${e}`:K}function G(...e){for(let n of e){let t=(n?.content??[]).find(r=>r?.type===Le);if(t)return t.props??{}}return null}function C(...e){return G(...e)!==null}function Te(e,n){let t=e.filter(r=>C(...r.docs)).map(r=>g(r.slug));return t.length===0&&n.fallback?[I]:t}var q=[Y,...Object.entries(W).filter(([e])=>e!=="tyreSizes").map(([,e])=>e)];function _e(e){let n=e.indexOf("#"),t=n===-1?"":e.slice(n),r=n===-1?e:e.slice(0,n),l=r.indexOf("?");return{path:l===-1?r:r.slice(0,l),query:l===-1?"":r.slice(l+1),hash:t}}function en(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return e}}function Ae(e){let n=new URLSearchParams(_e(e).query);for(let t of q){let r=n.get(t);if(r)return{param:t,value:r}}return null}function H(e,n){let{path:t,query:r,hash:l}=_e(e),s=r.split("&").filter(a=>a&&!q.includes(en(a.split("=")[0])));return n?.value&&s.push(`${encodeURIComponent(n.param)}=${encodeURIComponent(n.value)}`),`${t}${s.length?`?${s.join("&")}`:""}${l}`}function Re(e,n){let t=H(e,null);return n.includes(t)?t:e}function nn(e,n,t=[]){return E(e,n,{listingPaths:t,targetOf:r=>Re(r,t)})}function tn(e){return Array.isArray(e)?e.filter(n=>typeof n?.kind=="string"&&typeof n.field_key=="string").map(n=>({kind:n.kind,fieldKey:n.field_key,...typeof n.filter=="boolean"?{filter:n.filter}:{},filterOrder:n.filter_order??null})):[]}var Ee="Product type",rn="AUD";function j(e,n){let t=n.listing??{},r=M(t.kinds),l=e.filter(o=>r.includes(d(o))),s=xe(t),a=Se(l,be,rn,r,n.fieldUsage).filter(o=>!s.includes(o.key)).map(o=>({param:W[o.key],label:o.label,values:o.options.filter(i=>!i.value.includes(",")).map(i=>({value:i.value,label:i.label}))})).filter(o=>o.values.length>0),c=b.filter(o=>r.includes(o)&&l.some(i=>d(i)===o));return c.length>1&&a.unshift({param:Y,label:Ee,values:c.map(o=>({value:o,label:L[o]}))}),a}function ln(e){return n=>{let t=Te(n,{fallback:e.offersCommerce}),r=n.filter(l=>C(...l.docs)).length;return{listingPaths:t,pageOptions:l=>{let s=l.map(a=>{let c=n.find(o=>g(o.slug)===a.value);return c&&C(...c.docs)?{...a,label:Fe(c.title,r)}:a});return r===0&&e.offersCommerce&&!s.some(a=>a.value===I)&&s.push({value:I,label:K}),s},filtersFor:l=>{if(!t.includes(l))return null;let s=n.find(a=>g(a.slug)===l);return j(e.catalogue,{listing:s?G(...s.docs):null,fieldUsage:e.fieldUsage})},readFilter:Ae,withFilter:H}}}function on(e){let n=ln({catalogue:e.catalogue,fieldUsage:e.fieldUsage,offersCommerce:e.offers.offersCommerce})(e.pages),t=de({pages:e.pages,posts:e.posts,products:e.products.map(r=>({href:_(r.slug),name:r.name||r.slug})),offers:e.offers},n);return{...t,rules:{...t.rules,isSafe:we},filtersFor:t.filtersFor??(()=>null)}}function Ot(e,n){return j(e,n)}export{I as BUILT_IN_LISTING_PATH,w as LINK_KINDS,q as LISTING_FILTER_PARAMS,K as LISTING_PAGE_LABEL,Ee as PRODUCT_TYPE_FILTER_LABEL,A as anchorPath,tn as fieldUsageFromAdminRows,nn as inferLinkKind,C as isProductListingPage,we as isSafeLink,F as linkKindsFor,on as linkPickerSetup,Ot as listingFilterFields,G as listingNode,Fe as listingPageLabel,Re as listingTarget,R as pageAnchors,g as pagePath,T as postPath,Te as productListingPaths,Ae as readListingFilter,D as slugifyAnchor,_ as wheelPath,H as withListingFilter};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efficient-storefront-blocks",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "The EFFICIENT storefront's website editor — the website builder assembled with the storefront's own sections — for an app that edits a storefront website inside its own page. Built from the efficient-storefront-blocks repository.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Efficient Pty Ltd",
@@ -48,8 +48,8 @@
48
48
  "LICENSE"
49
49
  ],
50
50
  "peerDependencies": {
51
- "efficient-easel": "^2.0.0",
52
- "efficient-shell": "^4.171.0 || ^5.0.0",
51
+ "efficient-easel": "^2.2.0",
52
+ "efficient-shell": "^5.6.0 || ^6.0.0",
53
53
  "react": ">=19",
54
54
  "react-dom": ">=19"
55
55
  },
@@ -1 +0,0 @@
1
- "use client";import{_ as m,l as g}from"./chunk-MZOOSHH4.js";import{Jd as u,ag as f}from"./chunk-HURDX4EH.js";import"./chunk-YSV4ASRS.js";import"./chunk-NYX4XTRE.js";import{Ga as s,La as a,Ma as d,Qa as c}from"./chunk-HYLRHFHP.js";import"./chunk-EJ2NLQYY.js";import"./chunk-Y6SLVHK3.js";import{Render as I}from"efficient-easel/render";import{jsx as p}from"react/jsx-runtime";function i({footerBlock:r,rootProps:e,headerSettings:o,siteName:t,legalName:l,foundedYear:n,socialLinks:h}){let v=g({root:{props:{...e??{},kind:u}},content:[r],zones:{}});return p(s.Provider,{value:{logoUrl:o?.logoUrl??null,logoReversed:o?.logoReversed??null,logoInkIsDark:o?.logoInkIsDark??null,siteName:t,legalName:l??null,foundedYear:n??null,socialLinks:h??c},children:p(I,{config:m,data:v})})}import{jsx as k}from"react/jsx-runtime";function P(){let{footerBlock:r,editFooter:e}=f(),{settings:o,websiteName:t}=a();if(!r)return null;let l=o?{logoUrl:o.logoUrl,logoReversed:o.logoReversed??null,logoInkIsDark:o.logoInkIsDark??null}:null;return k("div",{className:"sf-preview-footer-pick",onClick:e?n=>{n.stopPropagation(),e()}:void 0,style:e?{cursor:"pointer"}:void 0,title:e?"Edit the site footer \u2192":void 0,children:k(i,{footerBlock:r,headerSettings:l,siteName:t?.trim()||d})})}export{P as default};
@@ -1 +0,0 @@
1
- "use client";import{l as t}from"./chunk-6EH27IKS.js";import"./chunk-HURDX4EH.js";import"./chunk-HYLRHFHP.js";import"./chunk-EJ2NLQYY.js";import"./chunk-Y6SLVHK3.js";import{jsx as e}from"react/jsx-runtime";import{default as r}from"efficient-easel/screen/components/ScreenStoreProvider";function p(o){return e(r,{...o,parts:t})}export{p as default};