@h-ai/ui 0.1.0-alpha.74 → 0.1.0-alpha.76
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.en.md +46 -17
- package/README.ja.md +46 -17
- package/README.md +46 -17
- package/auto-import.d.ts +2 -0
- package/auto-import.js +2 -0
- package/dist/components/compounds/Alert.svelte +2 -2
- package/dist/components/compounds/Alert.svelte.d.ts +1 -1
- package/dist/components/compounds/Confirm.svelte +12 -2
- package/dist/components/compounds/Drawer.svelte +32 -14
- package/dist/components/compounds/FilterBar.svelte +77 -0
- package/dist/components/compounds/FilterBar.svelte.d.ts +39 -0
- package/dist/components/compounds/Modal.svelte +4 -37
- package/dist/components/compounds/PageHeader.svelte +18 -11
- package/dist/components/compounds/TableToolbar.svelte +1 -1
- package/dist/components/compounds/ToastContainer.svelte +96 -42
- package/dist/components/compounds/ToastContainer.svelte.d.ts +1 -1
- package/dist/components/compounds/index.d.ts +1 -0
- package/dist/components/compounds/index.js +1 -0
- package/dist/components/primitives/Button.svelte +7 -0
- package/dist/components/primitives/Input.svelte +1 -1
- package/dist/components/primitives/Textarea.svelte +1 -1
- package/dist/components/scenes/app/FeedbackDetail.svelte +2 -2
- package/dist/components/scenes/app/FeedbackForm.svelte +5 -7
- package/dist/components/scenes/app/FeedbackList.svelte +4 -4
- package/dist/components/scenes/app/SettingsLayout.svelte +4 -15
- package/dist/components/scenes/app/ThemeSelector.svelte +56 -16
- package/dist/components/scenes/app/WorkspaceLayout.svelte +64 -0
- package/dist/components/scenes/app/WorkspaceLayout.svelte.d.ts +36 -0
- package/dist/components/scenes/app/feedback-functions.d.ts +16 -0
- package/dist/components/scenes/app/feedback-functions.js +31 -0
- package/dist/components/scenes/app/index.d.ts +1 -0
- package/dist/components/scenes/app/index.js +1 -0
- package/dist/components/scenes/crud/CrudEditPanel.svelte +18 -9
- package/dist/components/scenes/crud/CrudFilterBar.svelte +39 -30
- package/dist/components/scenes/crud/CrudFilterBar.svelte.d.ts +4 -1
- package/dist/components/scenes/crud/CrudPage.svelte +27 -7
- package/dist/components/scenes/crud/CrudPage.svelte.d.ts +1 -1
- package/dist/components/scenes/crud/crud-types.d.ts +1 -1
- package/dist/components/scenes/guide/GuideHost.svelte +22 -102
- package/dist/components/scenes/guide/GuideHost.svelte.d.ts +5 -13
- package/dist/components/scenes/guide/GuideHostContent.svelte +143 -0
- package/dist/components/scenes/guide/GuideHostContent.svelte.d.ts +43 -0
- package/dist/components/scenes/guide/HelpCenter.svelte +22 -9
- package/dist/components/scenes/iam/AuthPanel.svelte +5 -3
- package/dist/components/scenes/iam/LoginForm.svelte +25 -1
- package/dist/components/scenes/iam/PasswordInput.svelte +1 -1
- package/dist/components/scenes/iam/SensitiveOperationsForm.svelte +1 -1
- package/dist/components/scenes/types.d.ts +2 -0
- package/dist/guide.svelte.js +61 -26
- package/dist/internal/dialog-focus.d.ts +21 -0
- package/dist/internal/dialog-focus.js +77 -0
- package/dist/internal/form-validation.svelte.d.ts +2 -1
- package/dist/internal/form-validation.svelte.js +9 -1
- package/dist/messages/en-US.json +9 -2
- package/dist/messages/ja-JP.json +9 -2
- package/dist/messages/zh-CN.json +9 -2
- package/dist/styles/formal.css +55 -0
- package/dist/styles/high-contrast.css +64 -0
- package/dist/styles/theme.css +2 -0
- package/dist/theme-config.d.ts +2 -2
- package/dist/theme-config.js +5 -2
- package/dist/toast.svelte.d.ts +7 -6
- package/dist/toast.svelte.js +23 -23
- package/dist/types.d.ts +6 -2
- package/dist/workspace-context.d.ts +20 -0
- package/dist/workspace-context.js +9 -0
- package/package.json +7 -2
package/dist/toast.svelte.js
CHANGED
|
@@ -10,8 +10,14 @@ import { core } from '@h-ai/core';
|
|
|
10
10
|
*/
|
|
11
11
|
class ToastState {
|
|
12
12
|
items = $state([]);
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/** 仅队首计时,等待项在展示后才开始计算停留时间。 */
|
|
14
|
+
timer;
|
|
15
|
+
startTimer() {
|
|
16
|
+
const item = this.items[0];
|
|
17
|
+
if (item && (item.duration ?? 0) > 0) {
|
|
18
|
+
this.timer = setTimeout(() => this.remove(item.id), item.duration);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
15
21
|
/**
|
|
16
22
|
* 添加 Toast
|
|
17
23
|
* @param props - 组件的属性对象。
|
|
@@ -30,18 +36,12 @@ class ToastState {
|
|
|
30
36
|
...props,
|
|
31
37
|
id,
|
|
32
38
|
duration: props.duration ?? 3000,
|
|
33
|
-
position: props.position ?? '
|
|
39
|
+
position: props.position ?? 'bottom-right',
|
|
34
40
|
dismissible: props.dismissible ?? true,
|
|
35
41
|
};
|
|
36
42
|
this.items = [...this.items, item];
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const timer = setTimeout(() => {
|
|
40
|
-
this.timers.delete(id);
|
|
41
|
-
this.remove(id);
|
|
42
|
-
}, item.duration);
|
|
43
|
-
this.timers.set(id, timer);
|
|
44
|
-
}
|
|
43
|
+
if (this.items.length === 1)
|
|
44
|
+
this.startTimer();
|
|
45
45
|
return id;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
@@ -57,12 +57,14 @@ class ToastState {
|
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
59
|
remove(id) {
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
clearTimeout(timer);
|
|
63
|
-
this.
|
|
60
|
+
const isCurrent = this.items[0]?.id === id;
|
|
61
|
+
if (isCurrent) {
|
|
62
|
+
clearTimeout(this.timer);
|
|
63
|
+
this.timer = undefined;
|
|
64
64
|
}
|
|
65
65
|
this.items = this.items.filter(item => item.id !== id);
|
|
66
|
+
if (isCurrent)
|
|
67
|
+
this.startTimer();
|
|
66
68
|
}
|
|
67
69
|
/**
|
|
68
70
|
* 清空所有 Toast
|
|
@@ -76,10 +78,8 @@ class ToastState {
|
|
|
76
78
|
* ```
|
|
77
79
|
*/
|
|
78
80
|
clear() {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
this.timers.clear();
|
|
81
|
+
clearTimeout(this.timer);
|
|
82
|
+
this.timer = undefined;
|
|
83
83
|
this.items = [];
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
@@ -165,7 +165,7 @@ const SUCCESS_DURATION = 3000;
|
|
|
165
165
|
/** 失败提示默认停留时长(毫秒),比成功略长便于阅读错误信息。 */
|
|
166
166
|
const ERROR_DURATION = 5000;
|
|
167
167
|
/**
|
|
168
|
-
*
|
|
168
|
+
* 弹出操作成功提示(默认右下角)。
|
|
169
169
|
*
|
|
170
170
|
* @description 统一封装 toast 单例,业务应用无需自建 toast 工具文件即可获得一致的成功反馈。
|
|
171
171
|
*
|
|
@@ -184,7 +184,7 @@ export function notifySuccess(message, duration = SUCCESS_DURATION) {
|
|
|
184
184
|
return toast.success(message, duration);
|
|
185
185
|
}
|
|
186
186
|
/**
|
|
187
|
-
*
|
|
187
|
+
* 弹出操作失败提示(默认右下角)。
|
|
188
188
|
*
|
|
189
189
|
* @description 接受 `Error` 或字符串;`Error` 取其 message,其余回退到 fallback,
|
|
190
190
|
* 避免各业务页面重复实现错误文案兜底逻辑。
|
|
@@ -228,7 +228,7 @@ export function errorMessage(error, fallback = '') {
|
|
|
228
228
|
return core.error.formatMessage({ message, traceId: /\(traceId: [\w.:-]{1,128}\)$/.test(message) ? undefined : traceId });
|
|
229
229
|
}
|
|
230
230
|
/**
|
|
231
|
-
*
|
|
231
|
+
* 弹出信息提示(默认右下角)。
|
|
232
232
|
*
|
|
233
233
|
* @param message - 用户可见文案(已本地化)。
|
|
234
234
|
* @param duration - 可选停留时长(毫秒),默认 3000。
|
|
@@ -245,7 +245,7 @@ export function notifyInfo(message, duration = SUCCESS_DURATION) {
|
|
|
245
245
|
return toast.info(message, duration);
|
|
246
246
|
}
|
|
247
247
|
/**
|
|
248
|
-
*
|
|
248
|
+
* 弹出警告提示(默认右下角)。
|
|
249
249
|
*
|
|
250
250
|
* @param message - 用户可见文案(已本地化)。
|
|
251
251
|
* @param duration - 可选停留时长(毫秒),默认 5000。
|
package/dist/types.d.ts
CHANGED
|
@@ -102,6 +102,8 @@ export interface ButtonProps extends DataAttributes {
|
|
|
102
102
|
circle?: boolean;
|
|
103
103
|
/** 按钮类型 */
|
|
104
104
|
type?: 'button' | 'submit' | 'reset';
|
|
105
|
+
/** type=submit 时显示原生表单 Enter 提示;不注册全局快捷键。 */
|
|
106
|
+
submitHint?: boolean;
|
|
105
107
|
/** 点击事件 */
|
|
106
108
|
onclick?: (e: MouseEvent) => void;
|
|
107
109
|
/** 子内容 */
|
|
@@ -713,6 +715,8 @@ export interface DrawerProps extends DataAttributes {
|
|
|
713
715
|
widthStorageKey?: string;
|
|
714
716
|
/** 是否可通过点击遮罩关闭 */
|
|
715
717
|
closeOnBackdrop?: boolean;
|
|
718
|
+
/** 是否允许 Esc 关闭;提交期间可显式关闭。 */
|
|
719
|
+
closeOnEscape?: boolean;
|
|
716
720
|
/** 是否显示关闭按钮 */
|
|
717
721
|
showClose?: boolean;
|
|
718
722
|
/** 自定义类名 */
|
|
@@ -850,9 +854,9 @@ export interface ToastProps extends DataAttributes {
|
|
|
850
854
|
message: string;
|
|
851
855
|
/** 变体 */
|
|
852
856
|
variant?: Variant;
|
|
853
|
-
/**
|
|
857
|
+
/** 展示后的持续时间 (ms),默认 3000;排队等待不计时,0 为不自动关闭 */
|
|
854
858
|
duration?: number;
|
|
855
|
-
/**
|
|
859
|
+
/** 浮动位置,默认 bottom-right;多个提示按加入顺序逐条显示 */
|
|
856
860
|
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';
|
|
857
861
|
/** 是否可关闭 */
|
|
858
862
|
dismissible?: boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 工作区导航标题按实例共享,读取 getter 以跟随路由及语言变化。
|
|
3
|
+
* @example 模块内部上下文
|
|
4
|
+
* ```ts
|
|
5
|
+
* const context: WorkspaceContext = { title: '用户管理' }
|
|
6
|
+
* void context
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
export interface WorkspaceContext {
|
|
10
|
+
readonly title: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 仅供布局和标题组件协作,不属于公开 API。
|
|
14
|
+
* @example 模块内部上下文
|
|
15
|
+
* ```ts
|
|
16
|
+
* const key: symbol = workspaceContextKey
|
|
17
|
+
* void key
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const workspaceContextKey: unique symbol;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-ai/ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.0-alpha.
|
|
4
|
+
"version": "0.1.0-alpha.76",
|
|
5
5
|
"description": "Hai Framework UI component library for Svelte 5 Runes.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"svelte": "./dist/index.js",
|
|
@@ -24,6 +24,11 @@
|
|
|
24
24
|
"svelte": "./dist/i18n.svelte.js",
|
|
25
25
|
"import": "./dist/i18n.svelte.js"
|
|
26
26
|
},
|
|
27
|
+
"./toast": {
|
|
28
|
+
"types": "./dist/toast.svelte.d.ts",
|
|
29
|
+
"svelte": "./dist/toast.svelte.js",
|
|
30
|
+
"import": "./dist/toast.svelte.js"
|
|
31
|
+
},
|
|
27
32
|
"./theme": {
|
|
28
33
|
"types": "./dist/theme-config.d.ts",
|
|
29
34
|
"import": "./dist/theme-config.js"
|
|
@@ -119,7 +124,7 @@
|
|
|
119
124
|
"svelte": "^5.57.2"
|
|
120
125
|
},
|
|
121
126
|
"dependencies": {
|
|
122
|
-
"@h-ai/core": "0.1.0-alpha.
|
|
127
|
+
"@h-ai/core": "0.1.0-alpha.76",
|
|
123
128
|
"@internationalized/date": "^3.12.4",
|
|
124
129
|
"@rrweb/replay": "^2.1.7",
|
|
125
130
|
"@shikijs/langs": "^4.5.0",
|