@h-ai/ui 0.1.0-alpha.29 → 0.1.0-alpha.31

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 (194) hide show
  1. package/README.md +50 -3
  2. package/dist/components/compounds/Accordion.svelte +6 -3
  3. package/dist/components/compounds/Accordion.svelte.d.ts +3 -1
  4. package/dist/components/compounds/ActionSheet.svelte +11 -8
  5. package/dist/components/compounds/ActionSheet.svelte.d.ts +3 -1
  6. package/dist/components/compounds/Alert.svelte +6 -4
  7. package/dist/components/compounds/Alert.svelte.d.ts +3 -2
  8. package/dist/components/compounds/AppBar.svelte +13 -9
  9. package/dist/components/compounds/AppBar.svelte.d.ts +3 -1
  10. package/dist/components/compounds/BottomNav.svelte +13 -10
  11. package/dist/components/compounds/BottomNav.svelte.d.ts +3 -1
  12. package/dist/components/compounds/Breadcrumb.svelte +6 -4
  13. package/dist/components/compounds/Breadcrumb.svelte.d.ts +3 -2
  14. package/dist/components/compounds/Calendar.svelte +7 -2
  15. package/dist/components/compounds/Calendar.svelte.d.ts +3 -1
  16. package/dist/components/compounds/Card.svelte +6 -4
  17. package/dist/components/compounds/Card.svelte.d.ts +3 -2
  18. package/dist/components/compounds/Combobox.svelte +6 -2
  19. package/dist/components/compounds/Combobox.svelte.d.ts +3 -1
  20. package/dist/components/compounds/Confirm.svelte +9 -7
  21. package/dist/components/compounds/Confirm.svelte.d.ts +3 -2
  22. package/dist/components/compounds/DataTable.svelte +6 -2
  23. package/dist/components/compounds/DataTable.svelte.d.ts +2 -1
  24. package/dist/components/compounds/DatePicker.svelte +7 -2
  25. package/dist/components/compounds/DatePicker.svelte.d.ts +3 -1
  26. package/dist/components/compounds/Drawer.svelte +6 -4
  27. package/dist/components/compounds/Drawer.svelte.d.ts +3 -2
  28. package/dist/components/compounds/Dropdown.svelte +6 -4
  29. package/dist/components/compounds/Dropdown.svelte.d.ts +3 -2
  30. package/dist/components/compounds/Empty.svelte +6 -4
  31. package/dist/components/compounds/Empty.svelte.d.ts +3 -2
  32. package/dist/components/compounds/Form.svelte +11 -9
  33. package/dist/components/compounds/Form.svelte.d.ts +3 -2
  34. package/dist/components/compounds/FormField.svelte +6 -4
  35. package/dist/components/compounds/FormField.svelte.d.ts +3 -2
  36. package/dist/components/compounds/InfiniteScroll.svelte +10 -7
  37. package/dist/components/compounds/InfiniteScroll.svelte.d.ts +3 -1
  38. package/dist/components/compounds/MessageBoxContainer.svelte +6 -1
  39. package/dist/components/compounds/MessageBoxContainer.svelte.d.ts +3 -17
  40. package/dist/components/compounds/MessageBoxDialog.svelte +9 -7
  41. package/dist/components/compounds/MessageBoxDialog.svelte.d.ts +2 -1
  42. package/dist/components/compounds/MessageContainer.svelte +43 -66
  43. package/dist/components/compounds/MessageContainer.svelte.d.ts +2 -1
  44. package/dist/components/compounds/Modal.svelte +29 -43
  45. package/dist/components/compounds/Modal.svelte.d.ts +3 -2
  46. package/dist/components/compounds/PageHeader.svelte +6 -2
  47. package/dist/components/compounds/PageHeader.svelte.d.ts +3 -1
  48. package/dist/components/compounds/Pagination.svelte +6 -4
  49. package/dist/components/compounds/Pagination.svelte.d.ts +3 -2
  50. package/dist/components/compounds/Popover.svelte +10 -8
  51. package/dist/components/compounds/Popover.svelte.d.ts +3 -2
  52. package/dist/components/compounds/PullRefresh.svelte +11 -8
  53. package/dist/components/compounds/PullRefresh.svelte.d.ts +3 -1
  54. package/dist/components/compounds/Result.svelte +6 -4
  55. package/dist/components/compounds/Result.svelte.d.ts +3 -2
  56. package/dist/components/compounds/SafeArea.svelte +6 -3
  57. package/dist/components/compounds/SafeArea.svelte.d.ts +3 -1
  58. package/dist/components/compounds/Skeleton.svelte +6 -4
  59. package/dist/components/compounds/Skeleton.svelte.d.ts +3 -2
  60. package/dist/components/compounds/Steps.svelte +6 -4
  61. package/dist/components/compounds/Steps.svelte.d.ts +3 -2
  62. package/dist/components/compounds/SwipeCell.svelte +6 -3
  63. package/dist/components/compounds/SwipeCell.svelte.d.ts +3 -1
  64. package/dist/components/compounds/Tabs.svelte +6 -4
  65. package/dist/components/compounds/Tabs.svelte.d.ts +3 -2
  66. package/dist/components/compounds/TagInput.svelte +11 -9
  67. package/dist/components/compounds/TagInput.svelte.d.ts +3 -2
  68. package/dist/components/compounds/Timeline.svelte +6 -3
  69. package/dist/components/compounds/Timeline.svelte.d.ts +3 -1
  70. package/dist/components/compounds/ToastContainer.svelte +6 -2
  71. package/dist/components/compounds/ToastContainer.svelte.d.ts +2 -1
  72. package/dist/components/compounds/Tooltip.svelte +6 -4
  73. package/dist/components/compounds/Tooltip.svelte.d.ts +3 -2
  74. package/dist/components/primitives/Avatar.svelte +6 -4
  75. package/dist/components/primitives/Avatar.svelte.d.ts +3 -2
  76. package/dist/components/primitives/Badge.svelte +6 -4
  77. package/dist/components/primitives/Badge.svelte.d.ts +3 -2
  78. package/dist/components/primitives/BareButton.svelte +15 -12
  79. package/dist/components/primitives/BareButton.svelte.d.ts +3 -2
  80. package/dist/components/primitives/BareInput.svelte +37 -34
  81. package/dist/components/primitives/BareInput.svelte.d.ts +3 -2
  82. package/dist/components/primitives/Button.svelte +12 -10
  83. package/dist/components/primitives/Button.svelte.d.ts +3 -2
  84. package/dist/components/primitives/Checkbox.svelte +6 -4
  85. package/dist/components/primitives/Checkbox.svelte.d.ts +3 -2
  86. package/dist/components/primitives/IconButton.svelte +6 -4
  87. package/dist/components/primitives/IconButton.svelte.d.ts +3 -2
  88. package/dist/components/primitives/Input.svelte +6 -4
  89. package/dist/components/primitives/Input.svelte.d.ts +3 -2
  90. package/dist/components/primitives/Progress.svelte +6 -4
  91. package/dist/components/primitives/Progress.svelte.d.ts +3 -2
  92. package/dist/components/primitives/Radio.svelte +6 -4
  93. package/dist/components/primitives/Radio.svelte.d.ts +2 -2
  94. package/dist/components/primitives/Range.svelte +6 -3
  95. package/dist/components/primitives/Range.svelte.d.ts +3 -1
  96. package/dist/components/primitives/Rating.svelte +6 -3
  97. package/dist/components/primitives/Rating.svelte.d.ts +3 -1
  98. package/dist/components/primitives/Select.svelte +255 -48
  99. package/dist/components/primitives/Select.svelte.d.ts +2 -2
  100. package/dist/components/primitives/Spinner.svelte +6 -4
  101. package/dist/components/primitives/Spinner.svelte.d.ts +3 -2
  102. package/dist/components/primitives/Switch.svelte +6 -4
  103. package/dist/components/primitives/Switch.svelte.d.ts +3 -2
  104. package/dist/components/primitives/Tag.svelte +6 -4
  105. package/dist/components/primitives/Tag.svelte.d.ts +3 -2
  106. package/dist/components/primitives/Textarea.svelte +34 -19
  107. package/dist/components/primitives/Textarea.svelte.d.ts +3 -2
  108. package/dist/components/primitives/ToggleCheckbox.svelte +13 -10
  109. package/dist/components/primitives/ToggleCheckbox.svelte.d.ts +3 -2
  110. package/dist/components/primitives/ToggleInput.svelte +13 -10
  111. package/dist/components/primitives/ToggleInput.svelte.d.ts +3 -2
  112. package/dist/components/primitives/ToggleRadio.svelte +13 -10
  113. package/dist/components/primitives/ToggleRadio.svelte.d.ts +3 -2
  114. package/dist/components/scenes/ai/AiDocumentDownloadMenu.svelte +8 -5
  115. package/dist/components/scenes/ai/AiDocumentDownloadMenu.svelte.d.ts +3 -1
  116. package/dist/components/scenes/ai/AiDocumentEditor.svelte +40 -10
  117. package/dist/components/scenes/ai/AiDocumentEditor.svelte.d.ts +3 -1
  118. package/dist/components/scenes/ai/MarkdownRenderer.svelte +49 -7
  119. package/dist/components/scenes/ai/MarkdownRenderer.svelte.d.ts +3 -1
  120. package/dist/components/scenes/ai/document-parse.d.ts +2 -0
  121. package/dist/components/scenes/ai/document-parse.js +16 -17
  122. package/dist/components/scenes/ai/document-types.d.ts +6 -1
  123. package/dist/components/scenes/ai/markdown-parse.d.ts +2 -0
  124. package/dist/components/scenes/ai/markdown-parse.js +17 -20
  125. package/dist/components/scenes/ai/safe-html.d.ts +16 -0
  126. package/dist/components/scenes/ai/safe-html.js +284 -0
  127. package/dist/components/scenes/ai/table/AiTableEditor.svelte +6 -3
  128. package/dist/components/scenes/ai/table/AiTableEditor.svelte.d.ts +3 -1
  129. package/dist/components/scenes/ai/table/table-types.d.ts +2 -1
  130. package/dist/components/scenes/app/FeedbackModal.svelte +5 -2
  131. package/dist/components/scenes/app/FeedbackModal.svelte.d.ts +3 -1
  132. package/dist/components/scenes/app/LanguageSwitch.svelte +6 -2
  133. package/dist/components/scenes/app/LanguageSwitch.svelte.d.ts +3 -1
  134. package/dist/components/scenes/app/SettingsLayout.svelte +6 -3
  135. package/dist/components/scenes/app/SettingsLayout.svelte.d.ts +2 -1
  136. package/dist/components/scenes/app/SettingsModal.svelte +6 -3
  137. package/dist/components/scenes/app/SettingsModal.svelte.d.ts +3 -1
  138. package/dist/components/scenes/app/ThemeColorPicker.svelte +6 -3
  139. package/dist/components/scenes/app/ThemeColorPicker.svelte.d.ts +3 -1
  140. package/dist/components/scenes/app/ThemeSelector.svelte +6 -3
  141. package/dist/components/scenes/app/ThemeSelector.svelte.d.ts +3 -1
  142. package/dist/components/scenes/app/ThemeToggle.svelte +6 -2
  143. package/dist/components/scenes/app/ThemeToggle.svelte.d.ts +3 -1
  144. package/dist/components/scenes/crud/CrudDeleteConfirm.svelte +16 -11
  145. package/dist/components/scenes/crud/CrudDeleteConfirm.svelte.d.ts +2 -1
  146. package/dist/components/scenes/crud/CrudDetailDrawer.svelte +6 -3
  147. package/dist/components/scenes/crud/CrudDetailDrawer.svelte.d.ts +2 -2
  148. package/dist/components/scenes/crud/CrudDetailPanel.svelte +6 -3
  149. package/dist/components/scenes/crud/CrudDetailPanel.svelte.d.ts +2 -2
  150. package/dist/components/scenes/crud/CrudEditPanel.svelte +6 -3
  151. package/dist/components/scenes/crud/CrudEditPanel.svelte.d.ts +2 -2
  152. package/dist/components/scenes/crud/CrudFilterBar.svelte +6 -2
  153. package/dist/components/scenes/crud/CrudFilterBar.svelte.d.ts +2 -1
  154. package/dist/components/scenes/crud/CrudPage.svelte +6 -2
  155. package/dist/components/scenes/crud/CrudPage.svelte.d.ts +2 -1
  156. package/dist/components/scenes/crud/crud-types.d.ts +2 -2
  157. package/dist/components/scenes/crypto/EncryptedInput.svelte +6 -3
  158. package/dist/components/scenes/crypto/EncryptedInput.svelte.d.ts +3 -2
  159. package/dist/components/scenes/crypto/HashDisplay.svelte +6 -3
  160. package/dist/components/scenes/crypto/HashDisplay.svelte.d.ts +3 -1
  161. package/dist/components/scenes/crypto/SignatureDisplay.svelte +6 -3
  162. package/dist/components/scenes/crypto/SignatureDisplay.svelte.d.ts +3 -1
  163. package/dist/components/scenes/error/ErrorPage.svelte +6 -3
  164. package/dist/components/scenes/error/ErrorPage.svelte.d.ts +2 -1
  165. package/dist/components/scenes/iam/AuthShell.svelte +6 -3
  166. package/dist/components/scenes/iam/AuthShell.svelte.d.ts +2 -1
  167. package/dist/components/scenes/iam/ChangePasswordForm.svelte +6 -3
  168. package/dist/components/scenes/iam/ChangePasswordForm.svelte.d.ts +3 -1
  169. package/dist/components/scenes/iam/ForgotPasswordForm.svelte +6 -3
  170. package/dist/components/scenes/iam/ForgotPasswordForm.svelte.d.ts +3 -1
  171. package/dist/components/scenes/iam/LoginForm.svelte +6 -3
  172. package/dist/components/scenes/iam/LoginForm.svelte.d.ts +3 -1
  173. package/dist/components/scenes/iam/PasswordInput.svelte +6 -4
  174. package/dist/components/scenes/iam/PasswordInput.svelte.d.ts +3 -2
  175. package/dist/components/scenes/iam/RegisterForm.svelte +6 -4
  176. package/dist/components/scenes/iam/RegisterForm.svelte.d.ts +3 -1
  177. package/dist/components/scenes/iam/ResetPasswordForm.svelte +6 -3
  178. package/dist/components/scenes/iam/ResetPasswordForm.svelte.d.ts +3 -1
  179. package/dist/components/scenes/iam/UserProfile.svelte +6 -3
  180. package/dist/components/scenes/iam/UserProfile.svelte.d.ts +3 -1
  181. package/dist/components/scenes/storage/AvatarUpload.svelte +11 -8
  182. package/dist/components/scenes/storage/AvatarUpload.svelte.d.ts +3 -1
  183. package/dist/components/scenes/storage/FileList.svelte +6 -3
  184. package/dist/components/scenes/storage/FileList.svelte.d.ts +3 -1
  185. package/dist/components/scenes/storage/FileUpload.svelte +6 -3
  186. package/dist/components/scenes/storage/FileUpload.svelte.d.ts +3 -1
  187. package/dist/components/scenes/storage/ImageUpload.svelte +12 -9
  188. package/dist/components/scenes/storage/ImageUpload.svelte.d.ts +3 -1
  189. package/dist/components/scenes/types.d.ts +20 -16
  190. package/dist/styles/global.css +5 -0
  191. package/dist/types.d.ts +48 -41
  192. package/dist/utils.d.ts +6 -1
  193. package/dist/utils.js +16 -1
  194. package/package.json +2 -2
