@kud/ink-ui 0.16.0 → 0.17.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/AGENTS.md CHANGED
@@ -13,7 +13,7 @@ because it tells you a component is missing when it is not.
13
13
 
14
14
  **Before writing any component, check it isn't already here.** Bordered panes,
15
15
  scrolling viewports, selectable rows, tables, tab bars, spinners, progress
16
- bars, key/value pairs, badges and footer key hints are all provided. A
16
+ bars, key/value pairs, badges, pills and footer key hints are all provided. A
17
17
  hand-rolled version of one of these is the single most common mistake in a
18
18
  consuming repo.
19
19
 
@@ -56,6 +56,7 @@ differently on every screen.
56
56
  | Pick one / pick many from a list | `Select` / `MultiSelect` — these own their keyboard, unlike `SelectableRow` |
57
57
  | A persistent key-hints footer | `FooterHints` with `Hint` tuples: `[["↑↓", "move"], ["q", "quit"]]` |
58
58
  | Label/value detail rows | `KeyValue` with a shared `labelWidth` so values align |
59
+ | A category label — `epic`, `draft` — that should read as one object | `Pill`, filled and rounded; `Badge` for the bracket form. Never for a reference the reader follows |
59
60
  | Transient feedback | `StatusMessage` (inline) · `Alert` (boxed, with title) · `Toast` (self-dismissing) |
60
61
  | App chrome | `Banner` at the top, `Header` per section, `LoadingScreen` while booting |
61
62
 
package/dist/index.d.ts CHANGED
@@ -15,6 +15,46 @@ type BadgeProps = {
15
15
  };
16
16
  declare const Badge: ({ children, variant }: BadgeProps) => React__default.JSX.Element;
17
17
 
18
+ type PillVariant = "success" | "error" | "warning" | "info" | "accent" | "muted";
19
+ type PillProps = {
20
+ children: string;
21
+ variant?: PillVariant;
22
+ };
23
+ /**
24
+ * A filled, rounded label — a category the thing belongs to, not a status it is
25
+ * in.
26
+ *
27
+ * Reach for it when the word IS the information (`epic`, `draft`, `blocked`) and
28
+ * you want it to read as one object rather than as more prose. For a reference
29
+ * the reader is meant to follow — a ticket key, a repo — leave the text dim: a
30
+ * fill gives a breadcrumb a weight it has not earned, and once everything is a
31
+ * pill none of them is.
32
+ *
33
+ * The WORD carries the meaning and the colour only reinforces it, so a pill
34
+ * survives being read in monochrome, piped, or by someone who cannot separate
35
+ * the hues.
36
+ *
37
+ * Powerline half-circles, like `ToggleSwitch` and for the same reason: they are
38
+ * the only way to get a genuinely rounded end out of a terminal cell, and a font
39
+ * without them renders blanks, which degrades to a square pill rather than
40
+ * breaking the layout. Not gated on `getIconMode` — that switch chooses between
41
+ * two glyph SETS, and this is one glyph with a graceful absence.
42
+ *
43
+ * `NO_COLOR` is the one case that does fall back to brackets: with the fill
44
+ * stripped, the caps would be drawing the outline of a pill that is not there.
45
+ */
46
+ declare const Pill: ({ children, variant }: PillProps) => React__default.JSX.Element;
47
+ /**
48
+ * How many columns `<Pill>` occupies for `text` — the label plus its two caps.
49
+ *
50
+ * Exported because a caller laying out a fixed-width row has to price the pill
51
+ * BEFORE rendering it, and measuring the rendered output is not available at
52
+ * that point. A row that budgets for the label alone overflows by exactly two
53
+ * columns, which in a frame sized to fill the terminal scrolls the whole panel
54
+ * instead of clipping.
55
+ */
56
+ declare const pillWidth: (text: string) => number;
57
+
18
58
  type HeaderProps = {
19
59
  children: string;
20
60
  subtitle?: string;
@@ -321,4 +361,4 @@ declare const spacing: {
321
361
  };
322
362
  type Spacing = (typeof spacing)[keyof typeof spacing];
323
363
 
324
- export { Alert, Badge, type BadgeVariant, Banner, type Color, type Column, type ColumnAlign, type ColumnOverflow, Columns, ConfirmInput, EmailInput, FooterHints, Header, type Hint, type IconMode, KeyValue, LoadingScreen, MultiSelect, type NotifyOptions, OrderedList, Panel, PasswordInput, ProgressBar, ScrollView, Select, type SelectOption, SelectableRow, type Spacing, type Span, Spinner, StatusMessage, type StatusVariant, type StyledLine, Switch, type SwitchValue, type TabItem, Table, Tabs, TextInput, Toast, Toggle, ToggleSwitch, UnorderedList, UpdateBanner, colors, getIconMode, notify, setIconMode, spacing, useListCursor, useTabs };
364
+ export { Alert, Badge, type BadgeVariant, Banner, type Color, type Column, type ColumnAlign, type ColumnOverflow, Columns, ConfirmInput, EmailInput, FooterHints, Header, type Hint, type IconMode, KeyValue, LoadingScreen, MultiSelect, type NotifyOptions, OrderedList, Panel, PasswordInput, Pill, type PillVariant, ProgressBar, ScrollView, Select, type SelectOption, SelectableRow, type Spacing, type Span, Spinner, StatusMessage, type StatusVariant, type StyledLine, Switch, type SwitchValue, type TabItem, Table, Tabs, TextInput, Toast, Toggle, ToggleSwitch, UnorderedList, UpdateBanner, colors, getIconMode, notify, pillWidth, setIconMode, spacing, useListCursor, useTabs };
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Box, Text, useStdout, useInput, measureElement } from 'ink';
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { glyphs } from '@kud/glyphs';
3
4
  import React8, { createContext, useContext, useState, useEffect, useRef, useLayoutEffect } from 'react';
