250 lines
83 KiB
JavaScript
250 lines
83 KiB
JavaScript
|
(()=>{"use strict";var e={991:e=>{e.exports=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,o,a;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(o=r;0!=o--;)if(!e(t[o],n[o]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(o of t.entries())if(!n.has(o[0]))return!1;for(o of t.entries())if(!e(o[1],n.get(o[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(o of t.entries())if(!n.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if((r=t.length)!=n.length)return!1;for(o=r;0!=o--;)if(t[o]!==n[o])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(a=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(o=r;0!=o--;)if(!Object.prototype.hasOwnProperty.call(n,a[o]))return!1;for(o=r;0!=o--;){var i=a[o];if(!e(t[i],n[i]))return!1}return!0}return t!=t&&n!=n}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{const e=window.React;var t=n.n(e);const r=window.wp.element;function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o.apply(this,arguments)}function a(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}var i=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|
|
||
|
display: flex;
|
||
|
flex-flow: column;
|
||
|
margin-bottom: 24px;
|
||
|
&:last-child {
|
||
|
margin-bottom: 0;
|
||
|
}
|
||
|
@media ( min-width: 800px ) {
|
||
|
flex-flow: row;
|
||
|
}
|
||
|
.components-base-control {
|
||
|
label {
|
||
|
text-transform: none !important;
|
||
|
}
|
||
|
}
|
||
|
`,Xe=Oe.div`
|
||
|
flex: 0 1 auto;
|
||
|
margin-bottom: 24px;
|
||
|
@media ( min-width: 800px ) {
|
||
|
flex: 0 0 250px;
|
||
|
margin: 0 32px 0 0;
|
||
|
}
|
||
|
h2 {
|
||
|
font-size: 16px;
|
||
|
line-height: 24px;
|
||
|
}
|
||
|
p {
|
||
|
font-size: 13px;
|
||
|
line-height: 17.89px;
|
||
|
margin: 12px 0;
|
||
|
}
|
||
|
> :last-child {
|
||
|
margin-bottom: 0;
|
||
|
}
|
||
|
`,Ye=Oe.div`
|
||
|
flex: 1 1 auto;
|
||
|
margin-bottom: 12px;
|
||
|
`,Ke=({Description:t=(()=>null),children:n,...r})=>(0,e.createElement)(qe,{...r},(0,e.createElement)(Xe,null,(0,e.createElement)(t,null)),(0,e.createElement)(Ye,null,n)),Je=Oe(We.Card)`
|
||
|
border-radius: 3px;
|
||
|
`,Ze=Oe(We.CardBody)`
|
||
|
padding: 24px;
|
||
|
|
||
|
// increasing the specificity of the styles to override the Gutenberg ones
|
||
|
&.is-size-medium.is-size-medium {
|
||
|
padding: 24px;
|
||
|
}
|
||
|
|
||
|
h4 {
|
||
|
margin-top: 0;
|
||
|
margin-bottom: 1em;
|
||
|
}
|
||
|
|
||
|
> * {
|
||
|
margin-top: 0;
|
||
|
margin-bottom: 1.5em;
|
||
|
|
||
|
// fixing the spacing on the inputs and their help text, to ensure it is consistent
|
||
|
&:last-child {
|
||
|
margin-bottom: 0;
|
||
|
|
||
|
> :last-child {
|
||
|
margin-bottom: 0;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
input,
|
||
|
select {
|
||
|
margin: 0;
|
||
|
}
|
||
|
|
||
|
// spacing adjustment on "Express checkouts > Show express checkouts on" list
|
||
|
ul > li:last-child {
|
||
|
margin-bottom: 0;
|
||
|
|
||
|
.components-base-control__field {
|
||
|
margin-bottom: 0;
|
||
|
}
|
||
|
}
|
||
|
`,Qe=({children:t,...n})=>(0,e.createElement)(Je,null,(0,e.createElement)(Ze,{...n},t)),et=window.wp.url,tt=window.wp.apiFetch;var nt=n.n(tt);const rt=window.wp.data;var ot=n(991),at=n.n(ot);const it=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object,lt={enabled:!1,title:(0,Ae.__)("Local Pickup","woocommerce"),tax_status:"taxable",cost:""},st={hasLegacyPickup:!1,storeCountry:"",storeState:""},ct=()=>{const e=hydratedScreenSettings.pickupLocationSettings;return{enabled:null!=e&&e.enabled?"yes"===(null==e?void 0:e.enabled):lt.enabled,title:(null==e?void 0:e.title)||lt.title,tax_status:(null==e?void 0:e.tax_status)||lt.tax_status,cost:(null==e?void 0:e.cost)||lt.cost}},ut=()=>(hydratedScreenSettings.pickupLocations||[]).map(((e,t)=>({...e,id:(0,et.cleanForSlug)(e.name)+"-"+t}))),dt=hydratedScreenSettings.readonlySettings||st,pt=(0,Te.getSetting)("countries",[]),ft=(0,Te.getSetting)("countryStates",[]),gt={options:Object.keys(pt).map((e=>{const t=ft[e]||{};if(0===Object.keys(t).length)return{options:[{value:e,label:pt[e]}]};const n=Object.keys(t).map((n=>({value:`${e}:${n}`,label:`${pt[e]} — ${t[n]}`})));return{label:pt[e],options:[...n]}}))},ht=(0,r.createContext)({settings:lt,readOnlySettings:st,setSettingField:()=>()=>{},pickupLocations:[],setPickupLocations:()=>{},toggleLocation:()=>{},updateLocation:()=>{},isSaving:!1,save:()=>{}}),mt=()=>(0,r.useContext)(ht),vt=({children:t})=>{const[n,o]=(0,r.useState)(!1),[a,i]=(0,r.useState)(ut),[l,s]=(0,r.useState)(ct),c=(0,r.useCallback)((e=>t=>{s((n=>({...n,[e]:t})))}),[]),u=(0,r.useCallback)((e=>{i((t=>{const n=t.findIndex((({id:t})=>t===e)),r=[...t];return r[n].enabled=!t[n].enabled,r}))}),[]),d=(0,r.useCallback)((()=>{const e={pickup_location_settings:{enabled:l.enabled?"yes":"no",title:l.title,tax_status:["taxable","none"].includes(l.tax_status)?l.tax_status:"taxable",cost:l.cost},pickup_locations:a.map((e=>({name:e.name,address:e.address,details:e.details,enabled:e.enabled})))};o(!0),nt()({path:"/wp/v2/settings",method:"POST",data:e}).then((t=>{o(!1),at()(t.pickup_location_settings,e.pickup_location_settings)&&at()(t.pickup_locations,e.pickup_locations)&&(0,rt.dispatch)("core/notices").createSuccessNotice((0,Ae.__)("Local Pickup settings have been saved.","woocommerce"))}))}),[l,a]),p={settings:l,setSettingField:c,readOnlySettings:dt,pickupLocations:a,setPickupLocations:i,toggleLocation:u,updateLocation:(e,t)=>{i((n=>"new"===e?[...n,{...t,id:(0,et.cleanForSlug)(t.name)+"-"+n.length}]:n.map((n=>n.id===e?t:n)).filter(Boolean)))},isSaving:n,save:d};return(0,e.createElement)(ht.Provider,{value:p},t)},bt=()=>(0,e.createElement)(e.Fragment,null,(0,e.createElement)("h2",null,(0,Ae.__)("General","woocommerce")),(0,e.createElement)("p",null,(0,Ae.__)("Enable or disable local pickup on your store, and define costs. Local pickup is only available from the block checkout.","woocommerce")),(0,e.createElement)(We.ExternalLink,{href:`${Te.ADMIN_URL}post.php?post=${Ve}&action=edit`},(0,Ae.__)("View checkout page","woocommerce"))),yt=Oe(We.Notice)`
|
||
|
margin-left: 0;
|
||
|
margin-right: 0;
|
||
|
`,wt=()=>{const{settings:t,setSettingField:n,readOnlySettings:o}=mt(),[a,i]=(0,r.useState)(!!t.cost),l=(0,Te.getSetting)("shippingCostRequiresAddress",!1);return(0,e.createElement)(Ke,{Description:bt},(0,e.createElement)(Qe,null,o.hasLegacyPickup&&(0,e.createElement)(yt,{status:"warning",isDismissible:!1},(0,r.createInterpolateElement)((0,Ae.__)("Enabling this will produce duplicate options at checkout. Remove the local pickup shipping method from your <a>shipping zones</a>.","woocommerce"),{a:(0,e.createElement)("a",{href:`${Te.ADMIN_URL}admin.php?page=wc-settings&tab=shipping`,target:"_blank",rel:"noopener noreferrer"})})),(0,e.createElement)(We.CheckboxControl,{checked:t.enabled,name:"local_pickup_enabled",onChange:n("enabled"),label:(0,Ae.__)("Enable local pickup","woocommerce"),help:(0,e.createElement)("span",null,(0,Ae.__)("When enabled, local pickup will appear as an option on the block based checkout.","woocommerce"),l?(0,e.createElement)(e.Fragment,null,(0,e.createElement)("br",null),(0,Ae.__)('If local pickup is enabled, the "Hide shipping costs until an address is entered" setting will be ignored.',"woocommerce")):null)}),(0,e.createElement)(We.TextControl,{label:(0,Ae.__)("Title","woocommerce"),name:"local_pickup_title",help:(0,Ae.__)("This is the shipping method title shown to customers.","woocommerce"),placeholder:(0,Ae.__)("Local Pickup","woocommerce"),value:t.title,onChange:n("title"),disabled:!1,autoComplete:"off",required:!0,onInvalid:e=>{e.target.setCustomValidity((0,Ae.__)("Local pickup title is required","woocommerce"))},onInput:e=>{e.target.setCustomValidity("")}}),(0,e.createElement)(We.CheckboxControl,{checked:a,onChange:()=>{i(!a),n("cost")("")},label:(0,Ae.__)("Add a price for customers who choose local pickup","woocommerce"),help:(0,Ae.__)("By default, the local pickup shipping method is free.","woocommerce")}),a?(0,e.createElement)(e.Fragment,null,(0,e.createElement)(We.TextControl,{label:(0,Ae.__)("Cost","woocommerce"),name:"local_pickup_cost",help:(0,Ae.__)("Optional cost to charge for local pickup.","woocommerce"),placeholder:(0,Ae.__)("Free","woocommerce"),type:"number",pattern:"[0-9]+\\.?[0-9]*",min:0,value:t.cost,onChange:n("cost"),disabled:!1,autoComplete:"off"}),(0,e.createElement)(We.SelectControl,{label:(0,Ae.__)("Taxes","woocommerce"),name:"local_pickup_tax_status",help:(0,Ae.__)("If a cost is defined, this controls if taxes are applied to that cost.","woocommerce"),options:[{label:(0,Ae.__)("Taxable","woocommerce"),value:"taxable"},{label:(0,Ae.__)("Not taxable","woocommerce"),value:"none"}],value:t.tax_status,onChange:n("tax_status"),disabled:!1})):null))},xt=(0,r.forwardRef)((function({icon:e,size:t=24,...n},o){return(0,r.cloneElement)(e,{width:t,height:t,...n,ref:o})})),kt=window.wp.primitives,Et=(0,e.createElement)(kt.SVG,{width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,e.createElement)(kt.Path,{d:"M8 7h2V5H8v2zm0 6h2v-2H8v2zm0 6h2v-2H8v2zm6-14v2h2V5h-2zm0 8h2v-2h-2v2zm0 6h2v-2h-2v2z"})),Ct=window.ReactDOM,St="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function _t(e){const t=Object.prototype.toString.call(e);return"[object Window]"===t||"[object global]"===t}function Rt(e){return"nodeType"in e}function Dt(e){var t,n;return e?_t(e)?e:Rt(e)&&null!=(t=null==(n=e.ownerDocument)?void 0:n.defaultView)?t:window:window}function Ot(e){const{Document:t}=Dt(e);return e instanceof t}function At(e){return!_t(e)&&e instanceof Dt(e).HTMLElement}function Tt(e){return e?_t(e)?e.document:Rt(e)?Ot(e)?e:At(e)?e.ownerDocument:document:document:document}const Mt=St?e.useLayoutEffect:e.useEffect;function It(t){const n=(0,e.useRef)(t);return Mt((()=>{n.current=t})),(0,e.useCallback)((function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return null==n.current?void 0:n.current(...t)}),[])}function Nt(t,n){void 0===n&&(n=[t]);const r=(0,e.useRef)(t);return Mt((()=>{r.current!==t&&(r.current=t)}),n),r}function Lt(t,n){const r=(0,e.useRef)();return(0,e.useMemo)((()=>{const e=t(r.current);return
|
||
|
background: #fff;
|
||
|
border: 0;
|
||
|
border-radius: 3px;
|
||
|
box-shadow: 0 0 0 1px rgb( 0 0 0 / 10% );
|
||
|
border-spacing: 0;
|
||
|
width: 100%;
|
||
|
clear: both;
|
||
|
margin: 0;
|
||
|
font-size: 14px;
|
||
|
|
||
|
.align-left {
|
||
|
text-align: left;
|
||
|
.components-flex {
|
||
|
justify-content: flex-start;
|
||
|
gap: 0;
|
||
|
}
|
||
|
}
|
||
|
.align-right {
|
||
|
text-align: right;
|
||
|
.components-flex {
|
||
|
justify-content: flex-end;
|
||
|
gap: 0;
|
||
|
}
|
||
|
}
|
||
|
.align-center {
|
||
|
text-align: center;
|
||
|
> * {
|
||
|
margin: 0 auto;
|
||
|
}
|
||
|
.components-flex {
|
||
|
display: block;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
.sortable-table__handle {
|
||
|
cursor: move;
|
||
|
}
|
||
|
|
||
|
th {
|
||
|
position: relative;
|
||
|
color: #2c3338;
|
||
|
text-align: left;
|
||
|
vertical-align: middle;
|
||
|
vertical-align: top;
|
||
|
word-wrap: break-word;
|
||
|
}
|
||
|
|
||
|
tbody {
|
||
|
td {
|
||
|
vertical-align: top;
|
||
|
margin-bottom: 9px;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
tfoot {
|
||
|
td {
|
||
|
text-align: left;
|
||
|
vertical-align: middle;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
thead,
|
||
|
tfoot,
|
||
|
tbody {
|
||
|
td,
|
||
|
th {
|
||
|
border-top: 1px solid rgb( 0 0 0 / 10% );
|
||
|
border-bottom: 1px solid rgb( 0 0 0 / 10% );
|
||
|
padding: 16px 0 16px 24px;
|
||
|
line-height: 1.5;
|
||
|
|
||
|
&:last-child {
|
||
|
padding-right: 24px;
|
||
|
}
|
||
|
|
||
|
> svg,
|
||
|
> .components-base-control {
|
||
|
margin: 3px 0;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
thead th {
|
||
|
border-top: 0;
|
||
|
}
|
||
|
|
||
|
tfoot td {
|
||
|
border-bottom: 0;
|
||
|
}
|
||
|
`,Zr=({columns:t,data:n,setData:o,className:a,footerContent:i,placeholder:l})=>{const s=(0,r.useMemo)((()=>n.map((({id:e})=>e))),[n]),c=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(0,e.useMemo)((()=>[...n].filter((e=>null!=e))),[...n])}(on(Zn,{}),on(er,{}),on(Gn,{})),u=(e,t)=>{const n=(null==e?void 0:e.align)||"left",r=(null==e?void 0:e.width)||"auto";return{className:`${t}-${e.name} align-${n}`,style:{width:r}}};return(0,e.createElement)(Dr,{sensors:c,onDragEnd:function(e){const{active:t,over:r}=e;if(null!==t&&null!==r&&(null==t?void 0:t.id)!==(null==r?void 0:r.id)){const e=Nr(n,s.indexOf(t.id),s.indexOf(r.id));o(e)}},collisionDetection:un,modifiers:[Ir]},(0,e.createElement)(Jr,{className:`${a} sortable-table`},(0,e.createElement)("thead",null,(0,e.createElement)("tr",null,t.map(((t,n)=>(0,e.createElement)("th",{key:t.name,...u(t,"sortable-table__column"),colSpan:0===n?2:1},t.label))))),i&&(0,e.createElement)("tfoot",null,(0,e.createElement)("tr",null,(0,e.createElement)("td",{colSpan:t.length+1},(0,e.createElement)(i,null)))),(0,e.createElement)("tbody",null,(0,e.createElement)(Ur,{items:s,strategy:Br},n.length?n.map((n=>n&&(0,e.createElement)(Kr,{key:n.id,id:n.id,className:a},t.map((t=>{return(0,e.createElement)("td",{key:`${n.id}-${t.name}`,...u(t,"sortable-table__column")},t.renderCallback?t.renderCallback(n):(0,e.createElement)(e.Fragment,null,(r=n,o=t.name,it(r)&&o in r&&n[t.name])));var r,o}))))):(0,e.createElement)("tr",null,(0,e.createElement)("td",{colSpan:t.length+1},l))))))},Qr=Oe(We.Modal)`
|
||
|
max-width: 600px;
|
||
|
border-radius: 4px;
|
||
|
@media ( min-width: 600px ) {
|
||
|
min-width: 560px;
|
||
|
}
|
||
|
|
||
|
.components-modal__header {
|
||
|
padding: 12px 24px;
|
||
|
border-bottom: 1px solid #e0e0e0;
|
||
|
position: relative;
|
||
|
height: auto;
|
||
|
width: auto;
|
||
|
margin: 0 -24px 16px;
|
||
|
|
||
|
@media ( max-width: 599px ) {
|
||
|
button {
|
||
|
display: none;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
.components-modal__content {
|
||
|
margin: 0;
|
||
|
padding: 0 24px;
|
||
|
|
||
|
@media ( max-width: 599px ) {
|
||
|
display: flex;
|
||
|
flex-direction: column;
|
||
|
|
||
|
hr:last-of-type {
|
||
|
margin-top: auto;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
.components-base-control {
|
||
|
label {
|
||
|
margin-top: 8px;
|
||
|
text-transform: none !important;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
`,eo=Oe.div`
|
||
|
display: flex;
|
||
|
justify-content: flex-end;
|
||
|
border-top: 1px solid #e0e0e0;
|
||
|
margin: 24px -24px 0;
|
||
|
padding: 24px;
|
||
|
|
||
|
> * {
|
||
|
&:not( :first-of-type ) {
|
||
|
margin-left: 8px;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
.button-link-delete {
|
||
|
margin-right: auto;
|
||
|
color: #d63638;
|
||
|
}
|
||
|
`,to=({children:t,actions:n,title:r,onRequestClose:o,...a})=>(0,e.createElement)(Qr,{title:r,onRequestClose:o,...a},t,(0,e.createElement)(eo,null,n)),no=({formRef:t,values:n,setValues:r})=>{const{country:o,state:a}=n.address,i=e=>t=>{r((n=>({...n,[e]:t})))},l=e=>t=>{r((n=>({...n,address:{...n.address,[e]:t}})))},s=ft[o]&&Object.keys(ft[o]).length>0;return(0,e.createElement)("form",{ref:t},(0,e.createElement)(We.TextControl,{label:(0,Ae.__)("Location name","woocommerce"),name:"location_name",value:n.name,onChange:i("name"),autoComplete:"off",required:!0,onInvalid:e=>{e.target.setCustomValidity((0,Ae.__)("A Location title is required","woocommerce"))},onInput:e=>{e.target.setCustomValidity("")}}),(0,e.createElement)(We.TextControl,{label:(0,Ae.__)("Address","woocommerce"),name:"location_address",placeholder:(0,Ae.__)("Address","woocommerce"),value:n.address.address_1,onChange:l("address_1"),autoComplete:"off"}),(0,e.createElement)(We.TextControl,{label:(0,Ae.__)("City","woocommerce"),name:"location_city",hideLabelFromVision:!0,placeholder:(0,Ae.__)("City","woocommerce"),value:n.address.city,onChange:l("city"),autoComplete:"off"}),(0,e.createElement)(We.TextControl,{label:(0,Ae.__)("Postcode / ZIP","woocommerce"),name:"location_postcode",hideLabelFromVision:!0,placeholder:(0,Ae.__)("Postcode / ZIP","woocommerce"),value:n.address.postcode,onChange:l("postcode"),autoComplete:"off"}),!s&&(0,e.createElement)(We.TextControl,{placeholder:(0,Ae.__)("State","woocommerce"),value:a,onChange:l("state")}),(0,e.createElement)(We.SelectControl,{name:"location_country_state",label:(0,Ae.__)("Country / State","woocommerce"),hideLabelFromVision:!0,placeholder:(0,Ae.__)("Country / State","woocommerce"),value:!a&&s?`${o}:${Object.keys(ft[o])[0]}`:`${o}${a&&null!==(c=ft[o])&&void 0!==c&&c[a]?":"+a:""}`,onChange:e=>{const[t,n=""]=e.split(":");l("country")(t),l("state")(n)}},gt.options.map((t=>t.label?(0,e.createElement)("optgroup",{key:t.label,label:t.label},t.options.map((t=>(0,e.createElement)("option",{key:t.value,value:t.value},t.label)))):(0,e.createElement)("option",{key:t.options[0].value,value:t.options[0].value},t.options[0].label)))),(0,e.createElement)(We.TextControl,{label:(0,Ae.__)("Pickup details","woocommerce"),name:"pickup_details",value:n.details,onChange:i("details"),autoComplete:"off"}));var c},ro=({locationData:t,editingLocation:n,onClose:o,onSave:a,onDelete:i})=>{const l=(0,r.useRef)(null),[s,c]=(0,r.useState)(t);return t?(0,e.createElement)(to,{onRequestClose:o,title:"new"===n?(0,Ae.__)("Pickup location","woocommerce"):(0,Ae.__)("Edit pickup location","woocommerce"),actions:(0,e.createElement)(e.Fragment,null,"new"!==n&&(0,e.createElement)(We.Button,{variant:"link",className:"button-link-delete",onClick:()=>{i(),o()}},(0,Ae.__)("Delete location","woocommerce")),(0,e.createElement)(We.Button,{variant:"secondary",onClick:o},(0,Ae.__)("Cancel","woocommerce")),(0,e.createElement)(We.Button,{variant:"primary",onClick:()=>{(null==l?void 0:l.current).reportValidity()&&(a(s),o())}},(0,Ae.__)("Done","woocommerce")))},(0,e.createElement)(no,{formRef:l,values:s,setValues:c})):null},oo=()=>(0,e.createElement)(e.Fragment,null,(0,e.createElement)("h2",null,(0,Ae.__)("Pickup locations","woocommerce")),(0,e.createElement)("p",null,(0,Ae.__)("Define pickup locations for your customers to choose from during checkout.","woocommerce")),(0,e.createElement)(We.ExternalLink,{href:"https://woocommerce.com/document/woocommerce-blocks-local-pickup/"},(0,Ae.__)("Learn more","woocommerce"))),ao=Oe.address`
|
||
|
color: #757575;
|
||
|
font-style: normal;
|
||
|
display: inline;
|
||
|
margin-left: 12px;
|
||
|
`,io=()=>{const{pickupLocations:t,setPickupLocations:n,toggleLocation:o,updateLocation:a,readOnlySettings:i}=mt(),[l,s]=(0,r.useState)(""),c=[{name:"name",label:(0,Ae.__)("Pickup location","woocommerce"),width:"50%",renderCallback:t=>(0,e.createElement)(e.Fragment,null,t.name,(0,e.createElement)(ao,null,(e=>{var t;const n=it(e)&&{...e,country:"string"==typeof e.country&&pt[e.country],state:"string"==typeof e.country&&"string"==typeof e.state&&null!==(t=ft[e.country])&&void 0!==t&&t[e.state]?ft[e.country][e.state]:e.state};return Object.values(n).filter((e=>""!==e)).join(", ")})(t.address)))},{name:"enabled",label:(0,Ae.__)("Enabled","woocommerce"),align:"right",renderCallback:t=>{return(0,e.createElement)(We.ToggleControl,{checked:(n=t.enabled,"boolean"==typeof n&&t.enabled),onChange:()=>o(t.id)});var n}},{name:"edit",label:"",align:"center",width:"1%",renderCallback:t=>(0,e.createElement)("button",{type:"button",className:"button-link-edit button-link",onClick:()=>{s(t.id)}},(0,Ae.__)("Edit","woocommerce"))}];return(0,e.createElement)(Ke,{Description:oo},(0,e.createElement)(Zr,{className:"pickup-locations",columns:c,data:t,setData:e=>{n(e)},placeholder:(0,Ae.__)("When you add a pickup location, it will appear here.","woocommerce"),footerContent:()=>(0,e.createElement)(We.Button,{variant:"secondary",onClick:()=>{s("new")}},(0,Ae.__)("Add pickup location","woocommerce"))}),l&&(0,e.createElement)(ro,{locationData:"new"===l?{name:"",details:"",enabled:!0,address:{address_1:"",city:"",state:i.storeState,postcode:"",country:i.storeCountry}}:t.find((({id:e})=>e===l))||null,editingLocation:l,onSave:e=>{a(l,e)},onClose:()=>s(""),onDelete:()=>{a(l,null),s("")}}))},lo=Oe(Ke)`
|
||
|
text-align: right;
|
||
|
padding-top: 0;
|
||
|
margin-top: 0;
|
||
|
`,so=()=>{const{isSaving:t,save:n}=mt();return(0,e.createElement)(lo,{className:"submit"},(0,e.createElement)(We.Button,{variant:"primary",isBusy:t,disabled:t,onClick:e=>{var t;e.preventDefault();const r=e.target;null!=r&&null!==(t=r.form)&&void 0!==t&&t.reportValidity()&&n()},type:"submit"},(0,Ae.__)("Save changes","woocommerce")))},co=Oe.form`
|
||
|
margin: 48px auto 0;
|
||
|
max-width: 1032px;
|
||
|
display: flex;
|
||
|
flex-flow: column;
|
||
|
|
||
|
@media ( min-width: 960px ) {
|
||
|
padding: 0 56px;
|
||
|
}
|
||
|
`,uo=document.getElementById("wc-shipping-method-pickup-location-settings-container");uo&&(0,r.render)((0,e.createElement)((()=>(0,e.createElement)(co,{id:"local-pickup-settings"},(0,e.createElement)(vt,null,(0,e.createElement)(wt,null),(0,e.createElement)(io,null),(0,e.createElement)(so,null)))),null),uo)})()})();
|