@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.
Files changed (67) hide show
  1. package/README.en.md +46 -17
  2. package/README.ja.md +46 -17
  3. package/README.md +46 -17
  4. package/auto-import.d.ts +2 -0
  5. package/auto-import.js +2 -0
  6. package/dist/components/compounds/Alert.svelte +2 -2
  7. package/dist/components/compounds/Alert.svelte.d.ts +1 -1
  8. package/dist/components/compounds/Confirm.svelte +12 -2
  9. package/dist/components/compounds/Drawer.svelte +32 -14
  10. package/dist/components/compounds/FilterBar.svelte +77 -0
  11. package/dist/components/compounds/FilterBar.svelte.d.ts +39 -0
  12. package/dist/components/compounds/Modal.svelte +4 -37
  13. package/dist/components/compounds/PageHeader.svelte +18 -11
  14. package/dist/components/compounds/TableToolbar.svelte +1 -1
  15. package/dist/components/compounds/ToastContainer.svelte +96 -42
  16. package/dist/components/compounds/ToastContainer.svelte.d.ts +1 -1
  17. package/dist/components/compounds/index.d.ts +1 -0
  18. package/dist/components/compounds/index.js +1 -0
  19. package/dist/components/primitives/Button.svelte +7 -0
  20. package/dist/components/primitives/Input.svelte +1 -1
  21. package/dist/components/primitives/Textarea.svelte +1 -1
  22. package/dist/components/scenes/app/FeedbackDetail.svelte +2 -2
  23. package/dist/components/scenes/app/FeedbackForm.svelte +5 -7
  24. package/dist/components/scenes/app/FeedbackList.svelte +4 -4
  25. package/dist/components/scenes/app/SettingsLayout.svelte +4 -15
  26. package/dist/components/scenes/app/ThemeSelector.svelte +56 -16
  27. package/dist/components/scenes/app/WorkspaceLayout.svelte +64 -0
  28. package/dist/components/scenes/app/WorkspaceLayout.svelte.d.ts +36 -0
  29. package/dist/components/scenes/app/feedback-functions.d.ts +16 -0
  30. package/dist/components/scenes/app/feedback-functions.js +31 -0
  31. package/dist/components/scenes/app/index.d.ts +1 -0
  32. package/dist/components/scenes/app/index.js +1 -0
  33. package/dist/components/scenes/crud/CrudEditPanel.svelte +18 -9
  34. package/dist/components/scenes/crud/CrudFilterBar.svelte +39 -30
  35. package/dist/components/scenes/crud/CrudFilterBar.svelte.d.ts +4 -1
  36. package/dist/components/scenes/crud/CrudPage.svelte +27 -7
  37. package/dist/components/scenes/crud/CrudPage.svelte.d.ts +1 -1
  38. package/dist/components/scenes/crud/crud-types.d.ts +1 -1
  39. package/dist/components/scenes/guide/GuideHost.svelte +22 -102
  40. package/dist/components/scenes/guide/GuideHost.svelte.d.ts +5 -13
  41. package/dist/components/scenes/guide/GuideHostContent.svelte +143 -0
  42. package/dist/components/scenes/guide/GuideHostContent.svelte.d.ts +43 -0
  43. package/dist/components/scenes/guide/HelpCenter.svelte +22 -9
  44. package/dist/components/scenes/iam/AuthPanel.svelte +5 -3
  45. package/dist/components/scenes/iam/LoginForm.svelte +25 -1
  46. package/dist/components/scenes/iam/PasswordInput.svelte +1 -1
  47. package/dist/components/scenes/iam/SensitiveOperationsForm.svelte +1 -1
  48. package/dist/components/scenes/types.d.ts +2 -0
  49. package/dist/guide.svelte.js +61 -26
  50. package/dist/internal/dialog-focus.d.ts +21 -0
  51. package/dist/internal/dialog-focus.js +77 -0
  52. package/dist/internal/form-validation.svelte.d.ts +2 -1
  53. package/dist/internal/form-validation.svelte.js +9 -1
  54. package/dist/messages/en-US.json +9 -2
  55. package/dist/messages/ja-JP.json +9 -2
  56. package/dist/messages/zh-CN.json +9 -2
  57. package/dist/styles/formal.css +55 -0
  58. package/dist/styles/high-contrast.css +64 -0
  59. package/dist/styles/theme.css +2 -0
  60. package/dist/theme-config.d.ts +2 -2
  61. package/dist/theme-config.js +5 -2
  62. package/dist/toast.svelte.d.ts +7 -6
  63. package/dist/toast.svelte.js +23 -23
  64. package/dist/types.d.ts +6 -2
  65. package/dist/workspace-context.d.ts +20 -0
  66. package/dist/workspace-context.js +9 -0
  67. package/package.json +7 -2
