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.73 kB
import e from"primevue/basecomponent";import n from"primevue/terminalservice";import{openBlock as t,createElementBlock as o,mergeProps as m,normalizeProps as s,toDisplayString as p,createCommentVNode as r,createElementVNode as i,Fragment as a,renderList as l,withDirectives as c,vModelText as d}from"vue";var u={name:"Terminal",extends:e,props:{welcomeMessage:{type:String,default:null},prompt:{type:String,default:null}},data:()=>({commandText:null,commands:[]}),mounted(){n.on("response",this.responseListener),this.$refs.input.focus()},updated(){this.$el.scrollTop=this.$el.scrollHeight},beforeUnmount(){n.off("response",this.responseListener)},methods:{onClick(){this.$refs.input.focus()},onKeydown(e){"Enter"===e.code&&this.commandText&&(this.commands.push({text:this.commandText}),n.emit("command",this.commandText),this.commandText="")},responseListener(e){this.commands[this.commands.length-1].response=e}}};!function(e,n){void 0===n&&(n={});var t=n.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],m=document.createElement("style");m.type="text/css","top"===t&&o.firstChild?o.insertBefore(m,o.firstChild):o.appendChild(m),m.styleSheet?m.styleSheet.cssText=e:m.appendChild(document.createTextNode(e))}}("\n.p-terminal {\n height: 18rem;\n overflow: auto;\n}\n.p-terminal-prompt-container {\n display: flex;\n align-items: center;\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.p-terminal-input::-ms-clear {\n display: none;\n}\n"),u.render=function(e,n,u,h,f,x){return t(),o("div",m({class:"p-terminal p-component",onClick:n[2]||(n[2]=(...e)=>x.onClick&&x.onClick(...e))},e.ptm("root")),[u.welcomeMessage?(t(),o("div",s(m({key:0},e.ptm("welcomeMessage"))),p(u.welcomeMessage),17)):r("",!0),i("div",m({class:"p-terminal-content"},e.ptm("content")),[(t(!0),o(a,null,l(f.commands,((n,s)=>(t(),o("div",m({key:n.text+s.toString()},e.ptm("commands")),[i("span",m({class:"p-terminal-prompt"},e.ptm("prompt")),p(u.prompt),17),i("span",m({class:"p-terminal-command"},e.ptm("command")),p(n.text),17),i("div",m({class:"p-terminal-response","aria-live":"polite"},e.ptm("response")),p(n.response),17)],16)))),128))],16),i("div",m({class:"p-terminal-prompt-container"},e.ptm("container")),[i("span",m({class:"p-terminal-prompt"},e.ptm("prompt")),p(u.prompt),17),c(i("input",m({ref:"input","onUpdate:modelValue":n[0]||(n[0]=e=>f.commandText=e),type:"text",class:"p-terminal-input",autocomplete:"off",onKeydown:n[1]||(n[1]=(...e)=>x.onKeydown&&x.onKeydown(...e))},e.ptm("commandText")),null,16),[[d,f.commandText]])],16)],16)};export{u as default};