@yuhuanowo/yunui 0.2.17 → 0.2.18

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.
Files changed (41) hide show
  1. package/README.md +3 -1
  2. package/README.zh-CN.md +5 -1
  3. package/README.zh-TW.md +5 -1
  4. package/dist/ai.d.ts +99 -3
  5. package/dist/ai.js +212 -104
  6. package/dist/ai.js.map +1 -1
  7. package/dist/chat.d.ts +10 -3
  8. package/dist/chat.js +12 -7
  9. package/dist/chat.js.map +1 -1
  10. package/dist/{chunk-HH3JBHRP.js → chunk-AFVENY4D.js} +286 -31
  11. package/dist/chunk-AFVENY4D.js.map +1 -0
  12. package/dist/{chunk-F2HG4TOQ.js → chunk-GAXVET76.js} +13 -19
  13. package/dist/chunk-GAXVET76.js.map +1 -0
  14. package/dist/{chunk-DDUP7GAX.js → chunk-LEBQPP4B.js} +69 -3
  15. package/dist/chunk-LEBQPP4B.js.map +1 -0
  16. package/dist/chunk-ST6TSBVQ.js +208 -0
  17. package/dist/chunk-ST6TSBVQ.js.map +1 -0
  18. package/dist/chunk-V7VJKZ5Q.js +254 -0
  19. package/dist/chunk-V7VJKZ5Q.js.map +1 -0
  20. package/dist/{chunk-BCOKFWXC.js → chunk-YKWRCA2S.js} +80 -156
  21. package/dist/chunk-YKWRCA2S.js.map +1 -0
  22. package/dist/content.d.ts +10 -2
  23. package/dist/content.js +50 -40
  24. package/dist/content.js.map +1 -1
  25. package/dist/index.d.ts +266 -16
  26. package/dist/index.js +4 -4
  27. package/dist/patterns.d.ts +471 -22
  28. package/dist/patterns.js +783 -131
  29. package/dist/patterns.js.map +1 -1
  30. package/icons/providers/gmi.svg +5 -0
  31. package/package.json +3 -4
  32. package/styles/content.css +3 -1
  33. package/styles/yunui.css +197 -84
  34. package/dist/chunk-BCOKFWXC.js.map +0 -1
  35. package/dist/chunk-DDUP7GAX.js.map +0 -1
  36. package/dist/chunk-F2HG4TOQ.js.map +0 -1
  37. package/dist/chunk-HH3JBHRP.js.map +0 -1
  38. package/dist/chunk-N4QO7RN5.js +0 -98
  39. package/dist/chunk-N4QO7RN5.js.map +0 -1
  40. package/dist/chunk-QEIBYOG2.js +0 -188
  41. package/dist/chunk-QEIBYOG2.js.map +0 -1
package/README.md CHANGED
@@ -126,12 +126,14 @@ Without a provider, YunUI uses zero-dependency defaults (`<a>` / `<img>` / ident
126
126
 
127
127
  **Utilities / hooks** (exported from `@yuhuanowo/yunui`): `cn`, `toast` / `Toaster` (sonner-based), `MotionDiv` / `MotionSpan` / `fadeIn` / `staggerContainer` / `staggerItem`, `useEscapeKey` / `useBodyScrollLock` / `useModalBehavior`.
128
128
 
129
- > **`yunui/ai` icons — bundled, served via CDN by default.** `ProviderIcon` / `ModelIcon` / `ModelAvatar` / `ModelCard` resolve `/providers/*.png` and `/models/*.png` under `iconBasePath`, which **defaults to the bundled set on jsDelivr** (`https://cdn.jsdelivr.net/npm/@yuhuanowo/yunui@0.2/icons`) — so icons work with **zero setup**. To **self-host and/or extend** with your own icons, copy the package's `icons/` (or this repo's `site/public/icons/`) into your app and point the adapter at it: `<YunUIProvider adapters={{ iconBasePath: "/icons" }}>`. A single custom icon URL can be passed via a component's `iconUrl` prop and is used as-is. **next/image** users: self-host, or allow `cdn.jsdelivr.net` in `images.remotePatterns`.
129
+ > **`yunui/ai` icon assets ship in the package, separate from the JavaScript bundle, and are served via CDN by default.** `ProviderIcon` / `ModelIcon` / `ModelAvatar` / `ModelCard` resolve `/providers/*.png` and `/models/*.png` under `iconBasePath`, which **defaults to the package icons on jsDelivr** (`https://cdn.jsdelivr.net/npm/@yuhuanowo/yunui@0.2/icons`) — so icons work with **zero setup**. To **self-host and/or extend** with your own icons, copy the package's `icons/` (or this repo's `site/public/icons/`) into your app and point the adapter at it: `<YunUIProvider adapters={{ iconBasePath: "/icons" }}>`. A single custom icon URL can be passed via a component's `iconUrl` prop and is used as-is. **next/image** users: self-host, or allow `cdn.jsdelivr.net` in `images.remotePatterns`.
130
130
  >
