UNPKG

@tripetto/block-number

Version:

Number block for Tripetto.

2 lines 3.9 kB
/*! Tripetto Number Block 8.0.3 - Copyright (C) 2023 Tripetto B.V. - All Rights Reserved */ !function(){"use strict";var e={407:function(e,t,r){var o,n=this&&this.__extends||(o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},o(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__decorate||function(e,t,r,o){var n,i=arguments.length,u=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(e,t,r,o);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(u=(i<3?n(u):i>3?n(t,r,u):n(t,r))||u);return i>3&&u&&Object.defineProperty(t,r,u),u};Object.defineProperty(t,"__esModule",{value:!0}),t.NumberCondition=void 0;var u=r(226),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getValue=function(e,t){if((0,u.isString)(t)&&e instanceof u.Slots.Numeric){var r=this.variableFor(t);return r&&r.hasValue?e.toValue(r.value):void 0}return(0,u.isNumberFinite)(t)?t:void 0},t.prototype.verify=function(){var e=this.valueOf();if(e){var t=this.getValue(e.slot,this.props.value);switch(this.props.mode){case"equal":return(e.hasValue?e.value:void 0)===t;case"not-equal":return(e.hasValue?e.value:void 0)!==t;case"below":return(0,u.isNumberFinite)(t)&&e.hasValue&&e.value<t;case"above":return(0,u.isNumberFinite)(t)&&e.hasValue&&e.value>t;case"between":case"not-between":var r=this.getValue(e.slot,this.props.to);return(0,u.isNumberFinite)(t)&&(0,u.isNumberFinite)(r)&&(e.hasValue&&e.value>=u.Num.min(t,r)&&e.value<=u.Num.max(t,r))===("between"===this.props.mode);case"defined":return e.hasValue;case"undefined":return!e.hasValue}}return!1},i([u.condition],t.prototype,"verify",null),t=i([(0,u.tripetto)({type:"condition",legacyBlock:!0,identifier:"@tripetto/block-number"})],t)}(u.ConditionBlock);t.NumberCondition=a},856:function(e,t,r){var o,n=this&&this.__extends||(o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},o(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.Number=void 0;var i=r(226);r(407),r(873);var u=r(39);r(982);var a=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.calculatorSlot=t.valueOf("calculator","feature"),t.numberSlot=(0,i.assert)(t.valueOf("number","static",{prefill:(0,i.isNumberFinite)(t.props.prefill)&&{value:t.props.prefill}||void 0,onChange:function(e){t.calculatorSlot&&e.slot instanceof i.Slots.Numeric&&(0,u.calculator)(t.context,t.props.operations||[],e,t.calculatorSlot,(function(e){return t.variableFor(e)}),(function(e){return t.parseVariables(e)}))}})),t.required=t.numberSlot.slot.required||!1,t}return n(t,e),t}(i.NodeBlock);t.Number=a},873:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),(0,r(226).mountNamespace)("@tripetto/block-number")},982:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),(0,r(226).unmountNamespace)()},39:function(e){e.exports=require("@tripetto/block-calculator/runner")},226:function(e){e.exports=require("@tripetto/runner")}},t={};var r=function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,r),i.exports}(856);module.exports=r}();