PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.2.2
JetFormBuilder — Dynamic Blocks Form Builder v3.2.2
3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 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 / js / frontend / conditional.block.js
jetformbuilder / assets / js / frontend Last commit date
lib 2 years ago advanced.reporting.js 2 years ago calculated.field.js 3 years ago checkbox.field.js 2 years ago conditional.block.js 3 years ago custom.options.restrictions.js 2 years ago dynamic.value.js 2 years ago main.js 2 years ago media.field.js 3 years ago media.field.restrictions.js 2 years ago multi.step.js 2 years ago radio.field.js 2 years ago repeater.field.js 2 years ago
conditional.block.js
1 lines
1 (()=>{"use strict";function t(){}t.prototype.isSupported=function(t){return!1},t.prototype.observe=function(){},t.prototype.setOptions=function(t){},t.prototype.isPassed=function(){throw new Error("You must provide ConditionItem::isPassed function")},t.prototype.setList=function(t){this.list=t};const n=t;function e(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}var r=JetFormBuilderAbstract.CalculatedFormula;function o(){n.call(this),this.isSupported=function(t){var n;return!(null==t||null===(n=t.field)||void 0===n||!n.length)},this.observe=function(){var t,n=this,e=this.getInput();this.list._fields=null!==(t=this.list._fields)&&void 0!==t?t:[],e&&!this.list._fields.includes(this.field)&&(this.list._fields.push(this.field),e.watch((function(){return n.list.onChangeRelated()})))},this.getInput=function(){return this.list.root.getInput(this.field)},this.isPassed=function(){var t=this.getInput();return!!t&&t.checker.check(this,t)},this.setOptions=function(t){var n=this;this.field=t.field,this.operator=t.operator,this.render_state=t.render_state,this.use_preset=t.use_preset;var o=null==t?void 0:t.value;if(Array.isArray(o)||(o=o.split(",").map((function(t){return t.trim()}))),this.use_preset)this.value=o;else{this.value={};for(var i=function(){var t,o,i=(t=s[u],o=2,function(t){if(Array.isArray(t))return t}(t)||function(t,n){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var r,o,i,u,s=[],l=!0,a=!1;try{if(i=(e=e.call(t)).next,0===n){if(Object(e)!==e)return;l=!1}else for(;!(l=(r=i.call(e)).done)&&(s.push(r.value),s.length!==n);l=!0);}catch(t){a=!0,o=t}finally{try{if(!l&&null!=e.return&&(u=e.return(),Object(u)!==u))return}finally{if(a)throw o}}return s}}(t,o)||function(t,n){if(t){if("string"==typeof t)return e(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}(t,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),l=i[0],a=i[1],c=new r(n.list.root);c.observe(a),c.setResult=function(){n.value[l]=""+c.calculate(),n.list.onChangeRelated()},c.setResult()},u=0,s=Object.entries(o);u<s.length;u++)i();this.value=Object.values(this.value)}}}o.prototype=Object.create(n.prototype),o.prototype.field=null,o.prototype.value=null,o.prototype.operator=null,o.prototype.use_preset=null;const i=o;function u(){n.call(this),this.isSupported=function(t){var n;return null!==(n=t.or_operator)&&void 0!==n&&n}}u.prototype=Object.create(n.prototype);const s=u;function l(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return a(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?a(t,n):void 0}}(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,s=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return u=t.done,t},e:function(t){s=!0,i=t},f:function(){try{u||null==e.return||e.return()}finally{if(s)throw i}}}}function a(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function c(t,n){this.root=n,this.setConditions(t)}c.prototype={root:null,conditions:[],invalid:[],groups:[],onChangeRelated:function(){this.getResult()&&this.onMatchConditions()},onMatchConditions:function(){},observe:function(){var t,n=l(this.getConditions());try{for(n.s();!(t=n.n()).done;)t.value.observe()}catch(t){n.e(t)}finally{n.f()}},setConditions:function(t){var n=this;"string"==typeof t&&(t=JSON.parse(t)),this.conditions=t.map((function(t){return function(t,n){V.length||(V=N());var e,r=D(V);try{for(r.s();!(e=r.n()).done;){var o=new(0,e.value);if(o.isSupported(t))return o.setList(n),o.setOptions(t),o}}catch(t){r.e(t)}finally{r.f()}}(t,n)})).filter((function(t){return t}));var e,r={},o=0,i=l(this.getConditions());try{for(i.s();!(e=i.n()).done;){var u,a=e.value;a instanceof s?o++:(r[o]=null!==(u=r[o])&&void 0!==u?u:[],r[o].push(a))}}catch(t){i.e(t)}finally{i.f()}this.groups=Object.values(r)},getResult:function(){if(this.invalid=[],!this.groups.length)return!0;var t,n=l(this.groups);try{for(n.s();!(t=n.n()).done;){var e=t.value;if(this.isValidGroup(e))return!0}}catch(t){n.e(t)}finally{n.f()}return!1},isValidGroup:function(t){var n,e=l(t);try{for(e.s();!(n=e.n()).done;){var r=n.value;if(!r.isPassed())return this.invalid.push(r),!1}}catch(t){e.e(t)}finally{e.f()}return!0},getConditions:function(){return this.conditions}};const f=c;function h(t,n){f.call(this,t,n)}h.prototype=Object.create(f.prototype),h.prototype.block=null;const d=h;function p(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var r,o,i,u,s=[],l=!0,a=!1;try{if(i=(e=e.call(t)).next,0===n){if(Object(e)!==e)return;l=!1}else for(;!(l=(r=i.call(e)).done)&&(s.push(r.value),s.length!==n);l=!0);}catch(t){a=!0,o=t}finally{try{if(!l&&null!=e.return&&(u=e.return(),Object(u)!==u))return}finally{if(a)throw o}}return s}}(t,n)||function(t,n){if(t){if("string"==typeof t)return y(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?y(t,n):void 0}}(t,n)||function(){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 y(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}var v=JetPlugins.hooks.doAction,b=JetFormBuilderAbstract.ReactiveVar,m=JetFormBuilderFunctions.validateInputsAll;function g(t,n){var e;this.node=t,t.jfbConditional=this,this.root=n,this.isObserved=!1,this.list=null,this.function=null,this.settings=null,this.page=null,this.multistep=null,this.comment=null,this.inputs=[],this.isRight=new b(null),this.isRight.make(),this.setConditions(),this.setInputs(),this.setFunction(),null!==(e=window)&&void 0!==e&&null!==(e=e.JetFormBuilderSettings)&&void 0!==e&&e.devmode||(delete this.node.dataset.jfbConditional,delete this.node.dataset.jfbFunc),v("jet.fb.conditional.init",this)}g.prototype={setConditions:function(){var t=this,n=this.node.dataset.jfbConditional;this.list=new d(n,this.root),this.list.block=this,this.list.onChangeRelated=function(){t.isRight.current=t.list.getResult()}},setInputs:function(){this.inputs=Array.from(this.node.querySelectorAll("[data-jfb-sync]")).map((function(t){return t.jfbSync})).filter((function(t){return t}))},insertComment:function(){var t;null!==(t=this.settings)&&void 0!==t&&t.dom&&(this.comment=document.createComment(""),this.node.parentElement.insertBefore(this.comment,this.node.nextSibling))},observe:function(){var t=this;this.isObserved||(this.isObserved=!0,this.insertComment(),this.isRight.watch((function(){return t.runFunction()})),this.isRight.watch((function(){return t.validateInputs()})),this.list.observe())},runFunction:function(){var t=this.isRight.current;switch(this.function){case"show":this.showBlock(t);break;case"hide":this.showBlock(!t);break;case"disable":this.disableBlock(t);break;default:v("jet.fb.conditional.block.runFunction",this.function,t,this)}},validateInputs:function(){var t=this;setTimeout((function(){m(t.inputs,!0).then((function(){})).catch((function(){}))}))},showBlock:function(t){var n;this.node.classList.remove("jet-form-builder--hidden"),null!==(n=this.settings)&&void 0!==n&&n.dom?this.showBlockDom(t):this.node.style.display=t?"block":"none"},showBlockDom:function(t){t?this.comment.parentElement.insertBefore(this.node,this.comment):this.node.remove()},disableBlock:function(t){this.node.disabled=t},setFunction:function(){var t;this.function=this.node.dataset.jfbFunc;try{t=JSON.parse(this.function)}catch(t){return}var n=p(Object.entries(t),1),e=p(n[0],2),r=e[0],o=e[1];this.function=r,this.settings=o}};const j=g;var w=JetFormBuilderFunctions.isEmpty;function O(){this.operators=this.getOperators()}O.prototype={isSupported:function(t){return!0},operators:{},getOperators:function(){return{equal:function(t,n){return t===n[0]},empty:function(t){return w(t)},greater:function(t,n){return+t>+n[0]},less:function(t,n){return+t<+n[0]},between:function(t,n){return!(null==n||!n.length||null===t)&&n[0]<=+t&&+t<=n[1]},one_of:function(t,n){return!(null==n||!n.length)&&0<=n.indexOf(t)},contain:function(t,n){return!!t&&0<=t.indexOf(n[0])}}},check:function(t,n){var e=n.value.current,r=t.value;return this.checkRaw(t.operator,e,r)},checkRaw:function(t,n,e){if(this.operators.hasOwnProperty(t))return this.operators[t](n,e);if(0!==t.indexOf("not_"))return!1;var r=t.slice(4);return!!this.operators.hasOwnProperty(r)&&!this.operators[r](n,e)}};const S=O;function A(){S.call(this),this.operators.one_of=function(t,n){return!(null==n||!n.length||null==t||!t.length)&&t.some((function(t){return-1!==n.indexOf(t)}))},this.operators.contain=function(t,n){return!(null==t||!t.length)&&t.some((function(t){return-1!==t.indexOf(n[0])}))},this.isSupported=function(t){return t.isArray()}}A.prototype=Object.create(S.prototype);const C=A;function k(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}var I=JetFormBuilderFunctions.getTimestamp,_=JetFormBuilderConst,R=_.Min_In_Sec,F=_.Milli_In_Sec,P=(new Date).getTimezoneOffset();function B(){S.call(this),this.isSupported=function(t){var n,e,r=(n=t.nodes,e=1,function(t){if(Array.isArray(t))return t}(n)||function(t,n){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var r,o,i,u,s=[],l=!0,a=!1;try{if(i=(e=e.call(t)).next,0===n){if(Object(e)!==e)return;l=!1}else for(;!(l=(r=i.call(e)).done)&&(s.push(r.value),s.length!==n);l=!0);}catch(t){a=!0,o=t}finally{try{if(!l&&null!=e.return&&(u=e.return(),Object(u)!==u))return}finally{if(a)throw o}}return s}}(n,e)||function(t,n){if(t){if("string"==typeof t)return k(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?k(t,n):void 0}}(n,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];return["date","time","datetime-local"].includes(r.type)},this.check=function(t,n){var e=I(n.value.current).time,r=t.value.map((function(n){var e=I(n),r=e.time;return"number"===e.type&&t.use_preset?r*F+P*R:r}));return this.checkRaw(t.operator,e,r)}}B.prototype=Object.create(S.prototype);const J=B;function E(){n.call(this),this.isSupported=function(t){return"render_state"===(null==t?void 0:t.operator)},this.getInput=function(){return this.list.root.getInput("_jfb_current_render_states")},this.observe=function(){var t=this;this.getInput().watch((function(){return t.list.onChangeRelated()}))},this.setOptions=function(t){var n;this.render_state=null!==(n=t.render_state)&&void 0!==n?n:[]},this.isPassed=function(){var t,n=this.getInput().value;return!(null===(t=n.current)||void 0===t||!t.length)&&this.render_state.some((function(t){return n.current.includes(t)}))}}E.prototype=Object.create(n.prototype),E.prototype.render_state=[];const x=E;function T(){S.call(this),this.isSupported=function(t){return"calculated"===t.inputType},this.check=function(t,n){var e=n.calcValue,r=t.value;return this.checkRaw(t.operator,e,r)}}T.prototype=Object.create(S.prototype);const M=T;function D(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return U(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?U(t,n):void 0}}(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,s=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return u=t.done,t},e:function(t){s=!0,i=t},f:function(){try{u||null==e.return||e.return()}finally{if(s)throw i}}}}function U(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}var $,L=JetPlugins.hooks.applyFilters,N=function(){return L("jet.fb.conditional.types",[x,s,i])},V=[],q=[];function G(t,n){if(t.hasOwnProperty("jfbConditional"))return t.jfbConditional;var e=new j(t,n);return e.observe(),e.list.onChangeRelated(),e}function z(t){q.length||(q=L("jet.fb.conditional.checkers",[C,J,M,S]));var n,e=D(q);try{for(e.s();!(n=e.n()).done;){var r=new(0,n.value);if(r.isSupported(t))return r}}catch(t){e.e(t)}finally{e.f()}return null}function Y(t){return Y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Y(t)}function H(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),e.push.apply(e,r)}return e}function K(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{};n%2?H(Object(e),!0).forEach((function(n){Q(t,n,e[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):H(Object(e)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}))}return t}function Q(t,n,e){return(n=function(t){var n=function(t,n){if("object"!==Y(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!==Y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===Y(n)?n:String(n)}(n))in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function W(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}var X=JetPlugins.hooks.addAction;X("jet.fb.observe.after","jet-form-builder/conditional-block",(function(t){var n,e=function(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return W(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?W(t,n):void 0}}(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,s=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return u=t.done,t},e:function(t){s=!0,i=t},f:function(){try{u||null==e.return||e.return()}finally{if(s)throw i}}}}(t.rootNode.querySelectorAll("[data-jfb-conditional]"));try{for(e.s();!(n=e.n()).done;)G(n.value,t)}catch(t){e.e(t)}finally{e.f()}}),20),X("jet.fb.input.makeReactive","jet-form-builder/conditional-block",(function(t){t.checker=z(t)})),X("jet.fb.conditional.block.runFunction","jet-form-builder/conditional-block",(function(t,n,e){var r;"setCssClass"===t&&null!==(r=e.settings)&&void 0!==r&&r.className&&e.node.classList.toggle(e.settings.className,n)})),window.JetFormBuilderAbstract=K(K({},null!==($=window.JetFormBuilderAbstract)&&void 0!==$?$:{}),{},{ConditionItem:n,ConditionalBlock:j,createConditionalBlock:G,createChecker:z,ConditionsList:f})})();