@@ -62,7 +62,7 @@
62
62
  <form data-testid='sensitive-operations-form' {...dataAttributes} class='space-y-4' onsubmit={save}>
63
63
  <label class='block space-y-2 text-sm font-medium'>
64
64
  <span>{uiM('sensitive_operations_label')}</span>
65
- <Textarea bind:value rows={6} disabled={loading} aria-label={uiM('sensitive_operations_label')} />
65
+ <Textarea bind:value rows={6} disabled={loading} />
66
66
  </label>
67
67
  <p class='text-sm text-base-content/60'>{uiM('sensitive_operations_hint')}</p>
68
68
  {#if error}<p role='alert' class='text-sm text-error'>{error}</p>{/if}
@@ -107,6 +107,8 @@ export interface LoginFormData {
107
107
  * ```
108
108
  */
109
109
  export interface LoginFormProps extends FormLayoutOptions, DataAttributes {
110
+ /** 默认在桌面首次就绪且页面尚无焦点时聚焦登录标识;触屏不主动弹出键盘。 */
111
+ autoFocus?: boolean;
110
112
  /** 初始登录标识;原地恢复时预填原用户名,仍走正常鉴别。 */
111
113
  initialIdentifier?: string;
112
114
  /** 实际可用的方式;空数组表示无可用登录方式。 */
@@ -29,13 +29,18 @@ function escapeGuideText(text) {
29
29
  })[character]);
30
30
  }
31
31
  function findTarget(step) {
32
- const element = typeof step.target === 'function'
33
- ? step.target()
34
- : [...document.querySelectorAll('[data-guide]')].find(item => item.getAttribute('data-guide') === step.target);
35
- if (!element?.isConnected || !element.getClientRects().length || element.closest('[hidden], [aria-hidden="true"]'))
32
+ try {
33
+ const element = typeof step.target === 'function'
34
+ ? step.target()
35
+ : [...document.querySelectorAll('[data-guide]')].find(item => item.getAttribute('data-guide') === step.target);
36
+ if (!element?.isConnected || !element.getClientRects().length || element.closest('[hidden], [aria-hidden="true"]'))
37
+ return null;
38
+ const style = getComputedStyle(element);
39
+ return style.visibility === 'hidden' || style.display === 'none' ? null : element;
40
+ }
41
+ catch {
36
42
  return null;
37
- const style = getComputedStyle(element);
38
- return style.visibility === 'hidden' || style.display === 'none' ? null : element;
43
+ }
39
44
  }
40
45
  /** 等待异步渲染、页签展开或布局变化,所有退出路径均清理监听和计时器。 */
41
46
  function waitForTarget(step, signal, timeout, ready) {
@@ -58,17 +63,28 @@ function waitForTarget(step, signal, timeout, ready) {
58
63
  finish(null);
59
64
  return;
60
65
  }
61
- const element = ready() ? findTarget(step) : null;
62
- if (element)
63
- finish(element);
66
+ try {
67
+ const element = ready() ? findTarget(step) : null;
68
+ if (element)
69
+ finish(element);
70
+ }
71
+ catch {
72
+ finish(null);
73
+ }
64
74
  };
65
75
  if (signal.aborted) {
66
76
  finish(null);
67
77
  return;
68
78
  }
69
- const initial = ready() ? findTarget(step) : null;
70
- if (initial) {
71
- finish(initial);
79
+ try {
80
+ const initial = ready() ? findTarget(step) : null;
81
+ if (initial) {
82
+ finish(initial);
83
+ return;
84
+ }
85
+ }
86
+ catch {
87
+ finish(null);
72
88
  return;
73
89
  }
74
90
  observer = new MutationObserver(check);
@@ -116,7 +132,14 @@ export function createGuide(options) {
116
132
  let targetObserver;
117
133
  const msg = (key) => uiM(key, undefined, locale);
118
134
  const progressKey = (id) => `${persistKey}:${scope}:${id}`;
119
- const tourFor = (id) => options.tours.find(tour => tour.id === id && (!tour.enabled || tour.enabled()));
135
+ const tourFor = (id) => {
136
+ try {
137
+ return options.tours.find(tour => tour.id === id && (!tour.enabled || tour.enabled()));
138
+ }
139
+ catch {
140
+ return undefined;
141
+ }
142
+ };
120
143
  function clearPending() {
121
144
  try {
122
145
  sessionStorage.removeItem(pendingKey);
@@ -183,7 +206,7 @@ export function createGuide(options) {
183
206
  helpOpen = false;
184
207
  const tour = tourFor(id);
185
208
  if (!tour?.steps.length) {
186
- error = 'guide_unavailable';
209
+ error ||= 'guide_unavailable';
187
210
  return false;
188
211
  }
189
212
  const run = generation;
@@ -339,16 +362,22 @@ export function createGuide(options) {
339
362
  }
340
363
  },
341
364
  onPopoverRender: (popover) => {
342
- // 第三方默认支持 HTML;业务翻译和插值统一按纯文本写入。
343
- const index = driver?.getActiveIndex() ?? 0;
344
- const step = tour.steps[index];
345
- popover.title.textContent = resolveGuideText(step?.title);
346
- popover.description.textContent = resolveGuideText(step?.description);
347
- popover.nextButton.textContent = msg(index === tour.steps.length - 1 ? 'guide_done' : 'guide_next');
348
- popover.previousButton.textContent = msg('guide_previous');
349
- popover.progress.textContent = uiM('guide_progress', { current: index + 1, total: tour.steps.length }, locale);
350
- popover.nextButton.disabled = busy;
351
- popover.previousButton.disabled = busy || !hasPreviousStep(index);
365
+ try {
366
+ // 第三方默认支持 HTML;业务翻译和插值统一按纯文本写入。
367
+ const index = driver?.getActiveIndex() ?? 0;
368
+ const step = tour.steps[index];
369
+ popover.title.textContent = resolveGuideText(step?.title);
370
+ popover.description.textContent = resolveGuideText(step?.description);
371
+ popover.nextButton.textContent = msg(index === tour.steps.length - 1 ? 'guide_done' : 'guide_next');
372
+ popover.previousButton.textContent = msg('guide_previous');
373
+ popover.progress.textContent = uiM('guide_progress', { current: index + 1, total: tour.steps.length }, locale);
374
+ popover.nextButton.disabled = busy;
375
+ popover.previousButton.disabled = busy || !hasPreviousStep(index);
376
+ }
377
+ catch {
378
+ error = 'guide_startFailed';
379
+ stop();
380
+ }
352
381
  },
353
382
  });
354
383
  const started = await showStep(0);
@@ -425,8 +454,14 @@ export function createGuide(options) {
425
454
  locale = value;
426
455
  const tour = activeTourId ? tourFor(activeTourId) : undefined;
427
456
  if (driver && tour) {
428
- driver.setConfig({ ...driver.getConfig(), ...translatedConfig(tour) });
429
- driver.drive(driver.getActiveIndex() ?? 0);
457
+ try {
458
+ driver.setConfig({ ...driver.getConfig(), ...translatedConfig(tour) });
459
+ driver.drive(driver.getActiveIndex() ?? 0);
460
+ }
461
+ catch {
462
+ error = 'guide_startFailed';
463
+ stop();
464
+ }
430
465
  }
431
466
  },
432
467
  setScope(value) {
@@ -0,0 +1,21 @@
1
+ /**
2
+ * 打开后优先聚焦可编辑字段,清理时取消首帧校准并恢复触发控件。
3
+ * @example 模块内部上下文
4
+ * ```ts
5
+ * function example(panel: HTMLElement) {
6
+ * const restore = focusDialog(panel)
7
+ * return restore
8
+ * }
9
+ * ```
10
+ */
11
+ export declare function focusDialog(panel: HTMLElement): () => void;
12
+ /**
13
+ * 原生 Tab 顺序只在边缘循环;嵌套弹层已处理的键盘事件不再拦截。
14
+ * @example 模块内部上下文
15
+ * ```ts
16
+ * function example(event: KeyboardEvent, panel: HTMLElement) {
17
+ * handleDialogKeydown(event, panel, () => {})
18
+ * }
19
+ * ```
20
+ */
21
+ export declare function handleDialogKeydown(event: KeyboardEvent, panel: HTMLElement, close?: () => void): void;
@@ -0,0 +1,77 @@
1
+ /** 弹窗和抽屉共享可见、可操作的焦点边界。 */
2
+ function focusable(panel) {
3
+ return [...panel.querySelectorAll('button, a[href], input:not([type="hidden"]), select, textarea, [tabindex]')]
4
+ .filter(element => element.tabIndex >= 0 && !element.matches(':disabled') && element.getClientRects().length > 0);
5
+ }
6
+ /**
7
+ * 打开后优先聚焦可编辑字段,清理时取消首帧校准并恢复触发控件。
8
+ * @example 模块内部上下文
9
+ * ```ts
10
+ * function example(panel: HTMLElement) {
11
+ * const restore = focusDialog(panel)
12
+ * return restore
13
+ * }
14
+ * ```
15
+ */
16
+ export function focusDialog(panel) {
17
+ const previous = document.activeElement instanceof HTMLElement ? document.activeElement : null;
18
+ function preferred() {
19
+ const elements = focusable(panel);
20
+ return elements.find(element => element.matches('input:not([readonly]), textarea, select, [role="combobox"]')) ?? elements[0] ?? panel;
21
+ }
22
+ const initial = preferred();
23
+ initial.focus({ preventScroll: true });
24
+ function alignFocus() {
25
+ const active = document.activeElement;
26
+ if (panel.isConnected && (active === previous || active === initial || active === panel || active === document.body))
27
+ preferred().focus({ preventScroll: true });
28
+ }
29
+ function onTransition(event) {
30
+ if (event.target === panel)
31
+ alignFocus();
32
+ }
33
+ panel.addEventListener('transitionend', onTransition);
34
+ const frame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame(alignFocus) : undefined;
35
+ return () => {
36
+ panel.removeEventListener('transitionend', onTransition);
37
+ if (frame !== undefined)
38
+ cancelAnimationFrame(frame);
39
+ if (previous?.isConnected && !previous.matches(':disabled'))
40
+ previous.focus();
41
+ };
42
+ }
43
+ /**
44
+ * 原生 Tab 顺序只在边缘循环;嵌套弹层已处理的键盘事件不再拦截。
45
+ * @example 模块内部上下文
46
+ * ```ts
47
+ * function example(event: KeyboardEvent, panel: HTMLElement) {
48
+ * handleDialogKeydown(event, panel, () => {})
49
+ * }
50
+ * ```
51
+ */
52
+ export function handleDialogKeydown(event, panel, close) {
53
+ if (event.defaultPrevented)
54
+ return;
55
+ if (event.key === 'Escape' && close) {
56
+ event.preventDefault();
57
+ event.stopPropagation();
58
+ close();
59
+ }
60
+ else if (event.key === 'Tab') {
61
+ const elements = focusable(panel);
62
+ const first = elements[0];
63
+ const last = elements.at(-1);
64
+ if (!first) {
65
+ event.preventDefault();
66
+ panel.focus();
67
+ }
68
+ else if (event.shiftKey && (document.activeElement === first || document.activeElement === panel)) {
69
+ event.preventDefault();
70
+ last?.focus();
71
+ }
72
+ else if (!event.shiftKey && document.activeElement === last) {
73
+ event.preventDefault();
74
+ first.focus();
75
+ }
76
+ }
77
+ }
@@ -37,7 +37,7 @@ export declare function resolveFormText(text?: FormText): string;
37
37
  * 在组件初始化阶段创建原生约束校验状态;宿主关闭或表单 reset 时清除过期错误。
38
38
  * @param getOverride - 读取自定义校验提示的函数。
39
39
  * @param getValue - 读取当前控件值以跟踪程序回填的函数。
40
- * @returns 带响应式 message 和 validate/input/reset 方法的校验状态。
40
+ * @returns 带响应式 message 和 validate/blur/input/reset 方法的校验状态。
41
41
  *
42
42
  * @example 模块内部上下文
43
43
  * ```ts
@@ -52,6 +52,7 @@ export declare function resolveFormText(text?: FormText): string;
52
52
  export declare function createControlValidation(getOverride?: () => FormText | undefined, getValue?: () => unknown): {
53
53
  readonly message: string;
54
54
  validate(control: FormControl): void;
55
+ blur(control: FormControl): void;
55
56
  input(control: FormControl): void;
56
57
  reset: () => void;
57
58
  };
@@ -49,7 +49,7 @@ function readIssue(control) {
49
49
  * 在组件初始化阶段创建原生约束校验状态;宿主关闭或表单 reset 时清除过期错误。
50
50
  * @param getOverride - 读取自定义校验提示的函数。
51
51
  * @param getValue - 读取当前控件值以跟踪程序回填的函数。
52
- * @returns 带响应式 message 和 validate/input/reset 方法的校验状态。
52
+ * @returns 带响应式 message 和 validate/blur/input/reset 方法的校验状态。
53
53
  *
54
54
  * @example 模块内部上下文
55
55
  * ```ts
@@ -65,8 +65,10 @@ export function createControlValidation(getOverride = () => undefined, getValue)
65
65
  const visibility = getFormVisibilityContext();
66
66
  let issue = $state();
67
67
  let currentControl = $state();
68
+ let edited = false;
68
69
  function reset() {
69
70
  issue = undefined;
71
+ edited = false;
70
72
  currentControl?.setCustomValidity('');
71
73
  }
72
74
  $effect(() => {
@@ -101,7 +103,13 @@ export function createControlValidation(getOverride = () => undefined, getValue)
101
103
  issue = readIssue(control);
102
104
  control.setCustomValidity(issue ? resolveFormText(getOverride()) || uiM(issue.key, issue.params) : '');
103
105
  },
106
+ blur(control) {
107
+ // 默认焦点离开未输入的空字段时不挤动按钮/链接;提交仍由原生 invalid 校验。
108
+ if (edited || control.value || issue)
109
+ this.validate(control);
110
+ },
104
111
  input(control) {
112
+ edited = true;
105
113
  currentControl = control;
106
114
  control.setCustomValidity('');
107
115
  if (issue)
@@ -20,6 +20,7 @@
20
20
  "settings_close": "Close",
21
21
  "settings_language": "Language",
22
22
  "settings_theme": "Theme",
23
+ "theme_high_contrast": "High contrast",
23
24
  "combobox_no_match": "No match",
24
25
  "combobox_remove": "Remove",
25
26
  "data_table_actions": "Actions",
@@ -325,8 +326,9 @@
325
326
  "error_500_desc": "Something went wrong on our end. We're working on it, please try again later.",
326
327
  "error_503_title": "Under Maintenance",
327
328
  "error_503_desc": "The system is currently undergoing maintenance. Please check back soon.",
328
- "login_method_password": "Password",
329
+ "login_method_password": "Account & password",
329
330
  "login_method_ldap": "Organization",
331
+ "login_method_ldap_hint": "Use the account and password provided by your company or organization",
330
332
  "login_method_email": "Email code",
331
333
  "login_method_sms": "SMS code",
332
334
  "login_methods": "Login method",
@@ -496,5 +498,10 @@
496
498
  "session_recovery_account_error": "Sign in to the original account. The pending action has not continued.",
497
499
  "sensitive_operations_label": "Operation IDs requiring reauthentication",
498
500
  "sensitive_operations_hint": "One operation ID per line, matching the server guard. Database and file rules are combined. Clearing removes only this permission’s rules. The master switch must be enabled.",
499
- "sensitive_operations_invalid": "Use at most 1000 operation IDs, each no longer than 128 characters."
501
+ "sensitive_operations_invalid": "Use at most 1000 operation IDs, each no longer than 128 characters.",
502
+ "filter_bar_expand": "Expand filters",
503
+ "filter_bar_collapse": "Collapse filters",
504
+ "filter_bar_active": "Active filters: {count}",
505
+ "theme_formal": "Formal",
506
+ "keyboard_submit_enter": "Press Enter in a single-line field to submit"
500
507
  }
@@ -20,6 +20,7 @@
20
20
  "settings_close": "閉じる",
21
21
  "settings_language": "言語",
22
22
  "settings_theme": "テーマ",
23
+ "theme_high_contrast": "ハイコントラスト",
23
24
  "combobox_no_match": "一致する項目がありません",
24
25
  "combobox_remove": "削除",
25
26
  "data_table_actions": "操作",
@@ -325,8 +326,9 @@
325
326
  "error_500_desc": "サーバー側で問題が発生しました。しばらくしてから再試行してください。",
326
327
  "error_503_title": "メンテナンス中",
327
328
  "error_503_desc": "現在システムのメンテナンスを行っています。しばらくしてからアクセスしてください。",
328
- "login_method_password": "パスワード",
329
+ "login_method_password": "アカウントとパスワード",
329
330
  "login_method_ldap": "組織アカウント",
331
+ "login_method_ldap_hint": "会社や組織から提供されたアカウントとパスワードを使用します",
330
332
  "login_method_email": "メール認証コード",
331
333
  "login_method_sms": "SMS認証コード",
332
334
  "login_methods": "ログイン方法",
@@ -496,5 +498,10 @@
496
498
  "session_recovery_account_error": "元のアカウントでログインしてください。操作はまだ続行していません。",
497
499
  "sensitive_operations_label": "再認証が必要な操作 ID",
498
500
  "sensitive_operations_hint": "サーバーのガードと一致する操作 ID を1行ずつ入力します。DB とファイルの規則は和集合です。空欄はこの権限の規則だけを削除します。主スイッチが有効な場合に適用されます。",
499
- "sensitive_operations_invalid": "操作 ID は最大1000件、各128文字以内です。"
501
+ "sensitive_operations_invalid": "操作 ID は最大1000件、各128文字以内です。",
502
+ "filter_bar_expand": "絞り込みを展開",
503
+ "filter_bar_collapse": "絞り込みを折りたたむ",
504
+ "filter_bar_active": "適用中の条件:{count}件",
505
+ "theme_formal": "ビジネス(角丸なし)",
506
+ "keyboard_submit_enter": "1行の入力欄で Enter を押して送信"
500
507
  }
@@ -20,6 +20,7 @@
20
20
  "settings_close": "关闭",
21
21
  "settings_language": "语言",
22
22
  "settings_theme": "主题",
23
+ "theme_high_contrast": "高对比",
23
24
  "combobox_no_match": "无匹配结果",
24
25
  "combobox_remove": "移除",
25
26
  "data_table_actions": "操作",
@@ -325,8 +326,9 @@
325
326
  "error_500_desc": "服务器出现了一些问题。我们正在处理,请稍后重试。",
326
327
  "error_503_title": "服务维护中",
327
328
  "error_503_desc": "系统正在维护升级,请稍后再访问。",
328
- "login_method_password": "密码",
329
+ "login_method_password": "账号密码",
329
330
  "login_method_ldap": "企业账号",
331
+ "login_method_ldap_hint": "使用公司或组织提供的账号和密码",
330
332
  "login_method_email": "邮件验证码",
331
333
  "login_method_sms": "短信验证码",
332
334
  "login_methods": "登录方式",
@@ -496,5 +498,10 @@
496
498
  "session_recovery_account_error": "请使用原账号完成登录,当前操作尚未继续。",
497
499
  "sensitive_operations_label": "需要重新认证的操作 ID",
498
500
  "sensitive_operations_hint": "每行一个操作 ID,与服务端守卫一致。数据库与文件配置取并集;清空只移除本权限的规则。主开关关闭时不要求二次认证。",
499
- "sensitive_operations_invalid": "最多 1000 项,每个操作 ID 不超过 128 字符。"
501
+ "sensitive_operations_invalid": "最多 1000 项,每个操作 ID 不超过 128 字符。",
502
+ "filter_bar_expand": "展开筛选",
503
+ "filter_bar_collapse": "收起筛选",
504
+ "filter_bar_active": "已启用 {count} 项筛选",
505
+ "theme_formal": "简洁商务",
506
+ "keyboard_submit_enter": "在单行输入框中按 Enter 提交"
500
507
  }
@@ -0,0 +1,55 @@
1
+ /* 直角商务主题:语义色和圆角统一由共享主题控制。 */
2
+ [data-theme='formal'] {
3
+ color-scheme: light;
4
+ color: #132238;
5
+ background-color: #ffffff;
6
+ --color-base-100: #ffffff;
7
+ --color-base-200: #f5f7fa;
8
+ --color-base-300: #e1e6ed;
9
+ --color-base-content: #132238;
10
+ --color-primary: #123d70;
11
+ --color-primary-content: #ffffff;
12
+ --color-secondary: #45556c;
13
+ --color-secondary-content: #ffffff;
14
+ --color-accent: #126342;
15
+ --color-accent-content: #ffffff;
16
+ --color-neutral: #25354a;
17
+ --color-neutral-content: #ffffff;
18
+ --color-info: #155d91;
19
+ --color-info-content: #ffffff;
20
+ --color-success: #126342;
21
+ --color-success-content: #ffffff;
22
+ --color-warning: #6b4b00;
23
+ --color-warning-content: #ffffff;
24
+ --color-error: #b42318;
25
+ --color-error-content: #ffffff;
26
+ --radius-selector: 0;
27
+ --radius-field: 0;
28
+ --radius-box: 0;
29
+ --hai-radius-sm: 0;
30
+ --hai-radius-md: 0;
31
+ --hai-radius-lg: 0;
32
+ --hai-radius-full: 0;
33
+ --size-selector: 0.25rem;
34
+ --size-field: 0.25rem;
35
+ --border: 1px;
36
+ --depth: 0;
37
+ --noise: 0;
38
+ --hai-focus-color: #123d70;
39
+ }
40
+
41
+ /* 覆盖组件中的显式 rounded 类;单选指示和加载图形保留其交互含义。 */
42
+ [data-theme='formal'] :is([class*='rounded-'], .btn, .input, .select, .textarea, .card, .modal-box, .alert),
43
+ [data-theme='formal'] :focus-visible {
44
+ border-radius: 0;
45
+ }
46
+
47
+ [data-theme='formal'] :is([class^='text-base-content/'], [class*=' text-base-content/']),
48
+ [data-theme='formal'] .table th {
49
+ color: #4b5563;
50
+ }
51
+
52
+ [data-theme='formal'] :is(input, textarea)::placeholder {
53
+ color: #4b5563;
54
+ opacity: 1;
55
+ }
@@ -0,0 +1,64 @@
1
+ /* 共享高对比主题随 theme.css 发布,不依赖 DaisyUI 的内置主题名单。 */
2
+ [data-theme='high-contrast'] {
3
+ color-scheme: dark;
4
+ color: #ffffff;
5
+ background-color: #000000;
6
+ --color-base-100: #000000;
7
+ --color-base-200: #121212;
8
+ --color-base-300: #242424;
9
+ --color-base-content: #ffffff;
10
+ --color-primary: #ffe04d;
11
+ --color-primary-content: #111111;
12
+ --color-secondary: #80d4ff;
13
+ --color-secondary-content: #111111;
14
+ --color-accent: #9df3c4;
15
+ --color-accent-content: #111111;
16
+ --color-neutral: #dce5f0;
17
+ --color-neutral-content: #111111;
18
+ --color-info: #80d4ff;
19
+ --color-info-content: #111111;
20
+ --color-success: #9df3c4;
21
+ --color-success-content: #111111;
22
+ --color-warning: #ffe04d;
23
+ --color-warning-content: #111111;
24
+ --color-error: #ffb4ab;
25
+ --color-error-content: #111111;
26
+ --radius-selector: 0.375rem;
27
+ --radius-field: 0.375rem;
28
+ --radius-box: 0.5rem;
29
+ --size-selector: 0.25rem;
30
+ --size-field: 0.25rem;
31
+ --border: 2px;
32
+ --depth: 0;
33
+ --noise: 0;
34
+ --hai-focus-color: #ffe04d;
35
+ }
36
+
37
+ /* 低透明度的次要正文在此主题中保持可读,伪类和占位符类不误匹配。 */
38
+ [data-theme='high-contrast'] :is([class^='text-base-content/'], [class*=' text-base-content/']),
39
+ [data-theme='high-contrast'] .table th {
40
+ color: #e5e7eb;
41
+ }
42
+
43
+ [data-theme='high-contrast'] :is([class^='border-base-content/'], [class*=' border-base-content/']) {
44
+ border-color: #b5c1cf;
45
+ }
46
+
47
+ [data-theme='high-contrast'] :is(input, textarea)::placeholder {
48
+ color: #dce5f0;
49
+ opacity: 1;
50
+ }
51
+
52
+ [data-theme='high-contrast'] :focus-visible {
53
+ outline: 3px solid #ffe04d;
54
+ outline-offset: 3px;
55
+ }
56
+
57
+ [data-theme='high-contrast'] a:not(.btn) {
58
+ text-decoration: underline;
59
+ text-underline-offset: 0.15em;
60
+ }
61
+
62
+ [data-theme='high-contrast'] ::-webkit-scrollbar-thumb {
63
+ background: #b5c1cf;
64
+ }
@@ -12,6 +12,8 @@
12
12
  */
13
13
 
14
14
  @import './design-tokens.css';
15
+ @import './high-contrast.css';
16
+ @import './formal.css';
15
17
 
16
18
  :root {
17
19
  --hai-theme-color-default: #5765f0;
@@ -59,7 +59,7 @@ export interface ThemeGroup {
59
59
  themes: ThemeInfo[];
60
60
  }
61
61
  /**
62
- * DaisyUI 内置主题配置(精选)
62
+ * 精选 DaisyUI 主题及 UI 共享样式提供的高对比、直角商务主题。
63
63
  *
64
64
  * @example
65
65
  * ```ts
@@ -288,7 +288,7 @@ export declare function createThemeBootstrapScript(options: ThemeBootstrapScript
288
288
  */
289
289
  export declare function getThemeInitScript(): string;
290
290
  /**
291
- * 应用主题
291
+ * 应用主题,并同步原生表单控件配色;自定义主题由宿主 CSS 决定配色。
292
292
  * @param theme - 主题 ID
293
293
  * @param persist - 是否持久化到 localStorage
294
294
  * @returns {void} 无返回值;更新当前文档,并按 persist 决定是否保存偏好。
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { readStoredValue, writeStoredValue } from './internal/browser-safety.js';
8
8
  /**
9
- * DaisyUI 内置主题配置(精选)
9
+ * 精选 DaisyUI 主题及 UI 共享样式提供的高对比、直角商务主题。
10
10
  *
11
11
  * @example
12
12
  * ```ts
@@ -23,6 +23,7 @@ export const THEMES = [
23
23
  { id: 'lofi', name: 'Lo-Fi', dark: false, primaryColor: '#0d0d0d', bgColor: '#ffffff' },
24
24
  { id: 'winter', name: 'Winter', dark: false, primaryColor: '#047aff', bgColor: '#ffffff' },
25
25
  { id: 'nord', name: 'Nord', dark: false, primaryColor: '#5e81ac', bgColor: '#eceff4' },
26
+ { id: 'formal', name: 'Formal', dark: false, primaryColor: '#123d70', bgColor: '#ffffff' },
26
27
  // 暗色主题
27
28
  { id: 'dark', name: 'Dark', dark: true, primaryColor: '#661ae6', bgColor: '#1d232a' },
28
29
  { id: 'dracula', name: 'Dracula', dark: true, primaryColor: '#ff79c6', bgColor: '#282a36' },
@@ -32,6 +33,7 @@ export const THEMES = [
32
33
  { id: 'sunset', name: 'Sunset', dark: true, primaryColor: '#ff865b', bgColor: '#1a1919' },
33
34
  { id: 'luxury', name: 'Luxury', dark: true, primaryColor: '#c9a53d', bgColor: '#171618' },
34
35
  { id: 'coffee', name: 'Coffee', dark: true, primaryColor: '#db924b', bgColor: '#20161f' },
36
+ { id: 'high-contrast', name: 'High contrast', dark: true, primaryColor: '#ffe04d', bgColor: '#000000' },
35
37
  ];
36
38
  /**
37
39
  * 主题分组配置
@@ -278,7 +280,7 @@ export function getThemeInitScript() {
278
280
  });
279
281
  }
280
282
  /**
281
- * 应用主题
283
+ * 应用主题,并同步原生表单控件配色;自定义主题由宿主 CSS 决定配色。
282
284
  * @param theme - 主题 ID
283
285
  * @param persist - 是否持久化到 localStorage
284
286
  * @returns {void} 无返回值;更新当前文档,并按 persist 决定是否保存偏好。
@@ -294,6 +296,7 @@ export function applyTheme(theme, persist = true) {
294
296
  if (typeof document === 'undefined')
295
297
  return;
296
298
  document.documentElement.setAttribute('data-theme', theme);
299
+ document.documentElement.style.setProperty('color-scheme', getThemeInfo(theme) ? resolveThemeTone(theme) : '');
297
300
  if (persist) {
298
301
  writeStoredValue(THEME_STORAGE_KEY, theme);
299
302
  }
@@ -22,8 +22,9 @@ export interface ToastItem extends ToastProps {
22
22
  */
23
23
  declare class ToastState {
24
24
  items: ToastItem[];
25
- /** 自动关闭定时器 */
26
- private timers;
25
+ /** 仅队首计时,等待项在展示后才开始计算停留时间。 */
26
+ private timer;
27
+ private startTimer;
27
28
  /**
28
29
  * 添加 Toast
29
30
  * @param props - 组件的属性对象。
@@ -133,7 +134,7 @@ declare class ToastState {
133
134
  */
134
135
  export declare const toast: ToastState;
135
136
  /**
136
- * 弹出操作成功提示(右上角)。
137
+ * 弹出操作成功提示(默认右下角)。
137
138
  *
138
139
  * @description 统一封装 toast 单例,业务应用无需自建 toast 工具文件即可获得一致的成功反馈。
139
140
  *
@@ -150,7 +151,7 @@ export declare const toast: ToastState;
150
151
  */
151
152
  export declare function notifySuccess(message: string, duration?: number): string;
152
153
  /**
153
- * 弹出操作失败提示(右上角)。
154
+ * 弹出操作失败提示(默认右下角)。
154
155
  *
155
156
  * @description 接受 `Error` 或字符串;`Error` 取其 message,其余回退到 fallback,
156
157
  * 避免各业务页面重复实现错误文案兜底逻辑。
@@ -178,7 +179,7 @@ export declare function notifyError(error: unknown, fallback?: string, duration?
178
179
  */
179
180
  export declare function errorMessage(error: unknown, fallback?: string): string;
180
181
  /**
181
- * 弹出信息提示(右上角)。
182
+ * 弹出信息提示(默认右下角)。
182
183
  *
183
184
  * @param message - 用户可见文案(已本地化)。
184
185
  * @param duration - 可选停留时长(毫秒),默认 3000。
@@ -193,7 +194,7 @@ export declare function errorMessage(error: unknown, fallback?: string): string;
193
194
  */
194
195
  export declare function notifyInfo(message: string, duration?: number): string;
195
196
  /**
196
- * 弹出警告提示(右上角)。
197
+ * 弹出警告提示(默认右下角)。
197
198
  *
198
199
  * @param message - 用户可见文案(已本地化)。
199
200
  * @param duration - 可选停留时长(毫秒),默认 5000。