@longzai-intelligence-cli/tui 0.0.10 → 0.0.11

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 ADDED
@@ -0,0 +1,14 @@
1
+ # @longzai-intelligence-cli/tui
2
+
3
+ Longzai Intelligence Cli 的终端 TUI 预设包,为命令行应用提供组件式终端界面的固定策略实现。
4
+
5
+ ## 简介
6
+
7
+ 治理终端 TUI 界面的重复实现:需要组件式终端界面的命令行应用按需引入本包,获得统一渲染入口与通用界面组件,不需要的应用零负担。
8
+
9
+ ## 能力
10
+
11
+ - 应用渲染入口(`renderApp()`,返回可管理渲染实例)
12
+ - 数据表格组件(DataTable,列定义与行数据渲染)
13
+ - 信息面板组件(InfoPanel)
14
+ - 空态提示组件(EmptyState)
package/dist/index.d.ts CHANGED
@@ -29,11 +29,19 @@ type RenderInstance = ReturnType<typeof render>;
29
29
  declare function renderApp(element: ReactElement): RenderInstance;
30
30
  //#endregion
31
31
  //#region src/components/data-table.d.ts
32
- /** 文本对齐方式 */
32
+ /**
33
+ * 文本对齐方式
34
+ */
33
35
  type Align = 'left' | 'right';
34
- /** ink Text 支持的颜色字面量 */
36
+ /**
37
+ * ink Text 支持的颜色字面量
38
+ */
35
39
  type TextColor = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray' | 'grayBright' | 'redBright' | 'greenBright' | 'yellowBright' | 'blueBright' | 'magentaBright' | 'cyanBright' | 'whiteBright';
36
- /** 单元格取值方式:字段名或格式化器函数 */
40
+ /**
41
+ * 单元格取值方式:字段名或格式化器函数
42
+ *
43
+ * @typeParam T - 表格行数据类型,accessor 据此约束字段名或接收该行实例。
44
+ */
37
45
  type CellAccessor<T> = keyof T | ((row: T) => string);
38
46
  /**
39
47
  * 列定义
@@ -41,30 +49,56 @@ type CellAccessor<T> = keyof T | ((row: T) => string);
41
49
  * @typeParam T - 行数据类型
42
50
  */
43
51
  type Column<T> = {
44
- /** 列标题(表头显示文本) */
52
+ /**
53
+ * 列标题(表头显示文本)
54
+ */
45
55
  header: string;
46
- /** 列宽(字符数,用于 Box width) */
56
+ /**
57
+ * 列宽(字符数,用于 Box width)
58
+ */
47
59
  width: number;
48
- /** 单元格取值:行字段名或自定义格式化器 */
60
+ /**
61
+ * 单元格取值:行字段名或自定义格式化器
62
+ */
49
63
  cell: CellAccessor<T>;
50
- /** 文本对齐,默认 left */
64
+ /**
65
+ * 文本对齐,默认 left
66
+ */
51
67
  align?: Align;
52
- /** 数据行文本颜色,默认不染色 */
68
+ /**
69
+ * 数据行文本颜色,默认不染色
70
+ */
53
71
  color?: TextColor;
54
72
  };
55
- /** DataTable 组件属性 */
73
+ /**
74
+ * DataTable 组件属性
75
+ *
76
+ * @typeParam T - 表格行数据类型,列定义的 cell 取值器据此约束。
77
+ */
56
78
  type DataTableProps<T> = {
57
- /** 列定义列表 */
79
+ /**
80
+ * 列定义列表
81
+ */
58
82
  columns: Array<Column<T>>;
59
- /** 行数据列表 */
83
+ /**
84
+ * 行数据列表
85
+ */
60
86
  rows: T[];
61
- /** 表格标题(显示在表头上方) */
87
+ /**
88
+ * 表格标题(显示在表头上方)
89
+ */
62
90
  title?: string;
63
- /** 总记录数(用于标题展示,通常在分页时传入) */
91
+ /**
92
+ * 总记录数(用于标题展示,通常在分页时传入)
93
+ */
64
94
  total?: number;
65
- /** 空态提示文本,默认"暂无数据" */
95
+ /**
96
+ * 空态提示文本,默认"暂无数据"
97
+ */
66
98
  emptyText?: string;
67
- /** 行 key 提取器,默认使用行索引字符串 */
99
+ /**
100
+ * 行 key 提取器,默认使用行索引字符串
101
+ */
68
102
  rowKey?: (row: T, index: number) => string;
69
103
  };
