Refactor #3879 - For Terminal
parent
7dfa8eb0f4
commit
4db6f0ff43
|
@ -10,6 +10,12 @@ const TerminalProps = [
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: 'null',
|
default: 'null',
|
||||||
description: 'Prompt text for each command.'
|
description: 'Prompt text for each command.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'pt',
|
||||||
|
type: 'any',
|
||||||
|
default: 'null',
|
||||||
|
description: 'Uses to pass attributes to DOM elements inside the component.'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,80 @@
|
||||||
*/
|
*/
|
||||||
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
||||||
|
|
||||||
|
export declare type TerminalPassThroughOptionType = TerminalPassThroughAttributes | ((options: TerminalPassThroughMethodOptions) => TerminalPassThroughAttributes) | null | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough(pt) option method.
|
||||||
|
*/
|
||||||
|
export interface TerminalPassThroughMethodOptions {
|
||||||
|
props: TerminalProps;
|
||||||
|
state: TerminalState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough(pt) options.
|
||||||
|
* @see {@link TerminalProps.pt}
|
||||||
|
*/
|
||||||
|
export interface TerminalPassThroughOptions {
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the root's DOM element.
|
||||||
|
*/
|
||||||
|
root?: TerminalPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the welcome message's DOM element.
|
||||||
|
*/
|
||||||
|
welcomeMessage?: TerminalPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the content's DOM element.
|
||||||
|
*/
|
||||||
|
content?: TerminalPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the commands' DOM element.
|
||||||
|
*/
|
||||||
|
commands?: TerminalPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the prompt's DOM element.
|
||||||
|
*/
|
||||||
|
prompt?: TerminalPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the command's DOM element.
|
||||||
|
*/
|
||||||
|
command?: TerminalPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the response's DOM element.
|
||||||
|
*/
|
||||||
|
response?: TerminalPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the container's DOM element.
|
||||||
|
*/
|
||||||
|
container?: TerminalPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the command text's DOM element.
|
||||||
|
*/
|
||||||
|
commandText?: TerminalPassThroughOptionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough attributes for each DOM elements
|
||||||
|
*/
|
||||||
|
export interface TerminalPassThroughAttributes {
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines current inline state in Terminal component.
|
||||||
|
*/
|
||||||
|
export interface TerminalState {
|
||||||
|
/**
|
||||||
|
* Current command text as a string.
|
||||||
|
*/
|
||||||
|
commandText: string;
|
||||||
|
/**
|
||||||
|
* Current commands as an array.
|
||||||
|
*/
|
||||||
|
commands: string[];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines valid properties in Terminal component.
|
* Defines valid properties in Terminal component.
|
||||||
*/
|
*/
|
||||||
|
@ -21,6 +95,11 @@ export interface TerminalProps {
|
||||||
* Prompt text for each command.
|
* Prompt text for each command.
|
||||||
*/
|
*/
|
||||||
prompt?: string | undefined;
|
prompt?: string | undefined;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to DOM elements inside the component.
|
||||||
|
* @type {TerminalPassThroughOptions}
|
||||||
|
*/
|
||||||
|
pt?: TerminalPassThroughOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,25 +1,27 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="p-terminal p-component" @click="onClick">
|
<div class="p-terminal p-component" @click="onClick" v-bind="root">
|
||||||
<div v-if="welcomeMessage">{{ welcomeMessage }}</div>
|
<div v-if="welcomeMessage" v-bind="welcomeMessage">{{ welcomeMessage }}</div>
|
||||||
<div class="p-terminal-content">
|
<div class="p-terminal-content" v-bind="content">
|
||||||
<div v-for="(command, i) of commands" :key="command.text + i.toString()">
|
<div v-for="(command, i) of commands" :key="command.text + i.toString()" v-bind="commands">
|
||||||
<span class="p-terminal-prompt">{{ prompt }}</span>
|
<span class="p-terminal-prompt" v-bind="prompt">{{ prompt }}</span>
|
||||||
<span class="p-terminal-command">{{ command.text }}</span>
|
<span class="p-terminal-command" v-bind="command">{{ command.text }}</span>
|
||||||
<div class="p-terminal-response" aria-live="polite">{{ command.response }}</div>
|
<div class="p-terminal-response" aria-live="polite" v-bind="response">{{ command.response }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="p-terminal-prompt-container">
|
<div class="p-terminal-prompt-container" v-bind="container">
|
||||||
<span class="p-terminal-prompt">{{ prompt }}</span>
|
<span class="p-terminal-prompt" v-bind="prompt">{{ prompt }}</span>
|
||||||
<input ref="input" v-model="commandText" type="text" class="p-terminal-input" autocomplete="off" @keydown="onKeydown" />
|
<input ref="input" v-model="commandText" type="text" class="p-terminal-input" autocomplete="off" @keydown="onKeydown" v-bind="commandText" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import BaseComponent from 'primevue/basecomponent';
|
||||||
import TerminalService from 'primevue/terminalservice';
|
import TerminalService from 'primevue/terminalservice';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Terminal',
|
name: 'Terminal',
|
||||||
|
extends: BaseComponent,
|
||||||
props: {
|
props: {
|
||||||
welcomeMessage: {
|
welcomeMessage: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|
Loading…
Reference in New Issue