@@ -12,9 +12,10 @@
12
12
  -->
13
13
  <script lang='ts'>
14
14
  import type { Snippet } from 'svelte'
15
+ import type { DataAttributes } from '../../../types.js'
15
16
  import type { ErrorPreset } from './error-presets.js'
16
17
  import { uiM } from '../../../messages.js'
17
- import { cn } from '../../../utils.js'
18
+ import { cn, getDataAttributes } from '../../../utils.js'
18
19
  import Button from '../../primitives/Button.svelte'
19
20
  import { ERROR_PRESETS, resolveErrorPreset } from './error-presets.js'
20
21
 
@@ -31,6 +32,7 @@
31
32
  icon,
32
33
  actions,
33
34
  class: className = '',
35
+ ...restProps
34
36
  }: {
35
37
  /** HTTP 状态码或预设标识;未命中预设时回退到最接近的预设 */
36
38
  status?: number | string | ErrorPreset
@@ -55,8 +57,9 @@
55
57
  /** 自定义操作区插槽(提供时覆盖默认按钮) */
56
58
  actions?: Snippet
57
59
  class?: string
58
- } = $props()
60
+ } & DataAttributes = $props()
59
61
 
62
+ const dataAttributes = $derived(getDataAttributes(restProps))
60
63
  const preset = $derived(ERROR_PRESETS[resolveErrorPreset(status)])
