@h-ai/ui 0.1.0-alpha.67 → 0.1.0-alpha.68
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 +31 -5
- package/README.ja.md +31 -5
- package/README.md +64 -38
- package/dist/components/compounds/Accordion.svelte +24 -0
- package/dist/components/compounds/Accordion.svelte.d.ts +34 -0
- package/dist/components/compounds/ActionSheet.svelte +24 -0
- package/dist/components/compounds/ActionSheet.svelte.d.ts +38 -0
- package/dist/components/compounds/Alert.svelte +15 -4
- package/dist/components/compounds/Alert.svelte.d.ts +10 -0
- package/dist/components/compounds/AppBar.svelte +24 -0
- package/dist/components/compounds/AppBar.svelte.d.ts +33 -0
- package/dist/components/compounds/BottomNav.svelte +37 -0
- package/dist/components/compounds/BottomNav.svelte.d.ts +43 -0
- package/dist/components/compounds/Breadcrumb.svelte +11 -0
- package/dist/components/compounds/Breadcrumb.svelte.d.ts +20 -0
- package/dist/components/compounds/Calendar.svelte +20 -6
- package/dist/components/compounds/Calendar.svelte.d.ts +20 -6
- package/dist/components/compounds/Card.svelte +10 -0
- package/dist/components/compounds/Card.svelte.d.ts +10 -0
- package/dist/components/compounds/Combobox.svelte +35 -18
- package/dist/components/compounds/Combobox.svelte.d.ts +35 -18
- package/dist/components/compounds/Confirm.svelte +11 -0
- package/dist/components/compounds/Confirm.svelte.d.ts +21 -0
- package/dist/components/compounds/DataTable.svelte +40 -17
- package/dist/components/compounds/DataTable.svelte.d.ts +9 -13
- package/dist/components/compounds/DatePicker.svelte +20 -6
- package/dist/components/compounds/DatePicker.svelte.d.ts +20 -6
- package/dist/components/compounds/Drawer.svelte +11 -0
- package/dist/components/compounds/Drawer.svelte.d.ts +21 -0
- package/dist/components/compounds/Dropdown.svelte +10 -0
- package/dist/components/compounds/Dropdown.svelte.d.ts +10 -0
- package/dist/components/compounds/Empty.svelte +16 -5
- package/dist/components/compounds/Empty.svelte.d.ts +20 -0
- package/dist/components/compounds/Form.svelte +37 -2
- package/dist/components/compounds/Form.svelte.d.ts +20 -0
- package/dist/components/compounds/FormField.svelte +11 -0
- package/dist/components/compounds/FormField.svelte.d.ts +20 -0
- package/dist/components/compounds/FormLayout.svelte +13 -1
- package/dist/components/compounds/FormLayout.svelte.d.ts +13 -0
- package/dist/components/compounds/InfiniteScroll.svelte +24 -0
- package/dist/components/compounds/InfiniteScroll.svelte.d.ts +34 -0
- package/dist/components/compounds/MessageBoxContainer.svelte +11 -0
- package/dist/components/compounds/MessageBoxContainer.svelte.d.ts +21 -0
- package/dist/components/compounds/MessageBoxDialog.svelte +14 -0
- package/dist/components/compounds/MessageBoxDialog.svelte.d.ts +21 -0
- package/dist/components/compounds/MessageContainer.svelte +11 -0
- package/dist/components/compounds/MessageContainer.svelte.d.ts +21 -0
- package/dist/components/compounds/Modal.svelte +10 -0
- package/dist/components/compounds/Modal.svelte.d.ts +10 -0
- package/dist/components/compounds/PageHeader.svelte +21 -8
- package/dist/components/compounds/PageHeader.svelte.d.ts +21 -8
- package/dist/components/compounds/Pagination.svelte +34 -8
- package/dist/components/compounds/Pagination.svelte.d.ts +20 -0
- package/dist/components/compounds/Popover.svelte +11 -0
- package/dist/components/compounds/Popover.svelte.d.ts +20 -0
- package/dist/components/compounds/PullRefresh.svelte +24 -0
- package/dist/components/compounds/PullRefresh.svelte.d.ts +32 -0
- package/dist/components/compounds/Result.svelte +11 -0
- package/dist/components/compounds/Result.svelte.d.ts +20 -0
- package/dist/components/compounds/SafeArea.svelte +24 -0
- package/dist/components/compounds/SafeArea.svelte.d.ts +32 -0
- package/dist/components/compounds/Skeleton.svelte +10 -0
- package/dist/components/compounds/Skeleton.svelte.d.ts +10 -0
- package/dist/components/compounds/Steps.svelte +11 -0
- package/dist/components/compounds/Steps.svelte.d.ts +20 -0
- package/dist/components/compounds/SwipeCell.svelte +24 -0
- package/dist/components/compounds/SwipeCell.svelte.d.ts +37 -0
- package/dist/components/compounds/TableToolbar.svelte +66 -28
- package/dist/components/compounds/TableToolbar.svelte.d.ts +29 -19
- package/dist/components/compounds/Tabs.svelte +58 -10
- package/dist/components/compounds/Tabs.svelte.d.ts +10 -0
- package/dist/components/compounds/TagInput.svelte +11 -0
- package/dist/components/compounds/TagInput.svelte.d.ts +20 -0
- package/dist/components/compounds/Timeline.svelte +24 -0
- package/dist/components/compounds/Timeline.svelte.d.ts +34 -0
- package/dist/components/compounds/ToastContainer.svelte +11 -0
- package/dist/components/compounds/ToastContainer.svelte.d.ts +26 -0
- package/dist/components/compounds/Tooltip.svelte +11 -0
- package/dist/components/compounds/Tooltip.svelte.d.ts +22 -0
- package/dist/components/compounds/accordion-types.d.ts +10 -1
- package/dist/components/compounds/action-sheet-types.d.ts +9 -0
- package/dist/components/compounds/bottom-nav-types.d.ts +9 -0
- package/dist/components/compounds/swipe-cell-types.d.ts +9 -0
- package/dist/components/compounds/timeline-types.d.ts +9 -0
- package/dist/components/control-size.d.ts +17 -0
- package/dist/components/control-size.js +8 -0
- package/dist/components/primitives/Avatar.svelte +10 -0
- package/dist/components/primitives/Avatar.svelte.d.ts +10 -0
- package/dist/components/primitives/Badge.svelte +10 -0
- package/dist/components/primitives/Badge.svelte.d.ts +10 -0
- package/dist/components/primitives/BareButton.svelte +11 -0
- package/dist/components/primitives/BareButton.svelte.d.ts +20 -0
- package/dist/components/primitives/BareInput.svelte +11 -0
- package/dist/components/primitives/BareInput.svelte.d.ts +20 -0
- package/dist/components/primitives/Button.svelte +10 -0
- package/dist/components/primitives/Button.svelte.d.ts +10 -0
- package/dist/components/primitives/Checkbox.svelte +11 -0
- package/dist/components/primitives/Checkbox.svelte.d.ts +20 -0
- package/dist/components/primitives/IconButton.svelte +11 -0
- package/dist/components/primitives/IconButton.svelte.d.ts +20 -0
- package/dist/components/primitives/Input.svelte +10 -0
- package/dist/components/primitives/Input.svelte.d.ts +10 -0
- package/dist/components/primitives/Progress.svelte +11 -0
- package/dist/components/primitives/Progress.svelte.d.ts +20 -0
- package/dist/components/primitives/Radio.svelte +11 -0
- package/dist/components/primitives/Radio.svelte.d.ts +20 -0
- package/dist/components/primitives/Range.svelte +24 -0
- package/dist/components/primitives/Range.svelte.d.ts +34 -0
- package/dist/components/primitives/Rating.svelte +24 -0
- package/dist/components/primitives/Rating.svelte.d.ts +34 -0
- package/dist/components/primitives/Select.svelte +11 -0
- package/dist/components/primitives/Select.svelte.d.ts +21 -0
- package/dist/components/primitives/Spinner.svelte +11 -0
- package/dist/components/primitives/Spinner.svelte.d.ts +20 -0
- package/dist/components/primitives/Switch.svelte +11 -0
- package/dist/components/primitives/Switch.svelte.d.ts +20 -0
- package/dist/components/primitives/Tag.svelte +11 -0
- package/dist/components/primitives/Tag.svelte.d.ts +20 -0
- package/dist/components/primitives/Textarea.svelte +11 -0
- package/dist/components/primitives/Textarea.svelte.d.ts +21 -0
- package/dist/components/primitives/ToggleCheckbox.svelte +11 -0
- package/dist/components/primitives/ToggleCheckbox.svelte.d.ts +20 -0
- package/dist/components/primitives/ToggleInput.svelte +11 -0
- package/dist/components/primitives/ToggleInput.svelte.d.ts +20 -0
- package/dist/components/primitives/ToggleRadio.svelte +11 -0
- package/dist/components/primitives/ToggleRadio.svelte.d.ts +20 -0
- package/dist/components/scenes/ai/AiDocumentDownloadMenu.svelte +27 -0
- package/dist/components/scenes/ai/AiDocumentDownloadMenu.svelte.d.ts +27 -0
- package/dist/components/scenes/ai/AiDocumentEditor.svelte +79 -0
- package/dist/components/scenes/ai/AiDocumentEditor.svelte.d.ts +23 -0
- package/dist/components/scenes/ai/MarkdownRenderer.svelte +11 -0
- package/dist/components/scenes/ai/MarkdownRenderer.svelte.d.ts +28 -0
- package/dist/components/scenes/ai/code-preview.d.ts +28 -0
- package/dist/components/scenes/ai/code-preview.js +20 -0
- package/dist/components/scenes/ai/document-download.d.ts +52 -0
- package/dist/components/scenes/ai/document-download.js +30 -2
- package/dist/components/scenes/ai/document-parse.d.ts +71 -14
- package/dist/components/scenes/ai/document-parse.js +19 -9
- package/dist/components/scenes/ai/document-types.d.ts +222 -88
- package/dist/components/scenes/ai/editor-markdown-extensions.d.ts +16 -0
- package/dist/components/scenes/ai/editor-markdown-extensions.js +16 -0
- package/dist/components/scenes/ai/highlight.d.ts +11 -0
- package/dist/components/scenes/ai/highlight.js +11 -0
- package/dist/components/scenes/ai/markdown-parse.d.ts +8 -2
- package/dist/components/scenes/ai/markdown-parse.js +2 -2
- package/dist/components/scenes/ai/mermaid-host-sync.d.ts +38 -0
- package/dist/components/scenes/ai/mermaid-host-sync.js +30 -0
- package/dist/components/scenes/ai/mermaid-render.d.ts +23 -0
- package/dist/components/scenes/ai/mermaid-render.js +23 -0
- package/dist/components/scenes/ai/safe-html.d.ts +54 -6
- package/dist/components/scenes/ai/safe-html.js +54 -6
- package/dist/components/scenes/ai/table/AiTableEditor.svelte +48 -0
- package/dist/components/scenes/ai/table/AiTableEditor.svelte.d.ts +24 -0
- package/dist/components/scenes/ai/table/table-types.d.ts +79 -0
- package/dist/components/scenes/app/FeedbackModal.svelte +45 -5
- package/dist/components/scenes/app/FeedbackModal.svelte.d.ts +45 -5
- package/dist/components/scenes/app/LanguageSwitch.svelte +29 -19
- package/dist/components/scenes/app/LanguageSwitch.svelte.d.ts +28 -19
- package/dist/components/scenes/app/SettingsLayout.svelte +21 -9
- package/dist/components/scenes/app/SettingsLayout.svelte.d.ts +21 -9
- package/dist/components/scenes/app/SettingsModal.svelte +23 -0
- package/dist/components/scenes/app/SettingsModal.svelte.d.ts +23 -0
- package/dist/components/scenes/app/ThemeColorPicker.svelte +31 -0
- package/dist/components/scenes/app/ThemeColorPicker.svelte.d.ts +31 -0
- package/dist/components/scenes/app/ThemeSelector.svelte +21 -6
- package/dist/components/scenes/app/ThemeSelector.svelte.d.ts +21 -6
- package/dist/components/scenes/app/ThemeToggle.svelte +21 -4
- package/dist/components/scenes/app/ThemeToggle.svelte.d.ts +21 -4
- package/dist/components/scenes/app/index.d.ts +1 -1
- package/dist/components/scenes/app/index.js +1 -1
- package/dist/components/scenes/charts/Chart.svelte +11 -0
- package/dist/components/scenes/charts/Chart.svelte.d.ts +20 -0
- package/dist/components/scenes/charts/chart-theme.d.ts +25 -1
- package/dist/components/scenes/charts/chart-theme.js +25 -1
- package/dist/components/scenes/charts/chart-types.d.ts +83 -7
- package/dist/components/scenes/charts/renderers/LineChart.svelte +53 -0
- package/dist/components/scenes/charts/renderers/LineChart.svelte.d.ts +13 -0
- package/dist/components/scenes/crud/CrudDeleteConfirm.svelte +10 -0
- package/dist/components/scenes/crud/CrudDeleteConfirm.svelte.d.ts +10 -0
- package/dist/components/scenes/crud/CrudDetailDrawer.svelte +8 -0
- package/dist/components/scenes/crud/CrudDetailDrawer.svelte.d.ts +8 -0
- package/dist/components/scenes/crud/CrudDetailPanel.svelte +18 -0
- package/dist/components/scenes/crud/CrudDetailPanel.svelte.d.ts +18 -0
- package/dist/components/scenes/crud/CrudEditPanel.svelte +10 -0
- package/dist/components/scenes/crud/CrudEditPanel.svelte.d.ts +10 -0
- package/dist/components/scenes/crud/CrudFilterBar.svelte +18 -0
- package/dist/components/scenes/crud/CrudFilterBar.svelte.d.ts +18 -0
- package/dist/components/scenes/crud/CrudPage.svelte +37 -5
- package/dist/components/scenes/crud/CrudPage.svelte.d.ts +35 -3
- package/dist/components/scenes/crud/crud-controller.svelte.d.ts +142 -23
- package/dist/components/scenes/crud/crud-controller.svelte.js +22 -11
- package/dist/components/scenes/crud/crud-form-validation.d.ts +12 -0
- package/dist/components/scenes/crud/crud-form-validation.js +12 -0
- package/dist/components/scenes/crud/crud-types.d.ts +79 -8
- package/dist/components/scenes/crud/nav-adapter.d.ts +14 -0
- package/dist/components/scenes/crud/nav-adapter.js +8 -0
- package/dist/components/scenes/crypto/EncryptedInput.svelte +24 -0
- package/dist/components/scenes/crypto/EncryptedInput.svelte.d.ts +34 -0
- package/dist/components/scenes/crypto/HashDisplay.svelte +11 -0
- package/dist/components/scenes/crypto/HashDisplay.svelte.d.ts +21 -0
- package/dist/components/scenes/crypto/SignatureDisplay.svelte +11 -0
- package/dist/components/scenes/crypto/SignatureDisplay.svelte.d.ts +21 -0
- package/dist/components/scenes/error/ErrorPage.svelte +8 -1
- package/dist/components/scenes/error/ErrorPage.svelte.d.ts +8 -1
- package/dist/components/scenes/error/error-presets.d.ts +40 -4
- package/dist/components/scenes/error/error-presets.js +22 -2
- package/dist/components/scenes/guide/GuideHost.svelte +27 -0
- package/dist/components/scenes/guide/GuideHost.svelte.d.ts +27 -0
- package/dist/components/scenes/guide/HelpCenter.svelte +27 -0
- package/dist/components/scenes/guide/HelpCenter.svelte.d.ts +27 -0
- package/dist/components/scenes/iam/AuthPanel.svelte +26 -2
- package/dist/components/scenes/iam/AuthPanel.svelte.d.ts +25 -0
- package/dist/components/scenes/iam/AuthShell.svelte +8 -3
- package/dist/components/scenes/iam/AuthShell.svelte.d.ts +8 -3
- package/dist/components/scenes/iam/ChangePasswordForm.svelte +10 -0
- package/dist/components/scenes/iam/ChangePasswordForm.svelte.d.ts +10 -0
- package/dist/components/scenes/iam/ForgotPasswordForm.svelte +11 -0
- package/dist/components/scenes/iam/ForgotPasswordForm.svelte.d.ts +21 -0
- package/dist/components/scenes/iam/LoginForm.svelte +24 -31
- package/dist/components/scenes/iam/LoginForm.svelte.d.ts +10 -0
- package/dist/components/scenes/iam/PasswordInput.svelte +23 -0
- package/dist/components/scenes/iam/PasswordInput.svelte.d.ts +23 -0
- package/dist/components/scenes/iam/PermGuard.svelte +21 -11
- package/dist/components/scenes/iam/PermGuard.svelte.d.ts +30 -0
- package/dist/components/scenes/iam/RegisterForm.svelte +10 -0
- package/dist/components/scenes/iam/RegisterForm.svelte.d.ts +10 -0
- package/dist/components/scenes/iam/ResetPasswordForm.svelte +10 -0
- package/dist/components/scenes/iam/ResetPasswordForm.svelte.d.ts +10 -0
- package/dist/components/scenes/iam/UserProfile.svelte +11 -0
- package/dist/components/scenes/iam/UserProfile.svelte.d.ts +21 -0
- package/dist/components/scenes/iam/auth-error-message.d.ts +10 -0
- package/dist/components/scenes/iam/auth-error-message.js +10 -0
- package/dist/components/scenes/iam/password-utils.d.ts +39 -1
- package/dist/components/scenes/iam/password-utils.js +39 -1
- package/dist/components/scenes/iam/permission-context.svelte.d.ts +33 -23
- package/dist/components/scenes/iam/permission-context.svelte.js +20 -22
- package/dist/components/scenes/storage/AvatarUpload.svelte +11 -0
- package/dist/components/scenes/storage/AvatarUpload.svelte.d.ts +20 -0
- package/dist/components/scenes/storage/FileList.svelte +13 -2
- package/dist/components/scenes/storage/FileList.svelte.d.ts +20 -0
- package/dist/components/scenes/storage/FileUpload.svelte +37 -2
- package/dist/components/scenes/storage/FileUpload.svelte.d.ts +21 -0
- package/dist/components/scenes/storage/ImageUpload.svelte +11 -0
- package/dist/components/scenes/storage/ImageUpload.svelte.d.ts +21 -0
- package/dist/components/scenes/types.d.ts +352 -11
- package/dist/guide-storage.d.ts +13 -1
- package/dist/guide-storage.js +13 -1
- package/dist/guide-types.d.ts +67 -2
- package/dist/guide.svelte.d.ts +22 -1
- package/dist/guide.svelte.js +22 -1
- package/dist/i18n.svelte.d.ts +64 -3
- package/dist/i18n.svelte.js +99 -18
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -2
- package/dist/internal/browser-safety.d.ts +51 -2
- package/dist/internal/browser-safety.js +45 -7
- package/dist/internal/form-context.d.ts +73 -0
- package/dist/internal/form-context.js +57 -0
- package/dist/internal/form-validation.svelte.d.ts +42 -0
- package/dist/internal/form-validation.svelte.js +26 -0
- package/dist/internal/icon-safety.d.ts +7 -0
- package/dist/internal/icon-safety.js +7 -0
- package/dist/internal/locale.d.ts +19 -0
- package/dist/internal/locale.js +21 -0
- package/dist/message.svelte.d.ts +90 -0
- package/dist/message.svelte.js +84 -0
- package/dist/messagebox.svelte.d.ts +61 -13
- package/dist/messagebox.svelte.js +55 -13
- package/dist/messages/en-US.json +6 -1
- package/dist/messages/ja-JP.json +389 -0
- package/dist/messages/zh-CN.json +6 -1
- package/dist/messages.d.ts +24 -3
- package/dist/messages.js +18 -3
- package/dist/styles/design-tokens.css +4 -2
- package/dist/styles/global.css +28 -8
- package/dist/styles/theme.css +2 -0
- package/dist/theme-config.d.ts +173 -0
- package/dist/theme-config.js +143 -0
- package/dist/toast.svelte.d.ts +114 -4
- package/dist/toast.svelte.js +108 -4
- package/dist/types.d.ts +526 -9
- package/dist/utils/platform.svelte.d.ts +28 -15
- package/dist/utils/platform.svelte.js +19 -14
- package/dist/utils.d.ts +102 -0
- package/dist/utils.js +93 -0
- package/package.json +66 -6
|
@@ -1,4 +1,28 @@
|
|
|
1
|
-
<!--
|
|
1
|
+
<!--
|
|
2
|
+
@component AuthPanel 配置驱动认证场景;网络、通知及 Token 存储由 actions 注入。
|
|
3
|
+
|
|
4
|
+
@example
|
|
5
|
+
```ts
|
|
6
|
+
import { mount, unmount } from 'svelte'
|
|
7
|
+
import { AuthPanel } from '@h-ai/ui'
|
|
8
|
+
import { apiClient } from '@h-ai/api-client'
|
|
9
|
+
import type { AuthPanelProps } from '@h-ai/ui'
|
|
10
|
+
const initialized = await apiClient.init({ baseUrl: 'https://api.example.com/api/v1' })
|
|
11
|
+
if (!initialized.success) throw new Error(initialized.error.message)
|
|
12
|
+
try {
|
|
13
|
+
const result = await apiClient.iam.auth.publicConfig()
|
|
14
|
+
if (!result.success) throw new Error(result.error.message)
|
|
15
|
+
if (!result.data) throw new Error('Public auth configuration unavailable')
|
|
16
|
+
const actions = apiClient.createAuthActions(apiClient)
|
|
17
|
+
const props: AuthPanelProps = { config: result.data, actions, initialMode: 'login' }
|
|
18
|
+
const panel = mount(AuthPanel, { target: document.body, props })
|
|
19
|
+
await unmount(panel)
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
await apiClient.close()
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
-->
|
|
2
26
|
<script lang='ts'>
|
|
3
27
|
import type { HaiError, HaiResult } from '@h-ai/core'
|
|
4
28
|
import type { UIMessageKey } from '../../../messages.js'
|
|
@@ -104,7 +128,7 @@
|
|
|
104
128
|
{:else}
|
|
105
129
|
{#if notice}<Alert variant='success' class='mb-4'>{uiM(notice)}</Alert>{/if}
|
|
106
130
|
{#if mode === 'login'}
|
|
107
|
-
<LoginForm {columns} {labelPosition} {labelWidth} {methods} {loading} {errors} header={loginHeader} extraFields={loginFields}
|
|
131
|
+
<LoginForm {columns} {labelPosition} {labelWidth} {methods} {loading} {errors} header={loginHeader} extraFields={loginFields} showForgotPassword={config.passwordReset.enabled} {forgotPasswordUrl}
|
|
108
132
|
onforgotpassword={forgotPasswordUrl ? undefined : () => switchMode('forgot')}
|
|
109
133
|
otpLength={config.otp.length} resendInterval={config.otp.resendInterval} onsendotp={actions.sendOtp}
|
|
110
134
|
agreements={config.agreements.showOnLogin ? config.agreements : undefined}
|
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
import type { AuthPanelProps } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* AuthPanel 配置驱动认证场景;网络、通知及 Token 存储由 actions 注入。
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { mount, unmount } from 'svelte'
|
|
8
|
+
* import { AuthPanel } from '@h-ai/ui'
|
|
9
|
+
* import { apiClient } from '@h-ai/api-client'
|
|
10
|
+
* import type { AuthPanelProps } from '@h-ai/ui'
|
|
11
|
+
* const initialized = await apiClient.init({ baseUrl: 'https://api.example.com/api/v1' })
|
|
12
|
+
* if (!initialized.success) throw new Error(initialized.error.message)
|
|
13
|
+
* try {
|
|
14
|
+
* const result = await apiClient.iam.auth.publicConfig()
|
|
15
|
+
* if (!result.success) throw new Error(result.error.message)
|
|
16
|
+
* if (!result.data) throw new Error('Public auth configuration unavailable')
|
|
17
|
+
* const actions = apiClient.createAuthActions(apiClient)
|
|
18
|
+
* const props: AuthPanelProps = { config: result.data, actions, initialMode: 'login' }
|
|
19
|
+
* const panel = mount(AuthPanel, { target: document.body, props })
|
|
20
|
+
* await unmount(panel)
|
|
21
|
+
* }
|
|
22
|
+
* finally {
|
|
23
|
+
* await apiClient.close()
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
2
27
|
declare const AuthPanel: import("svelte").Component<AuthPanelProps, {}, "">;
|
|
3
28
|
type AuthPanel = ReturnType<typeof AuthPanel>;
|
|
4
29
|
export default AuthPanel;
|
|
@@ -8,9 +8,14 @@
|
|
|
8
8
|
使用 Svelte 5 Runes ($props, $derived)
|
|
9
9
|
|
|
10
10
|
@example
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
```ts
|
|
12
|
+
import { mount, unmount, createRawSnippet } from 'svelte'
|
|
13
|
+
import type { ComponentProps } from 'svelte'
|
|
14
|
+
import { AuthShell } from '@h-ai/ui'
|
|
15
|
+
const props: ComponentProps<typeof AuthShell> = { variant: 'card', title: '登录', subtitle: '欢迎回来', children: createRawSnippet(() => ({ render: () => "<p>在此放置登录或注册表单。</p>" })) }
|
|
16
|
+
const component = mount(AuthShell, { target: document.body, props })
|
|
17
|
+
await unmount(component)
|
|
18
|
+
```
|
|
14
19
|
-->
|
|
15
20
|
<script lang='ts'>
|
|
16
21
|
import type { Snippet } from 'svelte'
|
|
@@ -40,9 +40,14 @@ type $$ComponentProps = {
|
|
|
40
40
|
* 使用 Svelte 5 Runes ($props, $derived)
|
|
41
41
|
*
|
|
42
42
|
* @example
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
43
|
+
* ```ts
|
|
44
|
+
* import { mount, unmount, createRawSnippet } from 'svelte'
|
|
45
|
+
* import type { ComponentProps } from 'svelte'
|
|
46
|
+
* import { AuthShell } from '@h-ai/ui'
|
|
47
|
+
* const props: ComponentProps<typeof AuthShell> = { variant: 'card', title: '登录', subtitle: '欢迎回来', children: createRawSnippet(() => ({ render: () => "<p>在此放置登录或注册表单。</p>" })) }
|
|
48
|
+
* const component = mount(AuthShell, { target: document.body, props })
|
|
49
|
+
* await unmount(component)
|
|
50
|
+
* ```
|
|
46
51
|
*/
|
|
47
52
|
declare const AuthShell: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
48
53
|
type AuthShell = ReturnType<typeof AuthShell>;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component ChangePasswordForm
|
|
3
3
|
修改密码表单组件。
|
|
4
|
+
|
|
5
|
+
@example
|
|
6
|
+
```ts
|
|
7
|
+
import { mount, unmount } from 'svelte'
|
|
8
|
+
import type { ComponentProps } from 'svelte'
|
|
9
|
+
import { ChangePasswordForm } from '@h-ai/ui'
|
|
10
|
+
const props: ComponentProps<typeof ChangePasswordForm> = { requireOldPassword: true, minPasswordLength: 12 }
|
|
11
|
+
const component = mount(ChangePasswordForm, { target: document.body, props })
|
|
12
|
+
await unmount(component)
|
|
13
|
+
```
|
|
4
14
|
-->
|
|
5
15
|
<script lang='ts'>
|
|
6
16
|
import type { DataAttributes } from '../../../types.js'
|
|
@@ -4,6 +4,16 @@ type $$ComponentProps = ChangePasswordFormProps & DataAttributes;
|
|
|
4
4
|
/**
|
|
5
5
|
* ChangePasswordForm
|
|
6
6
|
* 修改密码表单组件。
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { mount, unmount } from 'svelte'
|
|
11
|
+
* import type { ComponentProps } from 'svelte'
|
|
12
|
+
* import { ChangePasswordForm } from '@h-ai/ui'
|
|
13
|
+
* const props: ComponentProps<typeof ChangePasswordForm> = { requireOldPassword: true, minPasswordLength: 12 }
|
|
14
|
+
* const component = mount(ChangePasswordForm, { target: document.body, props })
|
|
15
|
+
* await unmount(component)
|
|
16
|
+
* ```
|
|
7
17
|
*/
|
|
8
18
|
declare const ChangePasswordForm: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
19
|
type ChangePasswordForm = ReturnType<typeof ChangePasswordForm>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<!--
|
|
2
|
+
@component ForgotPasswordForm
|
|
2
3
|
=============================================================================
|
|
3
4
|
@h-ai/ui - ForgotPasswordForm 组件
|
|
4
5
|
=============================================================================
|
|
@@ -7,6 +8,16 @@
|
|
|
7
8
|
使用 Svelte 5 Runes ($props, $state, $derived)
|
|
8
9
|
使用 primitives/compounds 组件:Input, Button, Alert
|
|
9
10
|
=============================================================================
|
|
11
|
+
|
|
12
|
+
@example
|
|
13
|
+
```ts
|
|
14
|
+
import { mount, unmount } from 'svelte'
|
|
15
|
+
import type { ComponentProps } from 'svelte'
|
|
16
|
+
import { ForgotPasswordForm } from '@h-ai/ui'
|
|
17
|
+
const props: ComponentProps<typeof ForgotPasswordForm> = { mode: 'email' }
|
|
18
|
+
const component = mount(ForgotPasswordForm, { target: document.body, props })
|
|
19
|
+
await unmount(component)
|
|
20
|
+
```
|
|
10
21
|
-->
|
|
11
22
|
<script lang='ts'>
|
|
12
23
|
import type { DataAttributes } from '../../../types.js'
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import type { DataAttributes } from '../../../types.js';
|
|
2
2
|
import type { ForgotPasswordFormProps } from '../types.js';
|
|
3
3
|
type $$ComponentProps = ForgotPasswordFormProps & DataAttributes;
|
|
4
|
+
/**
|
|
5
|
+
* ForgotPasswordForm
|
|
6
|
+
* =============================================================================
|
|
7
|
+
* @h-ai/ui - ForgotPasswordForm 组件
|
|
8
|
+
* =============================================================================
|
|
9
|
+
* 找回密码表单组件
|
|
10
|
+
*
|
|
11
|
+
* 使用 Svelte 5 Runes ($props, $state, $derived)
|
|
12
|
+
* 使用 primitives/compounds 组件:Input, Button, Alert
|
|
13
|
+
* =============================================================================
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { mount, unmount } from 'svelte'
|
|
18
|
+
* import type { ComponentProps } from 'svelte'
|
|
19
|
+
* import { ForgotPasswordForm } from '@h-ai/ui'
|
|
20
|
+
* const props: ComponentProps<typeof ForgotPasswordForm> = { mode: 'email' }
|
|
21
|
+
* const component = mount(ForgotPasswordForm, { target: document.body, props })
|
|
22
|
+
* await unmount(component)
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
4
25
|
declare const ForgotPasswordForm: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
5
26
|
type ForgotPasswordForm = ReturnType<typeof ForgotPasswordForm>;
|
|
6
27
|
export default ForgotPasswordForm;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component LoginForm
|
|
3
3
|
用户登录表单组件,搭配 primitives/compounds 使用。
|
|
4
|
+
|
|
5
|
+
@example
|
|
6
|
+
```ts
|
|
7
|
+
import { mount, unmount } from 'svelte'
|
|
8
|
+
import type { ComponentProps } from 'svelte'
|
|
9
|
+
import { LoginForm } from '@h-ai/ui'
|
|
10
|
+
const props: ComponentProps<typeof LoginForm> = { methods: ['password'] }
|
|
11
|
+
const component = mount(LoginForm, { target: document.body, props })
|
|
12
|
+
await unmount(component)
|
|
13
|
+
```
|
|
4
14
|
-->
|
|
5
15
|
<script lang='ts'>
|
|
6
16
|
import type { HaiError } from '@h-ai/core'
|
|
@@ -13,7 +23,6 @@
|
|
|
13
23
|
import FormLayout from '../../compounds/FormLayout.svelte'
|
|
14
24
|
import BareButton from '../../primitives/BareButton.svelte'
|
|
15
25
|
import Button from '../../primitives/Button.svelte'
|
|
16
|
-
import Checkbox from '../../primitives/Checkbox.svelte'
|
|
17
26
|
import Input from '../../primitives/Input.svelte'
|
|
18
27
|
import AgreementNotice from './AgreementNotice.svelte'
|
|
19
28
|
import { authErrorMessage } from './auth-error-message.js'
|
|
@@ -30,7 +39,6 @@
|
|
|
30
39
|
labelWidth = '8rem',
|
|
31
40
|
disabled = false,
|
|
32
41
|
showTitle = false,
|
|
33
|
-
showRememberMe = true,
|
|
34
42
|
showForgotPassword = true,
|
|
35
43
|
forgotPasswordUrl = '/forgot-password',
|
|
36
44
|
showRegisterLink = false,
|
|
@@ -51,7 +59,6 @@
|
|
|
51
59
|
|
|
52
60
|
let username = $state('')
|
|
53
61
|
let password = $state('')
|
|
54
|
-
let rememberMe = $state(false)
|
|
55
62
|
let selectedMethod = $state<AuthLoginMethod>('password')
|
|
56
63
|
const method = $derived(methods.includes(selectedMethod) ? selectedMethod : methods[0])
|
|
57
64
|
const isOtp = $derived(method === 'email' || method === 'sms')
|
|
@@ -118,7 +125,6 @@
|
|
|
118
125
|
const data: LoginFormData = {
|
|
119
126
|
username,
|
|
120
127
|
password,
|
|
121
|
-
rememberMe,
|
|
122
128
|
method,
|
|
123
129
|
code: isOtp ? code : undefined,
|
|
124
130
|
}
|
|
@@ -204,34 +210,21 @@
|
|
|
204
210
|
{/if}
|
|
205
211
|
{/if}
|
|
206
212
|
|
|
207
|
-
<!--
|
|
208
|
-
{#if method === 'password' &&
|
|
209
|
-
<div class='flex
|
|
210
|
-
{#if
|
|
211
|
-
<
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
{
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
<!-- 忘记密码 -->
|
|
214
|
+
{#if method === 'password' && showForgotPassword}
|
|
215
|
+
<div class='flex justify-end'>
|
|
216
|
+
{#if onforgotpassword}
|
|
217
|
+
<BareButton
|
|
218
|
+
type='button'
|
|
219
|
+
class='link link-primary text-sm'
|
|
220
|
+
onclick={handleForgotPassword}
|
|
221
|
+
>
|
|
222
|
+
{uiM('login_forgot_password')}
|
|
223
|
+
</BareButton>
|
|
217
224
|
{:else}
|
|
218
|
-
<
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
{#if showForgotPassword}
|
|
222
|
-
{#if onforgotpassword}
|
|
223
|
-
<BareButton
|
|
224
|
-
type='button'
|
|
225
|
-
class='link link-primary text-sm'
|
|
226
|
-
onclick={handleForgotPassword}
|
|
227
|
-
>
|
|
228
|
-
{uiM('login_forgot_password')}
|
|
229
|
-
</BareButton>
|
|
230
|
-
{:else}
|
|
231
|
-
<a href={forgotPasswordUrl} class='link link-primary text-sm'>
|
|
232
|
-
{uiM('login_forgot_password')}
|
|
233
|
-
</a>
|
|
234
|
-
{/if}
|
|
225
|
+
<a href={forgotPasswordUrl} class='link link-primary text-sm'>
|
|
226
|
+
{uiM('login_forgot_password')}
|
|
227
|
+
</a>
|
|
235
228
|
{/if}
|
|
236
229
|
</div>
|
|
237
230
|
{/if}
|
|
@@ -4,6 +4,16 @@ type $$ComponentProps = LoginFormProps & DataAttributes;
|
|
|
4
4
|
/**
|
|
5
5
|
* LoginForm
|
|
6
6
|
* 用户登录表单组件,搭配 primitives/compounds 使用。
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { mount, unmount } from 'svelte'
|
|
11
|
+
* import type { ComponentProps } from 'svelte'
|
|
12
|
+
* import { LoginForm } from '@h-ai/ui'
|
|
13
|
+
* const props: ComponentProps<typeof LoginForm> = { methods: ['password'] }
|
|
14
|
+
* const component = mount(LoginForm, { target: document.body, props })
|
|
15
|
+
* await unmount(component)
|
|
16
|
+
* ```
|
|
7
17
|
*/
|
|
8
18
|
declare const LoginForm: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
19
|
type LoginForm = ReturnType<typeof LoginForm>;
|
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
@component PasswordInput
|
|
3
3
|
密码输入框组件,支持显示/隐藏切换和密码强度指示。
|
|
4
4
|
内置多语言支持,自动跟随全局 locale。
|
|
5
|
+
|
|
6
|
+
@example
|
|
7
|
+
```ts
|
|
8
|
+
import { mount, unmount } from 'svelte'
|
|
9
|
+
import type { ComponentProps } from 'svelte'
|
|
10
|
+
import { PasswordInput } from '@h-ai/ui'
|
|
11
|
+
const props: ComponentProps<typeof PasswordInput> = { value: '', autocomplete: 'new-password', showStrength: true, minLength: 12 }
|
|
12
|
+
const component = mount(PasswordInput, { target: document.body, props })
|
|
13
|
+
await unmount(component)
|
|
14
|
+
```
|
|
5
15
|
-->
|
|
6
16
|
<script lang='ts'>
|
|
7
17
|
import type { DataAttributes, FormText, Size } from '../../../types.js'
|
|
@@ -19,6 +29,19 @@
|
|
|
19
29
|
const PASSWORD_DIGIT_REGEX = /\d/
|
|
20
30
|
const PASSWORD_SPECIAL_CHAR_REGEX = /[^a-z0-9]/i
|
|
21
31
|
|
|
32
|
+
/**
|
|
33
|
+
* PasswordInput 组件的属性契约;通过公开组件配置使用。
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { mount, unmount } from 'svelte'
|
|
38
|
+
* import type { ComponentProps } from 'svelte'
|
|
39
|
+
* import { PasswordInput } from '@h-ai/ui'
|
|
40
|
+
* const props: ComponentProps<typeof PasswordInput> = { value: '', autocomplete: 'new-password', showStrength: true, minLength: 12 }
|
|
41
|
+
* const component = mount(PasswordInput, { target: document.body, props })
|
|
42
|
+
* await unmount(component)
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
22
45
|
interface Props {
|
|
23
46
|
/** 元素 ID */
|
|
24
47
|
id?: string
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import type { DataAttributes, FormText, Size } from '../../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* PasswordInput 组件的属性契约;通过公开组件配置使用。
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { mount, unmount } from 'svelte'
|
|
8
|
+
* import type { ComponentProps } from 'svelte'
|
|
9
|
+
* import { PasswordInput } from '@h-ai/ui'
|
|
10
|
+
* const props: ComponentProps<typeof PasswordInput> = { value: '', autocomplete: 'new-password', showStrength: true, minLength: 12 }
|
|
11
|
+
* const component = mount(PasswordInput, { target: document.body, props })
|
|
12
|
+
* await unmount(component)
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
2
15
|
interface Props {
|
|
3
16
|
/** 元素 ID */
|
|
4
17
|
id?: string;
|
|
@@ -46,6 +59,16 @@ type $$ComponentProps = Props & DataAttributes;
|
|
|
46
59
|
* PasswordInput
|
|
47
60
|
* 密码输入框组件,支持显示/隐藏切换和密码强度指示。
|
|
48
61
|
* 内置多语言支持,自动跟随全局 locale。
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* import { mount, unmount } from 'svelte'
|
|
66
|
+
* import type { ComponentProps } from 'svelte'
|
|
67
|
+
* import { PasswordInput } from '@h-ai/ui'
|
|
68
|
+
* const props: ComponentProps<typeof PasswordInput> = { value: '', autocomplete: 'new-password', showStrength: true, minLength: 12 }
|
|
69
|
+
* const component = mount(PasswordInput, { target: document.body, props })
|
|
70
|
+
* await unmount(component)
|
|
71
|
+
* ```
|
|
49
72
|
*/
|
|
50
73
|
declare const PasswordInput: import("svelte").Component<$$ComponentProps, {}, "value" | "inputRef">;
|
|
51
74
|
type PasswordInput = ReturnType<typeof PasswordInput>;
|
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
<!--
|
|
2
|
+
@component PermGuard
|
|
2
3
|
@h-ai/ui — PermGuard 权限守卫组件
|
|
3
4
|
|
|
4
5
|
根据权限上下文条件渲染子内容。
|
|
5
6
|
当用户拥有指定权限时渲染 children,否则渲染 fallback(可选)。
|
|
6
7
|
|
|
7
8
|
@example
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{#snippet fallback()}
|
|
16
|
-
<span>无权限</span>
|
|
17
|
-
{/snippet}
|
|
18
|
-
</PermGuard>
|
|
9
|
+
```ts
|
|
10
|
+
import { mount, unmount, createRawSnippet } from 'svelte'
|
|
11
|
+
import type { ComponentProps } from 'svelte'
|
|
12
|
+
import { PermGuard } from '@h-ai/ui'
|
|
13
|
+
const props: ComponentProps<typeof PermGuard> = { permission: 'user:read', children: createRawSnippet(() => ({ render: () => "<span>用户列表</span>" })) }
|
|
14
|
+
const component = mount(PermGuard, { target: document.body, props })
|
|
15
|
+
await unmount(component)
|
|
19
16
|
```
|
|
20
17
|
-->
|
|
21
18
|
<script lang='ts'>
|
|
22
19
|
import type { Snippet } from 'svelte'
|
|
23
20
|
import { usePermission } from './permission-context.svelte.js'
|
|
24
21
|
|
|
22
|
+
/**
|
|
23
|
+
* PermGuard 组件的属性契约;通过公开组件配置使用。
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { mount, unmount, createRawSnippet } from 'svelte'
|
|
28
|
+
* import type { ComponentProps } from 'svelte'
|
|
29
|
+
* import { PermGuard } from '@h-ai/ui'
|
|
30
|
+
* const props: ComponentProps<typeof PermGuard> = { permission: 'user:read', children: createRawSnippet(() => ({ render: () => "<span>用户列表</span>" })) }
|
|
31
|
+
* const component = mount(PermGuard, { target: document.body, props })
|
|
32
|
+
* await unmount(component)
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
25
35
|
interface Props {
|
|
26
36
|
/** 单个权限码 */
|
|
27
37
|
permission?: string
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
/**
|
|
3
|
+
* PermGuard 组件的属性契约;通过公开组件配置使用。
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { mount, unmount, createRawSnippet } from 'svelte'
|
|
8
|
+
* import type { ComponentProps } from 'svelte'
|
|
9
|
+
* import { PermGuard } from '@h-ai/ui'
|
|
10
|
+
* const props: ComponentProps<typeof PermGuard> = { permission: 'user:read', children: createRawSnippet(() => ({ render: () => "<span>用户列表</span>" })) }
|
|
11
|
+
* const component = mount(PermGuard, { target: document.body, props })
|
|
12
|
+
* await unmount(component)
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
2
15
|
interface Props {
|
|
3
16
|
/** 单个权限码 */
|
|
4
17
|
permission?: string;
|
|
@@ -11,6 +24,23 @@ interface Props {
|
|
|
11
24
|
/** 授权未通过时渲染的内容(可选) */
|
|
12
25
|
fallback?: Snippet;
|
|
13
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* PermGuard
|
|
29
|
+
* @h-ai/ui — PermGuard 权限守卫组件
|
|
30
|
+
*
|
|
31
|
+
* 根据权限上下文条件渲染子内容。
|
|
32
|
+
* 当用户拥有指定权限时渲染 children,否则渲染 fallback(可选)。
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { mount, unmount, createRawSnippet } from 'svelte'
|
|
37
|
+
* import type { ComponentProps } from 'svelte'
|
|
38
|
+
* import { PermGuard } from '@h-ai/ui'
|
|
39
|
+
* const props: ComponentProps<typeof PermGuard> = { permission: 'user:read', children: createRawSnippet(() => ({ render: () => "<span>用户列表</span>" })) }
|
|
40
|
+
* const component = mount(PermGuard, { target: document.body, props })
|
|
41
|
+
* await unmount(component)
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
14
44
|
declare const PermGuard: import("svelte").Component<Props, {}, "">;
|
|
15
45
|
type PermGuard = ReturnType<typeof PermGuard>;
|
|
16
46
|
export default PermGuard;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component RegisterForm
|
|
3
3
|
用户注册表单组件,搭配 primitives/compounds 使用。
|
|
4
|
+
|
|
5
|
+
@example
|
|
6
|
+
```ts
|
|
7
|
+
import { mount, unmount } from 'svelte'
|
|
8
|
+
import type { ComponentProps } from 'svelte'
|
|
9
|
+
import { RegisterForm } from '@h-ai/ui'
|
|
10
|
+
const props: ComponentProps<typeof RegisterForm> = { fields: ['username', 'password'], requireConfirmPassword: true }
|
|
11
|
+
const component = mount(RegisterForm, { target: document.body, props })
|
|
12
|
+
await unmount(component)
|
|
13
|
+
```
|
|
4
14
|
-->
|
|
5
15
|
<script lang='ts'>
|
|
6
16
|
import type { DataAttributes, InputProps } from '../../../types.js'
|
|
@@ -4,6 +4,16 @@ type $$ComponentProps = RegisterFormProps & DataAttributes;
|
|
|
4
4
|
/**
|
|
5
5
|
* RegisterForm
|
|
6
6
|
* 用户注册表单组件,搭配 primitives/compounds 使用。
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { mount, unmount } from 'svelte'
|
|
11
|
+
* import type { ComponentProps } from 'svelte'
|
|
12
|
+
* import { RegisterForm } from '@h-ai/ui'
|
|
13
|
+
* const props: ComponentProps<typeof RegisterForm> = { fields: ['username', 'password'], requireConfirmPassword: true }
|
|
14
|
+
* const component = mount(RegisterForm, { target: document.body, props })
|
|
15
|
+
* await unmount(component)
|
|
16
|
+
* ```
|
|
7
17
|
*/
|
|
8
18
|
declare const RegisterForm: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
19
|
type RegisterForm = ReturnType<typeof RegisterForm>;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component ResetPasswordForm
|
|
3
3
|
重置密码表单组件(配合验证码/链接使用)。
|
|
4
|
+
|
|
5
|
+
@example
|
|
6
|
+
```ts
|
|
7
|
+
import { mount, unmount } from 'svelte'
|
|
8
|
+
import type { ComponentProps } from 'svelte'
|
|
9
|
+
import { ResetPasswordForm } from '@h-ai/ui'
|
|
10
|
+
const props: ComponentProps<typeof ResetPasswordForm> = { showCode: true, minPasswordLength: 12 }
|
|
11
|
+
const component = mount(ResetPasswordForm, { target: document.body, props })
|
|
12
|
+
await unmount(component)
|
|
13
|
+
```
|
|
4
14
|
-->
|
|
5
15
|
<script lang='ts'>
|
|
6
16
|
import type { DataAttributes } from '../../../types.js'
|
|
@@ -4,6 +4,16 @@ type $$ComponentProps = ResetPasswordFormProps & DataAttributes;
|
|
|
4
4
|
/**
|
|
5
5
|
* ResetPasswordForm
|
|
6
6
|
* 重置密码表单组件(配合验证码/链接使用)。
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { mount, unmount } from 'svelte'
|
|
11
|
+
* import type { ComponentProps } from 'svelte'
|
|
12
|
+
* import { ResetPasswordForm } from '@h-ai/ui'
|
|
13
|
+
* const props: ComponentProps<typeof ResetPasswordForm> = { showCode: true, minPasswordLength: 12 }
|
|
14
|
+
* const component = mount(ResetPasswordForm, { target: document.body, props })
|
|
15
|
+
* await unmount(component)
|
|
16
|
+
* ```
|
|
7
17
|
*/
|
|
8
18
|
declare const ResetPasswordForm: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
19
|
type ResetPasswordForm = ReturnType<typeof ResetPasswordForm>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<!--
|
|
2
|
+
@component UserProfile
|
|
2
3
|
=============================================================================
|
|
3
4
|
@h-ai/ui - UserProfile 组件
|
|
4
5
|
=============================================================================
|
|
@@ -7,6 +8,16 @@
|
|
|
7
8
|
使用 Svelte 5 Runes ($props, $state, $derived)
|
|
8
9
|
使用 primitives/compounds 组件:Input, Button, Textarea, Avatar, Alert
|
|
9
10
|
=============================================================================
|
|
11
|
+
|
|
12
|
+
@example
|
|
13
|
+
```ts
|
|
14
|
+
import { mount, unmount } from 'svelte'
|
|
15
|
+
import type { ComponentProps } from 'svelte'
|
|
16
|
+
import { UserProfile } from '@h-ai/ui'
|
|
17
|
+
const props: ComponentProps<typeof UserProfile> = { user: { id: 'u1', username: 'ada', email: 'ada@example.com' }, fields: ['username', 'email'], editable: true }
|
|
18
|
+
const component = mount(UserProfile, { target: document.body, props })
|
|
19
|
+
await unmount(component)
|
|
20
|
+
```
|
|
10
21
|
-->
|
|
11
22
|
<script lang='ts'>
|
|
12
23
|
import type { DataAttributes } from '../../../types.js'
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import type { DataAttributes } from '../../../types.js';
|
|
2
2
|
import type { UserProfileProps } from '../types.js';
|
|
3
3
|
type $$ComponentProps = UserProfileProps & DataAttributes;
|
|
4
|
+
/**
|
|
5
|
+
* UserProfile
|
|
6
|
+
* =============================================================================
|
|
7
|
+
* @h-ai/ui - UserProfile 组件
|
|
8
|
+
* =============================================================================
|
|
9
|
+
* 用户个人信息展示/编辑组件
|
|
10
|
+
*
|
|
11
|
+
* 使用 Svelte 5 Runes ($props, $state, $derived)
|
|
12
|
+
* 使用 primitives/compounds 组件:Input, Button, Textarea, Avatar, Alert
|
|
13
|
+
* =============================================================================
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { mount, unmount } from 'svelte'
|
|
18
|
+
* import type { ComponentProps } from 'svelte'
|
|
19
|
+
* import { UserProfile } from '@h-ai/ui'
|
|
20
|
+
* const props: ComponentProps<typeof UserProfile> = { user: { id: 'u1', username: 'ada', email: 'ada@example.com' }, fields: ['username', 'email'], editable: true }
|
|
21
|
+
* const component = mount(UserProfile, { target: document.body, props })
|
|
22
|
+
* await unmount(component)
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
4
25
|
declare const UserProfile: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
5
26
|
type UserProfile = ReturnType<typeof UserProfile>;
|
|
6
27
|
export default UserProfile;
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import type { HaiError } from '@h-ai/core';
|
|
2
|
+
/**
|
|
3
|
+
* 将已知 IAM 错误码映射为当前语言的认证提示,未知错误保留原消息。
|
|
4
|
+
* @param error - 待显示的安全错误对象或消息。
|
|
5
|
+
* @returns 当前语言的已知认证错误提示;未知错误保留服务端消息。
|
|
6
|
+
*
|
|
7
|
+
* @example 模块内部上下文
|
|
8
|
+
* ```ts
|
|
9
|
+
* const message = authErrorMessage({ code: 'hai:iam:020', message: '登录失败' })
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
2
12
|
export declare function authErrorMessage(error: Pick<HaiError, 'code' | 'message'>): string;
|
|
@@ -27,6 +27,16 @@ const messages = {
|
|
|
27
27
|
'hai:iam:901': 'auth_error_service',
|
|
28
28
|
'hai:iam:999': 'auth_error_service',
|
|
29
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* 将已知 IAM 错误码映射为当前语言的认证提示,未知错误保留原消息。
|
|
32
|
+
* @param error - 待显示的安全错误对象或消息。
|
|
33
|
+
* @returns 当前语言的已知认证错误提示;未知错误保留服务端消息。
|
|
34
|
+
*
|
|
35
|
+
* @example 模块内部上下文
|
|
36
|
+
* ```ts
|
|
37
|
+
* const message = authErrorMessage({ code: 'hai:iam:020', message: '登录失败' })
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
30
40
|
export function authErrorMessage(error) {
|
|
31
41
|
const key = messages[error.code];
|
|
32
42
|
return key ? uiM(key) : error.message;
|