@h-ai/ui 0.1.0-alpha.29 → 0.1.0-alpha.30
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.md +12 -0
- package/dist/components/compounds/Accordion.svelte +6 -3
- package/dist/components/compounds/Accordion.svelte.d.ts +3 -1
- package/dist/components/compounds/ActionSheet.svelte +11 -8
- package/dist/components/compounds/ActionSheet.svelte.d.ts +3 -1
- package/dist/components/compounds/Alert.svelte +6 -4
- package/dist/components/compounds/Alert.svelte.d.ts +3 -2
- package/dist/components/compounds/AppBar.svelte +13 -9
- package/dist/components/compounds/AppBar.svelte.d.ts +3 -1
- package/dist/components/compounds/BottomNav.svelte +13 -10
- package/dist/components/compounds/BottomNav.svelte.d.ts +3 -1
- package/dist/components/compounds/Breadcrumb.svelte +6 -4
- package/dist/components/compounds/Breadcrumb.svelte.d.ts +3 -2
- package/dist/components/compounds/Calendar.svelte +7 -2
- package/dist/components/compounds/Calendar.svelte.d.ts +3 -1
- package/dist/components/compounds/Card.svelte +6 -4
- package/dist/components/compounds/Card.svelte.d.ts +3 -2
- package/dist/components/compounds/Combobox.svelte +6 -2
- package/dist/components/compounds/Combobox.svelte.d.ts +3 -1
- package/dist/components/compounds/Confirm.svelte +9 -7
- package/dist/components/compounds/Confirm.svelte.d.ts +3 -2
- package/dist/components/compounds/DataTable.svelte +6 -2
- package/dist/components/compounds/DataTable.svelte.d.ts +2 -1
- package/dist/components/compounds/DatePicker.svelte +7 -2
- package/dist/components/compounds/DatePicker.svelte.d.ts +3 -1
- package/dist/components/compounds/Drawer.svelte +6 -4
- package/dist/components/compounds/Drawer.svelte.d.ts +3 -2
- package/dist/components/compounds/Dropdown.svelte +6 -4
- package/dist/components/compounds/Dropdown.svelte.d.ts +3 -2
- package/dist/components/compounds/Empty.svelte +6 -4
- package/dist/components/compounds/Empty.svelte.d.ts +3 -2
- package/dist/components/compounds/Form.svelte +11 -9
- package/dist/components/compounds/Form.svelte.d.ts +3 -2
- package/dist/components/compounds/FormField.svelte +6 -4
- package/dist/components/compounds/FormField.svelte.d.ts +3 -2
- package/dist/components/compounds/InfiniteScroll.svelte +10 -7
- package/dist/components/compounds/InfiniteScroll.svelte.d.ts +3 -1
- package/dist/components/compounds/MessageBoxContainer.svelte +6 -1
- package/dist/components/compounds/MessageBoxContainer.svelte.d.ts +3 -17
- package/dist/components/compounds/MessageBoxDialog.svelte +9 -7
- package/dist/components/compounds/MessageBoxDialog.svelte.d.ts +2 -1
- package/dist/components/compounds/MessageContainer.svelte +6 -2
- package/dist/components/compounds/MessageContainer.svelte.d.ts +2 -1
- package/dist/components/compounds/Modal.svelte +9 -7
- package/dist/components/compounds/Modal.svelte.d.ts +3 -2
- package/dist/components/compounds/PageHeader.svelte +6 -2
- package/dist/components/compounds/PageHeader.svelte.d.ts +3 -1
- package/dist/components/compounds/Pagination.svelte +6 -4
- package/dist/components/compounds/Pagination.svelte.d.ts +3 -2
- package/dist/components/compounds/Popover.svelte +10 -8
- package/dist/components/compounds/Popover.svelte.d.ts +3 -2
- package/dist/components/compounds/PullRefresh.svelte +11 -8
- package/dist/components/compounds/PullRefresh.svelte.d.ts +3 -1
- package/dist/components/compounds/Result.svelte +6 -4
- package/dist/components/compounds/Result.svelte.d.ts +3 -2
- package/dist/components/compounds/SafeArea.svelte +6 -3
- package/dist/components/compounds/SafeArea.svelte.d.ts +3 -1
- package/dist/components/compounds/Skeleton.svelte +6 -4
- package/dist/components/compounds/Skeleton.svelte.d.ts +3 -2
- package/dist/components/compounds/Steps.svelte +6 -4
- package/dist/components/compounds/Steps.svelte.d.ts +3 -2
- package/dist/components/compounds/SwipeCell.svelte +6 -3
- package/dist/components/compounds/SwipeCell.svelte.d.ts +3 -1
- package/dist/components/compounds/Tabs.svelte +6 -4
- package/dist/components/compounds/Tabs.svelte.d.ts +3 -2
- package/dist/components/compounds/TagInput.svelte +11 -9
- package/dist/components/compounds/TagInput.svelte.d.ts +3 -2
- package/dist/components/compounds/Timeline.svelte +6 -3
- package/dist/components/compounds/Timeline.svelte.d.ts +3 -1
- package/dist/components/compounds/ToastContainer.svelte +6 -2
- package/dist/components/compounds/ToastContainer.svelte.d.ts +2 -1
- package/dist/components/compounds/Tooltip.svelte +6 -4
- package/dist/components/compounds/Tooltip.svelte.d.ts +3 -2
- package/dist/components/primitives/Avatar.svelte +6 -4
- package/dist/components/primitives/Avatar.svelte.d.ts +3 -2
- package/dist/components/primitives/Badge.svelte +6 -4
- package/dist/components/primitives/Badge.svelte.d.ts +3 -2
- package/dist/components/primitives/BareButton.svelte +15 -12
- package/dist/components/primitives/BareButton.svelte.d.ts +3 -2
- package/dist/components/primitives/BareInput.svelte +37 -34
- package/dist/components/primitives/BareInput.svelte.d.ts +3 -2
- package/dist/components/primitives/Button.svelte +12 -10
- package/dist/components/primitives/Button.svelte.d.ts +3 -2
- package/dist/components/primitives/Checkbox.svelte +6 -4
- package/dist/components/primitives/Checkbox.svelte.d.ts +3 -2
- package/dist/components/primitives/IconButton.svelte +6 -4
- package/dist/components/primitives/IconButton.svelte.d.ts +3 -2
- package/dist/components/primitives/Input.svelte +6 -4
- package/dist/components/primitives/Input.svelte.d.ts +3 -2
- package/dist/components/primitives/Progress.svelte +6 -4
- package/dist/components/primitives/Progress.svelte.d.ts +3 -2
- package/dist/components/primitives/Radio.svelte +6 -4
- package/dist/components/primitives/Radio.svelte.d.ts +2 -2
- package/dist/components/primitives/Range.svelte +6 -3
- package/dist/components/primitives/Range.svelte.d.ts +3 -1
- package/dist/components/primitives/Rating.svelte +6 -3
- package/dist/components/primitives/Rating.svelte.d.ts +3 -1
- package/dist/components/primitives/Select.svelte +6 -4
- package/dist/components/primitives/Select.svelte.d.ts +2 -2
- package/dist/components/primitives/Spinner.svelte +6 -4
- package/dist/components/primitives/Spinner.svelte.d.ts +3 -2
- package/dist/components/primitives/Switch.svelte +6 -4
- package/dist/components/primitives/Switch.svelte.d.ts +3 -2
- package/dist/components/primitives/Tag.svelte +6 -4
- package/dist/components/primitives/Tag.svelte.d.ts +3 -2
- package/dist/components/primitives/Textarea.svelte +6 -4
- package/dist/components/primitives/Textarea.svelte.d.ts +3 -2
- package/dist/components/primitives/ToggleCheckbox.svelte +13 -10
- package/dist/components/primitives/ToggleCheckbox.svelte.d.ts +3 -2
- package/dist/components/primitives/ToggleInput.svelte +13 -10
- package/dist/components/primitives/ToggleInput.svelte.d.ts +3 -2
- package/dist/components/primitives/ToggleRadio.svelte +13 -10
- package/dist/components/primitives/ToggleRadio.svelte.d.ts +3 -2
- package/dist/components/scenes/ai/AiDocumentDownloadMenu.svelte +8 -5
- package/dist/components/scenes/ai/AiDocumentDownloadMenu.svelte.d.ts +3 -1
- package/dist/components/scenes/ai/AiDocumentEditor.svelte +6 -3
- package/dist/components/scenes/ai/AiDocumentEditor.svelte.d.ts +3 -1
- package/dist/components/scenes/ai/MarkdownRenderer.svelte +8 -7
- package/dist/components/scenes/ai/MarkdownRenderer.svelte.d.ts +3 -1
- package/dist/components/scenes/ai/document-types.d.ts +2 -1
- package/dist/components/scenes/ai/table/AiTableEditor.svelte +6 -3
- package/dist/components/scenes/ai/table/AiTableEditor.svelte.d.ts +3 -1
- package/dist/components/scenes/ai/table/table-types.d.ts +2 -1
- package/dist/components/scenes/app/FeedbackModal.svelte +5 -2
- package/dist/components/scenes/app/FeedbackModal.svelte.d.ts +3 -1
- package/dist/components/scenes/app/LanguageSwitch.svelte +6 -2
- package/dist/components/scenes/app/LanguageSwitch.svelte.d.ts +3 -1
- package/dist/components/scenes/app/SettingsLayout.svelte +6 -3
- package/dist/components/scenes/app/SettingsLayout.svelte.d.ts +2 -1
- package/dist/components/scenes/app/SettingsModal.svelte +6 -3
- package/dist/components/scenes/app/SettingsModal.svelte.d.ts +3 -1
- package/dist/components/scenes/app/ThemeColorPicker.svelte +6 -3
- package/dist/components/scenes/app/ThemeColorPicker.svelte.d.ts +3 -1
- package/dist/components/scenes/app/ThemeSelector.svelte +6 -3
- package/dist/components/scenes/app/ThemeSelector.svelte.d.ts +3 -1
- package/dist/components/scenes/app/ThemeToggle.svelte +6 -2
- package/dist/components/scenes/app/ThemeToggle.svelte.d.ts +3 -1
- package/dist/components/scenes/crud/CrudDeleteConfirm.svelte +16 -11
- package/dist/components/scenes/crud/CrudDeleteConfirm.svelte.d.ts +2 -1
- package/dist/components/scenes/crud/CrudDetailDrawer.svelte +6 -3
- package/dist/components/scenes/crud/CrudDetailDrawer.svelte.d.ts +2 -2
- package/dist/components/scenes/crud/CrudDetailPanel.svelte +6 -3
- package/dist/components/scenes/crud/CrudDetailPanel.svelte.d.ts +2 -2
- package/dist/components/scenes/crud/CrudEditPanel.svelte +6 -3
- package/dist/components/scenes/crud/CrudEditPanel.svelte.d.ts +2 -2
- package/dist/components/scenes/crud/CrudFilterBar.svelte +6 -2
- package/dist/components/scenes/crud/CrudFilterBar.svelte.d.ts +2 -1
- package/dist/components/scenes/crud/CrudPage.svelte +6 -2
- package/dist/components/scenes/crud/CrudPage.svelte.d.ts +2 -1
- package/dist/components/scenes/crud/crud-types.d.ts +2 -2
- package/dist/components/scenes/crypto/EncryptedInput.svelte +6 -3
- package/dist/components/scenes/crypto/EncryptedInput.svelte.d.ts +3 -2
- package/dist/components/scenes/crypto/HashDisplay.svelte +6 -3
- package/dist/components/scenes/crypto/HashDisplay.svelte.d.ts +3 -1
- package/dist/components/scenes/crypto/SignatureDisplay.svelte +6 -3
- package/dist/components/scenes/crypto/SignatureDisplay.svelte.d.ts +3 -1
- package/dist/components/scenes/error/ErrorPage.svelte +6 -3
- package/dist/components/scenes/error/ErrorPage.svelte.d.ts +2 -1
- package/dist/components/scenes/iam/AuthShell.svelte +6 -3
- package/dist/components/scenes/iam/AuthShell.svelte.d.ts +2 -1
- package/dist/components/scenes/iam/ChangePasswordForm.svelte +6 -3
- package/dist/components/scenes/iam/ChangePasswordForm.svelte.d.ts +3 -1
- package/dist/components/scenes/iam/ForgotPasswordForm.svelte +6 -3
- package/dist/components/scenes/iam/ForgotPasswordForm.svelte.d.ts +3 -1
- package/dist/components/scenes/iam/LoginForm.svelte +6 -3
- package/dist/components/scenes/iam/LoginForm.svelte.d.ts +3 -1
- package/dist/components/scenes/iam/PasswordInput.svelte +6 -4
- package/dist/components/scenes/iam/PasswordInput.svelte.d.ts +3 -2
- package/dist/components/scenes/iam/RegisterForm.svelte +6 -4
- package/dist/components/scenes/iam/RegisterForm.svelte.d.ts +3 -1
- package/dist/components/scenes/iam/ResetPasswordForm.svelte +6 -3
- package/dist/components/scenes/iam/ResetPasswordForm.svelte.d.ts +3 -1
- package/dist/components/scenes/iam/UserProfile.svelte +6 -3
- package/dist/components/scenes/iam/UserProfile.svelte.d.ts +3 -1
- package/dist/components/scenes/storage/AvatarUpload.svelte +11 -8
- package/dist/components/scenes/storage/AvatarUpload.svelte.d.ts +3 -1
- package/dist/components/scenes/storage/FileList.svelte +6 -3
- package/dist/components/scenes/storage/FileList.svelte.d.ts +3 -1
- package/dist/components/scenes/storage/FileUpload.svelte +6 -3
- package/dist/components/scenes/storage/FileUpload.svelte.d.ts +3 -1
- package/dist/components/scenes/storage/ImageUpload.svelte +12 -9
- package/dist/components/scenes/storage/ImageUpload.svelte.d.ts +3 -1
- package/dist/components/scenes/types.d.ts +16 -16
- package/dist/types.d.ts +43 -36
- package/dist/utils.d.ts +6 -1
- package/dist/utils.js +15 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -94,6 +94,18 @@ export default defineConfig({
|
|
|
94
94
|
|
|
95
95
|
> 除 `toast`、类型导入与 `Range`(会和 DOM `Range` 构造器冲突)外,其余公开 Svelte 组件都可通过 `@h-ai/ui/auto-import` 自动注入。
|
|
96
96
|
|
|
97
|
+
### data-* 属性透传
|
|
98
|
+
|
|
99
|
+
公开 Svelte 组件支持把调用方传入的 `data-*` 属性透传到组件根节点或主交互节点,便于测试选择器、埋点和自动化标记。普通未知属性不会被透传。
|
|
100
|
+
|
|
101
|
+
```svelte
|
|
102
|
+
<Button data-testid='save-button' data-analytics-id='settings.save'>保存</Button>
|
|
103
|
+
<Input data-testid='username-input' bind:value={username} />
|
|
104
|
+
<Modal data-testid='confirm-modal' bind:open={open}>...</Modal>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
无需再为了 `data-testid` 单独封装按钮、输入框或弹层组件。
|
|
108
|
+
|
|
97
109
|
## 组件架构
|
|
98
110
|
|
|
99
111
|
组件按三层划分(primitives → compounds → scenes):
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
<script lang='ts'>
|
|
13
13
|
import type { Snippet } from 'svelte'
|
|
14
|
+
import type { DataAttributes } from '../../types.js'
|
|
14
15
|
import type { AccordionItem } from './accordion-types.js'
|
|
15
|
-
import { cn } from '../../utils.js'
|
|
16
|
+
import { cn, getDataAttributes } from '../../utils.js'
|
|
16
17
|
import ToggleCheckbox from '../primitives/ToggleCheckbox.svelte'
|
|
17
18
|
import ToggleRadio from '../primitives/ToggleRadio.svelte'
|
|
18
19
|
|
|
@@ -47,8 +48,10 @@
|
|
|
47
48
|
onchange,
|
|
48
49
|
class: className = '',
|
|
49
50
|
children,
|
|
50
|
-
|
|
51
|
+
...restProps
|
|
52
|
+
}: Props & DataAttributes = $props()
|
|
51
53
|
|
|
54
|
+
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
52
55
|
const groupName = `accordion-${Math.random().toString(36).slice(2, 9)}`
|
|
53
56
|
|
|
54
57
|
function isExpanded(itemId: string): boolean {
|
|
@@ -103,7 +106,7 @@
|
|
|
103
106
|
}
|
|
104
107
|
</script>
|
|
105
108
|
|
|
106
|
-
<div class={containerClass}>
|
|
109
|
+
<div {...dataAttributes} class={containerClass}>
|
|
107
110
|
{#each items as item (item.id)}
|
|
108
111
|
<div class={getItemClass(item)}>
|
|
109
112
|
{#if multiple}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { DataAttributes } from '../../types.js';
|
|
2
3
|
import type { AccordionItem } from './accordion-types.js';
|
|
3
4
|
interface Props {
|
|
4
5
|
/** 折叠项数据 */
|
|
@@ -20,6 +21,7 @@ interface Props {
|
|
|
20
21
|
/** 自定义内容渲染 */
|
|
21
22
|
children?: Snippet<[AccordionItem]>;
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
+
type $$ComponentProps = Props & DataAttributes;
|
|
25
|
+
declare const Accordion: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
24
26
|
type Accordion = ReturnType<typeof Accordion>;
|
|
25
27
|
export default Accordion;
|
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
/>
|
|
14
14
|
-->
|
|
15
15
|
<script lang='ts'>
|
|
16
|
+
import type { DataAttributes } from '../../types.js'
|
|
16
17
|
import type { ActionSheetItem } from './action-sheet-types.js'
|
|
17
|
-
import { cn } from '../../utils.js'
|
|
18
|
+
import { cn, getDataAttributes } from '../../utils.js'
|
|
18
19
|
|
|
19
20
|
// eslint-disable-next-line no-import-assign -- type re-export
|
|
20
21
|
export type { ActionSheetItem }
|
|
@@ -44,8 +45,10 @@
|
|
|
44
45
|
onselect,
|
|
45
46
|
onclose,
|
|
46
47
|
class: className,
|
|
47
|
-
|
|
48
|
+
...restProps
|
|
49
|
+
}: Props & DataAttributes = $props()
|
|
48
50
|
|
|
51
|
+
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
49
52
|
function handleSelect(id: string) {
|
|
50
53
|
onselect?.(id)
|
|
51
54
|
onclose?.()
|
|
@@ -54,12 +57,12 @@
|
|
|
54
57
|
|
|
55
58
|
{#if open}
|
|
56
59
|
<!-- 遮罩层 -->
|
|
57
|
-
<div
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
<div {...dataAttributes}
|
|
61
|
+
class='fixed inset-0 bg-black/50 z-50 transition-opacity'
|
|
62
|
+
role='button'
|
|
63
|
+
tabindex='-1'
|
|
64
|
+
onclick={onclose}
|
|
65
|
+
onkeydown={e => e.key === 'Escape' && onclose?.()}
|
|
63
66
|
></div>
|
|
64
67
|
|
|
65
68
|
<!-- 操作面板 -->
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DataAttributes } from '../../types.js';
|
|
1
2
|
import type { ActionSheetItem } from './action-sheet-types.js';
|
|
2
3
|
interface Props {
|
|
3
4
|
/** 是否显示 */
|
|
@@ -15,7 +16,8 @@ interface Props {
|
|
|
15
16
|
/** 额外 CSS 类 */
|
|
16
17
|
class?: string;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
type $$ComponentProps = Props & DataAttributes;
|
|
20
|
+
declare const ActionSheet: import("svelte").Component<$$ComponentProps, {
|
|
19
21
|
ActionSheetItem: typeof ActionSheetItem;
|
|
20
22
|
}, "">;
|
|
21
23
|
type ActionSheet = ReturnType<typeof ActionSheet>;
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
警告框组件,使用 tabler icon 替代 emoji,更精致。
|
|
4
4
|
-->
|
|
5
5
|
<script lang='ts'>
|
|
6
|
-
import type { AlertProps } from '../../types.js'
|
|
6
|
+
import type { AlertProps, DataAttributes } from '../../types.js'
|
|
7
7
|
import { uiM } from '../../messages.js'
|
|
8
|
-
import { cn, getAlertVariantClass } from '../../utils.js'
|
|
8
|
+
import { cn, getAlertVariantClass, getDataAttributes } from '../../utils.js'
|
|
9
9
|
import IconButton from '../primitives/IconButton.svelte'
|
|
10
10
|
|
|
11
11
|
const {
|
|
@@ -15,8 +15,10 @@
|
|
|
15
15
|
class: className = '',
|
|
16
16
|
onclose,
|
|
17
17
|
children,
|
|
18
|
-
|
|
18
|
+
...restProps
|
|
19
|
+
}: AlertProps & DataAttributes = $props()
|
|
19
20
|
|
|
21
|
+
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
20
22
|
let visible = $state(true)
|
|
21
23
|
|
|
22
24
|
const alertClass = $derived(
|
|
@@ -42,7 +44,7 @@
|
|
|
42
44
|
</script>
|
|
43
45
|
|
|
44
46
|
{#if visible}
|
|
45
|
-
<div class={alertClass} role='alert'>
|
|
47
|
+
<div {...dataAttributes} class={alertClass} role='alert'>
|
|
46
48
|
<span class='{iconMap[variant] ?? iconMap.info} size-5 shrink-0'></span>
|
|
47
49
|
|
|
48
50
|
<div>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { AlertProps } from '../../types.js';
|
|
1
|
+
import type { AlertProps, DataAttributes } from '../../types.js';
|
|
2
|
+
type $$ComponentProps = AlertProps & DataAttributes;
|
|
2
3
|
/**
|
|
3
4
|
* Alert
|
|
4
5
|
* 警告框组件,使用 tabler icon 替代 emoji,更精致。
|
|
5
6
|
*/
|
|
6
|
-
declare const Alert: import("svelte").Component
|
|
7
|
+
declare const Alert: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
8
|
type Alert = ReturnType<typeof Alert>;
|
|
8
9
|
export default Alert;
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
-->
|
|
10
10
|
<script lang='ts'>
|
|
11
11
|
import type { Snippet } from 'svelte'
|
|
12
|
-
import {
|
|
12
|
+
import type { DataAttributes } from '../../types.js'
|
|
13
|
+
import { cn, getDataAttributes } from '../../utils.js'
|
|
13
14
|
|
|
14
15
|
interface Props {
|
|
15
16
|
/** 标题文本 */
|
|
@@ -36,16 +37,19 @@
|
|
|
36
37
|
leading,
|
|
37
38
|
trailing,
|
|
38
39
|
children,
|
|
39
|
-
|
|
40
|
+
...restProps
|
|
41
|
+
}: Props & DataAttributes = $props()
|
|
42
|
+
|
|
43
|
+
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
40
44
|
</script>
|
|
41
45
|
|
|
42
|
-
<header
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
<header {...dataAttributes}
|
|
47
|
+
class={cn(
|
|
48
|
+
'flex items-center h-14 px-4 bg-base-100 border-b border-base-200',
|
|
49
|
+
safeArea && 'hai-safe-top',
|
|
50
|
+
fixed && 'fixed top-0 left-0 right-0 z-40',
|
|
51
|
+
className,
|
|
52
|
+
)}
|
|
49
53
|
>
|
|
50
54
|
<!-- 左侧 -->
|
|
51
55
|
<div class='flex items-center min-w-[48px]'>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { DataAttributes } from '../../types.js';
|
|
2
3
|
interface Props {
|
|
3
4
|
/** 标题文本 */
|
|
4
5
|
title?: string;
|
|
@@ -15,6 +16,7 @@ interface Props {
|
|
|
15
16
|
/** 自定义标题区域 */
|
|
16
17
|
children?: Snippet;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
type $$ComponentProps = Props & DataAttributes;
|
|
20
|
+
declare const AppBar: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
19
21
|
type AppBar = ReturnType<typeof AppBar>;
|
|
20
22
|
export default AppBar;
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
<BottomNav items={navItems} active="home" onchange={(id) => goto(`/${id}`)} />
|
|
6
6
|
-->
|
|
7
7
|
<script lang='ts'>
|
|
8
|
+
import type { DataAttributes } from '../../types.js'
|
|
8
9
|
import type { BottomNavItem } from './bottom-nav-types.js'
|
|
9
|
-
import { cn } from '../../utils.js'
|
|
10
|
+
import { cn, getDataAttributes } from '../../utils.js'
|
|
10
11
|
|
|
11
12
|
// eslint-disable-next-line no-import-assign -- type re-export
|
|
12
13
|
export type { BottomNavItem }
|
|
@@ -46,19 +47,21 @@
|
|
|
46
47
|
centered = false,
|
|
47
48
|
maxWidth = 'none',
|
|
48
49
|
class: className,
|
|
49
|
-
|
|
50
|
+
...restProps
|
|
51
|
+
}: Props & DataAttributes = $props()
|
|
50
52
|
|
|
53
|
+
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
51
54
|
const constrained = $derived(centered && maxWidth !== 'none')
|
|
52
55
|
</script>
|
|
53
56
|
|
|
54
|
-
<nav
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
<nav {...dataAttributes}
|
|
58
|
+
class={cn(
|
|
59
|
+
'fixed bottom-0 bg-base-100 border-t border-base-200 z-40',
|
|
60
|
+
constrained ? 'left-1/2 right-auto w-full -translate-x-1/2' : 'left-0 right-0',
|
|
61
|
+
constrained && MAX_WIDTH_CLASS[maxWidth],
|
|
62
|
+
safeArea && 'hai-safe-bottom',
|
|
63
|
+
className,
|
|
64
|
+
)}
|
|
62
65
|
>
|
|
63
66
|
<div class='flex items-center justify-around h-14'>
|
|
64
67
|
{#each items as item (item.id)}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DataAttributes } from '../../types.js';
|
|
1
2
|
import type { BottomNavItem } from './bottom-nav-types.js';
|
|
2
3
|
type BottomNavMaxWidth = 'sm' | 'md' | 'lg' | 'xl' | 'none';
|
|
3
4
|
interface Props {
|
|
@@ -16,7 +17,8 @@ interface Props {
|
|
|
16
17
|
/** 额外 CSS 类 */
|
|
17
18
|
class?: string;
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
+
type $$ComponentProps = Props & DataAttributes;
|
|
21
|
+
declare const BottomNav: import("svelte").Component<$$ComponentProps, {
|
|
20
22
|
BottomNavItem: typeof BottomNavItem;
|
|
21
23
|
}, "">;
|
|
22
24
|
type BottomNav = ReturnType<typeof BottomNav>;
|
|
@@ -8,14 +8,16 @@
|
|
|
8
8
|
=============================================================================
|
|
9
9
|
-->
|
|
10
10
|
<script lang='ts'>
|
|
11
|
-
import type { BreadcrumbProps } from '../../types.js'
|
|
12
|
-
import { cn } from '../../utils.js'
|
|
11
|
+
import type { BreadcrumbProps, DataAttributes } from '../../types.js'
|
|
12
|
+
import { cn, getDataAttributes } from '../../utils.js'
|
|
13
13
|
|
|
14
14
|
const {
|
|
15
15
|
items,
|
|
16
16
|
class: className = '',
|
|
17
|
-
|
|
17
|
+
...restProps
|
|
18
|
+
}: BreadcrumbProps & DataAttributes = $props()
|
|
18
19
|
|
|
20
|
+
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
19
21
|
const breadcrumbClass = $derived(
|
|
20
22
|
cn(
|
|
21
23
|
'breadcrumbs text-sm',
|
|
@@ -24,7 +26,7 @@
|
|
|
24
26
|
)
|
|
25
27
|
</script>
|
|
26
28
|
|
|
27
|
-
<div class={breadcrumbClass}>
|
|
29
|
+
<div {...dataAttributes} class={breadcrumbClass}>
|
|
28
30
|
<ul>
|
|
29
31
|
{#each items as item, index (item.href ?? `${item.label}:${index}`)}
|
|
30
32
|
<li>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { BreadcrumbProps } from '../../types.js';
|
|
2
|
-
|
|
1
|
+
import type { BreadcrumbProps, DataAttributes } from '../../types.js';
|
|
2
|
+
type $$ComponentProps = BreadcrumbProps & DataAttributes;
|
|
3
|
+
declare const Breadcrumb: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
3
4
|
type Breadcrumb = ReturnType<typeof Breadcrumb>;
|
|
4
5
|
export default Breadcrumb;
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
-->
|
|
22
22
|
<script lang='ts'>
|
|
23
23
|
import type { DateValue } from '@internationalized/date'
|
|
24
|
+
import type { DataAttributes } from '../../types.js'
|
|
24
25
|
import { Calendar as BitsCalendar } from 'bits-ui'
|
|
26
|
+
import { getDataAttributes } from '../../utils.js'
|
|
25
27
|
|
|
26
28
|
interface Props {
|
|
27
29
|
/** 选中日期(双向绑定) */
|
|
@@ -57,10 +59,13 @@
|
|
|
57
59
|
readonly: isReadonly = false,
|
|
58
60
|
class: className = '',
|
|
59
61
|
onchange,
|
|
60
|
-
|
|
62
|
+
...restProps
|
|
63
|
+
}: Props & DataAttributes = $props()
|
|
64
|
+
|
|
65
|
+
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
61
66
|
</script>
|
|
62
67
|
|
|
63
|
-
<div class={className}>
|
|
68
|
+
<div {...dataAttributes} class={className}>
|
|
64
69
|
<BitsCalendar.Root
|
|
65
70
|
type='single'
|
|
66
71
|
bind:value
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DateValue } from '@internationalized/date';
|
|
2
|
+
import type { DataAttributes } from '../../types.js';
|
|
2
3
|
interface Props {
|
|
3
4
|
/** 选中日期(双向绑定) */
|
|
4
5
|
value?: DateValue;
|
|
@@ -21,6 +22,7 @@ interface Props {
|
|
|
21
22
|
/** 日期变更回调 */
|
|
22
23
|
onchange?: (value: DateValue | undefined) => void;
|
|
23
24
|
}
|
|
25
|
+
type $$ComponentProps = Props & DataAttributes;
|
|
24
26
|
/**
|
|
25
27
|
* Calendar
|
|
26
28
|
* 日历组件,基于 Bits UI headless + DaisyUI 样式。
|
|
@@ -42,6 +44,6 @@ interface Props {
|
|
|
42
44
|
* <Calendar bind:value={date} />
|
|
43
45
|
* ```
|
|
44
46
|
*/
|
|
45
|
-
declare const Calendar: import("svelte").Component
|
|
47
|
+
declare const Calendar: import("svelte").Component<$$ComponentProps, {}, "value" | "placeholder">;
|
|
46
48
|
type Calendar = ReturnType<typeof Calendar>;
|
|
47
49
|
export default Calendar;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
卡片组件,默认使用 border 而非 shadow,更现代克制。
|
|
4
4
|
-->
|
|
5
5
|
<script lang='ts'>
|
|
6
|
-
import type { CardProps } from '../../types.js'
|
|
7
|
-
import { cn } from '../../utils.js'
|
|
6
|
+
import type { CardProps, DataAttributes } from '../../types.js'
|
|
7
|
+
import { cn, getDataAttributes } from '../../utils.js'
|
|
8
8
|
|
|
9
9
|
const {
|
|
10
10
|
title = '',
|
|
@@ -15,8 +15,10 @@
|
|
|
15
15
|
header,
|
|
16
16
|
footer,
|
|
17
17
|
children,
|
|
18
|
-
|
|
18
|
+
...restProps
|
|
19
|
+
}: CardProps & DataAttributes = $props()
|
|
19
20
|
|
|
21
|
+
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
20
22
|
const paddingMap = {
|
|
21
23
|
'none': 'p-0',
|
|
22
24
|
'xs': 'p-2',
|
|
@@ -54,7 +56,7 @@
|
|
|
54
56
|
)
|
|
55
57
|
</script>
|
|
56
58
|
|
|
57
|
-
<div class={cardClass}>
|
|
59
|
+
<div {...dataAttributes} class={cardClass}>
|
|
58
60
|
<div class={bodyClass}>
|
|
59
61
|
{#if header}
|
|
60
62
|
<div class='card-title text-sm font-semibold'>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { CardProps } from '../../types.js';
|
|
1
|
+
import type { CardProps, DataAttributes } from '../../types.js';
|
|
2
|
+
type $$ComponentProps = CardProps & DataAttributes;
|
|
2
3
|
/**
|
|
3
4
|
* Card
|
|
4
5
|
* 卡片组件,默认使用 border 而非 shadow,更现代克制。
|
|
5
6
|
*/
|
|
6
|
-
declare const Card: import("svelte").Component
|
|
7
|
+
declare const Card: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
8
|
type Card = ReturnType<typeof Card>;
|
|
8
9
|
export default Card;
|
|
@@ -33,8 +33,10 @@
|
|
|
33
33
|
/>
|
|
34
34
|
-->
|
|
35
35
|
<script lang='ts'>
|
|
36
|
+
import type { DataAttributes } from '../../types.js'
|
|
36
37
|
import { Combobox } from 'bits-ui'
|
|
37
38
|
import { uiM } from '../../messages.js'
|
|
39
|
+
import { getDataAttributes } from '../../utils.js'
|
|
38
40
|
import BareButton from '../primitives/BareButton.svelte'
|
|
39
41
|
|
|
40
42
|
/** 选项定义 */
|
|
@@ -80,8 +82,10 @@
|
|
|
80
82
|
label: fieldLabel,
|
|
81
83
|
class: className = '',
|
|
82
84
|
onchange,
|
|
83
|
-
|
|
85
|
+
...restProps
|
|
86
|
+
}: Props & DataAttributes = $props()
|
|
84
87
|
|
|
88
|
+
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
85
89
|
// 为未提供 value 时设置初始默认值(仅在初始化时执行一次)
|
|
86
90
|
// 统一以空字符串初始化,避免在初始化阶段捕获 multiple 的初始值。
|
|
87
91
|
// 多选模式会通过 multiVal 派生为 [] 传给 Combobox.Root。
|
|
@@ -159,7 +163,7 @@
|
|
|
159
163
|
}
|
|
160
164
|
</script>
|
|
161
165
|
|
|
162
|
-
<div class='fieldset w-full {className}'>
|
|
166
|
+
<div {...dataAttributes} class='fieldset w-full {className}'>
|
|
163
167
|
{#if fieldLabel}
|
|
164
168
|
<legend class='fieldset-legend font-medium'>{fieldLabel}</legend>
|
|
165
169
|
{/if}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DataAttributes } from '../../types.js';
|
|
1
2
|
import { Combobox } from 'bits-ui';
|
|
2
3
|
/** 选项定义 */
|
|
3
4
|
interface Option {
|
|
@@ -30,6 +31,7 @@ interface Props {
|
|
|
30
31
|
/** 值变更回调 */
|
|
31
32
|
onchange?: (value: string | string[]) => void;
|
|
32
33
|
}
|
|
34
|
+
type $$ComponentProps = Props & DataAttributes;
|
|
33
35
|
/**
|
|
34
36
|
* Combobox
|
|
35
37
|
* 可搜索下拉选择组件,基于 Bits UI headless + DaisyUI 样式。
|
|
@@ -64,6 +66,6 @@ interface Props {
|
|
|
64
66
|
* placeholder="搜索技能..."
|
|
65
67
|
* />
|
|
66
68
|
*/
|
|
67
|
-
declare const Combobox: import("svelte").Component
|
|
69
|
+
declare const Combobox: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
68
70
|
type Combobox = ReturnType<typeof Combobox>;
|
|
69
71
|
export default Combobox;
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
=============================================================================
|
|
10
10
|
-->
|
|
11
11
|
<script lang='ts'>
|
|
12
|
-
import type { ConfirmProps } from '../../types.js'
|
|
12
|
+
import type { ConfirmProps, DataAttributes } from '../../types.js'
|
|
13
13
|
import { uiM } from '../../messages.js'
|
|
14
|
-
import { cn } from '../../utils.js'
|
|
14
|
+
import { cn, getDataAttributes } from '../../utils.js'
|
|
15
15
|
import Button from '../primitives/Button.svelte'
|
|
16
16
|
|
|
17
17
|
let {
|
|
@@ -25,8 +25,10 @@
|
|
|
25
25
|
class: className = '',
|
|
26
26
|
onconfirm,
|
|
27
27
|
oncancel,
|
|
28
|
-
|
|
28
|
+
...restProps
|
|
29
|
+
}: ConfirmProps & DataAttributes = $props()
|
|
29
30
|
|
|
31
|
+
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
30
32
|
/** 响应式 i18n 显示值 */
|
|
31
33
|
const displayTitle = $derived(title ?? uiM('confirm_title'))
|
|
32
34
|
const displayMessage = $derived(message ?? uiM('confirm_message'))
|
|
@@ -61,10 +63,10 @@
|
|
|
61
63
|
}
|
|
62
64
|
</script>
|
|
63
65
|
|
|
64
|
-
<dialog
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
<dialog {...dataAttributes}
|
|
67
|
+
bind:this={modalElement}
|
|
68
|
+
class={cn('modal', className)}
|
|
69
|
+
onclick={handleBackdropClick}
|
|
68
70
|
>
|
|
69
71
|
<div class='modal-box'>
|
|
70
72
|
<h3 class='font-bold text-lg'>{displayTitle}</h3>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ConfirmProps } from '../../types.js';
|
|
2
|
-
|
|
1
|
+
import type { ConfirmProps, DataAttributes } from '../../types.js';
|
|
2
|
+
type $$ComponentProps = ConfirmProps & DataAttributes;
|
|
3
|
+
declare const Confirm: import("svelte").Component<$$ComponentProps, {}, "open">;
|
|
3
4
|
type Confirm = ReturnType<typeof Confirm>;
|
|
4
5
|
export default Confirm;
|
|
@@ -29,7 +29,9 @@
|
|
|
29
29
|
-->
|
|
30
30
|
<script lang='ts' generics='T'>
|
|
31
31
|
import type { Snippet } from 'svelte'
|
|
32
|
+
import type { DataAttributes } from '../../types.js'
|
|
32
33
|
import { uiM } from '../../messages.js'
|
|
34
|
+
import { getDataAttributes } from '../../utils.js'
|
|
33
35
|
|
|
34
36
|
const {
|
|
35
37
|
data,
|
|
@@ -45,6 +47,7 @@
|
|
|
45
47
|
sortDir,
|
|
46
48
|
onsort,
|
|
47
49
|
class: className = '',
|
|
50
|
+
...restProps
|
|
48
51
|
}: {
|
|
49
52
|
data: T[]
|
|
50
53
|
columns: { key: keyof T | string, label: string, width?: string, align?: 'left' | 'center' | 'right', sortable?: boolean, render?: (item: T) => string }[]
|
|
@@ -62,8 +65,9 @@
|
|
|
62
65
|
/** 排序回调;提供时为受控模式(不再对 data 做本地排序),否则组件内部对当前数据做客户端排序 */
|
|
63
66
|
onsort?: (key: string, dir: 'asc' | 'desc') => void
|
|
64
67
|
class?: string
|
|
65
|
-
} = $props()
|
|
68
|
+
} & DataAttributes = $props()
|
|
66
69
|
|
|
70
|
+
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
67
71
|
type Column = { key: keyof T | string, label: string, width?: string, align?: 'left' | 'center' | 'right', sortable?: boolean, render?: (item: T) => string }
|
|
68
72
|
|
|
69
73
|
// ─── 排序状态 ───
|
|
@@ -162,7 +166,7 @@
|
|
|
162
166
|
}
|
|
163
167
|
</script>
|
|
164
168
|
|
|
165
|
-
<div class='overflow-x-auto {className}'>
|
|
169
|
+
<div {...dataAttributes} class='overflow-x-auto {className}'>
|
|
166
170
|
<table class={tableClass} class:table-zebra={striped}>
|
|
167
171
|
<thead>
|
|
168
172
|
<tr class={headerRowClass}>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { DataAttributes } from '../../types.js';
|
|
2
3
|
declare function $$render<T>(): {
|
|
3
4
|
props: {
|
|
4
5
|
data: T[];
|
|
@@ -24,7 +25,7 @@ declare function $$render<T>(): {
|
|
|
24
25
|
/** 排序回调;提供时为受控模式(不再对 data 做本地排序),否则组件内部对当前数据做客户端排序 */
|
|
25
26
|
onsort?: (key: string, dir: "asc" | "desc") => void;
|
|
26
27
|
class?: string;
|
|
27
|
-
};
|
|
28
|
+
} & DataAttributes;
|
|
28
29
|
exports: {};
|
|
29
30
|
bindings: "";
|
|
30
31
|
slots: {};
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
-->
|
|
23
23
|
<script lang='ts'>
|
|
24
24
|
import type { DateValue } from '@internationalized/date'
|
|
25
|
+
import type { DataAttributes } from '../../types.js'
|
|
25
26
|
import { DatePicker as BitsDatePicker } from 'bits-ui'
|
|
27
|
+
import { getDataAttributes } from '../../utils.js'
|
|
26
28
|
|
|
27
29
|
interface Props {
|
|
28
30
|
/** 选中日期(双向绑定) */
|
|
@@ -55,10 +57,13 @@
|
|
|
55
57
|
error,
|
|
56
58
|
class: className = '',
|
|
57
59
|
onchange,
|
|
58
|
-
|
|
60
|
+
...restProps
|
|
61
|
+
}: Props & DataAttributes = $props()
|
|
62
|
+
|
|
63
|
+
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
59
64
|
</script>
|
|
60
65
|
|
|
61
|
-
<div class='fieldset w-full {className}'>
|
|
66
|
+
<div {...dataAttributes} class='fieldset w-full {className}'>
|
|
62
67
|
<BitsDatePicker.Root
|
|
63
68
|
bind:value
|
|
64
69
|
{minValue}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DateValue } from '@internationalized/date';
|
|
2
|
+
import type { DataAttributes } from '../../types.js';
|
|
2
3
|
interface Props {
|
|
3
4
|
/** 选中日期(双向绑定) */
|
|
4
5
|
value?: DateValue;
|
|
@@ -19,6 +20,7 @@ interface Props {
|
|
|
19
20
|
/** 日期变更回调 */
|
|
20
21
|
onchange?: (value: DateValue | undefined) => void;
|
|
21
22
|
}
|
|
23
|
+
type $$ComponentProps = Props & DataAttributes;
|
|
22
24
|
/**
|
|
23
25
|
* DatePicker
|
|
24
26
|
* 日期选择器组件,基于 Bits UI headless + DaisyUI 样式。
|
|
@@ -41,6 +43,6 @@ interface Props {
|
|
|
41
43
|
* <DatePicker bind:value={date} />
|
|
42
44
|
* ```
|
|
43
45
|
*/
|
|
44
|
-
declare const DatePicker: import("svelte").Component
|
|
46
|
+
declare const DatePicker: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
45
47
|
type DatePicker = ReturnType<typeof DatePicker>;
|
|
46
48
|
export default DatePicker;
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
=============================================================================
|
|
10
10
|
-->
|
|
11
11
|
<script lang='ts'>
|
|
12
|
-
import type { DrawerProps } from '../../types.js'
|
|
12
|
+
import type { DataAttributes, DrawerProps } from '../../types.js'
|
|
13
13
|
import { uiM } from '../../messages.js'
|
|
14
|
-
import { cn, generateId } from '../../utils.js'
|
|
14
|
+
import { cn, generateId, getDataAttributes } from '../../utils.js'
|
|
15
15
|
import IconButton from '../primitives/IconButton.svelte'
|
|
16
16
|
import ToggleCheckbox from '../primitives/ToggleCheckbox.svelte'
|
|
17
17
|
|
|
@@ -26,8 +26,10 @@
|
|
|
26
26
|
class: className = '',
|
|
27
27
|
onclose,
|
|
28
28
|
children,
|
|
29
|
-
|
|
29
|
+
...restProps
|
|
30
|
+
}: DrawerProps & DataAttributes = $props()
|
|
30
31
|
|
|
32
|
+
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
31
33
|
const id = generateId('drawer')
|
|
32
34
|
|
|
33
35
|
const sizeMap = {
|
|
@@ -78,7 +80,7 @@
|
|
|
78
80
|
}
|
|
79
81
|
</script>
|
|
80
82
|
|
|
81
|
-
<div class={drawerClass}>
|
|
83
|
+
<div {...dataAttributes} class={drawerClass}>
|
|
82
84
|
<ToggleCheckbox {id} class='drawer-toggle' bind:checked={open} />
|
|
83
85
|
|
|
84
86
|
<div class={sideClass}>
|