61
64
  const displayCode = $derived(code ?? preset.code)
62
65
  const displayTitle = $derived(title ?? uiM(preset.titleKey))
@@ -77,7 +80,7 @@
77
80
  }
78
81
  </script>
79
82
 
80
- <div class={cn('flex min-h-[60vh] w-full flex-col items-center justify-center px-6 py-12 text-center', className)}>
83
+ <div {...dataAttributes} class={cn('flex min-h-[60vh] w-full flex-col items-center justify-center px-6 py-12 text-center', className)}>
81
84
  <!-- 图标 -->
82
85
  <div class='mb-6 flex size-16 items-center justify-center rounded-2xl bg-base-content/5 text-base-content/40'>
83
86
  {#if icon}
@@ -1,4 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import type { DataAttributes } from '../../../types.js';
2
3
  import type { ErrorPreset } from './error-presets.js';
3
4
  type $$ComponentProps = {
4
5
  /** HTTP 状态码或预设标识;未命中预设时回退到最接近的预设 */
@@ -24,7 +25,7 @@ type $$ComponentProps = {
24
25
  /** 自定义操作区插槽(提供时覆盖默认按钮) */
25
26
  actions?: Snippet;
26
27
  class?: string;
27
- };
28
+ } & DataAttributes;
28
29
  /**
29
30
  * ErrorPage
30
31
  * 通用错误页场景组件
@@ -14,7 +14,8 @@
14
14
  -->
15
15
  <script lang='ts'>
16
16
  import type { Snippet } from 'svelte'
17
- import { cn } from '../../../utils.js'
17
+ import type { DataAttributes } from '../../../types.js'
18
+ import { cn, getDataAttributes } from '../../../utils.js'
18
19
 
19
20
  const {
20
21
  variant = 'card',
@@ -30,6 +31,7 @@
30
31
  footer,
31
32
  children,
32
33
  class: className = '',
34
+ ...restProps
33
35
  }: {
34
36
  /** 布局形态:'card'(居中卡片,默认)或 'split'(左右分栏) */
35
37
  variant?: 'card' | 'split'
@@ -56,15 +58,16 @@
56
58
  /** 表单内容 */
57
59
  children?: Snippet
58
60
  class?: string
59
- } = $props()
61
+ } & DataAttributes = $props()
60
62
 
