enquirer
Advanced tools
Comparing version 2.0.5 to 2.0.6
@@ -77,3 +77,3 @@ 'use strict'; | ||
} else if (!this.skipChoice(choice)) { | ||
} else if (!this.isDisabled(choice)) { | ||
val[choice.name] = choice.enabled === true; | ||
@@ -80,0 +80,0 @@ } |
@@ -10,3 +10,3 @@ 'use strict'; | ||
this.pos = { h: 0, get v() { return this.index; } }; | ||
this.term = process.TERM_PROGRAM; | ||
this.term = process.env.TERM_PROGRAM; | ||
@@ -78,6 +78,7 @@ if (!this.options.header) { | ||
let focused = this.index === i; | ||
let n = this.term !== 'Hyper' ? 9 : 8; | ||
let s = this.term !== 'Hyper' ? '' : ' '; | ||
let isHyper = this.term === 'Hyper'; | ||
let n = !isHyper ? 8 : 9; | ||
let s = !isHyper ? ' ' : ''; | ||
let ln = this.symbols.line.repeat(n); | ||
let sp = ' '.repeat(9); | ||
let sp = ' '.repeat(n + (isHyper ? 0 : 1)); | ||
let dot = enabled => (enabled ? this.styles.success('◉') : '◯') + s; | ||
@@ -84,0 +85,0 @@ |
@@ -5,3 +5,2 @@ 'use strict'; | ||
const symbols = require('./symbols'); | ||
const transform = require('./transform'); | ||
const utils = require('./utils'); | ||
@@ -11,5 +10,4 @@ | ||
prompt.options = utils.merge({}, prompt.options.theme, prompt.options); | ||
prompt.transform = transform.merge(prompt.options); | ||
prompt.symbols = symbols.merge(prompt.options); | ||
prompt.styles = styles.merge(prompt.options); | ||
}; |
@@ -14,3 +14,3 @@ 'use strict'; | ||
this.initial = options.initial || 0; | ||
this.delay = options.delay || 250; | ||
this.delay = options.delay || 0; | ||
this.longest = 0; | ||
@@ -108,3 +108,3 @@ this.num = ''; | ||
ele.path = parent ? parent.path + '.' + ele.name : ele.name; | ||
ele.enabled = !!(this.multiple && !this.skipChoice(ele) && (ele.enabled || this.isSelected(ele))); | ||
ele.enabled = !!(this.multiple && !this.isDisabled(ele) && (ele.enabled || this.isSelected(ele))); | ||
@@ -115,3 +115,3 @@ if (typeof ele.initial === 'function') { | ||
if (!this.skipChoice(ele)) { | ||
if (!this.isDisabled(ele)) { | ||
this.longest = Math.max(this.longest, colors.unstyle(ele.message).length); | ||
@@ -150,3 +150,3 @@ } | ||
this.index = choice.index; | ||
choice.enabled = enabled && !this.skipChoice(choice); | ||
choice.enabled = enabled && !this.isDisabled(choice); | ||
return choice; | ||
@@ -162,3 +162,3 @@ } | ||
a() { | ||
let choices = this.choices.filter(ch => !this.skipChoice(ch)); | ||
let choices = this.choices.filter(ch => !this.isDisabled(ch)); | ||
let enabled = choices.every(ch => ch.enabled); | ||
@@ -190,3 +190,3 @@ this.choices.forEach(ch => (ch.enabled = !enabled)); | ||
while (parent) { | ||
let choices = parent.choices.filter(ch => this.skipChoice(ch)); | ||
let choices = parent.choices.filter(ch => this.isDisabled(ch)); | ||
parent.enabled = choices.every(ch => ch.enabled); | ||
@@ -201,3 +201,3 @@ parent = parent.parent; | ||
enable(choice) { | ||
choice.enabled = !this.skipChoice(choice); | ||
choice.enabled = !this.isDisabled(choice); | ||
choice.choices && choice.choices.forEach(ch => this.enable(ch)); | ||
@@ -320,3 +320,3 @@ return choice; | ||
this.index = ((this.index - 1 % len) + len) % len; | ||
if (this.skipChoice()) { | ||
if (this.isDisabled()) { | ||
return this.up(); | ||
@@ -334,3 +334,3 @@ } | ||
this.index = (this.index + 1) % len; | ||
if (this.skipChoice()) { | ||
if (this.isDisabled()) { | ||
return this.down(); | ||
@@ -344,3 +344,3 @@ } | ||
this.index = i; | ||
if (this.skipChoice()) { | ||
if (this.isDisabled()) { | ||
return this.up(); | ||
@@ -354,3 +354,3 @@ } | ||
this.index = i; | ||
if (this.skipChoice()) { | ||
if (this.isDisabled()) { | ||
return this.down(); | ||
@@ -382,3 +382,3 @@ } | ||
this._limit = this.limit; | ||
if (this.skipChoice()) { | ||
if (this.isDisabled()) { | ||
return this.up(); | ||
@@ -394,3 +394,3 @@ } | ||
this._limit = this.limit; | ||
if (this.skipChoice()) { | ||
if (this.isDisabled()) { | ||
return this.down(); | ||
@@ -405,3 +405,3 @@ } | ||
skipChoice(choice = this.focused) { | ||
isDisabled(choice = this.focused) { | ||
if (choice) { | ||
@@ -415,6 +415,6 @@ return choice.disabled || choice.collapsed || choice.hidden || choice.completing; | ||
if (choice.choices) { | ||
let choices = choice.choices.filter(ch => !this.skipChoice(ch)); | ||
let choices = choice.choices.filter(ch => !this.isDisabled(ch)); | ||
return choice.enabled && choices.every(ch => this.isEnabled(ch)); | ||
} | ||
return choice.enabled && !this.skipChoice(choice); | ||
return choice.enabled && !this.isDisabled(choice); | ||
} | ||
@@ -497,4 +497,4 @@ | ||
if (!this.setInitial && this.options.initial) { | ||
this.setInitial = true; | ||
if (!this._initial && this.options.initial) { | ||
this._initial = true; | ||
let init = this.initial; | ||
@@ -556,6 +556,6 @@ if (typeof init === 'string' || typeof init === 'number') { | ||
if (choice.choices) { | ||
let items = choice.choices.filter(ch => !prompt.skipChoice(ch)); | ||
let items = choice.choices.filter(ch => !prompt.isDisabled(ch)); | ||
choice.enabled = items.every(ch => ch.enabled === true); | ||
} | ||
if (prompt.skipChoice(choice) === true) { | ||
if (prompt.isDisabled(choice) === true) { | ||
choice.enabled = false; | ||
@@ -562,0 +562,0 @@ } |
{ | ||
"name": "enquirer", | ||
"description": "Stylish, intuitive and user-friendly prompt system. Fast and lightweight enough for small projects, powerful and extensible enough for the most advanced use cases.", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"homepage": "https://github.com/enquirer/enquirer", | ||
@@ -6,0 +6,0 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", |
@@ -612,3 +612,3 @@ <h1 align="center">Enquirer</h1> | ||
super(options); | ||
this.value = options.sprays || 0; | ||
this.value = options.initial || 0; | ||
this.cursorHide(); | ||
@@ -850,2 +850,2 @@ } | ||
Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT License](LICENSE). | ||
Released under the [MIT License](LICENSE). |
850
148884
43
3110
2