@h-ai/ui 0.1.0-alpha.12 → 0.1.0-alpha.15
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 +20 -4
- package/dist/components/compounds/BottomNav.svelte +21 -1
- package/dist/components/compounds/BottomNav.svelte.d.ts +5 -0
- package/dist/components/primitives/Switch.svelte +5 -0
- package/dist/components/scenes/ai/AiDocumentDownloadMenu.svelte +1 -0
- package/dist/components/scenes/ai/AiDocumentEditor.svelte +1210 -145
- package/dist/components/scenes/ai/MarkdownRenderer.svelte +0 -4
- package/dist/components/scenes/ai/document-types.d.ts +28 -2
- package/dist/components/scenes/ai/editor-markdown-extensions.js +19 -4
- package/dist/components/scenes/crud/CrudFilterBar.svelte +1 -1
- package/dist/components/scenes/crud/CrudPage.svelte +27 -22
- package/dist/components/scenes/crud/CrudPage.svelte.d.ts +22 -15
- package/dist/components/scenes/crud/index.d.ts +2 -0
- package/dist/components/scenes/crud/index.js +1 -0
- package/dist/components/scenes/crud/nav-adapter.d.ts +36 -0
- package/dist/components/scenes/crud/nav-adapter.js +31 -0
- package/dist/components/scenes/crypto/EncryptedInput.svelte +2 -4
- package/dist/components/scenes/crypto/EncryptedInput.svelte.d.ts +1 -1
- package/dist/components/scenes/crypto/HashDisplay.svelte +1 -2
- package/dist/components/scenes/crypto/SignatureDisplay.svelte +1 -3
- package/dist/components/scenes/iam/UserProfile.svelte +7 -1
- package/dist/components/scenes/types.d.ts +3 -3
- package/dist/messages/en-US.json +5 -0
- package/dist/messages/zh-CN.json +5 -0
- package/dist/styles/mobile.css +28 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -49,7 +49,8 @@ export default defineConfig({
|
|
|
49
49
|
@import 'tailwindcss';
|
|
50
50
|
@import '@h-ai/ui/styles/global.css';
|
|
51
51
|
@import '@h-ai/ui/styles/theme.css';
|
|
52
|
-
@source "../node_modules/@h-ai/ui/dist/**/*.{svelte,ts}";
|
|
52
|
+
@source "../node_modules/@h-ai/ui/dist/**/*.{svelte,js,ts}";
|
|
53
|
+
@source "../../../node_modules/@h-ai/ui/dist/**/*.{svelte,js,ts}";
|
|
53
54
|
|
|
54
55
|
@plugin "daisyui" {
|
|
55
56
|
themes: light --default, dark --prefersdark, cupcake, emerald, corporate, nord, dracula, night;
|
|
@@ -61,7 +62,7 @@ export default defineConfig({
|
|
|
61
62
|
}
|
|
62
63
|
```
|
|
63
64
|
|
|
64
|
-
> `@source` 让 TailwindCSS 扫描 `@h-ai/ui` 组件中使用的 class
|
|
65
|
+
> `@source` 让 TailwindCSS 扫描 `@h-ai/ui` 组件中使用的 class 名,否则组件样式会丢失。嵌套应用位于 monorepo 中时,依赖包可能被提升到工作区根 `node_modules`,所以建议同时保留两条路径。
|
|
65
66
|
|
|
66
67
|
### 4. 使用组件
|
|
67
68
|
|
|
@@ -236,6 +237,8 @@ components/
|
|
|
236
237
|
| `HashDisplay` | 哈希展示 | `value`, `algorithm`, `copyable`, `truncate` |
|
|
237
238
|
| `SignatureDisplay` | 签名展示 | `signature`, `publicKey`, `algorithm`, `verified` |
|
|
238
239
|
|
|
240
|
+
默认算法与 `@h-ai/crypto` 对齐:加密输入使用 `SM4`,哈希展示使用 `SM3`,签名展示使用 `SM2`。
|
|
241
|
+
|
|
239
242
|
## 使用示例
|
|
240
243
|
|
|
241
244
|
### Toast 通知
|
|
@@ -376,7 +379,8 @@ components/
|
|
|
376
379
|
@import 'tailwindcss';
|
|
377
380
|
@import '@h-ai/ui/styles/global.css'; /* 基础重置、滚动条、焦点样式 */
|
|
378
381
|
@import '@h-ai/ui/styles/theme.css'; /* Tailwind v4 @theme Token(品牌色/阴影/动效) */
|
|
379
|
-
@source "../node_modules/@h-ai/ui/dist/**/*.{svelte,ts}";
|
|
382
|
+
@source "../node_modules/@h-ai/ui/dist/**/*.{svelte,js,ts}";
|
|
383
|
+
@source "../../../node_modules/@h-ai/ui/dist/**/*.{svelte,js,ts}";
|
|
380
384
|
|
|
381
385
|
/* 移动端项目追加(可选) */
|
|
382
386
|
@import '@h-ai/ui/styles/design-tokens.css'; /* CSS 自定义属性 */
|
|
@@ -391,7 +395,19 @@ components/
|
|
|
391
395
|
- `global.css`:基础 HTML 重置、滚动条美化、表单焦点环
|
|
392
396
|
- `theme.css`:Tailwind v4 `@theme` 块,包含品牌色、阴影层级、动效曲线、字体特性
|
|
393
397
|
- `design-tokens.css`:CSS 自定义属性(间距/圆角/z-index/过渡),移动端推荐
|
|
394
|
-
- `mobile.css`:安全区域 padding、momentum
|
|
398
|
+
- `mobile.css`:安全区域 padding、momentum 滚动、虚拟键盘适配、移动端 App 壳布局工具(`hai-mobile-viewport` / `hai-mobile-shell` / `hai-mobile-main`)
|
|
399
|
+
|
|
400
|
+
移动端页面推荐让 `BottomNav` 与页面壳宽度一致,避免桌面预览时底栏横跨整个视口:
|
|
401
|
+
|
|
402
|
+
```svelte
|
|
403
|
+
<div class="hai-mobile-viewport">
|
|
404
|
+
<div class="hai-mobile-shell max-w-lg">
|
|
405
|
+
<AppBar title="Home" fixed={false} safeArea />
|
|
406
|
+
<main class="hai-mobile-main">...</main>
|
|
407
|
+
<BottomNav items={items} active="home" centered maxWidth="lg" safeArea />
|
|
408
|
+
</div>
|
|
409
|
+
</div>
|
|
410
|
+
```
|
|
395
411
|
|
|
396
412
|
### 图标
|
|
397
413
|
|
|
@@ -11,6 +11,16 @@
|
|
|
11
11
|
// eslint-disable-next-line no-import-assign -- type re-export
|
|
12
12
|
export type { BottomNavItem }
|
|
13
13
|
|
|
14
|
+
type BottomNavMaxWidth = 'sm' | 'md' | 'lg' | 'xl' | 'none'
|
|
15
|
+
|
|
16
|
+
const MAX_WIDTH_CLASS: Record<BottomNavMaxWidth, string> = {
|
|
17
|
+
sm: 'max-w-sm',
|
|
18
|
+
md: 'max-w-md',
|
|
19
|
+
lg: 'max-w-lg',
|
|
20
|
+
xl: 'max-w-xl',
|
|
21
|
+
none: '',
|
|
22
|
+
}
|
|
23
|
+
|
|
14
24
|
interface Props {
|
|
15
25
|
/** 导航项列表 */
|
|
16
26
|
items: BottomNavItem[]
|
|
@@ -20,6 +30,10 @@
|
|
|
20
30
|
onchange?: (id: string) => void
|
|
21
31
|
/** 是否适配底部安全区域 */
|
|
22
32
|
safeArea?: boolean
|
|
33
|
+
/** 是否将 fixed 导航居中,适用于移动端仿真器/桌面预览中的窄屏壳 */
|
|
34
|
+
centered?: boolean
|
|
35
|
+
/** fixed 导航最大宽度,centered=true 时生效 */
|
|
36
|
+
maxWidth?: BottomNavMaxWidth
|
|
23
37
|
/** 额外 CSS 类 */
|
|
24
38
|
class?: string
|
|
25
39
|
}
|
|
@@ -29,13 +43,19 @@
|
|
|
29
43
|
active,
|
|
30
44
|
onchange,
|
|
31
45
|
safeArea = true,
|
|
46
|
+
centered = false,
|
|
47
|
+
maxWidth = 'none',
|
|
32
48
|
class: className,
|
|
33
49
|
}: Props = $props()
|
|
50
|
+
|
|
51
|
+
const constrained = $derived(centered && maxWidth !== 'none')
|
|
34
52
|
</script>
|
|
35
53
|
|
|
36
54
|
<nav
|
|
37
55
|
class={cn(
|
|
38
|
-
'fixed bottom-0
|
|
56
|
+
'fixed bottom-0 bg-base-100 border-t border-base-200 z-40',
|
|
57
|
+
constrained ? 'left-1/2 right-auto w-full -translate-x-1/2' : 'left-0 right-0',
|
|
58
|
+
constrained && MAX_WIDTH_CLASS[maxWidth],
|
|
39
59
|
safeArea && 'hai-safe-bottom',
|
|
40
60
|
className,
|
|
41
61
|
)}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BottomNavItem } from './bottom-nav-types.js';
|
|
2
|
+
type BottomNavMaxWidth = 'sm' | 'md' | 'lg' | 'xl' | 'none';
|
|
2
3
|
interface Props {
|
|
3
4
|
/** 导航项列表 */
|
|
4
5
|
items: BottomNavItem[];
|
|
@@ -8,6 +9,10 @@ interface Props {
|
|
|
8
9
|
onchange?: (id: string) => void;
|
|
9
10
|
/** 是否适配底部安全区域 */
|
|
10
11
|
safeArea?: boolean;
|
|
12
|
+
/** 是否将 fixed 导航居中,适用于移动端仿真器/桌面预览中的窄屏壳 */
|
|
13
|
+
centered?: boolean;
|
|
14
|
+
/** fixed 导航最大宽度,centered=true 时生效 */
|
|
15
|
+
maxWidth?: BottomNavMaxWidth;
|
|
11
16
|
/** 额外 CSS 类 */
|
|
12
17
|
class?: string;
|
|
13
18
|
}
|
|
@@ -22,10 +22,15 @@
|
|
|
22
22
|
|
|
23
23
|
const id = generateId('switch')
|
|
24
24
|
|
|
25
|
+
const hasToggleColorVariant = $derived(
|
|
26
|
+
/\btoggle-(?:primary|secondary|accent|neutral|success|warning|info|error)\b/.test(className),
|
|
27
|
+
)
|
|
28
|
+
|
|
25
29
|
const toggleClass = $derived(
|
|
26
30
|
cn(
|
|
27
31
|
'toggle',
|
|
28
32
|
getSizeClass(size, 'toggle'),
|
|
33
|
+
!hasToggleColorVariant && 'toggle-primary',
|
|
29
34
|
className,
|
|
30
35
|
),
|
|
31
36
|
)
|