3 const StringPrompt = require('../types/string');
5 class ListPrompt extends StringPrompt {
6 constructor(options = {}) {
8 this.sep = this.options.separator || /, */;
9 this.initial = options.initial || '';
12 split(input = this.value) {
13 return input ? String(input).split(this.sep) : [];
17 let style = this.state.submitted ? this.styles.primary : val => val;
18 return this.list.map(style).join(', ');
22 let result = this.state.error || await this.validate(this.list, this.state);
23 if (result !== true) {
24 this.state.error = result;
25 return super.submit();
27 this.value = this.list;
28 return super.submit();
36 module.exports = ListPrompt;