131
131
  > 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.
132
132
 
133
133
  ---
134
134
 
135
+ MarkdownRenderer accepts optional `linkOrigin` to classify same-origin absolute links consistently during SSR and in the browser. Without it, absolute HTTP(S) and protocol-relative links are external, while relative links stay internal. `ImageLightbox` accepts an optional accessible `label` (defaults to the image alt text or the content translation); it traps focus, exposes a modal dialog, and locks background scrolling.
136
+
135
137
  ## Themes
136
138
 
137
139
  Three themes, switched via a class on the root element (works with `next-themes`): `light` (default `:root`), `.dark`, and `.true-black` (OLED).
package/README.zh-CN.md CHANGED
@@ -115,16 +115,20 @@ import { useTranslations } from "next-intl";
115
115
  | `@yuhuanowo/yunui/css` | 设计系统样式(token 变量、`@theme` 映射、`.btn`/`.card`/`.glass` 等全局类、动画 keyframes) |
116
116
  | `@yuhuanowo/yunui/adapters` | `YunUIProvider` / `useYunUI` 与适配器接口 |
117
117
  | `@yuhuanowo/yunui/patterns` | 页面级组件:FAQ、StatCard(`tone`/`inline`/`valueFirst` 变体)、BlogCard、CodeBlock、Sidebar、PageHeader、BackgroundEffects 等 |
118
+ | `@yuhuanowo/yunui/content` | 内容渲染组件:`MarkdownRenderer`(GFM + KaTeX + Shiki + Mermaid + 提示框 + 惰性缩放图片)、`CodeBlock` / `InlineCode`、`CalloutBlock`、`MathRenderer`、`MermaidDiagram`、`ContentImage`、`ImageLightbox` |
119
+ | `@yuhuanowo/yunui/chat` | 插槽式聊天 UI:`ChatMessage`、`ChatMessageList`、`ChatComposer`、`ChatHeader` |
118
120
  | `@yuhuanowo/yunui/ai` | AI 产品域组件(prop 驱动,无 API 直连):ProviderIcon / ModelIcon / ModelTypeIcon、ModelCard、CapabilitySelector、Navbar、Footer、LanguageSwitcher、ThinkingBlock、IDBadge … |
119
121
 
120
122
  **工具 / hooks**(从 `@yuhuanowo/yunui` 导出):`cn`、`toast` / `Toaster`(基于 sonner)、`MotionDiv` / `MotionSpan` / `fadeIn` / `staggerContainer` / `staggerItem`、`useEscapeKey` / `useBodyScrollLock` / `useModalBehavior`。
121
123
 