70
104
  /**
@@ -88,15 +122,23 @@ type DataTableProps<T> = {
88
122
  * ```;
89
123
  *
90
124
  * @typeParam T - 行数据类型
125
+ * @param props - 表格配置,含列定义、行数据、标题、空态文案等。
126
+ * @returns 渲染好的表格 ReactElement;rows 为空时返回 EmptyState。
91
127
  */
92
128
  declare function DataTable<T>(props: DataTableProps<T>): ReactElement;
93
129
  //#endregion
94
130
  //#region src/components/info-panel.d.ts
95
- /** InfoPanel 组件属性 */
131
+ /**
132
+ * InfoPanel 组件属性
133
+ */
96
134
  type InfoPanelProps = {
97
- /** 面板标题(显示在顶部) */
135
+ /**
136
+ * 面板标题(显示在顶部)
137
+ */
98
138
  title: string;
99
- /** 面板内容 */
139
+ /**
140
+ * 面板内容
141
+ */
100
142
  children: ReactNode;
101
143
  };
102
144
  /**
@@ -110,13 +152,20 @@ type InfoPanelProps = {
110
152
  * <Text>仓库总数:{stats.totalRepos}</Text>
111
153
  * </InfoPanel>
112
154
  * ```;
155
+ *
156
+ * @param options - 组件属性对象:title 为面板标题,children 为内容区子元素
157
+ * @returns 渲染青色粗体标题与内容区的纵向 Ink Box。
113
158
  */
114
159
  declare const InfoPanel: FC<InfoPanelProps>;
115
160
  //#endregion
116
161
  //#region src/components/empty-state.d.ts
117
- /** 空态提示组件属性 */
162
+ /**
163
+ * 空态提示组件属性
164
+ */
118
165
  type EmptyStateProps = {
119
- /** 提示文本(默认"暂无数据") */
166
+ /**
167
+ * 提示文本(默认"暂无数据")
168
+ */
120
169
  text?: string;
121
170
  };
122
171
  /**
@@ -124,7 +173,8 @@ type EmptyStateProps = {
124
173
  *
125
174
  * 以暗色文本居中展示空态提示
126
175
  *
127
- * @param props - 组件属性
176
+ * @param options - 组件属性对象,text 为空态提示文本(缺省"暂无数据")
177
+ * @returns 渲染居中暗色提示文本的 Ink Box。
128
178
  */
129
179
  declare const EmptyState: FC<EmptyStateProps>;
