@h-ai/ui 0.1.0-alpha5
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/LICENSE +202 -0
- package/README.md +488 -0
- package/auto-import.d.ts +96 -0
- package/auto-import.js +259 -0
- package/dist/components/compounds/Accordion.svelte +142 -0
- package/dist/components/compounds/Accordion.svelte.d.ts +25 -0
- package/dist/components/compounds/ActionSheet.svelte +116 -0
- package/dist/components/compounds/ActionSheet.svelte.d.ts +22 -0
- package/dist/components/compounds/Alert.svelte +67 -0
- package/dist/components/compounds/Alert.svelte.d.ts +8 -0
- package/dist/components/compounds/AppBar.svelte +77 -0
- package/dist/components/compounds/AppBar.svelte.d.ts +20 -0
- package/dist/components/compounds/BottomNav.svelte +75 -0
- package/dist/components/compounds/BottomNav.svelte.d.ts +18 -0
- package/dist/components/compounds/Breadcrumb.svelte +49 -0
- package/dist/components/compounds/Breadcrumb.svelte.d.ts +4 -0
- package/dist/components/compounds/Calendar.svelte +116 -0
- package/dist/components/compounds/Calendar.svelte.d.ts +47 -0
- package/dist/components/compounds/Card.svelte +77 -0
- package/dist/components/compounds/Card.svelte.d.ts +8 -0
- package/dist/components/compounds/Combobox.svelte +327 -0
- package/dist/components/compounds/Combobox.svelte.d.ts +69 -0
- package/dist/components/compounds/Confirm.svelte +90 -0
- package/dist/components/compounds/Confirm.svelte.d.ts +4 -0
- package/dist/components/compounds/DataTable.svelte +133 -0
- package/dist/components/compounds/DataTable.svelte.d.ts +69 -0
- package/dist/components/compounds/DatePicker.svelte +135 -0
- package/dist/components/compounds/DatePicker.svelte.d.ts +46 -0
- package/dist/components/compounds/Drawer.svelte +113 -0
- package/dist/components/compounds/Drawer.svelte.d.ts +4 -0
- package/dist/components/compounds/Dropdown.svelte +91 -0
- package/dist/components/compounds/Dropdown.svelte.d.ts +8 -0
- package/dist/components/compounds/Empty.svelte +83 -0
- package/dist/components/compounds/Empty.svelte.d.ts +4 -0
- package/dist/components/compounds/Form.svelte +96 -0
- package/dist/components/compounds/Form.svelte.d.ts +7 -0
- package/dist/components/compounds/FormField.svelte +56 -0
- package/dist/components/compounds/FormField.svelte.d.ts +4 -0
- package/dist/components/compounds/InfiniteScroll.svelte +82 -0
- package/dist/components/compounds/InfiniteScroll.svelte.d.ts +22 -0
- package/dist/components/compounds/Modal.svelte +123 -0
- package/dist/components/compounds/Modal.svelte.d.ts +8 -0
- package/dist/components/compounds/PageHeader.svelte +44 -0
- package/dist/components/compounds/PageHeader.svelte.d.ts +28 -0
- package/dist/components/compounds/Pagination.svelte +157 -0
- package/dist/components/compounds/Pagination.svelte.d.ts +4 -0
- package/dist/components/compounds/Popover.svelte +137 -0
- package/dist/components/compounds/Popover.svelte.d.ts +4 -0
- package/dist/components/compounds/PullRefresh.svelte +98 -0
- package/dist/components/compounds/PullRefresh.svelte.d.ts +16 -0
- package/dist/components/compounds/Result.svelte +84 -0
- package/dist/components/compounds/Result.svelte.d.ts +4 -0
- package/dist/components/compounds/SafeArea.svelte +37 -0
- package/dist/components/compounds/SafeArea.svelte.d.ts +12 -0
- package/dist/components/compounds/Skeleton.svelte +75 -0
- package/dist/components/compounds/Skeleton.svelte.d.ts +8 -0
- package/dist/components/compounds/Steps.svelte +111 -0
- package/dist/components/compounds/Steps.svelte.d.ts +4 -0
- package/dist/components/compounds/SwipeCell.svelte +115 -0
- package/dist/components/compounds/SwipeCell.svelte.d.ts +19 -0
- package/dist/components/compounds/Tabs.svelte +79 -0
- package/dist/components/compounds/Tabs.svelte.d.ts +8 -0
- package/dist/components/compounds/TagInput.svelte +108 -0
- package/dist/components/compounds/TagInput.svelte.d.ts +4 -0
- package/dist/components/compounds/Timeline.svelte +167 -0
- package/dist/components/compounds/Timeline.svelte.d.ts +25 -0
- package/dist/components/compounds/ToastContainer.svelte +59 -0
- package/dist/components/compounds/ToastContainer.svelte.d.ts +3 -0
- package/dist/components/compounds/Tooltip.svelte +41 -0
- package/dist/components/compounds/Tooltip.svelte.d.ts +4 -0
- package/dist/components/compounds/accordion-types.d.ts +16 -0
- package/dist/components/compounds/accordion-types.js +5 -0
- package/dist/components/compounds/action-sheet-types.d.ts +14 -0
- package/dist/components/compounds/action-sheet-types.js +5 -0
- package/dist/components/compounds/bottom-nav-types.d.ts +17 -0
- package/dist/components/compounds/bottom-nav-types.js +5 -0
- package/dist/components/compounds/index.d.ts +44 -0
- package/dist/components/compounds/index.js +54 -0
- package/dist/components/compounds/swipe-cell-types.d.ts +14 -0
- package/dist/components/compounds/swipe-cell-types.js +5 -0
- package/dist/components/compounds/timeline-types.d.ts +20 -0
- package/dist/components/compounds/timeline-types.js +5 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.js +12 -0
- package/dist/components/primitives/Avatar.svelte +102 -0
- package/dist/components/primitives/Avatar.svelte.d.ts +8 -0
- package/dist/components/primitives/Badge.svelte +33 -0
- package/dist/components/primitives/Badge.svelte.d.ts +8 -0
- package/dist/components/primitives/BareButton.svelte +45 -0
- package/dist/components/primitives/BareButton.svelte.d.ts +4 -0
- package/dist/components/primitives/BareInput.svelte +101 -0
- package/dist/components/primitives/BareInput.svelte.d.ts +4 -0
- package/dist/components/primitives/Button.svelte +60 -0
- package/dist/components/primitives/Button.svelte.d.ts +8 -0
- package/dist/components/primitives/Checkbox.svelte +58 -0
- package/dist/components/primitives/Checkbox.svelte.d.ts +4 -0
- package/dist/components/primitives/IconButton.svelte +105 -0
- package/dist/components/primitives/IconButton.svelte.d.ts +4 -0
- package/dist/components/primitives/Input.svelte +130 -0
- package/dist/components/primitives/Input.svelte.d.ts +8 -0
- package/dist/components/primitives/Progress.svelte +58 -0
- package/dist/components/primitives/Progress.svelte.d.ts +4 -0
- package/dist/components/primitives/Radio.svelte +60 -0
- package/dist/components/primitives/Radio.svelte.d.ts +25 -0
- package/dist/components/primitives/Range.svelte +117 -0
- package/dist/components/primitives/Range.svelte.d.ts +27 -0
- package/dist/components/primitives/Rating.svelte +148 -0
- package/dist/components/primitives/Rating.svelte.d.ts +27 -0
- package/dist/components/primitives/Select.svelte +95 -0
- package/dist/components/primitives/Select.svelte.d.ts +25 -0
- package/dist/components/primitives/Spinner.svelte +54 -0
- package/dist/components/primitives/Spinner.svelte.d.ts +4 -0
- package/dist/components/primitives/Switch.svelte +53 -0
- package/dist/components/primitives/Switch.svelte.d.ts +4 -0
- package/dist/components/primitives/Tag.svelte +64 -0
- package/dist/components/primitives/Tag.svelte.d.ts +4 -0
- package/dist/components/primitives/Textarea.svelte +92 -0
- package/dist/components/primitives/Textarea.svelte.d.ts +4 -0
- package/dist/components/primitives/ToggleCheckbox.svelte +36 -0
- package/dist/components/primitives/ToggleCheckbox.svelte.d.ts +4 -0
- package/dist/components/primitives/ToggleInput.svelte +36 -0
- package/dist/components/primitives/ToggleInput.svelte.d.ts +4 -0
- package/dist/components/primitives/ToggleRadio.svelte +36 -0
- package/dist/components/primitives/ToggleRadio.svelte.d.ts +4 -0
- package/dist/components/primitives/index.d.ts +26 -0
- package/dist/components/primitives/index.js +30 -0
- package/dist/components/scenes/ai/AiDocumentDownloadMenu.svelte +387 -0
- package/dist/components/scenes/ai/AiDocumentDownloadMenu.svelte.d.ts +38 -0
- package/dist/components/scenes/ai/AiDocumentEditor.svelte +2259 -0
- package/dist/components/scenes/ai/AiDocumentEditor.svelte.d.ts +4 -0
- package/dist/components/scenes/ai/MarkdownRenderer.svelte +460 -0
- package/dist/components/scenes/ai/MarkdownRenderer.svelte.d.ts +4 -0
- package/dist/components/scenes/ai/document-download.d.ts +40 -0
- package/dist/components/scenes/ai/document-download.js +300 -0
- package/dist/components/scenes/ai/document-parse.d.ts +28 -0
- package/dist/components/scenes/ai/document-parse.js +243 -0
- package/dist/components/scenes/ai/document-types.d.ts +164 -0
- package/dist/components/scenes/ai/document-types.js +1 -0
- package/dist/components/scenes/ai/index.d.ts +17 -0
- package/dist/components/scenes/ai/index.js +13 -0
- package/dist/components/scenes/ai/markdown-parse.d.ts +32 -0
- package/dist/components/scenes/ai/markdown-parse.js +161 -0
- package/dist/components/scenes/app/FeedbackModal.svelte +160 -0
- package/dist/components/scenes/app/FeedbackModal.svelte.d.ts +47 -0
- package/dist/components/scenes/app/LanguageSwitch.svelte +136 -0
- package/dist/components/scenes/app/LanguageSwitch.svelte.d.ts +50 -0
- package/dist/components/scenes/app/SettingsModal.svelte +174 -0
- package/dist/components/scenes/app/SettingsModal.svelte.d.ts +31 -0
- package/dist/components/scenes/app/ThemeSelector.svelte +176 -0
- package/dist/components/scenes/app/ThemeSelector.svelte.d.ts +31 -0
- package/dist/components/scenes/app/ThemeToggle.svelte +76 -0
- package/dist/components/scenes/app/ThemeToggle.svelte.d.ts +29 -0
- package/dist/components/scenes/app/index.d.ts +11 -0
- package/dist/components/scenes/app/index.js +11 -0
- package/dist/components/scenes/crud/CrudDeleteConfirm.svelte +39 -0
- package/dist/components/scenes/crud/CrudDeleteConfirm.svelte.d.ts +18 -0
- package/dist/components/scenes/crud/CrudDetailDrawer.svelte +155 -0
- package/dist/components/scenes/crud/CrudDetailDrawer.svelte.d.ts +38 -0
- package/dist/components/scenes/crud/CrudEditDrawer.svelte +222 -0
- package/dist/components/scenes/crud/CrudEditDrawer.svelte.d.ts +48 -0
- package/dist/components/scenes/crud/CrudFilterBar.svelte +96 -0
- package/dist/components/scenes/crud/CrudFilterBar.svelte.d.ts +31 -0
- package/dist/components/scenes/crud/CrudPage.svelte +499 -0
- package/dist/components/scenes/crud/CrudPage.svelte.d.ts +114 -0
- package/dist/components/scenes/crud/crud-types.d.ts +135 -0
- package/dist/components/scenes/crud/crud-types.js +7 -0
- package/dist/components/scenes/crud/index.d.ts +12 -0
- package/dist/components/scenes/crud/index.js +11 -0
- package/dist/components/scenes/crypto/EncryptedInput.svelte +156 -0
- package/dist/components/scenes/crypto/EncryptedInput.svelte.d.ts +32 -0
- package/dist/components/scenes/crypto/HashDisplay.svelte +97 -0
- package/dist/components/scenes/crypto/HashDisplay.svelte.d.ts +4 -0
- package/dist/components/scenes/crypto/SignatureDisplay.svelte +161 -0
- package/dist/components/scenes/crypto/SignatureDisplay.svelte.d.ts +4 -0
- package/dist/components/scenes/crypto/index.d.ts +9 -0
- package/dist/components/scenes/crypto/index.js +11 -0
- package/dist/components/scenes/iam/ChangePasswordForm.svelte +134 -0
- package/dist/components/scenes/iam/ChangePasswordForm.svelte.d.ts +8 -0
- package/dist/components/scenes/iam/ForgotPasswordForm.svelte +147 -0
- package/dist/components/scenes/iam/ForgotPasswordForm.svelte.d.ts +4 -0
- package/dist/components/scenes/iam/LoginForm.svelte +191 -0
- package/dist/components/scenes/iam/LoginForm.svelte.d.ts +8 -0
- package/dist/components/scenes/iam/PasswordInput.svelte +203 -0
- package/dist/components/scenes/iam/PasswordInput.svelte.d.ts +49 -0
- package/dist/components/scenes/iam/PermGuard.svelte +69 -0
- package/dist/components/scenes/iam/PermGuard.svelte.d.ts +16 -0
- package/dist/components/scenes/iam/RegisterForm.svelte +269 -0
- package/dist/components/scenes/iam/RegisterForm.svelte.d.ts +8 -0
- package/dist/components/scenes/iam/ResetPasswordForm.svelte +153 -0
- package/dist/components/scenes/iam/ResetPasswordForm.svelte.d.ts +8 -0
- package/dist/components/scenes/iam/UserProfile.svelte +251 -0
- package/dist/components/scenes/iam/UserProfile.svelte.d.ts +4 -0
- package/dist/components/scenes/iam/index.d.ts +16 -0
- package/dist/components/scenes/iam/index.js +18 -0
- package/dist/components/scenes/iam/password-utils.d.ts +15 -0
- package/dist/components/scenes/iam/password-utils.js +19 -0
- package/dist/components/scenes/iam/permission-context.svelte.d.ts +90 -0
- package/dist/components/scenes/iam/permission-context.svelte.js +114 -0
- package/dist/components/scenes/index.d.ts +13 -0
- package/dist/components/scenes/index.js +20 -0
- package/dist/components/scenes/storage/AvatarUpload.svelte +218 -0
- package/dist/components/scenes/storage/AvatarUpload.svelte.d.ts +4 -0
- package/dist/components/scenes/storage/FileList.svelte +260 -0
- package/dist/components/scenes/storage/FileList.svelte.d.ts +4 -0
- package/dist/components/scenes/storage/FileUpload.svelte +400 -0
- package/dist/components/scenes/storage/FileUpload.svelte.d.ts +7 -0
- package/dist/components/scenes/storage/ImageUpload.svelte +285 -0
- package/dist/components/scenes/storage/ImageUpload.svelte.d.ts +4 -0
- package/dist/components/scenes/storage/index.d.ts +10 -0
- package/dist/components/scenes/storage/index.js +12 -0
- package/dist/components/scenes/types.d.ts +583 -0
- package/dist/components/scenes/types.js +7 -0
- package/dist/i18n.svelte.d.ts +44 -0
- package/dist/i18n.svelte.js +108 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +19 -0
- package/dist/messages/en-US.json +242 -0
- package/dist/messages/zh-CN.json +242 -0
- package/dist/messages.d.ts +29 -0
- package/dist/messages.js +42 -0
- package/dist/styles/design-tokens.css +58 -0
- package/dist/styles/global.css +218 -0
- package/dist/styles/mobile.css +105 -0
- package/dist/theme-config.d.ts +92 -0
- package/dist/theme-config.js +122 -0
- package/dist/toast.svelte.d.ts +45 -0
- package/dist/toast.svelte.js +77 -0
- package/dist/types.d.ts +944 -0
- package/dist/types.js +7 -0
- package/dist/utils/platform.svelte.d.ts +54 -0
- package/dist/utils/platform.svelte.js +87 -0
- package/dist/utils.d.ts +46 -0
- package/dist/utils.js +100 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [2026] [idealworld.group]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
# @h-ai/ui
|
|
2
|
+
|
|
3
|
+
> 基于 Svelte 5 Runes 的管理后台 UI 组件库,采用 DaisyUI v5 + Tailwind CSS v4 样式 + Bits UI v2 headless 交互,内置 i18n(zh-CN / en-US),支持 32+ 主题。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @h-ai/ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
依赖 `@h-ai/core`(会自动安装)。
|
|
12
|
+
|
|
13
|
+
## 快速开始
|
|
14
|
+
|
|
15
|
+
```svelte
|
|
16
|
+
<script>
|
|
17
|
+
import { Button, Input, Card } from '@h-ai/ui'
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<Card title="示例表单">
|
|
21
|
+
<Input placeholder="请输入用户名" />
|
|
22
|
+
<Button variant="primary" onclick={handleSubmit}>提交</Button>
|
|
23
|
+
</Card>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 自动导入(推荐)
|
|
27
|
+
|
|
28
|
+
启用预处理器后,页面中可直接使用 `@h-ai/ui` 组件,无需逐个 import:
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
import { autoImportHaiUi } from '@h-ai/ui/auto-import'
|
|
32
|
+
// svelte.config.js
|
|
33
|
+
import adapter from '@sveltejs/adapter-auto'
|
|
34
|
+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
|
|
35
|
+
|
|
36
|
+
/** @type {import('@sveltejs/kit').Config} */
|
|
37
|
+
const config = {
|
|
38
|
+
preprocess: [autoImportHaiUi(), vitePreprocess()],
|
|
39
|
+
kit: { adapter: adapter() },
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default config
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
启用后可直接在模板中使用:
|
|
46
|
+
|
|
47
|
+
```svelte
|
|
48
|
+
<!-- 无需 import { Button } from '@h-ai/ui' -->
|
|
49
|
+
<Button variant="primary">提交</Button>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 组件架构
|
|
53
|
+
|
|
54
|
+
组件按三层划分(primitives → compounds → scenes):
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
components/
|
|
58
|
+
├── primitives/ # 原子组件(不可再分的基础 UI 单元)
|
|
59
|
+
├── compounds/ # 组合组件(由原子组件 + Bits UI headless 组合而成)
|
|
60
|
+
└── scenes/ # 场景组件(面向具体业务场景的完整 UI 流程)
|
|
61
|
+
├── app/ # 应用级(设置/反馈/主题/语言切换)
|
|
62
|
+
├── iam/ # 身份认证
|
|
63
|
+
├── storage/ # 存储管理
|
|
64
|
+
└── crypto/ # 加密展示
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## 组件清单
|
|
68
|
+
|
|
69
|
+
### 原子组件 Primitives(21 个)
|
|
70
|
+
|
|
71
|
+
| 组件 | 描述 | 主要属性 |
|
|
72
|
+
| ---------------- | ------------ | ------------------------------------------------------------------ |
|
|
73
|
+
| `Button` | 按钮 | `variant`, `size`, `loading`, `disabled`, `outline`, `circle` |
|
|
74
|
+
| `IconButton` | 图标按钮 | `icon: string \| Snippet`, `variant`, `size`, `tooltip`, `loading` |
|
|
75
|
+
| `BareButton` | 无样式按钮 | `class`, `ariaLabel`, `role`, `tabindex` |
|
|
76
|
+
| `Input` | 输入框 | `type`, `value`, `size`, `error`, `validationMessage` |
|
|
77
|
+
| `BareInput` | 无样式输入框 | `type`, `class`, `accept`, `multiple` |
|
|
78
|
+
| `Textarea` | 文本域 | `value`, `rows`, `size`, `autoResize`, `error` |
|
|
79
|
+
| `Select` | 下拉选择 | `options`, `value`, `placeholder`, `size` |
|
|
80
|
+
| `Checkbox` | 复选框 | `checked`, `label`, `size`, `indeterminate` |
|
|
81
|
+
| `Switch` | 开关 | `checked`, `label`, `size` |
|
|
82
|
+
| `Radio` | 单选组 | `options`, `value`, `direction`, `size` |
|
|
83
|
+
| `ToggleCheckbox` | 原生开关输入 | `checked`, `name`, `onchange` |
|
|
84
|
+
| `ToggleInput` | 原生切换输入 | `checked`, `name` |
|
|
85
|
+
| `ToggleRadio` | 原生单选输入 | `checked`, `name`, `onchange` |
|
|
86
|
+
| `Range` | 滑块 | `value`, `min`, `max`, `step` |
|
|
87
|
+
| `Rating` | 评分 | `value`, `max` |
|
|
88
|
+
| `Badge` | 徽章 | `variant`, `size`, `outline` |
|
|
89
|
+
| `Avatar` | 头像 | `src`, `name`, `size`, `shape`, `ring` |
|
|
90
|
+
| `Tag` | 标签 | `text`, `variant`, `size`, `closable` |
|
|
91
|
+
| `Spinner` | 加载动画 | `size`, `variant` |
|
|
92
|
+
| `Progress` | 进度条 | `value`, `max`, `variant`, `striped`, `animated` |
|
|
93
|
+
|
|
94
|
+
### 组合组件 Compounds(25 个)
|
|
95
|
+
|
|
96
|
+
#### 表单
|
|
97
|
+
|
|
98
|
+
| 组件 | 描述 | 主要属性 |
|
|
99
|
+
| ----------- | -------- | -------------------------------------------- |
|
|
100
|
+
| `Form` | 表单容器 | `loading`, `disabled`, `onsubmit` |
|
|
101
|
+
| `FormField` | 表单字段 | `label`, `error`, `hint`, `required` |
|
|
102
|
+
| `TagInput` | 标签输入 | `tags`, `maxTags`, `allowDuplicates`, `size` |
|
|
103
|
+
|
|
104
|
+
#### 反馈
|
|
105
|
+
|
|
106
|
+
| 组件 | 描述 | 主要属性 |
|
|
107
|
+
| ---------------- | -------- | --------------------------------- |
|
|
108
|
+
| `Alert` | 警告框 | `variant`, `title`, `dismissible` |
|
|
109
|
+
| `ToastContainer` | 通知容器 | 全局放置,配合 `toast` 单例使用 |
|
|
110
|
+
|
|
111
|
+
#### 弹层
|
|
112
|
+
|
|
113
|
+
| 组件 | 描述 | 主要属性 |
|
|
114
|
+
| --------- | ------ | ------------------------------------------------------- |
|
|
115
|
+
| `Modal` | 模态框 | `open`, `title`, `size`, `closeOnBackdrop`, `showClose` |
|
|
116
|
+
| `Drawer` | 抽屉 | `open`, `position`, `title`, `size` |
|
|
117
|
+
| `Confirm` | 确认框 | `open`, `title`, `message`, `variant`, `onconfirm` |
|
|
118
|
+
| `Popover` | 弹出层 | `open`, `position`, `trigger`, `offset` |
|
|
119
|
+
|
|
120
|
+
#### 数据展示
|
|
121
|
+
|
|
122
|
+
| 组件 | 描述 | 主要属性 |
|
|
123
|
+
| ----------- | -------- | ---------------------------------------- |
|
|
124
|
+
| `Card` | 卡片容器 | `title`, `bordered`, `shadow`, `padding` |
|
|
125
|
+
| `DataTable` | 数据表格 | `data`, `columns`, `keyField`, `loading` |
|
|
126
|
+
| `Accordion` | 手风琴 | `items: AccordionItem[]` |
|
|
127
|
+
| `Timeline` | 时间线 | `items: TimelineItem[]` |
|
|
128
|
+
|
|
129
|
+
#### Bits UI headless 交互
|
|
130
|
+
|
|
131
|
+
| 组件 | 描述 | 主要属性 |
|
|
132
|
+
| ------------ | --------------------------- | --------------------------------------------------- |
|
|
133
|
+
| `Combobox` | 可搜索下拉选择(单选/多选) | `options`, `value`, `multiple`, `placeholder` |
|
|
134
|
+
| `Calendar` | 独立日历 | `value: DateValue`, `minValue`, `maxValue` |
|
|
135
|
+
| `DatePicker` | 日期输入+弹出 | `value: DateValue`, `minValue`, `maxValue`, `error` |
|
|
136
|
+
|
|
137
|
+
> 日期值使用 `@internationalized/date` 的 `DateValue` / `CalendarDate` 类型。
|
|
138
|
+
|
|
139
|
+
#### 导航
|
|
140
|
+
|
|
141
|
+
| 组件 | 描述 | 主要属性 |
|
|
142
|
+
| ------------ | -------- | -------------------------------------------- |
|
|
143
|
+
| `Tabs` | 标签页 | `items`, `active`, `type`, `size` |
|
|
144
|
+
| `Pagination` | 分页 | `page`, `total`, `pageSize`, `showTotal` |
|
|
145
|
+
| `Breadcrumb` | 面包屑 | `items`, `separator` |
|
|
146
|
+
| `Steps` | 步骤条 | `items`, `current`, `direction`, `clickable` |
|
|
147
|
+
| `Dropdown` | 下拉菜单 | `items`, `trigger`, `position` |
|
|
148
|
+
| `Tooltip` | 提示 | `content`, `position`, `delay` |
|
|
149
|
+
|
|
150
|
+
#### 状态占位
|
|
151
|
+
|
|
152
|
+
| 组件 | 描述 | 主要属性 |
|
|
153
|
+
| ---------- | ------ | ------------------------------------- |
|
|
154
|
+
| `Skeleton` | 骨架屏 | `variant`, `width`, `height`, `count` |
|
|
155
|
+
| `Empty` | 空状态 | `title`, `description`, `icon` |
|
|
156
|
+
| `Result` | 结果页 | `status`, `title`, `description` |
|
|
157
|
+
|
|
158
|
+
#### 页面级
|
|
159
|
+
|
|
160
|
+
| 组件 | 描述 | 主要属性 |
|
|
161
|
+
| ------------ | -------- | ------------------------------------------- |
|
|
162
|
+
| `PageHeader` | 页面头部 | `title`, `description`,支持 `actions` 插槽 |
|
|
163
|
+
|
|
164
|
+
### 场景组件 Scenes(19 个)
|
|
165
|
+
|
|
166
|
+
#### App 应用级(5 个)
|
|
167
|
+
|
|
168
|
+
| 组件 | 描述 | 主要属性 |
|
|
169
|
+
| ---------------- | ---------------- | ------------------ |
|
|
170
|
+
| `FeedbackModal` | 反馈模态框 | `open`, `onsubmit` |
|
|
171
|
+
| `SettingsModal` | 设置模态框 | `open`, `onclose` |
|
|
172
|
+
| `LanguageSwitch` | 语言切换 | 无需 Props |
|
|
173
|
+
| `ThemeSelector` | 完整主题选择面板 | 无需 Props |
|
|
174
|
+
| `ThemeToggle` | 明/暗主题切换 | 无需 Props |
|
|
175
|
+
|
|
176
|
+
#### IAM 身份认证(7 个)
|
|
177
|
+
|
|
178
|
+
| 组件 | 描述 | 主要属性 |
|
|
179
|
+
| -------------------- | ---------- | ----------------------------------------------------- |
|
|
180
|
+
| `LoginForm` | 登录表单 | `loading`, `errors`, `showRememberMe`, `onsubmit` |
|
|
181
|
+
| `RegisterForm` | 注册表单 | `loading`, `errors`, `fields`, `onsubmit` |
|
|
182
|
+
| `ForgotPasswordForm` | 忘记密码 | `mode`, `loading`, `errors`, `onsubmit` |
|
|
183
|
+
| `ResetPasswordForm` | 重置密码 | `loading`, `errors`, `showCode`, `onsubmit` |
|
|
184
|
+
| `ChangePasswordForm` | 修改密码 | `loading`, `errors`, `requireOldPassword`, `onsubmit` |
|
|
185
|
+
| `PasswordInput` | 密码输入框 | `value`, `showToggle`, `showStrength`, `minLength` |
|
|
186
|
+
| `UserProfile` | 用户资料 | `user`, `editable`, `fields`, `onsubmit` |
|
|
187
|
+
|
|
188
|
+
#### Storage 存储(4 个)
|
|
189
|
+
|
|
190
|
+
| 组件 | 描述 | 主要属性 |
|
|
191
|
+
| -------------- | -------- | -------------------------------------------------------- |
|
|
192
|
+
| `FileUpload` | 文件上传 | `accept`, `maxSize`, `maxFiles`, `multiple`, `uploadUrl` |
|
|
193
|
+
| `ImageUpload` | 图片上传 | `value`, `accept`, `maxSize`, `aspectRatio` |
|
|
194
|
+
| `AvatarUpload` | 头像上传 | `value`, `size`, `maxSize`, `fallback` |
|
|
195
|
+
| `FileList` | 文件列表 | `files`, `layout`, `showDelete`, `showDownload` |
|
|
196
|
+
|
|
197
|
+
#### Crypto 加密展示(3 个)
|
|
198
|
+
|
|
199
|
+
| 组件 | 描述 | 主要属性 |
|
|
200
|
+
| ------------------ | -------- | ------------------------------------------------------- |
|
|
201
|
+
| `EncryptedInput` | 加密输入 | `value`, `encryptedValue`, `algorithm`, `showEncrypted` |
|
|
202
|
+
| `HashDisplay` | 哈希展示 | `value`, `algorithm`, `copyable`, `truncate` |
|
|
203
|
+
| `SignatureDisplay` | 签名展示 | `signature`, `publicKey`, `algorithm`, `verified` |
|
|
204
|
+
|
|
205
|
+
## 使用示例
|
|
206
|
+
|
|
207
|
+
### Toast 通知
|
|
208
|
+
|
|
209
|
+
```svelte
|
|
210
|
+
<script>
|
|
211
|
+
import { toast, ToastContainer } from '@h-ai/ui'
|
|
212
|
+
|
|
213
|
+
function notify() {
|
|
214
|
+
toast.success('操作成功')
|
|
215
|
+
toast.error('操作失败')
|
|
216
|
+
toast.warning('请注意')
|
|
217
|
+
toast.info('提示信息', 5000) // 自定义持续时间
|
|
218
|
+
}
|
|
219
|
+
</script>
|
|
220
|
+
|
|
221
|
+
<button onclick={notify}>通知</button>
|
|
222
|
+
<ToastContainer />
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### 典型 CRUD 页面
|
|
226
|
+
|
|
227
|
+
```svelte
|
|
228
|
+
<script>
|
|
229
|
+
import {
|
|
230
|
+
PageHeader, Card, DataTable, Button,
|
|
231
|
+
Modal, Input, Select, toast, ToastContainer,
|
|
232
|
+
} from '@h-ai/ui'
|
|
233
|
+
|
|
234
|
+
let items = $state([])
|
|
235
|
+
let showModal = $state(false)
|
|
236
|
+
let loading = $state(false)
|
|
237
|
+
let formData = $state({ name: '', type: '' })
|
|
238
|
+
|
|
239
|
+
const columns = [
|
|
240
|
+
{ key: 'name', label: '名称' },
|
|
241
|
+
{ key: 'type', label: '类型' },
|
|
242
|
+
{ key: 'createdAt', label: '创建时间' },
|
|
243
|
+
]
|
|
244
|
+
|
|
245
|
+
async function handleCreate() {
|
|
246
|
+
loading = true
|
|
247
|
+
try {
|
|
248
|
+
await fetch('/api/items', { method: 'POST', body: JSON.stringify(formData) })
|
|
249
|
+
showModal = false
|
|
250
|
+
toast.success('创建成功')
|
|
251
|
+
} finally {
|
|
252
|
+
loading = false
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
</script>
|
|
256
|
+
|
|
257
|
+
<PageHeader title="项目管理" description="管理所有项目">
|
|
258
|
+
{#snippet actions()}
|
|
259
|
+
<Button onclick={() => showModal = true}>新建</Button>
|
|
260
|
+
{/snippet}
|
|
261
|
+
</PageHeader>
|
|
262
|
+
|
|
263
|
+
<Card>
|
|
264
|
+
<DataTable data={items} {columns} keyField="id" {loading}>
|
|
265
|
+
{#snippet actions(item)}
|
|
266
|
+
<Button size="xs">编辑</Button>
|
|
267
|
+
<Button size="xs" variant="error">删除</Button>
|
|
268
|
+
{/snippet}
|
|
269
|
+
</DataTable>
|
|
270
|
+
</Card>
|
|
271
|
+
|
|
272
|
+
<Modal bind:open={showModal} title="新建项目">
|
|
273
|
+
<form onsubmit={(e) => { e.preventDefault(); handleCreate() }} class="space-y-4">
|
|
274
|
+
<Input placeholder="名称" bind:value={formData.name} required />
|
|
275
|
+
<Select
|
|
276
|
+
placeholder="选择类型"
|
|
277
|
+
bind:value={formData.type}
|
|
278
|
+
options={[
|
|
279
|
+
{ value: 'a', label: '类型 A' },
|
|
280
|
+
{ value: 'b', label: '类型 B' },
|
|
281
|
+
]}
|
|
282
|
+
/>
|
|
283
|
+
</form>
|
|
284
|
+
{#snippet footer()}
|
|
285
|
+
<Button variant="ghost" onclick={() => showModal = false}>取消</Button>
|
|
286
|
+
<Button {loading} onclick={handleCreate}>创建</Button>
|
|
287
|
+
{/snippet}
|
|
288
|
+
</Modal>
|
|
289
|
+
|
|
290
|
+
<ToastContainer />
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### 登录页面
|
|
294
|
+
|
|
295
|
+
```svelte
|
|
296
|
+
<script>
|
|
297
|
+
import { LoginForm } from '@h-ai/ui'
|
|
298
|
+
|
|
299
|
+
let loading = $state(false)
|
|
300
|
+
let errors = $state({})
|
|
301
|
+
|
|
302
|
+
async function handleLogin(data) {
|
|
303
|
+
loading = true
|
|
304
|
+
errors = {}
|
|
305
|
+
try {
|
|
306
|
+
await fetch('/api/login', { method: 'POST', body: JSON.stringify(data) })
|
|
307
|
+
} catch {
|
|
308
|
+
errors = { general: '登录失败,请检查用户名和密码' }
|
|
309
|
+
} finally {
|
|
310
|
+
loading = false
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
</script>
|
|
314
|
+
|
|
315
|
+
<!-- 场景组件内置 i18n,无需传入翻译 props -->
|
|
316
|
+
<LoginForm {loading} {errors} onsubmit={handleLogin} showRegisterLink />
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### PasswordInput 受控模式
|
|
320
|
+
|
|
321
|
+
```svelte
|
|
322
|
+
<script>
|
|
323
|
+
import { PasswordInput } from '@h-ai/ui'
|
|
324
|
+
|
|
325
|
+
let password = $state('')
|
|
326
|
+
</script>
|
|
327
|
+
|
|
328
|
+
<PasswordInput
|
|
329
|
+
value={password}
|
|
330
|
+
oninput={(e) => { password = e.currentTarget.value }}
|
|
331
|
+
placeholder="请输入密码"
|
|
332
|
+
showStrength
|
|
333
|
+
/>
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## 样式依赖
|
|
337
|
+
|
|
338
|
+
组件基于 TailwindCSS v4 + DaisyUI。在应用层 `app.css` 中声明主题:
|
|
339
|
+
|
|
340
|
+
```css
|
|
341
|
+
/* app.css */
|
|
342
|
+
@import 'tailwindcss';
|
|
343
|
+
|
|
344
|
+
@plugin "daisyui" {
|
|
345
|
+
themes:
|
|
346
|
+
light --default,
|
|
347
|
+
dark --prefersdark,
|
|
348
|
+
cupcake,
|
|
349
|
+
bumblebee,
|
|
350
|
+
emerald,
|
|
351
|
+
corporate,
|
|
352
|
+
retro,
|
|
353
|
+
valentine,
|
|
354
|
+
garden,
|
|
355
|
+
aqua,
|
|
356
|
+
lofi,
|
|
357
|
+
pastel,
|
|
358
|
+
fantasy,
|
|
359
|
+
wireframe,
|
|
360
|
+
cmyk,
|
|
361
|
+
autumn,
|
|
362
|
+
acid,
|
|
363
|
+
lemonade,
|
|
364
|
+
winter,
|
|
365
|
+
nord,
|
|
366
|
+
synthwave,
|
|
367
|
+
cyberpunk,
|
|
368
|
+
halloween,
|
|
369
|
+
forest,
|
|
370
|
+
black,
|
|
371
|
+
luxury,
|
|
372
|
+
dracula,
|
|
373
|
+
business,
|
|
374
|
+
night,
|
|
375
|
+
coffee,
|
|
376
|
+
dim,
|
|
377
|
+
sunset;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### 图标
|
|
383
|
+
|
|
384
|
+
组件使用 Iconify (Tabler Icons):
|
|
385
|
+
|
|
386
|
+
```bash
|
|
387
|
+
pnpm add -D @iconify/tailwind4 @iconify-json/tabler
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
```css
|
|
391
|
+
/* app.css */
|
|
392
|
+
@plugin "@iconify/tailwind4" {
|
|
393
|
+
prefixes: tabler;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### 主题切换
|
|
399
|
+
|
|
400
|
+
使用内置的主题工具函数管理 32 个 DaisyUI 主题:
|
|
401
|
+
|
|
402
|
+
```ts
|
|
403
|
+
import {
|
|
404
|
+
applyTheme, // 应用主题(自动持久化到 localStorage)
|
|
405
|
+
getCurrentTheme, // 获取当前主题
|
|
406
|
+
getThemeInitScript, // 防闪烁脚本(放在 app.html <head> 中)
|
|
407
|
+
isDarkTheme, // 检查是否暗色主题
|
|
408
|
+
THEME_GROUPS, // 按亮色/暗色分组
|
|
409
|
+
THEMES, // ThemeInfo[] — 全部 32 个主题元数据
|
|
410
|
+
} from '@h-ai/ui'
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
在 `app.html` 中添加防闪烁脚本:
|
|
414
|
+
|
|
415
|
+
```html
|
|
416
|
+
<head>
|
|
417
|
+
<script>
|
|
418
|
+
{@html getThemeInitScript()}
|
|
419
|
+
</script>
|
|
420
|
+
</head>
|
|
421
|
+
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
## 国际化 (i18n)
|
|
425
|
+
|
|
426
|
+
@h-ai/ui 采用**组件内置翻译**模式:
|
|
427
|
+
|
|
428
|
+
- 场景组件(`scenes/`)内置中英文翻译(zh-CN / en-US),开箱即用
|
|
429
|
+
- 组件自动响应全局 locale 变化(通过 `@h-ai/core` 同步)
|
|
430
|
+
- 应用层只需处理**页面级文本**,组件内部文本由 @h-ai/ui 统一管理
|
|
431
|
+
- 如需覆盖特定文本,通过 `submitText`、`labels` 等 props 传入
|
|
432
|
+
|
|
433
|
+
### createLocaleStore
|
|
434
|
+
|
|
435
|
+
用于客户端 locale 状态管理,自动同步到 `@h-ai/core` 全局 locale 管理器:
|
|
436
|
+
|
|
437
|
+
```svelte
|
|
438
|
+
<script>
|
|
439
|
+
import { createLocaleStore, setGlobalLocale } from '@h-ai/ui'
|
|
440
|
+
import { setLocale } from '$lib/paraglide/runtime'
|
|
441
|
+
|
|
442
|
+
const localeStore = createLocaleStore()
|
|
443
|
+
|
|
444
|
+
function changeLocale(code) {
|
|
445
|
+
localeStore.set(code) // 更新 UI store + 同步到 @h-ai/core
|
|
446
|
+
setLocale(code) // 同步到 Paraglide(应用层)
|
|
447
|
+
}
|
|
448
|
+
</script>
|
|
449
|
+
|
|
450
|
+
<select value={localeStore.current} onchange={(e) => changeLocale(e.currentTarget.value)}>
|
|
451
|
+
{#each localeStore.supported as l}
|
|
452
|
+
<option value={l.code}>{l.label}</option>
|
|
453
|
+
{/each}
|
|
454
|
+
</select>
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### 导出的 i18n 工具
|
|
458
|
+
|
|
459
|
+
```ts
|
|
460
|
+
import {
|
|
461
|
+
createLocaleStore, // Svelte 响应式 locale store
|
|
462
|
+
DEFAULT_LOCALE, // 默认 locale: 'zh-CN'
|
|
463
|
+
DEFAULT_LOCALES, // 支持的 locale 列表
|
|
464
|
+
detectBrowserLocale, // 检测浏览器语言
|
|
465
|
+
getGlobalLocale, // 获取当前全局 locale
|
|
466
|
+
interpolate, // 字符串插值(如 "Hello {name}")
|
|
467
|
+
isLocaleSupported, // 检查 locale 是否支持
|
|
468
|
+
resolveLocale, // 解析 locale(支持回退)
|
|
469
|
+
setGlobalLocale, // 设置全局 locale(同步 @h-ai/core)
|
|
470
|
+
} from '@h-ai/ui'
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
## 其他导出
|
|
474
|
+
|
|
475
|
+
```ts
|
|
476
|
+
// 类型
|
|
477
|
+
import type { ButtonProps, InputProps, ModalProps } from '@h-ai/ui'
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
```ts
|
|
481
|
+
// 样式工具
|
|
482
|
+
import { cn, generateId, getSizeClass, getVariantClass } from '@h-ai/ui'
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
```ts
|
|
486
|
+
// Toast 单例
|
|
487
|
+
import { toast } from '@h-ai/ui'
|
|
488
|
+
```
|