4
5
  import cliSpinners from 'cli-spinners';
5
6
  import stringWidth from 'string-width';
6
- import { glyphs } from '@kud/glyphs';
7
7
  import { spawn } from 'child_process';
8
8
 
9
9
  // src/components/Banner.tsx
@@ -39,6 +39,36 @@ var Badge = ({ children, variant = "info" }) => /* @__PURE__ */ jsxs(Text, { col
39
39
  children,
40
40
  "]"
41
41
  ] });
42
+ var FILL = {
43
+ success: colors.success,
44
+ error: colors.error,
45
+ warning: colors.warning,
46
+ info: colors.info,
47
+ accent: colors.accent,
48
+ muted: colors.muted
49
+ };
50
+ var INK = {
51
+ success: "black",
52
+ error: "white",
53
+ warning: "black",
54
+ info: "black",
55
+ accent: "black",
56
+ muted: "white"
57
+ };
58
+ var Pill = ({ children, variant = "muted" }) => {
59
+ const fill = FILL[variant];
60
+ if (process.env["NO_COLOR"]) return /* @__PURE__ */ jsxs(Text, { color: fill, children: [
61
+ "[",
62
+ children,
63
+ "]"
64
+ ] });
65
+ return /* @__PURE__ */ jsxs(Text, { children: [
66
+ /* @__PURE__ */ jsx(Text, { color: fill, children: glyphs.plCapLeft }),
67
+ /* @__PURE__ */ jsx(Text, { backgroundColor: fill, color: INK[variant], children }),
68
+ /* @__PURE__ */ jsx(Text, { color: fill, children: glyphs.plCapRight })
69
+ ] });
70
+ };
71
+ var pillWidth = (text) => text.length + 2;
42
72
  var Header = ({ children, subtitle }) => /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
43
73
  /* @__PURE__ */ jsx(Text, { bold: true, underline: true, children }),
44
74
  subtitle && /* @__PURE__ */ jsx(Text, { dimColor: true, children: subtitle })
@@ -893,4 +923,4 @@ var notify = (message, options = {}) => {
893
923
  child.unref();
894
924
  };
895
925
 
896
- export { Alert, Badge, Banner, Columns, ConfirmInput, EmailInput, FooterHints, Header, KeyValue, LoadingScreen, MultiSelect, OrderedList, Panel, PasswordInput, ProgressBar, ScrollView, Select, SelectableRow, Spinner, StatusMessage, Switch, Table, Tabs, TextInput, Toast, Toggle, ToggleSwitch, UnorderedList, UpdateBanner, colors, getIconMode, notify, setIconMode, spacing, useListCursor, useTabs };
926
+ export { Alert, Badge, Banner, Columns, ConfirmInput, EmailInput, FooterHints, Header, KeyValue, LoadingScreen, MultiSelect, OrderedList, Panel, PasswordInput, Pill, ProgressBar, ScrollView, Select, SelectableRow, Spinner, StatusMessage, Switch, Table, Tabs, TextInput, Toast, Toggle, ToggleSwitch, UnorderedList, UpdateBanner, colors, getIconMode, notify, pillWidth, setIconMode, spacing, useListCursor, useTabs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kud/ink-ui",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "React component library for Ink CLIs",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",