63
+ const dataAttributes = $derived(getDataAttributes(restProps))
61
64
  const isSplit = $derived(variant === 'split')
62
65
  // split 模式下品牌区已展示 Logo,表单区仅在小屏展示,避免桌面端重复
63
66
  const logoWrapClass = $derived(isSplit ? 'mb-6 flex justify-center lg:hidden' : 'mb-6 flex justify-center')
64
67
  </script>
65
68
 
66
69
  {#snippet formPanel()}
67
- <div class='flex w-full max-w-sm flex-col'>
70
+ <div {...dataAttributes} class='flex w-full max-w-sm flex-col'>
68
71
  {#if logo}
69
72
  <div class={logoWrapClass}>{@render logo()}</div>
70
73
  {/if}
@@ -1,4 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import type { DataAttributes } from '../../../types.js';
2
3
  type $$ComponentProps = {
3
4
  /** 布局形态:'card'(居中卡片,默认)或 'split'(左右分栏) */
4
5
  variant?: 'card' | 'split';
@@ -25,7 +26,7 @@ type $$ComponentProps = {
25
26
  /** 表单内容 */
26
27
  children?: Snippet;
27
28
  class?: string;
28
- };
29
+ } & DataAttributes;
29
30
  /**
30
31
  * AuthShell
31
32
  * 认证页布局场景组件
@@ -3,9 +3,10 @@
3
3
  修改密码表单组件。
4
4
  -->
5
5
  <script lang='ts'>
6
+ import type { DataAttributes } from '../../../types.js'
6
7
  import type { ChangePasswordFormData, ChangePasswordFormProps } from '../types.js'
7
8
  import { uiM } from '../../../messages.js'
8
- import { cn } from '../../../utils.js'
9
+ import { cn, getDataAttributes } from '../../../utils.js'
9
10
  import Alert from '../../compounds/Alert.svelte'
10
11
  import Button from '../../primitives/Button.svelte'
11
12
  import { arePasswordsEqual } from './password-utils.js'
@@ -21,8 +22,10 @@
21
22
  class: className = '',
22
23
  errors = {},
23
24
  onsubmit,
24
- }: ChangePasswordFormProps = $props()
25
+ ...restProps
26
+ }: ChangePasswordFormProps & DataAttributes = $props()
25
27
 
28
+ const dataAttributes = $derived(getDataAttributes(restProps))
26
29
  let oldPassword = $state('')
27
30
  let newPassword = $state('')
28
31
  let confirmPassword = $state('')
@@ -66,7 +69,7 @@
66
69
  }
67
70
  </script>
68
71
 
69
- <form class={formClass} onsubmit={handleSubmit}>
72
+ <form {...dataAttributes} class={formClass} onsubmit={handleSubmit}>
70
73
  {#if requireOldPassword}
71
74
  <div class='space-y-1.5'>
72
75
  <label class='text-sm font-medium text-base-content/70' for='old-password'>
@@ -1,8 +1,10 @@
1
+ import type { DataAttributes } from '../../../types.js';
1
2
  import type { ChangePasswordFormProps } from '../types.js';
3
+ type $$ComponentProps = ChangePasswordFormProps & DataAttributes;
2
4
  /**
3
5
  * ChangePasswordForm
4
6
  * 修改密码表单组件。
5
7
  */
6
- declare const ChangePasswordForm: import("svelte").Component<ChangePasswordFormProps, {}, "">;
8
+ declare const ChangePasswordForm: import("svelte").Component<$$ComponentProps, {}, "">;
7
9
  type ChangePasswordForm = ReturnType<typeof ChangePasswordForm>;
8
10
  export default ChangePasswordForm;
@@ -9,9 +9,10 @@
9
9
  =============================================================================
10
10
  -->
11
11
  <script lang='ts'>
12
+ import type { DataAttributes } from '../../../types.js'
12
13
  import type { ForgotPasswordFormData, ForgotPasswordFormProps } from '../types.js'
13
14
  import { uiM } from '../../../messages.js'
14
- import { cn } from '../../../utils.js'
15
+ import { cn, getDataAttributes } from '../../../utils.js'
15
16
  import Alert from '../../compounds/Alert.svelte'
16
17
  import Button from '../../primitives/Button.svelte'
17
18
  import Input from '../../primitives/Input.svelte'
@@ -30,8 +31,10 @@
30
31
  onsubmit,
31
32
  header,
32
33
  footer,
33
- }: ForgotPasswordFormProps = $props()
34
+ ...restProps
35
+ }: ForgotPasswordFormProps & DataAttributes = $props()
34
36
 
