.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / enquirer / lib / prompts / sort.js
1 'use strict';
2
3 const hint = '(Use <shift>+<up/down> to sort)';
4 const Prompt = require('./select');
5
6 class Sort extends Prompt {
7   constructor(options) {
8     super({ ...options, reorder: false, sort: true, multiple: true });
9     this.state.hint = [this.options.hint, hint].find(this.isValue.bind(this));
10   }
11
12   indicator() {
13     return '';
14   }
15
16   async renderChoice(choice, i) {
17     let str = await super.renderChoice(choice, i);
18     let sym = this.symbols.identicalTo + ' ';
19     let pre = (this.index === i && this.sorting) ? this.styles.muted(sym) : '  ';
20     if (this.options.drag === false) pre = '';
21     if (this.options.numbered === true) {
22       return pre + `${i + 1} - ` + str;
23     }
24     return pre + str;
25   }
26
27   get selected() {
28     return this.choices;
29   }
30
31   submit() {
32     this.value = this.choices.map(choice => choice.value);
33     return super.submit();
34   }
35 }
36
37 module.exports = Sort;