/home/smartbloks/.trash/eazydocs/build/shortcode/index.js
(()=>{"use strict";(()=>{const e=window.wp.blocks,t=JSON.parse('{"apiVersion":2,"name":"eazydocs/shortcode","version":"0.1.0","title":"EazyDocs Shortcode","category":"eazydocs","icon":"media-document","description":"Display the Docs on the website frontend.","supports":{"html":false,"anchor":true},"attributes":{"col":{"type":"number","default":3},"include":{"type":"array","default":[]},"exclude":{"type":"string"},"show_docs":{"type":"number"},"show_articles":{"type":"number"},"more":{"type":"string","default":"View Details"}},"textdomain":"eazydocs","editorScript":"file:./index.js"}'),o=window.wp.element,l=window.wp.i18n,n=window.wp.blockEditor,a=window.wp.components,s=window.wp.data;function r(e){var t="";if(e)for(let o=0;o<e.length;o++)t+=e[o].split("|")[0].trim()+(o===e.length-1?"":",");return t}const{__}=wp.i18n,{Fragment:c}=(__("Black","boilerplate"),__("White","boilerplate"),__("Red","boilerplate"),__("Green","boilerplate"),__("Blue","boilerplate"),__("Yellow","boilerplate"),wp.element);(0,e.registerBlockType)(t,{edit:function(e){let{attributes:t,setAttributes:i}=e;const{col:d,include:u,exclude:m,show_docs:p,show_articles:_,more:h,list:w}=t,b=(0,n.useBlockProps)(),y=(0,s.useSelect)((e=>e("core").getEntityRecords("postType","docs",{parent:0,status:["publish","private"]})),[]),E=y&&y.map((e=>e.id+" | "+e.title.rendered));let g=r(u)?'include="'+r(u)+'"':"",x=r(m)?'exclude="'+r(m)+'"':"",f=d?'col="'+d+'"':"",z=p?'show_docs="'+p+'"':"",S=_?'show_articles="'+_+'"':"",C=h?'more="'+h+'"':"";return(0,o.createElement)(c,null,(0,o.createElement)(n.InspectorControls,null,(0,o.createElement)(a.PanelBody,{title:(0,l.__)("Filters","eazydocs"),initialOpen:!0},(0,o.createElement)(a.RangeControl,{initialPosition:3,label:(0,l.__)("Columns","eazydocs"),max:4,min:1,shiftStep:1,onChange:e=>{i({col:""==e?3:e})}}),(0,o.createElement)(a.__experimentalNumberControl,{label:(0,l.__)("Docs Show Count","eazydocs"),isShiftStepEnabled:!0,onChange:e=>i({show_docs:e}),shiftStep:1,value:p,min:1,__nextHasNoMarginBottom:!0}),(0,o.createElement)("small",null,(0,l.__)("How many docs to display.","eazydocs")),(0,o.createElement)("br",null),(0,o.createElement)("br",null),(0,o.createElement)(a.__experimentalNumberControl,{label:(0,l.__)("Docs Article Count","eazydocs"),isShiftStepEnabled:!0,onChange:e=>i({show_articles:e}),shiftStep:1,value:_,min:1,__nextHasNoMarginBottom:!0}),(0,o.createElement)("small",null,(0,l.__)("Articles/child-docs show under every Docs.","eazydocs")),(0,o.createElement)("br",null),(0,o.createElement)("br",null),(0,o.createElement)(a.FormTokenField,{__experimentalAutoSelectFirstMatch:!0,__experimentalExpandOnFocus:!0,label:(0,l.__)("Docs to Show","eazydocs"),suggestions:E,value:u,onChange:e=>i({include:e})}),(0,o.createElement)(a.FormTokenField,{__experimentalAutoSelectFirstMatch:!0,__experimentalExpandOnFocus:!0,label:(0,l.__)("Docs Not to Show","eazydocs"),suggestions:E,value:m,onChange:e=>i({exclude:e})}),(0,o.createElement)(a.TextControl,{help:(0,l.__)("Button/link to get the full docs","eazydocs"),label:(0,l.__)("More Button Label","eazydocs"),value:h,onChange:e=>i({more:e})}))),(0,o.createElement)("div",b,"[eazydocs ",f," ",g," ",x," ",z," ",S," ",C,"]"))},save:function(e){const{col:t,include:l,exclude:a,show_docs:s,show_articles:c,more:i}=e.attributes,d=n.useBlockProps.save();let u=r(l)?'include="'+r(l)+'"':"",m=r(a)?'exclude="'+r(a)+'"':"",p=t?'col="'+t+'"':"",_=s?'show_docs="'+s+'"':"",h=c?'show_articles="'+c+'"':"",w=i?'more="'+i+'"':"";return(0,o.createElement)(o.Fragment,null,(0,o.createElement)("div",d,"[eazydocs ",p," ",u," ",m," ",_," ",h," ",w,"]"))}})})()})();