37
+ const dataAttributes = $derived(getDataAttributes(restProps))
35
38
  let email = $state('')
36
39
  let phone = $state('')
37
40
 
@@ -65,7 +68,7 @@
65
68
  }
66
69
  </script>
67
70
 
68
- <form class={formClass} onsubmit={handleSubmit}>
71
+ <form {...dataAttributes} class={formClass} onsubmit={handleSubmit}>
69
72
  <!-- 标题 -->
70
73
  {#if showTitle}
71
74
  <h2 class='text-2xl font-semibold text-center mb-4'>{uiM('forgot_password_title')}</h2>
@@ -1,4 +1,6 @@
1
+ import type { DataAttributes } from '../../../types.js';
1
2
  import type { ForgotPasswordFormProps } from '../types.js';
2
- declare const ForgotPasswordForm: import("svelte").Component<ForgotPasswordFormProps, {}, "">;
3
+ type $$ComponentProps = ForgotPasswordFormProps & DataAttributes;
4
+ declare const ForgotPasswordForm: import("svelte").Component<$$ComponentProps, {}, "">;
3
5
  type ForgotPasswordForm = ReturnType<typeof ForgotPasswordForm>;
4
6
  export default ForgotPasswordForm;
@@ -3,9 +3,10 @@
3
3
  用户登录表单组件,搭配 primitives/compounds 使用。
4
4
  -->
5
5
  <script lang='ts'>
6
+ import type { DataAttributes } from '../../../types.js'
6
7
  import type { LoginFormData, LoginFormProps } from '../types.js'
7
8
  import { uiM } from '../../../messages.js'
8
- import { cn } from '../../../utils.js'
9
+ import { cn, getDataAttributes } from '../../../utils.js'
9
10
  import Alert from '../../compounds/Alert.svelte'
10
11
  import BareButton from '../../primitives/BareButton.svelte'
11
12
  import Button from '../../primitives/Button.svelte'
@@ -30,8 +31,10 @@
30
31
  onforgotpassword,
31
32
  header,
32
33
  footer,
33
- }: LoginFormProps = $props()
34
+ ...restProps
35
+ }: LoginFormProps & DataAttributes = $props()
34
36
 
37
+ const dataAttributes = $derived(getDataAttributes(restProps))
35
38
  const hasAgreements = $derived(
36
39
  !!(agreements?.userAgreementUrl || agreements?.privacyPolicyUrl),
37
40
  )
@@ -66,7 +69,7 @@
66
69
  }
67
70
  </script>
68
71
 
69
- <form class={formClass} onsubmit={handleSubmit}>
72
+ <form {...dataAttributes} class={formClass} onsubmit={handleSubmit}>
70
73
  <!-- 标题 -->
71
74
  {#if showTitle}
72
75
  <h2 class='text-xl font-semibold text-center mb-5'>{uiM('login_title')}</h2>
@@ -1,8 +1,10 @@
1
+ import type { DataAttributes } from '../../../types.js';
1
2
  import type { LoginFormProps } from '../types.js';
3
+ type $$ComponentProps = LoginFormProps & DataAttributes;
2
4
  /**
3
5
  * LoginForm
4
6
  * 用户登录表单组件,搭配 primitives/compounds 使用。
5
7
  */
6
- declare const LoginForm: import("svelte").Component<LoginFormProps, {}, "">;
8
+ declare const LoginForm: import("svelte").Component<$$ComponentProps, {}, "">;
7
9
  type LoginForm = ReturnType<typeof LoginForm>;
8
10
  export default LoginForm;
@@ -4,9 +4,9 @@
4
4
  内置多语言支持,自动跟随全局 locale。
5
5
  -->
6
6
  <script lang='ts'>
7
- import type { Size } from '../../../types.js'
7
+ import type { DataAttributes, Size } from '../../../types.js'
8
8
  import { uiM } from '../../../messages.js'
9
- import { cn } from '../../../utils.js'
9
+ import { cn, getDataAttributes } from '../../../utils.js'
10
10
  import BareButton from '../../primitives/BareButton.svelte'
11
11
  import BareInput from '../../primitives/BareInput.svelte'
12
12
  import Progress from '../../primitives/Progress.svelte'
@@ -71,8 +71,10 @@
71
71
  oninput,
72
72
  onchange,
73
73
  oninvalid,
74
- }: Props = $props()
74
+ ...restProps
75
+ }: Props & DataAttributes = $props()
75
76
 
