PluginProbe
Tiered Pricing Table for WooCommerce / 8.0.2
Tiered Pricing Table for WooCommerce v8.0.2
8.0.2 7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 All 91 releases
tier-pricing-table / src / Addons / TaxSettings / build / index.js

index.js in Tiered Pricing Table for WooCommerce 8.0.2, at src/Addons/TaxSettings/build/index.js

1 lines 10.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (()=>{"use strict";var e={20(e,t,r){var n=r(609),a=Symbol.for("react.element"),l=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,r){var n,c={},p=null,s=null;for(n in void 0!==r&&(p=""+r),void 0!==t.key&&(p=""+t.key),void 0!==t.ref&&(s=t.ref),t)l.call(t,n)&&!o.hasOwnProperty(n)&&(c[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===c[n]&&(c[n]=t[n]);return{$$typeof:a,type:e,key:p,ref:s,props:c,_owner:i.current}}},848(e,t,r){e.exports=r(20)},609(e){e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var l=t[n]={exports:{}};return e[n](l,l.exports,r),l.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var n=r(609);const a=window.wp.element,l=window.wp.components,i=window.wp.primitives;var o=r(848),c=(0,o.jsx)(i.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,o.jsx)(i.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"})}),p=(0,o.jsx)(i.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,o.jsx)(i.Path,{d:"M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"})});const s=window.wp.apiFetch;var d=r.n(s);const u=window.wp.i18n,m=window.tptTaxSettings?.roles||[{label:"Administrator",value:"administrator"},{label:"Editor",value:"editor"},{label:"Author",value:"author"},{label:"Contributor",value:"contributor"},{label:"Subscriber",value:"subscriber"},{label:"Customer",value:"customer"},{label:"Shop manager",value:"shop_manager"}];function g(){const[e,t]=(0,a.useState)(null),[r,i]=(0,a.useState)(!0),[o,s]=(0,a.useState)([]),[g,x]=(0,a.useState)(""),[f,_]=(0,a.useState)([]);(0,a.useEffect)(()=>{d()({path:"/tier-pricing-table/v1/tax-settings"}).then(e=>{t(e||{}),s(Object.keys(e||{})),i(!1)}).catch(()=>{t({}),i(!1)})},[]);const b=()=>{g&&!o.includes(g)&&(s([...o,g]),_([...f,g]),t({...e,[g]:{tax_exempt:!1,tax_class:"default",display_shop:"default",display_cart:"default",prices_include_tax:"default",price_suffix:""}}),x(""))},v=(r,n,a)=>{t({...e,[r]:{...e[r],[n]:a}})};if(r)return(0,n.createElement)(l.Spinner,null);const y=m.filter(e=>!o.includes(e.value));return(0,n.createElement)("div",{className:"tpt-tax-settings-app"},(0,n.createElement)("style",null,"\n\t\t\t\t.tpt-tax-settings-app {\n\t\t\t\t\tmargin-top: 20px;\n\t\t\t\t\tmax-width: 650px;\n\t\t\t\t}\n\t\t\t\t.tpt-role-settings-panel {\n\t\t\t\t\tborder: 1px solid var(--wp-components-color-border, #c3c4c7);\n\t\t\t\t\tbackground: var(--wp-components-color-background, #fff);\n\t\t\t\t\tmargin-bottom: 20px;\n\t\t\t\t\tborder-radius: 4px;\n\t\t\t\t\tbox-shadow: 0 1px 1px rgba(0,0,0,.04);\n\t\t\t\t}\n\t\t\t\t.tpt-role-settings-panel > .components-button {\n\t\t\t\t\tbackground: var(--wp-admin-theme-color-darker-20, #f6f7f7);\n\t\t\t\t\tborder-bottom: 1px solid var(--wp-components-color-border, #c3c4c7);\n\t\t\t\t\tfont-weight: 600;\n\t\t\t\t\tcolor: var(--wp-components-color-foreground, #1d2327);\n\t\t\t\t}\n\t\t\t\t.tpt-role-settings-panel > .components-button:hover {\n\t\t\t\t\tbackground: var(--wp-admin-theme-color-darker-10, #f0f0f1);\n\t\t\t\t}\n\t\t\t\t.tpt-premium-banner {\n\t\t\t\t\tbackground: #f0f6fc;\n\t\t\t\t\tpadding: 16px 16px;\n\t\t\t\t\tmargin: 20px 0;\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\tjustify-content: space-between;\n\t\t\t\t\tborder-radius: 5px;\n\t\t\t\t\talign-items: center;\n\t\t\t\t\tborder: 1px solid #ccc;\n\t\t\t\t}\n\t\t\t\t.tpt-add-role-card {\n\t\t\t\t\tposition: sticky;\n\t\t\t\t\ttop: 40px;\n\t\t\t\t}\n\t\t\t\t"),(0,n.createElement)(l.Flex,{align:"center",justify:"space-between",style:{marginBottom:"20px"}},(0,n.createElement)(l.FlexItem,null,(0,n.createElement)("h2",{style:{margin:0}},(0,u.__)("Role-Based Tax Options","tier-pricing-table")),(0,n.createElement)("p",{style:{margin:"5px 0 0 0",color:"#646970"}},(0,u.__)("Override default tax options for specific user roles.","tier-pricing-table")))),(0,n.createElement)("input",{type:"hidden",name:"tpt_role_tax_settings",value:JSON.stringify(e||{})}),0===o.length?(0,n.createElement)("div",{style:{padding:"40px",textAlign:"center",background:"#fff",border:"1px solid #c3c4c7",borderRadius:"8px",marginBottom:"24px",color:"#50575e"}},(0,n.createElement)("div",{style:{display:"flex",justifyContent:"center",marginBottom:"12px",color:"#a7aaad"}},(0,n.createElement)("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},(0,n.createElement)("path",{d:"M18 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),(0,n.createElement)("circle",{cx:"10",cy:"7",r:"4"}),(0,n.createElement)("circle",{cx:"18",cy:"17",r:"5",fill:"#fff"}),(0,n.createElement)("line",{x1:"16",y1:"19",x2:"20",y2:"15"}),(0,n.createElement)("circle",{cx:"16.5",cy:"15.5",r:"0.5",fill:"currentColor"}),(0,n.createElement)("circle",{cx:"19.5",cy:"18.5",r:"0.5",fill:"currentColor"}))),(0,n.createElement)("h3",{style:{margin:"0 0 8px",fontSize:"16px",color:"#1d2327",fontWeight:600}},(0,u.__)("No Custom Tax Configurations","tier-pricing-table")),(0,n.createElement)("p",{style:{margin:"0 0 8px",fontSize:"14px"}},(0,u.__)("Configure custom tax rules for specific user roles.","tier-pricing-table")),(0,n.createElement)("p",{style:{margin:"0 0 20px",fontSize:"13px",color:"#646970",maxWidth:"500px",marginLeft:"auto",marginRight:"auto"}},(0,u.__)("Select a role below to create your first configuration.","tier-pricing-table")),(0,n.createElement)("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"center"}},(0,n.createElement)(l.SelectControl,{options:[{label:(0,u.__)("Select a role...","tier-pricing-table"),value:""},...y],value:g,onChange:e=>x(e),style:{marginBottom:0}}),(0,n.createElement)(l.Button,{variant:"primary",onClick:b,disabled:!g},(0,u.__)("Create Configuration","tier-pricing-table")))):(0,n.createElement)("div",{className:"tpt-accordion-container",style:{maxWidth:"650px"}},o.map(r=>{const a=m.find(e=>e.value===r)?.label||r;return(0,n.createElement)(l.PanelBody,{key:r,className:"tpt-role-settings-panel",title:(0,n.createElement)("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},(0,n.createElement)("span",{style:{fontWeight:600}},(0,u.__)("Custom Tax Configuration","tier-pricing-table")),(0,n.createElement)("span",{style:{background:"var(--wp-admin-theme-color, #2271b1)",padding:"4px 10px",borderRadius:"4px",fontSize:"12px",fontWeight:"600",color:"#fff"}},a)),initialOpen:f.includes(r)},!window.tptTaxSettings?.isPremium&&(0,n.createElement)("div",{className:"tpt-premium-banner"},(0,n.createElement)("p",{style:{margin:"0",fontSize:"13px"}},(0,n.createElement)("strong",null,(0,u.__)("Premium Feature","tier-pricing-table")),": ",(0,u.__)("Upgrading to premium to unlock role-based tax options.","tier-pricing-table")),(0,n.createElement)("a",{href:window.tptTaxSettings?.upgradeUrl||"#",target:"_blank",rel:"noopener noreferrer",className:"button button-primary"},(0,u.__)("Upgrade to Premium","tier-pricing-table"))),(0,n.createElement)(l.PanelRow,null,(0,n.createElement)("div",{style:{width:"100%",paddingTop:"20px",maxWidth:"600px",display:"flex",flexDirection:"column",gap:"20px"}},(0,n.createElement)(l.ToggleControl,{label:(0,u.__)("Tax Exempt","tier-pricing-table"),help:(0,u.__)("Disable tax calculation entirely for this role.","tier-pricing-table"),checked:!!e[r]?.tax_exempt,onChange:e=>v(r,"tax_exempt",e)}),!e[r]?.tax_exempt&&(0,n.createElement)(n.Fragment,null,(0,n.createElement)(l.RadioControl,{label:(0,u.__)("Tax Class","tier-pricing-table"),selected:e[r]?.tax_class||"default",options:[{label:(0,u.__)("Default (Inherit)","tier-pricing-table"),value:"default"},{label:(0,u.__)("Standard","tier-pricing-table"),value:"standard"},{label:(0,u.__)("Reduced Rate","tier-pricing-table"),value:"reduced-rate"},{label:(0,u.__)("Zero Rate","tier-pricing-table"),value:"zero-rate"}],onChange:e=>v(r,"tax_class",e)}),(0,n.createElement)(l.RadioControl,{label:(0,u.__)("Prices Entered With Tax","tier-pricing-table"),selected:e[r]?.prices_include_tax||"default",options:[{label:(0,u.__)("Default (Inherit)","tier-pricing-table"),value:"default"},{label:(0,u.__)("Yes, I will enter prices inclusive of tax","tier-pricing-table"),value:"yes"},{label:(0,u.__)("No, I will enter prices exclusive of tax","tier-pricing-table"),value:"no"}],onChange:e=>v(r,"prices_include_tax",e)}),(0,n.createElement)(l.RadioControl,{label:(0,u.__)("Display Prices in Shop","tier-pricing-table"),selected:e[r]?.display_shop||"default",options:[{label:(0,u.__)("Default (Inherit)","tier-pricing-table"),value:"default"},{label:(0,u.__)("Including Tax","tier-pricing-table"),value:"incl"},{label:(0,u.__)("Excluding Tax","tier-pricing-table"),value:"excl"}],onChange:e=>v(r,"display_shop",e)}),(0,n.createElement)(l.RadioControl,{label:(0,u.__)("Display Prices in Cart/Checkout","tier-pricing-table"),selected:e[r]?.display_cart||"default",options:[{label:(0,u.__)("Default (Inherit)","tier-pricing-table"),value:"default"},{label:(0,u.__)("Including Tax","tier-pricing-table"),value:"incl"},{label:(0,u.__)("Excluding Tax","tier-pricing-table"),value:"excl"}],onChange:e=>v(r,"display_cart",e)}),(0,n.createElement)(l.TextControl,{label:(0,u.__)("Price Display Suffix","tier-pricing-table"),help:(0,u.__)("Leave blank to inherit default settings.","tier-pricing-table"),value:void 0!==e[r]?.price_suffix?e[r]?.price_suffix:"",onChange:e=>v(r,"price_suffix",e),placeholder:(0,u.__)("N/A","tier-pricing-table")})),(0,n.createElement)("div",{style:{marginTop:"10px",paddingTop:"20px",borderTop:"1px solid #eee"}},(0,n.createElement)(l.Button,{isDestructive:!0,isTertiary:!0,icon:c,onClick:()=>(r=>{const n=o.filter(e=>e!==r),a={...e};delete a[r],s(n),t(a)})(r),style:{padding:0}},(0,u.__)("Remove Configuration","tier-pricing-table"))))))})),(0,n.createElement)(l.Flex,{gap:"4",style:{marginTop:"20px",alignItems:"center"}},o.length>0&&y.length>0&&(0,n.createElement)("div",{style:{display:"flex",gap:"10px",alignItems:"center"}},(0,n.createElement)(l.SelectControl,{options:[{label:(0,u.__)("Select a role...","tier-pricing-table"),value:""},...y],value:g,onChange:e=>x(e),style:{marginBottom:0,minWidth:"200px"}}),(0,n.createElement)(l.Button,{variant:"secondary",icon:p,onClick:b,disabled:!g},(0,u.__)("Add Configuration","tier-pricing-table")))))}document.addEventListener("DOMContentLoaded",()=>{const e=document.getElementById("tiered-pricing__feature__tax");e&&(0,a.render)((0,n.createElement)(g,null),e)})})();