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) 3.17 kB
"use strict";var e=require("primevue/basecomponent"),t=require("primevue/terminalservice"),n=require("vue");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=o(e),m=o(t),s={name:"Terminal",extends:r.default,props:{welcomeMessage:{type:String,default:null},prompt:{type:String,default:null}},data:()=>({commandText:null,commands:[]}),mounted(){m.default.on("response",this.responseListener),this.$refs.input.focus()},updated(){this.$el.scrollTop=this.$el.scrollHeight},beforeUnmount(){m.default.off("response",this.responseListener)},methods:{onClick(){this.$refs.input.focus()},onKeydown(e){"Enter"===e.code&&this.commandText&&(this.commands.push({text:this.commandText}),m.default.emit("command",this.commandText),this.commandText="")},responseListener(e){this.commands[this.commands.length-1].response=e}}};!function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&o.firstChild?o.insertBefore(r,o.firstChild):o.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.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"),s.render=function(e,t,o,r,m,s){return n.openBlock(),n.createElementBlock("div",n.mergeProps({class:"p-terminal p-component",onClick:t[2]||(t[2]=(...e)=>s.onClick&&s.onClick(...e))},e.ptm("root")),[o.welcomeMessage?(n.openBlock(),n.createElementBlock("div",n.normalizeProps(n.mergeProps({key:0},e.ptm("welcomeMessage"))),n.toDisplayString(o.welcomeMessage),17)):n.createCommentVNode("",!0),n.createElementVNode("div",n.mergeProps({class:"p-terminal-content"},e.ptm("content")),[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(m.commands,((t,r)=>(n.openBlock(),n.createElementBlock("div",n.mergeProps({key:t.text+r.toString()},e.ptm("commands")),[n.createElementVNode("span",n.mergeProps({class:"p-terminal-prompt"},e.ptm("prompt")),n.toDisplayString(o.prompt),17),n.createElementVNode("span",n.mergeProps({class:"p-terminal-command"},e.ptm("command")),n.toDisplayString(t.text),17),n.createElementVNode("div",n.mergeProps({class:"p-terminal-response","aria-live":"polite"},e.ptm("response")),n.toDisplayString(t.response),17)],16)))),128))],16),n.createElementVNode("div",n.mergeProps({class:"p-terminal-prompt-container"},e.ptm("container")),[n.createElementVNode("span",n.mergeProps({class:"p-terminal-prompt"},e.ptm("prompt")),n.toDisplayString(o.prompt),17),n.withDirectives(n.createElementVNode("input",n.mergeProps({ref:"input","onUpdate:modelValue":t[0]||(t[0]=e=>m.commandText=e),type:"text",class:"p-terminal-input",autocomplete:"off",onKeydown:t[1]||(t[1]=(...e)=>s.onKeydown&&s.onKeydown(...e))},e.ptm("commandText")),null,16),[[n.vModelText,m.commandText]])],16)],16)},module.exports=s;