77
+ const dataAttributes = $derived(getDataAttributes(restProps))
76
78
  let showPassword = $state(false)
77
79
 
78
80
  // 容器高度(与 Input 组件一致)
@@ -146,7 +148,7 @@
146
148
  }
147
149
  </script>
148
150
 
149
- <div class='fieldset w-full'>
151
+ <div {...dataAttributes} class='fieldset w-full'>
150
152
  <!-- 输入框容器 -->
151
153
  <div class={cn(
152
154
  'flex items-center w-full rounded-lg border bg-base-100',
@@ -1,4 +1,4 @@
1
- import type { Size } from '../../../types.js';
1
+ import type { DataAttributes, Size } from '../../../types.js';
2
2
  interface Props {
3
3
  /** 元素 ID */
4
4
  id?: string;
@@ -41,11 +41,12 @@ interface Props {
41
41
  currentTarget: HTMLInputElement;
42
42
  }) => void;
43
43
  }
44
+ type $$ComponentProps = Props & DataAttributes;
44
45
  /**
45
46
  * PasswordInput
46
47
  * 密码输入框组件,支持显示/隐藏切换和密码强度指示。
47
48
  * 内置多语言支持,自动跟随全局 locale。
48
49
  */
49
- declare const PasswordInput: import("svelte").Component<Props, {}, "value" | "inputRef">;
50
+ declare const PasswordInput: import("svelte").Component<$$ComponentProps, {}, "value" | "inputRef">;
50
51
  type PasswordInput = ReturnType<typeof PasswordInput>;
51
52
  export default PasswordInput;
@@ -3,10 +3,10 @@
3
3
  用户注册表单组件,搭配 primitives/compounds 使用。
4
4
  -->
5
5
  <script lang='ts'>
6
- import type { InputProps } from '../../../types.js'
6
+ import type { DataAttributes, InputProps } from '../../../types.js'
7
7
  import type { RegisterField, RegisterFormData, RegisterFormProps } from '../types.js'
8
8
  import { uiM } from '../../../messages.js'
9
- import { cn } from '../../../utils.js'
9
+ import { cn, getDataAttributes } from '../../../utils.js'
10
10
  import Alert from '../../compounds/Alert.svelte'
11
11
  import Button from '../../primitives/Button.svelte'
12
12
  import Input from '../../primitives/Input.svelte'
@@ -29,8 +29,10 @@
29
29
  onsubmit,
30
30
  header,
31
31
  footer,
32
- }: RegisterFormProps = $props()
32
+ ...restProps
33
+ }: RegisterFormProps & DataAttributes = $props()
33
34
 
35
+ const dataAttributes = $derived(getDataAttributes(restProps))
34
36
  const hasAgreements = $derived(
35
37
  !!(agreements?.userAgreementUrl || agreements?.privacyPolicyUrl),
36
38
  )
@@ -159,7 +161,7 @@
159
161
  }
160
162
  </script>
161
163
 
162
- <form class={formClass} onsubmit={handleSubmit}>
164
+ <form {...dataAttributes} class={formClass} onsubmit={handleSubmit}>
163
165
  <!-- 标题 -->
164
166
  {#if showTitle}
165
167
  <h2 class='text-xl font-semibold text-center mb-5'>{uiM('register_title')}</h2>
@@ -1,8 +1,10 @@
1
+ import type { DataAttributes } from '../../../types.js';
1
2
  import type { RegisterFormProps } from '../types.js';
3
+ type $$ComponentProps = RegisterFormProps & DataAttributes;
2
4
  /**
3
5
  * RegisterForm
4
6
  * 用户注册表单组件,搭配 primitives/compounds 使用。
5
7
  */
6
- declare const RegisterForm: import("svelte").Component<RegisterFormProps, {}, "">;
8
+ declare const RegisterForm: import("svelte").Component<$$ComponentProps, {}, "">;
7
9
  type RegisterForm = ReturnType<typeof RegisterForm>;
8
10
  export default RegisterForm;
@@ -3,9 +3,10 @@
3
3
  重置密码表单组件(配合验证码/链接使用)。
4
4
  -->
5
5
  <script lang='ts'>
6
+ import type { DataAttributes } from '../../../types.js'
6
7
  import type { ResetPasswordFormData, ResetPasswordFormProps } from '../types.js'
7
8
  import { uiM } from '../../../messages.js'
8
- import { cn } from '../../../utils.js'
9
+ import { cn, getDataAttributes } from '../../../utils.js'
9
10
  import Alert from '../../compounds/Alert.svelte'
10
11
  import Button from '../../primitives/Button.svelte'
11
12
  import Input from '../../primitives/Input.svelte'
@@ -26,8 +27,10 @@
26
27
  class: className = '',
27
28
  errors = {},
28
29
  onsubmit,
29
- }: ResetPasswordFormProps = $props()
30
+ ...restProps
31
+ }: ResetPasswordFormProps & DataAttributes = $props()
30
32
 
33
+ const dataAttributes = $derived(getDataAttributes(restProps))
31
34
  let code = $state('')
32
35
  let newPassword = $state('')
33
36
  let confirmPassword = $state('')
@@ -65,7 +68,7 @@
65
68
  }
66
69
  </script>
67
70
 
68
- <form class={formClass} onsubmit={handleSubmit}>
71
+ <form {...dataAttributes} class={formClass} onsubmit={handleSubmit}>
69
72
  <!-- 标题 -->
