@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
package/README.en.md
CHANGED
|
@@ -6,13 +6,15 @@
|
|
|
6
6
|
|
|
7
7
|
## Introduction
|
|
8
8
|
|
|
9
|
+
Built-in messages support `zh-CN`, `en-US` and `ja-JP`; the language selector offers all three by default.
|
|
10
|
+
|
|
9
11
|
A cross-platform Svelte 5 Runes component library with DaisyUI v5 + Tailwind CSS v4 styling and Bits UI v2 headless interactions. Includes built-in i18n (zh-CN / en-US) and 15 curated DaisyUI themes.
|
|
10
12
|
|
|
11
13
|
## Core features
|
|
12
14
|
|
|
13
15
|
- Forms, tables, dialogs, navigation, charts and application components.
|
|
14
16
|
- Authentication, CRUD, AI content, onboarding and a help center.
|
|
15
|
-
- Svelte 5, themes, responsive layouts and Chinese/English component messages.
|
|
17
|
+
- Svelte 5, themes, responsive layouts and Chinese/English/Japanese component messages.
|
|
16
18
|
|
|
17
19
|
## Getting started
|
|
18
20
|
|
|
@@ -197,7 +199,7 @@ For `BareInput` with `type="file"`, read `event.currentTarget.files` in `onchang
|
|
|
197
199
|
|
|
198
200
|
Labels connect to nested UI controls automatically; use `<FormField for="control-id">` for explicit IDs or native controls. Errors and hints use `aria-describedby`, invalid controls use `aria-invalid`, and field errors appear once. `label` / `error` / `hint` accept strings or deferred translation functions.
|
|
199
201
|
|
|
200
|
-
`Input`, `Textarea`, `Select` and `PasswordInput` provide Chinese/English native validation messages. `validationMessage` overrides failures without keeping valid input invalid. Sync locale with the UI `setGlobalLocale` / `createLocaleStore` to update visible validation errors immediately. `Textarea` supports `minlength` / `maxlength`; `Select` supports `name`, required validation and FormData serialization.
|
|
202
|
+
`Input`, `Textarea`, `Select` and `PasswordInput` provide Chinese/English/Japanese native validation messages. `validationMessage` overrides failures without keeping valid input invalid. Sync locale with the UI `setGlobalLocale` / `createLocaleStore` to update visible validation errors immediately. `Textarea` supports `minlength` / `maxlength`; `Select` supports `name`, required validation and FormData serialization.
|
|
201
203
|
|
|
202
204
|
Client validation appears on the first blur and updates as invalid input is corrected. Untouched fields are validated on submit. CRUD create/edit forms share this behavior, honor custom messages and reset validation when reopened. `Select` validates when focus leaves both its trigger and options. `PasswordInput.minLength` enforces length and informs strength; omitting it leaves login password length unrestricted while strength uses an eight-character baseline.
|
|
203
205
|
|
|
@@ -317,7 +319,7 @@ Client validation appears on the first blur and updates as invalid input is corr
|
|
|
317
319
|
| -------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------ |
|
|
318
320
|
| `AuthPanel` | Configuration driven authentication | `config`, `actions`, `loginHeader/loginFields/loginFooter`, `registerHeader/registerFields/registerFooter` |
|
|
319
321
|
| `AuthShell` | Auth page layout (centered card / split columns) | `variant`, `title`, `subtitle`, `brandTitle`, `brandText`, `illustration`, `description`, `highlights` |
|
|
320
|
-
| `LoginForm` | Login form | `loading`, `errors`, `
|
|
322
|
+
| `LoginForm` | Login form | `loading`, `errors`, `showForgotPassword`, `onsubmit` |
|
|
321
323
|
| `RegisterForm` | Registration form | `loading`, `errors`, `fields`, `onsubmit` |
|
|
322
324
|
| `ForgotPasswordForm` | Forgot password | `mode`, `loading`, `errors`, `onsubmit` |
|
|
323
325
|
| `ResetPasswordForm` | Reset password | `loading`, `errors`, `showCode`, `onsubmit` |
|
|
@@ -414,6 +416,7 @@ Defaults match `@h-ai/crypto`: `SM4` for encrypted inputs, `SM3` for hashes, and
|
|
|
414
416
|
> `CrudPage` defaults to the `TableToolbar` icon/popover toolbar; use `toolbarStyle='filter-bar'` for a flat filter bar. `detailColumns={['title']}` makes specified columns open details. `toolbarLeading` injects left-side titles/descriptions; `showHeader={false}` avoids duplicate titles. `toolbarActions` adds right-side actions, `card` replaces rows with cards, `tableCell` renders interactive cells by row/column key (such as Tooltip), and `sortableColumns` controls server sorting fields. Filters support `select`, `boolean`, `number`, `date`, `date-range`, and `text`.
|
|
415
417
|
>
|
|
416
418
|
> The page fills available parent height. Tables fill remaining space even without data; only the data area scrolls, with headers fixed at its top and pagination fixed at the list card bottom.
|
|
419
|
+
> Pass remaining height through every host container, for example with `flex flex-1 min-h-0 flex-col`, from the viewport shell to the content area. Intermediate wrappers must not size only to their content. Pagination stays at the bottom for empty, short and scrolling lists.
|
|
417
420
|
>
|
|
418
421
|
> Columns first shrink to 7rem and truncate long text; horizontal scrolling appears only if total width still exceeds the container. The action column stays fixed on the right.
|
|
419
422
|
|
|
@@ -729,7 +732,7 @@ transformPageChunk: ({ html }) => html.replace('%theme_bootstrap%', themeBootstr
|
|
|
729
732
|
|
|
730
733
|
@h-ai/ui uses **built-in component translations**:
|
|
731
734
|
|
|
732
|
-
- Scene components (`scenes/`) include Chinese/English translations (zh-CN / en-US) out of the box.
|
|
735
|
+
- Scene components (`scenes/`) include Chinese/English/Japanese translations (zh-CN / en-US / ja-JP) out of the box.
|
|
733
736
|
- Components respond automatically to global locale changes, synchronized through `@h-ai/core`.
|
|
734
737
|
- Applications handle **page text** only; @h-ai/ui manages internal component text.
|
|
735
738
|
- Override specific text with props such as `submitText` or `labels`.
|
|
@@ -758,6 +761,8 @@ Client locale state management, automatically synchronized with the `@h-ai/core`
|
|
|
758
761
|
</select>
|
|
759
762
|
```
|
|
760
763
|
|
|
764
|
+
`createLocaleStore` from `@h-ai/ui/i18n` selects a resolvable saved locale, then the complete navigator.languages list (followed by navigator.language), then defaultLocale and the first supported entry. An unsupported candidate never triggers an early default. Matching handles case, language shorthand and progressively less specific region/script tags, returning the configured code. Same-language variants follow supportedLocales order. detectBrowserLocale returns null without an actual match; an empty supported list ultimately keeps the caller default. SSR neither reads browser candidates nor changes global locale. Paraglide applications must still synchronize their own setLocale; custom store entries do not add built-in UI dictionaries.
|
|
765
|
+
|
|
761
766
|
#### Exported i18n utilities
|
|
762
767
|
|
|
763
768
|
```ts
|
|
@@ -776,6 +781,8 @@ import {
|
|
|
776
781
|
|
|
777
782
|
### Configuration driven authentication
|
|
778
783
|
|
|
784
|
+
Password login submits only `identifier` and `password`; `AuthPanel` maps the `LoginForm` field `username` to `identifier`. Server settings `session.maxAge` / `session.refreshTokenMaxAge` control session lifetimes. The login form has no per-login persistent-session option.
|
|
785
|
+
|
|
779
786
|
Agreement content can be configured as `agreements.userAgreementMarkdown` and `privacyPolicyMarkdown` using YAML `|`. The modal safely renders configured Markdown and prefers it over the URL of the same agreement. URL-only content stays in a sandboxed iframe.
|
|
780
787
|
|
|
781
788
|
```yaml
|
|
@@ -809,7 +816,7 @@ When an authentication link points to the current complete URL, AuthPanel switch
|
|
|
809
816
|
|
|
810
817
|
### Onboarding and help center
|
|
811
818
|
|
|
812
|
-
Import `createGuide`, `GuideHost` and `HelpCenter` from `@h-ai/ui/guide`. No init/close is required. The tour engine loads when a tour starts; controls follow the current theme and include Chinese/English translations. Business text uses application i18n callbacks.
|
|
819
|
+
Import `createGuide`, `GuideHost` and `HelpCenter` from `@h-ai/ui/guide`. No init/close is required. The tour engine loads when a tour starts; controls follow the current theme and include Chinese/English/Japanese translations. Business text uses application i18n callbacks.
|
|
813
820
|
|
|
814
821
|
The same entry exports `resolveGuideText(text?)` to evaluate strings or i18n callbacks; host components resolve text automatically.
|
|
815
822
|
|
|
@@ -890,6 +897,19 @@ Agreements open in a Modal and preserve form input. Pages must allow iframe embe
|
|
|
890
897
|
</AuthPanel>
|
|
891
898
|
```
|
|
892
899
|
|
|
900
|
+
|
|
901
|
+
Component subpaths expose only explicit barrels in package.exports, such as `@h-ai/ui/components/primitives/index`. Component internals and storage helpers stay private; host clipboard registration remains public.
|
|
902
|
+
|
|
903
|
+
### Request locale isolation
|
|
904
|
+
|
|
905
|
+
Wrap Node requests and SSR in `core.i18n.runWithLocale(locale, () => handleRequest())`. SvelteKit can use `kit.i18n.runWithLocale(locale, () => resolve(event))`; serv creates the scope automatically from request headers. Async descendants inherit it. Explicit `MessageOptions.locale` takes precedence over the request locale and the startup default. Within a scope, `setGlobalLocale` only changes that request; outside a scope it configures the startup default and must not be called by request hooks.
|
|
906
|
+
|
|
907
|
+
Browsers keep application-level `setGlobalLocale` / `createLocaleStore`. During SSR, UI store initialization and setters only update the store; messages read the request scope. `runWithLocale` requires the Node entry; browser translations use explicit locale options or application state.
|
|
908
|
+
|
|
909
|
+
## Input limits and HTTP capabilities
|
|
910
|
+
|
|
911
|
+
Object keys are limited to 1024 UTF-8 bytes and reject absolute paths, backslashes, control characters and dot segments. Each public HTTP batch delete accepts 1–1000 entries. `@h-ai/storage/schemas` exposes the shared browser-safe rules. Presign expiry is an integer from 1 to 604800 seconds (Node default 3600, HTTP default 900). Upload signing accepts only key/contentType/expiresIn; contentLength/maxSize/metadata/checksum are unsupported. Invalid input returns HTTP 400 and the typed client maps it to VALIDATION_FAILED. FileUpload limits guide file selection; applications must validate actual objects on the server. Node streaming/checksum/conditional-write options have no default HTTP endpoints. See the [capability and authorization matrix (Chinese)](../storage/README.md#存储输入约束与跨端能力).
|
|
912
|
+
|
|
893
913
|
## Development and testing
|
|
894
914
|
|
|
895
915
|
```sh
|
|
@@ -899,6 +919,12 @@ pnpm --filter @h-ai/ui build
|
|
|
899
919
|
pnpm --filter @h-ai/ui test
|
|
900
920
|
```
|
|
901
921
|
|
|
922
|
+
## Design and interaction acceptance
|
|
923
|
+
|
|
924
|
+
Use [hai-ui-design](../cli/templates/skills/hai-ui-design/SKILL.md) for page decisions, [hai-ui](../cli/templates/skills/hai-ui/SKILL.md) for implementation, and [hai-ui-review](../cli/templates/skills/hai-ui-review/SKILL.md) for rendered UI review. See the [shared design guidance](../../.agents/instructions/ui-design.md).
|
|
925
|
+
|
|
926
|
+
Tabs support arrow/Home/End navigation, disabled items and one Tab stop. Tables expose sort/loading state and keyboard row activation. Pagination labels follow locale and external page changes update the jump input. Toolbar panels manage focus and view buttons expose selection. Empty/Alert wrap long content. theme.css imports shared tokens; focus follows the current theme and global.css respects reduced motion. Applications still implement filtering, sorting, paging and recovery.
|
|
927
|
+
|
|
902
928
|
## License
|
|
903
929
|
|
|
904
930
|
Apache-2.0
|
package/README.ja.md
CHANGED
|
@@ -6,13 +6,15 @@
|
|
|
6
6
|
|
|
7
7
|
## 概要
|
|
8
8
|
|
|
9
|
+
内蔵メッセージは `zh-CN`、`en-US`、`ja-JP` に対応し、言語セレクターは既定で3言語を表示します。
|
|
10
|
+
|
|
9
11
|
Svelte 5 Runes のクロスプラットフォーム UI ライブラリーです。DaisyUI v5 + Tailwind CSS v4 のスタイル、Bits UI v2 のヘッドレス UI、内蔵 i18n(zh-CN / en-US)、15 種類の厳選テーマを提供します。
|
|
10
12
|
|
|
11
13
|
## 主な機能
|
|
12
14
|
|
|
13
15
|
- フォーム、テーブル、ダイアログ、ナビゲーション、チャートなどの部品。
|
|
14
16
|
- 認証、CRUD、AI コンテンツ、操作ガイド、ヘルプセンター。
|
|
15
|
-
- Svelte 5
|
|
17
|
+
- Svelte 5、テーマ、レスポンシブ表示、中国語・英語・日本語のコンポーネント文言。
|
|
16
18
|
|
|
17
19
|
## 使い始める
|
|
18
20
|
|
|
@@ -197,7 +199,7 @@ components/
|
|
|
197
199
|
|
|
198
200
|
ラベルは内部 UI コントロールに自動で関連付けられます。明示 ID やネイティブ要素は `<FormField for="control-id">` を使います。エラーとヒントは `aria-describedby`、無効な要素は `aria-invalid` で通知し、エラーは重複表示しません。`label` / `error` / `hint` は文字列または翻訳関数を受け取ります。
|
|
199
201
|
|
|
200
|
-
`Input`、`Textarea`、`Select`、`PasswordInput`
|
|
202
|
+
`Input`、`Textarea`、`Select`、`PasswordInput` のネイティブ検証は中国語・英語・日本語に対応します。`validationMessage` は失敗時だけ適用され、有効な入力を無効にし続けません。UI の `setGlobalLocale` / `createLocaleStore` で言語を同期すると表示中のエラーも更新されます。`Textarea` は `minlength` / `maxlength`、`Select` は `name`・必須検証・FormData に対応します。
|
|
201
203
|
|
|
202
204
|
初回のフォーカス離脱時にエラーを表示し、修正中も更新します。未操作の項目は送信時に検証します。CRUD の新規作成・編集も同じ動作とカスタムメッセージに対応し、再表示時に検証状態をリセットします。`Select` はトリガーと選択肢の両方からフォーカスが離れた時に検証します。`PasswordInput.minLength` は長さ制約と強度計算に使い、省略時はログイン用の長さ制限を設けず、強度のみ8文字を基準にします。
|
|
203
205
|
|
|
@@ -317,7 +319,7 @@ components/
|
|
|
317
319
|
| -------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------ |
|
|
318
320
|
| `AuthPanel` | 設定による認証画面 | `config`, `actions`, `loginHeader/loginFields/loginFooter`, `registerHeader/registerFields/registerFooter` |
|
|
319
321
|
| `AuthShell` | 認証ページ配置(中央カード / 左右分割) | `variant`, `title`, `subtitle`, `brandTitle`, `brandText`, `illustration`, `description`, `highlights` |
|
|
320
|
-
| `LoginForm` | ログインフォーム | `loading`, `errors`, `
|
|
322
|
+
| `LoginForm` | ログインフォーム | `loading`, `errors`, `showForgotPassword`, `onsubmit` |
|
|
321
323
|
| `RegisterForm` | 登録フォーム | `loading`, `errors`, `fields`, `onsubmit` |
|
|
322
324
|
| `ForgotPasswordForm` | パスワード忘れ | `mode`, `loading`, `errors`, `onsubmit` |
|
|
323
325
|
| `ResetPasswordForm` | パスワードリセット | `loading`, `errors`, `showCode`, `onsubmit` |
|
|
@@ -414,6 +416,7 @@ components/
|
|
|
414
416
|
> `CrudPage` は既定で `TableToolbar` のアイコン・ポップアップ形式を使い、`toolbarStyle='filter-bar'` で平置きにできます。`detailColumns={['title']}` は指定列を詳細入口にします。`toolbarLeading` は左のタイトル・説明、`showHeader={false}` はタイトル重複の防止、`toolbarActions` は右の操作に使います。`card` は行をカード化、`tableCell` は行・列 key で Tooltip などの操作要素を描画、`sortableColumns` はサーバーのソート項目を制御します。フィルターは `select`、`boolean`、`number`、`date`、`date-range`、`text` に対応します。
|
|
415
417
|
>
|
|
416
418
|
> ページは親の利用可能な高さを満たします。データの有無にかかわらずテーブルが残りの領域を使い、データ部分のみがスクロールします。見出しはデータ領域の上、ページ分割は一覧カードの下に固定します。
|
|
419
|
+
> ビューポートの外枠からコンテンツまで、各親要素に `flex flex-1 min-h-0 flex-col` などで残りの高さを渡します。中間のラッパーを内容だけの高さにしないでください。空・少数・スクロールする一覧でもページ分割は下部に配置されます。
|
|
417
420
|
>
|
|
418
421
|
> 列は先に 7rem まで縮小し長文を切り詰め、総幅が容器を超える場合のみ横スクロールを出します。操作列は右に固定し、横スクロール中も表示します。
|
|
419
422
|
|
|
@@ -729,7 +732,7 @@ transformPageChunk: ({ html }) => html.replace('%theme_bootstrap%', themeBootstr
|
|
|
729
732
|
|
|
730
733
|
@h-ai/ui は**コンポーネント内蔵翻訳**を使います:
|
|
731
734
|
|
|
732
|
-
- 用途別コンポーネント(`scenes
|
|
735
|
+
- 用途別コンポーネント(`scenes/`)は中国語・英語・日本語(zh-CN / en-US / ja-JP)を内蔵し、そのまま使えます。
|
|
733
736
|
- `@h-ai/core` と同期した全体 locale の変更へ自動応答します。
|
|
734
737
|
- アプリは**ページ単位の文言**のみを扱い、内部テキストは @h-ai/ui が管理します。
|
|
735
738
|
- 個別文言の変更は `submitText`・`labels` などの props で指定。
|
|
@@ -758,6 +761,8 @@ transformPageChunk: ({ html }) => html.replace('%theme_bootstrap%', themeBootstr
|
|
|
758
761
|
</select>
|
|
759
762
|
```
|
|
760
763
|
|
|
764
|
+
`@h-ai/ui/i18n` の createLocaleStore は、解決できる保存値、navigator.languages 全体(その後 navigator.language)、defaultLocale、対応一覧の先頭の順で選択します。未対応の最初の候補で既定値に戻しません。大小文字、言語略称、地域・スクリプトの段階的フォールバックを照合し、設定済みのコードを返します。同じ言語の複数候補は supportedLocales 順です。実際の一致がなければ detectBrowserLocale は null、空の対応一覧では最終的に呼出側の既定値を返します。SSR はブラウザー候補を読まず全体の言語を変更しません。Paraglide アプリは独自の setLocale 同期が必要で、対応一覧の追加だけでは UI 内蔵辞書は増えません。
|
|
765
|
+
|
|
761
766
|
#### エクスポートされる i18n ツール
|
|
762
767
|
|
|
763
768
|
```ts
|
|
@@ -776,6 +781,8 @@ import {
|
|
|
776
781
|
|
|
777
782
|
### 設定による認証画面
|
|
778
783
|
|
|
784
|
+
パスワードログインの送信項目は `identifier` と `password` のみです。`AuthPanel` は `LoginForm` の `username` を `identifier` に変換します。有効期間はサーバーの `session.maxAge` / `session.refreshTokenMaxAge` で設定し、フォームにログインごとの永続セッション選択肢はありません。
|
|
785
|
+
|
|
779
786
|
YAML の `|` で `agreements.userAgreementMarkdown` と `privacyPolicyMarkdown` を設定できます。Modal は本文を安全に描画し、同じ規約の URL より本文を優先します。URL のみの場合は隔離 iframe を使用します。
|
|
780
787
|
|
|
781
788
|
```yaml
|
|
@@ -809,7 +816,7 @@ AuthPanel は SSR 中のフォーム操作を無効にし、クライアント
|
|
|
809
816
|
|
|
810
817
|
### 初回ガイドとヘルプセンター
|
|
811
818
|
|
|
812
|
-
`@h-ai/ui/guide` から `createGuide`、`GuideHost`、`HelpCenter` をインポートします。init/close
|
|
819
|
+
`@h-ai/ui/guide` から `createGuide`、`GuideHost`、`HelpCenter` をインポートします。init/close は不要です。ガイド開始時にエンジンを読み込み、既存テーマと中国語・英語・日本語の共通文言を使用します。業務内容はアプリの翻訳関数を使います。
|
|
813
820
|
|
|
814
821
|
同じ入口の `resolveGuideText(text?)` は文字列や i18n コールバックを評価します。ホストコンポーネントは文言を自動で解析します。
|
|
815
822
|
|
|
@@ -890,6 +897,19 @@ import { toast } from '@h-ai/ui'
|
|
|
890
897
|
</AuthPanel>
|
|
891
898
|
```
|
|
892
899
|
|
|
900
|
+
|
|
901
|
+
コンポーネントのサブパスは package.exports に明記した barrel(例: `@h-ai/ui/components/primitives/index`)に限定します。内部実装やストレージ補助関数は非公開で、ホストのクリップボード登録は引き続き公開します。
|
|
902
|
+
|
|
903
|
+
### リクエスト言語の分離
|
|
904
|
+
|
|
905
|
+
Node リクエストと SSR は `core.i18n.runWithLocale(locale, () => handleRequest())` で囲みます。SvelteKit は `kit.i18n.runWithLocale(locale, () => resolve(event))` を使えます。serv はリクエストヘッダーから自動設定します。非同期の子処理も言語を継承し、明示的な `MessageOptions.locale`、リクエスト言語、起動時の既定値の順で優先します。コンテキスト内の `setGlobalLocale` はそのリクエストだけを変更します。コンテキスト外の設定は起動時に限定し、リクエスト hook から呼びません。
|
|
906
|
+
|
|
907
|
+
ブラウザーはアプリ全体の `setGlobalLocale` / `createLocaleStore` を使います。SSR の UI store 初期化と setter は自身の状態のみ変更し、メッセージはリクエストコンテキストを参照します。`runWithLocale` は Node 入口専用です。
|
|
908
|
+
|
|
909
|
+
## 入力制約と HTTP 機能
|
|
910
|
+
|
|
911
|
+
キーは UTF-8 で最大 1024 バイトで、絶対パス、バックスラッシュ、制御文字、ドットセグメントを拒否します。公開 HTTP 一括削除は一度に 1–1000 件です。共通規則はブラウザー対応の `@h-ai/storage/schemas` から参照できます。署名有効期限は整数 1–604800 秒(Node 既定 3600、HTTP 既定 900)。アップロード署名の入力は key/contentType/expiresIn のみで、contentLength/maxSize/metadata/checksum は未対応です。不正入力は HTTP 400、typed client では VALIDATION_FAILED です。FileUpload の制限は選択時の補助であり、実際のオブジェクトはサーバーで検証してください。Node のストリーム/checksum/条件付き書き込みには既定の HTTP エンドポイントがありません。[機能と認可の対応表(中国語)](../storage/README.md#存储输入约束与跨端能力)を参照してください。
|
|
912
|
+
|
|
893
913
|
## 開発とテスト
|
|
894
914
|
|
|
895
915
|
```sh
|
|
@@ -899,6 +919,12 @@ pnpm --filter @h-ai/ui build
|
|
|
899
919
|
pnpm --filter @h-ai/ui test
|
|
900
920
|
```
|
|
901
921
|
|
|
922
|
+
## デザインと操作の検証
|
|
923
|
+
|
|
924
|
+
画面設計は [hai-ui-design](../cli/templates/skills/hai-ui-design/SKILL.md)、実装は [hai-ui](../cli/templates/skills/hai-ui/SKILL.md)、実画面の確認は [hai-ui-review](../cli/templates/skills/hai-ui-review/SKILL.md) を参照してください。[共通設計指針](../../.agents/instructions/ui-design.md) も利用できます。
|
|
925
|
+
|
|
926
|
+
Tabs は方向キー・Home/End、無効項目のスキップと単一の Tab 入口に対応します。表は並べ替え・読み込み状態と行のキーボード操作を提供します。ページ切り替えのラベルは言語に従い、外部ページ変更を入力欄に同期します。ツールバーはフォーカスと表示切り替え状態を管理します。Empty/Alert は長文を折り返します。theme.css は共通 tokens を読み込み、global.css は動きを減らす設定に対応します。業務側で検索、並べ替え、ページ切り替えと復旧処理を接続してください。
|
|
927
|
+
|
|
902
928
|
## ライセンス
|
|
903
929
|
|
|
904
930
|
Apache-2.0
|
package/README.md
CHANGED
|
@@ -6,13 +6,15 @@
|
|
|
6
6
|
|
|
7
7
|
## 简介
|
|
8
8
|
|
|
9
|
+
内置中英日文消息(`zh-CN` / `en-US` / `ja-JP`),语言选择器默认提供三种语言。
|
|
10
|
+
|
|
9
11
|
基于 Svelte 5 Runes 的多端 UI 组件库,采用 DaisyUI v5 + Tailwind CSS v4 样式 + Bits UI v2 headless 交互,内置 i18n(zh-CN / en-US),内置 15 个精选 DaisyUI 主题。
|
|
10
12
|
|
|
11
13
|
## 核心功能清单
|
|
12
14
|
|
|
13
15
|
- 表单、表格、弹窗、导航、图表与业务场景组件。
|
|
14
16
|
- 认证、CRUD、AI 内容展示、新手引导和帮助中心。
|
|
15
|
-
- Svelte 5
|
|
17
|
+
- Svelte 5、主题切换、响应式布局及中英日文组件文案。
|
|
16
18
|
|
|
17
19
|
## 使用入门
|
|
18
20
|
|
|
@@ -197,7 +199,7 @@ components/
|
|
|
197
199
|
|
|
198
200
|
标签自动关联内部 UI 控件;已有控件 ID 或原生控件使用 `<FormField for="control-id">`。错误/提示通过 `aria-describedby` 关联,错误控件带 `aria-invalid`,只显示一份字段提示。`label` / `error` / `hint` 支持字符串或延迟翻译函数。
|
|
199
201
|
|
|
200
|
-
`Input`、`Textarea`、`Select` 和 `PasswordInput`
|
|
202
|
+
`Input`、`Textarea`、`Select` 和 `PasswordInput` 的原生校验使用内置中英日文提示;`validationMessage` 只覆盖失败提示,不让有效输入一直无效。应用通过 UI 的 `setGlobalLocale` / `createLocaleStore` 同步语言,已显示的校验错误即时更新。`Textarea` 支持 `minlength` / `maxlength`,`Select` 支持 `name`、必填校验和 FormData 序列化。
|
|
201
203
|
|
|
202
204
|
字段首次失焦后显示前端校验错误,修正输入时即时更新;未访问的字段在提交时统一校验。CRUD 新增/编辑复用该行为,支持自定义校验文案,关闭重开清空校验状态。`Select` 在焦点离开触发器和选项后校验。`PasswordInput.minLength` 同时约束长度并用于强度计算;省略时不限制登录密码长度,强度计算仍以 8 位为基准。
|
|
203
205
|
|
|
@@ -317,7 +319,7 @@ components/
|
|
|
317
319
|
| -------------------- | ---------- | ----------------------------------------------------- |
|
|
318
320
|
| `AuthPanel` | 配置驱动认证页 | `config`, `actions`, `loginHeader/loginFields/loginFooter`, `registerHeader/registerFields/registerFooter` |
|
|
319
321
|
| `AuthShell` | 认证页布局(居中卡片 / 左右分栏) | `variant`, `title`, `subtitle`, `brandTitle`, `brandText`, `illustration`, `description`, `highlights` |
|
|
320
|
-
| `LoginForm` | 登录表单 | `loading`, `errors`, `
|
|
322
|
+
| `LoginForm` | 登录表单 | `loading`, `errors`, `showForgotPassword`, `onsubmit` |
|
|
321
323
|
| `RegisterForm` | 注册表单 | `loading`, `errors`, `fields`, `onsubmit` |
|
|
322
324
|
| `ForgotPasswordForm` | 忘记密码 | `mode`, `loading`, `errors`, `onsubmit` |
|
|
323
325
|
| `ResetPasswordForm` | 重置密码 | `loading`, `errors`, `showCode`, `onsubmit` |
|
|
@@ -413,6 +415,7 @@ components/
|
|
|
413
415
|
> `CrudPage` 默认使用 `TableToolbar` 图标弹层工具栏,也可通过 `toolbarStyle='filter-bar'` 切回平铺筛选栏;`detailColumns={['title']}` 可把标题等指定列绑定为详情入口;`toolbarLeading` 用于注入左侧标题或说明,配合 `showHeader={false}` 可避免重复标题;`toolbarActions` 注入右侧业务操作,`card` 插槽可将列表项替换为卡片视图,`tableCell` 可按行和列 key 渲染交互式单元格内容(例如 Tooltip),`sortableColumns` 控制服务端排序字段。过滤工具栏支持 `select`、`boolean`、`number`、`date`、`date-range`、`text`。
|
|
414
416
|
>
|
|
415
417
|
> 页面根容器会占满父级可用高度。表格无论是否有数据都会撑满剩余空间,仅数据区域滚动;表头固定在数据区顶部,分页栏固定在列表卡片底部。
|
|
418
|
+
> 宿主从视口外壳到内容区须逐层传递剩余高度(例如 `flex flex-1 min-h-0 flex-col`),中间包装层不能仅按内容自动计算高度。空表、少量数据和长列表均沿用底部分页。
|
|
416
419
|
>
|
|
417
420
|
> 表格列会优先压缩到 7rem 并截断超长文本;列总宽度仍超过容器时才显示横向滚动条。操作列固定在右侧,横向滚动时保持可见。
|
|
418
421
|
|
|
@@ -728,44 +731,11 @@ transformPageChunk: ({ html }) => html.replace('%theme_bootstrap%', themeBootstr
|
|
|
728
731
|
|
|
729
732
|
@h-ai/ui 采用**组件内置翻译**模式:
|
|
730
733
|
|
|
731
|
-
- 场景组件(`scenes
|
|
734
|
+
- 场景组件(`scenes/`)内置中英日文翻译(zh-CN / en-US / ja-JP),开箱即用
|
|
732
735
|
- 组件自动响应全局 locale 变化(通过 `@h-ai/core` 同步)
|
|
733
736
|
- 应用层只需处理**页面级文本**,组件内部文本由 @h-ai/ui 统一管理
|
|
734
737
|
- 如需覆盖特定文本,通过 `submitText`、`labels` 等 props 传入
|
|
735
738
|
|
|
736
|
-
### 配置驱动认证页面
|
|
737
|
-
|
|
738
|
-
协议支持 `agreements.userAgreementMarkdown` 与 `privacyPolicyMarkdown` 直接从配置加载;YAML 的 `|` 保留 Markdown 段落和换行。弹窗复用安全 MarkdownRenderer,关闭原始 HTML、脚本和代码复制工具。同主题同时提供正文与 URL 时优先正文,URL 可作为额外查看入口;只有 URL 时使用隔离 iframe。
|
|
739
|
-
|
|
740
|
-
```yaml
|
|
741
|
-
agreements:
|
|
742
|
-
showOnRegister: true
|
|
743
|
-
showOnLogin: false
|
|
744
|
-
userAgreementMarkdown: |
|
|
745
|
-
# 用户协议
|
|
746
|
-
|
|
747
|
-
**账户使用条款**
|
|
748
|
-
|
|
749
|
-
- 请妥善保管账户凭据。
|
|
750
|
-
privacyPolicyMarkdown: |
|
|
751
|
-
# 隐私政策
|
|
752
|
-
|
|
753
|
-
注册资料用于账户管理,会话信息用于身份认证。
|
|
754
|
-
# 可选 URL;同主题同时配置 Markdown 和 URL 时,弹窗优先显示 Markdown。
|
|
755
|
-
# userAgreementUrl: https://example.com/terms
|
|
756
|
-
# privacyPolicyUrl: https://example.com/privacy
|
|
757
|
-
```
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
AuthPanel 直接接收 IAM 白名单配置和 actions,内置登录(密码/LDAP/邮件/短信)、注册、找回、重置及协议展示。使用 `config.ui` 配置卡片/分栏、标题、品牌、Logo 和配图。`LoginForm` 提供 methods、onsendotp、otpLength、resendInterval;密码表单接受 passwordPolicy。组件只渲染与交互,网络和 Token 存储通过 actions 注入。认证场景按公开 IAM 错误码显示当前 UI 语言的提示,应用自定义错误保留原文。
|
|
762
|
-
|
|
763
|
-
AuthPanel 在 SSR 阶段禁用原生表单控件,客户端挂载并绑定事件后自动开放输入,避免接管时丢失早到的输入。应用无需额外的就绪适配;E2E 等待控件可编辑,并覆盖客户端脚本延迟加载的场景。
|
|
764
|
-
|
|
765
|
-
认证链接指向当前完整 URL 时,AuthPanel 只切换场景并阻止重复导航,返回登录后可立即输入。路径、查询串或 hash 不同时交给应用路由处理;Ctrl/Cmd 等修改键点击保留浏览器行为。
|
|
766
|
-
|
|
767
|
-
[完整 IAM 配置 / IAM configuration](../iam/README.md)
|
|
768
|
-
|
|
769
739
|
#### createLocaleStore
|
|
770
740
|
|
|
771
741
|
用于客户端 locale 状态管理,自动同步到 `@h-ai/core` 全局 locale 管理器:
|
|
@@ -790,6 +760,8 @@ AuthPanel 在 SSR 阶段禁用原生表单控件,客户端挂载并绑定事
|
|
|
790
760
|
</select>
|
|
791
761
|
```
|
|
792
762
|
|
|
763
|
+
`@h-ai/ui/i18n` 的 `createLocaleStore` 按“可解析的持久化值 → 完整 navigator.languages(再检查 navigator.language)→ defaultLocale → 支持列表首项”选择语言;首个不支持的候选不触发默认回退。匹配大小写、语言简写及逐级区域/脚本回退,返回 supportedLocales 中的配置代码;同语言多个变体按列表顺序选择。detectBrowserLocale 无实际命中返回 null,不插入框架默认值;空支持列表最终保留调用方默认值。SSR 不读取浏览器候选或修改全局语言。应用若使用 Paraglide,仍需用该项目的 setLocale 同步应用翻译;内置 UI 字典的覆盖范围不因自定义 store 列表而自动增加。
|
|
764
|
+
|
|
793
765
|
#### 导出的 i18n 工具
|
|
794
766
|
|
|
795
767
|
```ts
|
|
@@ -823,9 +795,44 @@ import {
|
|
|
823
795
|
|
|
824
796
|
上例的 subscribe 为应用自身的 $state,应用包装 register 动作校验/提交扩展业务数据;如需单独组合表单,使用 `<RegisterForm> {#snippet extraFields()}...{/snippet} </RegisterForm>`。扩展里的按钮须为 `type="button"`,避免误提交。
|
|
825
797
|
|
|
798
|
+
### 配置驱动认证页面
|
|
799
|
+
|
|
800
|
+
密码登录只提交 `identifier` 和 `password`;`AuthPanel` 将 `LoginForm` 的 `username` 映射为 `identifier`。会话有效期由服务端 `session.maxAge` / `session.refreshTokenMaxAge` 配置决定,登录表单不提供按次登录的持久会话选项。
|
|
801
|
+
|
|
802
|
+
协议支持 `agreements.userAgreementMarkdown` 与 `privacyPolicyMarkdown` 直接从配置加载;YAML 的 `|` 保留 Markdown 段落和换行。弹窗复用安全 MarkdownRenderer,关闭原始 HTML、脚本和代码复制工具。同主题同时提供正文与 URL 时优先正文,URL 可作为额外查看入口;只有 URL 时使用隔离 iframe。
|
|
803
|
+
|
|
804
|
+
```yaml
|
|
805
|
+
agreements:
|
|
806
|
+
showOnRegister: true
|
|
807
|
+
showOnLogin: false
|
|
808
|
+
userAgreementMarkdown: |
|
|
809
|
+
# 用户协议
|
|
810
|
+
|
|
811
|
+
**账户使用条款**
|
|
812
|
+
|
|
813
|
+
- 请妥善保管账户凭据。
|
|
814
|
+
privacyPolicyMarkdown: |
|
|
815
|
+
# 隐私政策
|
|
816
|
+
|
|
817
|
+
注册资料用于账户管理,会话信息用于身份认证。
|
|
818
|
+
# 可选 URL;同主题同时配置 Markdown 和 URL 时,弹窗优先显示 Markdown。
|
|
819
|
+
# userAgreementUrl: https://example.com/terms
|
|
820
|
+
# privacyPolicyUrl: https://example.com/privacy
|
|
821
|
+
```
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
AuthPanel 直接接收 IAM 白名单配置和 actions,内置登录(密码/LDAP/邮件/短信)、注册、找回、重置及协议展示。使用 `config.ui` 配置卡片/分栏、标题、品牌、Logo 和配图。`LoginForm` 提供 methods、onsendotp、otpLength、resendInterval;密码表单接受 passwordPolicy。组件只渲染与交互,网络和 Token 存储通过 actions 注入。认证场景按公开 IAM 错误码显示当前 UI 语言的提示,应用自定义错误保留原文。
|
|
826
|
+
|
|
827
|
+
AuthPanel 在 SSR 阶段禁用原生表单控件,客户端挂载并绑定事件后自动开放输入,避免接管时丢失早到的输入。应用无需额外的就绪适配;E2E 等待控件可编辑,并覆盖客户端脚本延迟加载的场景。
|
|
828
|
+
|
|
829
|
+
认证链接指向当前完整 URL 时,AuthPanel 只切换场景并阻止重复导航,返回登录后可立即输入。路径、查询串或 hash 不同时交给应用路由处理;Ctrl/Cmd 等修改键点击保留浏览器行为。
|
|
830
|
+
|
|
831
|
+
[完整 IAM 配置 / IAM configuration](../iam/README.md)
|
|
832
|
+
|
|
826
833
|
### 新手引导与帮助中心
|
|
827
834
|
|
|
828
|
-
`@h-ai/ui/guide` 提供 `createGuide`、`GuideHost`、`HelpCenter` 和相关类型。无需 init/close
|
|
835
|
+
`@h-ai/ui/guide` 提供 `createGuide`、`GuideHost`、`HelpCenter` 和相关类型。无需 init/close;引擎在开始导览时按需加载,浮层复用当前主题。组件内置中英日文按钮、进度和错误提示,业务内容使用应用 i18n。
|
|
829
836
|
|
|
830
837
|
同一入口的 `resolveGuideText(text?)` 可解析字符串或 i18n 回调;宿主组件已自动解析文案。
|
|
831
838
|
|
|
@@ -893,6 +900,19 @@ import { cn, generateId, getSizeClass, getVariantClass } from '@h-ai/ui'
|
|
|
893
900
|
import { toast } from '@h-ai/ui'
|
|
894
901
|
```
|
|
895
902
|
|
|
903
|
+
|
|
904
|
+
组件子路径只开放 package.exports 明确列出的 barrel,例如 `@h-ai/ui/components/primitives/index`;不开放任意组件实现或内部存储辅助函数。宿主剪贴板注册仍是公开能力。
|
|
905
|
+
|
|
906
|
+
### 请求语言隔离
|
|
907
|
+
|
|
908
|
+
Node 请求与 SSR 使用 `core.i18n.runWithLocale(locale, () => handleRequest())`;SvelteKit 可使用 `kit.i18n.runWithLocale(locale, () => resolve(event))`,serv 自动按请求头建立上下文。异步子任务继承请求语言,优先级为显式 `MessageOptions.locale`、请求语言、进程启动默认语言。`setGlobalLocale` 在请求上下文中只更新当前请求;上下文外仅用于启动默认值,不能在请求 hook 中调用它修改默认值。
|
|
909
|
+
|
|
910
|
+
浏览器继续使用应用级 `setGlobalLocale` / `createLocaleStore`。SSR 的 UI store 初始化和 setter 只修改自身状态,不写全局语言;UI 消息从请求上下文读取。`runWithLocale` 仅支持 Node 入口,浏览器通过显式 locale 或应用状态翻译。
|
|
911
|
+
|
|
912
|
+
## 输入约束与 HTTP 能力
|
|
913
|
+
|
|
914
|
+
存储 key 按 UTF-8 最多 1024 字节,并拒绝绝对路径、反斜线、控制字符及点路径段;公开 HTTP 批量删除每次 1–1000 项。`@h-ai/storage/schemas` 提供浏览器安全的共同规则。预签名有效期为整数 1–604800 秒(Node 默认 3600,HTTP 默认 900);HTTP 上传仅接受 key/contentType/expiresIn,不支持 contentLength/maxSize/metadata/checksum。无效输入返回 HTTP 400,typed client 映射 VALIDATION_FAILED。FileUpload 的大小/类型限制仅为前端体验,实际对象须由应用服务端复核。Node 流式读写/checksum/条件写等没有默认 HTTP 端点。完整映射与授权边界见 [存储 API 能力](../storage/README.md#存储输入约束与跨端能力)。
|
|
915
|
+
|
|
896
916
|
## 开发测试
|
|
897
917
|
|
|
898
918
|
```sh
|
|
@@ -902,6 +922,12 @@ pnpm --filter @h-ai/ui build
|
|
|
902
922
|
pnpm --filter @h-ai/ui test
|
|
903
923
|
```
|
|
904
924
|
|
|
925
|
+
## 设计与交互验收
|
|
926
|
+
|
|
927
|
+
页面设计使用 [hai-ui-design](../cli/templates/skills/hai-ui-design/SKILL.md),组件实现使用 [hai-ui](../cli/templates/skills/hai-ui/SKILL.md),真实界面走查使用 [hai-ui-review](../cli/templates/skills/hai-ui-review/SKILL.md)。[设计约定](../../.agents/instructions/ui-design.md) 说明布局、状态和示例。
|
|
928
|
+
|
|
929
|
+
Tabs 支持方向键/Home/End、禁用项跳过和单一 Tab 入口;表格提供排序与加载状态和行键盘操作;分页导航/输入名称跟随语言,外部页码同步跳页输入;工具栏弹层管理焦点,视图按钮提供选中状态。Empty/Alert 支持长内容换行。theme.css 引入共享 tokens,焦点跟随当前主题,global.css 响应减少动态效果。应用仍需接入实际筛选、排序、分页与失败恢复。
|
|
930
|
+
|
|
905
931
|
## 许可证
|
|
906
932
|
|
|
907
933
|
Apache-2.0
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<!--
|
|
2
|
+
@component Accordion
|
|
2
3
|
=============================================================================
|
|
3
4
|
@h-ai/ui - Accordion 组件
|
|
4
5
|
=============================================================================
|
|
@@ -7,6 +8,16 @@
|
|
|
7
8
|
使用 Svelte 5 Runes ($props, $state, $derived)
|
|
8
9
|
使用 DaisyUI collapse 类
|
|
9
10
|
=============================================================================
|
|
11
|
+
|
|
12
|
+
@example
|
|
13
|
+
```ts
|
|
14
|
+
import { mount, unmount } from 'svelte'
|
|
15
|
+
import type { ComponentProps } from 'svelte'
|
|
16
|
+
import { Accordion } from '@h-ai/ui'
|
|
17
|
+
const props: ComponentProps<typeof Accordion> = { items: [{ id: 'intro', title: '简介', content: '操作说明' }], value: 'intro' }
|
|
18
|
+
const component = mount(Accordion, { target: document.body, props })
|
|
19
|
+
await unmount(component)
|
|
20
|
+
```
|
|
10
21
|
-->
|
|
11
22
|
|
|
12
23
|
<script lang='ts'>
|
|
@@ -17,6 +28,19 @@
|
|
|
17
28
|
import ToggleCheckbox from '../primitives/ToggleCheckbox.svelte'
|
|
18
29
|
import ToggleRadio from '../primitives/ToggleRadio.svelte'
|
|
19
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Accordion 组件的属性契约;通过公开组件配置使用。
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { mount, unmount } from 'svelte'
|
|
37
|
+
* import type { ComponentProps } from 'svelte'
|
|
38
|
+
* import { Accordion } from '@h-ai/ui'
|
|
39
|
+
* const props: ComponentProps<typeof Accordion> = { items: [{ id: 'intro', title: '简介', content: '操作说明' }], value: 'intro' }
|
|
40
|
+
* const component = mount(Accordion, { target: document.body, props })
|
|
41
|
+
* await unmount(component)
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
20
44
|
interface Props {
|
|
21
45
|
/** 折叠项数据 */
|
|
22
46
|
items: AccordionItem[]
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { DataAttributes } from '../../types.js';
|
|
3
3
|
import type { AccordionItem } from './accordion-types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Accordion 组件的属性契约;通过公开组件配置使用。
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { mount, unmount } from 'svelte'
|
|
10
|
+
* import type { ComponentProps } from 'svelte'
|
|
11
|
+
* import { Accordion } from '@h-ai/ui'
|
|
12
|
+
* const props: ComponentProps<typeof Accordion> = { items: [{ id: 'intro', title: '简介', content: '操作说明' }], value: 'intro' }
|
|
13
|
+
* const component = mount(Accordion, { target: document.body, props })
|
|
14
|
+
* await unmount(component)
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
4
17
|
interface Props {
|
|
5
18
|
/** 折叠项数据 */
|
|
6
19
|
items: AccordionItem[];
|
|
@@ -22,6 +35,27 @@ interface Props {
|
|
|
22
35
|
children?: Snippet<[AccordionItem]>;
|
|
23
36
|
}
|
|
24
37
|
type $$ComponentProps = Props & DataAttributes;
|
|
38
|
+
/**
|
|
39
|
+
* Accordion
|
|
40
|
+
* =============================================================================
|
|
41
|
+
* @h-ai/ui - Accordion 组件
|
|
42
|
+
* =============================================================================
|
|
43
|
+
* 手风琴/折叠面板组件,支持单选/多选模式、多种样式变体
|
|
44
|
+
*
|
|
45
|
+
* 使用 Svelte 5 Runes ($props, $state, $derived)
|
|
46
|
+
* 使用 DaisyUI collapse 类
|
|
47
|
+
* =============================================================================
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* import { mount, unmount } from 'svelte'
|
|
52
|
+
* import type { ComponentProps } from 'svelte'
|
|
53
|
+
* import { Accordion } from '@h-ai/ui'
|
|
54
|
+
* const props: ComponentProps<typeof Accordion> = { items: [{ id: 'intro', title: '简介', content: '操作说明' }], value: 'intro' }
|
|
55
|
+
* const component = mount(Accordion, { target: document.body, props })
|
|
56
|
+
* await unmount(component)
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
25
59
|
declare const Accordion: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
26
60
|
type Accordion = ReturnType<typeof Accordion>;
|
|
27
61
|
export default Accordion;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<!--
|
|
2
|
+
@component ActionSheet
|
|
2
3
|
@h-ai/ui — ActionSheet(底部操作菜单)
|
|
3
4
|
|
|
4
5
|
用法:
|
|
@@ -11,6 +12,16 @@
|
|
|
11
12
|
onselect={(id) => handleAction(id)}
|
|
12
13
|
onclose={() => showActions = false}
|
|
13
14
|
/>
|
|
15
|
+
|
|
16
|
+
@example
|
|
17
|
+
```ts
|
|
18
|
+
import { mount, unmount } from 'svelte'
|
|
19
|
+
import type { ComponentProps } from 'svelte'
|
|
20
|
+
import { ActionSheet } from '@h-ai/ui'
|
|
21
|
+
const props: ComponentProps<typeof ActionSheet> = { open: true, items: [{ id: 'remove', label: '删除', destructive: true }] }
|
|
22
|
+
const component = mount(ActionSheet, { target: document.body, props })
|
|
23
|
+
await unmount(component)
|
|
24
|
+
```
|
|
14
25
|
-->
|
|
15
26
|
<script lang='ts'>
|
|
16
27
|
import type { DataAttributes } from '../../types.js'
|
|
@@ -20,6 +31,19 @@
|
|
|
20
31
|
// eslint-disable-next-line no-import-assign -- type re-export
|
|
21
32
|
export type { ActionSheetItem }
|
|
22
33
|
|
|
34
|
+
/**
|
|
35
|
+
* ActionSheet 组件的属性契约;通过公开组件配置使用。
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { mount, unmount } from 'svelte'
|
|
40
|
+
* import type { ComponentProps } from 'svelte'
|
|
41
|
+
* import { ActionSheet } from '@h-ai/ui'
|
|
42
|
+
* const props: ComponentProps<typeof ActionSheet> = { open: true, items: [{ id: 'remove', label: '删除', destructive: true }] }
|
|
43
|
+
* const component = mount(ActionSheet, { target: document.body, props })
|
|
44
|
+
* await unmount(component)
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
23
47
|
interface Props {
|
|
24
48
|
/** 是否显示 */
|
|
25
49
|
open?: boolean
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import type { DataAttributes } from '../../types.js';
|
|
2
2
|
import type { ActionSheetItem } from './action-sheet-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* ActionSheet 组件的属性契约;通过公开组件配置使用。
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { mount, unmount } from 'svelte'
|
|
9
|
+
* import type { ComponentProps } from 'svelte'
|
|
10
|
+
* import { ActionSheet } from '@h-ai/ui'
|
|
11
|
+
* const props: ComponentProps<typeof ActionSheet> = { open: true, items: [{ id: 'remove', label: '删除', destructive: true }] }
|
|
12
|
+
* const component = mount(ActionSheet, { target: document.body, props })
|
|
13
|
+
* await unmount(component)
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
3
16
|
interface Props {
|
|
4
17
|
/** 是否显示 */
|
|
5
18
|
open?: boolean;
|
|
@@ -17,6 +30,31 @@ interface Props {
|
|
|
17
30
|
class?: string;
|
|
18
31
|
}
|
|
19
32
|
type $$ComponentProps = Props & DataAttributes;
|
|
33
|
+
/**
|
|
34
|
+
* ActionSheet
|
|
35
|
+
* @h-ai/ui — ActionSheet(底部操作菜单)
|
|
36
|
+
*
|
|
37
|
+
* 用法:
|
|
38
|
+
* <ActionSheet
|
|
39
|
+
* open={showActions}
|
|
40
|
+
* items={[
|
|
41
|
+
* { id: 'edit', label: '编辑' },
|
|
42
|
+
* { id: 'delete', label: '删除', destructive: true },
|
|
43
|
+
* ]}
|
|
44
|
+
* onselect={(id) => handleAction(id)}
|
|
45
|
+
* onclose={() => showActions = false}
|
|
46
|
+
* />
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { mount, unmount } from 'svelte'
|
|
51
|
+
* import type { ComponentProps } from 'svelte'
|
|
52
|
+
* import { ActionSheet } from '@h-ai/ui'
|
|
53
|
+
* const props: ComponentProps<typeof ActionSheet> = { open: true, items: [{ id: 'remove', label: '删除', destructive: true }] }
|
|
54
|
+
* const component = mount(ActionSheet, { target: document.body, props })
|
|
55
|
+
* await unmount(component)
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
20
58
|
declare const ActionSheet: import("svelte").Component<$$ComponentProps, {
|
|
21
59
|
ActionSheetItem: typeof ActionSheetItem;
|
|
22
60
|
}, "">;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component Alert
|
|
3
3
|
警告框组件,使用 tabler icon 替代 emoji,更精致。
|
|
4
|
+
|
|
5
|
+
@example
|
|
6
|
+
```ts
|
|
7
|
+
import { mount, unmount, createRawSnippet } from 'svelte'
|
|
8
|
+
import type { ComponentProps } from 'svelte'
|
|
9
|
+
import { Alert } from '@h-ai/ui'
|
|
10
|
+
const props: ComponentProps<typeof Alert> = { title: '保存成功', variant: 'success', children: createRawSnippet(() => ({ render: () => "<span>操作已经完成。</span>" })) }
|
|
11
|
+
const component = mount(Alert, { target: document.body, props })
|
|
12
|
+
await unmount(component)
|
|
13
|
+
```
|
|
4
14
|
-->
|
|
5
15
|
<script lang='ts'>
|
|
6
16
|
import type { AlertProps, DataAttributes } from '../../types.js'
|
|
@@ -24,6 +34,7 @@
|
|
|
24
34
|
const alertClass = $derived(
|
|
25
35
|
cn(
|
|
26
36
|
'alert',
|
|
37
|
+
'flex items-start gap-3',
|
|
27
38
|
getAlertVariantClass(variant),
|
|
28
39
|
className,
|
|
29
40
|
),
|
|
@@ -45,21 +56,21 @@
|
|
|
45
56
|
|
|
46
57
|
{#if visible}
|
|
47
58
|
<div {...dataAttributes} class={alertClass} role='alert'>
|
|
48
|
-
<span class='{iconMap[variant] ?? iconMap.info} size-5 shrink-0'></span>
|
|
59
|
+
<span class='{iconMap[variant] ?? iconMap.info} mt-0.5 size-5 shrink-0' aria-hidden='true'></span>
|
|
49
60
|
|
|
50
|
-
<div>
|
|
61
|
+
<div class='min-w-0 flex-1 [overflow-wrap:anywhere]'>
|
|
51
62
|
{#if title}
|
|
52
63
|
<h3 class='font-semibold text-sm'>{title}</h3>
|
|
53
64
|
{/if}
|
|
54
65
|
{#if children}
|
|
55
|
-
<div class='text-sm'>
|
|
66
|
+
<div class='text-sm leading-relaxed'>
|
|
56
67
|
{@render children()}
|
|
57
68
|
</div>
|
|
58
69
|
{/if}
|
|
59
70
|
</div>
|
|
60
71
|
|
|
61
72
|
{#if dismissible}
|
|
62
|
-
<IconButton size='sm' variant='ghost' label={uiM('common_close')} onclick={handleClose}>
|
|
73
|
+
<IconButton size='sm' variant='ghost' class='shrink-0' label={uiM('common_close')} onclick={handleClose}>
|
|
63
74
|
<span class='icon-[tabler--x] size-4'></span>
|
|
64
75
|
</IconButton>
|
|
65
76
|
{/if}
|