@jboltai/tokui 0.2.4 → 0.2.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jboltai/tokui",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "TokUI — Zero-dependency streaming UI description & rendering framework for AI chat. Describe UI with a tiny DSL, stream over SSE, render to real DOM incrementally.",
5
5
  "keywords": [
6
6
  "tokui",
@@ -91,6 +91,7 @@
91
91
  "typecheck": "tsc",
92
92
  "coverage": "c8 --include='src/**/*.js' --exclude='src/server/**' npm run test:all",
93
93
  "server": "node demo/server/sse-server.js",
94
+ "demo:validate": "node demo/server/validate-demos.js",
94
95
  "demo:sync": "npm run build && cp dist/tokui.umd.js dist/tokui.css demo/lib/ && perl -i -ne 'print unless m{^//# sourceMappingURL=}' demo/lib/tokui.umd.js && cp src/server/tokui-builder.js demo/server/tokui-builder.js",
95
96
  "dev": "vite",
96
97
  "build": "vite build --mode lib",
@@ -94,6 +94,31 @@ export declare class TokUIBuilder {
94
94
  editable(attrs?: BuilderAttrs): this;
95
95
  floatButton(attrs?: BuilderAttrs): this;
96
96
  masonry(attrs?: BuilderAttrs): this;
97
+ scrollArea(attrs?: BuilderAttrs): this;
98
+ /** 科技边框容器(容器) */
99
+ panel(attrs?: BuilderAttrs): this;
100
+ /** 指标卡(容器) */
101
+ kpi(attrs?: BuilderAttrs): this;
102
+ /** 数字翻牌器(自闭合) */
103
+ flipNum(attrs?: BuilderAttrs): this;
104
+ /** 轮播榜单(容器) */
105
+ scrollboard(attrs?: BuilderAttrs): this;
106
+ /** 大屏缩放容器 */
107
+ fitScreen(attrs?: BuilderAttrs): this;
108
+
109
+ // —— 应用壳(M2 / T2.1,容器,需 end() 闭合)——
110
+ /** 应用壳(三件套落位 grid areas) */
111
+ page(attrs?: BuilderAttrs): this;
112
+ /** 页头(子节点为右侧动作区;bc 面包屑、sticky 吸顶) */
113
+ pageHeader(attrs?: BuilderAttrs): this;
114
+ /** 侧栏(品牌行 + 折叠钮 + 滚动主体) */
115
+ pageSidebar(attrs?: BuilderAttrs): this;
116
+ /** 主区薄包装 */
117
+ pageContent(attrs?: BuilderAttrs): this;
118
+ /** 多页签容器(act 初始激活 key) */
119
+ pageTabs(attrs?: BuilderAttrs): this;
120
+ /** 单页签(n 为 key,closeable 可关闭) */
121
+ pageTab(attrs?: BuilderAttrs): this;
97
122
 
98
123
  // —— 高级网格布局(容器,需 end() 闭合)——
99
124
  grid(attrs?: BuilderAttrs): this;
@@ -218,13 +218,19 @@ class TokUIBuilder {
218
218
  tbody() { return this._open('tbody'); }
219
219
  /** 表格数据行,多个值用逗号拼接,含逗号的值自动加双引号 */
220
220
  row(...values) {
221
+ // T2.3:尾参可为 attrs 对象(tr id/pid/clk 等)——[tr id:x pid:y] 树形行/行点击
222
+ let attrs;
223
+ const last = values[values.length - 1];
224
+ if (last && typeof last === 'object' && !Array.isArray(last)) {
225
+ attrs = values.pop();
226
+ }
221
227
  const escaped = values.map(v => {
222
228
  const s = String(v);
223
229
  // 只对含逗号的 cell 加引号,含冒号的交给 _selfClosing 统一处理
224
230
  if (s.includes(',')) return `"${s}"`;
225
231
  return s;
226
232
  });
227
- return this._selfClosing('tr', escaped.join(','));
233
+ return this._selfClosing('tr', escaped.join(','), attrs);
228
234
  }
229
235
 
230
236
  // ========== 表单组件 ==========
@@ -348,9 +354,9 @@ class TokUIBuilder {
348
354
  var a = attrs || {};
349
355
  // hasInline 判定:凡带内联数据载体的 chart 均自闭合。
350
356
  // d=柱/折/面积/饼/雷达/散点/气泡/直方/瀑布/箱线/K线/树图; tasks=甘特;
351
- // rows=热力; nodes+flows=桑基; v=仪表盘/进度条(单值)
357
+ // rows=热力; nodes+flows=桑基; v=仪表盘/进度条(单值); region=地图省级热力。
352
358
  // 漏判会让本应自闭合的 chart 走容器分支,.end() 错位闭合 → 后续栅格结构串味乱套。
353
- var hasInline = a.d || a.tasks || a.rows || (a.nodes && a.flows) ||
359
+ var hasInline = a.d || a.tasks || a.rows || a.region || (a.nodes && a.flows) ||
354
360
  (a.v !== undefined && (a.t === 'gauge' || a.t === 'progress'));
355
361
  // 布局属性前置:流式预览阶段 d/tasks 边到边长,若 orient/stack/smooth/area 排在数据后,
356
362
  // parser 半成品看不到 → 预览用默认布局,] 闭合才翻转(如 orient:h 末尾到达致纵向→横向闪)。
@@ -668,6 +674,43 @@ class TokUIBuilder {
668
674
 
669
675
  /** 终端输出(容器) */
670
676
  terminal(attrs) { return this._open('terminal', attrs); }
677
+ // ========== 数据大屏组件(M1 Dashboard Pack) ==========
678
+
679
+ /** 科技边框容器(容器) */
680
+ panel(attrs) { return this._open('panel', attrs); }
681
+
682
+ /** 指标卡(容器,子节点为底部说明行) */
683
+ kpi(attrs) { return this._open('kpi', attrs); }
684
+
685
+ /** 数字翻牌器(自闭合) */
686
+ flipNum(attrs) { return this._selfClosing('flip-num', null, attrs); }
687
+
688
+ /** 轮播榜单(容器,可加 tr 子节点行) */
689
+ scrollboard(attrs) { return this._open('scrollboard', attrs); }
690
+
691
+ /** 大屏缩放容器(1920×1080 设计稿等比适配) */
692
+ fitScreen(attrs) { return this._open('fit-screen', attrs); }
693
+
694
+ // ========== 应用壳组件(M2 Admin Pack / T2.1,均为容器需 .end()) ==========
695
+
696
+ /** 应用壳(page-header/page-sidebar/page-content 三件套落位 grid areas) */
697
+ page(attrs) { return this._open('page', attrs); }
698
+
699
+ /** 页头(子节点为右侧动作区;bc 逗号分级面包屑,sticky 吸顶) */
700
+ pageHeader(attrs) { return this._open('page-header', attrs); }
701
+
702
+ /** 侧栏(内置品牌行 + 折叠钮,子节点为主体内容) */
703
+ pageSidebar(attrs) { return this._open('page-sidebar', attrs); }
704
+
705
+ /** 主区薄包装(自滚动 + 裁剪防护) */
706
+ pageContent(attrs) { return this._open('page-content', attrs); }
707
+
708
+ /** 多页签容器(act 指定初始激活页签 key) */
709
+ pageTabs(attrs) { return this._open('page-tabs', attrs); }
710
+
711
+ /** 单页签(n 为 key,closeable 可关闭,del 整签移除) */
712
+ pageTab(attrs) { return this._open('page-tab', attrs); }
713
+
671
714
 
672
715
  /** 流式闪光加载(自闭合) */
673
716
  shimmer(attrs) { return this._selfClosing('shimmer', null, attrs); }