70
73
  {#if showTitle}
71
74
  <h2 class='text-xl font-semibold text-center mb-4'>{uiM('reset_password_title')}</h2>
@@ -1,8 +1,10 @@
1
+ import type { DataAttributes } from '../../../types.js';
1
2
  import type { ResetPasswordFormProps } from '../types.js';
3
+ type $$ComponentProps = ResetPasswordFormProps & DataAttributes;
2
4
  /**
3
5
  * ResetPasswordForm
4
6
  * 重置密码表单组件(配合验证码/链接使用)。
5
7
  */
6
- declare const ResetPasswordForm: import("svelte").Component<ResetPasswordFormProps, {}, "">;
8
+ declare const ResetPasswordForm: import("svelte").Component<$$ComponentProps, {}, "">;
7
9
  type ResetPasswordForm = ReturnType<typeof ResetPasswordForm>;
8
10
  export default ResetPasswordForm;
@@ -9,9 +9,10 @@
9
9
  =============================================================================
10
10
  -->
11
11
  <script lang='ts'>
12
+ import type { DataAttributes } from '../../../types.js'
12
13
  import type { UserProfileField, UserProfileProps, UserProfileSubmitData } from '../types.js'
13
14
  import { uiM } from '../../../messages.js'
14
- import { cn } from '../../../utils.js'
15
+ import { cn, getDataAttributes } from '../../../utils.js'
15
16
  import Alert from '../../compounds/Alert.svelte'
16
17
  import Avatar from '../../primitives/Avatar.svelte'
17
18
  import BareInput from '../../primitives/BareInput.svelte'
@@ -29,8 +30,10 @@
29
30
  errors = {},
30
31
  onsubmit,
31
32
  onavatarchange,
32
- }: UserProfileProps = $props()
33
+ ...restProps
34
+ }: UserProfileProps & DataAttributes = $props()
33
35
 
36
+ const dataAttributes = $derived(getDataAttributes(restProps))
34
37
  let editMode = $state(false)
35
38
  let formData = $state<UserProfileSubmitData>({
36
39
  username: '',
@@ -149,7 +152,7 @@
149
152
  }
150
153
  </script>
151
154
 
152
- <div class={containerClass}>
155
+ <div {...dataAttributes} class={containerClass}>
153
156
  <form onsubmit={handleSubmit}>
154
157
  <div class='space-y-6'>
155
158
  {#each fields as field (field)}
@@ -1,4 +1,6 @@
1
+ import type { DataAttributes } from '../../../types.js';
1
2
  import type { UserProfileProps } from '../types.js';
2
- declare const UserProfile: import("svelte").Component<UserProfileProps, {}, "">;
3
+ type $$ComponentProps = UserProfileProps & DataAttributes;
4
+ declare const UserProfile: import("svelte").Component<$$ComponentProps, {}, "">;
3
5
  type UserProfile = ReturnType<typeof UserProfile>;
4
6
  export default UserProfile;
@@ -8,9 +8,10 @@
8
8
  =============================================================================
9
9
  -->
10
10
  <script lang='ts'>
11
+ import type { DataAttributes } from '../../../types.js'
11
12
  import type { AvatarUploadProps } from '../types.js'
12
13
  import { uiM } from '../../../messages.js'
13
- import { cn } from '../../../utils.js'
14
+ import { cn, getDataAttributes } from '../../../utils.js'
14
15
  import BareInput from '../../primitives/BareInput.svelte'
15
16
 
16
17
  const SAFE_HTTP_URL_REGEX = /^https?:\/\//i
@@ -29,8 +30,10 @@
29
30
  class: className = '',
30
31
  onchange,
31
32
  onerror,
32
- }: AvatarUploadProps = $props()
33
+ ...restProps
34
+ }: AvatarUploadProps & DataAttributes = $props()
33
35
 
36
+ const dataAttributes = $derived(getDataAttributes(restProps))
34
37
  let loading = $state(false)
35
38
  let inputElement = $state<HTMLInputElement | undefined>(undefined)
36
39
  let localPreviewUrl: string | null = $state(null)
@@ -216,12 +219,12 @@
216
219
  }
217
220
  </script>
218
221
 
219
- <div
220
- class={containerClass}
221
- role='button'
222
- tabindex='0'
223
- onclick={handleClick}
224
- onkeydown={e => e.key === 'Enter' && handleClick()}
222
+ <div {...dataAttributes}
223
+ class={containerClass}
224
+ role='button'
225
+ tabindex='0'
226
+ onclick={handleClick}
227
+ onkeydown={e => e.key === 'Enter' && handleClick()}
225
228
  >
226
229
  <BareInput
227
230
  type='file'
@@ -1,4 +1,6 @@
1
+ import type { DataAttributes } from '../../../types.js';
1
2
  import type { AvatarUploadProps } from '../types.js';
2
- declare const AvatarUpload: import("svelte").Component<AvatarUploadProps, {}, "value">;
3
+ type $$ComponentProps = AvatarUploadProps & DataAttributes;
4
+ declare const AvatarUpload: import("svelte").Component<$$ComponentProps, {}, "value">;
3
5
  type AvatarUpload = ReturnType<typeof AvatarUpload>;
4
6
  export default AvatarUpload;
@@ -8,9 +8,10 @@
8
8
  =============================================================================
9
9
  -->
10
10
  <script lang='ts'>
11
+ import type { DataAttributes } from '../../../types.js'
11
12
  import type { FileItem, FileListProps } from '../types.js'
12
13
  import { uiM } from '../../../messages.js'
13
- import { cn } from '../../../utils.js'
14
+ import { cn, getDataAttributes } from '../../../utils.js'
14
15
  import Button from '../../primitives/Button.svelte'
15
16
  import IconButton from '../../primitives/IconButton.svelte'
16
17
 
