PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.5.1
JetFormBuilder — Dynamic Blocks Form Builder v3.5.1
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / assets / build / frontend / advanced.reporting.js
jetformbuilder / assets / build / frontend Last commit date
advanced.reporting.asset.php 1 year ago advanced.reporting.js 1 year ago calculated.field.asset.php 1 year ago calculated.field.js 1 year ago conditional.block.asset.php 1 year ago conditional.block.js 1 year ago dynamic.value.asset.php 1 year ago dynamic.value.js 1 year ago main.asset.php 1 year ago main.css 1 year ago main.js 1 year ago media.field.asset.php 1 year ago media.field.js 1 year ago media.field.restrictions.asset.php 1 year ago media.field.restrictions.js 1 year ago multi.step.asset.php 1 year ago multi.step.js 1 year ago
advanced.reporting.js
1 lines
1 (()=>{"use strict";var t={n:e=>{var i=e&&e.__esModule?()=>e.default:()=>e;return t.d(i,{a:i}),i},d:(e,i)=>{for(var r in i)t.o(i,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:i[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const{Restriction:e,CalculatedFormula:i}=window.JetFormBuilderAbstract;function r(){e.call(this),this.message="",this.formula=null,this.watchedAttrs=[]}r.prototype=Object.create(e.prototype),r.prototype.message="",r.prototype.formula=null,r.prototype.watchedAttrs=[],r.prototype.isServerSide=function(){return!1},r.prototype.getMessage=function(){return this.message},r.prototype.getRawMessage=function(){return"Error"},r.prototype.getMessageBySlug=function(t){return function(t,e){var i,r,s,n;const{reporting:o}=t,a=null!==(i=o.messages[e])&&void 0!==i?i:"";if(a)return a;const u=null!==(r=window?.JetFormsValidation)&&void 0!==r&&r;if(!1===u)return"";const c=o.input.getSubmit(),{messages:l}=null!==(s=u[c.getFormId()])&&void 0!==s?s:{};return null!==(n=l[e])&&void 0!==n?n:""}(this,t)},r.prototype.onReady=function(){this.formula=new i(this.reporting.input),this.formula.observe(this.getRawMessage()),this.formula.setResult=()=>{this.message=this.formula.calculateString()},this.formula.setResult(),this.watchedAttrs.length&&(this.reporting.watchAttrs=[...new Set([...this.reporting.watchAttrs,...this.watchedAttrs])])};const s=r;function n(){s.call(this),this.watchedAttrs.push("max"),this.isSupported=function(t,e){const{max:i=!1}=e.input.attrs;return!1!==i&&["number","range"].includes(t.type)},this.validate=function(){const t=this.getValue(),{max:e}=this.reporting.input.attrs;return!t||+t<=+e.value.current},this.getRawMessage=function(){return this.getMessageBySlug("number_max")}}n.prototype=Object.create(s.prototype);const o=n;function a(){s.call(this),this.watchedAttrs.push("min"),this.isSupported=function(t,e){const{min:i=!1}=e.input.attrs;return!1!==i&&["number","range"].includes(t.type)},this.validate=function(){const t=this.getValue(),{min:e}=this.reporting.input.attrs;return!t||+t>=+e.value.current},this.getRawMessage=function(){return this.getMessageBySlug("number_min")}}a.prototype=Object.create(s.prototype);const u=a;function c(){s.call(this),this.isSupported=function(t){return"url"===t.type},this.validate=function(){const t=this.getValue();return!t||/((mailto\:|(news|(ht|f)tp(s?))\:\/\/)\S+)/.test(t)},this.getRawMessage=function(){return this.getMessageBySlug("url")}}c.prototype=Object.create(s.prototype);const l=c;function p(){s.call(this),this.isSupported=function(t){return"email"===t.type},this.validate=function(){const t=this.getValue();return!t||/^[\w-\.\+]+@([\w-]+\.)+[\w-]{1,6}$/.test(t)},this.getRawMessage=function(){return this.getMessageBySlug("email")}}p.prototype=Object.create(s.prototype);const h=p;function d(){s.call(this),this.watchedAttrs.push("minLength"),this.isSupported=function(t,e){const{minLength:i=!1}=e.input.attrs;return!1!==i},this.validate=function(){const t=this.getValue()?.length,{minLength:e}=this.reporting.input.attrs;return!t||t>=+e.value.current},this.getRawMessage=function(){return this.getMessageBySlug("char_min")}}d.prototype=Object.create(s.prototype);const g=d;function f(){s.call(this),this.watchedAttrs.push("maxLength"),this.isSupported=function(t,e){const{maxLength:i=!1}=e.input.attrs;return!1!==i},this.validate=function(){const t=this.getValue()?.length,{maxLength:e}=this.reporting.input.attrs;return!t||t<=+e.value.current},this.getRawMessage=function(){return this.getMessageBySlug("char_max")}}f.prototype=Object.create(s.prototype);const y=f,{isEmpty:m}=JetFormBuilderFunctions;function v(){s.call(this),this.type="required"}v.prototype=Object.create(s.prototype),v.prototype.isSupported=function(t,e){return e.input.isRequired},v.prototype.validate=function(){const t=this.getValue();return!m(t)},v.prototype.getRawMessage=function(){return this.getMessageBySlug("empty")};const S=v;function b(){s.call(this),this.isSupported=function(t){return t.classList.contains("jet-form-builder__masked-field")&&jQuery.fn.inputmask},this.validate=function(){const t=this.getValue(),e=this.reporting.getNode();return!t||e.inputmask.isComplete()},this.getRawMessage=function(){return this.getMessageBySlug("inputmask")}}b.prototype=Object.create(s.prototype);const w=b;function j(){s.call(this),this.isSupported=function(t,e){var i;const r=t.closest(".jet-form-builder-row"),s=JSON.parse(null!==(i=r.dataset?.validationRules)&&void 0!==i?i:"[]");return!!Boolean(s.length)&&(e.restrictions=[...e.restrictions,...X(s,e)],!1)}}j.prototype=Object.create(s.prototype);const R=j;function _(){s.call(this),this.attrs={}}_.prototype=Object.create(s.prototype),_.prototype.attrs={},_.prototype.setAttrs=function(t){this.attrs=t},_.prototype.getSlug=function(){throw new Error("you need to return slug of rule")},_.prototype.getRawMessage=function(){var t;return null!==(t=this.attrs?.message)&&void 0!==t?t:""};const A=_;function O(){A.call(this),this.getSlug=function(){return"contain"}}O.prototype=Object.create(A.prototype),O.prototype.setAttrs=function(t){A.prototype.setAttrs.call(this,t),Z.call(this)},O.prototype.validate=function(){const t=this.getValue();return!t||t.includes(this.attrs.value)};const B=O;function M(){B.call(this),this.getSlug=function(){return"contain_not"},this.validate=function(){return!this.getValue()||!B.prototype.validate.call(this)}}M.prototype=Object.create(B.prototype);const F=M;function P(){A.call(this),this.getSlug=function(){return"regexp"}}P.prototype=Object.create(A.prototype),P.prototype.setAttrs=function(t){A.prototype.setAttrs.call(this,t),Z.call(this)},P.prototype.validate=function(){const t=this.getValue();return!t||new RegExp(this.attrs.value,"g").test(t)};const V=P;function x(){V.call(this),this.getSlug=function(){return"regexp_not"},this.validate=function(){return!this.getValue()||!V.prototype.validate.call(this)}}x.prototype=Object.create(V.prototype);const k=x,E=window.wp.apiFetch;var L=t.n(E);function N(){A.call(this),this.getSlug=function(){return"ssr"},this.isServerSide=function(){return!0},this.validatePromise=async function(t=null){if(!this.getValue())return Promise.resolve();const e=this.getFormData();try{const i=await L()({path:"/jet-form-builder/v1/validate-field",method:"POST",body:e,signal:t});return i?.result?Promise.resolve():Promise.reject()}catch(t){throw t}},this.getFormData=function(){const{input:t}=this.reporting,{rootNode:e}=t.getRoot(),i=new FormData(e);i.delete("_wpnonce"),i.set("_jfb_validation_rule_index",this.attrs.index);for(const e of t.path)i.append("_jfb_validation_path[]",e);return i}}N.prototype=Object.create(A.prototype);const J=N;function T(){A.call(this),this.getSlug=function(){return"equal"},this.validate=function(){const t=this.getValue();return!t||t===this.attrs.value}}T.prototype=Object.create(A.prototype),T.prototype.setAttrs=function(t){A.prototype.setAttrs.call(this,t),Z.call(this)};const q=T,{getTimestamp:C}=JetFormBuilderFunctions;function I(){s.call(this),this.watchedAttrs.push("min"),this.isSupported=function(t,e){const{min:i=!1}=e.input.attrs;return!1!==i&&["time","date","datetime-local"].includes(t.type)},this.validate=function(){const t=this.getValue();if(!t)return!0;const{min:e}=this.reporting.input.attrs,{time:i}=C(t),{time:r}=C(e.value.current);return i>=r},this.getRawMessage=function(){return this.getMessageBySlug("date_min")}}I.prototype=Object.create(s.prototype);const D=I,{getTimestamp:H}=JetFormBuilderFunctions;function Q(){s.call(this),this.watchedAttrs.push("max"),this.isSupported=function(t,e){const{max:i=!1}=e.input.attrs;return!1!==i&&["time","date","datetime-local"].includes(t.type)},this.validate=function(){const t=this.getValue();if(!t)return!0;const{max:e}=this.reporting.input.attrs,{time:i}=H(t),{time:r}=H(e.value.current);return i<=r},this.getRawMessage=function(){return this.getMessageBySlug("date_max")}}Q.prototype=Object.create(s.prototype);const $=Q,{applyFilters:z}=JetPlugins.hooks,{isEmpty:G}=JetFormBuilderFunctions,K=()=>z("jet.fb.advanced.rules",[B,F,V,k,J,q]);let U=[],W=[];function X(t,e){const i=[];U.length||(U=K());for(const[r,s]of Object.entries(t))for(const t of U){const n=new t;if(s.type===n.getSlug()){delete s.type,n.setReporting(e),n.setAttrs({...s,index:r}),n.onReady(),i.push(n);break}}return i}function Y(t){return t.closest(".jet-form-builder-row")}function Z(){if(!this.attrs?.field)return;const{root:t}=this.reporting.input,e=t.getInput(this.attrs.field);e.watch((()=>{this.attrs.value=e.value.current,this.reporting.valuePrev=null,this.reporting.validateOnChange()})),G(e.value.current)||(this.attrs.value=e.value.current)}function tt(t){for(const e of t.children)if(e.classList.contains("error-message"))return e;const e=t.querySelector(".jet-form-builder-col__end");return!!e&&tt(e)}const{ReportingInterface:et}=JetFormBuilderAbstract,{allRejected:it}=JetFormBuilderFunctions;function rt(){et.call(this),this.type="inherit",this.messages={},this.skipServerSide=!0,this.watchAttrs=[],this.queue=[]}rt.prototype=Object.create(et.prototype),rt.prototype.skipServerSide=!0,rt.prototype.hasServerSide=!1,rt.prototype.isProcess=null,rt.prototype.queue=[],rt.prototype.setRestrictions=function(){!function(t){W.length||(W=z("jet.fb.restrictions",[D,$,o,u,l,h,w,g,y,S,R]));for(const e of W){const i=new e;i.isSupported(t.getNode(),t)&&(i.setReporting(t),i.onReady(),t.restrictions.push(i))}}(this)},rt.prototype.isSupported=function(t,e){this.type=function(t){var e;const i=Y(t),{validationType:r=""}=null!==(e=i?.dataset)&&void 0!==e?e:{};return r}(t);const i="inherit"===this.type?function(t){var e,i;const r=null!==(e=window?.JetFormsValidation)&&void 0!==e&&e;if(!1===r)return"";const s=t.getSubmit().getFormId(),{type:n=""}=null!==(i=r[s])&&void 0!==i?i:{};return n}(e):this.type;return!!i?.length},rt.prototype.getErrorsRaw=async function(t,e=null){this.hasServerSide&&this.input.loading.start();let i=await it(t);return this.valuePrev=this.input.getValue(),this.hasServerSide&&this.input.loading.end(),e?.aborted&&(i=[]),i},rt.prototype.reportRaw=function(t){let e="";for(const i of t)if(e=i.getMessage(),e?.length)break;e?this.insertError(e):this.clearReport()},rt.prototype.setInput=function(t){this.messages=function(t){var e;const i=Y(t),{validationMessages:r="{}"}=null!==(e=i?.dataset)&&void 0!==e?e:{};return JSON.parse(r)}(t.nodes[0]),et.prototype.setInput.call(this,t)},rt.prototype.observeAttrs=function(){for(const t of this.watchAttrs)this.input.attrs.hasOwnProperty(t)&&this.input.attrs[t].value.watch((()=>{this.valuePrev=null,this.validateOnBlur()}))},rt.prototype.clearReport=function(){(()=>{const t=Y(this.getNode());if(!t)return;t.classList.remove("field-has-error");const e=tt(t);e&&e.remove()})(),this.makeValid()},rt.prototype.insertError=function(t){(()=>{const e=Y(this.getNode()),i=this.createError(e,t);if(e.classList.add("field-has-error"),i.isConnected)return;const r=e.querySelector(".jet-form-builder-col__end");r?r.appendChild(i):e.appendChild(i)})(),this.makeInvalid()},rt.prototype.createError=function(t,e){const i=tt(t);if(i)return i.innerHTML=e,i;const r=this.getNode(),s=document.createElement("div");return s.classList.add("error-message"),s.innerHTML=e,s.id=r.id+"__error",s},rt.prototype.makeInvalid=function(){var t;const e=tt(Y(this.getNode()));this.getNode().setAttribute("aria-invalid","true"),this.getNode().setAttribute("aria-describedby",null!==(t=e?.id)&&void 0!==t&&t)},rt.prototype.makeValid=function(){this.getNode().removeAttribute("aria-invalid"),this.getNode().removeAttribute("aria-describedby")},rt.prototype.validateOnChange=function(t=!1){this.switchButtonsState(!0);const e=()=>{this.input.getContext().setSilence(!1),this.validate().then((()=>{})).catch((()=>{})).finally((()=>{this.isProcess=null;const t=[...this.queue];this.queue=[],t.length?(this.valuePrev=null,t.forEach((t=>t())),this.switchButtonsState()):this.switchButtonsState()}))};t&&this.isProcess&&(this.queue=[e]),this.isProcess||(this.isProcess=!0,e())},rt.prototype.validateOnBlur=function(t=null){this.isProcess||(this.isProcess=!0,this.skipServerSide=!1,this.switchButtonsState(!0),this.canSubmitForm(!1),this.canTriggerEnterSubmit(!1),this.input.getContext().setSilence(!1),this.validate(t).then((()=>{})).catch((()=>{})).finally((()=>{this.skipServerSide=!0,this.hasServerSide=!1,this.isProcess=null,this.input.nodes[0].readOnly=!1,t?.aborted||(this.switchButtonsState(),this.canSubmitForm(),this.validityState.current&&this.canTriggerEnterSubmit())})))},rt.prototype.switchButtonsState=function(t=!1){const e=this.input.nodes[0].closest(".jet-form-builder-page");if(e&&!this.input.getContext().silence){const i=e.querySelectorAll(".jet-form-builder__next-page, .jet-form-builder__prev-page, .jet-form-builder__action-button");for(const e of i)(e.classList.contains("jet-form-builder__submit")||this.isNodeBelongThis(e))&&(e.classList.contains("jet-form-builder__prev-page")?e.disabled=t:e.disabled=!0===t||!this.validityState.current)}},rt.prototype.canTriggerEnterSubmit=function(t=!0){const e=this.input.root.form;e&&(e.canTriggerEnterSubmit=t)},rt.prototype.canSubmitForm=function(t=!0){const e=this.input.root.form;e&&(e.canSubmitForm=t)},rt.prototype.isNodeBelongThis=function(t){const e=t.closest(".jet-form-builder-page");return!!e&&!e.classList.contains("jet-form-builder-page--hidden")},rt.prototype.validateOnChangeState=function(){return this.isProcess?Promise.resolve():(this.switchButtonsState(!0),this.canTriggerEnterSubmit(!1),this.input.maskValidation&&this.input.changeStateMaskValidation(),this.isProcess=!0,this.skipServerSide=!1,new Promise(((t,e)=>{this.validate().then(t).catch(e).finally((()=>{this.skipServerSide=!0,this.hasServerSide=!1,this.isProcess=null,this.input.nodes[0].readOnly=!1,this.switchButtonsState(),this.canTriggerEnterSubmit()}))})))},rt.prototype.canProcessRestriction=function(t){return!this.skipServerSide||!t.isServerSide()},rt.prototype.beforeProcessRestriction=function(t){this.hasServerSide=!!t.isServerSide()||this.hasServerSide};const st=rt;var nt;const{addFilter:ot,addAction:at}=JetPlugins.hooks;at("jet.fb.observe.after","jet-form-builder/observe-dynamic-attrs",(function(t){t.getInputs().forEach((t=>{t.reporting instanceof st&&t.reporting.observeAttrs()}))}),11),ot("jet.fb.reporting","jet-form-builder/advanced-reporting",(function(t){return[st,...t]})),window.JetFormBuilderAbstract={...null!==(nt=window.JetFormBuilderAbstract)&&void 0!==nt?nt:{},AdvancedRestriction:s,NotEmptyRestriction:S}})();