UNPKG

primevue

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primevue.svg)](https://badge.fury.io/js/primevue) [![Discord Chat](https://img.shields.io/discord/55794023

2 lines (1 loc) 2.92 kB
import n from"primevue/terminalservice";import e from"primevue/basecomponent";import{useStyle as t}from"primevue/usestyle";import{openBlock as o,createElementBlock as m,mergeProps as r,normalizeProps as s,toDisplayString as a,createCommentVNode as p,createElementVNode as i,Fragment as c,renderList as l,withDirectives as d,vModelText as u}from"vue";var f=t("\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}),x={name:"Terminal",extends:{name:"BaseTerminal",extends:e,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:f.load},provide:function(){return{$parentInstance:this}}},data:function(){return{commandText:null,commands:[]}},mounted:function(){n.on("response",this.responseListener),this.$refs.input.focus()},updated:function(){this.$el.scrollTop=this.$el.scrollHeight},beforeUnmount:function(){n.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}),n.emit("command",this.commandText),this.commandText="")},responseListener:function(n){this.commands[this.commands.length-1].response=n}}};x.render=function(n,e,t,f,x,h){return o(),m("div",r({class:n.cx("root"),onClick:e[2]||(e[2]=function(){return h.onClick&&h.onClick.apply(h,arguments)})},n.ptm("root"),{"data-pc-name":"terminal"}),[n.welcomeMessage?(o(),m("div",s(r({key:0},n.ptm("welcomeMessage"))),a(n.welcomeMessage),17)):p("",!0),i("div",r({class:n.cx("content")},n.ptm("content")),[(o(!0),m(c,null,l(x.commands,(function(e,t){return o(),m("div",r({key:e.text+t.toString()},n.ptm("commands")),[i("span",r({class:n.cx("prompt")},n.ptm("prompt")),a(n.prompt),17),i("span",r({class:n.cx("command")},n.ptm("command")),a(e.text),17),i("div",r({class:n.cx("response"),"aria-live":"polite"},n.ptm("response")),a(e.response),17)],16)})),128))],16),i("div",r({class:n.cx("container")},n.ptm("container")),[i("span",r({class:n.cx("prompt")},n.ptm("prompt")),a(n.prompt),17),d(i("input",r({ref:"input","onUpdate:modelValue":e[0]||(e[0]=function(n){return x.commandText=n}),type:"text",class:n.cx("commandText"),autocomplete:"off",onKeydown:e[1]||(e[1]=function(){return h.onKeydown&&h.onKeydown.apply(h,arguments)})},n.ptm("commandText")),null,16),[[u,x.commandText]])],16)],16)};export{x as default};