1 line
25 KiB
JavaScript
1 line
25 KiB
JavaScript
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o=[],a=!0,l=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){l=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(l)throw i}}return o}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _get(e,t,r){return(_get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){e=_superPropBase(e,t);if(e){t=Object.getOwnPropertyDescriptor(e,t);return t.get?t.get.call(r):t.value}})(e,t,r||e)}function _superPropBase(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_getPrototypeOf(e)););return e}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _createSuper(r){var n=_isNativeReflectConstruct();return function(){var e,t=_getPrototypeOf(r);return _possibleConstructorReturn(this,n?(e=_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function _possibleConstructorReturn(e,t){return!t||"object"!==_typeof(t)&&"function"!=typeof t?_assertThisInitialized(e):t}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ownKeys(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach(function(e){_defineProperty(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}jQuery,acf.jsxNameReplacements={"accent-height":"accentHeight",accentheight:"accentHeight","accept-charset":"acceptCharset",acceptcharset:"acceptCharset",accesskey:"accessKey","alignment-baseline":"alignmentBaseline",alignmentbaseline:"alignmentBaseline",allowedblocks:"allowedBlocks",allowfullscreen:"allowFullScreen",allowreorder:"allowReorder","arabic-form":"arabicForm",arabicform:"arabicForm",attributename:"attributeName",attributetype:"attributeType",autocapitalize:"autoCapitalize",autocomplete:"autoComplete",autocorrect:"autoCorrect",autofocus:"autoFocus",autoplay:"autoPlay",autoreverse:"autoReverse",autosave:"autoSave",basefrequency:"baseFrequency","baseline-shift":"baselineShift",baselineshift:"baselineShift",baseprofile:"baseProfile",calcmode:"calcMode","cap-height":"capHeight",capheight:"capHeight",cellpadding:"cellPadding",cellspacing:"cellSpacing",charset:"charSet",class:"className",classid:"classID",classname:"className","clip-path":"clipPath","clip-rule":"clipRule",clippath:"clipPath",clippathunits:"clipPathUnits",cliprule:"clipRule","color-interpolation":"colorInterpolation","color-interpolation-filters":"colorInterpolationFilters","color-profile":"colorProfile","color-rendering":"colorRendering",colorinterpolation:"colorInterpolation",colorinterpolationfilters:"colorInterpolationFilters",colorprofile:"colorProfile",colorrendering:"colorRendering",colspan:"colSpan",contenteditable:"contentEditable",contentscripttype:"contentScriptType",contentstyletype:"contentStyleType",contextmenu:"contextMenu",controlslist:"controlsList",crossorigin:"crossOrigin",dangerouslysetinnerhtml:"dangerouslySetInnerHTML",datetime:"dateTime",defaultchecked:"defaultChecked",defaultvalue:"defaultValue",diffuseconstant:"diffuseConstant",disablepictureinpicture:"disablePictureInPicture",disableremoteplayback:"disableRemotePlayback","dominant-baseline":"dominantBaseline",dominantbaseline:"dominantBaseline",edgemode:"edgeMode","enable-background":"enableBackground",enablebackground:"enableBackground",enctype:"encType",enterkeyhint:"enterKeyHint",externalresourcesrequired:"externalResourcesRequired","fill-opacity":"fillOpacity","fill-rule":"fillRule",fillopacity:"fillOpacity",fillrule:"fillRule",filterres:"filterRes",filterunits:"filterUnits","flood-color":"floodColor","flood-opacity":"floodOpacity",floodcolor:"floodColor",floodopacity:"floodOpacity","font-family":"fontFamily","font-size":"fontSize","font-size-adjust":"fontSizeAdjust","font-stretch":"fontStretch","font-style":"fontStyle","font-variant":"fontVariant","font-weight":"fontWeight",fontfamily:"fontFamily",fontsize:"fontSize",fontsizeadjust:"fontSizeAdjust",fontstretch:"fontStretch",fontstyle:"fontStyle",fontvariant:"fontVariant",fontweight:"fontWeight",for:"htmlFor",formaction:"formAction",formenctype:"formEncType",formmethod:"formMethod",formnovalidate:"formNoValidate",formtarget:"formTarget",frameborder:"frameBorder","glyph-name":"glyphName","glyph-orientation-horizontal":"glyphOrientationHorizontal","glyph-orientation-vertical":"glyphOrientationVertical",glyphname:"glyphName",glyphorientationhorizontal:"glyphOrientationHorizontal",glyphorientationvertical:"glyphOrientationVertical",glyphref:"glyphRef",gradienttransform:"gradientTransform",gradientunits:"gradientUnits","horiz-adv-x":"horizAdvX","horiz-origin-x":"horizOriginX",horizadvx:"horizAdvX",horizoriginx:"horizOriginX",hreflang:"hrefLang",htmlfor:"htmlFor","http-equiv":"httpEquiv",httpequiv:"httpEquiv","image-rendering":"imageRendering",imagerendering:"imageRendering",innerhtml:"innerHTML",inputmode:"inputMode",itemid:"itemID",itemprop:"itemProp",itemref:"itemRef",itemscope:"itemScope",itemtype:"itemType",kernelmatrix:"kernelMatrix",kernelunitlength:"kernelUnitLength",keyparams:"keyParams",keypoints:"keyPoints",keysplines:"keySplines",keytimes:"keyTimes",keytype:"keyType",lengthadjust:"lengthAdjust","letter-spacing":"letterSpacing",letterspacing:"letterSpacing","lighting-color":"lightingColor",lightingcolor:"lightingColor",limitingconeangle:"limitingConeAngle",marginheight:"marginHeight",marginwidth:"marginWidth","marker-end":"markerEnd","marker-mid":"markerMid","marker-start":"markerStart",markerend:"markerEnd",markerheight:"markerHeight",markermid:"markerMid",markerstart:"markerStart",markerunits:"markerUnits",markerwidth:"markerWidth",maskcontentunits:"maskContentUnits",maskunits:"maskUnits",maxlength:"maxLength",mediagroup:"mediaGroup",minlength:"minLength",nomodule:"noModule",novalidate:"noValidate",numoctaves:"numOctaves","overline-position":"overlinePosition","overline-thickness":"overlineThickness",overlineposition:"overlinePosition",overlinethickness:"overlineThickness","paint-order":"paintOrder",paintorder:"paintOrder","panose-1":"panose1",pathlength:"pathLength",patterncontentunits:"patternContentUnits",patterntransform:"patternTransform",patternunits:"patternUnits",playsinline:"playsInline","pointer-events":"pointerEvents",pointerevents:"pointerEvents",pointsatx:"pointsAtX",pointsaty:"pointsAtY",pointsatz:"pointsAtZ",preservealpha:"preserveAlpha",preserveaspectratio:"preserveAspectRatio",primitiveunits:"primitiveUnits",radiogroup:"radioGroup",readonly:"readOnly",referrerpolicy:"referrerPolicy",refx:"refX",refy:"refY","rendering-intent":"renderingIntent",renderingintent:"renderingIntent",repeatcount:"repeatCount",repeatdur:"repeatDur",requiredextensions:"requiredExtensions",requiredfeatures:"requiredFeatures",rowspan:"rowSpan","shape-rendering":"shapeRendering",shaperendering:"shapeRendering",specularconstant:"specularConstant",specularexponent:"specularExponent",spellcheck:"spellCheck",spreadmethod:"spreadMethod",srcdoc:"srcDoc",srclang:"srcLang",srcset:"srcSet",startoffset:"startOffset",stddeviation:"stdDeviation",stitchtiles:"stitchTiles","stop-color":"stopColor","stop-opacity":"stopOpacity",stopcolor:"stopColor",stopopacity:"stopOpacity","strikethrough-position":"strikethroughPosition","strikethrough-thickness":"strikethroughThickness",strikethroughposition:"strikethroughPosition",strikethroughthickness:"strikethroughThickness","stroke-dasharray":"strokeDasharray","stroke-dashoffset":"strokeDashoffset","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","stroke-miterlimit":"strokeMiterlimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth",strokedasharray:"strokeDasharray",strokedashoffset:"strokeDashoffset",strokelinecap:"strokeLinecap",strokelinejoin:"strokeLinejoin",strokemiterlimit:"strokeMiterlimit",strokeopacity:"strokeOpacity",strokewidth:"strokeWidth",suppresscontenteditablewarning:"suppressContentEditableWarning",suppresshydrationwarning:"suppressHydrationWarning",surfacescale:"surfaceScale",systemlanguage:"systemLanguage",tabindex:"tabIndex",tablevalues:"tableValues",targetx:"targetX",targety:"targetY",templatelock:"templateLock","text-anchor":"textAnchor","text-decoration":"textDecoration","text-rendering":"textRendering",textanchor:"textAnchor",textdecoration:"textDecoration",textlength:"textLength",textrendering:"textRendering","underline-position":"underlinePosition","underline-thickness":"underlineThickness",underlineposition:"underlinePosition",underlinethickness:"underlineThickness","unicode-bidi":"unicodeBidi","unicode-range":"unicodeRange",unicodebidi:"unicodeBidi",unicoderange:"unicodeRange","units-per-em":"unitsPerEm",unitsperem:"unitsPerEm",usemap:"useMap","v-alphabetic":"vAlphabetic","v-hanging":"vHanging","v-ideographic":"vIdeographic","v-mathematical":"vMathematical",valphabetic:"vAlphabetic","vector-effect":"vectorEffect",vectoreffect:"vectorEffect","vert-adv-y":"vertAdvY","vert-origin-x":"vertOriginX","vert-origin-y":"vertOriginY",vertadvy:"vertAdvY",vertoriginx:"vertOriginX",vertoriginy:"vertOriginY",vhanging:"vHanging",videographic:"vIdeographic",viewbox:"viewBox",viewtarget:"viewTarget",vmathematical:"vMathematical","word-spacing":"wordSpacing",wordspacing:"wordSpacing","writing-mode":"writingMode",writingmode:"writingMode","x-height":"xHeight",xchannelselector:"xChannelSelector",xheight:"xHeight","xlink:actuate":"xlinkActuate","xlink:arcrole":"xlinkArcrole","xlink:href":"xlinkHref","xlink:role":"xlinkRole","xlink:show":"xlinkShow","xlink:title":"xlinkTitle","xlink:type":"xlinkType",xlinkactuate:"xlinkActuate",xlinkarcrole:"xlinkArcrole",xlinkhref:"xlinkHref",xlinkrole:"xlinkRole",xlinkshow:"xlinkShow",xlinktitle:"xlinkTitle",xlinktype:"xlinkType","xml:base":"xmlBase","xml:lang":"xmlLang","xml:space":"xmlSpace",xmlbase:"xmlBase",xmllang:"xmlLang","xmlns:xlink":"xmlnsXlink",xmlnsxlink:"xmlnsXlink",xmlspace:"xmlSpace",ychannelselector:"yChannelSelector",zoomandpan:"zoomAndPan"},function(o,s){var e=wp.blockEditor,u=e.BlockControls,a=e.InspectorControls,t=e.InnerBlocks,r=wp.components,l=r.Toolbar,c=r.IconButton,i=r.Placeholder,p=r.Spinner,f=wp.element.Fragment,h=React.Component,e=wp.data.withSelect,r=wp.compose.createHigherOrderComponent,d={};function m(e){return d[e]||!1}function y(t){return function(t){var r,e=function(e){return"core/block-editor"!==e?wp.data.select(e):wp.data.select("core/block-editor")||wp.data.select("core/editor")}("core/block-editor").getBlocks(),n=0;for(;n<e.length;)e=e.concat(e[n].innerBlocks),n++;for(r in t)e=e.filter(function(e){return e.attributes[r]===t[r]});return e}().filter(function(e){return e.attributes.id===t.attributes.id}).filter(function(e){return e.clientId!==t.clientId}).length}function n(t){var e=t.post_types||[];if(e.length){e.push("wp_block");var r=acf.get("postType");if(-1===e.indexOf(r))return!1}"string"==typeof t.icon&&"<svg"===t.icon.substr(0,4)&&(a=t.icon,t.icon=React.createElement(S,null,a)),t.icon||delete t.icon,wp.blocks.getCategories().filter(function(e){return e.slug===t.category}).pop()||(t.category="common");var n,i,o,a={id:{type:"string"},name:{type:"string"},data:{type:"object"},align:{type:"string"},mode:{type:"string"}},l=R,c=w;t.supports.align_text&&((o=a).align_text={type:"string"},a=o,n=l,i=M,(o=t).align_text=i(o.align_text),l=function(){_inherits(t,h);var e=_createSuper(t);function t(){return _classCallCheck(this,t),e.apply(this,arguments)}return _createClass(t,[{key:"render",value:function(){var e=this.props,t=e.attributes,r=e.setAttributes,t=t.align_text;return React.createElement(f,null,React.createElement(u,null,React.createElement(I,{value:i(t),onChange:function(e){r({align_text:i(e)})}})),React.createElement(n,this.props))}}]),t}()),t.supports.align_content&&((o=a).align_content={type:"string"},a=o,l=function(n,e){var i,o,t=e.supports.align_content;o="matrix"===t?(i=H||z,B):(i=D,j);return i!==s?(e.align_content=o(e.align_content),function(){_inherits(t,h);var e=_createSuper(t);function t(){return _classCallCheck(this,t),e.apply(this,arguments)}return _createClass(t,[{key:"render",value:function(){var e=this.props,t=e.attributes,r=e.setAttributes,t=t.align_content;return React.createElement(f,null,React.createElement(u,{group:"block"},React.createElement(i,{label:acf.__("Change content alignment"),value:o(t),onChange:function(e){r({align_content:o(e)})}})),React.createElement(n,this.props))}}]),t}()):(console.warn('The "'.concat(t,'" alignment component was not found.')),n)}(l,t)),t=acf.parseArgs(t,{title:"",name:"",category:"",attributes:a,edit:function(e){return React.createElement(l,e)},save:function(e){return React.createElement(c,e)}}),d[t.name]=t;a=wp.blocks.registerBlockType(t.name,t);return a.attributes.anchor&&(a.attributes.anchor={type:"string"}),a}var g={};function k(e){var t=e.attributes,r=void 0===t?{}:t,t=e.query,t=void 0===t?{}:t,e=e.delay,e=void 0===e?0:e,n=r.id,i=g[n]||{query:{},timeout:!1,promise:o.Deferred()};return i.query=_objectSpread(_objectSpread({},i.query),t),clearTimeout(i.timeout),i.timeout=setTimeout(function(){o.ajax({url:acf.get("ajaxurl"),dataType:"json",type:"post",cache:!1,data:acf.prepareForAjax({action:"acf/ajax/fetch-block",block:JSON.stringify(r),query:i.query})}).always(function(){g[n]=null}).done(function(){i.promise.resolve.apply(this,arguments)}).fail(function(){i.promise.reject.apply(this,arguments)})},e),(g[n]=i).promise}function v(e,t){return JSON.stringify(e)===JSON.stringify(t)}function b(e){var t=acf.isget(acf,"jsxNameReplacements",e);return t||e}function _(e){switch(e){case"innerblocks":return t;case"script":return O;case"#comment":return null;default:e=b(e)}return e}function x(e){var t=e.name,r=e.value;switch(t){case"class":t="className";break;case"style":var n={};r.split(";").forEach(function(e){var t,r=e.indexOf(":");0<r&&(t=e.substr(0,r).trim(),r=e.substr(r+1).trim(),"-"!==t.charAt(0)&&(t=acf.strCamelCase(t)),n[t]=r)}),r=n;break;default:if(0===t.indexOf("data-"))break;var t=b(t),i=r.charAt(0);"true"!==(r="["===i||"{"===i?JSON.parse(r):r)&&"false"!==r||(r="true"===r)}return{name:t,value:r}}acf.parseJSX=function(e){return function r(e){var t=_(e.nodeName.toLowerCase());if(!t)return null;var n={};acf.arrayArgs(e.attributes).map(x).forEach(function(e){n[e.name]=e.value});var i=[t,n];acf.arrayArgs(e.childNodes).forEach(function(e){var t;e instanceof Text?(t=e.textContent)&&i.push(t):i.push(r(e))});return React.createElement.apply(this,i)}(o(e)[0])};r=r(function(e){return function(){_inherits(c,h);var l=_createSuper(c);function c(e){_classCallCheck(this,c);var t,r,n=(t=l.call(this,e)).props,i=n.name,o=n.attributes,a=m(i);if(!a)return _possibleConstructorReturn(t);if(e.attributes.id)return y(e)?(o.id=acf.uniqid("block_"),_possibleConstructorReturn(t)):t;for(r in o.id=acf.uniqid("block_"),a.attributes)o[r]===s&&a[r]!==s&&(o[r]=a[r]);return _possibleConstructorReturn(t)}return _createClass(c,[{key:"render",value:function(){return React.createElement(e,this.props)}}]),c}()},"withDefaultAttributes");function w(){return React.createElement(t.Content,null)}wp.hooks.addFilter("editor.BlockListBlock","acf/with-default-attributes",r);var R=function(){_inherits(r,h);var t=_createSuper(r);function r(e){return _classCallCheck(this,r),(e=t.call(this,e)).setup(),e}return _createClass(r,[{key:"setup",value:function(){var e=this.props,t=e.name,r=e.attributes;function n(e){-1===e.indexOf(r.mode)&&(r.mode=e[0])}switch(m(t).mode){case"edit":n(["edit","preview"]);break;case"preview":n(["preview","edit"]);break;default:n(["auto"])}}},{key:"render",value:function(){var e=this.props,t=e.name,r=e.attributes,n=e.setAttributes,i=r.mode,r=m(t).supports.mode;"auto"===i&&(r=!1);t="preview"===i?acf.__("Switch to Edit"):acf.__("Switch to Preview");return React.createElement(f,null,React.createElement(u,null,r&&React.createElement(l,null,React.createElement(c,{className:"components-icon-button components-toolbar__control",label:t,icon:"preview"===i?"edit":"welcome-view-site",onClick:function(){n({mode:"preview"===i?"edit":"preview"})}}))),React.createElement(a,null,"preview"===i&&React.createElement("div",{className:"acf-block-component acf-block-panel"},React.createElement(P,this.props))),React.createElement(C,this.props))}}]),r}(),r=function(){_inherits(t,h);var e=_createSuper(t);function t(){return _classCallCheck(this,t),e.apply(this,arguments)}return _createClass(t,[{key:"render",value:function(){var e=this.props,t=e.attributes,e=e.isSelected,t=t.mode;return React.createElement("div",{className:"acf-block-component acf-block-body"},!("auto"===t&&e||("auto"!==t||e)&&"preview"!==t)?React.createElement(T,this.props):React.createElement(P,this.props))}}]),t}(),C=e(function(e,t){var r=t.clientId,t=e("core/block-editor").getBlockRootClientId(r);return{index:e("core/block-editor").getBlockIndex(r,t)}})(r),S=function(){_inherits(t,h);var e=_createSuper(t);function t(){return _classCallCheck(this,t),e.apply(this,arguments)}return _createClass(t,[{key:"render",value:function(){return React.createElement("div",{dangerouslySetInnerHTML:{__html:this.props.children}})}}]),t}(),O=function(){_inherits(t,h);var e=_createSuper(t);function t(){return _classCallCheck(this,t),e.apply(this,arguments)}return _createClass(t,[{key:"render",value:function(){var t=this;return React.createElement("div",{ref:function(e){return t.el=e}})}},{key:"setHTML",value:function(e){o(this.el).html("<script>".concat(e,"<\/script>"))}},{key:"componentDidUpdate",value:function(){this.setHTML(this.props.children)}},{key:"componentDidMount",value:function(){this.setHTML(this.props.children)}}]),t}(),A={},E=function(){_inherits(n,h);var r=_createSuper(n);function n(e){var t;return _classCallCheck(this,n),(t=r.call(this,e)).setRef=t.setRef.bind(_assertThisInitialized(t)),t.id="",t.el=!1,t.subscribed=!0,t.renderMethod="jQuery",t.setup(e),t.loadState(),t}return _createClass(n,[{key:"setup",value:function(e){}},{key:"fetch",value:function(){}},{key:"loadState",value:function(){this.state=A[this.id]||{}}},{key:"setState",value:function(e){A[this.id]=_objectSpread(_objectSpread({},this.state),e),this.subscribed&&_get(_getPrototypeOf(n.prototype),"setState",this).call(this,e)}},{key:"setHtml",value:function(e){var t;(e=e?e.trim():"")!==this.state.html&&(t={html:e},"jsx"===this.renderMethod?(t.jsx=acf.parseJSX(e),t.$el=o(this.el)):t.$el=o(e),this.setState(t))}},{key:"setRef",value:function(e){this.el=e}},{key:"render",value:function(){return this.state.jsx?React.createElement("div",{ref:this.setRef},this.state.jsx):React.createElement("div",{ref:this.setRef},React.createElement(i,null,React.createElement(p,null)))}},{key:"shouldComponentUpdate",value:function(e,t){return e.index!==this.props.index&&this.componentWillMove(),t.html!==this.state.html}},{key:"display",value:function(e){var t,r,n;switch("jQuery"===this.renderMethod&&(r=(t=this.state.$el).parent(),(n=o(this.el)).html(t),r.length&&r[0]!==n[0]&&r.html(t.clone())),e){case"append":this.componentDidAppend();break;case"remount":this.componentDidRemount()}}},{key:"componentDidMount",value:function(){this.state.html===s?this.fetch():this.display("remount")}},{key:"componentDidUpdate",value:function(e,t){this.display("append")}},{key:"componentDidAppend",value:function(){acf.doAction("append",this.state.$el)}},{key:"componentWillUnmount",value:function(){acf.doAction("unmount",this.state.$el),this.subscribed=!1}},{key:"componentDidRemount",value:function(){var e=this;this.subscribed=!0,setTimeout(function(){acf.doAction("remount",e.state.$el)})}},{key:"componentWillMove",value:function(){var e=this;acf.doAction("unmount",this.state.$el),setTimeout(function(){acf.doAction("remount",e.state.$el)})}}]),n}(),P=function(){_inherits(a,E);var e=_createSuper(a);function a(){return _classCallCheck(this,a),e.apply(this,arguments)}return _createClass(a,[{key:"setup",value:function(e){this.id="BlockForm-".concat(e.attributes.id)}},{key:"fetch",value:function(){var t=this;k({attributes:this.props.attributes,query:{form:!0}}).done(function(e){t.setHtml(e.data.form)})}},{key:"componentDidAppend",value:function(){_get(_getPrototypeOf(a.prototype),"componentDidAppend",this).call(this);var e=this.props,r=e.attributes,n=e.setAttributes,i=this.state.$el;function t(){var e=0<arguments.length&&arguments[0]!==s&&arguments[0],t=acf.serialize(i,"acf-".concat(r.id));e?r.data=t:n({data:t})}var o=!1;i.on("change keyup",function(){clearTimeout(o),o=setTimeout(t,300)}),r.data||t(!0)}}]),a}(),T=function(){_inherits(o,E);var e=_createSuper(o);function o(){return _classCallCheck(this,o),e.apply(this,arguments)}return _createClass(o,[{key:"setup",value:function(e){this.id="BlockPreview-".concat(e.attributes.id),m(e.name).supports.jsx&&(this.renderMethod="jsx")}},{key:"fetch",value:function(){var t=this,e=0<arguments.length&&arguments[0]!==s?arguments[0]:{},r=e.attributes,n=void 0===r?this.props.attributes:r,r=e.delay,e=void 0===r?0:r;if(this.setState({prevAttributes:n}),this.state.html===s){r=acf.get("preloadedBlocks");if(r&&r[n.id])return void this.setHtml(r[n.id])}k({attributes:n,query:{preview:!0},delay:e}).done(function(e){t.setHtml(e.data.preview)})}},{key:"componentDidAppend",value:function(){_get(_getPrototypeOf(o.prototype),"componentDidAppend",this).call(this);var e=this.props.attributes,t=this.state.$el,r=e.name.replace("acf/","");acf.doAction("render_block_preview",t,e),acf.doAction("render_block_preview/type=".concat(r),t,e)}},{key:"shouldComponentUpdate",value:function(e,t){var r,n=e.attributes,i=this.props.attributes;return v(n,i)||(r=0,n.className!==i.className&&(r=300),n.anchor!==i.anchor&&(r=300),this.fetch({attributes:n,delay:r})),_get(_getPrototypeOf(o.prototype),"shouldComponentUpdate",this).call(this,e,t)}},{key:"componentDidRemount",value:function(){_get(_getPrototypeOf(o.prototype),"componentDidRemount",this).call(this),v(this.state.prevAttributes,this.props.attributes)||this.fetch()}}]),o}();function j(e){return["top","center","bottom"].includes(e)?e:"top"}function M(e){var t=acf.get("rtl")?"right":"left";return["left","center","right"].includes(e)?e:t}function B(e){if(e){var t=_slicedToArray(e.split(" "),2),e=t[0],t=t[1];return j(e)+" "+M(t)}return"center center"}acf.addAction("prepare",function(){wp.blockEditor||(wp.blockEditor=wp.editor);var e=acf.get("blockTypes");e&&e.map(n)});var r=wp.blockEditor,I=r.AlignmentToolbar,D=r.BlockVerticalAlignmentToolbar,z=wp.blockEditor.__experimentalBlockAlignmentMatrixToolbar||wp.blockEditor.BlockAlignmentMatrixToolbar,H=wp.blockEditor.__experimentalBlockAlignmentMatrixControl||wp.blockEditor.BlockAlignmentMatrixControl}(jQuery); |