← Back
Editing: price-filter.js
(()=>{var e,t,o,r={46513:(e,t,o)=>{"use strict";const r=window.wp.blocks;var n=o(4921),i=o(11789),c=o(1951);const s=window.wp.blockEditor;var l=o(27723);const a=window.wc.wcSettings,u=window.wc.wcTypes,d=(0,a.getSetting)("wcBlocksConfig",{pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),p=(d.pluginUrl,d.pluginUrl,a.STORE_PAGES.shop,a.STORE_PAGES.checkout,a.STORE_PAGES.checkout,a.STORE_PAGES.privacy,a.STORE_PAGES.privacy,a.STORE_PAGES.terms,a.STORE_PAGES.terms,a.STORE_PAGES.cart,a.STORE_PAGES.cart,a.STORE_PAGES.myaccount?.permalink?a.STORE_PAGES.myaccount.permalink:(0,a.getSetting)("wpLoginUrl","/wp-login.php"),(0,a.getSetting)("localPickupEnabled",!1),(0,a.getSetting)("shippingMethodsExist",!1),(0,a.getSetting)("shippingEnabled",!0),(0,a.getSettingWithCoercion)("countries",{},u.isObject)),m=(0,a.getSetting)("countryData",{}),b={...Object.fromEntries(Object.keys(m).filter(e=>!0===m[e].allowBilling).map(e=>{const t=p[e];return[e,(0,u.isString)(t)?t:""]})),...Object.fromEntries(Object.keys(m).filter(e=>!0===m[e].allowShipping).map(e=>{const t=p[e];return[e,(0,u.isString)(t)?t:""]}))},_=(Object.fromEntries(Object.keys(b).map(e=>[e,m[e].states||{}])),Object.fromEntries(Object.keys(b).map(e=>[e,m[e].locale||{}])),{address:["first_name","last_name","company","address_1","address_2","city","postcode","country","state","phone"],contact:["email"],order:[]});(0,a.getSetting)("addressFieldsLocations",_).address,(0,a.getSetting)("addressFieldsLocations",_).contact,(0,a.getSetting)("addressFieldsLocations",_).order,(0,a.getSetting)("additionalOrderFields",{}),(0,a.getSetting)("additionalContactFields",{}),(0,a.getSetting)("additionalAddressFields",{});var w=o(29491),g=(o(12796),o(10790));const h=(0,w.withInstanceId)(({className:e,headingLevel:t,onChange:o,heading:r,instanceId:n})=>{const i=`h${t}`;return(0,g.jsxs)(i,{className:e,children:[(0,g.jsx)("label",{className:"screen-reader-text",htmlFor:`block-title-${n}`,children:(0,l.__)("Block title","woocommerce")}),(0,g.jsx)(s.PlainText,{id:`block-title-${n}`,className:"wc-block-editor-components-title",value:r,onChange:o,style:{backgroundColor:"transparent"}})]})});var f=o(96900);const x=window.wp.components;var k=o(86087);function y(e,t){const o=(0,k.useRef)();return(0,k.useEffect)(()=>{o.current===e||t&&!t(e,o.current)||(o.current=e)},[e,t]),o.current}const v=window.wc.wcBlocksData,j=window.wp.data;var S=o(20923),E=o.n(S);const C=(0,k.createContext)("page"),N=()=>(0,k.useContext)(C),F=(C.Provider,e=>{const t=N();e=e||t;const o=(0,j.useSelect)(t=>t(v.QUERY_STATE_STORE_KEY).getValueForQueryContext(e,void 0),[e]),{setValueForQueryContext:r}=(0,j.useDispatch)(v.QUERY_STATE_STORE_KEY);return[o,(0,k.useCallback)(t=>{r(e,t)},[e,r])]}),P=(e,t,o)=>{const r=N();o=o||r;const n=(0,j.useSelect)(r=>r(v.QUERY_STATE_STORE_KEY).getValueForQueryKey(o,e,t),[o,e]),{setQueryValue:i}=(0,j.useDispatch)(v.QUERY_STATE_STORE_KEY);return[n,(0,k.useCallback)(t=>{i(o,e,t)},[o,e,i])]};var O=o(64347),A=o(61303);function T(e){const t=(0,k.useRef)(e);return E()(e,t.current)||(t.current=e),t.current}const R=({queryAttribute:e,queryTaxonomy:t,queryPrices:o,queryStock:r,queryRating:n,queryState:i,isEditor:c=!1})=>{let s=N();s=`${s}-collection-data`;const[a]=F(s),[d,p]=P("calculate_attribute_counts",[],s),[m,b]=P("calculate_taxonomy_counts",[],s),[_,w]=P("calculate_price_range",null,s),[g,h]=P("calculate_stock_status_counts",null,s),[f,x]=P("calculate_rating_counts",null,s),y=T(e||{}),S=T(t),E=T(o),C=T(r),R=T(n);(0,k.useEffect)(()=>{"object"==typeof y&&Object.keys(y).length&&(d.find(e=>(0,u.objectHasProp)(y,"taxonomy")&&e.taxonomy===y.taxonomy)||p([...d,y]))},[y,d,p]),(0,k.useEffect)(()=>{S&&!m.includes(S)&&b([...m,S])},[S,m,b]),(0,k.useEffect)(()=>{_!==E&&void 0!==E&&w(E)},[E,w,_]),(0,k.useEffect)(()=>{g!==C&&void 0!==C&&h(C)},[C,h,g]),(0,k.useEffect)(()=>{f!==R&&void 0!==R&&x(R)},[R,x,f]);const[B,I]=(0,k.useState)(c),[L]=(0,O.d7)(B,200);B||I(!0);const U=(0,k.useMemo)(()=>(e=>{const t=e;return Array.isArray(e.calculate_attribute_counts)&&(t.calculate_attribute_counts=(0,A.di)(e.calculate_attribute_counts.map(({taxonomy:e,queryType:t})=>({taxonomy:e,query_type:t}))).asc(["taxonomy","query_type"])),Array.isArray(e.calculate_taxonomy_counts)&&(t.calculate_taxonomy_counts=e.calculate_taxonomy_counts),t})(a),[a]),{results:M,isLoading:q}=(e=>{const{namespace:t,resourceName:o,resourceValues:r=[],query:n={},shouldSelect:i=!0}=e;if(!t||!o)throw new Error("The options object must have valid values for the namespace and the resource properties.");const c=(0,k.useRef)({results:[],isLoading:!0}),s=T(n),a=T(r),d=(()=>{const[,e]=(0,k.useState)();return(0,k.useCallback)(t=>{e(()=>{throw t})},[])})(),p=(0,j.useSelect)(e=>{if(!i)return null;const r=e(v.COLLECTIONS_STORE_KEY),n=[t,o,s,a],c=r.getCollectionError(...n);if(c)if((0,u.isError)(c))d(c);else{const e="object"==typeof c&&null!==c&&"string"==typeof c.message?c.message:(0,l.__)("Something went wrong while loading data.","woocommerce");d(new Error(e))}return{results:r.getCollection(...n),isLoading:!r.hasFinishedResolution("getCollection",n)}},[t,o,a,s,i,d]);return null!==p&&(c.current=p),c.current})({namespace:"/wc/store/v1",resourceName:"products/collection-data",query:{...i,page:void 0,per_page:void 0,orderby:void 0,order:void 0,...U},shouldSelect:L});return{data:M,isLoading:q}},B=window.wc.blocksComponents;o(86599);const I=(e,t,o,r=1,n=!1)=>{let[i,c]=e;const s=e=>Number.isFinite(e);return s(i)||(i=t||0),s(c)||(c=o||r),s(t)&&t>i&&(i=t),s(o)&&o<=i&&(i=o-r),s(t)&&t>=c&&(c=t+r),s(o)&&o<c&&(c=o),!n&&i>=c&&(i=c-r),n&&c<=i&&(c=i+r),[i,c]};o(90874);const L=({className:e,isLoading:t,disabled:o, /* translators: Submit button text for filters. */ label:r=(0,l.__)("Apply","woocommerce"),onClick:i,screenReaderLabel:c=(0,l.__)("Apply filter","woocommerce")})=>(0,g.jsx)("button",{type:"submit",className:(0,n.A)("wp-block-button__link","wc-block-filter-submit-button","wc-block-components-filter-submit-button",{"is-loading":t},e),disabled:o,onClick:i,children:(0,g.jsx)(B.Label,{label:r,screenReaderLabel:c})}),U=({maxConstraint:e,minorUnit:t})=>({floatValue:o})=>void 0!==o&&o<=e/10**t&&o>0,M=({minConstraint:e,currentMaxValue:t,minorUnit:o})=>({floatValue:r})=>void 0!==r&&r>=e/10**o&&r<t/10**o;o(97165);const q=({className:e, /* translators: Reset button text for filters. */ label:t=(0,l.__)("Reset","woocommerce"),onClick:o,screenReaderLabel:r=(0,l.__)("Reset filter","woocommerce")})=>(0,g.jsx)("button",{className:(0,n.A)("wc-block-components-filter-reset-button",e),onClick:o,children:(0,g.jsx)(B.Label,{label:t,screenReaderLabel:r})}),G=({minPrice:e,maxPrice:t,minConstraint:o,maxConstraint:r,onChange:i,step:c,currency:s,showInputFields:a=!0,showFilterButton:d=!1,inlineInput:p=!0,isLoading:m=!1,isUpdating:b=!1,isEditor:_=!1,onSubmit:w=()=>{}})=>{const h=(0,k.useRef)(null),f=(0,k.useRef)(null),x=c||10**s.minorUnit,[y,v]=(0,k.useState)(e),[j,S]=(0,k.useState)(t),E=(0,k.useRef)(null),[C,N]=(0,k.useState)(0);(0,k.useEffect)(()=>{v(e)},[e]),(0,k.useEffect)(()=>{S(t)},[t]),(0,k.useLayoutEffect)(()=>{p&&E.current&&N(E.current?.offsetWidth)},[p,N]);const F=(0,k.useMemo)(()=>isFinite(o)&&isFinite(r),[o,r]),P=(0,k.useMemo)(()=>isFinite(e)&&isFinite(t)&&F?{"--low":(e-o)/(r-o)*100+"%","--high":(t-o)/(r-o)*100+"%"}:{"--low":"0%","--high":"100%"},[e,t,o,r,F]),A=(0,k.useCallback)(e=>{if(m||!F||!h.current||!f.current)return;const t=e.target.getBoundingClientRect(),o=e.clientX-t.left,n=h.current.offsetWidth,i=+h.current.value,c=f.current.offsetWidth,s=+f.current.value,l=n*(i/r),a=c*(s/r);Math.abs(o-l)>Math.abs(o-a)?(h.current.style.zIndex="20",f.current.style.zIndex="21"):(h.current.style.zIndex="21",f.current.style.zIndex="20")},[m,r,F]),T=(0,k.useCallback)(n=>{const c=n.target.classList.contains("wc-block-price-filter__range-input--min"),s=+n.target.value,l=c?[Math.round(s/x)*x,t]:[e,Math.round(s/x)*x],a=I(l,o,r,x,c);i(a)},[i,e,t,o,r,x]),R=(0,O.YQ)((e,t,o)=>{if(e>=t){const e=I([0,t],null,null,x,o);return i([parseInt(e[0],10),parseInt(e[1],10)])}const r=I([e,t],null,null,x,o);i(r)},1e3),G=(0,O.YQ)(w,600),Q=(0,n.A)("wc-block-price-filter","wc-block-components-price-slider",a&&"wc-block-price-filter--has-input-fields",a&&"wc-block-components-price-slider--has-input-fields",d&&"wc-block-price-filter--has-filter-button",d&&"wc-block-components-price-slider--has-filter-button",!F&&"is-disabled",(p||C<=300)&&"wc-block-components-price-slider--is-input-inline"),D=(0,u.isObject)(h.current)?h.current.ownerDocument.activeElement:void 0,V=D&&D===h.current?x:1,W=D&&D===f.current?x:1,Y=String(y/10**s.minorUnit),$=String(j/10**s.minorUnit),H=p&&C>300,K=(0,g.jsx)("div",{className:(0,n.A)("wc-block-price-filter__range-input-wrapper","wc-block-components-price-slider__range-input-wrapper",{"is-loading":m&&b}),onMouseMove:A,onFocus:A,children:F&&(0,g.jsxs)("div",{"aria-hidden":a,children:[(0,g.jsx)("div",{className:"wc-block-price-filter__range-input-progress wc-block-components-price-slider__range-input-progress",style:P}),(0,g.jsx)("input",{type:"range",className:"wc-block-price-filter__range-input wc-block-price-filter__range-input--min wc-block-components-price-slider__range-input wc-block-components-price-slider__range-input--min","aria-label":(0,l.__)("Filter products by minimum price","woocommerce"),"aria-valuetext":Y,value:Number.isFinite(e)?e:o,onChange:T,step:V,min:o,max:r,ref:h,disabled:m&&!F,tabIndex:a?-1:0}),(0,g.jsx)("input",{type:"range",className:"wc-block-price-filter__range-input wc-block-price-filter__range-input--max wc-block-components-price-slider__range-input wc-block-components-price-slider__range-input--max","aria-label":(0,l.__)("Filter products by maximum price","woocommerce"),"aria-valuetext":$,value:Number.isFinite(t)?t:r,onChange:T,step:W,min:o,max:r,ref:f,disabled:m,tabIndex:a?-1:0})]})}),z=e=>`wc-block-price-filter__amount wc-block-price-filter__amount--${e} wc-block-form-text-input wc-block-components-price-slider__amount wc-block-components-price-slider__amount--${e}`,J={currency:s,decimalScale:0},X={...J,displayType:"input",allowNegative:!1,disabled:m||!F,onClick:e=>{const t=e.currentTarget;t&&t.select()}};return(0,g.jsxs)("div",{className:Q,ref:E,children:[(!H||!a)&&K,a&&(0,g.jsxs)("div",{className:"wc-block-price-filter__controls wc-block-components-price-slider__controls",children:[b?(0,g.jsx)("div",{className:"input-loading"}):(0,g.jsxs)("div",{className:"wc-block-price-filter__control wc-block-components-price-slider__control",children:[(0,g.jsx)("label",{className:"wc-block-components-price-slider__label",htmlFor:"minPriceInput",children:(0,l.__)("Min. Price","woocommerce")}),(0,g.jsx)(B.FormattedMonetaryAmount,{...X,id:"minPriceInput",className:z("min"),"aria-label":(0,l.__)("Filter products by minimum price","woocommerce"),isAllowed:M({minConstraint:o,minorUnit:s.minorUnit,currentMaxValue:j}),onValueChange:e=>{e!==y&&(v(e),R(e,j,!0))},value:y})]}),H&&K,b?(0,g.jsx)("div",{className:"input-loading"}):(0,g.jsxs)("div",{className:"wc-block-price-filter__control wc-block-components-price-slider__control",children:[(0,g.jsx)("label",{className:"wc-block-components-price-slider__label",htmlFor:"maxPriceInput",children:(0,l.__)("Max. Price","woocommerce")}),(0,g.jsx)(B.FormattedMonetaryAmount,{...X,id:"maxPriceInput",className:z("max"),"aria-label":(0,l.__)("Filter products by maximum price","woocommerce"),isAllowed:U({maxConstraint:r,minorUnit:s.minorUnit}),onValueChange:e=>{e!==j&&(S(e),R(y,e,!1))},value:j})]})]}),!a&&!b&&Number.isFinite(e)&&Number.isFinite(t)&&(0,g.jsxs)("div",{className:"wc-block-price-filter__range-text wc-block-components-price-slider__range-text",children:[(0,g.jsx)(B.FormattedMonetaryAmount,{...J,value:e}),(0,g.jsx)(B.FormattedMonetaryAmount,{...J,value:t})]}),(0,g.jsxs)("div",{className:"wc-block-components-price-slider__actions",children:[(_||!b&&(e!==o||t!==r))&&(0,g.jsx)(q,{onClick:()=>{i([o,r]),G()},screenReaderLabel:(0,l.__)("Reset price filter","woocommerce")}),d&&(0,g.jsx)(L,{className:"wc-block-price-filter__button wc-block-components-price-slider__button",isLoading:b,disabled:m||!F,onClick:w,screenReaderLabel:(0,l.__)("Apply price filter","woocommerce")})]})]})};o(49300);const Q=({children:e})=>(0,g.jsx)("div",{className:"wc-block-filter-title-placeholder",children:e}),D=window.wc.priceFormat,V=window.wp.url,W=(0,a.getSettingWithCoercion)("isRenderingPhpTemplate",!1,u.isBoolean);function Y(e){return window?(0,V.getQueryArg)(window.location.href,e):null}function $(e){if(W){const t=new URL(e);t.pathname=t.pathname.replace(/\/page\/[0-9]+/i,""),t.searchParams.delete("paged"),t.searchParams.forEach((e,o)=>{o.match(/^query(?:-[0-9]+)?-page$/)&&t.searchParams.delete(o)}),window.location.href=t.href}else window.history.replaceState({},"",e)}const H="ROUND_UP",K="ROUND_DOWN",z=(e,t,o)=>{const r=1*10**t;let n=null;const i=parseFloat(e);isNaN(i)||(o===H?n=Math.ceil(i/r)*r:o===K&&(n=Math.floor(i/r)*r));const c=y(n,Number.isFinite);return Number.isFinite(n)?n:c};o(83846);const J=(0,k.createContext)({});function X(e,t){return Number(e)*10**t}const Z=({attributes:e,isEditor:t=!1})=>{const o=(()=>{const{wrapper:e}=(0,k.useContext)(J);return t=>{e&&e.current&&(e.current.hidden=!t)}})(),r=(0,a.getSettingWithCoercion)("hasFilterableProducts",!1,u.isBoolean),n=(0,a.getSettingWithCoercion)("isRenderingPhpTemplate",!1,u.isBoolean),[i,c]=(0,k.useState)(!1),s=Y("min_price"),l=Y("max_price"),[d]=F(),p=(0,a.getSettingWithCoercion)("queryState",{},u.isObject),{data:m,isLoading:b}=R({queryPrices:!0,queryState:{...p,...d},isEditor:t}),_=(0,D.getCurrencyFromPriceResponse)((0,u.objectHasProp)(m,"price_range")?m.price_range:void 0),[w,h]=P("min_price"),[f,x]=P("max_price"),[v,j]=(0,k.useState)(X(s,_.minorUnit)||null),[S,E]=(0,k.useState)(X(l,_.minorUnit)||null),{minConstraint:C,maxConstraint:N}=(({minPrice:e,maxPrice:t,minorUnit:o})=>({minConstraint:z(e||"",o,K),maxConstraint:z(t||"",o,H)}))({minPrice:(0,u.objectHasProp)(m,"price_range")&&(0,u.objectHasProp)(m.price_range,"min_price")&&(0,u.isString)(m.price_range.min_price)?m.price_range.min_price:void 0,maxPrice:(0,u.objectHasProp)(m,"price_range")&&(0,u.objectHasProp)(m.price_range,"max_price")&&(0,u.isString)(m.price_range.max_price)?m.price_range.max_price:void 0,minorUnit:_.minorUnit});(0,k.useEffect)(()=>{i||(h(X(s,_.minorUnit)),x(X(l,_.minorUnit)),c(!0))},[_.minorUnit,i,l,s,x,h]);const[A,T]=(0,k.useState)(b),B=(0,k.useCallback)((e,t)=>{const o=t>=Number(N)?void 0:t,r=e<=Number(C)?void 0:e;if(window){const e=function(e,t){const o={};for(const[e,r]of Object.entries(t))r?o[e]=r.toString():delete o[e];const r=(0,V.removeQueryArgs)(e,...Object.keys(t));return(0,V.addQueryArgs)(r,o)}(window.location.href,{min_price:r/10**_.minorUnit,max_price:o/10**_.minorUnit});window.location.href!==e&&$(e)}h(r),x(o)},[C,N,h,x,_.minorUnit]),I=(0,O.YQ)(B,500),L=(0,k.useCallback)(t=>{T(!0),t[0]!==v&&j(t[0]),t[1]!==S&&E(t[1]),n&&i&&!e.showFilterButton&&I(t[0],t[1])},[v,S,j,E,n,i,I,e.showFilterButton]);(0,k.useEffect)(()=>{e.showFilterButton||n||I(v,S)},[v,S,e.showFilterButton,I,n]);const U=y(w),M=y(f),q=y(C),W=y(N);if((0,k.useEffect)(()=>{(!Number.isFinite(v)||w!==U&&w!==v||C!==q&&C!==v)&&j(Number.isFinite(w)?w:C),(!Number.isFinite(S)||f!==M&&f!==S||N!==W&&N!==S)&&E(Number.isFinite(f)?f:N)},[v,S,w,f,C,N,q,W,U,M]),!r)return o(!1),null;if(!b&&(null===C||null===N||C===N))return o(!1),null;const Z=`h${e.headingLevel}`;o(!0),!b&&A&&T(!1);const ee=(0,g.jsx)(Z,{className:"wc-block-price-filter__title",children:e.heading}),te=b&&A?(0,g.jsx)(Q,{children:ee}):ee;return(0,g.jsxs)(g.Fragment,{children:[!t&&e.heading&&te,(0,g.jsx)("div",{className:"wc-block-price-slider",children:(0,g.jsx)(G,{minConstraint:C,maxConstraint:N,minPrice:v,maxPrice:S,currency:_,showInputFields:e.showInputFields,inlineInput:e.inlineInput,showFilterButton:e.showFilterButton,onChange:L,onSubmit:()=>B(v,S),isLoading:b,isUpdating:A,isEditor:t})})]})};function ee({children:e,className:t,actionLabel:o,onActionClick:r,status:i="info",...c}){return(0,g.jsx)(x.Notice,{...c,status:i,politeness:"polite",className:(0,n.$)("wc-block-editor-components-upgrade-downgrade-notice",t),actions:[{label:o,onClick:r,noDefaultClasses:!0,variant:"link"}],children:(0,g.jsx)("div",{className:"wc-block-editor-components-upgrade-downgrade-notice__text",children:e})})}o(65012),o(49969);const te=({clientId:e})=>{const{replaceBlock:t,removeBlock:o,updateBlockAttributes:n,selectBlock:i}=(0,j.useDispatch)("core/block-editor"),c=(0,k.createInterpolateElement)((0,l.__)("Upgrade all Filter blocks on this page for better performance and more customizability","woocommerce"),{strongText:(0,g.jsx)("strong",{children:(0,l.__)("Product Filters","woocommerce")})}),s=(0,l.__)("Upgrade all Filter blocks","woocommerce");return(0,g.jsx)(ee,{isDismissible:!1,actionLabel:s,onActionClick:()=>{const{getBlocksByName:c,getBlockParentsByBlockName:s}=(0,j.select)("core/block-editor"),l=s(e,"woocommerce/filter-wrapper"),a=(0,r.createBlock)("woocommerce/product-filters");l.length?t(l[0],a):t(e,a),c("woocommerce/filter-wrapper").forEach(e=>{n(e,{lock:{remove:!1}}),o(e)}),["woocommerce/active-filters","woocommerce/price-filter","woocommerce/attribute-filter","woocommerce/stock-filter"].forEach(e=>{const t=c(e);t.length&&(n(t[0],{lock:{remove:!1}}),o(t[0]))}),i(a.clientId)},children:c})},oe=JSON.parse('{"name":"woocommerce/price-filter","title":"Filter by Price Controls","description":"Enable customers to filter the product grid by choosing a price range.","category":"woocommerce","keywords":["WooCommerce"],"supports":{"interactivity":{"clientNavigation":false},"html":false,"multiple":false,"color":{"text":true,"background":false},"inserter":false,"lock":false},"attributes":{"className":{"type":"string","default":""},"showInputFields":{"type":"boolean","default":true},"inlineInput":{"type":"boolean","default":false},"showFilterButton":{"type":"boolean","default":false},"headingLevel":{"type":"number","default":3}},"textdomain":"woocommerce","apiVersion":3,"$schema":"https://schemas.wp.org/trunk/block.json"}'),re={heading:{type:"string",default:(0,l.__)("Filter by price","woocommerce")}},ne=[{attributes:{...oe.attributes,...re},save:({attributes:e})=>{const{className:t,showInputFields:o,showFilterButton:r,heading:i,headingLevel:c}=e,l={"data-showinputfields":o,"data-showfilterbutton":r,"data-heading":i,"data-heading-level":c};return(0,g.jsx)("div",{...s.useBlockProps.save({className:(0,n.A)("is-loading",t)}),...l,children:(0,g.jsx)("span",{"aria-hidden":!0,className:"wc-block-product-categories__placeholder"})})}}];(0,r.registerBlockType)(oe,{icon:{src:(0,g.jsx)(i.A,{icon:c.A,className:"wc-block-editor-components-block-icon"})},attributes:{...oe.attributes,...re},edit:function({attributes:e,setAttributes:t,clientId:o}){const{heading:r,headingLevel:n,showInputFields:u,inlineInput:p,showFilterButton:m}=e,b=(0,s.useBlockProps)();return(0,g.jsx)("div",{...b,children:0===d.productCount?(0,g.jsxs)(x.Placeholder,{className:"wc-block-price-slider",icon:(0,g.jsx)(i.A,{icon:c.A}),label:(0,l.__)("Filter by Price","woocommerce"),instructions:(0,l.__)("Display a slider to filter products in your store by price.","woocommerce"),children:[(0,g.jsx)("p",{children:(0,l.__)("To filter your products by price you first need to assign prices to your products.","woocommerce")}),(0,g.jsxs)(x.Button,{className:"wc-block-price-slider__add-product-button",variant:"secondary",href:(0,a.getAdminLink)("post-new.php?post_type=product"),target:"_top",children:[(0,l.__)("Add new product","woocommerce")+" ",(0,g.jsx)(i.A,{icon:f.A})]}),(0,g.jsx)(x.Button,{className:"wc-block-price-slider__read_more_button",variant:"tertiary",href:"https://woocommerce.com/document/managing-products/",target:"_blank",children:(0,l.__)("Learn more","woocommerce")})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(s.InspectorControls,{children:[(0,g.jsx)(x.PanelBody,{children:(0,g.jsx)(te,{clientId:o})}),(0,g.jsxs)(x.PanelBody,{title:(0,l.__)("Settings","woocommerce"),children:[(0,g.jsxs)(x.__experimentalToggleGroupControl,{label:(0,l.__)("Price Range Selector","woocommerce"),isBlock:!0,value:u?"editable":"text",onChange:e=>t({showInputFields:"editable"===e}),className:"wc-block-price-filter__price-range-toggle",children:[(0,g.jsx)(x.__experimentalToggleGroupControlOption,{value:"editable",label:(0,l.__)("Editable","woocommerce")}),(0,g.jsx)(x.__experimentalToggleGroupControlOption,{value:"text",label:(0,l.__)("Text","woocommerce")})]}),u&&(0,g.jsx)(x.ToggleControl,{label:(0,l.__)("Inline input fields","woocommerce"),checked:p,onChange:()=>t({inlineInput:!p}),help:(0,l.__)("Show input fields inline with the slider.","woocommerce")}),(0,g.jsx)(x.ToggleControl,{label:(0,l.__)("Show 'Apply filters' button","woocommerce"),help:(0,l.__)("Products will update when the button is clicked.","woocommerce"),checked:m,onChange:()=>t({showFilterButton:!m})})]})]},"inspector"),r&&(0,g.jsx)(h,{className:"wc-block-price-filter__title",headingLevel:n,heading:r,onChange:e=>t({heading:e})}),(0,g.jsx)(x.Disabled,{children:(0,g.jsx)(Z,{attributes:e,isEditor:!0})})]})})},save({attributes:e}){const{className:t}=e;return(0,g.jsx)("div",{...s.useBlockProps.save({className:(0,n.A)("is-loading",t)}),children:(0,g.jsx)("span",{"aria-hidden":!0,className:"wc-block-product-categories__placeholder"})})},deprecated:ne})},49300:()=>{},97165:()=>{},90874:()=>{},86599:()=>{},65012:()=>{},83846:()=>{},12796:()=>{},49969:()=>{},51609:e=>{"use strict";e.exports=window.React},10790:e=>{"use strict";e.exports=window.ReactJSXRuntime},29491:e=>{"use strict";e.exports=window.wp.compose},86087:e=>{"use strict";e.exports=window.wp.element},27723:e=>{"use strict";e.exports=window.wp.i18n},20923:e=>{"use strict";e.exports=window.wp.isShallowEqual},5573:e=>{"use strict";e.exports=window.wp.primitives}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var o=n[e]={exports:{}};return r[e](o,o.exports,i),o.exports}i.m=r,e=[],i.O=(t,o,r,n)=>{if(!o){var c=1/0;for(u=0;u<e.length;u++){for(var[o,r,n]=e[u],s=!0,l=0;l<o.length;l++)(!1&n||c>=n)&&Object.keys(i.O).every(e=>i.O[e](o[l]))?o.splice(l--,1):(s=!1,n<c&&(c=n));if(s){e.splice(u--,1);var a=r();void 0!==a&&(t=a)}}return t}n=n||0;for(var u=e.length;u>0&&e[u-1][2]>n;u--)e[u]=e[u-1];e[u]=[o,r,n]},i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},o=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(e,r){if(1&r&&(e=this(e)),8&r)return e;if("object"==typeof e&&e){if(4&r&&e.__esModule)return e;if(16&r&&"function"==typeof e.then)return e}var n=Object.create(null);i.r(n);var c={};t=t||[null,o({}),o([]),o(o)];for(var s=2&r&&e;"object"==typeof s&&!~t.indexOf(s);s=o(s))Object.getOwnPropertyNames(s).forEach(t=>c[t]=()=>e[t]);return c.default=()=>e,i.d(n,c),n},i.d=(e,t)=>{for(var o in t)i.o(t,o)&&!i.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.j=1493,(()=>{var e={1493:0};i.O.j=t=>0===e[t];var t=(t,o)=>{var r,n,[c,s,l]=o,a=0;if(c.some(t=>0!==e[t])){for(r in s)i.o(s,r)&&(i.m[r]=s[r]);if(l)var u=l(i)}for(t&&t(o);a<c.length;a++)n=c[a],i.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return i.O(u)},o=globalThis.webpackChunkwebpackWcBlocksMainJsonp=globalThis.webpackChunkwebpackWcBlocksMainJsonp||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var c=i.O(void 0,[94],()=>i(46513));c=i.O(c),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["price-filter"]=c})();
Save File
Cancel