ICEN UI AI 文件标签
Docs ⌘K
Beta · 演进中

AI 文件标签

文件 chips:增删改三态 × 七类文件修饰的纯 CSS 小组件。

Preview
AI 原生 ai-files
src/utils/format.ts src/components/ai-chat.css package.json README.md scripts/old-build.js assets/cover.png

纯 CSS 族:is-added(绿)/ is-modified(accent)/ is-deleted(红,删除线)× 文件类型图标 · renderAiContext 文件区同款

html
<div class="icen-ai-files">  <span class="icen-ai-file-chip is-added icen-ai-file-chip--ts"><span class="icen-ai-file-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" focusable="false" class="icen-symbol" aria-hidden="true"><path d="M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1v-12a2 2 0 0 1 2-2ZM11.5 2.5V7H16"></path></svg></span>src/utils/format.ts</span>  <span class="icen-ai-file-chip is-modified icen-ai-file-chip--css"><span class="icen-ai-file-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" focusable="false" class="icen-symbol" aria-hidden="true"><path d="M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1v-12a2 2 0 0 1 2-2ZM11.5 2.5V7H16"></path></svg></span>src/components/ai-chat.css</span>  <span class="icen-ai-file-chip is-modified icen-ai-file-chip--json"><span class="icen-ai-file-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" focusable="false" class="icen-symbol" aria-hidden="true"><path d="M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1v-12a2 2 0 0 1 2-2ZM11.5 2.5V7H16"></path></svg></span>package.json</span>  <span class="icen-ai-file-chip is-modified icen-ai-file-chip--md"><span class="icen-ai-file-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" focusable="false" class="icen-symbol" aria-hidden="true"><path d="M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1v-12a2 2 0 0 1 2-2ZM11.5 2.5V7H16"></path></svg></span>README.md</span>  <span class="icen-ai-file-chip is-deleted icen-ai-file-chip--js"><span class="icen-ai-file-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" focusable="false" class="icen-symbol" aria-hidden="true"><path d="M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1v-12a2 2 0 0 1 2-2ZM11.5 2.5V7H16"></path></svg></span>scripts/old-build.js</span>  <span class="icen-ai-file-chip is-added icen-ai-file-chip--img"><span class="icen-ai-file-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" focusable="false" class="icen-symbol" aria-hidden="true"><path d="M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1v-12a2 2 0 0 1 2-2ZM11.5 2.5V7H16"></path></svg></span>assets/cover.png</span></div><p class="demo-label" style="margin-top:8px">纯 CSS 族:is-added(绿)/ is-modified(accent)/ is-deleted(红,删除线)× 文件类型图标 · renderAiContext 文件区同款</p>

特性

纯 CSS 族,无 behavior。

接口

导出
renderAiDiff 共享行为模块,清单含族内导出
事件
icen:ai-diff-accepticen:ai-diff-rejecticen:ai-toggle detail 契约见 IcenEventMap;共享行为模块,清单含族内事件
类型
dist/behaviors/ai-diff.d.mts(随 npm 包发布,含全部 JSDoc 约束)

安装

bun add @icen.ai/ui

一行引入该组件(CSS 与 behavior 自动带上,无需关心内部 CSS 文件名):

js
import '@icen.ai/ui/kit/ai-files';

也可以用脚手架直接打印引入行:

bash
bunx --bun @icen.ai/ui add ai-files

Astro 项目注意:kit 入口里的 CSS import 在页面 <script> 里会被 Astro 的 client bundle 摇掉——请改在布局 frontmatter 里引 CSS(import '@icen.ai/ui/components/ai-diff.css';),JS 行为仍可走 kit。Vite SPA / webpack 项目无此问题。

用法

html
<!-- 纯 CSS 组件,无 behavior;文件图标由消费方注入 svg --><div class="icen-ai-files">  <span class="icen-ai-file-chip is-added icen-ai-file-chip--ts">    <span class="icen-ai-file-icon">…svg…</span>src/foo.ts  </span></div><!-- 类型修饰类:--ts / --js / --css / --json / --md / --img / --other -->