switcher.js
1 lines
| 1 | (()=>{"use strict";function t(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;l=!1}else for(;!(l=(n=i.call(e)).done)&&(u.push(n.value),u.length!==r);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}(t,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.")}()}function r(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}var e=JetFormBuilderAbstract,n=e.InputData,o=e.ReactiveHook;function i(){n.call(this),this.isSupported=function(t){return"switch"===(null==t?void 0:t.role)},this.addListeners=function(){var r=this,e=t(this.nodes,1)[0];e.addEventListener("input",(function(t){r.value.current=t.target.checked})),e.addEventListener("blur",(function(t){r.reportOnBlur()})),this.enterKey=new o,e.addEventListener("keydown",this.handleEnterKey.bind(this)),this.sanitize((function(t){return Boolean(t)?e.value:""}))},this.setValue=function(){var r=t(this.nodes,1)[0];this.value.current=r.checked?r.value:null},this.setNode=function(t){n.prototype.setNode.call(this,t),this.inputType="switcher"}}i.prototype=Object.create(n.prototype);const a=i;function u(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}var l=JetFormBuilderAbstract.BaseSignal;function c(){l.call(this),this.isSupported=function(t,r){return"switch"===t.role},this.runSignal=function(){var t,r,e,n,o=(e=this.input.nodes,n=1,function(t){if(Array.isArray(t))return t}(e)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;l=!1}else for(;!(l=(n=i.call(e)).done)&&(u.push(n.value),u.length!==r);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(e,n)||function(t,r){if(t){if("string"==typeof t)return u(t,r);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,r):void 0}}(e,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.")}())[0];this.input.calcValue=0,o.checked=this.input.value.current===o.value,o.checked&&(this.input.calcValue+=parseFloat(null!==(t=null===(r=o.dataset)||void 0===r?void 0:r.calculate)&&void 0!==t?t:o.value))}}c.prototype=Object.create(l.prototype);const s=c;function f(t){return function(t){if(Array.isArray(t))return d(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,r){if(t){if("string"==typeof t)return d(t,r);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)?d(t,r):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}var y=JetPlugins.hooks.addFilter;y("jet.fb.inputs","jet-form-builder/switcher",(function(t){return[a].concat(f(t))})),y("jet.fb.signals","jet-form-builder/switcher",(function(t){return[s].concat(f(t))}))})(); |