@nbtca/prompt 1.5.7 → 1.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,7 +44,7 @@ export class ListField {
44
44
  const maxVisible = this.maxVisible;
45
45
  if (!maxVisible || options.length <= maxVisible) {
46
46
  return renderMenu({
47
- title,
47
+ ...(title === undefined ? {} : { title }),
48
48
  options,
49
49
  selectedIndex: this.index,
50
50
  ...(footer === undefined ? {} : { footer }),
@@ -52,7 +52,7 @@ export class ListField {
52
52
  }
53
53
  const visible = options.slice(this.scrollTop, this.scrollTop + maxVisible);
54
54
  const lines = renderMenu({
55
- title,
55
+ ...(title === undefined ? {} : { title }),
56
56
  options: visible,
57
57
  selectedIndex: this.index - this.scrollTop,
58
58
  }, cols).split('\n');
@@ -80,12 +80,16 @@ export class ListField {
80
80
  const labelWidth = options.reduce((width, option) => Math.max(width, visualWidth(option.label)), 0);
81
81
  const optionGroups = options.map((option, index) => renderMenuOption(option, index === this.index, labelWidth, cols));
82
82
  const selectedLines = optionGroups[this.index] ?? [];
83
- const titleValue = options.length > 1
84
- ? `${type.heading(title)}${type.hint(` ${this.index + 1}/${options.length}`)}`
85
- : type.heading(title);
83
+ const titleValue = !title
84
+ ? ''
85
+ : options.length > 1
86
+ ? `${type.heading(title)}${type.hint(` ${this.index + 1}/${options.length}`)}`
87
+ : type.heading(title);
86
88
  const titleLines = title ? renderIndentedOutput(titleValue, cols) : [];
87
89
  let header = [];
88
- if (titleLines.length + 1 + selectedLines.length <= maxRows)
90
+ if (titleLines.length === 0)
91
+ header = [];
92
+ else if (titleLines.length + 1 + selectedLines.length <= maxRows)
89
93
  header = [...titleLines, ''];
90
94
  else if (titleLines.length + selectedLines.length <= maxRows)
91
95
  header = titleLines;
@@ -92,10 +92,8 @@ function goToLoginId(errorMessage) {
92
92
  };
93
93
  }
94
94
  function buildPublicField() {
95
- const trans = t();
96
95
  return new ListField({
97
- title: trans.timetable.menuEntry,
98
- options: [{ value: 'login', label: trans.timetable.publicLoginAction }],
96
+ options: [{ value: 'login', label: t().timetable.publicLoginAction }],
99
97
  });
100
98
  }
101
99
  async function goToPublic(ctx, generation = lifecycleGeneration) {
@@ -87,8 +87,7 @@ export function renderMenuOption(option, selected, labelWidth = visualWidth(opti
87
87
  }
88
88
  export function renderMenu(state, cols = Number.POSITIVE_INFINITY) {
89
89
  const labelWidth = state.options.reduce((width, option) => Math.max(width, visualWidth(option.label)), 0);
90
- const lines = renderIndentedText(state.title, cols, type.heading);
91
- lines.push('');
90
+ const lines = state.title ? [...renderIndentedText(state.title, cols, type.heading), ''] : [];
92
91
  state.options.forEach((option, index) => {
93
92
  lines.push(...renderMenuOption(option, index === state.selectedIndex, labelWidth, cols));
94
93
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nbtca/prompt",
3
- "version": "1.5.7",
3
+ "version": "1.5.8",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "exports": {