blessed-tab-container
Version:
A CLI Multi-Tab Container Utilizing Labels For Blessed
131 lines (89 loc) • 3.47 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>tab_container/index.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav >
<input type="text" id="nav-search" placeholder="Search" />
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#BlessedTabContainer">BlessedTabContainer</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">tab_container/index.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>'use strict'
const _isEmpty = require('lodash/isEmpty')
const initTabs = require('./util/init_tabs')
const parseArgs = require('./args/parse')
const validateArgs = require('./args/validate')
const updateLabels = require('./util/update_labels')
const genContainerAPI = require('./api/gen_container')
require('../types/blessed_tab_container_args')
require('../types/blessed_tab_container')
/**
* Merges multiple elements into the same position on the screen, while only
* enabling visiblity for one at a time depending on the active tab.
*
* Renders tabs in different styles depending on if they are visible, hidden, or
* hidden and modified (dirty).
*
* Dirty flags are automatically cleared when tabs are opened, and set when they
* are updated in the background, unless the `autoDirty` flag is explicity set
* to `false` for that individual tab.
*
* A basic API is exposed on both the individual tab elements themselves, and
* on the root tabbed container element.
*
* @see BlessedTabContainerAPI
* @see BlessedTabContainerTabAPI
*
* @param {BlessedTabContainerArgs} options - tab container options
* @return {BlessedTabContainer}
*/
const BlessedTabContainer = (options = {}) => {
const config = parseArgs(options)
const validationError = validateArgs(config)
if (!_isEmpty(validationError)) {
throw new Error(validationError)
}
const { screen } = config
const visible = config.defaultVisible || (
(config.tabs[0] || {}).label || ''
)
const state = { config, visible, screen }
state.tabs = initTabs(state)
Object.assign(state, genContainerAPI(state))
updateLabels(state)
return state
}
module.exports = BlessedTabContainer
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Tue Mar 31 2020 19:20:06 GMT+0700 (Indochina Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>
<script src="scripts/search.js" defer></script>
</body>
</html>