@kud/ink-ui 0.9.0 → 0.10.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/README.md +2 -2
- package/dist/index.d.ts +1 -12
- package/dist/index.js +7 -31
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
|
|
14
14
|
## Features
|
|
15
15
|
|
|
16
|
-
- **
|
|
16
|
+
- **27 ready-made components**, pre-styled and ready to drop in:
|
|
17
17
|
- **Inputs** — `TextInput`, `EmailInput` (domain completion), `PasswordInput` (masked), `ConfirmInput`
|
|
18
18
|
- **Lists** — `UnorderedList`, `OrderedList` (both nestable), `Table`
|
|
19
19
|
- **Selection & navigation** — `Select`, `MultiSelect`, `Tabs`, `Switch`, `Toggle`, `SelectableRow`
|
|
20
20
|
- **Status & feedback** — `Spinner`, `ProgressBar`, `StatusMessage`, `Alert`, `Badge`, `Toast`
|
|
21
|
-
- **Layout & chrome** — `Banner`, `Header`, `FooterHints`, `KeyValue`, `LoadingScreen`, `ScrollView`
|
|
21
|
+
- **Layout & chrome** — `Banner`, `Header`, `Panel` (bordered pane, optional focus state), `Columns`, `FooterHints`, `KeyValue`, `LoadingScreen`, `ScrollView`
|
|
22
22
|
- **Full [@inkjs/ui](https://github.com/vadimdemedes/ink-ui) parity** — every upstream component has an equivalent, plus a dozen more the design system adds on top
|
|
23
23
|
- **Colourblind-safe by design** — state is signalled by shape, case, and glyph, never colour alone
|
|
24
24
|
- **Design tokens included** — a shared colour palette (`colors`) and spacing scale (`spacing`) to keep every screen consistent
|
package/dist/index.d.ts
CHANGED
|
@@ -54,17 +54,6 @@ type LoadingScreenProps = {
|
|
|
54
54
|
};
|
|
55
55
|
declare const LoadingScreen: ({ label }: LoadingScreenProps) => React.JSX.Element;
|
|
56
56
|
|
|
57
|
-
type ScreenProps = {
|
|
58
|
-
children: ReactNode;
|
|
59
|
-
/**
|
|
60
|
-
* Enter the terminal's alternate buffer so the app owns the whole screen and
|
|
61
|
-
* the previous scrollback is restored on exit. Defaults to true. Set false to
|
|
62
|
-
* render full-height inline instead.
|
|
63
|
-
*/
|
|
64
|
-
altScreen?: boolean;
|
|
65
|
-
};
|
|
66
|
-
declare const Screen: ({ children, altScreen }: ScreenProps) => React.JSX.Element;
|
|
67
|
-
|
|
68
57
|
type PanelProps = {
|
|
69
58
|
/** Optional title shown in the panel's header row. */
|
|
70
59
|
title?: string;
|
|
@@ -280,4 +269,4 @@ declare const spacing: {
|
|
|
280
269
|
};
|
|
281
270
|
type Spacing = (typeof spacing)[keyof typeof spacing];
|
|
282
271
|
|
|
283
|
-
export { Alert, Badge, type BadgeVariant, Banner, type Color, type Column, Columns, ConfirmInput, EmailInput, FooterHints, Header, type Hint, type IconMode, KeyValue, LoadingScreen, MultiSelect, type NotifyOptions, OrderedList, Panel, PasswordInput, ProgressBar,
|
|
272
|
+
export { Alert, Badge, type BadgeVariant, Banner, type Color, type Column, 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, UnorderedList, colors, getIconMode, notify, setIconMode, spacing };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Box, Text,
|
|
1
|
+
import { Box, Text, useInput, measureElement } from 'ink';
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
-
import
|
|
3
|
+
import React8, { createContext, useContext, useState, useEffect, useRef, useLayoutEffect } from 'react';
|
|
4
4
|
import cliSpinners from 'cli-spinners';
|
|
5
5
|
import { glyphs } from '@kud/glyphs';
|
|
6
6
|
import { spawn } from 'child_process';
|
|
@@ -63,7 +63,7 @@ var Table = ({
|
|
|
63
63
|
/* @__PURE__ */ jsx(Box, { gap: 2, children: columns.map((col) => /* @__PURE__ */ jsx(Box, { width: col.width, minWidth: col.width, children: /* @__PURE__ */ jsx(Text, { bold: true, color: colors.muted, children: col.header }) }, col.key)) }),
|
|
64
64
|
data.map((row, i) => /* @__PURE__ */ jsx(Box, { gap: 2, children: columns.map((col) => /* @__PURE__ */ jsx(Box, { width: col.width, minWidth: col.width, children: /* @__PURE__ */ jsx(Text, { wrap: "truncate-end", children: String(row[col.key] ?? "") }) }, col.key)) }, i))
|
|
65
65
|
] });
|
|
66
|
-
var FooterHints = ({ hints }) => /* @__PURE__ */ jsx(Box, {
|
|
66
|
+
var FooterHints = ({ hints }) => /* @__PURE__ */ jsx(Box, { columnGap: 2, rowGap: 0, flexWrap: "wrap", children: hints.map(([key, label]) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
67
67
|
/* @__PURE__ */ jsx(Text, { color: "white", children: key }),
|
|
68
68
|
/* @__PURE__ */ jsx(Text, { dimColor: true, children: " " + label })
|
|
69
69
|
] }, key)) });
|
|
@@ -73,30 +73,6 @@ var KeyValue = ({ label, value, labelWidth = 12 }) => /* @__PURE__ */ jsxs(Box,
|
|
|
73
73
|
isTextValue(value) ? /* @__PURE__ */ jsx(Text, { children: value }) : value
|
|
74
74
|
] });
|
|
75
75
|
var LoadingScreen = ({ label }) => /* @__PURE__ */ jsx(Box, { padding: 1, children: /* @__PURE__ */ jsx(Spinner, { label }) });
|
|
76
|
-
var ENTER_ALT = "\x1B[?1049h";
|
|
77
|
-
var LEAVE_ALT = "\x1B[?1049l";
|
|
78
|
-
var Screen = ({ children, altScreen = true }) => {
|
|
79
|
-
const { stdout } = useStdout();
|
|
80
|
-
const [size, setSize] = useState({
|
|
81
|
-
columns: stdout.columns || 80,
|
|
82
|
-
rows: stdout.rows || 24
|
|
83
|
-
});
|
|
84
|
-
useEffect(() => {
|
|
85
|
-
const restore = () => {
|
|
86
|
-
if (altScreen) stdout.write(LEAVE_ALT);
|
|
87
|
-
};
|
|
88
|
-
if (altScreen) stdout.write(ENTER_ALT);
|
|
89
|
-
const onResize = () => setSize({ columns: stdout.columns || 80, rows: stdout.rows || 24 });
|
|
90
|
-
stdout.on("resize", onResize);
|
|
91
|
-
process.on("exit", restore);
|
|
92
|
-
return () => {
|
|
93
|
-
stdout.off("resize", onResize);
|
|
94
|
-
process.off("exit", restore);
|
|
95
|
-
restore();
|
|
96
|
-
};
|
|
97
|
-
}, [stdout, altScreen]);
|
|
98
|
-
return /* @__PURE__ */ jsx(Box, { width: size.columns, height: size.rows, flexDirection: "column", children });
|
|
99
|
-
};
|
|
100
76
|
var Panel = ({
|
|
101
77
|
title,
|
|
102
78
|
color = colors.info,
|
|
@@ -472,10 +448,10 @@ var OrderedListItem = ({ children, _index = 1 }) => /* @__PURE__ */ jsxs(Box, {
|
|
|
472
448
|
] });
|
|
473
449
|
var OrderedListRoot = ({ children }) => {
|
|
474
450
|
let n = 0;
|
|
475
|
-
const numbered =
|
|
476
|
-
if (
|
|
451
|
+
const numbered = React8.Children.map(children, (child) => {
|
|
452
|
+
if (React8.isValidElement(child) && child.type === OrderedListItem) {
|
|
477
453
|
n += 1;
|
|
478
|
-
return
|
|
454
|
+
return React8.cloneElement(child, {
|
|
479
455
|
_index: n
|
|
480
456
|
});
|
|
481
457
|
}
|
|
@@ -716,4 +692,4 @@ var notify = (message, options = {}) => {
|
|
|
716
692
|
child.unref();
|
|
717
693
|
};
|
|
718
694
|
|
|
719
|
-
export { Alert, Badge, Banner, Columns, ConfirmInput, EmailInput, FooterHints, Header, KeyValue, LoadingScreen, MultiSelect, OrderedList, Panel, PasswordInput, ProgressBar,
|
|
695
|
+
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, UnorderedList, colors, getIconMode, notify, setIconMode, spacing };
|