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