Files
2026-04-28 15:13:50 +02:00

4 lines
12 KiB
JavaScript

(()=>{"use strict";var e,o={20:(e,o,t)=>{var r=t(609),l=Symbol.for("react.element"),i=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),a=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function s(e,o,t){var r,s={},n=null,d=null;for(r in void 0!==t&&(n=""+t),void 0!==o.key&&(n=""+o.key),void 0!==o.ref&&(d=o.ref),o)i.call(o,r)&&!c.hasOwnProperty(r)&&(s[r]=o[r]);if(e&&e.defaultProps)for(r in o=e.defaultProps)void 0===s[r]&&(s[r]=o[r]);return{$$typeof:l,type:e,key:n,ref:d,props:s,_owner:a.current}}o.jsx=s,o.jsxs=s},363:(e,o,t)=>{const r=window.wc.blocksCheckout,l=window.wc.wcSettings;function i(e){var o,t,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var l=e.length;for(o=0;o<l;o++)e[o]&&(t=i(e[o]))&&(r&&(r+=" "),r+=t)}else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}const a=function(){for(var e,o,t=0,r="",l=arguments.length;t<l;t++)(e=arguments[t])&&(o=i(e))&&(r&&(r+=" "),r+=o);return r},c=window.wc.blocksComponents,s=window.wc.wcBlocksData;var n=t(609);const d=window.wp.data,p=(window.wp.coreData,window.lodash),u=window.wp.i18n,h=window.wp.element,m=(0,h.forwardRef)((function({icon:e,size:o=24,...t},r){return(0,h.cloneElement)(e,{width:o,height:o,...t,ref:r})})),_=window.wp.primitives;var b=t(848);const w=(0,b.jsx)(_.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,b.jsx)(_.Path,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})}),f=e=>{const{onChange:o,options:t,label:r,value:l="",className:i,size:n,errorId:p,required:_,errorMessage:f=(0,u.__)("Please select a valid option","woo-checkout-field-editor-pro"),placeholder:k,...v}=e,g=(0,h.useCallback)((e=>{o(e.target.value)}),[o]),y=(0,h.useMemo)((()=>({value:"",label:null!=k?k:(0,u.sprintf)(
// translators: %s will be label of the field. For example "country/region".
// translators: %s will be label of the field. For example "country/region".
(0,u.__)("Select a %s","woo-checkout-field-editor-pro"),r?.toLowerCase()),disabled:!!_})),[r,k,_]),x=(0,h.useId)(),C=v.id||`wc-blocks-components-select-${x}`,j=p||C,E=(0,h.useMemo)((()=>_&&l?t:[y].concat(t)),[_,l,y,t]),{setValidationErrors:N,clearValidationError:O}=(0,d.useDispatch)(s.VALIDATION_STORE_KEY),{error:S,validationErrorId:$}=(0,d.useSelect)((e=>{const o=e(s.VALIDATION_STORE_KEY);return{error:o.getValidationError(j),validationErrorId:o.getValidationErrorId(j)}}));(0,h.useEffect)((()=>(!_||l?O(j):N({[j]:{message:f,hidden:!0}}),()=>{O(j)})),[O,l,j,f,_,N]);const I=(0,d.useSelect)((e=>e(s.VALIDATION_STORE_KEY).getValidationError(j||"")||{hidden:!0}));return(0,b.jsxs)("div",{className:a(i,{"has-error":!I.hidden}),children:[(0,b.jsx)("div",{className:"wc-blocks-components-select",children:(0,b.jsxs)("div",{className:"wc-blocks-components-select__container",children:[(0,b.jsx)("label",{htmlFor:C,className:"wc-blocks-components-select__label",children:r}),(0,b.jsx)("select",{className:"wc-blocks-components-select__select",id:C,size:void 0!==n?n:1,onChange:g,value:l,"aria-invalid":!(!S?.message||S?.hidden),"aria-errormessage":$,...v,children:E.map((e=>(0,b.jsx)("option",{value:e.value,"data-alternate-values":`[${e.label}]`,disabled:void 0!==e.disabled&&e.disabled,children:e.label},e.value)))},C),(0,b.jsx)(m,{className:"wc-blocks-components-select__expand",icon:w})]})}),(0,b.jsx)(c.ValidationInputError,{propertyName:j})]})},k=window.wp.compose,v=({label:e,secondaryLabel:o,description:t,secondaryDescription:r,id:l})=>(0,b.jsxs)("div",{className:"wc-block-components-radio-control__option-layout",children:[(0,b.jsxs)("div",{className:"wc-block-components-radio-control__label-group",children:[e&&(0,b.jsx)("span",{id:l&&`${l}__label`,className:"wc-block-components-radio-control__label",children:e}),o&&(0,b.jsx)("span",{id:l&&`${l}__secondary-label`,className:"wc-block-components-radio-control__secondary-label",children:o})]}),(t||r)&&(0,b.jsxs)("div",{className:"wc-block-components-radio-control__description-group",children:[t&&(0,b.jsx)("span",{id:l&&`${l}__description`,className:"wc-block-components-radio-control__description",children:t}),r&&(0,b.jsx)("span",{id:l&&`${l}__secondary-description`,className:"wc-block-components-radio-control__secondary-description",children:r})]})]}),g=({checked:e,name:o,onChange:t,option:r,disabled:l=!1,highlightChecked:i=!1})=>{const{value:c,label:s,description:n,secondaryLabel:d,secondaryDescription:p}=r;return(0,b.jsxs)("label",{className:a("wc-block-components-radio-control__option",{"wc-block-components-radio-control__option-checked":e,"wc-block-components-radio-control__option--checked-option-highlighted":e&&i}),htmlFor:`${o}-${c}`,children:[(0,b.jsx)("input",{id:`${o}-${c}`,className:"wc-block-components-radio-control__input",type:"radio",name:o,value:c,onChange:e=>t(e.target.value),checked:e,"aria-describedby":a({[`${o}-${c}__label`]:s,[`${o}-${c}__secondary-label`]:d,[`${o}-${c}__description`]:n,[`${o}-${c}__secondary-description`]:p}),"aria-disabled":l,onKeyDown:e=>{l&&["ArrowUp","ArrowDown","AllowLeft","ArrowRight"].includes(e.key)&&e.preventDefault()}}),(0,b.jsx)(v,{id:`${o}-${c}`,label:s,secondaryLabel:d,description:n,secondaryDescription:p})]})},y=({className:e="",id:o,selected:t="",onChange:r,options:l=[],disabled:i=!1,highlightChecked:p=!1,title:h="",required:m=!1,errorMessage:_=(0,u.__)("Please select an option","woo-checkout-field-editor-pro"),errorId:w})=>{const f=(0,k.useInstanceId)(y),v=o||f,x=w||v,{setValidationErrors:C,clearValidationError:j}=(0,d.useDispatch)(s.VALIDATION_STORE_KEY),E=(0,d.useSelect)((e=>e(s.VALIDATION_STORE_KEY).getValidationError(x)||{hidden:!0}));(0,n.useEffect)((()=>(!m||t?j(x):C({[x]:{message:_,hidden:!0}}),()=>{j(x)})),[t,m,x,_]);const N=(0,n.useMemo)((()=>l.findIndex((e=>e.value===t))),[l,t]);return l.length?(0,b.jsxs)("div",{className:a("wc-block-components-radio-control thwcfe-radio-control",{"has-error":!E.hidden,"wc-block-components-radio-control--highlight-checked--first-selected":p&&0===N,"wc-block-components-radio-control--highlight-checked--last-selected":p&&N===l.length-1,"wc-block-components-radio-control--highlight-checked":p},e),children:[(0,b.jsxs)("div",{className:"wc-block-components-cfe-radio-control__heading",children:[" ",h||""," "]}),l.map((e=>(0,b.jsx)(g,{highlightChecked:p,name:`radio-control-${v}`,checked:e.value===t,option:e,onChange:o=>{r(o),"function"==typeof e.onChange&&e.onChange(o)},disabled:i},`${v}-${e.value}`))),(0,b.jsx)(c.ValidationInputError,{propertyName:x})]}):null},x=y,C=e=>{const{errorId:o,errorMessage:t,autoCapitalize:r,autoComplete:l,placeholder:i,...a}=e;return a},j=window.wp.url,E=({field:e,onChange:o=""})=>{const{id:t,label:r,type:l,value:i,placeholder:s,required:d,options:p,title:h,validate:m,property_set:_,enabled:w,cssclass:k}=e,{default:v,checked:g}=_,y=(e=>({id:`section_one-${e?.id}`.replaceAll("/","-"),errorId:`section_${e?.id}`,label:e?.title,autoCapitalize:e?.autocapitalize,autoComplete:e?.autocomplete,errorMessage:e?.errorMessage,required:e?.required,placeholder:e?.placeholder,className:`wc-block-components-address-form__${e?.id}`.replaceAll("/","-"),options:e?.options?Object.values(e.options).map((e=>({value:e.key,label:e.text}))):[],...e?.attributes}))(e),E=(0,n.useRef)({}),[N,O]=(0,n.useState)(!1);if(!w||"0"===w)return null;const S=e=>{o({[t]:e})};if((0,n.useEffect)((()=>{void 0!==v&&S(v)}),[v]),"checkbox"===l&&(0,n.useEffect)((()=>{void 0!==g&&(S(g),O(!0))}),[g]),"email"!==e.type){if("checkbox"===l){var $;const o={...C(y),checked:Boolean(null!==($=null!=i?i:v)&&void 0!==$?$:g),onChange:e=>S(e)};return d&&void 0!==c.ValidatedCheckboxControl&&N?(0,b.jsx)(c.ValidatedCheckboxControl,{...o,errorMessage:e?.errorMessage,ref:e=>E.current[t]=e,required:!0},t):(0,b.jsx)(c.CheckboxControl,{...o},t)}return"select"===l&&e.options?(0,b.jsx)(f,{...y,label:h||"",className:a(k?.split(",").map((e=>e.trim())),"wc-block-components-select-input",`wc-block-components-select-input-${t}`.replaceAll("/","-")),value:i,onChange:S,options:y.options,required:d,errorMessage:y.errorMessage||void 0,placeholder:s||null},t):"radio"===l?(0,b.jsx)(x,{...y,selected:i,onChange:S,options:y.options,disabled:!1,highlightChecked:!0,title:h||"",className:a(k?.split(",").map((e=>e.trim())))}):(0,b.jsx)(c.ValidatedTextInput,{ref:e=>E.current[t]=e,...y,type:l,value:i,onChange:S,className:a(k?.split(",").map((e=>e.trim()))),customFormatter:o=>"postcode"===e.type?o.trimStart().toUpperCase():o,customValidation:e=>((e,o)=>!((e.required||e.value)&&("phone"!==o||(0,j.isPhoneNumber)(e.value)?"url"!==o||(0,j.isURL)(e.value)?"email"===o&&!(0,j.isEmail)(e.value)&&(e.setCustomValidity((0,u.__)("Please enter a valid email address","woo-checkout-field-editor-pro")),1):(e.setCustomValidity((0,u.__)("Please enter a valid URL","woo-checkout-field-editor-pro")),1):(e.setCustomValidity((0,u.__)("Please enter a valid Phone Number","woo-checkout-field-editor-pro")),1))))(e,m)},t)}},N=JSON.parse('{"apiVersion":2,"name":"woocommerce-checkout-field-editor-pro/additional-sections","version":"2.0.0","title":"Additional Checkout Sections Block","category":"woocommerce","description":"Render additional Section.","supports":{"html":false,"align":false,"multiple":false,"reusable":false},"attributes":{"className":{"type":"string","default":""},"lock":{"type":"object","default":{"remove":true,"move":false}},"title":{"type":"string","default":"Additional Information"},"description":{"type":"string","default":"Additional Fields"}},"parent":["woocommerce/checkout-fields-block"],"textdomain":"woocommerce-checkout-field-editor-pro"}'),O=(0,l.getSetting)("thwcfe-block-integration_data",""),{allSections:S}=O,{additional_info:$}=S,I=(0,l.getSetting)("thwcfe-block-integration_data",""),{allSections:A}=I,{additional_info:V}=A||{};V&&Object.keys(V).length>0&&(0,r.registerCheckoutBlock)({metadata:N,component:({checkoutExtensionData:e})=>{const o=$,{setExtensionData:t}=e,[r,l]=(0,n.useState)({}),i=(0,d.useSelect)((e=>e(s.CHECKOUT_STORE_KEY).isProcessing())),u=(0,n.useRef)(!1),h=(0,n.useCallback)((0,p.debounce)((e=>{t("thwcfe-additional-fields",o.id,e)}),1e3),[t]),m=(0,n.useCallback)((e=>{l((o=>({...o,...e})))}),[]);(0,n.useEffect)((()=>(Object.keys(r).length>0&&h(r),()=>{h.cancel()})),[r,h]),(0,n.useEffect)((()=>{if(u.current)return;const e=o.id,t=`thwcfe_sections_${e}`,r=()=>{const o=document.querySelector(`#${e}`),r=document.querySelector(`.${t}`),l=document.querySelector(".wc-block-checkout__actions.wp-block-woocommerce-checkout-actions-block");return!!(o&&r&&l)&&(r.parentNode&&r.parentNode.replaceChild(o,r),u.current=!0,!0)},l=new MutationObserver((()=>{r()&&l.disconnect()}));return r()||l.observe(document.body,{childList:!0,subtree:!0}),()=>l.disconnect()}),[]);const _=(0,n.useMemo)((()=>Array.isArray(o.fields)?o.fields:Object.values(o.fields)),[o.fields]),w=o.show_title?c.FormStep:"div";return Object.keys(_).length>0?(0,b.jsx)(w,{id:o.id,className:a("wc-block-checkout__additional-fields",o.cssclass),...o.show_title&&{title:o.title,description:o.subtitle||"",showStepNumber:!0,disabled:i},children:(0,b.jsx)("div",{children:_.map((e=>(0,b.jsx)("div",{className:"wc-block-checkout__additional-fields__field",children:(0,b.jsx)(E,{field:{...e,value:r[e.id]||""},onChange:m})},e.id)))})}):null}})},609:e=>{e.exports=window.React},848:(e,o,t)=>{e.exports=t(20)}},t={};function r(e){var l=t[e];if(void 0!==l)return l.exports;var i=t[e]={exports:{}};return o[e](i,i.exports,r),i.exports}r.m=o,e=[],r.O=(o,t,l,i)=>{if(!t){var a=1/0;for(d=0;d<e.length;d++){for(var[t,l,i]=e[d],c=!0,s=0;s<t.length;s++)(!1&i||a>=i)&&Object.keys(r.O).every((e=>r.O[e](t[s])))?t.splice(s--,1):(c=!1,i<a&&(a=i));if(c){e.splice(d--,1);var n=l();void 0!==n&&(o=n)}}return o}i=i||0;for(var d=e.length;d>0&&e[d-1][2]>i;d--)e[d]=e[d-1];e[d]=[t,l,i]},r.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),(()=>{var e={498:0,185:0,871:0};r.O.j=o=>0===e[o];var o=(o,t)=>{var l,i,[a,c,s]=t,n=0;if(a.some((o=>0!==e[o]))){for(l in c)r.o(c,l)&&(r.m[l]=c[l]);if(s)var d=s(r)}for(o&&o(t);n<a.length;n++)i=a[n],r.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return r.O(d)},t=globalThis.webpackChunkwoo_checkout_field_editor_pro=globalThis.webpackChunkwoo_checkout_field_editor_pro||[];t.forEach(o.bind(null,0)),t.push=o.bind(null,t.push.bind(t))})();var l=r.O(void 0,[185,871],(()=>r(363)));l=r.O(l)})();