UNPKG

primevue

Version:

PrimeVue is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBloc

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