(opts: SelectOptions<T>)
| 21 | } |
| 22 | |
| 23 | constructor(opts: SelectOptions<T>) { |
| 24 | super(opts, false); |
| 25 | |
| 26 | this.options = opts.options; |
| 27 | |
| 28 | const initialCursor = this.options.findIndex(({ value }) => value === opts.initialValue); |
| 29 | const cursor = initialCursor === -1 ? 0 : initialCursor; |
| 30 | this.cursor = this.options[cursor].disabled ? findCursor<T>(cursor, 1, this.options) : cursor; |
| 31 | this.changeValue(); |
| 32 | |
| 33 | this.on('cursor', (key) => { |
| 34 | switch (key) { |
| 35 | case 'left': |
| 36 | case 'up': |
| 37 | this.cursor = findCursor<T>(this.cursor, -1, this.options); |
| 38 | break; |
| 39 | case 'down': |
| 40 | case 'right': |
| 41 | this.cursor = findCursor<T>(this.cursor, 1, this.options); |
| 42 | break; |
| 43 | } |
| 44 | this.changeValue(); |
| 45 | }); |
| 46 | } |
| 47 | } |
nothing calls this directly
no test coverage detected