@tripetto/block-textarea
Version:
Text input (multi-line) block for Tripetto.
3 lines (2 loc) • 1.9 kB
JavaScript
/*! Tripetto Textarea Block 6.0.3 - Copyright (C) 2023 Tripetto B.V. - All Rights Reserved */
import{tripetto as t,condition as e,ConditionBlock as r,isVariable as s,Str as i,NodeBlock as n,assert as a,isString as o,validator as l}from"@tripetto/runner";function c(t,e,r,s){var i,n=arguments.length,a=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,s);else for(var o=t.length-1;o>=0;o--)(i=t[o])&&(a=(n<3?i(a):n>3?i(e,r,a):i(e,r))||a);return n>3&&a&&Object.defineProperty(e,r,a),a}let h=class extends r{getMatchString(){if(s(this.props.match)){const t=this.variableFor(this.props.match);return t&&t.hasValue?t.string:""}return this.parseVariables(this.props.match||"","",!0)}isEqual(){const t=this.valueOf();if(t){const e=this.props.ignoreCase?i.lowercase(this.getMatchString()):this.getMatchString(),r=this.props.ignoreCase?i.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}};c([e],h.prototype,"isEqual",null),h=c([t({type:"condition",legacyBlock:!0,identifier:"@tripetto/block-textarea"})],h);class p extends n{constructor(){super(...arguments),this.textareaSlot=a(this.valueOf("value","static",{prefill:o(this.props.prefill)&&{value:this.props.prefill}||void 0})),this.required=this.textareaSlot.slot.required||!1,this.maxLength=this.textareaSlot.slot.maxLength}validate(){return!this.props.minLength||!this.textareaSlot.value.length||this.textareaSlot.value.length>=this.props.minLength}}c([l],p.prototype,"validate",null);export{p as Textarea};