122
- > ⚠️ **`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 传入,原样使用。
124
+ > **`yunui/ai` 图标素材随 npm 包发布在 `icons/`,但不在 JavaScript bundle 中;默认通过 jsDelivr 提供。** `ProviderIcon` / `ModelIcon` / `ModelAvatar` / `ModelCard` 从 `iconBasePath` 下的 `/providers/*.png`、`/models/*.png` 加载图标,默认使用 `https://cdn.jsdelivr.net/npm/@yuhuanowo/yunui@0.2/icons`。消费方也可自行托管包内的 `icons/` 并配置 `<YunUIProvider adapters={{ iconBasePath: "/icons" }}>`。单个自定义图标 URL 通过组件 `iconUrl` prop 传入,原样使用。
123
125
  >
124
126
  > 同样,`./_deferred/ai-search`(文档 AI 搜索)**未导出** —— 它绑定 `@ai-sdk/react` + 聊天栈,是产品功能而非通用组件,导出会给库强加 ai-sdk peer 依赖。
125
127
 
126
128
  ---
127
129
 
130
+ Markdown 渲染器可选接收 `linkOrigin`,让 SSR 与浏览器以相同 origin 判断绝对链接是否站内。不传时,绝对 HTTP(S) 与协议相对链接视为外链,相对链接仍视为站内。`ImageLightbox` 可用 `label` 设置无障碍名称(默认取图片 alt 或内容翻译);它会限制焦点、声明模态对话框并锁定背景滚动。
131
+
128
132
  ## 主题
129
133
 
130
134
  三套主题,通过根元素 class 切换(配合 `next-themes`):`light`(默认 `:root`)、`.dark`、`.true-black`(OLED)。
package/README.zh-TW.md CHANGED
@@ -115,16 +115,20 @@ import { useTranslations } from "next-intl";
115
115
  | `@yuhuanowo/yunui/css` | 設計系統樣式(token 變數、`@theme` 對應、`.btn`/`.card`/`.glass` 等全域類別、動畫 keyframes) |
116
116
  | `@yuhuanowo/yunui/adapters` | `YunUIProvider` / `useYunUI` 與轉接器介面 |
117
117
  | `@yuhuanowo/yunui/patterns` | 頁面級元件:FAQ、StatCard(`tone`/`inline`/`valueFirst` 變體)、BlogCard、CodeBlock、Sidebar、PageHeader、BackgroundEffects 等 |
118
+ | `@yuhuanowo/yunui/content` | 內容渲染元件:`MarkdownRenderer`(GFM + KaTeX + Shiki + Mermaid + 提示框 + 惰性縮放圖片)、`CodeBlock` / `InlineCode`、`CalloutBlock`、`MathRenderer`、`MermaidDiagram`、`ContentImage`、`ImageLightbox` |
119
+ | `@yuhuanowo/yunui/chat` | 插槽式聊天 UI:`ChatMessage`、`ChatMessageList`、`ChatComposer`、`ChatHeader` |
118
120
  | `@yuhuanowo/yunui/ai` | AI 產品域元件(prop 驅動,無 API 直連):ProviderIcon / ModelIcon / ModelTypeIcon、ModelCard、CapabilitySelector、Navbar、Footer、LanguageSwitcher、ThinkingBlock、IDBadge … |
119
121
 
120
122
  **工具 / hooks**(從 `@yuhuanowo/yunui` 匯出):`cn`、`toast` / `Toaster`(基於 sonner)、`MotionDiv` / `MotionSpan` / `fadeIn` / `staggerContainer` / `staggerItem`、`useEscapeKey` / `useBodyScrollLock` / `useModalBehavior`。
121
123
 
122
- > ⚠️ **`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 傳入,原樣使用。
124
+ > **`yunui/ai` 圖示素材隨 npm 套件發佈於 `icons/`,但不在 JavaScript bundle 中;預設透過 jsDelivr 提供。** `ProviderIcon` / `ModelIcon` / `ModelAvatar` / `ModelCard` 從 `iconBasePath` 下的 `/providers/*.png`、`/models/*.png` 載入圖示,預設使用 `https://cdn.jsdelivr.net/npm/@yuhuanowo/yunui@0.2/icons`。消費方也可自行託管套件內的 `icons/` 並設定 `<YunUIProvider adapters={{ iconBasePath: "/icons" }}>`。單個自訂圖示 URL 透過元件 `iconUrl` prop 傳入,原樣使用。
123
125
  >
124
126
  > 同樣,`./_deferred/ai-search`(文件 AI 搜尋)**未匯出** —— 它綁定 `@ai-sdk/react` + 聊天堆疊,是產品功能而非通用元件,匯出會給函式庫強加 ai-sdk peer 相依。
125
127
 
126
128
  ---
127
129
 
130
+ Markdown 渲染器可選接收 `linkOrigin`,讓 SSR 與瀏覽器以相同 origin 判斷絕對連結是否站內。不傳時,絕對 HTTP(S) 與協定相對連結視為外連,相對連結仍視為站內。`ImageLightbox` 可用 `label` 設定無障礙名稱(預設取圖片 alt 或內容翻譯);它會限制焦點、宣告模態對話框並鎖定背景捲動。
131
+
128
132
  ## 主題
129
133
 
130
134
  三套主題,透過根元素 class 切換(配合 `next-themes`):`light`(預設 `:root`)、`.dark`、`.true-black`(OLED)。
package/dist/ai.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { ReactNode, HTMLAttributes } from 'react';
2
+ import { ReactNode, HTMLAttributes, ElementType } from 'react';
3
3
  import * as class_variance_authority_types from 'class-variance-authority/types';
4
4
  import { VariantProps } from 'class-variance-authority';
5
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';
@@ -422,8 +422,104 @@ interface NavbarProps {
422
422
  loginHref?: string;
423
423
  /** Sign-up link destination. @defaultValue "/signup" */
