@tripetto/block-text
Version:
Text input (single-line) block for Tripetto.
2 lines • 6.89 kB
JavaScript
/*! Tripetto Text Block 6.0.2 - Copyright (C) 2023 Tripetto B.V. - All Rights Reserved */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("TripettoRunner")):"function"==typeof define&&define.amd?define("TripettoBlockText",["TripettoRunner"],e):"object"==typeof exports?exports.TripettoBlockText=e(require("TripettoRunner")):t.TripettoBlockText=e(t.TripettoRunner)}(this,(function(t){return function(){"use strict";var e={502:function(t,e,r){var o,n=this&&this.__extends||(o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},o(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__decorate||function(t,e,r,o){var n,i=arguments.length,s=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,o);else for(var u=t.length-1;u>=0;u--)(n=t[u])&&(s=(i<3?n(s):i>3?n(e,r,s):n(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s};Object.defineProperty(e,"__esModule",{value:!0}),e.ScoreCondition=void 0;var s=r(294),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.getValue=function(t,e){if((0,s.isString)(e)&&t instanceof s.Slots.Numeric){var r=this.variableFor(e);return r&&r.hasValue?t.toValue(r.value):void 0}return(0,s.isNumberFinite)(e)?e:void 0},e.prototype.verify=function(){var t=this.valueOf();if(t){var e=this.getValue(t.slot,this.props.value);switch(this.props.mode){case"equal":return(t.hasValue?t.value:void 0)===e;case"not-equal":return(t.hasValue?t.value:void 0)!==e;case"below":return(0,s.isNumberFinite)(e)&&t.hasValue&&t.value<e;case"above":return(0,s.isNumberFinite)(e)&&t.hasValue&&t.value>e;case"between":case"not-between":var r=this.getValue(t.slot,this.props.to);return(0,s.isNumberFinite)(e)&&(0,s.isNumberFinite)(r)&&(t.hasValue&&t.value>=s.Num.min(e,r)&&t.value<=s.Num.max(e,r))===("between"===this.props.mode);case"defined":return t.hasValue;case"undefined":return!t.hasValue}}return!1},i([s.condition],e.prototype,"verify",null),e=i([(0,s.tripetto)({type:"condition",legacyBlock:!0,identifier:"".concat("@tripetto/block-text",":score")})],e)}(s.ConditionBlock);e.ScoreCondition=u},400:function(t,e,r){var o,n=this&&this.__extends||(o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},o(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__decorate||function(t,e,r,o){var n,i=arguments.length,s=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,o);else for(var u=t.length-1;u>=0;u--)(n=t[u])&&(s=(i<3?n(s):i>3?n(e,r,s):n(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s};Object.defineProperty(e,"__esModule",{value:!0}),e.TextCondition=void 0;var s=r(294),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.getMatchString=function(){if((0,s.isVariable)(this.props.match)){var t=this.variableFor(this.props.match);return t&&t.hasValue?t.string:""}return this.parseVariables(this.props.match||"")},e.prototype.isEqual=function(){var t=this.valueOf();if(t){var e=this.props.ignoreCase?s.Str.lowercase(this.getMatchString()):this.getMatchString(),r=this.props.ignoreCase?s.Str.lowercase(t.string):t.string;switch(this.props.mode){case"exact":return r===e;case"not-exact":return r!==e;case"contains":return e&&-1!==r.indexOf(e)||!1;case"not-contains":return e&&-1===r.indexOf(e)||!1;case"starts":return e&&0===r.indexOf(e)||!1;case"ends":return e&&r.length>=e.length&&r.lastIndexOf(e)===r.length-e.length||!1;case"defined":return""!==r;case"undefined":return""===r}}return!1},i([s.condition],e.prototype,"isEqual",null),e=i([(0,s.tripetto)({type:"condition",legacyBlock:!0,identifier:"@tripetto/block-text"})],e)}(s.ConditionBlock);e.TextCondition=u},856:function(t,e,r){var o,n=this&&this.__extends||(o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},o(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__decorate||function(t,e,r,o){var n,i=arguments.length,s=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,o);else for(var u=t.length-1;u>=0;u--)(n=t[u])&&(s=(i<3?n(s):i>3?n(e,r,s):n(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s};Object.defineProperty(e,"__esModule",{value:!0}),e.Text=void 0;var s=r(294);r(400),r(502);var u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.scoreSlot=e.valueOf("score","feature"),e.textSlot=(0,s.assert)(e.valueOf("value","static",{prefill:(0,s.isString)(e.props.prefill)&&{value:e.props.prefill}||void 0,modifier:function(t){var r;if(e.props.useSuggestions)return{value:t.value,reference:t.value&&(null===(r=(0,s.findFirst)(e.props.suggestions,(function(e){return e.name===t.value})))||void 0===r?void 0:r.id)||void 0}},onChange:function(t){if(e.scoreSlot){var r=e.props.useSuggestions&&(0,s.findFirst)(e.props.suggestions,(function(e){return e.name===t.value}))||void 0;e.scoreSlot.set(r&&((null==r?void 0:r.score)||0))}}})),e.required=e.textSlot.slot.required||!1,e.maxLength=e.textSlot.slot.maxLength,e.autoComplete=e.props.autoComplete,e}return n(e,t),Object.defineProperty(e.prototype,"suggestions",{get:function(){var t;return this.props.useSuggestions&&(null===(t=this.props.suggestions)||void 0===t?void 0:t.map((function(t){return t.name})))||void 0},enumerable:!1,configurable:!0}),e.prototype.validate=function(){return!this.props.minLength||!this.textSlot.value.length||this.textSlot.value.length>=this.props.minLength},i([s.validator],e.prototype,"validate",null),e}(s.NodeBlock);e.Text=u},294:function(e){e.exports=t}},r={};var o=function t(o){var n=r[o];if(void 0!==n)return n.exports;var i=r[o]={exports:{}};return e[o].call(i.exports,i,i.exports,t),i.exports}(856);return o}()}));