1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.formatTypeaheadSelection = exports.printTypeaheadItem = exports.printMore = exports.printStartTyping = exports.printPatternMatches = void 0;
|
7 |
|
8 | var _chalk = _interopRequireDefault(require("chalk"));
|
9 |
|
10 | var _stripAnsi = _interopRequireDefault(require("strip-ansi"));
|
11 |
|
12 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13 |
|
14 | const pluralize = (count, text) => count === 1 ? text : `${text}s`;
|
15 |
|
16 | const printPatternMatches = (count, entity, pipe, extraText = '') => {
|
17 | const pluralized = pluralize(count, entity);
|
18 | const result = count ? `\n\n Pattern matches ${count} ${pluralized}` : `\n\n Pattern matches no ${pluralized}`;
|
19 | pipe.write(result + extraText);
|
20 | };
|
21 |
|
22 | exports.printPatternMatches = printPatternMatches;
|
23 |
|
24 | const printStartTyping = (entity, pipe) => {
|
25 | pipe.write(`\n\n ${_chalk.default.italic.yellow(`Start typing to filter by a ${entity} regex pattern.`)}`);
|
26 | };
|
27 |
|
28 | exports.printStartTyping = printStartTyping;
|
29 |
|
30 | const printMore = (entity, pipe, more) => {
|
31 | pipe.write(`\n ${_chalk.default.dim(`...and ${more} more ${pluralize(more, entity)}`)}`);
|
32 | };
|
33 |
|
34 | exports.printMore = printMore;
|
35 |
|
36 | const printTypeaheadItem = (item, pipe) => {
|
37 | pipe.write(`\n ${_chalk.default.dim('\u203A')} ${item}`);
|
38 | };
|
39 |
|
40 | exports.printTypeaheadItem = printTypeaheadItem;
|
41 |
|
42 | const formatTypeaheadSelection = (item, index, activeIndex, prompt) => {
|
43 | if (index === activeIndex) {
|
44 | prompt.setPromptSelection((0, _stripAnsi.default)(item));
|
45 | return _chalk.default.black.bgYellow((0, _stripAnsi.default)(item));
|
46 | }
|
47 |
|
48 | return item;
|
49 | };
|
50 |
|
51 | exports.formatTypeaheadSelection = formatTypeaheadSelection; |
\ | No newline at end of file |