@nmakarov/cli-toolkit 0.68.0 → 0.69.0

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.
package/dist/init.js CHANGED
@@ -978,7 +978,7 @@ function scrollbarGlyphs(viewportRows, totalLines, scrollTop) {
978
978
  const thumbStart = maxScroll === 0 ? 0 : Math.round(s / maxScroll * travel);
979
979
  const glyphs = [];
980
980
  for (let i = 0; i < view; i++) {
981
- glyphs.push(i >= thumbStart && i < thumbStart + thumbSize ? "\u2588" : "\u2502");
981
+ glyphs.push(i >= thumbStart && i < thumbStart + thumbSize ? BAR_THUMB : BAR_TRACK);
982
982
  }
983
983
  return glyphs;
984
984
  }
@@ -1000,20 +1000,19 @@ function ScrollableText({
1000
1000
  }) {
1001
1001
  const [scrollTop, setScrollTop] = useState3(0);
1002
1002
  const [, bump] = useState3(0);
1003
- const termCols = process.stdout.columns || 80;
1004
1003
  const termRows = process.stdout.rows || 24;
1005
1004
  const viewportRows = Math.max(
1006
1005
  4,
1007
1006
  maxHeight != null ? Math.floor(maxHeight) : Math.max(8, termRows - 8)
1008
1007
  );
1009
- const provisionalBar = showScrollbar ? 1 : 0;
1010
- const wrapCols = Math.max(8, termCols - provisionalBar);
1008
+ const contentCols = Math.max(20, getScreenWidth() - 4);
1009
+ const barCols = showScrollbar ? 1 : 0;
1010
+ const textWidth = Math.max(8, contentCols - barCols);
1011
1011
  const allLines = useMemo(() => {
1012
1012
  if (Array.isArray(linesProp)) return linesProp.map((l) => String(l ?? ""));
1013
- return wrap ? wrapTextLines(text, wrapCols) : String(text ?? "").split("\n");
1014
- }, [linesProp, text, wrap, wrapCols]);
1013
+ return wrap ? wrapTextLines(text, textWidth) : String(text ?? "").split("\n");
1014
+ }, [linesProp, text, wrap, textWidth]);
1015
1015
  const needsBar = showScrollbar && allLines.length > viewportRows;
1016
- const textWidth = Math.max(8, termCols - (needsBar ? 1 : 0));
1017
1016
  const maxScroll = Math.max(0, allLines.length - viewportRows);
1018
1017
  const clamped = Math.min(Math.max(0, scrollTop), maxScroll);
1019
1018
  const visible = allLines.slice(clamped, clamped + viewportRows);
@@ -1053,22 +1052,24 @@ function ScrollableText({
1053
1052
  const status = allLines.length === 0 ? "empty" : `lines ${clamped + 1}-${Math.min(clamped + visible.length, allLines.length)} of ${allLines.length}` + (needsBar ? " \xB7 \u2325\u2191/\u2193 or PgUp/Dn page" : "");
1054
1053
  const rowNodes = visible.map((line, i) => {
1055
1054
  const body = padEndVisible(line, textWidth);
1056
- const glyph = bar ? bar[i] ?? "\u2502" : "";
1055
+ const glyph = bar ? bar[i] ?? BAR_TRACK : showScrollbar ? " " : "";
1056
+ const isThumb = glyph === BAR_THUMB;
1057
1057
  return h5(
1058
- Box4,
1059
- { key: `L${clamped + i}`, flexDirection: "row" },
1060
- h5(Text5, {}, body),
1061
- glyph ? h5(Text5, { color: bar[i] === "\u2588" ? "cyan" : "gray" }, glyph) : null
1058
+ Text5,
1059
+ { key: `L${clamped + i}` },
1060
+ body,
1061
+ glyph ? h5(Text5, { color: isThumb ? "cyan" : "gray" }, glyph) : null
1062
1062
  );
1063
1063
  });
1064
1064
  if (bar && visible.length < viewportRows) {
1065
1065
  for (let i = visible.length; i < viewportRows; i++) {
1066
+ const glyph = bar[i] ?? BAR_TRACK;
1066
1067
  rowNodes.push(
1067
1068
  h5(
1068
- Box4,
1069
- { key: `pad${i}`, flexDirection: "row" },
1070
- h5(Text5, {}, padEndVisible("", textWidth)),
1071
- h5(Text5, { color: bar[i] === "\u2588" ? "cyan" : "gray" }, bar[i] ?? "\u2502")
1069
+ Text5,
1070
+ { key: `pad${i}` },
1071
+ padEndVisible("", textWidth),
1072
+ h5(Text5, { color: glyph === BAR_THUMB ? "cyan" : "gray" }, glyph)
1072
1073
  )
1073
1074
  );
1074
1075
  }
@@ -1081,10 +1082,13 @@ function ScrollableText({
1081
1082
  ...rowNodes
1082
1083
  );
1083
1084
  }
1084
- var h5, SCROLL_KEYS;
1085
+ var h5, BAR_THUMB, BAR_TRACK, SCROLL_KEYS;
1085
1086
  var init_scrollable_text = __esm({
1086
1087
  "src/screen/scrollable-text.js"() {
1088
+ init_components();
1087
1089
  h5 = createElement2;
1090
+ BAR_THUMB = "#";
1091
+ BAR_TRACK = "|";
1088
1092
  SCROLL_KEYS = [
1089
1093
  { key: "upArrow", caption: "scroll", action: "scrollUp", order: 0 },
1090
1094
  { key: "downArrow", caption: "scroll", action: "scrollDown", order: 0 },