PluginProbe
Tiered Pricing Table for WooCommerce / 7.1.7
Tiered Pricing Table for WooCommerce v7.1.7
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 / CustomColumns / build / index.js

index.js in Tiered Pricing Table for WooCommerce 7.1.7, at src/Addons/CustomColumns/build/index.js

1 lines 11.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (()=>{"use strict";var t={n:e=>{var i=e&&e.__esModule?()=>e.default:()=>e;return t.d(i,{a:i}),i},d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const e=window.wp.element,i=window.wp.apiFetch;var n=t.n(i);const r=window.wp.components,o=window.wp.i18n,l=window.ReactJSXRuntime,s=({column:t,onUpdate:e,onRemove:i})=>{const n=(i,n)=>e(t.slug,{...t,[i]:n});return(0,l.jsxs)("div",{style:{background:"#fff",border:"1px solid #e2e4e7",borderRadius:"8px",marginBottom:"16px",display:"flex",alignItems:"flex-start",padding:"20px",gap:"20px",boxShadow:"0 1px 3px rgba(0,0,0,0.04)",position:"relative"},children:[(0,l.jsx)("style",{children:'\n\t\t\t\t.tier-column-field { flex: 1 1 200px; min-width: 0; }\n\t\t\t\t.tier-column-field select,\n\t\t\t\t.tier-column-field input[type="text"] { min-width: 0 !important; width: 100% !important; }\n\t\t\t\t.tier-remove-col-btn { position: absolute; top: 8px; right: 8px; background: none; border: none; color: #d63638; cursor: pointer; padding: 4px; display: flex; align-items: center; justify-content: center; opacity: 0.5; transition: opacity 0.2s; border-radius: 4px; }\n\t\t\t\t.tier-remove-col-btn:hover { opacity: 1; background: rgba(214, 54, 56, 0.1); }\n\t\t\t\t'}),(0,l.jsx)("div",{className:"tier-column-field",children:(0,l.jsx)(r.TextControl,{label:(0,o.__)("Column Title","tier-pricing-table"),value:t.name,onChange:t=>n("name",t),placeholder:(0,o.__)("e.g., Discounted Price","tier-pricing-table")})}),(0,l.jsx)("div",{className:"tier-column-field",children:(0,l.jsx)(r.SelectControl,{label:(0,o.__)("Column Data Type","tier-pricing-table"),value:t.type||"",options:[{label:(0,o.__)("Select column type...","tier-pricing-table"),value:"",disabled:!0},{label:(0,o.__)("Custom column","tier-pricing-table"),value:"custom"},{label:(0,o.__)("Price excluding taxes","tier-pricing-table"),value:"price_excl_taxes"},{label:(0,o.__)("Price including taxes","tier-pricing-table"),value:"price_incl_taxes"},{label:(0,o.__)("Total row price","tier-pricing-table"),value:"total_price"},{label:(0,o.__)("Saving per item","tier-pricing-table"),value:"saving_per_item"}],onChange:t=>n("type",t)})}),"custom"===t.type&&(0,l.jsx)("div",{className:"tier-column-field",children:(0,l.jsx)(r.SelectControl,{label:(0,o.__)("Format","tier-pricing-table"),value:t.data_type||"text",options:[{label:(0,o.__)("Price","tier-pricing-table"),value:"price"},{label:(0,o.__)("Number","tier-pricing-table"),value:"number"},{label:(0,o.__)("Text","tier-pricing-table"),value:"text"}],onChange:t=>n("data_type",t)})}),(0,l.jsx)("button",{className:"tier-remove-col-btn",onClick:()=>i(t.slug),title:(0,o.__)("Remove column","tier-pricing-table"),children:(0,l.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,l.jsx)("path",{d:"M18 6 6 18"}),(0,l.jsx)("path",{d:"m6 6 12 12"})]})})]})},a=()=>{const[t,i]=(0,e.useState)([]),[a,d]=(0,e.useState)(!0),[c,p]=(0,e.useState)(!1),[x,m]=(0,e.useState)({message:"",type:"success"}),u=(t,e="success")=>{m({message:t,type:e}),setTimeout(()=>m({message:"",type:"success"}),4e3)},[g,f]=(0,e.useState)(0),b=[{title:(0,o.__)("Your Saving","tier-pricing-table"),rows:["-","$1.00 / item","$2.50 / item","$5.00 / item"]},{title:(0,o.__)("Price per piece","tier-pricing-table"),rows:["$10.00 / pc","$9.00 / pc","$7.50 / pc","$5.00 / pc"],isBox:!0},{title:(0,o.__)("Price incl tax","tier-pricing-table"),rows:["$12.00","$10.80","$9.00","$6.00"]}];(0,e.useEffect)(()=>{n()({path:"tier-pricing-table/features/custom-columns/v1/columns"}).then(t=>{i(Array.isArray(t)?t:[]),d(!1)})},[]),(0,e.useEffect)(()=>{if(t.length>0)return;const e=setInterval(()=>{f(t=>(t+1)%b.length)},3500);return()=>clearInterval(e)},[t.length]);const h=()=>{i([...t,{slug:"col_"+Math.random().toString(36).substr(2,9),name:"",type:"",data_type:"price"}])};return a?(0,l.jsx)("div",{style:{padding:"40px",textAlign:"center"},children:(0,l.jsx)(r.Spinner,{})}):(0,l.jsxs)("div",{className:"tier-custom-columns-settings",style:{marginTop:"20px",position:"relative",maxWidth:"975px"},children:[x.message&&(0,l.jsxs)("div",{style:{position:"fixed",bottom:"40px",left:"50%",transform:"translateX(-50%)",background:"#1d2327",color:"#fff",padding:"12px 24px",borderRadius:"4px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",zIndex:9999,fontSize:"14px",fontWeight:500,display:"flex",alignItems:"center",gap:"8px",animation:"tierToastSlideUp 0.3s ease-out forwards"},children:[(0,l.jsx)("style",{children:"\n\t\t\t\t\t\t@keyframes tierToastSlideUp {\n\t\t\t\t\t\t\tfrom { opacity: 0; transform: translate(-50%, 20px); }\n\t\t\t\t\t\t\tto { opacity: 1; transform: translate(-50%, 0); }\n\t\t\t\t\t\t}\n\t\t\t\t\t\t"}),"success"===x.type&&(0,l.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#46b450",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,l.jsx)("path",{d:"M20 6 9 17l-5-5"})}),"warning"===x.type&&(0,l.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#f0b849",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,l.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,l.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,l.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),x.message]}),!window.tptCustomColumns?.isPremium&&(0,l.jsxs)("div",{style:{background:"#f0f6fc",padding:"16px 16px",marginBottom:"24px",display:"flex",justifyContent:"space-between",borderRadius:"5px",alignItems:"center",border:"1px solid #ccc"},children:[(0,l.jsxs)("p",{style:{margin:"0",fontSize:"13px"},children:[(0,l.jsx)("strong",{children:(0,o.__)("Premium Feature","tier-pricing-table")}),": ",(0,o.__)("Upgrading to premium to unlock custom columns.","tier-pricing-table")]}),(0,l.jsx)("a",{href:window.tptCustomColumns?.upgradeUrl||"#",target:"_blank",rel:"noopener noreferrer",className:"button button-primary",children:(0,o.__)("Upgrade to Premium","tier-pricing-table")})]}),0===t.length&&(0,l.jsxs)("div",{style:{background:"#ffffff",border:"1px solid #c3c4c7",borderRadius:"8px",marginBottom:"24px",color:"#50575e",display:"flex",flexWrap:"wrap",alignItems:"stretch",overflow:"hidden"},children:[(0,l.jsxs)("div",{style:{flex:"1 1 300px",padding:"40px",textAlign:"left",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"flex-start"},children:[(0,l.jsx)("svg",{style:{margin:"0 0 16px",color:"#a7aaad",display:"block"},width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,l.jsx)("path",{d:"M12 3h7a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-7m0-18H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7m0-18v18"})}),(0,l.jsx)("h3",{style:{margin:"0 0 12px",fontSize:"20px",color:"#1d2327",fontWeight:600},children:(0,o.__)("No Custom Columns","tier-pricing-table")}),(0,l.jsx)("p",{style:{margin:"0 0 24px",fontSize:"14px",lineHeight:"1.5"},children:(0,o.__)("Add custom columns to display extra information alongside your pricing tiers.","tier-pricing-table")}),(0,l.jsx)(r.Button,{variant:"primary",onClick:h,children:(0,o.__)("Add your first column","tier-pricing-table")})]}),(0,l.jsx)("div",{style:{flex:"1 1 400px",padding:"40px",display:"flex",justifyContent:"center",alignItems:"center",background:"#f8f9fa",borderLeft:"1px solid #e2e4e7"},children:(0,l.jsxs)("div",{style:{width:"100%",maxWidth:"450px",background:"#fff",border:"1px solid #dcdcde",borderRadius:"4px",textAlign:"left",overflow:"hidden",boxShadow:"0 4px 12px rgba(0,0,0,0.08)"},children:[(0,l.jsx)("style",{children:"\n\t\t\t\t\t\t\t\t@keyframes tptPreviewTextFade {\n\t\t\t\t\t\t\t\t\t0% { opacity: 0; transform: translateY(-3px); }\n\t\t\t\t\t\t\t\t\t100% { opacity: 1; transform: translateY(0); }\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t.tpt-preview-animated {\n\t\t\t\t\t\t\t\t\tdisplay: inline-block;\n\t\t\t\t\t\t\t\t\tanimation: tptPreviewTextFade 0.4s ease-out forwards;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t"}),(0,l.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"14px",margin:0},children:[(0,l.jsx)("thead",{children:(0,l.jsxs)("tr",{style:{background:"#f6f7f7",borderBottom:"1px solid #dcdcde"},children:[(0,l.jsx)("th",{style:{padding:"12px 16px",fontWeight:600,textAlign:"left",border:"none"},children:(0,o.__)("Quantity","tier-pricing-table")}),(0,l.jsx)("th",{style:{padding:"12px 16px",fontWeight:600,textAlign:"left",border:"none"},children:(0,o.__)("Price","tier-pricing-table")}),(0,l.jsx)("th",{style:{padding:"12px 16px",fontWeight:600,textAlign:"left",border:"none",background:"#f0f6fc",color:"#0a4b78"},children:(0,l.jsx)("span",{className:"tpt-preview-animated",children:b[g].title},"th-"+g)})]})}),(0,l.jsxs)("tbody",{children:[(0,l.jsxs)("tr",{style:{borderBottom:"1px solid #f0f0f1"},children:[(0,l.jsx)("td",{style:{padding:"12px 16px",border:"none"},children:"1 - 4"}),(0,l.jsx)("td",{style:{padding:"12px 16px",border:"none"},children:b[g].isBox?"$100.00":"$10.00"}),(0,l.jsx)("td",{style:{padding:"12px 16px",border:"none",background:"#f6faff",color:"#0a4b78"},children:(0,l.jsx)("span",{className:"tpt-preview-animated",children:b[g].rows[0]},"td1-"+g)})]}),(0,l.jsxs)("tr",{style:{borderBottom:"1px solid #f0f0f1"},children:[(0,l.jsx)("td",{style:{padding:"12px 16px",border:"none"},children:"5 - 9"}),(0,l.jsx)("td",{style:{padding:"12px 16px",border:"none"},children:b[g].isBox?"$90.00":"$9.00"}),(0,l.jsx)("td",{style:{padding:"12px 16px",border:"none",background:"#f6faff",color:"#0a4b78",fontWeight:500},children:(0,l.jsx)("span",{className:"tpt-preview-animated",children:b[g].rows[1]},"td2-"+g)})]}),(0,l.jsxs)("tr",{style:{borderBottom:"1px solid #f0f0f1"},children:[(0,l.jsx)("td",{style:{padding:"12px 16px",border:"none"},children:"10 - 19"}),(0,l.jsx)("td",{style:{padding:"12px 16px",border:"none"},children:b[g].isBox?"$75.00":"$7.50"}),(0,l.jsx)("td",{style:{padding:"12px 16px",border:"none",background:"#f6faff",color:"#0a4b78",fontWeight:500},children:(0,l.jsx)("span",{className:"tpt-preview-animated",children:b[g].rows[2]},"td3-"+g)})]}),(0,l.jsxs)("tr",{children:[(0,l.jsx)("td",{style:{padding:"12px 16px",border:"none"},children:"20+"}),(0,l.jsx)("td",{style:{padding:"12px 16px",border:"none"},children:b[g].isBox?"$50.00":"$5.00"}),(0,l.jsx)("td",{style:{padding:"12px 16px",border:"none",background:"#f6faff",color:"#0a4b78",fontWeight:500},children:(0,l.jsx)("span",{className:"tpt-preview-animated",children:b[g].rows[3]},"td4-"+g)})]})]})]})]})})]}),t.map(e=>(0,l.jsx)(s,{column:e,onRemove:e=>i(t.filter(t=>t.slug!==e)),onUpdate:(e,n)=>i(t.map(t=>t.slug===e?n:t))},e.slug)),(0,l.jsxs)(r.Flex,{gap:"4",style:{marginTop:"20px"},children:[(0,l.jsx)(r.Button,{variant:"primary",onClick:()=>{window.tptCustomColumns?.isPremium?t.some(t=>!t.name||""===t.name.trim())?u((0,o.__)("Please enter a title for all custom columns before saving.","tier-pricing-table"),"warning"):(p(!0),n()({path:"tier-pricing-table/features/custom-columns/v1/columns",method:"POST",data:{columns:t}}).then(()=>{p(!1),u((0,o.__)("Columns saved successfully!","tier-pricing-table"),"success")})):u((0,o.__)("Please upgrade to the Premium version to save custom columns.","tier-pricing-table"),"warning")},isBusy:c,disabled:c,children:c?(0,o.__)("Saving...","tier-pricing-table"):(0,o.__)("Save Columns","tier-pricing-table")}),(0,l.jsx)(r.Button,{variant:"secondary",onClick:h,children:(0,o.__)("+ Add Column","tier-pricing-table")})]})]})};document.addEventListener("DOMContentLoaded",()=>{const t=document.getElementById("tiered-pricing__feature__custom-columns");t&&(0,e.createRoot)(t).render((0,l.jsx)(a,{}))})})();