@kud/ink-ui 0.18.0 → 0.19.1

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/index.d.ts CHANGED
@@ -249,6 +249,24 @@ type TabItem<T extends string = string> = {
249
249
  value: T;
250
250
  label: string;
251
251
  count?: number;
252
+ /**
253
+ * A marker drawn immediately before the label, in its own colour.
254
+ *
255
+ * Give every tab one of the SAME WIDTH, or none at all. A marker that appears
256
+ * on one tab alone pushes every tab after it sideways — which is the whole
257
+ * reason this is a field rather than something a caller prepends to `label`:
258
+ * a bar that shifts when news arrives is a bar you have to re-find. A blank of
259
+ * the right width is how you say "not this one".
260
+ *
261
+ * Its own `Text` because the label's colour answers "is this tab active" and a
262
+ * marker usually answers something else; folded together, the marker would
263
+ * have to borrow the answer to the wrong question.
264
+ *
265
+ * Animating one costs nothing: the cell is already reserved, so a caller
266
+ * cycling the glyph or the colour per frame moves no layout at all.
267
+ */
268
+ marker?: string;
269
+ markerColor?: string;
252
270
  };
253
271
  type TabsProps<T extends string> = {
254
272
  active: T;
package/dist/index.js CHANGED
@@ -657,21 +657,27 @@ var ScrollView = ({
657
657
  var Tabs = ({ active, items }) => {
658
658
  const cells = items.map((item) => ({
659
659
  key: item.value,
660
+ marker: item.marker ?? "",
661
+ markerColor: item.markerColor,
660
662
  text: item.count !== void 0 ? `${item.label} (${item.count})` : item.label,
661
663
  isActive: item.value === active
662
664
  }));
665
+ const gutterOf = (cell) => [...cell.marker].length;
666
+ const labelOf = (cell) => [...cell.text].length;
663
667
  return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
664
- /* @__PURE__ */ jsx(Box, { gap: 2, children: cells.map((cell) => /* @__PURE__ */ jsx(
665
- Text,
666
- {
667
- bold: cell.isActive,
668
- color: cell.isActive ? colors.accent : void 0,
669
- dimColor: !cell.isActive,
670
- children: cell.text
671
- },
672
- cell.key
673
- )) }),
674
- /* @__PURE__ */ jsx(Box, { gap: 2, children: cells.map((cell) => /* @__PURE__ */ jsx(Text, { color: colors.accent, children: cell.isActive ? "\u2500".repeat(cell.text.length) : " ".repeat(cell.text.length) }, cell.key)) })
668
+ /* @__PURE__ */ jsx(Box, { gap: 2, children: cells.map((cell) => /* @__PURE__ */ jsxs(Box, { children: [
669
+ cell.marker ? /* @__PURE__ */ jsx(Text, { color: cell.markerColor, children: cell.marker }) : null,
670
+ /* @__PURE__ */ jsx(
671
+ Text,
672
+ {
673
+ bold: cell.isActive,
674
+ color: cell.isActive ? colors.accent : void 0,
675
+ dimColor: !cell.isActive,
676
+ children: cell.text
677
+ }
678
+ )
679
+ ] }, cell.key)) }),
680
+ /* @__PURE__ */ jsx(Box, { gap: 2, children: cells.map((cell) => /* @__PURE__ */ jsx(Text, { color: colors.accent, children: " ".repeat(gutterOf(cell)) + (cell.isActive ? "\u2500" : " ").repeat(labelOf(cell)) }, cell.key)) })
675
681
  ] });
676
682
  };
677
683
  var useTabs = (items, { initial, isActive = true } = {}) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kud/ink-ui",
3
- "version": "0.18.0",
3
+ "version": "0.19.1",
4
4
  "description": "React component library for Ink CLIs",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",