UNPKG

@tripetto/block-textarea

Version:

Text input (multi-line) block for Tripetto.

2 lines 11.7 kB
/*! Tripetto Textarea Block 6.0.3 - Copyright (C) 2023 Tripetto B.V. - All Rights Reserved */ !function(){"use strict";var t={583:function(t,e,o){var i,a=this&&this.__extends||(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},i(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 o(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}),n=this&&this.__decorate||function(t,e,o,i){var a,n=arguments.length,r=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,o,i);else for(var l=t.length-1;l>=0;l--)(a=t[l])&&(r=(n<3?a(r):n>3?a(e,o,r):a(e,o))||r);return n>3&&r&&Object.defineProperty(e,o,r),r};Object.defineProperty(e,"__esModule",{value:!0}),e.TextareaCondition=void 0;var r=o(954),l=o(537),c=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.allowMarkdown=!0,e.mode="exact",e}return a(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return""},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){var t,e,o=this;if(this.slot instanceof r.Slots.Text){var i=((0,r.isVariable)(this.match)?(null===(t=(0,r.lookupVariable)(this,this.match))||void 0===t?void 0:t.label)&&"@".concat(this.match):this.match&&((e=(0,r.makeMarkdownSafe)(r.Str.replace(this.match,"\n","↵")))&&("contains"===o.mode||"not-contains"===o.mode||"starts"===o.mode||"ends"===o.mode)&&"_".concat(e,"_")||e))||"\\_\\_";switch(this.mode){case"exact":case"not-exact":return"@".concat(this.slot.id," ").concat("not-exact"===this.mode?"≠":"="," ").concat(i);case"contains":case"not-contains":case"starts":case"ends":return"@".concat(this.slot.id," ").concat("not-contains"===this.mode?(0,r.pgettext)("block:textarea","does not contain"):"starts"===this.mode?(0,r.pgettext)("block:textarea","starts with"):"ends"===this.mode?(0,r.pgettext)("block:textarea","ends with"):(0,r.pgettext)("block:textarea","contains")," ").concat(i);case"defined":return"@".concat(this.slot.id," ").concat((0,r.pgettext)("block:textarea","not empty"));case"undefined":return"@".concat(this.slot.id," ").concat((0,r.pgettext)("block:textarea","empty"))}}return this.type.label},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){var t;return null===(t=this.node)||void 0===t?void 0:t.label},enumerable:!1,configurable:!0}),e.prototype.defineEditor=function(){var t,e=this;this.editor.form({title:(0,r.pgettext)("block:textarea","Compare mode"),controls:[new r.Forms.Radiobutton([{label:(0,r.pgettext)("block:textarea","Text matches"),value:"exact"},{label:(0,r.pgettext)("block:textarea","Text does not match"),value:"not-exact"},{label:(0,r.pgettext)("block:textarea","Text contains"),value:"contains"},{label:(0,r.pgettext)("block:textarea","Text does not contain"),value:"not-contains"},{label:(0,r.pgettext)("block:textarea","Text starts with"),value:"starts"},{label:(0,r.pgettext)("block:textarea","Text ends with"),value:"ends"},{label:(0,r.pgettext)("block:textarea","Text is not empty"),value:"defined"},{label:(0,r.pgettext)("block:textarea","Text is empty"),value:"undefined"}],r.Forms.Radiobutton.bind(this,"mode","exact")).on((function(t){switch(l.visible("defined"!==t.value&&"undefined"!==t.value),t.value){case"exact":l.title=(0,r.pgettext)("block:textarea","If text matches");break;case"not-exact":l.title=(0,r.pgettext)("block:textarea","If text does not match");break;case"contains":l.title=(0,r.pgettext)("block:textarea","If text contains");break;case"not-contains":l.title=(0,r.pgettext)("block:textarea","If text does not contain");break;case"starts":l.title=(0,r.pgettext)("block:textarea","If text starts with");break;case"ends":l.title=(0,r.pgettext)("block:textarea","If text ends with")}a.isInteractable&&a.focus()}))]});var o=this.match&&(0,r.isVariable)(this.match)||!1,i=(0,r.populateVariables)(this,void 0,o?this.match:void 0,!1,null===(t=this.slot)||void 0===t?void 0:t.id),a=new r.Forms.Text("multiline",o?"":this.match).label((0,r.pgettext)("block:textarea","Use fixed text")).action("@",(0,r.insertVariable)(this,"exclude")).autoFocus().enter(this.editor.close).escape(this.editor.close).on((function(t){t.isFormVisible&&t.isObservable&&(e.match=t.value)})),n=new r.Forms.Dropdown(i,o?this.match:"").label((0,r.pgettext)("block:textarea","Use value of")).width("full").on((function(t){t.isFormVisible&&t.isObservable&&(e.match=t.value||void 0)})),l=this.editor.form({title:(0,r.pgettext)("block:textarea","If text matches"),controls:[new r.Forms.Radiobutton([{label:(0,r.pgettext)("block:textarea","Text"),value:"text"},{label:(0,r.pgettext)("block:textarea","Value"),value:"variable",disabled:0===i.length}],o?"variable":"text").on((function(t){a.visible("text"===t.value),n.visible("variable"===t.value),a.isInteractable&&a.focus()})),a,n,new r.Forms.Checkbox((0,r.pgettext)("block:textarea","Ignore case"),r.Forms.Checkbox.bind(this,"ignoreCase",void 0,!0))]}).visible("defined"!==this.mode&&"undefined"!==this.mode)},n([r.definition,(0,r.affects)("#name")],e.prototype,"mode",void 0),n([r.definition,(0,r.affects)("#name")],e.prototype,"match",void 0),n([r.definition],e.prototype,"ignoreCase",void 0),n([r.editor],e.prototype,"defineEditor",null),e=n([(0,r.tripetto)({type:"condition",legacyBlock:!0,context:"@tripetto/block-textarea",identifier:"@tripetto/block-textarea",version:"6.0.3",icon:l.default,get label(){return(0,r.pgettext)("block:textarea","Text contains")}})],e)}(r.ConditionBlock);e.TextareaCondition=c},110:function(t,e,o){var i,a=this&&this.__extends||(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},i(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 o(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}),n=this&&this.__decorate||function(t,e,o,i){var a,n=arguments.length,r=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,o,i);else for(var l=t.length-1;l>=0;l--)(a=t[l])&&(r=(n<3?a(r):n>3?a(e,o,r):a(e,o))||r);return n>3&&r&&Object.defineProperty(e,o,r),r};Object.defineProperty(e,"__esModule",{value:!0}),e.Textarea=void 0;var r=o(954),l=o(583),c=o(617),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),e.prototype.defineSlot=function(){this.textareaSlot=this.slots.static({type:r.Slots.Text,reference:"value",label:(0,r.pgettext)("block:textarea","Multi-line text"),exchange:["required","alias","exportable","maxLength","transformation"]})},e.prototype.defineEditor=function(){var t=this;this.editor.name(),this.editor.description(),this.editor.placeholder(),this.editor.explanation(),this.editor.groups.settings();var e=new r.Forms.Numeric(r.Forms.Numeric.bind(this,"minLength",void 0)).min(1).max(this.textareaSlot.maxLength).visible((0,r.isNumber)(this.minLength)).indent(32).width(75).on((function(){o.min(t.minLength||1)})),o=new r.Forms.Numeric(r.Forms.Numeric.bind(this.textareaSlot,"maxLength",void 0)).min(this.minLength||1).visible((0,r.isNumber)(this.textareaSlot.maxLength)).indent(32).width(75).on((function(){e.max(t.textareaSlot.maxLength)}));this.editor.option({name:(0,r.pgettext)("block:textarea","Limits"),form:{title:(0,r.pgettext)("block:textarea","Limits"),controls:[new r.Forms.Checkbox((0,r.pgettext)("block:textarea","Minimum"),(0,r.isNumber)(this.minLength)).on((function(t){e.visible(t.isChecked)})),e,new r.Forms.Checkbox((0,r.pgettext)("block:textarea","Maximum"),(0,r.isNumber)(this.textareaSlot.maxLength)).on((function(t){o.visible(t.isChecked)})),o]},activated:(0,r.isNumber)(this.textareaSlot.maxLength)||(0,r.isNumber)(this.minLength)}),this.editor.transformations(this.textareaSlot),this.editor.groups.options(),this.editor.option({name:(0,r.pgettext)("block:textarea","Prefill"),form:{title:(0,r.pgettext)("block:textarea","Prefill"),controls:[new r.Forms.Text("multiline",r.Forms.Text.bind(this,"prefill",void 0)).label((0,r.pgettext)("block:textarea","Prefill with the following text:"))]},activated:(0,r.isString)(this.prefill)}),this.editor.required(this.textareaSlot),this.editor.visibility(),this.editor.alias(this.textareaSlot),this.editor.exportable(this.textareaSlot)},e.prototype.defineCondition=function(){var t=this;(0,r.each)([{mode:"exact",label:(0,r.pgettext)("block:textarea","Text matches")},{mode:"not-exact",label:(0,r.pgettext)("block:textarea","Text does not match")},{mode:"contains",label:(0,r.pgettext)("block:textarea","Text contains")},{mode:"not-contains",label:(0,r.pgettext)("block:textarea","Text does not contain")},{mode:"starts",label:(0,r.pgettext)("block:textarea","Text starts with")},{mode:"ends",label:(0,r.pgettext)("block:textarea","Text ends with")},{mode:"defined",label:(0,r.pgettext)("block:textarea","Text is not empty")},{mode:"undefined",label:(0,r.pgettext)("block:textarea","Text is empty")}],(function(e){t.conditions.template({condition:l.TextareaCondition,label:e.label,autoOpen:"defined"!==e.mode&&"undefined"!==e.mode,props:{slot:t.textareaSlot,mode:e.mode}})}))},n([(0,r.definition)("string","optional")],e.prototype,"prefill",void 0),n([(0,r.definition)("number","optional")],e.prototype,"minLength",void 0),n([r.slots],e.prototype,"defineSlot",null),n([r.editor],e.prototype,"defineEditor",null),n([r.conditions],e.prototype,"defineCondition",null),e=n([(0,r.tripetto)({type:"node",legacyBlock:!0,identifier:"@tripetto/block-textarea",version:"6.0.3",icon:c.default,get label(){return(0,r.pgettext)("block:textarea","Text (multiple lines)")}})],e)}(r.NodeBlock);e.Textarea=s},537:function(t,e,o){o.r(e),e.default="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCI+PHBhdGggZD0iTTE3LjUgNWgtMTVhLjUuNSAwIDAgMSAwLTFoMTVhLjUuNSAwIDAgMSAwIDF6bS00IDNoLTExYS41LjUgMCAwIDEgMC0xaDExYS41LjUgMCAwIDEgMCAxem00IDNoLTE1YS41LjUgMCAwIDEgMC0xaDE1YS41LjUgMCAwIDEgMCAxem0tNCAzaC0xMWEuNS41IDAgMCAxIDAtMWgxMWEuNS41IDAgMCAxIDAgMXptNCAzaC0xNWEuNS41IDAgMCAxIDAtMWgxNWEuNS41IDAgMCAxIDAgMXoiIGNsYXNzPSJ0cmlwZXR0by1maWxsIi8+PC9zdmc+"},617:function(t,e,o){o.r(e),e.default="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCI+PHBhdGggZD0iTTE3LjUgNWgtMTVhLjUuNSAwIDAgMSAwLTFoMTVhLjUuNSAwIDAgMSAwIDF6bTAgMTJoLTE1YS41LjUgMCAwIDEgMC0xaDE1YS41LjUgMCAwIDEgMCAxem0tMi05aC0xM2EuNS41IDAgMCAwIDAgMWgxM2MuODI3IDAgMS41LjY3MyAxLjUgMS41cy0uNjczIDEuNS0xLjUgMS41aC01LjI5M2wxLjE0Ni0xLjE0NmEuNS41IDAgMCAwLS43MDctLjcwN2wtMiAyYS41LjUgMCAwIDAgMCAuNzA3bDIgMmEuNDk4LjQ5OCAwIDAgMCAuNzA4IDAgLjUuNSAwIDAgMCAwLS43MDdsLTEuMTQ2LTEuMTQ2aDUuMjkzYzEuMzc4IDAgMi41LTEuMTIyIDIuNS0yLjVzLTEuMTIyLTIuNS0yLjUtMi41eiIgY2xhc3M9InRyaXBldHRvLWZpbGwiLz48cGF0aCBkPSJNNi41IDEzaC00YS41LjUgMCAwIDEgMC0xaDRhLjUuNSAwIDAgMSAwIDF6IiBjbGFzcz0idHJpcGV0dG8tZmlsbCIvPjwvc3ZnPg=="},954:function(t){t.exports=require("@tripetto/builder")}},e={};function o(i){var a=e[i];if(void 0!==a)return a.exports;var n=e[i]={exports:{}};return t[i].call(n.exports,n,n.exports,o),n.exports}o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i=o(110);module.exports=i}();