@@ -27,8 +28,10 @@
27
28
  ondownload,
28
29
  ondelete,
29
30
  onpreview,
30
- }: FileListProps = $props()
31
+ ...restProps
32
+ }: FileListProps & DataAttributes = $props()
31
33
 
34
+ const dataAttributes = $derived(getDataAttributes(restProps))
32
35
  let previewFile = $state<FileItem | null>(null)
33
36
 
34
37
  const containerClass = $derived(
@@ -109,7 +112,7 @@
109
112
  </script>
110
113
 
111
114
  {#if loading}
112
- <div class='flex justify-center py-8'>
115
+ <div {...dataAttributes} class='flex justify-center py-8'>
113
116
  <span class='loading loading-spinner loading-lg'></span>
114
117
  </div>
115
118
  {:else if files.length === 0}
@@ -1,4 +1,6 @@
1
+ import type { DataAttributes } from '../../../types.js';
1
2
  import type { FileListProps } from '../types.js';
2
- declare const FileList: import("svelte").Component<FileListProps, {}, "">;
3
+ type $$ComponentProps = FileListProps & DataAttributes;
4
+ declare const FileList: import("svelte").Component<$$ComponentProps, {}, "">;
3
5
  type FileList = ReturnType<typeof FileList>;
4
6
  export default FileList;
@@ -9,10 +9,11 @@
9
9
  =============================================================================
10
10
  -->
11
11
  <script lang='ts'>
12
+ import type { DataAttributes } from '../../../types.js'
12
13
  import type { FileUploadProps, UploadFile } from '../types.js'
13
14
  import { SvelteMap } from 'svelte/reactivity'
14
15
  import { uiM } from '../../../messages.js'
15
- import { cn, generateId } from '../../../utils.js'
16
+ import { cn, generateId, getDataAttributes } from '../../../utils.js'
16
17
  import BareInput from '../../primitives/BareInput.svelte'
17
18
  import IconButton from '../../primitives/IconButton.svelte'
18
19
  import Progress from '../../primitives/Progress.svelte'
@@ -37,8 +38,10 @@
37
38
  onupload,
38
39
  onerror,
39
40
  onremove,
40
- }: FileUploadProps = $props()
41
+ ...restProps
42
+ }: FileUploadProps & DataAttributes = $props()
41
43
 
44
+ const dataAttributes = $derived(getDataAttributes(restProps))
42
45
  let files = $state<UploadFile[]>([])
43
46
  let isDragging = $state(false)
44
47
  let inputElement = $state<HTMLInputElement | undefined>(undefined)
@@ -361,7 +364,7 @@
361
364
  }
362
365
  </script>
363
366
 
364
- <div class={containerClass}>
367
+ <div {...dataAttributes} class={containerClass}>
365
368
  <!-- 上传区域 -->
366
369
  <div
367
370
  class={dropzoneClass}
@@ -1,5 +1,7 @@
1
+ import type { DataAttributes } from '../../../types.js';
1
2
  import type { FileUploadProps } from '../types.js';
2
- declare const FileUpload: import("svelte").Component<FileUploadProps, {
3
+ type $$ComponentProps = FileUploadProps & DataAttributes;
4
+ declare const FileUpload: import("svelte").Component<$$ComponentProps, {
3
5
  upload: () => Promise<void>;
4
6
  clear: () => void;
5
7
  }, "">;
@@ -9,9 +9,10 @@
9
9
  =============================================================================
10
10
  -->
11
11
  <script lang='ts'>
12
+ import type { DataAttributes } from '../../../types.js'
12
13
  import type { ImageUploadProps } from '../types.js'
13
14
  import { uiM } from '../../../messages.js'
14
- import { cn } from '../../../utils.js'
15
+ import { cn, getDataAttributes } from '../../../utils.js'
15
16
  import BareInput from '../../primitives/BareInput.svelte'
16
17
  import IconButton from '../../primitives/IconButton.svelte'
17
18
  import Spinner from '../../primitives/Spinner.svelte'
@@ -33,8 +34,10 @@
33
34
  class: className = '',
34
35
  onchange,
35
36
  onerror,
36
- }: ImageUploadProps = $props()
37
+ ...restProps
38
+ }: ImageUploadProps & DataAttributes = $props()
37
39
 
40
+ const dataAttributes = $derived(getDataAttributes(restProps))
38
41
  let loading = $state(false)
39
42
  let inputElement = $state<HTMLInputElement | undefined>(undefined)
40
43
  let previewUrl = $derived(value)
@@ -205,13 +208,13 @@
205
208
  }
206
209
  </script>
207
210
 
208
- <div
209
- class={containerClass}
210
- style={containerStyle}
211
- role='button'
212
- tabindex='0'
213
- onclick={handleClick}
214
- onkeydown={e => e.key === 'Enter' && handleClick()}
211
+ <div {...dataAttributes}
212
+ class={containerClass}
213
+ style={containerStyle}
214
+ role='button'
215
+ tabindex='0'
216
+ onclick={handleClick}
217
+ onkeydown={e => e.key === 'Enter' && handleClick()}
215
218
  >
216
219
  <BareInput
217
220
  type='file'
@@ -1,4 +1,6 @@
1
+ import type { DataAttributes } from '../../../types.js';
1
2
  import type { ImageUploadProps } from '../types.js';
2
- declare const ImageUpload: import("svelte").Component<ImageUploadProps, {}, "value">;
3
+ type $$ComponentProps = ImageUploadProps & DataAttributes;
4
+ declare const ImageUpload: import("svelte").Component<$$ComponentProps, {}, "value">;
3
5
  type ImageUpload = ReturnType<typeof ImageUpload>;
4
6
  export default ImageUpload;