@kud/ink-ui 0.18.0 → 0.19.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/index.d.ts +18 -0
- package/dist/index.js +16 -11
- package/package.json +1 -1
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,26 @@ 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 widthOf = (cell) => [...cell.marker].length + [...cell.text].length;
|
|
663
666
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
664
|
-
/* @__PURE__ */ jsx(Box, { gap: 2, children: cells.map((cell) => /* @__PURE__ */
|
|
665
|
-
Text,
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
667
|
+
/* @__PURE__ */ jsx(Box, { gap: 2, children: cells.map((cell) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
668
|
+
cell.marker ? /* @__PURE__ */ jsx(Text, { color: cell.markerColor, children: cell.marker }) : null,
|
|
669
|
+
/* @__PURE__ */ jsx(
|
|
670
|
+
Text,
|
|
671
|
+
{
|
|
672
|
+
bold: cell.isActive,
|
|
673
|
+
color: cell.isActive ? colors.accent : void 0,
|
|
674
|
+
dimColor: !cell.isActive,
|
|
675
|
+
children: cell.text
|
|
676
|
+
}
|
|
677
|
+
)
|
|
678
|
+
] }, cell.key)) }),
|
|
679
|
+
/* @__PURE__ */ jsx(Box, { gap: 2, children: cells.map((cell) => /* @__PURE__ */ jsx(Text, { color: colors.accent, children: (cell.isActive ? "\u2500" : " ").repeat(widthOf(cell)) }, cell.key)) })
|
|
675
680
|
] });
|
|
676
681
|
};
|
|
677
682
|
var useTabs = (items, { initial, isActive = true } = {}) => {
|