@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
|
@@ -8,12 +8,14 @@
|
|
|
8
8
|
@prop {boolean} grouped - 是否按分组显示
|
|
9
9
|
|
|
10
10
|
@example
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
```ts
|
|
12
|
+
import { mount, unmount } from 'svelte'
|
|
13
|
+
import type { ComponentProps } from 'svelte'
|
|
14
|
+
import { ThemeSelector } from '@h-ai/ui'
|
|
15
|
+
const props: ComponentProps<typeof ThemeSelector> = { currentTheme: 'light', grouped: true }
|
|
16
|
+
const component = mount(ThemeSelector, { target: document.body, props })
|
|
17
|
+
await unmount(component)
|
|
18
|
+
```
|
|
17
19
|
-->
|
|
18
20
|
<script lang='ts'>
|
|
19
21
|
import type { ThemeInfo } from '../../../theme-config.js'
|
|
@@ -23,6 +25,19 @@
|
|
|
23
25
|
import { cn, getDataAttributes } from '../../../utils.js'
|
|
24
26
|
import BareButton from '../../primitives/BareButton.svelte'
|
|
25
27
|
|
|
28
|
+
/**
|
|
29
|
+
* ThemeSelector 组件的属性契约;通过公开组件配置使用。
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { mount, unmount } from 'svelte'
|
|
34
|
+
* import type { ComponentProps } from 'svelte'
|
|
35
|
+
* import { ThemeSelector } from '@h-ai/ui'
|
|
36
|
+
* const props: ComponentProps<typeof ThemeSelector> = { currentTheme: 'light', grouped: true }
|
|
37
|
+
* const component = mount(ThemeSelector, { target: document.body, props })
|
|
38
|
+
* await unmount(component)
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
26
41
|
interface Props {
|
|
27
42
|
currentTheme?: string
|
|
28
43
|
/** 选择主题按钮的 aria-label */
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import type { DataAttributes } from '../../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* ThemeSelector 组件的属性契约;通过公开组件配置使用。
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { mount, unmount } from 'svelte'
|
|
8
|
+
* import type { ComponentProps } from 'svelte'
|
|
9
|
+
* import { ThemeSelector } from '@h-ai/ui'
|
|
10
|
+
* const props: ComponentProps<typeof ThemeSelector> = { currentTheme: 'light', grouped: true }
|
|
11
|
+
* const component = mount(ThemeSelector, { target: document.body, props })
|
|
12
|
+
* await unmount(component)
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
2
15
|
interface Props {
|
|
3
16
|
currentTheme?: string;
|
|
4
17
|
/** 选择主题按钮的 aria-label */
|
|
@@ -23,12 +36,14 @@ type $$ComponentProps = Props & DataAttributes;
|
|
|
23
36
|
* @prop {boolean} grouped - 是否按分组显示
|
|
24
37
|
*
|
|
25
38
|
* @example
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
39
|
+
* ```ts
|
|
40
|
+
* import { mount, unmount } from 'svelte'
|
|
41
|
+
* import type { ComponentProps } from 'svelte'
|
|
42
|
+
* import { ThemeSelector } from '@h-ai/ui'
|
|
43
|
+
* const props: ComponentProps<typeof ThemeSelector> = { currentTheme: 'light', grouped: true }
|
|
44
|
+
* const component = mount(ThemeSelector, { target: document.body, props })
|
|
45
|
+
* await unmount(component)
|
|
46
|
+
* ```
|
|
32
47
|
*/
|
|
33
48
|
declare const ThemeSelector: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
34
49
|
type ThemeSelector = ReturnType<typeof ThemeSelector>;
|
|
@@ -8,10 +8,14 @@
|
|
|
8
8
|
@prop {string} darkTheme - 暗色主题名称
|
|
9
9
|
|
|
10
10
|
@example
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
```ts
|
|
12
|
+
import { mount, unmount } from 'svelte'
|
|
13
|
+
import type { ComponentProps } from 'svelte'
|
|
14
|
+
import { ThemeToggle } from '@h-ai/ui'
|
|
15
|
+
const props: ComponentProps<typeof ThemeToggle> = { currentTheme: 'light', lightTheme: 'light', darkTheme: 'dark' }
|
|
16
|
+
const component = mount(ThemeToggle, { target: document.body, props })
|
|
17
|
+
await unmount(component)
|
|
18
|
+
```
|
|
15
19
|
-->
|
|
16
20
|
<script lang='ts'>
|
|
17
21
|
import type { DataAttributes } from '../../../types.js'
|
|
@@ -20,6 +24,19 @@
|
|
|
20
24
|
import { getDataAttributes } from '../../../utils.js'
|
|
21
25
|
import IconButton from '../../primitives/IconButton.svelte'
|
|
22
26
|
|
|
27
|
+
/**
|
|
28
|
+
* ThemeToggle 组件的属性契约;通过公开组件配置使用。
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { mount, unmount } from 'svelte'
|
|
33
|
+
* import type { ComponentProps } from 'svelte'
|
|
34
|
+
* import { ThemeToggle } from '@h-ai/ui'
|
|
35
|
+
* const props: ComponentProps<typeof ThemeToggle> = { currentTheme: 'light', lightTheme: 'light', darkTheme: 'dark' }
|
|
36
|
+
* const component = mount(ThemeToggle, { target: document.body, props })
|
|
37
|
+
* await unmount(component)
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
23
40
|
interface Props {
|
|
24
41
|
currentTheme?: string
|
|
25
42
|
onchange?: (theme: string) => void
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import type { DataAttributes } from '../../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* ThemeToggle 组件的属性契约;通过公开组件配置使用。
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { mount, unmount } from 'svelte'
|
|
8
|
+
* import type { ComponentProps } from 'svelte'
|
|
9
|
+
* import { ThemeToggle } from '@h-ai/ui'
|
|
10
|
+
* const props: ComponentProps<typeof ThemeToggle> = { currentTheme: 'light', lightTheme: 'light', darkTheme: 'dark' }
|
|
11
|
+
* const component = mount(ThemeToggle, { target: document.body, props })
|
|
12
|
+
* await unmount(component)
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
2
15
|
interface Props {
|
|
3
16
|
currentTheme?: string;
|
|
4
17
|
onchange?: (theme: string) => void;
|
|
@@ -21,10 +34,14 @@ type $$ComponentProps = Props & DataAttributes;
|
|
|
21
34
|
* @prop {string} darkTheme - 暗色主题名称
|
|
22
35
|
*
|
|
23
36
|
* @example
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { mount, unmount } from 'svelte'
|
|
39
|
+
* import type { ComponentProps } from 'svelte'
|
|
40
|
+
* import { ThemeToggle } from '@h-ai/ui'
|
|
41
|
+
* const props: ComponentProps<typeof ThemeToggle> = { currentTheme: 'light', lightTheme: 'light', darkTheme: 'dark' }
|
|
42
|
+
* const component = mount(ThemeToggle, { target: document.body, props })
|
|
43
|
+
* await unmount(component)
|
|
44
|
+
* ```
|
|
28
45
|
*/
|
|
29
46
|
declare const ThemeToggle: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
30
47
|
type ThemeToggle = ReturnType<typeof ThemeToggle>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<!--
|
|
2
|
+
@component Chart
|
|
2
3
|
=============================================================================
|
|
3
4
|
@h-ai/ui - Chart 组件
|
|
4
5
|
=============================================================================
|
|
@@ -6,6 +7,16 @@
|
|
|
6
7
|
|
|
7
8
|
使用 Svelte 5 Runes ($props, $derived)
|
|
8
9
|
=============================================================================
|
|
10
|
+
|
|
11
|
+
@example
|
|
12
|
+
```ts
|
|
13
|
+
import { mount, unmount } from 'svelte'
|
|
14
|
+
import type { ComponentProps } from 'svelte'
|
|
15
|
+
import { Chart } from '@h-ai/ui'
|
|
16
|
+
const props: ComponentProps<typeof Chart> = { type: 'line', data: [{ month: 'Jan', sales: 42 }], x: 'month', y: 'sales', lineVariant: 'segmented-point', tooltipMode: 'nearest' }
|
|
17
|
+
const component = mount(Chart, { target: document.body, props })
|
|
18
|
+
await unmount(component)
|
|
19
|
+
```
|
|
9
20
|
-->
|
|
10
21
|
<script lang='ts'>
|
|
11
22
|
import type { ChartProps, ChartSeries, ChartType } from './chart-types.js'
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
import type { ChartProps } from './chart-types.js';
|
|
2
2
|
import 'layerchart/daisyui-5.css';
|
|
3
|
+
/**
|
|
4
|
+
* Chart
|
|
5
|
+
* =============================================================================
|
|
6
|
+
* @h-ai/ui - Chart 组件
|
|
7
|
+
* =============================================================================
|
|
8
|
+
* 基于 LayerChart 的统一图表入口,仅处理 type 路由、主题色默认值和基础状态。
|
|
9
|
+
*
|
|
10
|
+
* 使用 Svelte 5 Runes ($props, $derived)
|
|
11
|
+
* =============================================================================
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { mount, unmount } from 'svelte'
|
|
16
|
+
* import type { ComponentProps } from 'svelte'
|
|
17
|
+
* import { Chart } from '@h-ai/ui'
|
|
18
|
+
* const props: ComponentProps<typeof Chart> = { type: 'line', data: [{ month: 'Jan', sales: 42 }], x: 'month', y: 'sales', lineVariant: 'segmented-point', tooltipMode: 'nearest' }
|
|
19
|
+
* const component = mount(Chart, { target: document.body, props })
|
|
20
|
+
* await unmount(component)
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
3
23
|
declare const Chart: import("svelte").Component<ChartProps, {}, "">;
|
|
4
24
|
type Chart = ReturnType<typeof Chart>;
|
|
5
25
|
export default Chart;
|
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
* @module chart-theme
|
|
6
6
|
*/
|
|
7
7
|
import type { ChartSeries } from './chart-types.js';
|
|
8
|
+
/**
|
|
9
|
+
* 图表使用的 DaisyUI 语义 CSS 变量映射;切换主题时无需重新取色。
|
|
10
|
+
*
|
|
11
|
+
* @example 模块内部上下文
|
|
12
|
+
* ```ts
|
|
13
|
+
* const series = [{ key: 'sales', color: DAISYUI_CHART_THEME_COLORS.primary }]
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
8
16
|
export declare const DAISYUI_CHART_THEME_COLORS: {
|
|
9
17
|
readonly primary: "var(--color-primary)";
|
|
10
18
|
readonly secondary: "var(--color-secondary)";
|
|
@@ -14,10 +22,26 @@ export declare const DAISYUI_CHART_THEME_COLORS: {
|
|
|
14
22
|
readonly error: "var(--color-error)";
|
|
15
23
|
readonly info: "var(--color-info)";
|
|
16
24
|
};
|
|
17
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* DaisyUI 图表主题色按系列分配的稳定顺序。
|
|
27
|
+
*
|
|
28
|
+
* @example 模块内部上下文
|
|
29
|
+
* ```ts
|
|
30
|
+
* const firstColor = DAISYUI_CHART_COLORS[0]
|
|
31
|
+
* const series = [{ key: 'sales', color: firstColor }]
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
18
34
|
export declare const DAISYUI_CHART_COLORS: readonly ["var(--color-primary)", "var(--color-secondary)", "var(--color-accent)", "var(--color-success)", "var(--color-warning)", "var(--color-error)", "var(--color-info)"];
|
|
19
35
|
/**
|
|
20
36
|
* 为缺少 color 的系列补齐 DaisyUI 主题色。
|
|
21
37
|
* 返回新数组,避免修改调用方传入的 series 对象。
|
|
38
|
+
* @param series - 系列配置;缺失颜色按主题顺序补齐。
|
|
39
|
+
* @returns 补齐主题色的新系列数组;不修改输入,未提供系列时返回 undefined。
|
|
40
|
+
* @typeParam TSeries - 字段值或资源条目的数据类型。
|
|
41
|
+
*
|
|
42
|
+
* @example 模块内部上下文
|
|
43
|
+
* ```ts
|
|
44
|
+
* const series = resolveChartColors([{ key: 'sales', label: '销量' }, { key: 'cost', label: '成本', color: '#ef4444' }])
|
|
45
|
+
* ```
|
|
22
46
|
*/
|
|
23
47
|
export declare function resolveChartColors<TSeries extends ChartSeries>(series?: readonly TSeries[]): TSeries[] | undefined;
|
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
* 颜色保持 CSS 变量引用,避免在 JS 中读取主题并让 DaisyUI 主题切换自然生效。
|
|
5
5
|
* @module chart-theme
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* 图表使用的 DaisyUI 语义 CSS 变量映射;切换主题时无需重新取色。
|
|
9
|
+
*
|
|
10
|
+
* @example 模块内部上下文
|
|
11
|
+
* ```ts
|
|
12
|
+
* const series = [{ key: 'sales', color: DAISYUI_CHART_THEME_COLORS.primary }]
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
7
15
|
export const DAISYUI_CHART_THEME_COLORS = {
|
|
8
16
|
// primary 用作第一条主数据系列,跟随当前 DaisyUI 5 主题主色。
|
|
9
17
|
primary: 'var(--color-primary)',
|
|
@@ -20,7 +28,15 @@ export const DAISYUI_CHART_THEME_COLORS = {
|
|
|
20
28
|
// info 用作信息类系列,补足多系列图表的第七种主题色。
|
|
21
29
|
info: 'var(--color-info)',
|
|
22
30
|
};
|
|
23
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* DaisyUI 图表主题色按系列分配的稳定顺序。
|
|
33
|
+
*
|
|
34
|
+
* @example 模块内部上下文
|
|
35
|
+
* ```ts
|
|
36
|
+
* const firstColor = DAISYUI_CHART_COLORS[0]
|
|
37
|
+
* const series = [{ key: 'sales', color: firstColor }]
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
24
40
|
export const DAISYUI_CHART_COLORS = [
|
|
25
41
|
DAISYUI_CHART_THEME_COLORS.primary,
|
|
26
42
|
DAISYUI_CHART_THEME_COLORS.secondary,
|
|
@@ -33,6 +49,14 @@ export const DAISYUI_CHART_COLORS = [
|
|
|
33
49
|
/**
|
|
34
50
|
* 为缺少 color 的系列补齐 DaisyUI 主题色。
|
|
35
51
|
* 返回新数组,避免修改调用方传入的 series 对象。
|
|
52
|
+
* @param series - 系列配置;缺失颜色按主题顺序补齐。
|
|
53
|
+
* @returns 补齐主题色的新系列数组;不修改输入,未提供系列时返回 undefined。
|
|
54
|
+
* @typeParam TSeries - 字段值或资源条目的数据类型。
|
|
55
|
+
*
|
|
56
|
+
* @example 模块内部上下文
|
|
57
|
+
* ```ts
|
|
58
|
+
* const series = resolveChartColors([{ key: 'sales', label: '销量' }, { key: 'cost', label: '成本', color: '#ef4444' }])
|
|
59
|
+
* ```
|
|
36
60
|
*/
|
|
37
61
|
export function resolveChartColors(series) {
|
|
38
62
|
if (!series)
|
|
@@ -5,20 +5,83 @@
|
|
|
5
5
|
* @module chart-types
|
|
6
6
|
*/
|
|
7
7
|
import type { DataAttributes } from '../../../types.js';
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* 图表数据单元允许的原子值,和 LayerChart 常见 accessor 输入保持一致。
|
|
10
|
+
*
|
|
11
|
+
* @example 模块内部上下文
|
|
12
|
+
* ```ts
|
|
13
|
+
* const example: ChartDataValue = 42
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
9
16
|
export type ChartDataValue = string | number | Date;
|
|
10
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* 图表数据项;每个字段都可被 x/y/key/value 等 accessor 引用。
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import type { ChartDataItem } from '@h-ai/ui'
|
|
23
|
+
* const example: ChartDataItem = { month: 'Jan', sales: 42 }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
11
26
|
export type ChartDataItem = Record<string, ChartDataValue>;
|
|
12
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* LayerChart accessor 的常用子集,用于 series.value 等透传配置。
|
|
29
|
+
*
|
|
30
|
+
* @example 模块内部上下文
|
|
31
|
+
* ```ts
|
|
32
|
+
* const example: ChartAccessor = 'sales'
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
13
35
|
export type ChartAccessor = string | number | ((item: ChartDataItem) => unknown) | ChartAccessor[] | null | undefined;
|
|
14
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* 统一 Chart 支持的高阶图表类型。
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import type { ChartType } from '@h-ai/ui'
|
|
42
|
+
* const example: ChartType = 'line'
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
15
45
|
export type ChartType = 'bar' | 'line' | 'area' | 'pie' | 'scatter';
|
|
16
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Chart 预设高度档位;具体像素值在 Chart.svelte 中固定映射。
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* import type { ChartSize } from '@h-ai/ui'
|
|
52
|
+
* const example: ChartSize = 'md'
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
17
55
|
export type ChartSize = 'sm' | 'md' | 'lg';
|
|
18
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* 折线图渲染变体;default 保持 LayerChart 原生渲染,segmented-point 提供分段线 + 圆点样式。
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* import type { ChartLineVariant } from '@h-ai/ui'
|
|
62
|
+
* const example: ChartLineVariant = 'segmented-point'
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
19
65
|
export type ChartLineVariant = 'default' | 'segmented-point';
|
|
20
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* 折线图 tooltip 触发方式;nearest 会在绘图区内吸附最近数据点。
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* import type { ChartTooltipMode } from '@h-ai/ui'
|
|
72
|
+
* const example: ChartTooltipMode = 'nearest'
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
21
75
|
export type ChartTooltipMode = 'default' | 'nearest';
|
|
76
|
+
/**
|
|
77
|
+
* 图表系列配置;key 关联数据字段,未指定的颜色由当前主题补齐。
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* import type { ChartSeries } from '@h-ai/ui'
|
|
82
|
+
* const example: ChartSeries = { key: 'sales', label: '销量', color: '#2563eb' }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
22
85
|
export interface ChartSeries {
|
|
23
86
|
/** 系列稳定标识;宽表数据通常对应数据项中的数值字段名。 */
|
|
24
87
|
key: string;
|
|
@@ -39,6 +102,19 @@ export interface ChartSeries {
|
|
|
39
102
|
/** 保留 LayerChart 新增 series 字段的透传能力,避免薄包装层限制底层 API。 */
|
|
40
103
|
[key: string]: unknown;
|
|
41
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* 统一图表的类型、数据和坐标映射;其他配置透传当前 LayerChart renderer。
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```svelte
|
|
110
|
+
* <script lang="ts">
|
|
111
|
+
* import { Chart } from '@h-ai/ui'
|
|
112
|
+
* import type { ChartProps } from '@h-ai/ui'
|
|
113
|
+
* const props: ChartProps = { type: 'line', data: [{ month: 'Jan', sales: 42 }], x: 'month', y: 'sales', lineVariant: 'segmented-point', tooltipMode: 'nearest' }
|
|
114
|
+
* </script>
|
|
115
|
+
* <Chart {...props} />
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
42
118
|
export interface ChartProps extends DataAttributes {
|
|
43
119
|
/** 选择内部 LayerChart 高阶组件;必填。 */
|
|
44
120
|
type: ChartType;
|
|
@@ -17,6 +17,14 @@
|
|
|
17
17
|
} from '../chart-types.js'
|
|
18
18
|
import { LineChart as LayerLineChart } from 'layerchart'
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* 分段折线图单个数据点,保留展示标签与数值。
|
|
22
|
+
*
|
|
23
|
+
* @example 模块内部上下文
|
|
24
|
+
* ```ts
|
|
25
|
+
* const example: SegmentedLinePoint = { label: 'Jan', value: 42 }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
20
28
|
interface SegmentedLinePoint {
|
|
21
29
|
/** 横轴展示标签,来源于 Chart 的 x accessor。 */
|
|
22
30
|
label: string
|
|
@@ -24,6 +32,14 @@
|
|
|
24
32
|
value: number
|
|
25
33
|
}
|
|
26
34
|
|
|
35
|
+
/**
|
|
36
|
+
* 分段折线图归一化后的系列与样式。
|
|
37
|
+
*
|
|
38
|
+
* @example 模块内部上下文
|
|
39
|
+
* ```ts
|
|
40
|
+
* const example: SegmentedLineSeries = { key: 'sales', label: '销量', color: '#2563eb', points: [{ label: 'Jan', value: 42 }], dashed: false }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
27
43
|
interface SegmentedLineSeries {
|
|
28
44
|
/** 系列稳定标识,优先来自 ChartSeries.key。 */
|
|
29
45
|
key: string
|
|
@@ -37,6 +53,14 @@
|
|
|
37
53
|
dashed: boolean
|
|
38
54
|
}
|
|
39
55
|
|
|
56
|
+
/**
|
|
57
|
+
* 分段折线图中按比例映射到 SVG 视口的数据点。
|
|
58
|
+
*
|
|
59
|
+
* @example 模块内部上下文
|
|
60
|
+
* ```ts
|
|
61
|
+
* const example: SegmentedLineCoordinate = { label: 'Jan', value: 42, x: 120, y: 80 }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
40
64
|
interface SegmentedLineCoordinate extends SegmentedLinePoint {
|
|
41
65
|
/** SVG viewBox 中的横向坐标。 */
|
|
42
66
|
x: number
|
|
@@ -44,6 +68,14 @@
|
|
|
44
68
|
y: number
|
|
45
69
|
}
|
|
46
70
|
|
|
71
|
+
/**
|
|
72
|
+
* 折线图 tooltip 内的一条系列数据。
|
|
73
|
+
*
|
|
74
|
+
* @example 模块内部上下文
|
|
75
|
+
* ```ts
|
|
76
|
+
* const example: SegmentedLineTooltipItem = { label: '销量', value: 42, color: '#2563eb' }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
47
79
|
interface SegmentedLineTooltipItem {
|
|
48
80
|
/** tooltip 中展示的系列名称。 */
|
|
49
81
|
label: string
|
|
@@ -53,6 +85,14 @@
|
|
|
53
85
|
color: string
|
|
54
86
|
}
|
|
55
87
|
|
|
88
|
+
/**
|
|
89
|
+
* 当前吸附数据点的 tooltip 位置与多系列内容。
|
|
90
|
+
*
|
|
91
|
+
* @example 模块内部上下文
|
|
92
|
+
* ```ts
|
|
93
|
+
* const example: SegmentedLineTooltip = { x: 120, leftPercent: 25, topPercent: 50, label: 'Jan', items: [{ label: '销量', value: 42, color: '#2563eb' }] }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
56
96
|
interface SegmentedLineTooltip {
|
|
57
97
|
/** 当前吸附数据点在 SVG 坐标系内的横向位置。 */
|
|
58
98
|
x: number
|
|
@@ -66,6 +106,19 @@
|
|
|
66
106
|
items: SegmentedLineTooltipItem[]
|
|
67
107
|
}
|
|
68
108
|
|
|
109
|
+
/**
|
|
110
|
+
* LineChart 组件的属性契约;通过公开组件配置使用。
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* import { mount, unmount } from 'svelte'
|
|
115
|
+
* import type { ComponentProps } from 'svelte'
|
|
116
|
+
* import { Chart } from '@h-ai/ui'
|
|
117
|
+
* const props: ComponentProps<typeof Chart> = { type: 'line', data: [{ month: 'Jan', sales: 42 }], x: 'month', y: 'sales', lineVariant: 'segmented-point', tooltipMode: 'nearest' }
|
|
118
|
+
* const component = mount(Chart, { target: document.body, props })
|
|
119
|
+
* await unmount(component)
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
69
122
|
interface Props extends LineChartProps<ChartDataItem> {
|
|
70
123
|
/** 折线图渲染变体;default 保持 LayerChart 原生渲染。 */
|
|
71
124
|
lineVariant?: ChartLineVariant
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import type { LineChartProps } from 'layerchart';
|
|
2
2
|
import type { ChartDataItem, ChartLineVariant, ChartTooltipMode } from '../chart-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* LineChart 组件的属性契约;通过公开组件配置使用。
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { mount, unmount } from 'svelte'
|
|
9
|
+
* import type { ComponentProps } from 'svelte'
|
|
10
|
+
* import { Chart } from '@h-ai/ui'
|
|
11
|
+
* const props: ComponentProps<typeof Chart> = { type: 'line', data: [{ month: 'Jan', sales: 42 }], x: 'month', y: 'sales', lineVariant: 'segmented-point', tooltipMode: 'nearest' }
|
|
12
|
+
* const component = mount(Chart, { target: document.body, props })
|
|
13
|
+
* await unmount(component)
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
3
16
|
interface Props extends LineChartProps<ChartDataItem> {
|
|
4
17
|
/** 折线图渲染变体;default 保持 LayerChart 原生渲染。 */
|
|
5
18
|
lineVariant?: ChartLineVariant;
|
|
@@ -4,6 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
使用 Svelte 5 Runes ($props)
|
|
6
6
|
使用 compounds 组件:Confirm
|
|
7
|
+
|
|
8
|
+
@example
|
|
9
|
+
```ts
|
|
10
|
+
import { mount, unmount } from 'svelte'
|
|
11
|
+
import type { ComponentProps } from 'svelte'
|
|
12
|
+
import { CrudDeleteConfirm } from '@h-ai/ui'
|
|
13
|
+
const props: ComponentProps<typeof CrudDeleteConfirm> = { open: true, title: '删除用户', message: '删除后不可恢复。' }
|
|
14
|
+
const component = mount(CrudDeleteConfirm, { target: document.body, props })
|
|
15
|
+
await unmount(component)
|
|
16
|
+
```
|
|
7
17
|
-->
|
|
8
18
|
<script lang='ts'>
|
|
9
19
|
import type { DataAttributes } from '../../../types.js'
|
|
@@ -14,6 +14,16 @@ type $$ComponentProps = {
|
|
|
14
14
|
*
|
|
15
15
|
* 使用 Svelte 5 Runes ($props)
|
|
16
16
|
* 使用 compounds 组件:Confirm
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { mount, unmount } from 'svelte'
|
|
21
|
+
* import type { ComponentProps } from 'svelte'
|
|
22
|
+
* import { CrudDeleteConfirm } from '@h-ai/ui'
|
|
23
|
+
* const props: ComponentProps<typeof CrudDeleteConfirm> = { open: true, title: '删除用户', message: '删除后不可恢复。' }
|
|
24
|
+
* const component = mount(CrudDeleteConfirm, { target: document.body, props })
|
|
25
|
+
* await unmount(component)
|
|
26
|
+
* ```
|
|
17
27
|
*/
|
|
18
28
|
declare const CrudDeleteConfirm: import("svelte").Component<$$ComponentProps, {}, "open">;
|
|
19
29
|
type CrudDeleteConfirm = ReturnType<typeof CrudDeleteConfirm>;
|
|
@@ -16,6 +16,14 @@
|
|
|
16
16
|
import Badge from '../../primitives/Badge.svelte'
|
|
17
17
|
import Button from '../../primitives/Button.svelte'
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* 详情/列表对字段定义的局部视图,不是独立的公开资源模型。
|
|
21
|
+
*
|
|
22
|
+
* @example 模块内部上下文
|
|
23
|
+
* ```ts
|
|
24
|
+
* const example: FieldDef = { id: 'email', label: '邮箱', type: 'email', inDetail: true }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
19
27
|
type FieldDef = {
|
|
20
28
|
id: string
|
|
21
29
|
label: string | (() => string)
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { DataAttributes, Size } from '../../../types.js';
|
|
3
3
|
import type { CrudFormVariant } from './crud-types.js';
|
|
4
|
+
/**
|
|
5
|
+
* 详情/列表对字段定义的局部视图,不是独立的公开资源模型。
|
|
6
|
+
*
|
|
7
|
+
* @example 模块内部上下文
|
|
8
|
+
* ```ts
|
|
9
|
+
* const example: FieldDef = { id: 'email', label: '邮箱', type: 'email', inDetail: true }
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
4
12
|
type FieldDef = {
|
|
5
13
|
id: string;
|
|
6
14
|
label: string | (() => string);
|
|
@@ -4,6 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
使用 Svelte 5 Runes ($props, $derived)
|
|
6
6
|
使用 compounds 组件:Drawer, Modal, Badge
|
|
7
|
+
|
|
8
|
+
@example
|
|
9
|
+
```ts
|
|
10
|
+
import { mount, unmount } from 'svelte'
|
|
11
|
+
import type { ComponentProps } from 'svelte'
|
|
12
|
+
import { CrudDetailPanel } from '@h-ai/ui'
|
|
13
|
+
const props: ComponentProps<typeof CrudDetailPanel> = { open: true, title: '用户详情', item: { email: 'ada@example.com' }, fields: [{ id: 'email', label: '邮箱', type: 'email' }] }
|
|
14
|
+
const component = mount(CrudDetailPanel, { target: document.body, props })
|
|
15
|
+
await unmount(component)
|
|
16
|
+
```
|
|
7
17
|
-->
|
|
8
18
|
<script lang='ts'>
|
|
9
19
|
import type { Snippet } from 'svelte'
|
|
@@ -16,6 +26,14 @@
|
|
|
16
26
|
import Badge from '../../primitives/Badge.svelte'
|
|
17
27
|
import Button from '../../primitives/Button.svelte'
|
|
18
28
|
|
|
29
|
+
/**
|
|
30
|
+
* 详情/列表对字段定义的局部视图,不是独立的公开资源模型。
|
|
31
|
+
*
|
|
32
|
+
* @example 模块内部上下文
|
|
33
|
+
* ```ts
|
|
34
|
+
* const example: FieldDef = { id: 'email', label: '邮箱', type: 'email', inDetail: true }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
19
37
|
type FieldDef = {
|
|
20
38
|
id: string
|
|
21
39
|
label: string | (() => string)
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { DataAttributes, Size } from '../../../types.js';
|
|
3
3
|
import type { CrudDensity, CrudFormVariant } from './crud-types.js';
|
|
4
|
+
/**
|
|
5
|
+
* 详情/列表对字段定义的局部视图,不是独立的公开资源模型。
|
|
6
|
+
*
|
|
7
|
+
* @example 模块内部上下文
|
|
8
|
+
* ```ts
|
|
9
|
+
* const example: FieldDef = { id: 'email', label: '邮箱', type: 'email', inDetail: true }
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
4
12
|
type FieldDef = {
|
|
5
13
|
id: string;
|
|
6
14
|
label: string | (() => string);
|
|
@@ -42,6 +50,16 @@ type $$ComponentProps = {
|
|
|
42
50
|
*
|
|
43
51
|
* 使用 Svelte 5 Runes ($props, $derived)
|
|
44
52
|
* 使用 compounds 组件:Drawer, Modal, Badge
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* import { mount, unmount } from 'svelte'
|
|
57
|
+
* import type { ComponentProps } from 'svelte'
|
|
58
|
+
* import { CrudDetailPanel } from '@h-ai/ui'
|
|
59
|
+
* const props: ComponentProps<typeof CrudDetailPanel> = { open: true, title: '用户详情', item: { email: 'ada@example.com' }, fields: [{ id: 'email', label: '邮箱', type: 'email' }] }
|
|
60
|
+
* const component = mount(CrudDetailPanel, { target: document.body, props })
|
|
61
|
+
* await unmount(component)
|
|
62
|
+
* ```
|
|
45
63
|
*/
|
|
46
64
|
declare const CrudDetailPanel: import("svelte").Component<$$ComponentProps, {}, "open">;
|
|
47
65
|
type CrudDetailPanel = ReturnType<typeof CrudDetailPanel>;
|