@h-ai/ui 0.1.0-alpha5
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/LICENSE +202 -0
- package/README.md +488 -0
- package/auto-import.d.ts +96 -0
- package/auto-import.js +259 -0
- package/dist/components/compounds/Accordion.svelte +142 -0
- package/dist/components/compounds/Accordion.svelte.d.ts +25 -0
- package/dist/components/compounds/ActionSheet.svelte +116 -0
- package/dist/components/compounds/ActionSheet.svelte.d.ts +22 -0
- package/dist/components/compounds/Alert.svelte +67 -0
- package/dist/components/compounds/Alert.svelte.d.ts +8 -0
- package/dist/components/compounds/AppBar.svelte +77 -0
- package/dist/components/compounds/AppBar.svelte.d.ts +20 -0
- package/dist/components/compounds/BottomNav.svelte +75 -0
- package/dist/components/compounds/BottomNav.svelte.d.ts +18 -0
- package/dist/components/compounds/Breadcrumb.svelte +49 -0
- package/dist/components/compounds/Breadcrumb.svelte.d.ts +4 -0
- package/dist/components/compounds/Calendar.svelte +116 -0
- package/dist/components/compounds/Calendar.svelte.d.ts +47 -0
- package/dist/components/compounds/Card.svelte +77 -0
- package/dist/components/compounds/Card.svelte.d.ts +8 -0
- package/dist/components/compounds/Combobox.svelte +327 -0
- package/dist/components/compounds/Combobox.svelte.d.ts +69 -0
- package/dist/components/compounds/Confirm.svelte +90 -0
- package/dist/components/compounds/Confirm.svelte.d.ts +4 -0
- package/dist/components/compounds/DataTable.svelte +133 -0
- package/dist/components/compounds/DataTable.svelte.d.ts +69 -0
- package/dist/components/compounds/DatePicker.svelte +135 -0
- package/dist/components/compounds/DatePicker.svelte.d.ts +46 -0
- package/dist/components/compounds/Drawer.svelte +113 -0
- package/dist/components/compounds/Drawer.svelte.d.ts +4 -0
- package/dist/components/compounds/Dropdown.svelte +91 -0
- package/dist/components/compounds/Dropdown.svelte.d.ts +8 -0
- package/dist/components/compounds/Empty.svelte +83 -0
- package/dist/components/compounds/Empty.svelte.d.ts +4 -0
- package/dist/components/compounds/Form.svelte +96 -0
- package/dist/components/compounds/Form.svelte.d.ts +7 -0
- package/dist/components/compounds/FormField.svelte +56 -0
- package/dist/components/compounds/FormField.svelte.d.ts +4 -0
- package/dist/components/compounds/InfiniteScroll.svelte +82 -0
- package/dist/components/compounds/InfiniteScroll.svelte.d.ts +22 -0
- package/dist/components/compounds/Modal.svelte +123 -0
- package/dist/components/compounds/Modal.svelte.d.ts +8 -0
- package/dist/components/compounds/PageHeader.svelte +44 -0
- package/dist/components/compounds/PageHeader.svelte.d.ts +28 -0
- package/dist/components/compounds/Pagination.svelte +157 -0
- package/dist/components/compounds/Pagination.svelte.d.ts +4 -0
- package/dist/components/compounds/Popover.svelte +137 -0
- package/dist/components/compounds/Popover.svelte.d.ts +4 -0
- package/dist/components/compounds/PullRefresh.svelte +98 -0
- package/dist/components/compounds/PullRefresh.svelte.d.ts +16 -0
- package/dist/components/compounds/Result.svelte +84 -0
- package/dist/components/compounds/Result.svelte.d.ts +4 -0
- package/dist/components/compounds/SafeArea.svelte +37 -0
- package/dist/components/compounds/SafeArea.svelte.d.ts +12 -0
- package/dist/components/compounds/Skeleton.svelte +75 -0
- package/dist/components/compounds/Skeleton.svelte.d.ts +8 -0
- package/dist/components/compounds/Steps.svelte +111 -0
- package/dist/components/compounds/Steps.svelte.d.ts +4 -0
- package/dist/components/compounds/SwipeCell.svelte +115 -0
- package/dist/components/compounds/SwipeCell.svelte.d.ts +19 -0
- package/dist/components/compounds/Tabs.svelte +79 -0
- package/dist/components/compounds/Tabs.svelte.d.ts +8 -0
- package/dist/components/compounds/TagInput.svelte +108 -0
- package/dist/components/compounds/TagInput.svelte.d.ts +4 -0
- package/dist/components/compounds/Timeline.svelte +167 -0
- package/dist/components/compounds/Timeline.svelte.d.ts +25 -0
- package/dist/components/compounds/ToastContainer.svelte +59 -0
- package/dist/components/compounds/ToastContainer.svelte.d.ts +3 -0
- package/dist/components/compounds/Tooltip.svelte +41 -0
- package/dist/components/compounds/Tooltip.svelte.d.ts +4 -0
- package/dist/components/compounds/accordion-types.d.ts +16 -0
- package/dist/components/compounds/accordion-types.js +5 -0
- package/dist/components/compounds/action-sheet-types.d.ts +14 -0
- package/dist/components/compounds/action-sheet-types.js +5 -0
- package/dist/components/compounds/bottom-nav-types.d.ts +17 -0
- package/dist/components/compounds/bottom-nav-types.js +5 -0
- package/dist/components/compounds/index.d.ts +44 -0
- package/dist/components/compounds/index.js +54 -0
- package/dist/components/compounds/swipe-cell-types.d.ts +14 -0
- package/dist/components/compounds/swipe-cell-types.js +5 -0
- package/dist/components/compounds/timeline-types.d.ts +20 -0
- package/dist/components/compounds/timeline-types.js +5 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.js +12 -0
- package/dist/components/primitives/Avatar.svelte +102 -0
- package/dist/components/primitives/Avatar.svelte.d.ts +8 -0
- package/dist/components/primitives/Badge.svelte +33 -0
- package/dist/components/primitives/Badge.svelte.d.ts +8 -0
- package/dist/components/primitives/BareButton.svelte +45 -0
- package/dist/components/primitives/BareButton.svelte.d.ts +4 -0
- package/dist/components/primitives/BareInput.svelte +101 -0
- package/dist/components/primitives/BareInput.svelte.d.ts +4 -0
- package/dist/components/primitives/Button.svelte +60 -0
- package/dist/components/primitives/Button.svelte.d.ts +8 -0
- package/dist/components/primitives/Checkbox.svelte +58 -0
- package/dist/components/primitives/Checkbox.svelte.d.ts +4 -0
- package/dist/components/primitives/IconButton.svelte +105 -0
- package/dist/components/primitives/IconButton.svelte.d.ts +4 -0
- package/dist/components/primitives/Input.svelte +130 -0
- package/dist/components/primitives/Input.svelte.d.ts +8 -0
- package/dist/components/primitives/Progress.svelte +58 -0
- package/dist/components/primitives/Progress.svelte.d.ts +4 -0
- package/dist/components/primitives/Radio.svelte +60 -0
- package/dist/components/primitives/Radio.svelte.d.ts +25 -0
- package/dist/components/primitives/Range.svelte +117 -0
- package/dist/components/primitives/Range.svelte.d.ts +27 -0
- package/dist/components/primitives/Rating.svelte +148 -0
- package/dist/components/primitives/Rating.svelte.d.ts +27 -0
- package/dist/components/primitives/Select.svelte +95 -0
- package/dist/components/primitives/Select.svelte.d.ts +25 -0
- package/dist/components/primitives/Spinner.svelte +54 -0
- package/dist/components/primitives/Spinner.svelte.d.ts +4 -0
- package/dist/components/primitives/Switch.svelte +53 -0
- package/dist/components/primitives/Switch.svelte.d.ts +4 -0
- package/dist/components/primitives/Tag.svelte +64 -0
- package/dist/components/primitives/Tag.svelte.d.ts +4 -0
- package/dist/components/primitives/Textarea.svelte +92 -0
- package/dist/components/primitives/Textarea.svelte.d.ts +4 -0
- package/dist/components/primitives/ToggleCheckbox.svelte +36 -0
- package/dist/components/primitives/ToggleCheckbox.svelte.d.ts +4 -0
- package/dist/components/primitives/ToggleInput.svelte +36 -0
- package/dist/components/primitives/ToggleInput.svelte.d.ts +4 -0
- package/dist/components/primitives/ToggleRadio.svelte +36 -0
- package/dist/components/primitives/ToggleRadio.svelte.d.ts +4 -0
- package/dist/components/primitives/index.d.ts +26 -0
- package/dist/components/primitives/index.js +30 -0
- package/dist/components/scenes/ai/AiDocumentDownloadMenu.svelte +387 -0
- package/dist/components/scenes/ai/AiDocumentDownloadMenu.svelte.d.ts +38 -0
- package/dist/components/scenes/ai/AiDocumentEditor.svelte +2259 -0
- package/dist/components/scenes/ai/AiDocumentEditor.svelte.d.ts +4 -0
- package/dist/components/scenes/ai/MarkdownRenderer.svelte +460 -0
- package/dist/components/scenes/ai/MarkdownRenderer.svelte.d.ts +4 -0
- package/dist/components/scenes/ai/document-download.d.ts +40 -0
- package/dist/components/scenes/ai/document-download.js +300 -0
- package/dist/components/scenes/ai/document-parse.d.ts +28 -0
- package/dist/components/scenes/ai/document-parse.js +243 -0
- package/dist/components/scenes/ai/document-types.d.ts +164 -0
- package/dist/components/scenes/ai/document-types.js +1 -0
- package/dist/components/scenes/ai/index.d.ts +17 -0
- package/dist/components/scenes/ai/index.js +13 -0
- package/dist/components/scenes/ai/markdown-parse.d.ts +32 -0
- package/dist/components/scenes/ai/markdown-parse.js +161 -0
- package/dist/components/scenes/app/FeedbackModal.svelte +160 -0
- package/dist/components/scenes/app/FeedbackModal.svelte.d.ts +47 -0
- package/dist/components/scenes/app/LanguageSwitch.svelte +136 -0
- package/dist/components/scenes/app/LanguageSwitch.svelte.d.ts +50 -0
- package/dist/components/scenes/app/SettingsModal.svelte +174 -0
- package/dist/components/scenes/app/SettingsModal.svelte.d.ts +31 -0
- package/dist/components/scenes/app/ThemeSelector.svelte +176 -0
- package/dist/components/scenes/app/ThemeSelector.svelte.d.ts +31 -0
- package/dist/components/scenes/app/ThemeToggle.svelte +76 -0
- package/dist/components/scenes/app/ThemeToggle.svelte.d.ts +29 -0
- package/dist/components/scenes/app/index.d.ts +11 -0
- package/dist/components/scenes/app/index.js +11 -0
- package/dist/components/scenes/crud/CrudDeleteConfirm.svelte +39 -0
- package/dist/components/scenes/crud/CrudDeleteConfirm.svelte.d.ts +18 -0
- package/dist/components/scenes/crud/CrudDetailDrawer.svelte +155 -0
- package/dist/components/scenes/crud/CrudDetailDrawer.svelte.d.ts +38 -0
- package/dist/components/scenes/crud/CrudEditDrawer.svelte +222 -0
- package/dist/components/scenes/crud/CrudEditDrawer.svelte.d.ts +48 -0
- package/dist/components/scenes/crud/CrudFilterBar.svelte +96 -0
- package/dist/components/scenes/crud/CrudFilterBar.svelte.d.ts +31 -0
- package/dist/components/scenes/crud/CrudPage.svelte +499 -0
- package/dist/components/scenes/crud/CrudPage.svelte.d.ts +114 -0
- package/dist/components/scenes/crud/crud-types.d.ts +135 -0
- package/dist/components/scenes/crud/crud-types.js +7 -0
- package/dist/components/scenes/crud/index.d.ts +12 -0
- package/dist/components/scenes/crud/index.js +11 -0
- package/dist/components/scenes/crypto/EncryptedInput.svelte +156 -0
- package/dist/components/scenes/crypto/EncryptedInput.svelte.d.ts +32 -0
- package/dist/components/scenes/crypto/HashDisplay.svelte +97 -0
- package/dist/components/scenes/crypto/HashDisplay.svelte.d.ts +4 -0
- package/dist/components/scenes/crypto/SignatureDisplay.svelte +161 -0
- package/dist/components/scenes/crypto/SignatureDisplay.svelte.d.ts +4 -0
- package/dist/components/scenes/crypto/index.d.ts +9 -0
- package/dist/components/scenes/crypto/index.js +11 -0
- package/dist/components/scenes/iam/ChangePasswordForm.svelte +134 -0
- package/dist/components/scenes/iam/ChangePasswordForm.svelte.d.ts +8 -0
- package/dist/components/scenes/iam/ForgotPasswordForm.svelte +147 -0
- package/dist/components/scenes/iam/ForgotPasswordForm.svelte.d.ts +4 -0
- package/dist/components/scenes/iam/LoginForm.svelte +191 -0
- package/dist/components/scenes/iam/LoginForm.svelte.d.ts +8 -0
- package/dist/components/scenes/iam/PasswordInput.svelte +203 -0
- package/dist/components/scenes/iam/PasswordInput.svelte.d.ts +49 -0
- package/dist/components/scenes/iam/PermGuard.svelte +69 -0
- package/dist/components/scenes/iam/PermGuard.svelte.d.ts +16 -0
- package/dist/components/scenes/iam/RegisterForm.svelte +269 -0
- package/dist/components/scenes/iam/RegisterForm.svelte.d.ts +8 -0
- package/dist/components/scenes/iam/ResetPasswordForm.svelte +153 -0
- package/dist/components/scenes/iam/ResetPasswordForm.svelte.d.ts +8 -0
- package/dist/components/scenes/iam/UserProfile.svelte +251 -0
- package/dist/components/scenes/iam/UserProfile.svelte.d.ts +4 -0
- package/dist/components/scenes/iam/index.d.ts +16 -0
- package/dist/components/scenes/iam/index.js +18 -0
- package/dist/components/scenes/iam/password-utils.d.ts +15 -0
- package/dist/components/scenes/iam/password-utils.js +19 -0
- package/dist/components/scenes/iam/permission-context.svelte.d.ts +90 -0
- package/dist/components/scenes/iam/permission-context.svelte.js +114 -0
- package/dist/components/scenes/index.d.ts +13 -0
- package/dist/components/scenes/index.js +20 -0
- package/dist/components/scenes/storage/AvatarUpload.svelte +218 -0
- package/dist/components/scenes/storage/AvatarUpload.svelte.d.ts +4 -0
- package/dist/components/scenes/storage/FileList.svelte +260 -0
- package/dist/components/scenes/storage/FileList.svelte.d.ts +4 -0
- package/dist/components/scenes/storage/FileUpload.svelte +400 -0
- package/dist/components/scenes/storage/FileUpload.svelte.d.ts +7 -0
- package/dist/components/scenes/storage/ImageUpload.svelte +285 -0
- package/dist/components/scenes/storage/ImageUpload.svelte.d.ts +4 -0
- package/dist/components/scenes/storage/index.d.ts +10 -0
- package/dist/components/scenes/storage/index.js +12 -0
- package/dist/components/scenes/types.d.ts +583 -0
- package/dist/components/scenes/types.js +7 -0
- package/dist/i18n.svelte.d.ts +44 -0
- package/dist/i18n.svelte.js +108 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +19 -0
- package/dist/messages/en-US.json +242 -0
- package/dist/messages/zh-CN.json +242 -0
- package/dist/messages.d.ts +29 -0
- package/dist/messages.js +42 -0
- package/dist/styles/design-tokens.css +58 -0
- package/dist/styles/global.css +218 -0
- package/dist/styles/mobile.css +105 -0
- package/dist/theme-config.d.ts +92 -0
- package/dist/theme-config.js +122 -0
- package/dist/toast.svelte.d.ts +45 -0
- package/dist/toast.svelte.js +77 -0
- package/dist/types.d.ts +944 -0
- package/dist/types.js +7 -0
- package/dist/utils/platform.svelte.d.ts +54 -0
- package/dist/utils/platform.svelte.js +87 -0
- package/dist/utils.d.ts +46 -0
- package/dist/utils.js +100 -0
- package/package.json +69 -0
package/dist/messages.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @h-ai/ui — 内置消息获取器
|
|
3
|
+
*
|
|
4
|
+
* 为 UI 组件提供内置的多语言翻译支持
|
|
5
|
+
* @module messages
|
|
6
|
+
*/
|
|
7
|
+
import { core } from '@h-ai/core';
|
|
8
|
+
// 导入消息文件
|
|
9
|
+
import messagesEnUS from './messages/en-US.json';
|
|
10
|
+
import messagesZhCN from './messages/zh-CN.json';
|
|
11
|
+
// 创建消息获取器
|
|
12
|
+
const getMessage = core.i18n.createMessageGetter({
|
|
13
|
+
'zh-CN': messagesZhCN,
|
|
14
|
+
'en-US': messagesEnUS,
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* 获取 UI 组件翻译消息
|
|
18
|
+
*
|
|
19
|
+
* @param key - 消息 key
|
|
20
|
+
* @param params - 可选的插值参数
|
|
21
|
+
* @returns 当前 locale 对应的翻译文本
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* uiM('password_show') // => '显示密码' (zh-CN) 或 'Show password' (en-US)
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function uiM(key, params) {
|
|
29
|
+
return getMessage(key, params ? { params } : undefined);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 获取当前 UI 模块使用的 locale
|
|
33
|
+
*/
|
|
34
|
+
export function getUILocale() {
|
|
35
|
+
return core.i18n.getGlobalLocale();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 手动设置 UI 模块的 locale(通常不需要,会自动同步)
|
|
39
|
+
*/
|
|
40
|
+
export function setUILocale(locale) {
|
|
41
|
+
core.i18n.setGlobalLocale(locale);
|
|
42
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* =============================================================================
|
|
3
|
+
* @hai/ui - Design Token 系统
|
|
4
|
+
* =============================================================================
|
|
5
|
+
* 所有视觉变量通过 CSS Variables 定义,多端复用。
|
|
6
|
+
*
|
|
7
|
+
* 在 app.css 中导入:
|
|
8
|
+
* @import '@hai/ui/styles/design-tokens.css';
|
|
9
|
+
* =============================================================================
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
:root {
|
|
13
|
+
/* ─── 间距 ─── */
|
|
14
|
+
--hai-spacing-xs: 4px;
|
|
15
|
+
--hai-spacing-sm: 8px;
|
|
16
|
+
--hai-spacing-md: 16px;
|
|
17
|
+
--hai-spacing-lg: 24px;
|
|
18
|
+
--hai-spacing-xl: 32px;
|
|
19
|
+
|
|
20
|
+
/* ─── 圆角 ─── */
|
|
21
|
+
--hai-radius-sm: 4px;
|
|
22
|
+
--hai-radius-md: 8px;
|
|
23
|
+
--hai-radius-lg: 16px;
|
|
24
|
+
--hai-radius-full: 9999px;
|
|
25
|
+
|
|
26
|
+
/* ─── 字体大小 ─── */
|
|
27
|
+
--hai-font-size-xs: 12px;
|
|
28
|
+
--hai-font-size-sm: 14px;
|
|
29
|
+
--hai-font-size-md: 16px;
|
|
30
|
+
--hai-font-size-lg: 18px;
|
|
31
|
+
--hai-font-size-xl: 20px;
|
|
32
|
+
--hai-font-size-2xl: 24px;
|
|
33
|
+
|
|
34
|
+
/* ─── 最小点击区域 ─── */
|
|
35
|
+
--hai-touch-target-min: 44px;
|
|
36
|
+
|
|
37
|
+
/* ─── 安全区域 ─── */
|
|
38
|
+
--hai-safe-area-top: env(safe-area-inset-top, 0px);
|
|
39
|
+
--hai-safe-area-bottom: env(safe-area-inset-bottom, 0px);
|
|
40
|
+
--hai-safe-area-left: env(safe-area-inset-left, 0px);
|
|
41
|
+
--hai-safe-area-right: env(safe-area-inset-right, 0px);
|
|
42
|
+
|
|
43
|
+
/* ─── z-index 层级 ─── */
|
|
44
|
+
--hai-z-dropdown: 1000;
|
|
45
|
+
--hai-z-modal: 1100;
|
|
46
|
+
--hai-z-toast: 1200;
|
|
47
|
+
--hai-z-tooltip: 1300;
|
|
48
|
+
|
|
49
|
+
/* ─── 动画时长 ─── */
|
|
50
|
+
--hai-transition-fast: 150ms;
|
|
51
|
+
--hai-transition-normal: 250ms;
|
|
52
|
+
--hai-transition-slow: 350ms;
|
|
53
|
+
|
|
54
|
+
/* ─── 阴影 ─── */
|
|
55
|
+
--hai-shadow-sm: 0 1px 2px 0 oklch(0 0 0 / 0.05);
|
|
56
|
+
--hai-shadow-md: 0 4px 6px -1px oklch(0 0 0 / 0.1);
|
|
57
|
+
--hai-shadow-lg: 0 10px 15px -3px oklch(0 0 0 / 0.1);
|
|
58
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* =============================================================================
|
|
3
|
+
* @hai/ui - 全局样式
|
|
4
|
+
* =============================================================================
|
|
5
|
+
* 可选的全局样式增强,消费应用可通过以下方式导入:
|
|
6
|
+
*
|
|
7
|
+
* 在 app.css 中:
|
|
8
|
+
* @import '@hai/ui/styles/global.css';
|
|
9
|
+
* =============================================================================
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/* ─── 滚动条 ─── */
|
|
13
|
+
::-webkit-scrollbar {
|
|
14
|
+
width: 5px;
|
|
15
|
+
height: 5px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
::-webkit-scrollbar-track {
|
|
19
|
+
background: transparent;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
::-webkit-scrollbar-thumb {
|
|
23
|
+
background: oklch(0.7 0 0 / 0.2);
|
|
24
|
+
border-radius: 9999px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
::-webkit-scrollbar-thumb:hover {
|
|
28
|
+
background: oklch(0.55 0 0 / 0.35);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* ─── 基础 ─── */
|
|
32
|
+
html {
|
|
33
|
+
scroll-behavior: smooth;
|
|
34
|
+
-webkit-font-smoothing: antialiased;
|
|
35
|
+
-moz-osx-font-smoothing: grayscale;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* ─── 表单焦点 ─── */
|
|
39
|
+
.input:focus,
|
|
40
|
+
.select:focus,
|
|
41
|
+
.textarea:focus {
|
|
42
|
+
outline: none;
|
|
43
|
+
box-shadow: 0 0 0 2px oklch(var(--p) / 0.15);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* ─── 隐藏浏览器原生密码显示按钮(使用自定义切换) ─── */
|
|
47
|
+
input::-ms-reveal,
|
|
48
|
+
input::-ms-clear {
|
|
49
|
+
display: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* ─── 卡片 ─── */
|
|
53
|
+
.card {
|
|
54
|
+
transition:
|
|
55
|
+
box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1),
|
|
56
|
+
transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* ─── 按钮 ─── */
|
|
60
|
+
.btn {
|
|
61
|
+
transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* ─── 动画 keyframes ─── */
|
|
65
|
+
@keyframes hai-fade-in {
|
|
66
|
+
from {
|
|
67
|
+
opacity: 0;
|
|
68
|
+
}
|
|
69
|
+
to {
|
|
70
|
+
opacity: 1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@keyframes hai-fade-out {
|
|
75
|
+
from {
|
|
76
|
+
opacity: 1;
|
|
77
|
+
}
|
|
78
|
+
to {
|
|
79
|
+
opacity: 0;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@keyframes hai-slide-up {
|
|
84
|
+
from {
|
|
85
|
+
opacity: 0;
|
|
86
|
+
transform: translateY(6px);
|
|
87
|
+
}
|
|
88
|
+
to {
|
|
89
|
+
opacity: 1;
|
|
90
|
+
transform: translateY(0);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@keyframes hai-slide-down {
|
|
95
|
+
from {
|
|
96
|
+
opacity: 0;
|
|
97
|
+
transform: translateY(-6px);
|
|
98
|
+
}
|
|
99
|
+
to {
|
|
100
|
+
opacity: 1;
|
|
101
|
+
transform: translateY(0);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@keyframes hai-scale-in {
|
|
106
|
+
from {
|
|
107
|
+
opacity: 0;
|
|
108
|
+
transform: scale(0.96);
|
|
109
|
+
}
|
|
110
|
+
to {
|
|
111
|
+
opacity: 1;
|
|
112
|
+
transform: scale(1);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@keyframes hai-scale-out {
|
|
117
|
+
from {
|
|
118
|
+
opacity: 1;
|
|
119
|
+
transform: scale(1);
|
|
120
|
+
}
|
|
121
|
+
to {
|
|
122
|
+
opacity: 0;
|
|
123
|
+
transform: scale(0.96);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@keyframes hai-slide-in-right {
|
|
128
|
+
from {
|
|
129
|
+
opacity: 0;
|
|
130
|
+
transform: translateX(100%);
|
|
131
|
+
}
|
|
132
|
+
to {
|
|
133
|
+
opacity: 1;
|
|
134
|
+
transform: translateX(0);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@keyframes hai-slide-out-right {
|
|
139
|
+
from {
|
|
140
|
+
opacity: 1;
|
|
141
|
+
transform: translateX(0);
|
|
142
|
+
}
|
|
143
|
+
to {
|
|
144
|
+
opacity: 0;
|
|
145
|
+
transform: translateX(100%);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@keyframes hai-shimmer {
|
|
150
|
+
0% {
|
|
151
|
+
background-position: 200% 0;
|
|
152
|
+
}
|
|
153
|
+
100% {
|
|
154
|
+
background-position: -200% 0;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* ─── 动画工具类 ─── */
|
|
159
|
+
.hai-fade-in {
|
|
160
|
+
animation: hai-fade-in 0.2s cubic-bezier(0.4, 0, 0.2, 1) both;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.hai-fade-out {
|
|
164
|
+
animation: hai-fade-out 0.15s cubic-bezier(0.4, 0, 0.2, 1) both;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.hai-slide-up {
|
|
168
|
+
animation: hai-slide-up 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.hai-slide-down {
|
|
172
|
+
animation: hai-slide-down 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.hai-scale-in {
|
|
176
|
+
animation: hai-scale-in 0.15s cubic-bezier(0.16, 1, 0.3, 1) both;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.hai-scale-out {
|
|
180
|
+
animation: hai-scale-out 0.1s cubic-bezier(0.4, 0, 0.2, 1) both;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.hai-slide-in-right {
|
|
184
|
+
animation: hai-slide-in-right 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.hai-slide-out-right {
|
|
188
|
+
animation: hai-slide-out-right 0.2s cubic-bezier(0.4, 0, 0.2, 1) both;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* 兼容旧动画类名 */
|
|
192
|
+
.animate-slide-in-from-right {
|
|
193
|
+
animation: hai-slide-in-right 0.3s ease-out;
|
|
194
|
+
}
|
|
195
|
+
.animate-slide-out-to-right {
|
|
196
|
+
animation: hai-slide-out-right 0.3s ease-in forwards;
|
|
197
|
+
}
|
|
198
|
+
.animate-fade-in {
|
|
199
|
+
animation: hai-fade-in 0.2s ease-out;
|
|
200
|
+
}
|
|
201
|
+
.animate-fade-out {
|
|
202
|
+
animation: hai-fade-out 0.2s ease-in forwards;
|
|
203
|
+
}
|
|
204
|
+
.animate-in {
|
|
205
|
+
animation-duration: 0.3s;
|
|
206
|
+
animation-timing-function: ease-out;
|
|
207
|
+
animation-fill-mode: both;
|
|
208
|
+
}
|
|
209
|
+
.slide-in-from-right {
|
|
210
|
+
animation-name: hai-slide-in-right;
|
|
211
|
+
}
|
|
212
|
+
.slide-in-from-left {
|
|
213
|
+
animation-name: hai-slide-in-right;
|
|
214
|
+
animation-direction: reverse;
|
|
215
|
+
}
|
|
216
|
+
.fade-in {
|
|
217
|
+
animation-name: hai-fade-in;
|
|
218
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* =============================================================================
|
|
3
|
+
* @hai/ui - 移动端全局样式
|
|
4
|
+
* =============================================================================
|
|
5
|
+
* 触摸优化、安全区域、点击区域增强。
|
|
6
|
+
*
|
|
7
|
+
* 在 app.css 中导入:
|
|
8
|
+
* @import '@hai/ui/styles/mobile.css';
|
|
9
|
+
* =============================================================================
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/* ─── 全局触摸优化 ─── */
|
|
13
|
+
* {
|
|
14
|
+
-webkit-tap-highlight-color: transparent;
|
|
15
|
+
touch-action: manipulation;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* ─── Hover 仅在支持鼠标设备上生效 ─── */
|
|
19
|
+
@media (hover: hover) and (pointer: fine) {
|
|
20
|
+
.hai-hover\:opacity:hover {
|
|
21
|
+
opacity: 0.8;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* ─── 移动端最小点击区域(Apple HIG 44x44) ─── */
|
|
26
|
+
@media (pointer: coarse) {
|
|
27
|
+
.btn,
|
|
28
|
+
.input,
|
|
29
|
+
.select,
|
|
30
|
+
.checkbox,
|
|
31
|
+
.radio,
|
|
32
|
+
.toggle {
|
|
33
|
+
min-height: var(--hai-touch-target-min, 44px);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* DaisyUI btn 尺寸覆盖 */
|
|
37
|
+
.btn-sm {
|
|
38
|
+
min-height: 36px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.btn-xs {
|
|
42
|
+
min-height: 32px;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* ─── 安全区域 padding 工具类 ─── */
|
|
47
|
+
.hai-safe-top {
|
|
48
|
+
padding-top: var(--hai-safe-area-top);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.hai-safe-bottom {
|
|
52
|
+
padding-bottom: var(--hai-safe-area-bottom);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.hai-safe-left {
|
|
56
|
+
padding-left: var(--hai-safe-area-left);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.hai-safe-right {
|
|
60
|
+
padding-right: var(--hai-safe-area-right);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.hai-safe-x {
|
|
64
|
+
padding-left: var(--hai-safe-area-left);
|
|
65
|
+
padding-right: var(--hai-safe-area-right);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.hai-safe-y {
|
|
69
|
+
padding-top: var(--hai-safe-area-top);
|
|
70
|
+
padding-bottom: var(--hai-safe-area-bottom);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.hai-safe-all {
|
|
74
|
+
padding-top: var(--hai-safe-area-top);
|
|
75
|
+
padding-bottom: var(--hai-safe-area-bottom);
|
|
76
|
+
padding-left: var(--hai-safe-area-left);
|
|
77
|
+
padding-right: var(--hai-safe-area-right);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* ─── 虚拟键盘适配 ─── */
|
|
81
|
+
.hai-keyboard-aware {
|
|
82
|
+
transition: padding-bottom var(--hai-transition-normal, 250ms) ease;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* ─── 禁止文本选择(在交互元素上) ─── */
|
|
86
|
+
.hai-no-select {
|
|
87
|
+
-webkit-user-select: none;
|
|
88
|
+
user-select: none;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* ─── 移动端滚动容器 ─── */
|
|
92
|
+
.hai-scroll-x {
|
|
93
|
+
overflow-x: auto;
|
|
94
|
+
-webkit-overflow-scrolling: touch;
|
|
95
|
+
scrollbar-width: none;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.hai-scroll-x::-webkit-scrollbar {
|
|
99
|
+
display: none;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.hai-scroll-y {
|
|
103
|
+
overflow-y: auto;
|
|
104
|
+
-webkit-overflow-scrolling: touch;
|
|
105
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @h-ai/ui — 主题配置
|
|
3
|
+
*
|
|
4
|
+
* DaisyUI 主题元数据和配置
|
|
5
|
+
* @module theme-config
|
|
6
|
+
*/
|
|
7
|
+
import type { UIMessageKey } from './messages.js';
|
|
8
|
+
/**
|
|
9
|
+
* 主题信息
|
|
10
|
+
*/
|
|
11
|
+
export interface ThemeInfo {
|
|
12
|
+
/** 主题标识符 */
|
|
13
|
+
id: string;
|
|
14
|
+
/** 显示名称 */
|
|
15
|
+
name: string;
|
|
16
|
+
/** 是否为暗色主题 */
|
|
17
|
+
dark: boolean;
|
|
18
|
+
/** 主题色(用于预览) */
|
|
19
|
+
primaryColor: string;
|
|
20
|
+
/** 背景色(用于预览) */
|
|
21
|
+
bgColor: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 主题分组
|
|
25
|
+
*/
|
|
26
|
+
export interface ThemeGroup {
|
|
27
|
+
/** 分组标识 */
|
|
28
|
+
id: string;
|
|
29
|
+
/** 分组名称 i18n key */
|
|
30
|
+
nameKey: UIMessageKey;
|
|
31
|
+
/** 分组内的主题 */
|
|
32
|
+
themes: ThemeInfo[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* DaisyUI 内置主题配置(精选)
|
|
36
|
+
*/
|
|
37
|
+
export declare const THEMES: ThemeInfo[];
|
|
38
|
+
/**
|
|
39
|
+
* 主题分组配置
|
|
40
|
+
*/
|
|
41
|
+
export declare const THEME_GROUPS: ThemeGroup[];
|
|
42
|
+
/**
|
|
43
|
+
* 暗色主题列表
|
|
44
|
+
*/
|
|
45
|
+
export declare const DARK_THEMES: string[];
|
|
46
|
+
/**
|
|
47
|
+
* 获取主题信息
|
|
48
|
+
*/
|
|
49
|
+
export declare function getThemeInfo(themeId: string): ThemeInfo | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* 检查是否为暗色主题
|
|
52
|
+
*/
|
|
53
|
+
export declare function isDarkTheme(themeId: string): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* 默认主题
|
|
56
|
+
*/
|
|
57
|
+
export declare const DEFAULT_THEME = "light";
|
|
58
|
+
/**
|
|
59
|
+
* 主题存储键名
|
|
60
|
+
*/
|
|
61
|
+
export declare const THEME_STORAGE_KEY = "theme";
|
|
62
|
+
/**
|
|
63
|
+
* 获取主题初始化脚本(用于 app.html 防闪烁)
|
|
64
|
+
*
|
|
65
|
+
* 使用方式:在 app.html 的 <head> 中添加 <script>{getThemeInitScript()}</script>
|
|
66
|
+
*/
|
|
67
|
+
export declare function getThemeInitScript(): string;
|
|
68
|
+
/**
|
|
69
|
+
* 应用主题
|
|
70
|
+
* @param theme - 主题 ID
|
|
71
|
+
* @param persist - 是否持久化到 localStorage
|
|
72
|
+
*/
|
|
73
|
+
export declare function applyTheme(theme: string, persist?: boolean): void;
|
|
74
|
+
/**
|
|
75
|
+
* 获取当前主题
|
|
76
|
+
*/
|
|
77
|
+
export declare function getCurrentTheme(): string;
|
|
78
|
+
/**
|
|
79
|
+
* 获取保存的主题(从 localStorage)
|
|
80
|
+
*/
|
|
81
|
+
export declare function getSavedTheme(): string;
|
|
82
|
+
/**
|
|
83
|
+
* DaisyUI 主题配置字符串(用于 app.css)
|
|
84
|
+
*
|
|
85
|
+
* 注意:Tailwind CSS v4 要求主题在 CSS 中声明,无法通过 JS 动态注入
|
|
86
|
+
* 消费应用需要在 app.css 中添加:
|
|
87
|
+
*
|
|
88
|
+
* @plugin "daisyui" {
|
|
89
|
+
* themes: light --default, dark --prefersdark, cupcake, bumblebee, ...
|
|
90
|
+
* }
|
|
91
|
+
*/
|
|
92
|
+
export declare const DAISYUI_THEMES_CONFIG: string;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @h-ai/ui — 主题配置
|
|
3
|
+
*
|
|
4
|
+
* DaisyUI 主题元数据和配置
|
|
5
|
+
* @module theme-config
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* DaisyUI 内置主题配置(精选)
|
|
9
|
+
*/
|
|
10
|
+
export const THEMES = [
|
|
11
|
+
// 亮色主题
|
|
12
|
+
{ id: 'light', name: 'Light', dark: false, primaryColor: '#570df8', bgColor: '#ffffff' },
|
|
13
|
+
{ id: 'cupcake', name: 'Cupcake', dark: false, primaryColor: '#65c3c8', bgColor: '#faf7f5' },
|
|
14
|
+
{ id: 'emerald', name: 'Emerald', dark: false, primaryColor: '#66cc8a', bgColor: '#ffffff' },
|
|
15
|
+
{ id: 'corporate', name: 'Corporate', dark: false, primaryColor: '#4b6bfb', bgColor: '#ffffff' },
|
|
16
|
+
{ id: 'lofi', name: 'Lo-Fi', dark: false, primaryColor: '#0d0d0d', bgColor: '#ffffff' },
|
|
17
|
+
{ id: 'winter', name: 'Winter', dark: false, primaryColor: '#047aff', bgColor: '#ffffff' },
|
|
18
|
+
{ id: 'nord', name: 'Nord', dark: false, primaryColor: '#5e81ac', bgColor: '#eceff4' },
|
|
19
|
+
// 暗色主题
|
|
20
|
+
{ id: 'dark', name: 'Dark', dark: true, primaryColor: '#661ae6', bgColor: '#1d232a' },
|
|
21
|
+
{ id: 'dracula', name: 'Dracula', dark: true, primaryColor: '#ff79c6', bgColor: '#282a36' },
|
|
22
|
+
{ id: 'business', name: 'Business', dark: true, primaryColor: '#1c4f82', bgColor: '#202020' },
|
|
23
|
+
{ id: 'night', name: 'Night', dark: true, primaryColor: '#38bdf8', bgColor: '#0f172a' },
|
|
24
|
+
{ id: 'dim', name: 'Dim', dark: true, primaryColor: '#9fe88d', bgColor: '#2a303c' },
|
|
25
|
+
{ id: 'sunset', name: 'Sunset', dark: true, primaryColor: '#ff865b', bgColor: '#1a1919' },
|
|
26
|
+
{ id: 'luxury', name: 'Luxury', dark: true, primaryColor: '#c9a53d', bgColor: '#171618' },
|
|
27
|
+
{ id: 'coffee', name: 'Coffee', dark: true, primaryColor: '#db924b', bgColor: '#20161f' },
|
|
28
|
+
];
|
|
29
|
+
/**
|
|
30
|
+
* 主题分组配置
|
|
31
|
+
*/
|
|
32
|
+
export const THEME_GROUPS = [
|
|
33
|
+
{
|
|
34
|
+
id: 'light',
|
|
35
|
+
nameKey: 'theme_group_light',
|
|
36
|
+
themes: THEMES.filter(t => !t.dark),
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: 'dark',
|
|
40
|
+
nameKey: 'theme_group_dark',
|
|
41
|
+
themes: THEMES.filter(t => t.dark),
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
/**
|
|
45
|
+
* 暗色主题列表
|
|
46
|
+
*/
|
|
47
|
+
export const DARK_THEMES = THEMES.filter(t => t.dark).map(t => t.id);
|
|
48
|
+
/**
|
|
49
|
+
* 获取主题信息
|
|
50
|
+
*/
|
|
51
|
+
export function getThemeInfo(themeId) {
|
|
52
|
+
return THEMES.find(t => t.id === themeId);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 检查是否为暗色主题
|
|
56
|
+
*/
|
|
57
|
+
export function isDarkTheme(themeId) {
|
|
58
|
+
return DARK_THEMES.includes(themeId);
|
|
59
|
+
}
|
|
60
|
+
// ─── 主题初始化工具 ───
|
|
61
|
+
/**
|
|
62
|
+
* 默认主题
|
|
63
|
+
*/
|
|
64
|
+
export const DEFAULT_THEME = 'light';
|
|
65
|
+
/**
|
|
66
|
+
* 主题存储键名
|
|
67
|
+
*/
|
|
68
|
+
export const THEME_STORAGE_KEY = 'theme';
|
|
69
|
+
/**
|
|
70
|
+
* 获取主题初始化脚本(用于 app.html 防闪烁)
|
|
71
|
+
*
|
|
72
|
+
* 使用方式:在 app.html 的 <head> 中添加 <script>{getThemeInitScript()}</script>
|
|
73
|
+
*/
|
|
74
|
+
export function getThemeInitScript() {
|
|
75
|
+
return `(function(){var t=localStorage.getItem('${THEME_STORAGE_KEY}')||'${DEFAULT_THEME}';document.documentElement.setAttribute('data-theme',t)})()`;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 应用主题
|
|
79
|
+
* @param theme - 主题 ID
|
|
80
|
+
* @param persist - 是否持久化到 localStorage
|
|
81
|
+
*/
|
|
82
|
+
export function applyTheme(theme, persist = true) {
|
|
83
|
+
if (typeof document === 'undefined')
|
|
84
|
+
return;
|
|
85
|
+
document.documentElement.setAttribute('data-theme', theme);
|
|
86
|
+
if (persist && typeof localStorage !== 'undefined') {
|
|
87
|
+
localStorage.setItem(THEME_STORAGE_KEY, theme);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 获取当前主题
|
|
92
|
+
*/
|
|
93
|
+
export function getCurrentTheme() {
|
|
94
|
+
if (typeof document === 'undefined')
|
|
95
|
+
return DEFAULT_THEME;
|
|
96
|
+
return document.documentElement.getAttribute('data-theme') ?? DEFAULT_THEME;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 获取保存的主题(从 localStorage)
|
|
100
|
+
*/
|
|
101
|
+
export function getSavedTheme() {
|
|
102
|
+
if (typeof localStorage === 'undefined')
|
|
103
|
+
return DEFAULT_THEME;
|
|
104
|
+
return localStorage.getItem(THEME_STORAGE_KEY) ?? DEFAULT_THEME;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* DaisyUI 主题配置字符串(用于 app.css)
|
|
108
|
+
*
|
|
109
|
+
* 注意:Tailwind CSS v4 要求主题在 CSS 中声明,无法通过 JS 动态注入
|
|
110
|
+
* 消费应用需要在 app.css 中添加:
|
|
111
|
+
*
|
|
112
|
+
* @plugin "daisyui" {
|
|
113
|
+
* themes: light --default, dark --prefersdark, cupcake, bumblebee, ...
|
|
114
|
+
* }
|
|
115
|
+
*/
|
|
116
|
+
export const DAISYUI_THEMES_CONFIG = THEMES.map((t, i) => {
|
|
117
|
+
if (i === 0)
|
|
118
|
+
return `${t.id} --default`;
|
|
119
|
+
if (t.id === 'dark')
|
|
120
|
+
return `${t.id} --prefersdark`;
|
|
121
|
+
return t.id;
|
|
122
|
+
}).join(',\n ');
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @h-ai/ui — Toast 状态管理
|
|
3
|
+
*
|
|
4
|
+
* Toast 通知的状态管理,使用 Svelte 5 Runes
|
|
5
|
+
* @module toast.svelte
|
|
6
|
+
*/
|
|
7
|
+
import type { ToastProps } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Toast 项
|
|
10
|
+
*/
|
|
11
|
+
export interface ToastItem extends ToastProps {
|
|
12
|
+
id: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Toast 状态
|
|
16
|
+
*/
|
|
17
|
+
declare class ToastState {
|
|
18
|
+
items: ToastItem[];
|
|
19
|
+
/** 自动关闭定时器 */
|
|
20
|
+
private timers;
|
|
21
|
+
/**
|
|
22
|
+
* 添加 Toast
|
|
23
|
+
*/
|
|
24
|
+
add(props: Omit<ToastProps, 'onclose'>): string;
|
|
25
|
+
/**
|
|
26
|
+
* 移除 Toast
|
|
27
|
+
*/
|
|
28
|
+
remove(id: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* 清空所有 Toast
|
|
31
|
+
*/
|
|
32
|
+
clear(): void;
|
|
33
|
+
/**
|
|
34
|
+
* 快捷方法
|
|
35
|
+
*/
|
|
36
|
+
success(message: string, duration?: number): string;
|
|
37
|
+
error(message: string, duration?: number): string;
|
|
38
|
+
warning(message: string, duration?: number): string;
|
|
39
|
+
info(message: string, duration?: number): string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Toast 单例
|
|
43
|
+
*/
|
|
44
|
+
export declare const toast: ToastState;
|
|
45
|
+
export {};
|