424
424
  signupHref?: string;
425
+ /**
426
+ * Signed-in account control — pass an `AccountMenu`. When present it
427
+ * REPLACES the sign in / sign up buttons (desktop and mobile), so a reader
428
+ * who is already signed in sees their avatar rather than an invitation to
429
+ * sign in again.
430
+ */
431
+ account?: ReactNode;
432
+ /**
433
+ * Replaces the logo + wordmark block entirely. Pass a mark-only logo, a
434
+ * custom lockup, anything — it is still wrapped in the link to `homeHref`.
435
+ * Without this, a brand that is a single glyph had to be faked through
436
+ * `logoSrc`/`appName`, which is why YunUI's own site and YunNEWS each kept
437
+ * a private copy of this bar.
438
+ */
439
+ brand?: ReactNode;
440
+ /**
441
+ * Extra controls in the right-hand cluster, before the language/theme
442
+ * pills — a GitHub link, a search button. Desktop only, matching the rest
443
+ * of that cluster; put the mobile equivalent in `mobileMenuHeader`.
444
+ */
445
+ actions?: ReactNode;
446
+ /** Rendered at the TOP of the mobile menu, above the links. */
447
+ mobileMenuHeader?: ReactNode;
448
+ /**
449
+ * The bottom region of the mobile menu, under the divider. Passing this
450
+ * REPLACES the automatic `languageSwitcher` row there — so a host that
451
+ * wants the language pill alongside something else (a GitHub link, a
452
+ * status chip) lays that row out itself instead of getting two rows.
453
+ * Leave it off and the language row appears on its own, as before.
454
+ */
455
+ mobileMenuFooter?: ReactNode;
456
+ /**
457
+ * Accessible name for the `<nav>` landmark. A page with more than one nav
458
+ * needs each one named, or a screen reader offers several identical
459
+ * "navigation" regions.
460
+ */
461
+ label?: string;
462
+ /** Extra classes on the `<nav>` element. */
463
+ className?: string;
425
464
  }
426
465
  /** Floating top navigation bar: logo, center links with scroll-spy, theme/language slots, and auth buttons with a mobile menu. */