130
180
  //#endregion
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import"./rolldown-runtime-BqT_7tdF.js";import{Box as e,Text as t,render as n}from"ink";import{jsx as r,jsxs as i}from"react/jsx-runtime";function a(e){return n(e)}const o=({text:n=`暂无数据`})=>r(e,{padding:1,children:r(t,{dimColor:!0,children:n})});function s(e,t){if(typeof t==`function`)return t(e);let n=e[t];return n==null?`-`:String(n)}function c(n){let{columns:a,rows:c,title:l,total:u,emptyText:d=`暂无数据`,rowKey:f}=n;if(c.length===0)return r(o,{text:d});let p=a.reduce((e,t)=>e+t.width,0);return i(e,{flexDirection:`column`,padding:1,children:[l!==void 0&&i(t,{color:`cyan`,bold:!0,children:[l,u===void 0?``:`(共 ${u} 条)`]}),i(e,{marginTop:l===void 0?0:1,flexDirection:`column`,children:[r(e,{children:a.map(n=>r(e,{width:n.width,children:r(t,{bold:!0,color:`gray`,children:n.header})},n.header))}),r(t,{dimColor:!0,children:`─`.repeat(p)}),c.map((n,i)=>r(e,{children:a.map(i=>{let a=s(n,i.cell);return r(e,{width:i.width,children:i.color===void 0?r(t,{children:a}):r(t,{color:i.color,children:a})},i.header)})},f?.(n,i)??String(i)))]})]})}const l=({title:n,children:a})=>i(e,{flexDirection:`column`,padding:1,children:[r(t,{color:`cyan`,bold:!0,children:n}),r(e,{marginTop:1,flexDirection:`column`,children:a})]});export{c as DataTable,o as EmptyState,l as InfoPanel,a as renderApp};
1
+ import"./rolldown-runtime-BqT_7tdF.js";import{Box as e,Text as t,render as n}from"ink";import{jsx as r,jsxs as i}from"react/jsx-runtime";function a(e){return n(e)}const o=({text:n=`暂无数据`})=>/* @__PURE__ */ r(e,{padding:1,children:/* @__PURE__ */ r(t,{dimColor:!0,children:n})});function s(e,t){if(typeof t==`function`)return t(e);let n=e[t];return n==null?`-`:String(n)}function c(n){let{columns:a,rows:c,title:l,total:u,emptyText:d=`暂无数据`,rowKey:f}=n;if(c.length===0)return/* @__PURE__ */ r(o,{text:d});let p=a.reduce((e,t)=>e+t.width,0);return/* @__PURE__ */ i(e,{flexDirection:`column`,padding:1,children:[l!==void 0&&/* @__PURE__ */ i(t,{color:`cyan`,bold:!0,children:[l,u===void 0?``:`(共 ${u} 条)`]}),/* @__PURE__ */ i(e,{marginTop:l===void 0?0:1,flexDirection:`column`,children:[/* @__PURE__ */ r(e,{children:a.map(n=>/* @__PURE__ */ r(e,{width:n.width,children:/* @__PURE__ */ r(t,{bold:!0,color:`gray`,children:n.header})},n.header))}),/* @__PURE__ */ r(t,{dimColor:!0,children:`─`.repeat(p)}),c.map((n,i)=>/* @__PURE__ */ r(e,{children:a.map(i=>{let a=s(n,i.cell);return/* @__PURE__ */ r(e,{width:i.width,children:i.color===void 0?/* @__PURE__ */ r(t,{children:a}):/* @__PURE__ */ r(t,{color:i.color,children:a})},i.header)})},f?.(n,i)??String(i)))]})]})}const l=({title:n,children:a})=>/* @__PURE__ */ i(e,{flexDirection:`column`,padding:1,children:[/* @__PURE__ */ r(t,{color:`cyan`,bold:!0,children:n}),/* @__PURE__ */ r(e,{marginTop:1,flexDirection:`column`,children:a})]});export{c as DataTable,o as EmptyState,l as InfoPanel,a as renderApp};
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-cli/tui",
3
- "version": "0.0.10",
4
- "private": false,
3
+ "version": "0.0.11",
4
+ "description": "Longzai Intelligence CLI 终端 TUI 交互预设",
5
5
  "keywords": [
6
+ "longzai-intelligence",
6
7
  "cli",
7
8
  "ink",
8
9
  "preset",
9
10
  "react",
10
11
  "tui"
11
12
  ],
13
+ "private": false,
12
14
  "license": "UNLICENSED",
13
15
  "files": [
14
16
  "dist"
@@ -24,12 +26,12 @@
24
26
  },
25
27
  "scripts": {
26
28
  "build": "lzi-builder",
27
- "build:prod": "NODE_ENV=production lzi-builder",
29
+ "build:prod": "NODE_ENV=production bun run build",
28
30
  "prepublishOnly": "bun run build:prod",
29
31
  "typecheck": "bun run typecheck:app && bun run typecheck:node && bun run typecheck:test",
30
- "typecheck:app": "tsgo --noEmit -p tsconfig/app.json",
31
- "typecheck:node": "tsgo --noEmit -p tsconfig/node.json",
32
- "typecheck:test": "tsgo --noEmit -p tsconfig/test.json",
32
+ "typecheck:app": "lzi-tsgo typecheck tsconfig/app.json",
33
+ "typecheck:node": "lzi-tsgo typecheck tsconfig/node.json",
34
+ "typecheck:test": "lzi-tsgo typecheck tsconfig/test.json",
33
35
  "lint": "oxlint && oxfmt --check",
34
36
  "lint:fix": "oxlint --fix && oxfmt",
35
37
  "test": "bun test",
@@ -38,7 +40,7 @@
38
40
  "clean": "lzi-dev-cli clean"
39
41
  },
40
42
  "dependencies": {
41
- "@longzai-intelligence-cli/core": "0.0.10",
43
+ "@longzai-intelligence-cli/core": "0.0.11",
42
44
  "ink": "^5.0.1",
43
45
  "react": "^19.2.6"
44
46
  },