primevue
Version:
[](https://opensource.org/licenses/MIT) [](https://badge.fury.io/js/primevue) [ • 3.36 kB
JavaScript
this.primevue=this.primevue||{},this.primevue.terminal=function(e,n,t,o){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var m=r(e),s=r(n),a=t.useStyle("\n.p-terminal {\n height: 18rem;\n overflow: auto;\n}\n\n.p-terminal-prompt-container {\n display: flex;\n align-items: center;\n}\n\n.p-terminal-input {\n flex: 1 1 auto;\n border: 0 none;\n background-color: transparent;\n color: inherit;\n padding: 0;\n outline: 0 none;\n}\n\n.p-terminal-input::-ms-clear {\n display: none;\n}\n",{name:"terminal",manual:!0}),i={name:"Terminal",extends:{name:"BaseTerminal",extends:s.default,props:{welcomeMessage:{type:String,default:null},prompt:{type:String,default:null}},css:{classes:{root:"p-terminal p-component",content:"p-terminal-content",prompt:"p-terminal-prompt",command:"p-terminal-command",response:"p-terminal-response",container:"p-terminal-prompt-container",commandText:"p-terminal-input"},loadStyle:a.load},provide:function(){return{$parentInstance:this}}},data:function(){return{commandText:null,commands:[]}},mounted:function(){m.default.on("response",this.responseListener),this.$refs.input.focus()},updated:function(){this.$el.scrollTop=this.$el.scrollHeight},beforeUnmount:function(){m.default.off("response",this.responseListener)},methods:{onClick:function(){this.$refs.input.focus()},onKeydown:function(e){"Enter"===e.code&&this.commandText&&(this.commands.push({text:this.commandText}),m.default.emit("command",this.commandText),this.commandText="")},responseListener:function(e){this.commands[this.commands.length-1].response=e}}};return i.render=function(e,n,t,r,m,s){return o.openBlock(),o.createElementBlock("div",o.mergeProps({class:e.cx("root"),onClick:n[2]||(n[2]=function(){return s.onClick&&s.onClick.apply(s,arguments)})},e.ptm("root"),{"data-pc-name":"terminal"}),[e.welcomeMessage?(o.openBlock(),o.createElementBlock("div",o.normalizeProps(o.mergeProps({key:0},e.ptm("welcomeMessage"))),o.toDisplayString(e.welcomeMessage),17)):o.createCommentVNode("",!0),o.createElementVNode("div",o.mergeProps({class:e.cx("content")},e.ptm("content")),[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(m.commands,(function(n,t){return o.openBlock(),o.createElementBlock("div",o.mergeProps({key:n.text+t.toString()},e.ptm("commands")),[o.createElementVNode("span",o.mergeProps({class:e.cx("prompt")},e.ptm("prompt")),o.toDisplayString(e.prompt),17),o.createElementVNode("span",o.mergeProps({class:e.cx("command")},e.ptm("command")),o.toDisplayString(n.text),17),o.createElementVNode("div",o.mergeProps({class:e.cx("response"),"aria-live":"polite"},e.ptm("response")),o.toDisplayString(n.response),17)],16)})),128))],16),o.createElementVNode("div",o.mergeProps({class:e.cx("container")},e.ptm("container")),[o.createElementVNode("span",o.mergeProps({class:e.cx("prompt")},e.ptm("prompt")),o.toDisplayString(e.prompt),17),o.withDirectives(o.createElementVNode("input",o.mergeProps({ref:"input","onUpdate:modelValue":n[0]||(n[0]=function(e){return m.commandText=e}),type:"text",class:e.cx("commandText"),autocomplete:"off",onKeydown:n[1]||(n[1]=function(){return s.onKeydown&&s.onKeydown.apply(s,arguments)})},e.ptm("commandText")),null,16),[[o.vModelText,m.commandText]])],16)],16)},i}(primevue.terminalservice,primevue.basecomponent,primevue.usestyle,Vue);