427
- declare function Navbar({ appName, logoSrc, links, currentPath, variant, labels, languageSwitcher, themeToggle, homeHref, loginHref, signupHref, }: NavbarProps): React.JSX.Element;
466
+ declare function Navbar({ appName, logoSrc, links, currentPath, variant, labels, languageSwitcher, themeToggle, homeHref, loginHref, signupHref, account, brand, actions, mobileMenuHeader, mobileMenuFooter, label, className, }: NavbarProps): React.JSX.Element;
467
+
468
+ interface AccountMenuUser {
469
+ /** Display name. Falls back to `fallbackName` when absent. */
470
+ name?: string | null;
471
+ /** Shown under the name in the menu header. */
472
+ email?: string | null;
473
+ /** Avatar image URL; a glyph is shown when absent. */
474
+ avatarUrl?: string | null;
475
+ }
476
+ interface AccountMenuItem {
477
+ key: string;
478
+ label: ReactNode;
479
+ icon?: ElementType;
480
+ /** Navigate on select. */
481
+ href?: string;
482
+ /** Or run something on select (takes precedence over `href`). */
483
+ onSelect?: () => void;
484
+ }
485
+ interface AccountMenuProps {
486
+ /**
487
+ * The signed-in user, `null` when signed out, or `undefined` while the
488
+ * answer is still unknown.
489
+ *
490
+ * The three-state shape is the point: a session cookie is usually
491
+ * `httpOnly`, so the page cannot read it and only the server can answer.
492
+ * While it is `undefined` this renders a fixed-size placeholder rather than
493
+ * guessing — showing "sign in" first and swapping to an avatar makes every
494
+ * page load look like it signed the reader out.
495
+ */
496
+ user: AccountMenuUser | null | undefined;
497
+ /** Menu entries above the sign-out row. */
498
+ items?: AccountMenuItem[];
499
+ /** Where the signed-out button links. */
500
+ signInHref: string;
501
+ /** Called when the sign-out row is chosen. Omit to hide the row. */
502
+ onSignOut?: () => void;
503
+ /** Every string this renders — localize them yourself. */
504
+ labels?: {
505
+ signIn?: string;
506
+ signOut?: string;
507
+ /** Accessible name for the trigger, e.g. "{name} menu". */
508
+ menu?: string;
509
+ /** Shown when the user has no name. */
510
+ fallbackName?: string;
511
+ };
512
+ className?: string;
513
+ }
514
+ /**
515
+ * The navbar account control: a sign-in glyph when signed out, the reader's
516
+ * avatar when signed in, and a menu with their identity, your links and a
517
+ * sign-out row.
518
+ *
519
+ * Extracted from YunNEWS, which handles the signed-in swap better than the
520
+ * other apps — hence upstreaming it so they all get it. Purely presentational:
521
+ * the host fetches the session, supplies every label and owns each action.
522
+ */
523
+ declare function AccountMenu({ user, items, signInHref, onSignOut, labels, className, }: AccountMenuProps): React.JSX.Element;
428
524
 
429
- export { type AgentRunPhase, AgentRunStatus, type AgentRunStatusProps, AgentTimeline, type AgentTimelineBlock, type AgentTimelineIconName, type AgentTimelineProps, type AgentTimelineToolStatus, type ButtonProps, CapabilityIcon, CapabilitySelector, IDBadge, type LanguageOption, LanguageSwitcher, ModelAvatar, ModelCard, type ModelCardProps, ModelIcon, ModelManagerCard, type ModelManagerCardProps, type ModelManagerField, ModelSelect, type ModelSelectFilter, type ModelSelectLabels, type ModelSelectOption, type ModelSelectProps, ModelTypeIcon, type NavLink, Navbar, PROVIDER_ICON_SLUGS, ProviderAvatar, ProviderIcon, ProviderIconImg, ProviderNames, ThinkingBlock, buttonVariants, getDeveloperIconPath, getIconPath, getModelDeveloperId, getProviderIconOptions, getProviderName, isKnownCapability, normalizeProviderId };
525
+ export { AccountMenu, type AccountMenuItem, type AccountMenuProps, type AccountMenuUser, type AgentRunPhase, AgentRunStatus, type AgentRunStatusProps, AgentTimeline, type AgentTimelineBlock, type AgentTimelineIconName, type AgentTimelineProps, type AgentTimelineToolStatus, type ButtonProps, CapabilityIcon, CapabilitySelector, IDBadge, type LanguageOption, LanguageSwitcher, ModelAvatar, ModelCard, type ModelCardProps, ModelIcon, ModelManagerCard, type ModelManagerCardProps, type ModelManagerField, ModelSelect, type ModelSelectFilter, type ModelSelectLabels, type ModelSelectOption, type ModelSelectProps, ModelTypeIcon, type NavLink, Navbar, PROVIDER_ICON_SLUGS, ProviderAvatar, ProviderIcon, ProviderIconImg, ProviderNames, ThinkingBlock, buttonVariants, getDeveloperIconPath, getIconPath, getModelDeveloperId, getProviderIconOptions, getProviderName, isKnownCapability, normalizeProviderId };