@yuhuanowo/yunui 0.1.4 → 0.1.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/README.md CHANGED
@@ -1,40 +1,48 @@
1
1
  # YunUI
2
2
 
3
+ [![npm](https://img.shields.io/npm/v/@yuhuanowo/yunui.svg)](https://www.npmjs.com/package/@yuhuanowo/yunui)
4
+
3
5
  Yunxin 的设计系统(YUNXIN Design System v3 / Zinc),提取成一个独立、版本化、可被多项目引用的 UI 库 —— 对标 [once-ui.com](https://once-ui.com)。
4
6
 
5
- 改 YunUI 一处 → 发版 → 各项目升级版本号即可同步获得统一的 **设计 token、动画、组件**。
7
+ 改 YunUI 一处 → 发版 → 各项目升级版本号即可同步获得统一的 **设计 token、动画、组件**。已在 Yunxin 生产环境使用。
6
8
 
7
9
  ---
8
10
 
9
11
  ## 安装
10
12
 
11
13
  ```bash
12
- pnpm add github:yuhuanowo/YunUI#v0.1.0
13
- # 或私有 registry: pnpm add yunui@0.1.0
14
+ npm i @yuhuanowo/yunui # 或 pnpm add / yarn add
14
15
  ```
15
16
 
16
- YunUI 要求消费方使用 **React 19** 与 **Tailwind CSS v4**(均为 peerDependencies)。
17
+ 要求消费方使用 **React 19** 与 **Tailwind CSS v4**(peerDependencies)。
18
+
19
+ > 想让 import 保持短名 `yunui`?用包别名:
20
+ > ```jsonc
21
+ > // package.json
22
+ > "dependencies": { "yunui": "npm:@yuhuanowo/yunui@^0.1.5" }
23
+ > ```
24
+ > 之后 `import { Button } from "yunui"` 即可,下文示例同理。
17
25
 
18
26
  ## 接入(3 步)
19
27
 
20
28
  ### 1. 引入设计系统样式
21
29
 
22
- 在你的全局 CSS(如 `app/globals.css`)里:
30
+ 在全局 CSS(如 `app/globals.css`):
23
31
 
24
32
  ```css
25
33
  @import "tailwindcss";
26
- @import "yunui/css";
34
+ @import "@yuhuanowo/yunui/css";
27
35
 
28
36
  /* 关键:让 Tailwind v4 扫描 YunUI 产物里的内联工具类,否则组件会"没样式" */
29
- @source "../node_modules/yunui/dist";
37
+ @source "../node_modules/@yuhuanowo/yunui/dist";
30
38
  ```
31
39
 
32
- > `@source` 的相对路径以该 CSS 文件为基准,按你的项目结构调整。
40
+ > `@source` 路径以该 CSS 文件为基准,按你的项目结构调整。字体(Geist / JetBrains Mono)不打包,由消费方自行加载。
33
41
 
34
42
  ### 2. 用组件
35
43
 
36
44
  ```tsx
37
- import { Button, Card, Dialog, DialogContent } from "yunui";
45
+ import { Button, Card, Dialog, DialogContent } from "@yuhuanowo/yunui";
38
46
 
39
47
  export function Demo() {
40
48
  return (
@@ -50,7 +58,7 @@ export function Demo() {
50
58
  部分组件需要路由 / 图片 / i18n。在根布局用 `YunUIProvider` 注入你框架的实现:
51
59
 
52
60
  ```tsx
53
- import { YunUIProvider } from "yunui/adapters";
61
+ import { YunUIProvider } from "@yuhuanowo/yunui/adapters";
54
62
  import Link from "next/link";
55
63
  import Image from "next/image";
56
64
  import { useRouter } from "next/navigation";
@@ -76,11 +84,17 @@ import { useTranslations } from "next-intl";
76
84
 
77
85
  | 入口 | 内容 |
78
86
  | --- | --- |
79
- | `yunui` | 原子组件(Button / Input / Card / Dialog / Select / Tabs / DropdownMenu / Tooltip …) |
80
- | `yunui/css` | 设计系统样式(token 变量、`@theme` 映射、全局类、动画 keyframes) |
81
- | `yunui/adapters` | `YunUIProvider` / `useYunUI` 与适配器接口 |
82
- | `yunui/patterns` | 中等耦合的页面级组件(landing / blog / docs) |
83
- | `yunui/ai` | Yunxin AI 产品域组件(prop 驱动,无 API 直连) |
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 … |
92
+
93
+ **工具 / hooks**(从 `@yuhuanowo/yunui` 导出):`cn`、`toast` / `Toaster`(基于 sonner)、`MotionDiv` / `MotionSpan` / `fadeIn` / `staggerContainer` / `staggerItem`、`useEscapeKey` / `useBodyScrollLock` / `useModalBehavior`。
94
+
95
+ > ⚠️ **`yunui/ai` 的图标素材需要你自备。** `ProviderIcon` / `ModelIcon` / `ModelAvatar` / `ModelCard` 会从 `/icons/providers/*.png`、`/icons/models/*.png` 加载图标 —— 这些素材**不随 npm 包发布**(包里只有 `dist` / `styles`)。消费方需把对应图标放到自己 `public/icons/...` 下(可从本仓库 `site/public/icons/` 取),否则图标会显示为裂图。自定义图标 URL 可通过组件 `iconUrl` prop 传入。(让 base path 可配置 = roadmap 待办。)
96
+ >
97
+ > 同样,`./_deferred/ai-search`(文档 AI 搜索)**未导出** —— 它绑定 `@ai-sdk/react` + 聊天栈,是产品功能而非通用组件,导出会给库强加 ai-sdk peer 依赖。
84
98
 
85
99
  ---
86
100
 
@@ -88,17 +102,33 @@ import { useTranslations } from "next-intl";
88
102
 
89
103
  三套主题,通过根元素 class 切换(配合 `next-themes`):`light`(默认 `:root`)、`.dark`、`.true-black`(OLED)。
90
104
 
91
- ## 同步流程
105
+ ## 同步流程(改一处,各项目同步)
106
+
107
+ ```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)
112
+
113
+ # 在消费项目:
114
+ pnpm up @yuhuanowo/yunui
115
+ ```
92
116
 
93
- 1. 改 YunUI 源码 → `pnpm build`。
94
- 2. 提交并打 tag:`git tag v0.2.0 && git push --tags`。
95
- 3. 各消费项目 `pnpm up yunui` 升到新版本。
117
+ > 发布走 GitHub Actions(`.github/workflows/release.yml`)。一次性设置:在
118
+ > npmjs.com 的包 Settings → Trusted Publisher 里添加 GitHub Actions
119
+ > (repo `YuhuanStudio/YunUI`,workflow `release.yml`)。**不需要任何 npm token。**
96
120
 
97
121
  ## 开发
98
122
 
99
123
  ```bash
100
124
  pnpm install
101
- pnpm dev # tsup watch
125
+ pnpm dev # tsup watch(配合 site/ 实时预览)
102
126
  pnpm build # 产出 dist/
103
127
  pnpm typecheck
104
128
  ```
129
+
130
+ 展示站在 `site/`(Next 16 + Tailwind v4):`pnpm --filter yunui-site dev`。
131
+
132
+ ## License
133
+
134
+ MIT © yuhuanowo
package/dist/ai.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { ReactNode } from 'react';
3
+ import * as class_variance_authority_types from 'class-variance-authority/types';
4
+ import { VariantProps } from 'class-variance-authority';
3
5
 
4
6
  interface ThinkingBlockProps {
5
7
  content: string;
@@ -60,6 +62,27 @@ interface CapabilitySelectorProps {
60
62
  }
61
63
  declare function CapabilitySelector({ selected, onChange, disabled, size, columns, modelType }: CapabilitySelectorProps): React.JSX.Element;
62
64
 
65
+ /**
66
+ * Rounded provider icon — a thin alias over the canonical {@link ProviderIcon}
67
+ * (rounded avatar style). Kept for call sites that prefer the short name.
68
+ */
69
+ declare function ProviderIconImg({ provider, size }: {
70
+ provider: string;
71
+ size?: number;
72
+ }): React.JSX.Element;
73
+ /** Capability/type icon for a model (chat, embedding, tts, …). */
74
+ declare function ModelTypeIcon({ type, size }: {
75
+ type: string;
76
+ size?: number;
77
+ }): React.JSX.Element;
78
+
79
+ declare const buttonVariants: (props?: ({
80
+ variant?: "outline" | "primary" | "ghost" | "secondary" | null | undefined;
81
+ color?: "outline" | "primary" | "ghost" | "secondary" | null | undefined;
82
+ size?: "icon" | "sm" | "icon-sm" | "icon-xs" | null | undefined;
83
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
84
+ type ButtonProps = VariantProps<typeof buttonVariants>;
85
+
63
86
  declare function getDeveloperIconPath(developer: string | null | undefined): string | null;
64
87
  declare function getProviderIconOptions(): {
65
88
  value: string;
@@ -189,4 +212,4 @@ interface FooterProps {
189
212
  }
190
213
  declare function Footer({ appName, logoSrc, homeHref, tagline, sections, social, copyright, }: FooterProps): React.JSX.Element;
191
214
 
192
- export { CapabilitySelector, DiscordIcon, Footer, type FooterLink, type FooterProps, type FooterSection, type FooterSocial, GithubIcon, IDBadge, InstagramIcon, type LanguageOption, LanguageSwitcher, ModelAvatar, ModelCard, type ModelCardProps, ModelIcon, type NavLink, Navbar, ProviderAvatar, ProviderIcon, ProviderNames, ThinkingBlock, getDeveloperIconPath, getIconPath, getProviderIconOptions, getProviderName, normalizeProviderId };
215
+ 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 };
package/dist/ai.js CHANGED
@@ -4,8 +4,9 @@ import { cn, ThemeToggle } from './chunk-DRZ7UCRU.js';
4
4
  import { useYunUI } from './chunk-XZGNL5A6.js';
5
5
  import { useState, useRef, useEffect, useMemo } from 'react';
6
6
  import { AnimatePresence, motion } from 'framer-motion';
7
- import { Brain, ChevronUp, ChevronDown, Check, Copy, Waves, SlidersHorizontal, Layers, Fingerprint, Ban, Image, Code, Eye, PauseCircle, Globe, X, Menu, MessageSquare, Radio, Box, Music, Video, Mic, Pencil } from 'lucide-react';
7
+ import { Brain, ChevronUp, ChevronDown, Check, Copy, Waves, SlidersHorizontal, Layers, Fingerprint, Ban, Image, Code, Eye, PauseCircle, Bot, Globe, X, Menu, Radio, Box, Shield, Shuffle, Music, Video, Mic, Volume2, Headphones, Palette, Hash, FileText, MessageSquare, Pencil } from 'lucide-react';
8
8
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
9
+ import { cva } from 'class-variance-authority';
9
10
 
10
11
  function ThinkingBlock({ content, isStreaming, defaultOpen = false, renderContent }) {
11
12
  const t = useYunUI().useT("common.thinking");
@@ -762,6 +763,54 @@ function ModelAvatar({
762
763
  }) {
763
764
  return /* @__PURE__ */ jsx(ModelIcon, { iconUrl, developer, provider, size, rounded: true, className });
764
765
  }
766
+ function ProviderIconImg({ provider, size = 16 }) {
767
+ return /* @__PURE__ */ jsx(ProviderIcon, { provider, size, rounded: true });
768
+ }
769
+ var MODEL_TYPE_ICONS = {
770
+ chat: /* @__PURE__ */ jsx(MessageSquare, { size: 16, className: "text-blue-500" }),
771
+ completion: /* @__PURE__ */ jsx(FileText, { size: 16, className: "text-gray-500" }),
772
+ embedding: /* @__PURE__ */ jsx(Hash, { size: 16, className: "text-purple-500" }),
773
+ image_generation: /* @__PURE__ */ jsx(Palette, { size: 16, className: "text-pink-500" }),
774
+ audio: /* @__PURE__ */ jsx(Headphones, { size: 16, className: "text-orange-500" }),
775
+ tts: /* @__PURE__ */ jsx(Volume2, { size: 16, className: "text-green-500" }),
776
+ stt: /* @__PURE__ */ jsx(Mic, { size: 16, className: "text-red-500" }),
777
+ video: /* @__PURE__ */ jsx(Video, { size: 16, className: "text-cyan-500" }),
778
+ video_generation: /* @__PURE__ */ jsx(Video, { size: 16, className: "text-cyan-400" }),
779
+ music_generation: /* @__PURE__ */ jsx(Music, { size: 16, className: "text-orange-400" }),
780
+ rerank: /* @__PURE__ */ jsx(Shuffle, { size: 16, className: "text-indigo-500" }),
781
+ moderation: /* @__PURE__ */ jsx(Shield, { size: 16, className: "text-yellow-500" }),
782
+ "3d": /* @__PURE__ */ jsx(Box, { size: 16, className: "text-amber-500" }),
783
+ realtime: /* @__PURE__ */ jsx(Radio, { size: 16, className: "text-yellow-400" })
784
+ };
785
+ function ModelTypeIcon({ type, size = 16 }) {
786
+ const icon = MODEL_TYPE_ICONS[type.toLowerCase()];
787
+ if (icon) {
788
+ return /* @__PURE__ */ jsx("span", { className: "inline-flex", style: { transform: size !== 16 ? `scale(${size / 16})` : void 0 }, children: icon });
789
+ }
790
+ return /* @__PURE__ */ jsx(Bot, { size, className: "text-muted-foreground" });
791
+ }
792
+ var variants = {
793
+ primary: "bg-fd-primary text-fd-primary-foreground hover:bg-fd-primary/80 disabled:bg-fd-secondary disabled:text-fd-secondary-foreground",
794
+ outline: "border hover:bg-fd-accent hover:text-fd-accent-foreground",
795
+ ghost: "hover:bg-fd-accent hover:text-fd-accent-foreground",
796
+ secondary: "border bg-fd-secondary text-fd-secondary-foreground hover:bg-fd-accent hover:text-fd-accent-foreground"
797
+ };
798
+ var buttonVariants = cva(
799
+ "inline-flex items-center justify-center rounded-md p-2 text-sm font-medium transition-colors duration-100 disabled:pointer-events-none disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring",
800
+ {
801
+ variants: {
802
+ variant: variants,
803
+ // fumadocs use `color` instead of `variant`
804
+ color: variants,
805
+ size: {
806
+ sm: "gap-1 px-2 py-1.5 text-xs",
807
+ icon: "p-1.5 [&_svg]:size-5",
808
+ "icon-sm": "p-1.5 [&_svg]:size-4.5",
809
+ "icon-xs": "p-1 [&_svg]:size-4"
810
+ }
811
+ }
812
+ }
813
+ );
765
814
  function LanguageSwitcher({
766
815
  locales,
767
816
  currentLocale,
@@ -1008,6 +1057,6 @@ function Footer({
1008
1057
  ] }) }) });
1009
1058
  }
1010
1059
 
1011
- export { CapabilitySelector, DiscordIcon, Footer, GithubIcon, IDBadge, InstagramIcon, LanguageSwitcher, ModelAvatar, ModelCard, ModelIcon, Navbar, ProviderAvatar, ProviderIcon, ProviderNames, ThinkingBlock, getDeveloperIconPath, getIconPath, getProviderIconOptions, getProviderName, normalizeProviderId };
1060
+ export { CapabilitySelector, DiscordIcon, Footer, GithubIcon, IDBadge, InstagramIcon, LanguageSwitcher, ModelAvatar, ModelCard, ModelIcon, ModelTypeIcon, Navbar, ProviderAvatar, ProviderIcon, ProviderIconImg, ProviderNames, ThinkingBlock, buttonVariants, getDeveloperIconPath, getIconPath, getProviderIconOptions, getProviderName, normalizeProviderId };
1012
1061
  //# sourceMappingURL=ai.js.map
1013
1062
  //# sourceMappingURL=ai.js.map