woocommerce/packages/woocommerce-admin/dist/chunks/task-list.js

1 line
77 KiB
JavaScript
Raw Normal View History

2021-12-10 12:03:04 +00:00
(window.__wcAdmin_webpackJsonp=window.__wcAdmin_webpackJsonp||[]).push([[51],{162:function(e,t,o){"use strict";o.d(t,"a",(function(){return s}));var c=o(15),n=o(13);const s=(e,t={})=>{const{pathname:o,search:s}=window.location,a=Object(n.f)("connectNonce","");return t={"wccom-site":Object(n.f)("siteUrl"),"wccom-back":o+s,"wccom-woo-version":Object(n.f)("wcVersion"),"wccom-connect-nonce":a,...t},Object(c.addQueryArgs)(e,t)}},473:function(e,t,o){"use strict";var c=o(0),n=o(8),s=Object(c.createElement)(n.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(c.createElement)(n.Path,{d:"M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"}));t.a=s},475:function(e,t,o){"use strict";var c=o(0),n=o(8),s=Object(c.createElement)(n.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(c.createElement)(n.Path,{d:"M18.3 5.6L9.9 16.9l-4.6-3.4-.9 1.2 5.8 4.3 9.3-12.6z"}));t.a=s},526:function(e,t,o){"use strict";o.d(t,"a",(function(){return c})),o.d(t,"b",(function(){return n}));const c=(e,t,o="undefined")=>e&&Array.isArray(e)&&e.length?t?e.reduce((e,c)=>(c[t]||(c[t]=o),(e[c[t]]=e[c[t]]||[]).push(c),e),{}):e:{},n=(e,t)=>Object.entries(e).reduce((e,[o])=>({...e,[o]:t}),{})},527:function(e,t,o){"use strict";o.d(t,"b",(function(){return p})),o.d(t,"a",(function(){return u}));var c=o(35),n=o.n(c),s=o(0),a=o(2),i=o(28),r=o(4),l=o(13),m=o(21);const{countries:d}=Object(l.f)("dataEndpoints",{countries:{}});function p(e){const t={};return e.addressLine1.trim().length||(t.addressLine1=Object(a.__)("Please add an address",'woocommerce')),e.countryState.trim().length||(t.countryState=Object(a.__)("Please select a country / region",'woocommerce')),e.city.trim().length||(t.city=Object(a.__)("Please add a city",'woocommerce')),e.postCode.trim().length||(t.postCode=Object(a.__)("Please add a post code",'woocommerce')),t}function u(e){const{getInputProps:t,setValue:o}=e,c=Object(s.useMemo)(()=>d.reduce((e,t)=>{if(!t.states.length)return e.push({key:t.code,label:Object(i.decodeEntities)(t.name)}),e;const o=t.states.map(e=>({key:t.code+":"+e.code,label:Object(i.decodeEntities)(t.name)+" — "+Object(i.decodeEntities)(e.name)}));return e.push(...o),e},[]),[]),l=function(e,t,o){const[c,n]=Object(s.useState)(""),[a,i]=Object(s.useState)(""),l=Object(s.useRef)();return Object(s.useEffect)(()=>{const o=e.find(e=>e.key===t),s=o?o.label.split(/\u2013|\u2014|\-/):[],r=(s[0]||"").trim(),m=(s[1]||"").trim();l.current||r===c&&m===a||(n(r),i(m)),l.current=!1},[t]),Object(s.useEffect)(()=>{c||a||!t||(l.current=!0,o("countryState",""));let n=[];const s=new RegExp(Object(r.escapeRegExp)(c),"i"),i=new RegExp(Object(r.escapeRegExp)(a.replace(/\s/g,""))+"$","i");if((a.length||c.length)&&(n=e.filter(e=>(c.length?s:i).test(e.label))),c.length&&a.length){const e=a.length<3;n=n.filter(t=>i.test((e?t.key:t.label).replace("-","").replace(/\s/g,"")));const t=c.length<3;if(n.length>1){let e=[];e=n.filter(e=>s.test(t?e.key:e.label)),e.length>0&&(n=e)}if(n.length>1){let t=[];t=n.filter(t=>i.test((e?t.key:t.label).replace("-","").replace(/\s/g,""))),1===t.length&&(n=t)}}1===n.length&&t!==n[0].key&&(l.current=!0,o("countryState",n[0].key))},[c,a,e,o]),Object(s.createElement)(s.Fragment,null,Object(s.createElement)("input",{onChange:e=>n(e.target.value),value:c,name:"country",type:"text",className:"woocommerce-select-control__autofill-input",tabIndex:"-1",autoComplete:"country"}),Object(s.createElement)("input",{onChange:e=>i(e.target.value),value:a,name:"state",type:"text",className:"woocommerce-select-control__autofill-input",tabIndex:"-1",autoComplete:"address-level1"}))}(c,t("countryState").value,o);return Object(s.createElement)("div",{className:"woocommerce-store-address-fields"},Object(s.createElement)(m.TextControl,n()({label:Object(a.__)("Address line 1",'woocommerce'),required:!0,autoComplete:"address-line1"},t("addressLine1"))),Object(s.createElement)(m.TextControl,n()({label:Object(a.__)("Address line 2 (optional)",'woocommerce'),required:!0,autoComplete:"address-line2"},t("addressLine2"))),Object(s.createElement)(m.SelectControl,n()({label:Object(a.__)("Cou