← Back
Editing: components.js
(()=>{var e={500(e,t){var n;!function(){"use strict";var o={}.hasOwnProperty;function s(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=l(e,r(n)))}return e}function r(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return s.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var n in e)o.call(e,n)&&e[n]&&(t=l(t,n));return t}function l(e,t){return t?e?e+" "+t:e+t:e}e.exports?(s.default=s,e.exports=s):void 0===(n=function(){return s}.apply(t,[]))||(e.exports=n)}()}};const t={};function n(o){const s=t[o];if(void 0!==s)return s.exports;const r=t[o]={exports:{}};return e[o](r,r.exports,n),r.exports}n.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{if(Array.isArray(t))for(var o=0;o<t.length;){var s=t[o++],r=t[o++];n.o(e,s)?0===r&&o++:0===r?Object.defineProperty(e,s,{enumerable:!0,value:t[o++]}):Object.defineProperty(e,s,{enumerable:!0,get:r})}else for(var s in t)n.o(t,s)&&!n.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},n.o=(e,t)=>Object.hasOwn(e,t),n.r=e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};let o={};(()=>{"use strict";n.r(o),n.d(o,{CallToActionSelectControl:()=>y,ConfirmDialogue:()=>N,ControlledTabPanel:()=>E,DeviceToggle:()=>$,EntitySelectControl:()=>I,FieldPanel:()=>F,FieldRow:()=>L,FreeFormEditControl:()=>P,FullScreenPanel:()=>Z,ListTable:()=>J,PopupSelectControl:()=>Q,RadioButtonControl:()=>ee,SearchableMulticheckControl:()=>ne,SmartTokenControl:()=>C,SortDirection:()=>z,TextHighlight:()=>se,URLControl:()=>ae,useControlledState:()=>q});const e=window.wp.data,t=window.wp.element,s=window.wp.compose,r=window.wp.htmlEntities,l=window.popupMaker.i18n,i=window.popupMaker.coreData;function a(e){var t,n,o="";if("string"==typeof e||"number"==typeof e)o+=e;else if("object"==typeof e)if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(n=a(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}const c=function(){for(var e,t,n=0,o="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=a(e))&&(o&&(o+=" "),o+=t);return o},u=window.wp.components;(0,t.forwardRef)(({icon:e,size:n=24,...o},s)=>(0,t.cloneElement)(e,{width:n,height:n,...o,ref:s}));const d=window.wp.primitives,p=window.ReactJSXRuntime;var m=(0,p.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,p.jsx)(d.Path,{d:"m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z"})}),g=(0,p.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,p.jsx)(d.Path,{d:"M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z"})}),h=(0,p.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,p.jsx)(d.Path,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})}),x=(0,p.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,p.jsx)(d.Path,{d:"M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"})}),f=(0,p.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,p.jsx)(d.Path,{d:"m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z"})}),v=(0,p.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,p.jsx)(d.Path,{d:"M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8Zm6.5 8c0 .6 0 1.2-.2 1.8h-2.7c0-.6.2-1.1.2-1.8s0-1.2-.2-1.8h2.7c.2.6.2 1.1.2 1.8Zm-.9-3.2h-2.4c-.3-.9-.7-1.8-1.1-2.4-.1-.2-.2-.4-.3-.5 1.6.5 3 1.6 3.8 3ZM12.8 17c-.3.5-.6 1-.8 1.3-.2-.3-.5-.8-.8-1.3-.3-.5-.6-1.1-.8-1.7h3.3c-.2.6-.5 1.2-.8 1.7Zm-2.9-3.2c-.1-.6-.2-1.1-.2-1.8s0-1.2.2-1.8H14c.1.6.2 1.1.2 1.8s0 1.2-.2 1.8H9.9ZM11.2 7c.3-.5.6-1 .8-1.3.2.3.5.8.8 1.3.3.5.6 1.1.8 1.7h-3.3c.2-.6.5-1.2.8-1.7Zm-1-1.2c-.1.2-.2.3-.3.5-.4.7-.8 1.5-1.1 2.4H6.4c.8-1.4 2.2-2.5 3.8-3Zm-1.8 8H5.7c-.2-.6-.2-1.1-.2-1.8s0-1.2.2-1.8h2.7c0 .6-.2 1.1-.2 1.8s0 1.2.2 1.8Zm-2 1.4h2.4c.3.9.7 1.8 1.1 2.4.1.2.2.4.3.5-1.6-.5-3-1.6-3.8-3Zm7.4 3c.1-.2.2-.3.3-.5.4-.7.8-1.5 1.1-2.4h2.4c-.8 1.4-2.2 2.5-3.8 3Z"})}),b=(0,p.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,p.jsx)(d.Path,{d:"m6.734 16.106 2.176-2.38-1.093-1.028-3.846 4.158 3.846 4.158 1.093-1.028-2.176-2.38h2.811c1.125 0 2.25.03 3.374 0 1.428-.001 3.362-.25 4.963-1.277 1.66-1.065 2.868-2.906 2.868-5.859 0-2.479-1.327-4.896-3.65-5.93-1.82-.813-3.044-.8-4.806-.788l-.567.002v1.5c.184 0 .368 0 .553-.002 1.82-.007 2.704-.014 4.21.657 1.854.827 2.76 2.657 2.76 4.561 0 2.472-.973 3.824-2.178 4.596-1.258.807-2.864 1.04-4.163 1.04h-.02c-1.115.03-2.229 0-3.344 0H6.734Z"})}),j=(0,p.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,p.jsx)(d.Path,{d:"M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z"})}),_=(0,p.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,p.jsx)(d.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})});const w=window.popupMaker.utils,S={container:"component-smart-token-control",popover:"component-smart-token-control__suggestions-popover",inputContainer:"component-smart-token-control__input",tokens:"component-smart-token-control__tokens",token:"component-smart-token-control__token",tokenLabel:"component-smart-token-control__token-label",tokenRemove:"component-smart-token-control__token-remove",textInput:"component-smart-token-control__text-input",toggleSuggestions:"component-smart-token-control__toggle",suggestions:"component-smart-token-control__suggestions",suggestion:"component-smart-token-control__suggestion"},k=({id:e,value:n,onChange:o,label:r,placeholder:i=(0,l.__)("Enter a value","popup-maker"),className:a,inputStyles:d={},popoverStyles:m={},tokenOnComma:g=!1,classes:h=S,renderToken:x=e=>(0,p.jsx)(p.Fragment,{children:"string"==typeof e?e:e.item}),renderSuggestion:v=e=>(0,p.jsx)(p.Fragment,{children:e}),onInputChange:b=w.noop,saveTransform:j=e=>e,closeOnSelect:_=!1,hideLabelFromVision:C=!1,extraKeyboardShortcuts:y={},multiple:N=!1,suggestions:R,extraOptions:E=[],messages:$={searchTokens:(0,l.__)("Search","popup-maker"),noSuggestions:(0,l.__)("No suggestions","popup-maker"),removeToken:(0,l.__)("Remove token","popup-maker")}},B)=>{const I={...S,...h},F=(0,s.useInstanceId)(k),L=(0,t.useRef)(null),T=(0,t.useRef)(null),O=(0,t.useRef)(null),[M,A]=(0,t.useState)({inputText:"",isFocused:!1,selectedSuggestion:-1,popoverOpen:!1,refocus:!1}),{inputText:D,isFocused:P,selectedSuggestion:H,popoverOpen:V}=M;function Z(e){return"object"==typeof e?e.value:e}function U(e){return n.some(t=>Z(e)===Z(t))}function q(e){!function(e){const t=[...new Set(e.map(j).filter(Boolean).filter(e=>!U(e)))];t.length>0&&o([...n,...t])}([e]),A({...M,inputText:"",selectedSuggestion:-1,popoverOpen:!_&&V})}const z=R.length,G=H>z?0:H;(0,t.useEffect)(()=>{setTimeout(()=>{O.current&&O.current.scrollIntoView()},25)},[H,V]),(0,t.useEffect)(()=>{M.refocus&&(A({...M,refocus:!1}),T.current?.focus())},[M,M.refocus]);const K={up:e=>{e.preventDefault(),A({...M,popoverOpen:0===D.length&&!V||V,selectedSuggestion:(0,w.clamp)(G-1>=0?G-1:z,0,z)})},down:e=>{e.preventDefault(),A({...M,popoverOpen:0===D.length&&!V||V,selectedSuggestion:(0,w.clamp)(G+1<=z?G+1:0,0,z)})},"alt+down":()=>A({...M,popoverOpen:!0}),enter:()=>{if(-1===H)return A({...M,popoverOpen:!1});J(W[G])},escape:e=>{e.preventDefault(),e.stopPropagation(),A({...M,selectedSuggestion:-1,popoverOpen:!1})},",":e=>{g&&(e.preventDefault(),0!==D.length&&q(D))},...y},W=[...R,...E.map(e=>e.label)],J=e=>{const t=E.find(t=>t.label===e);if(t)return t.onSelect?.(),void q(t.value.toString());q(e)},X=V&&T.current&&(W.length>0||E.length>0);return(0,p.jsx)(u.KeyboardShortcuts,{shortcuts:K,children:(0,p.jsxs)("div",{id:e?`${e}-wrapper`:`component-smart-token-control-${F}-wrapper`,className:c([I.container,P&&"is-focused",a]),ref:e=>{L.current=e,B&&"object"==typeof B&&(B.current=e)},onBlur:e=>{e.relatedTarget&&e.relatedTarget.closest(`.${I.popover}`)||A({...M,isFocused:!1,popoverOpen:!1,selectedSuggestion:-1})},children:[(0,p.jsx)(u.BaseControl,{id:e||`component-smart-token-control-${F}`,label:r,hideLabelFromVision:C,__nextHasNoMarginBottom:!0,children:(0,p.jsxs)("div",{className:c([I.inputContainer,!N&&n.length>0&&"input-disabled"]),children:[n.length>0&&(0,p.jsx)("div",{className:I.tokens,children:n.map(e=>(0,p.jsxs)("div",{className:I.token,children:[(0,p.jsx)("div",{className:I.tokenLabel,children:x(e)}),(0,p.jsx)(u.Button,{className:I.tokenRemove,label:$.removeToken,icon:f,onClick:()=>function(e){A({...M,refocus:!0}),o(n.filter(t=>Z(t)!==Z(e)))}(e)})]},Z(e)))}),(0,p.jsx)("input",{id:e||`component-smart-token-control-${F}`,type:"text",className:c([I.textInput]),style:d??{},placeholder:i,disabled:!N&&n.length>0,ref:T,value:D??"",onChange:e=>{return t=e.target.value,A({...M,inputText:t,selectedSuggestion:-1,popoverOpen:t.length>=1||E.length>0&&0===t.length}),void b(t);var t},autoComplete:"off","aria-autocomplete":"list","aria-controls":e?`${e}-listbox`:`${F}-listbox`,"aria-activedescendant":`sug-${G}`,onFocus:()=>{A({...M,isFocused:!0,popoverOpen:D.length>=1||E.length>0&&(0===R.length||0===D.length)})},onClick:()=>{!V&&(R.length>0||E.length>0)&&A({...M,popoverOpen:!0})},onBlur:e=>{const t=e.relatedTarget;t&&t.closest(`.${I.popover}`)||A({...M,isFocused:!1,popoverOpen:!1,selectedSuggestion:-1})}})]})}),X&&(0,p.jsx)(u.Popover,{focusOnMount:!1,onClose:()=>{A({...M,popoverOpen:!1,selectedSuggestion:-1})},position:"bottom right",anchor:T.current,className:I.popover,style:m??{},children:(0,p.jsx)("div",{className:I.suggestions,style:{width:T.current?.clientWidth},children:W.length?W.map((e,t)=>(0,p.jsx)("div",{id:`sug-${t}`,className:c([I.suggestion,t===G&&"is-currently-highlighted",U(e)&&"is-selected"]),ref:t===G?O:void 0,onFocus:()=>{(e=>{A({...M,selectedSuggestion:e})})(t)},onMouseDown:e=>{e.preventDefault(),J(W[t])},role:"option",tabIndex:t,"aria-selected":t===G,children:v(e)},t)):(0,p.jsx)("div",{children:$.noSuggestions})})})]})})},C=(0,t.forwardRef)(k),y=({id:n,label:o,value:a,onChange:c,placeholder:u,multiple:d=!1,...m})=>{const[g,h]=(0,t.useState)(""),x=(0,s.useDebounce)(e=>{h(e)},300),{suggestions:f=[],isLoading:v=!1}=(0,e.useSelect)(e=>({suggestions:e(i.callToActionStore).getCallToActions()||[],isLoading:e(i.callToActionStore).isResolving("getCallToActions")}),[]),b=e=>f&&f.find(t=>t.id.toString()===e.toString()),j=(0,t.useMemo)(()=>f.filter(e=>e.title.rendered.toLowerCase().includes(g.toLowerCase())),[f,g]),_=a?(Array.isArray(a)?a:[a]).map(e=>e.toString()):[],w=e=>"object"==typeof e?e.value:e;return(0,p.jsx)("div",{className:"pum-object-search-field",children:(0,p.jsx)(C,{id:n,label:o||(0,l.sprintf)( // translators: %s: entity type. // translators: %s: entity type. (0,l.__)("%s(s)","popup-maker"),"Call to Action"),multiple:d,placeholder:u||(0,l.sprintf)( // translators: %s: entity type. // translators: %s: entity type. (0,l.__)("Select %s(s)","popup-maker"),"call to action"),...m,tokenOnComma:!0,value:_,onInputChange:x,onChange:e=>{const t=(d&&!Array.isArray(e)?[e]:e).map(e=>{const t=w(e);if("string"==typeof t&&!t.match(/^\d+$/))return t;const n=parseInt(t,10);return isNaN(n)?null:n}).filter(e=>null!==e);c(d?t:t[0])},renderToken:e=>{const t=b(w(e));return t?(0,r.decodeEntities)(t.title.rendered??(t.title.raw||t.title.rendered)):w(e)},renderSuggestion:e=>{const t=b(e);return t?(0,p.jsx)(p.Fragment,{children:(0,r.decodeEntities)(t.title.rendered??(t.title.raw||t.title.rendered))}):e},suggestions:j.length?j.map(e=>e.id.toString()).filter(e=>e):[],messages:v?{noSuggestions:(0,l.__)("Searching…","popup-maker")}:void 0})})},N=({message:e,callback:n,onClose:o,isDestructive:s=!1,children:r})=>{const i=(0,t.useRef)(null),a=(0,t.useRef)(null);return(0,t.useEffect)(()=>(i.current?.ownerDocument&&(a.current=i.current.ownerDocument.activeElement),i.current?.focus(),()=>{a.current&&"focus"in a.current&&a.current.focus()}),[n,o]),(e&&e.length||r)&&n?(0,p.jsxs)(u.Modal,{title:(0,l.__)("Confirm Action","popup-maker"),onRequestClose:o,focusOnMount:!1,children:[r||(0,p.jsx)("p",{children:e}),(0,p.jsxs)(u.Flex,{justify:"right",children:[(0,p.jsx)(u.Button,{text:(0,l.__)("Cancel","popup-maker"),onClick:o}),(0,p.jsx)(u.Button,{variant:"primary",text:(0,l.__)("Confirm","popup-maker"),isDestructive:s,ref:i,onClick:()=>{n(),o()}})]})]}):null},R=({tabId:e,onClick:t,children:n,selected:o,...s})=>(0,p.jsx)(u.Button,{role:"tab",tabIndex:o?void 0:-1,"aria-selected":o,id:e,onClick:t,...s,children:n}),E=(0,s.withInstanceId)(({instanceId:e,orientation:t="horizontal",activeClass:n="is-active",tabsClass:o="tabs",tabClass:s="tab",className:r,tabs:l,selected:i,onSelect:a,children:d})=>{const m=l.find(e=>i===e.name)||l[0],g=`${e}-${m?.name??"none"}`;return(0,p.jsxs)("div",{className:c(r,"pum-"+t+"-tabs"),children:[(0,p.jsx)(u.NavigableMenu,{role:"tablist",orientation:t,onNavigate:(e,t)=>{t.click()},className:c([o,"components-tab-panel__tabs"]),children:l.map(t=>(0,p.jsx)(R,{className:c(s,"components-tab-panel__tabs-item","components-tab-panel__tab",t.className,{[n]:t.name===m.name}),tabId:`${e}-${t.name}`,"aria-controls":`${e}-${t.name}-view`,selected:t.name===m.name,onClick:()=>{return e=t.name,void a?.(e);var e},href:t?.href??void 0,target:t?.target??void 0,children:t.title},t.name))}),m&&(0,p.jsx)("div",{"aria-labelledby":g,role:"tabpanel",id:`${g}-view`,className:"components-tab-panel__tab-content",tabIndex:0,children:d&&d(m)},g)]})}),$=({label:e,icon:t,isVisible:n,onChange:o=w.noop})=>{const s=n?/* translators: 1. Device type. */ /* translators: 1. Device type. */ (0,l._x)("Show on %1$s","Device toggle option","popup-maker"):/* translators: 1. Device type. */ /* translators: 1. Device type. */ (0,l._x)("Hide on %1$s","Device toggle option","popup-maker"),r=n?"visibility":"hidden",i=()=>o(!n);return(0,p.jsxs)("div",{className:c(["pum__component-device-toggle",n&&"is-checked"]),children:[(0,p.jsxs)("h3",{className:"pum__component-device-toggle__label",children:[(0,p.jsx)(u.Icon,{icon:t}),e]}),(0,p.jsxs)("div",{className:"pum__component-device-toggle__control",children:[(0,p.jsx)(u.Tooltip,{text:(0,l.sprintf)(s,e),children:(0,p.jsx)("span",{children:(0,p.jsx)(u.Icon,{className:"pum__component-device-toggle__control-icon",onClick:i,icon:r})})}),(0,p.jsx)(u.Tooltip,{text:(0,l.sprintf)(s,e),children:(0,p.jsx)("span",{children:(0,p.jsx)(u.ToggleControl,{className:"pum__component-device-toggle__control-input",checked:n,onChange:i,hideLabelFromVision:!0,"aria-label":s,label:(0,l.sprintf)(/* translators: 1. Device type. */ /* translators: 1. Device type. */ (0,l._x)("Show on %1$s","Device toggle option","popup-maker"),e),__nextHasNoMarginBottom:!0})})})]})]})},B=window.wp.coreData,I=({id:n,label:o,value:i,onChange:a,placeholder:c,entityKind:u="postType",entityType:d="post",multiple:m=!1,forceRefresh:g=!1,...h})=>{const[x,f]=(0,t.useState)(""),v=(0,s.useDebounce)(e=>{f(e)},300),{prefill:b=[]}=(0,e.useSelect)(e=>({prefill:i?e(B.store).getEntityRecords(u,d,{context:"view",include:i,per_page:-1}):[]}),[i,u,d,g]),{suggestions:j=[],isSearching:_=!1}=(0,e.useSelect)(e=>({suggestions:e(B.store).getEntityRecords(u,d,{context:"view",search:x,per_page:-1}),isSearching:e("core/data").isResolving("core","getEntityRecords",[u,d,{context:"view",search:x,per_page:-1}])}),[u,d,x,g]),w=e=>j&&j.find(t=>t.id.toString()===e.toString())||b&&b.find(t=>t.id.toString()===e.toString()),S=i?(Array.isArray(i)?i:[i]).map(e=>e.toString()):[],k=e=>"object"==typeof e?e.value:e;return(0,p.jsx)("div",{className:"pum-object-search-field",children:(0,p.jsx)(C,{id:n,label:o||(0,l.sprintf)( // translators: %s: entity type. // translators: %s: entity type. (0,l.__)("%s(s)","popup-maker"),d.replace(/_/g," ").charAt(0).toUpperCase()+d.replace(/_/g," ").slice(1)),multiple:m,placeholder:c||(0,l.sprintf)( // translators: %s: entity type. // translators: %s: entity type. (0,l.__)("Select %s(s)","popup-maker"),d.replace(/_/g," ").toLowerCase()),...h,tokenOnComma:!0,value:S,onInputChange:v,onChange:e=>{const t=e.map(e=>{const t=k(e);if("string"==typeof t&&!t.match(/^\d+$/))return t;const n=parseInt(t,10);return isNaN(n)?null:n}).filter(e=>null!==e);a(m?t:t[0])},renderToken:e=>{const t=w(k(e));return t?"postType"===u?(0,r.decodeEntities)(t.title.rendered??t.title.raw):t.name:k(e)},renderSuggestion:e=>{const t=w(e);return t?(0,p.jsx)(p.Fragment,{children:"postType"===u?(0,r.decodeEntities)(t.title.rendered??t.title.raw):t.name}):e},suggestions:j?j.map(e=>e?.id.toString()??!1):[],messages:_?{noSuggestions:(0,l.__)("Searching…","popup-maker")}:void 0})})},F=({title:e,className:t,children:n})=>(0,p.jsx)(u.Panel,{header:e,className:c(["components-field-panel",t]),children:(0,p.jsx)(u.PanelBody,{opened:!0,children:n})}),L=({id:e,label:t,description:n,className:o,children:s})=>(0,p.jsxs)("div",{className:c(["components-field-row",o]),children:[(0,p.jsxs)("div",{className:"components-base-control",children:[(0,p.jsx)("label",{htmlFor:e,className:"components-truncate components-text components-input-control__label",children:t}),(0,p.jsx)("p",{className:"components-base-control__help",children:n})]}),(0,p.jsx)("div",{className:"components-base-control__field",children:s})]}),T=window.wp.keycodes,{wp:O,tinymce:M,wpEditorL10n:A={tinymce:{baseURL:"",suffix:"",settings:{}}}}=window,D=e=>{const n=(0,s.useInstanceId)(D),{label:o,value:r,onChange:i=w.noop,className:a,minHeight:d=100}=e,m=(0,t.useRef)(!1);return(0,t.useEffect)(()=>{if(!m.current)return;const e=M.get(`editor-${n}`),t=e?.getContent();t!==r&&e.setContent(r||"")},[r,n]),(0,t.useEffect)(()=>{const{baseURL:e,suffix:t}=A.tinymce;function o(e){let t;r&&e.on("loadContent",()=>e.setContent(r)),e.on("blur",()=>{t=e.selection.getBookmark(2,!0);const n=document.querySelector(".interface-interface-skeleton__content"),o=n?.scrollTop;return i(e.getContent()),e.once("focus",()=>{t&&(e.selection.moveToBookmark(t),n&&n?.scrollTop!==o&&(n.scrollTop=o||0))}),!1}),e.on("mousedown touchstart",()=>{t=null});const n=(0,s.debounce)(()=>{const t=e.getContent();t!==e._lastChange&&(e._lastChange=t,i(t))},250);e.on("Paste Change input Undo Redo",n),e.on("remove",n.cancel),e.on("keydown",e=>{T.isKeyboardEvent.primary(e,"z")&&e.stopPropagation();const{altKey:t}=e;t&&e.keyCode===T.F10&&e.stopPropagation()}),e.on("init",()=>{const t=e.getBody();t.ownerDocument.activeElement===t&&(t.blur(),e.focus())})}function l(){const{settings:e}=A.tinymce;O.oldEditor.initialize(`editor-${n}`,{tinymce:{...e,inline:!0,content_css:!1,fixed_toolbar_container:`#toolbar-${n}`,setup:o}})}function a(){"complete"===document.readyState&&l()}return m.current=!0,M.EditorManager.overrideDefaults({base_url:e,suffix:t}),"complete"===document.readyState?l():document.addEventListener("readystatechange",a),()=>{document.removeEventListener("readystatechange",a),O.oldEditor.remove(`editor-${n}`)}},[]),(0,p.jsxs)(u.BaseControl,{id:`freeform-edit-control-${n}`,label:o,className:c(["component-freeform-edit-control",a]),__nextHasNoMarginBottom:!0,children:[(0,p.jsx)("div",{id:`toolbar-${n}`,className:"block-library-classic__toolbar",onClick:function(){const e=M.get(`editor-${n}`);e&&e.focus()},onKeyDown:function(e){e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()},"data-placeholder":(0,l.__)("Click here to edit this text.","popup-maker")},"toolbar"),(0,p.jsx)("div",{id:`editor-${n}`,style:{minHeight:d},className:"wp-block-freeform block-library-rich-text__tinymce"},"editor")]})},P=D;var H=n(500),V=n.n(H);const Z=e=>{const{className:n,children:o}=e,[s,r]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=document.querySelector("html");s?e?.classList.add("disable-scroll"):e?.classList.remove("disable-scroll")},[s]),(0,p.jsxs)("div",{className:V()("fullscreen-panel",n,{"is-full-screen":s}),children:[(0,p.jsx)("button",{onClick:()=>{r(!s)},className:V()("maximize-fullscreen-panel","dashicons",s?"dashicons dashicons-no-alt":"dashicons-editor-expand")}),o]})},U=window.popupMaker.skeleton;function q(e,n,o){const[s,r]=(0,t.useState)(e??n),l=(0,t.useRef)(void 0!==e),i=l.current,a=void 0!==e,c=(0,t.useRef)(s);i!==a&&console.warn(`WARN: A component changed from ${i?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}.`),l.current=a;const u=(0,t.useCallback)((e,...t)=>{const n=(e,...t)=>{o&&(Object.is(c.current,e)||o(e,...t)),a||(c.current=e)};"function"==typeof e?(console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320"),r((o,...s)=>{const r=e(a?c.current:o,...s);return n(r,...t),a?o:r})):(a||r(e),n(e,...t))},[a,o]);return a?c.current=e:e=s,[e,u]}let z=function(e){return e.ASC="ASC",e.DESC="DESC",e}({});const G=window.React,K=["80%","55%","70%","45%","65%"],W=({heading:e=!1,children:t,...n})=>e?(0,p.jsx)("th",{...n,children:t}):(0,p.jsx)("td",{...n,children:t}),J=({items:e,columns:n,sortableColumns:o=[],idCol:s="id",rowClasses:r=e=>[`item-${e.id}`],renderCell:i=(e,t)=>t[e],noItemsText:a=(0,l.__)("No items found.","popup-maker"),showBulkSelect:d=!0,className:h,selectedItems:x=[],onSelectItems:f=()=>{},onSort:v,initialSort:b,isLoading:j=!1,loadingRowCount:_=5})=>{const w={[s]:n[s]??"",...n},S=Object.keys(w).length,[k,C]=q(x,[],f);(0,t.useEffect)(()=>{f(k)},[k,f]);const y=({header:t=!1})=>(0,p.jsx)(p.Fragment,{children:Object.entries(w).map(([n,r])=>{const l=d&&n===s,i=b?.orderby===n,a=!l&&o.indexOf(n)>=0,h={key:n,heading:!l,id:t&&!l?n:void 0,scope:l?void 0:"col",className:c([`column-${n}`,...!l&&a?["sortable",b?.order??z.ASC]:[],l&&"check-column"])},x=()=>(0,p.jsx)(p.Fragment,{children:"function"==typeof r?r():(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{children:r}),i&&(0,p.jsx)(u.Icon,{icon:b?.order===z.ASC?g:m,size:16})]})});return(0,G.createElement)(W,{...h,key:n},l&&(0,p.jsx)(u.CheckboxControl,{onChange:t=>C(t?e.map(e=>e.id):[]),checked:k.length>0&&k.length===e.length,indeterminate:k.length>0&&k.length<e.length,__nextHasNoMarginBottom:!0}),!l&&a&&(0,p.jsx)(u.Button,{variant:"link",onClick:()=>{if(v){let e;e=b?.orderby===n&&b.order===z.ASC?z.DESC:z.ASC,v(n,e)}},children:(0,p.jsx)(x,{})}),!l&&!a&&(0,p.jsx)(x,{}))})});return(0,p.jsxs)("table",{className:c([h,"component-list-table","list-table",j&&"is-loading",!j&&0===e.length&&"no-items"]),children:[(0,p.jsx)("thead",{children:(0,p.jsx)("tr",{children:(0,p.jsx)(y,{header:!0})})}),(0,p.jsxs)("tbody",{children:[j&&Array.from({length:_}).map((e,t)=>(0,p.jsx)(U.SkeletonTableRow,{cells:Object.keys(w).map((e,n)=>({key:e,width:e===s?16:K[(t+n)%K.length]}))},t)),!j&&(e.length?e.map((e,t)=>(0,p.jsx)("tr",{className:c(r(e)),children:Object.entries(w).map(([n])=>{const o=n===s;return(0,p.jsx)(W,{heading:o,className:c([`column-${n}`,d&&o&&"check-column"]),scope:o?"row":void 0,children:o?(0,p.jsx)(u.CheckboxControl,{onChange:t=>{const n=t?[...k,e.id]:k.filter(t=>t!==e.id);C(n)},checked:k.indexOf(e.id)>=0,__nextHasNoMarginBottom:!0}):i(n,e,t)},n)})},e.id)):(0,p.jsx)("tr",{children:(0,p.jsx)("td",{colSpan:S,children:a})}))]}),(0,p.jsx)("tfoot",{children:(0,p.jsx)("tr",{children:(0,p.jsx)(y,{})})})]})},{popups:X}=window.popupMakerComponents,Q=({onChange:e,value:t,label:n=(0,l.__)("Select Popup","popup-maker"),emptyValueLabel:o=(0,l.__)("Choose a popup","popup-maker"),hideLabelFromVision:s=!1,multiple:r=!1,required:i=!1,options:a=[{value:"",label:o},...X.map(({ID:e,post_title:t})=>({value:`${e}`,label:t}))],...d})=>(0,p.jsx)(u.SelectControl,{label:n,hideLabelFromVision:s,className:c("pum-component-popup-select-control",r&&"pum-popup-select-control--multiple"),options:a,required:i,...r?{multiple:!0,value:t,onChange:e}:{value:t,onChange:e},...d,__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),Y=({id:e,label:t,value:n,onChange:o,className:r,options:l=[],orientation:i="horizontal",equalWidth:a=!1,spacing:d,hideLabelFromVision:m=!1})=>{const g=(0,s.useInstanceId)(Y);return(0,p.jsx)(u.BaseControl,{id:e||`radio-button-control-${g}`,label:t,className:c("components-radio-button-control",i,a&&"equal-width",r),hideLabelFromVision:m,__nextHasNoMarginBottom:!0,children:(0,p.jsx)("div",{className:"options",style:d?{gap:`${d}px`}:void 0,children:l.map(({label:e,value:t})=>(0,p.jsx)(u.Button,{variant:t===n?"primary":"secondary",onClick:()=>o(t),children:e},t))})})},ee=Y,te=({label:e="",placeholder:n="",searchIcon:o,value:r=[],options:i=[],onChange:a=()=>{},className:d=""})=>{const m=(0,s.useInstanceId)(te),[g,f]=(0,t.useState)(""),[v,b]=(0,t.useState)("ASC"),j=e=>-1!==r.indexOf(e),_=e=>a(j(e)?[...r.filter(t=>t!==e)]:[...r,e]),w=i.filter(({label:e,value:t,keywords:n})=>e.includes(g)||"string"==typeof t&&t.includes(g)||n&&n.includes(g)),S=w.sort((e,t)=>"ASC"===v?e.label>t.label?1:-1:t.label>e.label?1:-1);return(0,p.jsxs)(u.BaseControl,{id:`searchable-multicheck-control-${m}`,label:e,className:c(["component-searchable-multicheck-control",d]),__nextHasNoMarginBottom:!0,children:[(0,p.jsxs)("div",{className:"select-actions",children:[(0,p.jsx)(u.Button,{variant:"link",text:(0,l.__)("Select All","popup-maker"),onClick:()=>{const e=w.map(({value:e})=>e),t=[...r,...e];a([...new Set(t)])}}),(0,p.jsx)(u.Button,{variant:"link",text:(0,l.__)("Deselect All","popup-maker"),onClick:()=>{const e=w.map(({value:e})=>e),t=[...r.filter(t=>-1===e.indexOf(t))];a([...new Set(t)])}})]}),(0,p.jsxs)("div",{className:c([o?"icon-input":null]),children:[(0,p.jsx)("input",{type:"text",className:"components-text-control__input",placeholder:n,value:g,onChange:e=>f(e.target.value)}),o&&(0,p.jsx)(u.Icon,{icon:o})]}),(0,p.jsxs)("table",{children:[(0,p.jsx)("thead",{children:(0,p.jsxs)("tr",{children:[(0,p.jsx)("th",{className:"label-column",children:(0,p.jsx)(u.Button,{text:(0,l.__)("Name","popup-maker"),onClick:()=>b("DESC"===v?"ASC":"DESC"),icon:"DESC"===v?x:h,iconPosition:"right"})}),(0,p.jsx)("td",{className:"cb-column"})]})}),(0,p.jsx)("tbody",{children:S.map(({label:e,value:t})=>(0,p.jsxs)("tr",{children:[(0,p.jsx)("td",{children:(0,p.jsx)("span",{role:"button",tabIndex:-1,onClick:()=>_(t),onKeyDown:()=>{},children:e})}),(0,p.jsx)("th",{className:"cb-column",children:(0,p.jsx)(u.CheckboxControl,{checked:j(t),onChange:()=>_(t),__nextHasNoMarginBottom:!0})})]},t.toString()))})]})]})},ne=te,oe=window.lodash,se=e=>{const{text:n="",highlight:o=""}=e,s=(Array.isArray(o)?o:[o]).map(e=>e.trim()).filter(e=>!!e).map(e=>(0,oe.escapeRegExp)(e));if(!s.length)return(0,p.jsx)(p.Fragment,{children:n});const r=new RegExp(`(${s.join("|")})`,"gi");return(0,t.createInterpolateElement)(n.replace(r,"<mark>$&</mark>"),{mark:(0,p.jsx)("mark",{})})},re=(0,t.forwardRef)(({icon:e,title:t,info:n,type:o,className:s,isSelected:r,onFocus:l=w.noop,onSelect:i=w.noop,...a},d)=>(0,p.jsxs)(u.Button,{type:"button",className:c(["suggestion",r&&"is-selected",s]),ref:d,onClick:i,onFocus:l,onMouseOver:l,"aria-selected":r,role:"option",tabIndex:-1,...a,children:[e&&(0,p.jsx)(u.Icon,{icon:e,className:"suggestion-item-icon"}),(0,p.jsxs)("span",{className:"suggestion-item-header",children:[(0,p.jsx)("span",{className:"suggestion-item-title",children:t}),n&&(0,p.jsx)("span",{"aria-hidden":"true",className:"suggestion-item-info",children:n})]}),o&&(0,p.jsx)("span",{className:"suggestion-item-type",children:o})]})),le={id:-1,title:"",url:"",type:(0,l.__)("URL","popup-maker")},ie=({id:n,label:o,value:r,onChange:a=()=>{},className:d=""},m)=>{const g=(0,s.useInstanceId)(ie),h=(0,t.useRef)(null),x=(0,t.useRef)(null),f=(0,t.useRef)(null),w=(0,t.useRef)(null),S=(0,t.useRef)(null),k=(0,t.useRef)([]);(0,t.useImperativeHandle)(m,()=>f.current,[f]);const C="string"==typeof r?{...le,url:r}:r??le,y={value:C,query:C.url??"",isEditing:!1,isFocused:!1,selected:-1,showSuggestions:!1},[N,R]=(0,t.useState)(y),{value:E,query:$,isFocused:B,isEditing:I,selected:F,showSuggestions:L}=N,T=n||`url-input-control-${g}`,O=`url-input-control-suggestions-${g}`,M=`url-input-${g}-sug-`,{unfilteredSuggestions:A,isFetchingSuggestions:D}=(0,e.useSelect)(e=>({unfilteredSuggestions:e(i.urlSearchStore).getSuggestions(),isFetchingSuggestions:e(i.urlSearchStore).isResolving("updateSuggestions")}),[]),{updateSuggestions:P}=(0,e.useDispatch)(i.urlSearchStore),H=(0,oe.debounce)(P,200,{leading:!0}),V=e=>R({...N,selected:e}),Z=e=>{const t={...N,value:{...E,...e},query:"",isEditing:!1,isFocused:!0,selected:-1,showSuggestions:!1};R(t)};(0,t.useEffect)(()=>{C.url!==E.url&&a(E)},[E,C.url,a]),(0,t.useEffect)(()=>{B&&(I?f.current?.focus():S.current?.focus())},[I,B]);const U=(0,t.useMemo)(()=>A.filter((e,t)=>{const n=A.findIndex(t=>e.id===t.id);return n===t}),[A]).slice(0,10),q=U.length,z=F>q?0:F,G={up:()=>R({...N,showSuggestions:0===$.length&&!L||L,selected:(0,oe.clamp)(z-1>=0?z-1:q,0,q)}),down:()=>{R({...N,showSuggestions:0===$.length&&!L||L,selected:(0,oe.clamp)(z+1<=q?z+1:0,0,q)})},"alt+down":()=>R({...N,showSuggestions:!0}),enter:e=>{e.preventDefault(),L&&z>-1&&z!==q?Z(U[z]):E.url===$?R({...N,isEditing:!1,query:"",showSuggestions:!1,selected:-1}):Z({title:(0,l.__)("Custom URL","popup-maker"),type:"URL",url:$})},escape:e=>{e.preventDefault(),e.stopPropagation(),R({...N,selected:-1,showSuggestions:!1})}};return(0,p.jsx)(u.BaseControl,{id:T,label:o,className:c(["components-url-control",B&&"is-focused",d]),__nextHasNoMarginBottom:!0,children:(0,p.jsx)("div",{ref:h,onFocus:()=>{R({...N,isFocused:!0,showSuggestions:$.length>=1})},onBlur:e=>{if(!h.current?.contains(e.relatedTarget)&&!w.current?.contains(e.relatedTarget)){const e={...N,selected:-1,isFocused:!1,showSuggestions:!1};I&&(e.isEditing=!1,e.value=F>-1?U[F]:{title:(0,l.__)("Custom URL","popup-maker"),type:"URL",url:$}),R(e)}},children:!I&&C.url.length>0?(0,p.jsxs)("div",{className:"chosen-suggestion",children:[(0,p.jsx)(u.Icon,{icon:v,className:"suggestion-item-icon"}),(0,p.jsxs)("span",{className:"suggestion-item-header",children:[(0,p.jsx)("span",{className:"suggestion-item-title",children:(0,p.jsx)(p.Fragment,{children:E?.title??E?.url})}),(0,p.jsx)("span",{"aria-hidden":"true",className:"suggestion-item-info",children:E.url})]}),(0,p.jsx)(u.Button,{"aria-label":(0,l.__)("Edit","popup-maker"),icon:_,onClick:()=>{R({...N,isEditing:!0,isFocused:!0,query:C.url})},ref:S})]}):(0,p.jsx)(u.KeyboardShortcuts,{shortcuts:G,children:(0,p.jsxs)("div",{className:c(["url-control-wrapper"]),ref:x,children:[(0,p.jsxs)("div",{className:"url-control",children:[(0,p.jsx)(u.Icon,{icon:j,className:"url-control__input-icon"}),(0,p.jsx)("input",{id:T,className:"url-control__input",ref:f,type:"text",role:"combobox",placeholder:(0,l.__)("Search or type url","popup-maker"),value:$,onChange:e=>{return t=e.target.value,R({...N,query:t,showSuggestions:t.length>=1}),void H(t.trim(),{type:["post","term"]});var t},autoComplete:"off","aria-autocomplete":"list","aria-controls":O,"aria-expanded":L,"aria-activedescendant":z>=0?`${M}-${z}`:void 0,"aria-label":o?void 0:(0,l.__)("URL","popup-maker")}),(0,p.jsxs)("div",{className:"url-control__actions",children:[D&&(0,p.jsx)(u.Spinner,{}),(0,p.jsx)(u.Button,{icon:b,iconSize:30,onClick:()=>Z({title:(0,l.__)("Custom URL","popup-maker"),type:"URL",url:$})})]})]}),L&&U.length>0&&(0,p.jsx)(u.Popover,{ref:w,focusOnMount:!1,onClose:()=>V(-1),position:"bottom right",anchor:x.current,className:"suggestions-popover",children:(0,p.jsxs)("div",{className:"suggestions",id:O,role:"listbox",children:[U.map((e,t)=>(0,p.jsx)(re,{id:`${M}-${t}`,title:e.title,info:e.url,type:e.type,isSelected:t===z,onSelect:()=>Z(e),onFocus:()=>V(t),ref:e=>{k.current[t]=e}},e.id)),$.length>0&&(0,p.jsx)(re,{id:`${M}-${q}`,icon:v,title:$,info:(0,l.__)("Press ENTER to add this link","popup-maker"),type:(0,l.__)("URL","popup-maker"),className:"is-url",isSelected:q===z,onSelect:()=>Z({title:(0,l.__)("Custom URL","popup-maker"),type:"URL",url:$}),onFocus:()=>{V(q)},ref:e=>{k.current[q]=e}},"use-current-input-text")]})})]})})})})},ae=(0,t.forwardRef)(ie)})(),(window.popupMaker=window.popupMaker||{}).components=o})();
Save File
Cancel