@yuhuanowo/yunui 0.1.8 → 0.2.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 CHANGED
@@ -2,44 +2,47 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@yuhuanowo/yunui.svg)](https://www.npmjs.com/package/@yuhuanowo/yunui)
4
4
 
5
- Yunxin 的设计系统(YUNXIN Design System v3 / Zinc),提取成一个独立、版本化、可被多项目引用的 UI 库 —— 对标 [once-ui.com](https://once-ui.com)。
5
+ **English** · [简体中文](./README.zh-CN.md) · [繁體中文](./README.zh-TW.md)
6
6
 
7
- 改 YunUI 一处 → 发版 → 各项目升级版本号即可同步获得统一的 **设计 token、动画、组件**。已在 Yunxin 生产环境使用。
7
+ A standalone, versioned, multi-project React 19 + Tailwind v4 design system — in the spirit of [once-ui.com](https://once-ui.com).
8
+
9
+ Edit YunUI once → publish a new version → every project picks up the same **design tokens, animations, and components** on its next upgrade (`pnpm up`). Already running in production at Yunxin.
8
10
 
9
11
  ---
10
12
 
11
- ## 安装
13
+ ## Install
12
14
 
13
15
  ```bash
14
- npm i @yuhuanowo/yunui # 或 pnpm add / yarn add
16
+ npm i @yuhuanowo/yunui # or pnpm add / yarn add
15
17
  ```
16
18
 
17
- 要求消费方使用 **React 19** 与 **Tailwind CSS v4**(peerDependencies)。
19
+ Consumers must be on **React 19** and **Tailwind CSS v4** (peer dependencies).
18
20
 
19
- > 想让 import 保持短名 `yunui`?用包别名:
21
+ > Want to keep the import short as `yunui`? Use a package alias:
20
22
  > ```jsonc
21
23
  > // package.json
22
- > "dependencies": { "yunui": "npm:@yuhuanowo/yunui@^0.1.5" }
24
+ > "dependencies": { "yunui": "npm:@yuhuanowo/yunui@^0.2.0" }
23
25
  > ```
24
- > 之后 `import { Button } from "yunui"` 即可,下文示例同理。
26
+ > Then `import { Button } from "yunui"` works — the examples below assume this.
25
27
 
26
- ## 接入(3 步)
28
+ ## Setup (3 steps)
27
29
 
28
- ### 1. 引入设计系统样式
30
+ ### 1. Import the design-system styles
29
31
 
30
- 在全局 CSS(如 `app/globals.css`):
32
+ In your global CSS (e.g. `app/globals.css`):
31
33
 
32
34
  ```css
33
35
  @import "tailwindcss";
34
36
  @import "@yuhuanowo/yunui/css";
35
37
 
36
- /* 关键:让 Tailwind v4 扫描 YunUI 产物里的内联工具类,否则组件会"没样式" */
38
+ /* Key step: let Tailwind v4 scan YunUI's compiled output for its inline utility
39
+ classes, otherwise components render unstyled. */
37
40
  @source "../node_modules/@yuhuanowo/yunui/dist";
38
41
  ```
39
42
 
40
- > `@source` 路径以该 CSS 文件为基准,按你的项目结构调整。字体(Geist / JetBrains Mono)不打包,由消费方自行加载。
43
+ > The `@source` path is relative to that CSS file — adjust it to your project layout. Fonts (Geist / JetBrains Mono) are not bundled; load them yourself in the consuming app.
41
44
 
42
- ### 2. 用组件
45
+ ### 2. Use a component
43
46
 
44
47
  ```tsx
45
48
  import { Button, Card, Dialog, DialogContent } from "@yuhuanowo/yunui";
@@ -53,9 +56,9 @@ export function Demo() {
53
56
  }
54
57
  ```
55
58
 
56
- ### 3.(可选)注入框架适配器
59
+ ### 3. (Optional) Inject framework adapters
57
60
 
58
- 部分组件需要路由 / 图片 / i18n。在根布局用 `YunUIProvider` 注入你框架的实现:
61
+ Some components need routing / images / i18n. Inject your framework's implementations once at the root with `YunUIProvider`:
59
62
 
60
63
  ```tsx
61
64
  import { YunUIProvider } from "@yuhuanowo/yunui/adapters";
@@ -76,59 +79,75 @@ import { useTranslations } from "next-intl";
76
79
  </YunUIProvider>;
77
80
  ```
78
81
 
79
- 不注入时,YunUI 使用零依赖默认实现(`<a>` / `<img>` / identity 翻译)。
82
+ Without a provider, YunUI uses zero-dependency defaults (`<a>` / `<img>` / identity translation).
80
83
 
81
84
  ---
82
85
 
83
- ## 入口
86
+ ## Entry points
84
87
 
85
- | 入口 | 内容 |
88
+ | Entry | Contents |
86
89
  | --- | --- |
87
- | `@yuhuanowo/yunui` | 原子组件:Button / Input / Textarea / Card / Badge / Dialog / Select / Slider / Progress / Tabs / Avatar / Tooltip / DropdownMenu / Skeleton / Spinner / PageLoader / EmptyState / IconButton / Label,以及 MotionDiv·fadeIn·stagger 等动画预设 |
88
- | `@yuhuanowo/yunui/css` | 设计系统样式(token 变量、`@theme` 映射、`.btn`/`.card`/`.glass` 等全局类、动画 keyframes) |
89
- | `@yuhuanowo/yunui/adapters` | `YunUIProvider` / `useYunUI` 与适配器接口 |
90
- | `@yuhuanowo/yunui/patterns` | 页面级组件:FAQ、StatCard(`tone`/`inline`/`valueFirst` 变体)、BlogCard、CodeBlock、Sidebar、BackgroundEffects 等 |
91
- | `@yuhuanowo/yunui/ai` | Yunxin AI 产品域(prop 驱动,无 API 直连):ProviderIcon / ModelIcon / ModelTypeIcon、ModelCard、CapabilitySelector、Navbar、Footer、LanguageSwitcher、ThinkingBlock、IDBadge … |
90
+ | `@yuhuanowo/yunui` | Atomic components: Button / IconButton / Input / Textarea / Card / Badge / Dialog / Select / Slider / Progress / Tabs / Avatar / Tooltip / DropdownMenu / Skeleton / Spinner / PageLoader / EmptyState / Label; layout primitives Flex / Grid / Row / Column / Stack; data display Table / Breadcrumb / Pagination; interactive Accordion / RadioGroup / Switch / Checkbox / Combobox / CustomSelect / SegmentedSelect / NavTabs / Collapsible / Popover / Modal / Sheet / ConfirmModal / ThemeToggle; plus ShinyButton / Marquee / BentoGrid / AnimatedNumber and the MotionDiv · fadeIn · stagger animation presets |
91
+ | `@yuhuanowo/yunui/css` | Design-system stylesheet (token variables, `@theme` mappings, global `.btn` / `.card` / `.glass` classes, animation keyframes) |
92
+ | `@yuhuanowo/yunui/adapters` | `YunUIProvider` / `useYunUI` and the adapter interfaces |
93
+ | `@yuhuanowo/yunui/patterns` | Page-level components: FAQ, StatCard (`tone` / `inline` / `valueFirst` variants), BlogCard, CodeBlock, Sidebar, PageHeader, BackgroundEffects, and more |
94
+ | `@yuhuanowo/yunui/ai` | AI product-domain components (prop-driven, no direct API calls): ProviderIcon / ModelIcon / ModelTypeIcon, ModelCard, CapabilitySelector, Navbar, Footer, LanguageSwitcher, ThinkingBlock, IDBadge, … |
92
95
 
93
- **工具 / hooks**(从 `@yuhuanowo/yunui` 导出):`cn`、`toast` / `Toaster`(基于 sonner)、`MotionDiv` / `MotionSpan` / `fadeIn` / `staggerContainer` / `staggerItem`、`useEscapeKey` / `useBodyScrollLock` / `useModalBehavior`。
96
+ **Utilities / hooks** (exported from `@yuhuanowo/yunui`): `cn`, `toast` / `Toaster` (sonner-based), `MotionDiv` / `MotionSpan` / `fadeIn` / `staggerContainer` / `staggerItem`, `useEscapeKey` / `useBodyScrollLock` / `useModalBehavior`.
94
97
 
95
- > ⚠️ **`yunui/ai` 的图标素材需要你自备。** `ProviderIcon` / `ModelIcon` / `ModelAvatar` / `ModelCard` 会从 `/icons/providers/*.png`、`/icons/models/*.png` 加载图标 —— 这些素材**不随 npm 包发布**(包里只有 `dist` / `styles`)。消费方需把对应图标托管到 `iconBasePath` 指向的位置(默认 `/icons`,可从本仓库 `site/public/icons/` 取),否则图标会显示为裂图。base path 可通过适配器配置:`<YunUIProvider adapters={{ iconBasePath: "/assets/icons" }}>`(也可指向 CDN)。单个自定义图标 URL 通过组件 `iconUrl` prop 传入,原样使用。
98
+ > ⚠️ **`yunui/ai` icon assets are not bundled.** `ProviderIcon` / `ModelIcon` / `ModelAvatar` / `ModelCard` load images from `/icons/providers/*.png`, `/icons/models/*.png` — these assets are **not shipped with the npm package** (the package contains only `dist` / `styles`). Host the icons at the location `iconBasePath` points to (default `/icons`; you can grab them from this repo's `site/public/icons/`), or icons render as broken images. Configure the base path via the adapter: `<YunUIProvider adapters={{ iconBasePath: "/assets/icons" }}>` (a CDN origin works too). A single custom icon URL can be passed via a component's `iconUrl` prop and is used as-is.
96
99
  >
97
- > 同样,`./_deferred/ai-search`(文档 AI 搜索)**未导出** —— 它绑定 `@ai-sdk/react` + 聊天栈,是产品功能而非通用组件,导出会给库强加 ai-sdk peer 依赖。
100
+ > Likewise, `./_deferred/ai-search` (the docs AI search) is **not exported** — it is bound to `@ai-sdk/react` + a chat stack, making it a product feature rather than a general component; exporting it would force an ai-sdk peer dependency on the library.
98
101
 
99
102
  ---
100
103
 
101
- ## 主题
104
+ ## Themes
102
105
 
103
- 三套主题,通过根元素 class 切换(配合 `next-themes`):`light`(默认 `:root`)、`.dark`、`.true-black`(OLED)。
106
+ Three themes, switched via a class on the root element (works with `next-themes`): `light` (default `:root`), `.dark`, and `.true-black` (OLED).
104
107
 
105
- ## 同步流程(改一处,各项目同步)
108
+ ## Sync workflow (edit once, every project follows)
106
109
 
107
110
  ```bash
108
- # 在 YunUI:改代码 → 升 package.json 版本号 → 提交
109
- git tag v0.1.6 && git push origin v0.1.6
110
- # ↑ 推 tag 触发 GitHub Actions:typecheck → test → build → npm publish
111
- # (tokenless OIDC trusted publishing + provenance,无需本地发布/OTP)
111
+ # In YunUI: edit code → bump the version in package.json → commit
112
+ git tag v0.2.0 && git push origin v0.2.0
113
+ # ↑ pushing the tag triggers GitHub Actions: typecheck → test → build → npm publish
114
+ # (tokenless OIDC trusted publishing + provenance; no local publish/OTP needed)
112
115
 
113
- # 在消费项目:
116
+ # In the consuming project:
114
117
  pnpm up @yuhuanowo/yunui
115
118
  ```
116
119
 
117
- > 发布走 GitHub Actions(`.github/workflows/release.yml`)。一次性设置:在
118
- > npmjs.com 的包 Settings → Trusted Publisher 里添加 GitHub Actions
119
- > (repo `YuhuanStudio/YunUI`,workflow `release.yml`)。**不需要任何 npm token。**
120
+ > Publishing runs via GitHub Actions (`.github/workflows/release.yml`). One-time setup: on npmjs.com, under the package's Settings → Trusted Publisher, add the GitHub Actions publisher (repo `YuhuanStudio/YunUI`, workflow `release.yml`). **No npm token required.**
120
121
 
121
- ## 开发
122
+ ## Development
122
123
 
123
124
  ```bash
124
125
  pnpm install
125
- pnpm dev # tsup watch(配合 site/ 实时预览)
126
- pnpm build # 产出 dist/
126
+ pnpm dev # tsup watch (pairs with the site/ live preview)
127
+ pnpm build # produce dist/
127
128
  pnpm typecheck
129
+ pnpm test
130
+ ```
131
+
132
+ The showcase site lives in `site/` (Next 16 + Tailwind v4): `pnpm --filter yunui-site dev`.
133
+
134
+ ## Contributing / adding a component
135
+
136
+ Full guidelines are in **[CONTRIBUTING.md](./CONTRIBUTING.md)**. The most common pitfall: **components carry no copy and bind no i18n library.** Any component that shows text must go through an adapter — don't import next-intl, don't hardcode strings:
137
+
138
+ ```tsx
139
+ import { useYunUI } from "../adapters/context";
140
+
141
+ export function Thing() {
142
+ const t = useYunUI().useT("thing"); // namespace
143
+ return <button>{t("submit")}</button>; // a key, not a literal
144
+ }
128
145
  ```
129
146
 
130
- 展示站在 `site/`(Next 16 + Tailwind v4):`pnpm --filter yunui-site dev`。
147
+ - Without a provider, `useT` returns the key directly (the component still renders — that's how the showcase runs).
148
+ - Real translations live in the **consumer** (e.g. Yunxin's `messages/{en,zh-CN,zh-TW}.json`), not in YunUI.
149
+ - Same idea for routing/images via `useYunUI().Link/Image/useRouter` (never `next/*`), and business data via **props** (no `useBranding`/`fetch`/`localStorage` inside a component).
131
150
 
132
151
  ## License
133
152
 
134
- MIT © yuhuanowo
153
+ Apache-2.0 © YuhuanStudio
@@ -0,0 +1,154 @@
1
+ # YunUI
2
+
3
+ [![npm](https://img.shields.io/npm/v/@yuhuanowo/yunui.svg)](https://www.npmjs.com/package/@yuhuanowo/yunui)
4
+
5
+ [English](./README.md) · **简体中文** · [繁體中文](./README.zh-TW.md)
6
+
7
+ 一个独立、版本化、可被多项目引用的 React 19 + Tailwind v4 设计系统 —— 对标 [once-ui.com](https://once-ui.com)。
8
+
9
+ 改 YunUI 一处 → 发版 → 各项目升级版本号即可同步获得统一的 **设计 token、动画、组件**。已在 Yunxin 生产环境使用。
10
+
11
+ ---
12
+
13
+ ## 安装
14
+
15
+ ```bash
16
+ npm i @yuhuanowo/yunui # 或 pnpm add / yarn add
17
+ ```
18
+
19
+ 要求消费方使用 **React 19** 与 **Tailwind CSS v4**(peerDependencies)。
20
+
21
+ > 想让 import 保持短名 `yunui`?用包别名:
22
+ > ```jsonc
23
+ > // package.json
24
+ > "dependencies": { "yunui": "npm:@yuhuanowo/yunui@^0.2.0" }
25
+ > ```
26
+ > 之后 `import { Button } from "yunui"` 即可,下文示例同理。
27
+
28
+ ## 接入(3 步)
29
+
30
+ ### 1. 引入设计系统样式
31
+
32
+ 在全局 CSS(如 `app/globals.css`):
33
+
34
+ ```css
35
+ @import "tailwindcss";
36
+ @import "@yuhuanowo/yunui/css";
37
+
38
+ /* 关键:让 Tailwind v4 扫描 YunUI 产物里的内联工具类,否则组件会"没样式" */
39
+ @source "../node_modules/@yuhuanowo/yunui/dist";
40
+ ```
41
+
42
+ > `@source` 路径以该 CSS 文件为基准,按你的项目结构调整。字体(Geist / JetBrains Mono)不打包,由消费方自行加载。
43
+
44
+ ### 2. 用组件
45
+
46
+ ```tsx
47
+ import { Button, Card, Dialog, DialogContent } from "@yuhuanowo/yunui";
48
+
49
+ export function Demo() {
50
+ return (
51
+ <Card hover className="p-6">
52
+ <Button variant="primary">Hello YunUI</Button>
53
+ </Card>
54
+ );
55
+ }
56
+ ```
57
+
58
+ ### 3.(可选)注入框架适配器
59
+
60
+ 部分组件需要路由 / 图片 / i18n。在根布局用 `YunUIProvider` 注入你框架的实现:
61
+
62
+ ```tsx
63
+ import { YunUIProvider } from "@yuhuanowo/yunui/adapters";
64
+ import Link from "next/link";
65
+ import Image from "next/image";
66
+ import { useRouter } from "next/navigation";
67
+ import { useTranslations } from "next-intl";
68
+
69
+ <YunUIProvider
70
+ adapters={{
71
+ Link,
72
+ Image,
73
+ useRouter,
74
+ useT: (ns) => useTranslations(ns),
75
+ }}
76
+ >
77
+ {children}
78
+ </YunUIProvider>;
79
+ ```
80
+
81
+ 不注入时,YunUI 使用零依赖默认实现(`<a>` / `<img>` / identity 翻译)。
82
+
83
+ ---
84
+
85
+ ## 入口
86
+
87
+ | 入口 | 内容 |
88
+ | --- | --- |
89
+ | `@yuhuanowo/yunui` | 原子组件:Button / IconButton / Input / Textarea / Card / Badge / Dialog / Select / Slider / Progress / Tabs / Avatar / Tooltip / DropdownMenu / Skeleton / Spinner / PageLoader / EmptyState / Label,布局原语 Flex / Grid / Row / Column / Stack,数据展示 Table / Breadcrumb / Pagination,交互组件 Accordion / RadioGroup / Switch / Checkbox / Combobox / CustomSelect / SegmentedSelect / NavTabs / Collapsible / Popover / Modal / Sheet / ConfirmModal / ThemeToggle,以及 ShinyButton / Marquee / BentoGrid / AnimatedNumber 与 MotionDiv·fadeIn·stagger 等动画预设 |
90
+ | `@yuhuanowo/yunui/css` | 设计系统样式(token 变量、`@theme` 映射、`.btn`/`.card`/`.glass` 等全局类、动画 keyframes) |
91
+ | `@yuhuanowo/yunui/adapters` | `YunUIProvider` / `useYunUI` 与适配器接口 |
92
+ | `@yuhuanowo/yunui/patterns` | 页面级组件:FAQ、StatCard(`tone`/`inline`/`valueFirst` 变体)、BlogCard、CodeBlock、Sidebar、PageHeader、BackgroundEffects 等 |
93
+ | `@yuhuanowo/yunui/ai` | AI 产品域组件(prop 驱动,无 API 直连):ProviderIcon / ModelIcon / ModelTypeIcon、ModelCard、CapabilitySelector、Navbar、Footer、LanguageSwitcher、ThinkingBlock、IDBadge … |
94
+
95
+ **工具 / hooks**(从 `@yuhuanowo/yunui` 导出):`cn`、`toast` / `Toaster`(基于 sonner)、`MotionDiv` / `MotionSpan` / `fadeIn` / `staggerContainer` / `staggerItem`、`useEscapeKey` / `useBodyScrollLock` / `useModalBehavior`。
96
+
97
+ > ⚠️ **`yunui/ai` 的图标素材需要你自备。** `ProviderIcon` / `ModelIcon` / `ModelAvatar` / `ModelCard` 会从 `/icons/providers/*.png`、`/icons/models/*.png` 加载图标 —— 这些素材**不随 npm 包发布**(包里只有 `dist` / `styles`)。消费方需把对应图标托管到 `iconBasePath` 指向的位置(默认 `/icons`,可从本仓库 `site/public/icons/` 取),否则图标会显示为裂图。base path 可通过适配器配置:`<YunUIProvider adapters={{ iconBasePath: "/assets/icons" }}>`(也可指向 CDN)。单个自定义图标 URL 通过组件 `iconUrl` prop 传入,原样使用。
98
+ >
99
+ > 同样,`./_deferred/ai-search`(文档 AI 搜索)**未导出** —— 它绑定 `@ai-sdk/react` + 聊天栈,是产品功能而非通用组件,导出会给库强加 ai-sdk peer 依赖。
100
+
101
+ ---
102
+
103
+ ## 主题
104
+
105
+ 三套主题,通过根元素 class 切换(配合 `next-themes`):`light`(默认 `:root`)、`.dark`、`.true-black`(OLED)。
106
+
107
+ ## 同步流程(改一处,各项目同步)
108
+
109
+ ```bash
110
+ # 在 YunUI:改代码 → 升 package.json 版本号 → 提交
111
+ git tag v0.2.0 && git push origin v0.2.0
112
+ # ↑ 推 tag 触发 GitHub Actions:typecheck → test → build → npm publish
113
+ # (tokenless OIDC trusted publishing + provenance,无需本地发布/OTP)
114
+
115
+ # 在消费项目:
116
+ pnpm up @yuhuanowo/yunui
117
+ ```
118
+
119
+ > 发布走 GitHub Actions(`.github/workflows/release.yml`)。一次性设置:在
120
+ > npmjs.com 的包 Settings → Trusted Publisher 里添加 GitHub Actions
121
+ > (repo `YuhuanStudio/YunUI`,workflow `release.yml`)。**不需要任何 npm token。**
122
+
123
+ ## 开发
124
+
125
+ ```bash
126
+ pnpm install
127
+ pnpm dev # tsup watch(配合 site/ 实时预览)
128
+ pnpm build # 产出 dist/
129
+ pnpm typecheck
130
+ pnpm test
131
+ ```
132
+
133
+ 展示站在 `site/`(Next 16 + Tailwind v4):`pnpm --filter yunui-site dev`。
134
+
135
+ ## 贡献 / 加新组件
136
+
137
+ 完整规范见 **[CONTRIBUTING.md](./CONTRIBUTING.md)**。最容易踩的一条:**组件不内置文案 / 不绑定 i18n 库**。需要显示文字的组件必须走 adapter,不要 import next-intl,也不要硬写字符串:
138
+
139
+ ```tsx
140
+ import { useYunUI } from "../adapters/context";
141
+
142
+ export function Thing() {
143
+ const t = useYunUI().useT("thing"); // 命名空间
144
+ return <button>{t("submit")}</button>; // key,不是字面量
145
+ }
146
+ ```
147
+
148
+ - 不注入 provider 时 `useT` 直接返回 key(组件照样渲染,展示站也是这样跑的)。
149
+ - 真正的翻译文案加到**消费方**(如 Yunxin `messages/{en,zh-CN,zh-TW}.json`),不放 YunUI。
150
+ - 同理:路由/图片走 `useYunUI().Link/Image/useRouter`(别用 `next/*`);业务数据走 **props**(别在组件里 `useBranding`/`fetch`/`localStorage`)。
151
+
152
+ ## License
153
+
154
+ Apache-2.0 © YuhuanStudio
@@ -0,0 +1,154 @@
1
+ # YunUI
2
+
3
+ [![npm](https://img.shields.io/npm/v/@yuhuanowo/yunui.svg)](https://www.npmjs.com/package/@yuhuanowo/yunui)
4
+
5
+ [English](./README.md) · [简体中文](./README.zh-CN.md) · **繁體中文**
6
+
7
+ 一個獨立、版本化、可被多專案引用的 React 19 + Tailwind v4 設計系統 —— 對標 [once-ui.com](https://once-ui.com)。
8
+
9
+ 改 YunUI 一處 → 發版 → 各專案升級版本號即可同步取得統一的 **設計 token、動畫、元件**。已在 Yunxin 生產環境使用。
10
+
11
+ ---
12
+
13
+ ## 安裝
14
+
15
+ ```bash
16
+ npm i @yuhuanowo/yunui # 或 pnpm add / yarn add
17
+ ```
18
+
19
+ 要求消費方使用 **React 19** 與 **Tailwind CSS v4**(peerDependencies)。
20
+
21
+ > 想讓 import 保持短名 `yunui`?用套件別名:
22
+ > ```jsonc
23
+ > // package.json
24
+ > "dependencies": { "yunui": "npm:@yuhuanowo/yunui@^0.2.0" }
25
+ > ```
26
+ > 之後 `import { Button } from "yunui"` 即可,下文範例同理。
27
+
28
+ ## 接入(3 步)
29
+
30
+ ### 1. 引入設計系統樣式
31
+
32
+ 在全域 CSS(如 `app/globals.css`):
33
+
34
+ ```css
35
+ @import "tailwindcss";
36
+ @import "@yuhuanowo/yunui/css";
37
+
38
+ /* 關鍵:讓 Tailwind v4 掃描 YunUI 產物裡的內聯工具類,否則元件會「沒樣式」 */
39
+ @source "../node_modules/@yuhuanowo/yunui/dist";
40
+ ```
41
+
42
+ > `@source` 路徑以該 CSS 檔為基準,依你的專案結構調整。字型(Geist / JetBrains Mono)不打包,由消費方自行載入。
43
+
44
+ ### 2. 用元件
45
+
46
+ ```tsx
47
+ import { Button, Card, Dialog, DialogContent } from "@yuhuanowo/yunui";
48
+
49
+ export function Demo() {
50
+ return (
51
+ <Card hover className="p-6">
52
+ <Button variant="primary">Hello YunUI</Button>
53
+ </Card>
54
+ );
55
+ }
56
+ ```
57
+
58
+ ### 3.(可選)注入框架轉接器
59
+
60
+ 部分元件需要路由 / 圖片 / i18n。在根佈局用 `YunUIProvider` 注入你框架的實作:
61
+
62
+ ```tsx
63
+ import { YunUIProvider } from "@yuhuanowo/yunui/adapters";
64
+ import Link from "next/link";
65
+ import Image from "next/image";
66
+ import { useRouter } from "next/navigation";
67
+ import { useTranslations } from "next-intl";
68
+
69
+ <YunUIProvider
70
+ adapters={{
71
+ Link,
72
+ Image,
73
+ useRouter,
74
+ useT: (ns) => useTranslations(ns),
75
+ }}
76
+ >
77
+ {children}
78
+ </YunUIProvider>;
79
+ ```
80
+
81
+ 不注入時,YunUI 使用零相依預設實作(`<a>` / `<img>` / identity 翻譯)。
82
+
83
+ ---
84
+
85
+ ## 入口
86
+
87
+ | 入口 | 內容 |
88
+ | --- | --- |
89
+ | `@yuhuanowo/yunui` | 原子元件:Button / IconButton / Input / Textarea / Card / Badge / Dialog / Select / Slider / Progress / Tabs / Avatar / Tooltip / DropdownMenu / Skeleton / Spinner / PageLoader / EmptyState / Label,佈局原語 Flex / Grid / Row / Column / Stack,資料展示 Table / Breadcrumb / Pagination,互動元件 Accordion / RadioGroup / Switch / Checkbox / Combobox / CustomSelect / SegmentedSelect / NavTabs / Collapsible / Popover / Modal / Sheet / ConfirmModal / ThemeToggle,以及 ShinyButton / Marquee / BentoGrid / AnimatedNumber 與 MotionDiv·fadeIn·stagger 等動畫預設 |
90
+ | `@yuhuanowo/yunui/css` | 設計系統樣式(token 變數、`@theme` 對應、`.btn`/`.card`/`.glass` 等全域類別、動畫 keyframes) |
91
+ | `@yuhuanowo/yunui/adapters` | `YunUIProvider` / `useYunUI` 與轉接器介面 |
92
+ | `@yuhuanowo/yunui/patterns` | 頁面級元件:FAQ、StatCard(`tone`/`inline`/`valueFirst` 變體)、BlogCard、CodeBlock、Sidebar、PageHeader、BackgroundEffects 等 |
93
+ | `@yuhuanowo/yunui/ai` | AI 產品域元件(prop 驅動,無 API 直連):ProviderIcon / ModelIcon / ModelTypeIcon、ModelCard、CapabilitySelector、Navbar、Footer、LanguageSwitcher、ThinkingBlock、IDBadge … |
94
+
95
+ **工具 / hooks**(從 `@yuhuanowo/yunui` 匯出):`cn`、`toast` / `Toaster`(基於 sonner)、`MotionDiv` / `MotionSpan` / `fadeIn` / `staggerContainer` / `staggerItem`、`useEscapeKey` / `useBodyScrollLock` / `useModalBehavior`。
96
+
97
+ > ⚠️ **`yunui/ai` 的圖示素材需要你自備。** `ProviderIcon` / `ModelIcon` / `ModelAvatar` / `ModelCard` 會從 `/icons/providers/*.png`、`/icons/models/*.png` 載入圖示 —— 這些素材**不隨 npm 套件發佈**(套件裡只有 `dist` / `styles`)。消費方需把對應圖示託管到 `iconBasePath` 指向的位置(預設 `/icons`,可從本倉庫 `site/public/icons/` 取),否則圖示會顯示為裂圖。base path 可透過轉接器設定:`<YunUIProvider adapters={{ iconBasePath: "/assets/icons" }}>`(也可指向 CDN)。單個自訂圖示 URL 透過元件 `iconUrl` prop 傳入,原樣使用。
98
+ >
99
+ > 同樣,`./_deferred/ai-search`(文件 AI 搜尋)**未匯出** —— 它綁定 `@ai-sdk/react` + 聊天堆疊,是產品功能而非通用元件,匯出會給函式庫強加 ai-sdk peer 相依。
100
+
101
+ ---
102
+
103
+ ## 主題
104
+
105
+ 三套主題,透過根元素 class 切換(配合 `next-themes`):`light`(預設 `:root`)、`.dark`、`.true-black`(OLED)。
106
+
107
+ ## 同步流程(改一處,各專案同步)
108
+
109
+ ```bash
110
+ # 在 YunUI:改程式碼 → 升 package.json 版本號 → 提交
111
+ git tag v0.2.0 && git push origin v0.2.0
112
+ # ↑ 推 tag 觸發 GitHub Actions:typecheck → test → build → npm publish
113
+ # (tokenless OIDC trusted publishing + provenance,無需本地發佈/OTP)
114
+
115
+ # 在消費專案:
116
+ pnpm up @yuhuanowo/yunui
117
+ ```
118
+
119
+ > 發佈走 GitHub Actions(`.github/workflows/release.yml`)。一次性設定:在
120
+ > npmjs.com 的套件 Settings → Trusted Publisher 裡新增 GitHub Actions
121
+ > (repo `YuhuanStudio/YunUI`,workflow `release.yml`)。**不需要任何 npm token。**
122
+
123
+ ## 開發
124
+
125
+ ```bash
126
+ pnpm install
127
+ pnpm dev # tsup watch(配合 site/ 即時預覽)
128
+ pnpm build # 產出 dist/
129
+ pnpm typecheck
130
+ pnpm test
131
+ ```
132
+
133
+ 展示站在 `site/`(Next 16 + Tailwind v4):`pnpm --filter yunui-site dev`。
134
+
135
+ ## 貢獻 / 加新元件
136
+
137
+ 完整規範見 **[CONTRIBUTING.md](./CONTRIBUTING.md)**。最容易踩的一條:**元件不內建文案 / 不綁定 i18n 函式庫**。需要顯示文字的元件必須走 adapter,不要 import next-intl,也不要硬寫字串:
138
+
139
+ ```tsx
140
+ import { useYunUI } from "../adapters/context";
141
+
142
+ export function Thing() {
143
+ const t = useYunUI().useT("thing"); // 命名空間
144
+ return <button>{t("submit")}</button>; // key,不是字面量
145
+ }
146
+ ```
147
+
148
+ - 不注入 provider 時 `useT` 直接回傳 key(元件照樣渲染,展示站也是這樣跑的)。
149
+ - 真正的翻譯文案加到**消費方**(如 Yunxin `messages/{en,zh-CN,zh-TW}.json`),不放 YunUI。
150
+ - 同理:路由/圖片走 `useYunUI().Link/Image/useRouter`(別用 `next/*`);業務資料走 **props**(別在元件裡 `useBranding`/`fetch`/`localStorage`)。
151
+
152
+ ## License
153
+
154
+ Apache-2.0 © YuhuanStudio
package/dist/ai.d.ts CHANGED
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import * as class_variance_authority_types from 'class-variance-authority/types';
4
4
  import { VariantProps } from 'class-variance-authority';
5
+ export { D as DiscordIcon, F as Footer, a as FooterLink, b as FooterProps, c as FooterSection, d as FooterSocial, G as GithubIcon, I as InstagramIcon } from './footer-BoFu7Wqq.js';
5
6
 
6
7
  interface ThinkingBlockProps {
7
8
  content: string;
@@ -104,8 +105,8 @@ declare function getProviderIconOptions(): {
104
105
  value: string;
105
106
  label: string;
106
107
  }[];
107
- declare function normalizeProviderId(id: string): string;
108
- declare function getIconPath(providerId: string): string | null;
108
+ declare function normalizeProviderId(id: string | null | undefined): string;
109
+ declare function getIconPath(providerId: string | null | undefined): string | null;
109
110
  interface ProviderIconProps {
110
111
  /** Provider id; resolved to a built-in icon by name (e.g. "openai", "anthropic"). */
111
112
  provider: string;
@@ -128,7 +129,7 @@ declare function ProviderAvatar({ provider, size, className, }: {
128
129
  className?: string;
129
130
  }): React.JSX.Element;
130
131
  declare const ProviderNames: Record<string, string>;
131
- declare function getProviderName(providerId: string): string;
132
+ declare function getProviderName(providerId: string | null | undefined): string;
132
133
  interface ModelIconProps {
133
134
  /** Model's own icon URL or `/icons/models/` filename (highest priority). */
134
135
  iconUrl?: string | null;
@@ -229,46 +230,4 @@ interface NavbarProps {
229
230
  /** Floating top navigation bar: logo, center links with scroll-spy, theme/language slots, and auth buttons with a mobile menu. */
230
231
  declare function Navbar({ appName, logoSrc, links, currentPath, variant, labels, languageSwitcher, themeToggle, homeHref, loginHref, signupHref, }: NavbarProps): React.JSX.Element;
231
232
 
232
- declare const GithubIcon: () => React.JSX.Element;
233
- declare const InstagramIcon: () => React.JSX.Element;
234
- declare const DiscordIcon: () => React.JSX.Element;
235
- interface FooterLink {
236
- /** Link text. */
237
- label: string;
238
- /** Destination href. */
239
- href: string;
240
- }
241
- interface FooterSection {
242
- /** Column heading. */
243
- title: string;
244
- /** Links in this column. */
245
- links: FooterLink[];
246
- }
247
- interface FooterSocial {
248
- /** Icon to render (e.g. {@link GithubIcon}). */
249
- icon: ReactNode;
250
- /** Destination href (external links open in a new tab). */
251
- href: string;
252
- /** Accessible label for the link. */
253
- label: string;
254
- }
255
- interface FooterProps {
256
- /** Brand name shown next to the logo. */
257
- appName: string;
258
- /** Logo image src. @defaultValue "/favicon.ico" */
259
- logoSrc?: string;
260
- /** Where the logo links to. @defaultValue "/" */
261
- homeHref?: string;
262
- /** Short brand tagline under the logo. */
263
- tagline?: string;
264
- /** Link columns. */
265
- sections?: FooterSection[];
266
- /** Social/icon links shown in the bottom bar. */
267
- social?: FooterSocial[];
268
- /** Defaults to `© <year> <appName>. All rights reserved.` */
269
- copyright?: string;
270
- }
271
- /** Site footer: brand block, link columns, copyright line, and social icons. */
272
- declare function Footer({ appName, logoSrc, homeHref, tagline, sections, social, copyright, }: FooterProps): React.JSX.Element;
273
-
274
- export { type ButtonProps, CapabilitySelector, DiscordIcon, Footer, type FooterLink, type FooterProps, type FooterSection, type FooterSocial, GithubIcon, IDBadge, InstagramIcon, type LanguageOption, LanguageSwitcher, ModelAvatar, ModelCard, type ModelCardProps, ModelIcon, ModelTypeIcon, type NavLink, Navbar, ProviderAvatar, ProviderIcon, ProviderIconImg, ProviderNames, ThinkingBlock, buttonVariants, getDeveloperIconPath, getIconPath, getProviderIconOptions, getProviderName, normalizeProviderId };
233
+ export { type ButtonProps, CapabilitySelector, IDBadge, type LanguageOption, LanguageSwitcher, ModelAvatar, ModelCard, type ModelCardProps, ModelIcon, ModelTypeIcon, type NavLink, Navbar, ProviderAvatar, ProviderIcon, ProviderIconImg, ProviderNames, ThinkingBlock, buttonVariants, getDeveloperIconPath, getIconPath, getProviderIconOptions, getProviderName, normalizeProviderId };