@h-ai/ui 1.0.0-beta.2 → 1.0.0-beta.20
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 +228 -70
- package/README.ja.md +227 -69
- package/README.md +229 -72
- package/auto-import.d.ts +4 -0
- package/auto-import.js +241 -65
- package/dist/components/compounds/Accordion.svelte +6 -2
- package/dist/components/compounds/BottomNav.svelte +14 -2
- package/dist/components/compounds/Card.svelte +3 -1
- package/dist/components/compounds/Combobox.svelte +41 -5
- package/dist/components/compounds/DataTable.svelte +28 -8
- package/dist/components/compounds/DatePicker.svelte +6 -1
- package/dist/components/compounds/Drawer.svelte +12 -4
- package/dist/components/compounds/Dropdown.svelte +135 -59
- package/dist/components/compounds/Empty.svelte +10 -2
- package/dist/components/compounds/FormField.svelte +10 -2
- package/dist/components/compounds/JsonViewer.svelte +18 -6
- package/dist/components/compounds/Modal.svelte +8 -2
- package/dist/components/compounds/Pagination.svelte +22 -7
- package/dist/components/compounds/Popover.svelte +93 -12
- package/dist/components/compounds/Steps.svelte +24 -8
- package/dist/components/compounds/SwipeCell.svelte +3 -1
- package/dist/components/compounds/TableToolbar.svelte +32 -9
- package/dist/components/compounds/Tabs.svelte +25 -5
- package/dist/components/compounds/TagInput.svelte +2 -0
- package/dist/components/compounds/Timeline.svelte +6 -2
- package/dist/components/compounds/ToastContainer.svelte +41 -10
- package/dist/components/compounds/Tooltip.svelte +1 -1
- package/dist/components/compounds/Tooltip.svelte.d.ts +1 -1
- package/dist/components/control-size.js +48 -8
- package/dist/components/primitives/Avatar.svelte +9 -3
- package/dist/components/primitives/BareInput.svelte +3 -1
- package/dist/components/primitives/Button.svelte +6 -2
- package/dist/components/primitives/Checkbox.svelte +5 -0
- package/dist/components/primitives/IconButton.svelte +3 -1
- package/dist/components/primitives/Input.svelte +19 -3
- package/dist/components/primitives/Radio.svelte +4 -1
- package/dist/components/primitives/Range.svelte +3 -1
- package/dist/components/primitives/Rating.svelte +9 -3
- package/dist/components/primitives/Select.svelte +21 -5
- package/dist/components/primitives/Tag.svelte +6 -10
- package/dist/components/primitives/Textarea.svelte +14 -2
- package/dist/components/scenes/ai/AiDocumentEditor.svelte +40 -12
- package/dist/components/scenes/ai/document-download.js +6 -2
- package/dist/components/scenes/ai/document-parse.js +24 -8
- package/dist/components/scenes/ai/editor-markdown-extensions.js +9 -3
- package/dist/components/scenes/ai/highlight.js +18 -1
- package/dist/components/scenes/ai/markdown-parse.js +81 -28
- package/dist/components/scenes/ai/mermaid-render.js +13 -1
- package/dist/components/scenes/ai/safe-html.js +9 -3
- package/dist/components/scenes/ai/table/AiTableEditor.svelte +27 -9
- package/dist/components/scenes/app/FeedbackDetail.svelte +102 -24
- package/dist/components/scenes/app/FeedbackForm.svelte +70 -16
- package/dist/components/scenes/app/FeedbackList.svelte +138 -21
- package/dist/components/scenes/app/FeedbackRecorder.svelte +18 -5
- package/dist/components/scenes/app/FeedbackReplay.svelte +15 -3
- package/dist/components/scenes/app/FeedbackScreenshot.svelte +64 -13
- package/dist/components/scenes/app/LanguageSwitch.svelte +6 -2
- package/dist/components/scenes/app/SettingsLayout.svelte +3 -1
- package/dist/components/scenes/app/ThemeSelector.svelte +29 -5
- package/dist/components/scenes/app/ThemeToggle.svelte +6 -2
- package/dist/components/scenes/app/WorkspaceLayout.svelte +1 -1
- package/dist/components/scenes/app/feedback-functions.js +6 -2
- package/dist/components/scenes/charts/Chart.svelte +55 -21
- package/dist/components/scenes/charts/Chart.svelte.d.ts +0 -1
- package/dist/components/scenes/charts/ChartLoadError.svelte +13 -0
- package/dist/components/scenes/charts/ChartLoadError.svelte.d.ts +6 -0
- package/dist/components/scenes/charts/DashboardGrid.svelte +34 -0
- package/dist/components/scenes/charts/DashboardGrid.svelte.d.ts +15 -0
- package/dist/components/scenes/charts/MetricCard.svelte +69 -0
- package/dist/components/scenes/charts/MetricCard.svelte.d.ts +15 -0
- package/dist/components/scenes/charts/ReportCard.svelte +48 -0
- package/dist/components/scenes/charts/ReportCard.svelte.d.ts +15 -0
- package/dist/components/scenes/charts/chart-presets.d.ts +15 -0
- package/dist/components/scenes/charts/chart-presets.js +56 -0
- package/dist/components/scenes/charts/chart-types.d.ts +13 -2
- package/dist/components/scenes/charts/dashboard-types.d.ts +79 -0
- package/dist/components/scenes/charts/dashboard-types.js +1 -0
- package/dist/components/scenes/charts/index.d.ts +6 -2
- package/dist/components/scenes/charts/index.js +4 -1
- package/dist/components/scenes/charts/renderers/AreaChart.svelte +1 -0
- package/dist/components/scenes/charts/renderers/AreaChart.svelte.d.ts +1 -0
- package/dist/components/scenes/charts/renderers/BarChart.svelte +1 -0
- package/dist/components/scenes/charts/renderers/BarChart.svelte.d.ts +1 -0
- package/dist/components/scenes/charts/renderers/LineChart.svelte +39 -12
- package/dist/components/scenes/charts/renderers/LineChart.svelte.d.ts +1 -0
- package/dist/components/scenes/charts/renderers/PieChart.svelte +1 -0
- package/dist/components/scenes/charts/renderers/PieChart.svelte.d.ts +1 -0
- package/dist/components/scenes/charts/renderers/ScatterChart.svelte +1 -0
- package/dist/components/scenes/charts/renderers/ScatterChart.svelte.d.ts +1 -0
- package/dist/components/scenes/crud/CrudDetailDrawer.svelte +6 -2
- package/dist/components/scenes/crud/CrudDetailPanel.svelte +6 -2
- package/dist/components/scenes/crud/CrudEditPanel.svelte +41 -12
- package/dist/components/scenes/crud/CrudPage.svelte +34 -9
- package/dist/components/scenes/crud/crud-controller.svelte.js +23 -8
- package/dist/components/scenes/crud/crud-form-validation.js +27 -9
- package/dist/components/scenes/crypto/EncryptedInput.svelte +9 -3
- package/dist/components/scenes/error/error-presets.js +30 -5
- package/dist/components/scenes/guide/GuideHostContent.svelte +7 -1
- package/dist/components/scenes/guide/HelpCenter.svelte +23 -4
- package/dist/components/scenes/iam/AgreementNotice.svelte +9 -3
- package/dist/components/scenes/iam/AuthPanel.svelte +74 -16
- package/dist/components/scenes/iam/ChangePasswordForm.svelte +6 -2
- package/dist/components/scenes/iam/ForgotPasswordForm.svelte +9 -3
- package/dist/components/scenes/iam/LoginForm.svelte +32 -8
- package/dist/components/scenes/iam/PasswordInput.svelte +50 -12
- package/dist/components/scenes/iam/RegisterForm.svelte +11 -3
- package/dist/components/scenes/iam/ResetPasswordForm.svelte +6 -2
- package/dist/components/scenes/iam/SensitiveOperationsForm.svelte +3 -1
- package/dist/components/scenes/iam/SessionRecoveryDialog.svelte +4 -1
- package/dist/components/scenes/iam/UserProfile.svelte +41 -14
- package/dist/components/scenes/iam/auth-captcha.js +9 -2
- package/dist/components/scenes/iam/auth-error-message.d.ts +2 -2
- package/dist/components/scenes/iam/auth-error-message.js +16 -3
- package/dist/components/scenes/iam/password-utils.js +9 -2
- package/dist/components/scenes/iam/sensitive-actions.svelte.js +4 -1
- package/dist/components/scenes/storage/FileList.svelte +3 -1
- package/dist/components/scenes/storage/FileUpload.svelte +7 -2
- package/dist/components/scenes/types.d.ts +2 -2
- package/dist/guide-storage.js +12 -4
- package/dist/guide.svelte.js +59 -16
- package/dist/i18n.svelte.js +9 -3
- package/dist/internal/dialog-focus.d.ts +19 -0
- package/dist/internal/dialog-focus.js +104 -4
- package/dist/internal/form-validation.svelte.js +46 -15
- package/dist/internal/icon-safety.js +6 -2
- package/dist/message.svelte.js +6 -2
- package/dist/messagebox.svelte.js +6 -2
- package/dist/messages/en-US.json +7 -1
- package/dist/messages/ja-JP.json +7 -1
- package/dist/messages/zh-CN.json +7 -1
- package/dist/styles/eye-care.css +55 -0
- package/dist/styles/global.css +16 -0
- package/dist/styles/theme.css +1 -0
- package/dist/theme-config.d.ts +1 -1
- package/dist/theme-config.js +136 -21
- package/dist/toast.svelte.js +14 -3
- package/dist/types.d.ts +3 -3
- package/dist/utils.js +6 -2
- package/package.json +19 -19
package/README.en.md
CHANGED
|
@@ -4,21 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
[Framework home](../../README.en.md) · Related modules: [@h-ai/core](../core/README.en.md)
|
|
6
6
|
|
|
7
|
-
## Introduction
|
|
8
|
-
|
|
9
7
|
Built-in messages support `zh-CN`, `en-US` and `ja-JP`; the language selector offers all three by default.
|
|
10
8
|
|
|
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 / ja-JP) and 15 curated DaisyUI themes plus high contrast
|
|
12
|
-
|
|
13
|
-
## Core features
|
|
14
|
-
|
|
15
|
-
- Forms, tables, dialogs, navigation, charts and application components.
|
|
16
|
-
- Authentication, CRUD, AI content, onboarding and a help center.
|
|
17
|
-
- Svelte 5, themes, responsive layouts and Chinese/English/Japanese component messages.
|
|
9
|
+
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 / ja-JP) and 15 curated DaisyUI themes plus high contrast, square business and eye-care themes.
|
|
18
10
|
|
|
19
|
-
|
|
11
|
+
HTTP/UI boundaries expose business messages only for explicit valid 4xx statuses. Missing or invalid `httpStatus` is treated as 500 with a safe message. Custom business errors must carry a complete error definition or an explicit status.
|
|
20
12
|
|
|
21
|
-
##
|
|
13
|
+
## Quick Start
|
|
22
14
|
|
|
23
15
|
### Installation
|
|
24
16
|
|
|
@@ -28,50 +20,45 @@ npm install @h-ai/ui @h-ai/core
|
|
|
28
20
|
|
|
29
21
|
For a Node server, declare both UI and core as production dependencies so the adapter preserves native logging and runtime dependencies.
|
|
30
22
|
|
|
31
|
-
###
|
|
32
|
-
|
|
33
|
-
#### 1. Configure svelte.config.js
|
|
23
|
+
### 1. Configure application imports in package.json
|
|
34
24
|
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
|
|
25
|
+
```json
|
|
26
|
+
{ "imports": { "#lib/*": "./src/lib/*" } }
|
|
27
|
+
```
|
|
39
28
|
|
|
40
|
-
|
|
41
|
-
const config = {
|
|
42
|
-
preprocess: [autoImportHaiUi(), vitePreprocess()],
|
|
43
|
-
compilerOptions: { runes: true },
|
|
44
|
-
kit: { adapter: adapter() },
|
|
45
|
-
}
|
|
29
|
+
### 2. Configure vite.config.ts
|
|
46
30
|
|
|
47
|
-
|
|
48
|
-
```
|
|
31
|
+
SvelteKit 3 configures preprocessing, the compiler and the adapter in the Vite plugin; only a plain Svelte/Vite project keeps svelte.config.js.
|
|
49
32
|
|
|
50
|
-
|
|
33
|
+
Run `vitePreprocess()` or other style/template language transforms before `autoImportHaiUi()`. Auto-import reads the complete Svelte AST and does not accept unprocessed SCSS, Pug or other nonstandard syntax. Its direct markup API remains synchronous.
|
|
51
34
|
|
|
52
35
|
```ts
|
|
36
|
+
import { autoImportHaiUi } from '@h-ai/ui/auto-import'
|
|
53
37
|
import { haiOptimizeExclude, haiPrebundledDeps } from '@h-ai/ui/vite'
|
|
38
|
+
import adapter from '@sveltejs/adapter-node'
|
|
54
39
|
import { sveltekit } from '@sveltejs/kit/vite'
|
|
40
|
+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
|
|
55
41
|
import tailwindcss from '@tailwindcss/vite'
|
|
56
42
|
import { defineConfig } from 'vite'
|
|
57
43
|
|
|
58
44
|
export default defineConfig({
|
|
59
|
-
plugins: [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
45
|
+
plugins: [
|
|
46
|
+
sveltekit({
|
|
47
|
+
preprocess: [vitePreprocess(), autoImportHaiUi()],
|
|
48
|
+
compilerOptions: { runes: true },
|
|
49
|
+
adapter: adapter(),
|
|
50
|
+
paths: { relative: false },
|
|
51
|
+
}),
|
|
52
|
+
tailwindcss(),
|
|
53
|
+
],
|
|
54
|
+
optimizeDeps: { exclude: [...haiOptimizeExclude], include: [...haiPrebundledDeps] },
|
|
68
55
|
ssr: { noExternal: ['@h-ai/ui', '@h-ai/kit'], external: ['@h-ai/core', 'sm-crypto'] },
|
|
69
56
|
})
|
|
70
57
|
```
|
|
71
58
|
|
|
72
|
-
|
|
59
|
+
### 3. Configure src/app.css
|
|
73
60
|
|
|
74
|
-
|
|
61
|
+
When using Crypto or Kit/IAM, include `sm-crypto@0.5.8` in application production dependencies. CLI projects already do this; for manual setup, run `pnpm add sm-crypto@0.5.8`. The external option alone is insufficient: adapter-node also uses direct production dependencies to preserve native package loading.
|
|
75
62
|
|
|
76
63
|
```css
|
|
77
64
|
@import 'tailwindcss';
|
|
@@ -92,7 +79,7 @@ When using Crypto or Kit/IAM, include `sm-crypto@0.5.7` in application productio
|
|
|
92
79
|
|
|
93
80
|
> `@source` makes TailwindCSS scan classes in `@h-ai/ui`; without it, component styles are missing. In nested monorepo apps, dependencies may be hoisted to root `node_modules`, so retain both paths.
|
|
94
81
|
|
|
95
|
-
|
|
82
|
+
### 4. Use components
|
|
96
83
|
|
|
97
84
|
```svelte
|
|
98
85
|
<script>
|
|
@@ -116,7 +103,7 @@ With auto-import enabled, use components directly in templates without individua
|
|
|
116
103
|
|
|
117
104
|
Pages using a subset of components, such as administration screens, can import public component-directory entry points directly. Import theme utilities from the lightweight `@h-ai/ui/theme` entry so theme consumers do not load the root entry's AI and chart components. Use `@h-ai/ui/i18n` for locale utilities in stores without loading components or tour CSS. Check the installed package's exports; do not import its internal `src/` or `dist/` paths.
|
|
118
105
|
|
|
119
|
-
The preprocessor
|
|
106
|
+
The preprocessor imports only components actually used in the template AST; examples in comments, textarea content and script strings do not trigger imports. Script declarations and local each, await and snippet bindings take precedence. Real semicolon-free, multiline and aliased imports are recognized through the syntax tree, without duplicating existing runtime bindings. Type-only component bindings from the root `@h-ai/ui` entry are promoted to values when needed. A conflicting type-only import from another module causes a build error naming the file and component; alias the type, or explicitly import the component under another local name.
|
|
120
107
|
|
|
121
108
|
```ts
|
|
122
109
|
import { Card } from '@h-ai/ui/components/compounds/index'
|
|
@@ -124,7 +111,99 @@ import { Button } from '@h-ai/ui/components/primitives/index'
|
|
|
124
111
|
import { getThemeInfo, THEMES } from '@h-ai/ui/theme'
|
|
125
112
|
```
|
|
126
113
|
|
|
127
|
-
|
|
114
|
+
## Features
|
|
115
|
+
|
|
116
|
+
### Purpose, inputs and outputs
|
|
117
|
+
|
|
118
|
+
UI has no init/close. Use these fragments in the application component or browser interaction context. Named variables stand for application-provided requests, schemas, resource definitions or options. Follow the corresponding examples for setup and failure handling. Check HaiResult.success and await asynchronous calls.
|
|
119
|
+
|
|
120
|
+
| Entry | Use case | Input | Output | Call fragment |
|
|
121
|
+
| --- | --- | --- | --- | --- |
|
|
122
|
+
| `autoImportHaiUi` | Auto-import | `preprocessed Svelte source and filename through markup` | `PreprocessorGroup; synchronous { code }` | `autoImportHaiUi()` |
|
|
123
|
+
| `parseMarkdown` | Safe Markdown | `Markdown source, MarkdownParseOptions?` | `HTML string; raw HTML escaped or allowlisted` | `parseMarkdown("# Hello", { allowHtmlTags: false })` |
|
|
124
|
+
| `renderMarkdownDocument` | Editor document model | `Markdown source, MarkdownDocumentParseOptions?` | `MarkdownRenderResult with outline/codeBlocks/blocks` | `renderMarkdownDocument("# Report", { allowHtmlTags: false })` |
|
|
125
|
+
| `isLanguageSupported` | Check highlight language | `language name` | `boolean` | `isLanguageSupported("typescript")` |
|
|
126
|
+
| `highlightCode` | Highlight code | `code text, supported language` | `escaped/highlighted HTML string` | `highlightCode("const total = 1", "typescript")` |
|
|
127
|
+
| `resolveDocumentMarkdownContent` | Fence code content | `text, sourceKind?, language?` | `Markdown string with a safe fence length` | `resolveDocumentMarkdownContent("const x = 1", "code", "ts")` |
|
|
128
|
+
| `resolveDocumentDownloadActions` | Download menu | `MarkdownToolbarDownloadAction[]?` | `AiDocumentResolvedDownloadAction[]` | `resolveDocumentDownloadActions([{ id: "markdown", label: "Markdown" }])` |
|
|
129
|
+
| `downloadAiDocument` | Download selected format | `AiDocumentDownloadRequest` | `Promise<void>; browser failure rejects, SSR does nothing` | `downloadAiDocument({ actionId: "markdown", content: "# Report", filename: "report.md" })` |
|
|
130
|
+
| `createLocaleStore` | Component locale state | `{ defaultLocale?, supportedLocales?, detectBrowser?, persistKey? }` | `locale store with current/set/isSupported` | `createLocaleStore({ defaultLocale: "zh-CN", detectBrowser: false })` |
|
|
131
|
+
| `getGlobalLocale` | Read current locale | `none` | `locale string from current context` | `getGlobalLocale()` |
|
|
132
|
+
| `setGlobalLocale` | Set browser/startup locale | `locale` | `void; use request context for SSR` | `setGlobalLocale("en-US")` |
|
|
133
|
+
| `detectBrowserLocale` | Detect browser locale | `supportedLocales?` | `supported locale or null` | `detectBrowserLocale()` |
|
|
134
|
+
| `isLocaleSupported` | Check supported locale | `locale, supportedLocales?` | `boolean` | `isLocaleSupported("ja-JP")` |
|
|
135
|
+
| `resolveLocale` | Normalize locale | `locale, supportedLocales?, fallback?` | `supported locale` | `resolveLocale("en")` |
|
|
136
|
+
| `interpolate` | Interpolate message | `template string, InterpolationParams` | `string` | `interpolate("Hello {name}", { name: "Ada" })` |
|
|
137
|
+
| `getThemeInfo` | Theme metadata | `theme ID` | `ThemeInfo or undefined` | `getThemeInfo("light")` |
|
|
138
|
+
| `isDarkTheme` | Dark theme check | `theme ID` | `boolean` | `isDarkTheme("dark")` |
|
|
139
|
+
| `normalizeThemeId` | Normalize theme | `candidate theme ID, fallback?` | `supported theme ID` | `normalizeThemeId("unknown", "light")` |
|
|
140
|
+
| `normalizeHexColor` | Normalize color | `string or null/undefined` | `six-digit lowercase hex string or null` | `normalizeHexColor("#5765F0")` |
|
|
141
|
+
| `resolveThemeTone` | Theme tone | `theme ID` | `light or dark` | `resolveThemeTone("light")` |
|
|
142
|
+
| `createThemeBootstrapScript` | Bootstrap theme | `ThemeBootstrapScriptOptions from trusted host config` | `script string for the application HTML shell` | `createThemeBootstrapScript({ storageKey: "theme", defaultThemeId: "light" })` |
|
|
143
|
+
| `getThemeInitScript` | Default theme bootstrap | `none` | `script string` | `getThemeInitScript()` |
|
|
144
|
+
| `applyTheme` | Apply theme | `theme ID, persist? (default true)` | `void; updates DOM/browser preference` | `applyTheme("dark")` |
|
|
145
|
+
| `getCurrentTheme` | Current theme | `none` | `theme ID string` | `getCurrentTheme()` |
|
|
146
|
+
| `getSavedTheme` | Saved theme | `fallback theme ID?` | `theme ID string` | `getSavedTheme("light")` |
|
|
147
|
+
| `createGuide` | Guide controller | `GuideOptions: tours, articles?, nav?, persistence?, persistKey?` | `GuideController; no init/close` | `createGuide({ tours: [], persistence: "memory" })` |
|
|
148
|
+
| `resolveGuideText` | Resolve guide text | `string or translation callback?` | `string` | `resolveGuideText(() => m.help())` |
|
|
149
|
+
| `matchPermission` | Permission visibility | `required permission, userPermissions[]` | `boolean; not server authorization` | `matchPermission("orders:read", ["orders:*"])` |
|
|
150
|
+
| `setPermissionContext` | Provide permission context | `() => current permissions; component initialization only` | `void` | `setPermissionContext(() => user.permissions)` |
|
|
151
|
+
| `usePermission` | Consume permissions | `none; component initialization only` | `PermissionContext with hasPerm/hasAnyPerm/hasAllPerms` | `usePermission()` |
|
|
152
|
+
| `createSensitiveActions` | Sensitive confirmation | `standard auth actions providing reauthenticate/publicConfig?` | `SensitiveActions: configure/authorize/submit/cancel` | `createSensitiveActions(actions)` |
|
|
153
|
+
| `createSessionRecovery` | In-place session recovery | `none; configure public config and current user afterward` | `SessionRecovery controller` | `createSessionRecovery()` |
|
|
154
|
+
| `defineCrud` | Define CRUD | `CrudResource with fields/API callbacks` | `CrudDef for CrudPage` | `defineCrud(resourceDefinition)` |
|
|
155
|
+
| `createCrudController` | Manage list state | `CrudDef, { autoLoad? }?` | `controller data/nav/loading/loaded/error/load/reload` | `createCrudController(crud, { autoLoad: false })` |
|
|
156
|
+
| `mapPaginated` | Map paginated items | `PaginatedResult<T>, (item,index) => R` | `PaginatedResult<R> retaining total/page/pageSize` | `mapPaginated(page, item => ({ ...item, selected: false }))` |
|
|
157
|
+
| `createBrowserNavAdapter` | Browser navigation | `none` | `NavAdapter` | `createBrowserNavAdapter()` |
|
|
158
|
+
| `registerClipboardHostWriter` | Register host clipboard | `async text => boolean or null to unregister` | `void` | `registerClipboardHostWriter(null)` |
|
|
159
|
+
| `writeTextToClipboard` | Copy and check result | `text: string` | `Promise<boolean>; true only when write succeeds` | `writeTextToClipboard("trace-001")` |
|
|
160
|
+
| `cn` | Combine classes | `...string\|boolean\|null\|undefined values` | `string` | `cn("flex", active && "text-primary")` |
|
|
161
|
+
| `getDataAttributes` | Forward data attributes | `props record` | `ForwardedDataAttributes` | `getDataAttributes({ "data-testid": "save" })` |
|
|
162
|
+
| `generateId` | UI identifier | `prefix?; not a security token generator` | `string` | `generateId("field")` |
|
|
163
|
+
| `portal` | Portal a node | `HTMLElement, target HTMLElement or selector?` | `Svelte action result with cleanup` | `portal(node, document.body)` |
|
|
164
|
+
| `detectPlatform` | Detect platform | `none` | `Platform` | `detectPlatform()` |
|
|
165
|
+
| `isMobile` | Check mobile | `none` | `boolean` | `isMobile()` |
|
|
166
|
+
| `isNativeApp` | Check native shell | `none` | `boolean` | `isNativeApp()` |
|
|
167
|
+
| `usePlatform` | Reactive platform view | `none; component initialization` | `{ current, isMobile, isApp }` | `usePlatform()` |
|
|
168
|
+
| `getVariantClass` | Map theme classes | `Variant, prefix?` | `string class name` | `getVariantClass("primary", "btn")` |
|
|
169
|
+
| `getSizeClass` | Map theme classes | `Size, prefix?` | `string class name` | `getSizeClass("sm", "btn")` |
|
|
170
|
+
| `getInputSizeClass` | Map theme classes | `Size` | `string class name` | `getInputSizeClass("sm")` |
|
|
171
|
+
| `getBadgeVariantClass` | Map theme classes | `Variant` | `string class name` | `getBadgeVariantClass("info")` |
|
|
172
|
+
| `getBadgeSizeClass` | Map theme classes | `Size` | `string class name` | `getBadgeSizeClass("sm")` |
|
|
173
|
+
| `getAlertVariantClass` | Map theme classes | `Variant` | `string class name` | `getAlertVariantClass("info")` |
|
|
174
|
+
| `getProgressVariantClass` | Map theme classes | `Variant` | `string class name` | `getProgressVariantClass("primary")` |
|
|
175
|
+
| `useToastFeedback` | Operation feedback | `() => safely localized message, variant?` | `void; source-owned toast lifecycle` | `useToastFeedback(() => errorMessage(error))` |
|
|
176
|
+
| `notifySuccess` | Operation feedback | `localized message, duration?` | `toast ID string` | `notifySuccess(m.saved())` |
|
|
177
|
+
| `notifyInfo` | Operation feedback | `localized message, duration?` | `toast ID string` | `notifyInfo(m.loading())` |
|
|
178
|
+
| `notifyWarning` | Operation feedback | `localized message, duration?` | `toast ID string` | `notifyWarning(m.warning())` |
|
|
179
|
+
| `notifyError` | Operation feedback | `unknown error, safe fallback?, duration?` | `toast ID string; internal exception text hidden` | `notifyError(error, m.retry())` |
|
|
180
|
+
| `errorMessage` | Operation feedback | `unknown error, safe fallback?` | `safe localized string` | `errorMessage(error, m.retry())` |
|
|
181
|
+
| `toast.add` | Shared feedback queue | `localized options/message` | `string item ID` | `toast.add({ message: m.saved(), variant: "success" })` |
|
|
182
|
+
| `toast.success` | Shared feedback queue | `localized safe message, duration?` | `string item ID` | `toast.success(m.result())` |
|
|
183
|
+
| `toast.info` | Shared feedback queue | `localized safe message, duration?` | `string item ID` | `toast.info(m.result())` |
|
|
184
|
+
| `toast.warning` | Shared feedback queue | `localized safe message, duration?` | `string item ID` | `toast.warning(m.result())` |
|
|
185
|
+
| `toast.error` | Shared feedback queue | `localized safe message, duration?` | `string item ID` | `toast.error(m.result())` |
|
|
186
|
+
| `toast.remove` | Shared feedback queue | `item ID` | `void` | `toast.remove(id)` |
|
|
187
|
+
| `toast.clear` | Shared feedback queue | `none` | `void` | `toast.clear()` |
|
|
188
|
+
| `message.add` | Shared feedback queue | `localized options/message` | `string item ID` | `message.add({ message: m.saved(), type: "success" })` |
|
|
189
|
+
| `message.success` | Shared feedback queue | `localized safe message, duration?` | `string item ID` | `message.success(m.result())` |
|
|
190
|
+
| `message.info` | Shared feedback queue | `localized safe message, duration?` | `string item ID` | `message.info(m.result())` |
|
|
191
|
+
| `message.warning` | Shared feedback queue | `localized safe message, duration?` | `string item ID` | `message.warning(m.result())` |
|
|
192
|
+
| `message.error` | Shared feedback queue | `localized safe message, duration?` | `string item ID` | `message.error(m.result())` |
|
|
193
|
+
| `message.remove` | Shared feedback queue | `item ID` | `void` | `message.remove(id)` |
|
|
194
|
+
| `message.clear` | Shared feedback queue | `none` | `void` | `message.clear()` |
|
|
195
|
+
| `toast.pause` | Toast timing | `toast ID` | `void` | `toast.pause(id)` |
|
|
196
|
+
| `toast.resume` | Toast timing | `toast ID` | `void` | `toast.resume(id)` |
|
|
197
|
+
| `messageBox.confirm` | Async confirmation | `localized string or MessageBoxOptions` | `Promise<boolean>; host handles confirmation/cancellation` | `messageBox.confirm({ message: m.confirm() })` |
|
|
198
|
+
| `messageBox.alert` | Async confirmation | `localized string or MessageBoxOptions` | `Promise<boolean>; host handles confirmation/cancellation` | `messageBox.alert({ message: m.confirm() })` |
|
|
199
|
+
|
|
200
|
+
- Forms, tables, dialogs, navigation, charts and application components.
|
|
201
|
+
- Authentication, CRUD, AI content, onboarding and a help center.
|
|
202
|
+
- Svelte 5, themes, responsive layouts and Chinese/English/Japanese component messages.
|
|
203
|
+
|
|
204
|
+
Markdown underline and highlight markers support escaping; unclosed markers remain text. Toasts and document downloads handle unusually long text without repeated scanning, while trace identifiers remain hidden by default.
|
|
205
|
+
|
|
206
|
+
### data-\* attribute forwarding
|
|
128
207
|
|
|
129
208
|
Public Svelte components forward caller-supplied `data-*` attributes to their root or primary interactive element for tests, analytics, and automation. Other unknown attributes are not forwarded.
|
|
130
209
|
|
|
@@ -136,6 +215,32 @@ Public Svelte components forward caller-supplied `data-*` attributes to their ro
|
|
|
136
215
|
|
|
137
216
|
No extra button, input, or overlay wrappers are needed just for `data-testid`.
|
|
138
217
|
|
|
218
|
+
### Component-family inputs, events and outputs
|
|
219
|
+
|
|
220
|
+
These families cover the interaction categories in the component catalog. Supply application-owned m, rows, user, controllers and callbacks. Display components render DOM; interactive components report through bindings/callbacks and do not grant server authorization. See Examples, catalog notes and the UI skill for complete compositions. Exported Props types constrain further options.
|
|
221
|
+
|
|
222
|
+
| Component family | Input | Output/events | Example fragment |
|
|
223
|
+
| --- | --- | --- | --- |
|
|
224
|
+
| Button / IconButton / BareButton | variant, size, loading, disabled; icon/snippet; onclick | click event; loading/disabled block repeated action | `<Button loading={saving} onclick={save}>{m.save()}</Button>` |
|
|
225
|
+
| Input / BareInput / Textarea / PasswordInput | type, value, label/validation props | bind:value; input/change/focus events; file input exposes FileList | `<Input bind:value={draft} required />` |
|
|
226
|
+
| Select / Radio / Range / Rating / Combobox | options or min/max/step, current value | bound selected value and selection callbacks | `<Select options={options} bind:value={selected} />` |
|
|
227
|
+
| Checkbox / Switch / ToggleCheckbox / ToggleInput / ToggleRadio | checked/name/label, disabled | bind:checked and change events | `<Checkbox bind:checked={enabled} label={m.enabled()} />` |
|
|
228
|
+
| Form / FormLayout / FormField / TagInput | columns, labels, error/hint, tags, submit callback | validated submit event, tag changes, accessible field association | `<Form onsubmit={save}><FormField label={m.name()}><Input bind:value={name} /></FormField></Form>` |
|
|
229
|
+
| Modal / Drawer / Popover / Dropdown / Tooltip / Calendar | open, trigger/content snippets, dimensions, selected value | bound open/selection; focus handling and close actions | `<Modal bind:open={open} title={m.details()}>{m.content()}</Modal>` |
|
|
230
|
+
| DataTable / TableToolbar / Pagination / FilterBar | rows, columns, total/page, draft search/filter, loading | row/sort/page/query callbacks; host performs the request | `<DataTable {columns} data={rows} sortKey={sortKey} sortDir={sortDir} onsort={sortRows} />` |
|
|
231
|
+
| Tabs / Breadcrumb / Steps / BottomNav / AppBar | items/current key, links, titles and action snippets | selected key/navigation callbacks; host owns routing | `<Tabs {items} bind:active={activeTab} />` |
|
|
232
|
+
| Alert / Badge / Avatar / Tag / Spinner / Progress / Skeleton / Empty / Result | status/variant/value/text/image and state props | presentational DOM; tag/alert close callbacks when enabled | `<Progress value={completed} max={total} />` |
|
|
233
|
+
| WorkspaceLayout / PageHeader / SettingsLayout / SettingsModal | title, sections, active key, leading/actions/footer/children | layout DOM; selection/open callbacks; no business writes | `<WorkspaceLayout title={m.title()}>{m.content()}</WorkspaceLayout>` |
|
|
234
|
+
| FileUpload / ImageUpload / AvatarUpload / FileList | accept/size limits, File values, uploadHandler, files | selected files/progress/result URL and delete/download callbacks | `<ImageUpload bind:value={imageUrl} uploadHandler={uploadImage} />` |
|
|
235
|
+
| AuthPanel / AuthShell / LoginForm / RegisterForm / password forms / PermGuard | public IAM config, standard actions, errors, permission context | authenticated/submit/reset callbacks; server still authorizes | `<AuthPanel {config} {actions} />` |
|
|
236
|
+
| UserProfile / SensitiveOperationsForm / ReauthenticationDialog / SessionRecoveryDialog | profile or operations, async submit, current controller/state | UserProfile closes only on true; other confirmations report explicit completion | `<UserProfile {user} editable onsubmit={saveProfile} />` |
|
|
237
|
+
| CrudPage / CrudFilterBar / CrudEditPanel / CrudDetailPanel / CrudDeleteConfirm | CrudDef, data/nav, loading/error/permissions, API callbacks | resource-bound query/edit/delete callbacks; server enforces resource access | `<CrudPage {crud} data={controller.data} nav={controller.nav} />` |
|
|
238
|
+
| MarkdownRenderer / AiDocumentEditor / AiTableEditor / AiDocumentDownloadMenu | content or columns/rows, action callbacks, safe HTML options | Markdown HTML, content/cell changes and explicit download/run requests | `<MarkdownRenderer content={markdown} allowHtmlTags={false} />` |
|
|
239
|
+
| EncryptedInput / HashDisplay / SignatureDisplay | plaintext/hash/signature, algorithm label, real onencrypt callback | display DOM; bound encryptedValue only after current request succeeds | `<EncryptedInput bind:value={plain} bind:encryptedValue={cipher} onencrypt={encrypt} />` |
|
|
240
|
+
| FeedbackModal / FeedbackForm / FeedbackList / FeedbackDetail / FeedbackScreenshot | prepared evidence, attachments, rows/report, permissions and actions | submission/query/status/export/retry/annotation callbacks | `<FeedbackForm attachments={attachments} onsubmit={submitFeedback} />` |
|
|
241
|
+
| Chart / DashboardGrid / MetricCard / ReportCard | chart data/preset and raw chart props; metrics and loading state | rendered chart/dashboard; native chart callbacks pass through | `<MetricCard title={m.revenue()} value={revenue} trend={growth} />` |
|
|
242
|
+
| GuideHost / HelpCenter | GuideController, locale/scope, articles/tours | onboarding/help UI; start/close callbacks and nonsensitive preferences | `<GuideHost {guide} scope={user.id} locale={locale} />` |
|
|
243
|
+
|
|
139
244
|
### Component architecture
|
|
140
245
|
|
|
141
246
|
Three layers (primitives → compounds → scenes):
|
|
@@ -155,7 +260,7 @@ components/
|
|
|
155
260
|
|
|
156
261
|
### Component catalog
|
|
157
262
|
|
|
158
|
-
#### Primitives
|
|
263
|
+
#### Primitives
|
|
159
264
|
|
|
160
265
|
| Component | Description | Key props |
|
|
161
266
|
| ---------------- | ------------------- | ------------------------------------------------------------------------------ |
|
|
@@ -180,9 +285,11 @@ components/
|
|
|
180
285
|
| `Spinner` | Loading animation | `size`, `variant` |
|
|
181
286
|
| `Progress` | Progress bar | `value`, `max`, `variant`, `striped`, `animated` |
|
|
182
287
|
|
|
288
|
+
`Checkbox`, `Switch` and `Radio` default to the theme primary color, and their checked states follow the current DaisyUI theme; `Checkbox` colors can be overridden with a `checkbox-*` class.
|
|
289
|
+
|
|
183
290
|
For `BareInput` with `type="file"`, read `event.currentTarget.files` in `onchange` and leave the file path `value` unbound. Other input types support `bind:value`.
|
|
184
291
|
|
|
185
|
-
#### Compounds
|
|
292
|
+
#### Compounds
|
|
186
293
|
|
|
187
294
|
##### Forms
|
|
188
295
|
|
|
@@ -209,6 +316,8 @@ Text controls validate on blur after input and update errors as input is correct
|
|
|
209
316
|
|
|
210
317
|
`UserProfile.fieldConstraints` accepts per-field `required`, `minlength`, `maxlength`, `pattern` and `validationMessage` (`pattern` applies to single-line inputs), so application rules such as username formats share blur validation. `validationMessage` also accepts a deferred translation function.
|
|
211
318
|
|
|
319
|
+
`UserProfile.onsubmit` must return `true` to confirm a successful save, or `false` to keep the editor and draft. Thrown errors also keep editing open and use the shared Toast feedback. Cancel restores the saved values from `user`.
|
|
320
|
+
|
|
212
321
|
`CrudEditPanel.onsubmit` receives only writable fields declared by the form. Fields marked `readonly` are omitted when editing and remain available when creating. Primary keys, related display values and audit timestamps are not copied from the entire row. Null values, `false` and `0` are preserved. Keep strict schema validation on the server.
|
|
213
322
|
|
|
214
323
|
`LoginForm`, `RegisterForm`, `ChangePasswordForm`, `ForgotPasswordForm`, `ResetPasswordForm`, `AuthPanel`, `UserProfile` and `FeedbackModal` accept the same layout options. Pass them through `CrudPage.form` or directly to `CrudEditPanel`. CRUD fields support `colSpan` and deferred `validation.message`. Buttons and Enter both validate before submission; corrections clear errors. Server validation remains required.
|
|
@@ -242,6 +351,10 @@ Text controls validate on blur after input and update errors as input is correct
|
|
|
242
351
|
| `Confirm` | Confirmation dialog | `open`, `title`, `message`, `variant`, `onconfirm` |
|
|
243
352
|
| `Popover` | Popover | `open`, `position`, `trigger`, `offset`, `portal` |
|
|
244
353
|
|
|
354
|
+
`Popover` renders in `body` by default. In `click` mode, Enter or Space opens the panel and moves focus into it. Escape closes the panel and returns focus to the trigger. Use `portal={false}` to render inline.
|
|
355
|
+
|
|
356
|
+
Inside a Modal or Drawer, portal controls participate in the owning dialog's Tab and Shift+Tab order. Closing the Popover removes that registration and restores focus to its trigger.
|
|
357
|
+
|
|
245
358
|
##### Data display
|
|
246
359
|
|
|
247
360
|
| Component | Description | Key props |
|
|
@@ -283,7 +396,9 @@ Text controls validate on blur after input and update errors as input is correct
|
|
|
283
396
|
| `Breadcrumb` | Breadcrumbs | `items`, `separator` |
|
|
284
397
|
| `Steps` | Steps | `items`, `current`, `direction`, `clickable` |
|
|
285
398
|
| `Dropdown` | Dropdown menu | `items`, `trigger`, `triggerClass`, `position` |
|
|
286
|
-
| `Tooltip` | Tooltip | `content`, `position`, `delay` |
|
|
399
|
+
| `Tooltip` | Tooltip | `content`, `position`, `delay`, `portal` (use inside overflow-clipped containers) |
|
|
400
|
+
|
|
401
|
+
`Dropdown` renders the menu in `body` in `click` and `hover` modes. In `manual` mode, toggle `dropdown-open` through `class` to control the inline menu.
|
|
287
402
|
|
|
288
403
|
##### State placeholders
|
|
289
404
|
|
|
@@ -299,16 +414,16 @@ Text controls validate on blur after input and update errors as input is correct
|
|
|
299
414
|
| ------------ | ----------- | ----------------------------------------------- |
|
|
300
415
|
| `PageHeader` | Page header | `title`, `description`; supports `actions` slot |
|
|
301
416
|
|
|
302
|
-
#### Scenes
|
|
417
|
+
#### Scenes
|
|
303
418
|
|
|
304
|
-
##### Guide
|
|
419
|
+
##### Guide
|
|
305
420
|
|
|
306
421
|
| Component | Description | Key props |
|
|
307
422
|
| --- | --- | --- |
|
|
308
423
|
| `GuideHost` | First-use invitations, tours and help dialog host | `guide`, `locale`, `scope`, `autoStart` |
|
|
309
424
|
| `HelpCenter` | Standalone searchable help center | `articles`, `tours`, `locale`, `selectedId`, `onstart` |
|
|
310
425
|
|
|
311
|
-
##### App
|
|
426
|
+
##### App
|
|
312
427
|
|
|
313
428
|
| Component | Description | Key props |
|
|
314
429
|
| ------------------ | ---------------------------------------------- | -------------------------------------------------------- |
|
|
@@ -328,7 +443,7 @@ Pass the type: webhook task from report jobs into FeedbackDetail.webhook to show
|
|
|
328
443
|
|
|
329
444
|
Descriptions are optional. Call `prepare()` from `@h-ai/feedback/client` before opening the modal. Connect `onfileschange` to attachment preparation and `onannotate` to image editing that burns annotations into the pixels. Failed submissions retain input and support local export. The list shows the description or server summary and requests pages through `onquerychange`; UI permissions do not replace server authorization. See the [feedback module](../feedback/README.en.md) for integration and offline tools.
|
|
330
445
|
|
|
331
|
-
##### IAM authentication
|
|
446
|
+
##### IAM authentication
|
|
332
447
|
|
|
333
448
|
| Component | Description | Key props |
|
|
334
449
|
| -------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------ |
|
|
@@ -346,7 +461,7 @@ Descriptions are optional. Call `prepare()` from `@h-ai/feedback/client` before
|
|
|
346
461
|
| `SessionRecoveryDialog` | In-place session recovery | `recovery`, `actions` |
|
|
347
462
|
| `SensitiveOperationsForm` | Permission operation editor | `operations`, `onsubmit`, `ondone` |
|
|
348
463
|
|
|
349
|
-
##### Storage
|
|
464
|
+
##### Storage
|
|
350
465
|
|
|
351
466
|
| Component | Description | Key props |
|
|
352
467
|
| -------------- | ------------- | ------------------------------------------------------------ |
|
|
@@ -357,7 +472,7 @@ Descriptions are optional. Call `prepare()` from `@h-ai/feedback/client` before
|
|
|
357
472
|
|
|
358
473
|
Upload components do not embed presigning, headers, or PUT/POST protocols. Applications call their service through `uploadHandler(file, { signal, onProgress })` and return `{ url?, response? }`. Image/avatar uploads require a displayable `url`. Without a handler, `FileUpload` only selects files, and image/avatar components generate local previews only.
|
|
359
474
|
|
|
360
|
-
##### Crypto display
|
|
475
|
+
##### Crypto display
|
|
361
476
|
|
|
362
477
|
Input changes immediately clear `encryptedValue`; only successful results for current input are restored. Clearing, callback replacement, and unmounting invalidate old requests. Failures show built-in errors and leave ciphertext empty. Submit encrypted inputs only when current ciphertext is nonempty.
|
|
363
478
|
|
|
@@ -371,7 +486,7 @@ Callers must connect `EncryptedInput` to a real encryption service through `onen
|
|
|
371
486
|
|
|
372
487
|
Defaults match `@h-ai/crypto`: `SM4` for encrypted inputs, `SM3` for hashes, and `SM2` for signatures.
|
|
373
488
|
|
|
374
|
-
##### AI documents and spreadsheets
|
|
489
|
+
##### AI documents and spreadsheets
|
|
375
490
|
|
|
376
491
|
| Component | Description | Key props / capabilities |
|
|
377
492
|
| ------------------------ | ---------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
@@ -389,6 +504,7 @@ Defaults match `@h-ai/crypto`: `SM4` for encrypted inputs, `SM3` for hashes, and
|
|
|
389
504
|
> - `fontSize` accepts a `number` in px or any CSS length such as `1.125rem`.
|
|
390
505
|
> - `allowHtmlTags` is off by default; when enabled, tags such as `<b>` / `<i>` / `<u>` / `<mark>` use a safe allowlist, with dangerous tags/attributes still sanitized.
|
|
391
506
|
> - Text entities in safe HTML retain one level of meaning, so quotes, comparison operators and `&` in configuration snippets remain readable. Encoded tags remain text and are never reparsed as markup.
|
|
507
|
+
> - HTML code blocks such as `<pre><code class="language-yaml">` also receive safely rebuilt highlighting and copy buttons. Input styles and events are discarded. Supported languages include YAML, TypeScript, Shell, PowerShell, dotenv, Nginx, Dockerfile and Svelte.
|
|
392
508
|
> - Raw `<img>` tags retain `width` / `height` as positive integer pixel values from 1 to 99999. These reserve space before lazy images load and keep document layout and anchor positions stable. Percentages, negatives, decimals, events, and arbitrary `style` are removed.
|
|
393
509
|
|
|
394
510
|
```svelte
|
|
@@ -406,6 +522,26 @@ Defaults match `@h-ai/crypto`: `SM4` for encrypted inputs, `SM3` for hashes, and
|
|
|
406
522
|
|
|
407
523
|
##### Charts
|
|
408
524
|
|
|
525
|
+
Lightweight dashboards use `MetricCard` (value, unit and percentage change), `ReportCard` (heading, actions, content, loading/empty states), and `DashboardGrid` (one, two or more columns based on container width). MetricCard alone does not load a chart engine. `trend={12.8}` means +12.8%; `trendTone` expresses business meaning independently, so a decrease can be success. Missing and non-finite values show “—”; zero remains visible.
|
|
526
|
+
|
|
527
|
+
`Chart` supports `preset`: `grouped-bar`, `stacked-bar`, `stacked-area`, `donut`, and `sparkline`. Presets supply defaults; explicit `type` and native props take precedence, such as `innerRadius={0.8}` overriding the donut radius. Other LayerChart props and snippets continue to pass through.
|
|
528
|
+
|
|
529
|
+
Renderers load dynamically by type. SSR reserves height and shows a loading placeholder; drawing starts after browser mount. Loading and empty charts do not load renderers. Prefer the public charts entry for dashboard-only consumers. For advanced charts, place native LayerChart components in ReportCard children, beyond Chart's five types. Declare a compatible `layerchart` dependency and use its actual public entries such as `layerchart/svg` or `layerchart/hierarchy`. Load advanced components dynamically when needed; see the admin native ArcChart example.
|
|
530
|
+
|
|
531
|
+
```svelte
|
|
532
|
+
<script lang="ts">
|
|
533
|
+
import { Chart, DashboardGrid, MetricCard, ReportCard } from '@h-ai/ui/components/scenes/charts/index'
|
|
534
|
+
const data = [{ month: 'Jan', revenue: 42, cost: 24 }, { month: 'Feb', revenue: 58, cost: 31 }]
|
|
535
|
+
</script>
|
|
536
|
+
|
|
537
|
+
<DashboardGrid label="Key metrics" columns={4}>
|
|
538
|
+
<MetricCard title="Revenue" value="128,430" unit="CNY" trend={12.8} trendTone="success" trendLabel="vs previous month" />
|
|
539
|
+
</DashboardGrid>
|
|
540
|
+
<ReportCard title="Revenue and cost">
|
|
541
|
+
<Chart preset="grouped-bar" {data} x="month" y={['revenue', 'cost']} />
|
|
542
|
+
</ReportCard>
|
|
543
|
+
```
|
|
544
|
+
|
|
409
545
|
`Chart type='line'` uses LayerChart's native line chart by default. For monitoring dashboards with segmented lines, points, nearest-point hover, and vertical reference lines, use `lineVariant='segmented-point'`:
|
|
410
546
|
|
|
411
547
|
```svelte
|
|
@@ -423,7 +559,7 @@ Defaults match `@h-ai/crypto`: `SM4` for encrypted inputs, `SM3` for hashes, and
|
|
|
423
559
|
/>
|
|
424
560
|
```
|
|
425
561
|
|
|
426
|
-
##### CRUD scenes
|
|
562
|
+
##### CRUD scenes
|
|
427
563
|
|
|
428
564
|
| Component | Description | Key props / capabilities |
|
|
429
565
|
| ------------------- | ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -440,7 +576,7 @@ Defaults match `@h-ai/crypto`: `SM4` for encrypted inputs, `SM3` for hashes, and
|
|
|
440
576
|
>
|
|
441
577
|
> 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.
|
|
442
578
|
|
|
443
|
-
##### Error pages
|
|
579
|
+
##### Error pages
|
|
444
580
|
|
|
445
581
|
| Component | Description | Key props / capabilities |
|
|
446
582
|
| ----------- | --------------------------------------------------- | ----------------------------------------------------------------------- |
|
|
@@ -700,6 +836,8 @@ On mobile pages, match `BottomNav` width to the page shell to avoid spanning the
|
|
|
700
836
|
</div>
|
|
701
837
|
```
|
|
702
838
|
|
|
839
|
+
`BottomNav` and `ThemeSelector` keep their trigger buttons disabled until the client has mounted and the event handlers are ready.
|
|
840
|
+
|
|
703
841
|
#### Icons
|
|
704
842
|
|
|
705
843
|
Components use Iconify (Tabler Icons):
|
|
@@ -717,10 +855,12 @@ npm install -D @iconify/tailwind4 @iconify-json/tabler
|
|
|
717
855
|
|
|
718
856
|
#### Theme switching
|
|
719
857
|
|
|
720
|
-
Manage 15 curated DaisyUI themes plus high contrast
|
|
858
|
+
Manage 15 curated DaisyUI themes plus high contrast, square business and eye-care themes through built-in utilities:
|
|
721
859
|
|
|
722
860
|
`high-contrast` ships in shared theme.css with bright text on dark surfaces, clear borders/focus, and stronger muted text/placeholders. ThemeSelector has localized labels; examples and default generated projects offer it. Explicit fullstack themes lists remain host controlled. Palette checks target 7:1 for normal text; arbitrary application content still needs accessibility review.
|
|
723
861
|
|
|
862
|
+
`eye-care` ships in shared theme.css with warm green surfaces, dark text, readable placeholders and clear focus outlines. Select “Eye care” in examples and default templates; the preference survives reloads. Existing default themes and explicit fullstack themes lists are preserved.
|
|
863
|
+
|
|
724
864
|
`formal` provides square corners for business buttons, fields, cards and dialogs, with localized labels in examples and default templates. Button submitHint displays the native Enter action only for type=submit; it adds no global shortcut. LoginForm focuses its identifier on desktop when ready and no element has focus; autoFocus=false opts out. Search Enter submits immediately while respecting IME composition. Theme choices support arrows/Home/End, Enter/Space and Escape focus restoration. Confirmation dialogs initially focus Cancel and synchronize Escape cancellation.
|
|
725
865
|
|
|
726
866
|
```ts
|
|
@@ -734,7 +874,7 @@ import {
|
|
|
734
874
|
normalizeHexColor, // 归一化 #RGB / #RRGGBB 主题色
|
|
735
875
|
normalizeThemeId, // 校验主题 ID 并自动回退
|
|
736
876
|
THEME_GROUPS, // 按亮色/暗色分组
|
|
737
|
-
THEMES, // ThemeInfo[] —
|
|
877
|
+
THEMES, // ThemeInfo[] — 18 个主题元数据
|
|
738
878
|
} from '@h-ai/ui/theme'
|
|
739
879
|
```
|
|
740
880
|
|
|
@@ -779,7 +919,7 @@ Client locale state management, automatically synchronized with the `@h-ai/core`
|
|
|
779
919
|
```svelte
|
|
780
920
|
<script>
|
|
781
921
|
import { createLocaleStore, setGlobalLocale } from '@h-ai/ui/i18n'
|
|
782
|
-
import { setLocale } from '
|
|
922
|
+
import { setLocale } from '#lib/paraglide/runtime.js'
|
|
783
923
|
|
|
784
924
|
const localeStore = createLocaleStore()
|
|
785
925
|
|
|
@@ -841,11 +981,9 @@ agreements:
|
|
|
841
981
|
# privacyPolicyUrl: https://example.com/privacy
|
|
842
982
|
```
|
|
843
983
|
|
|
844
|
-
|
|
845
|
-
|
|
846
984
|
AuthPanel accepts public IAM config and actions for password/LDAP/email/SMS login, registration and recovery. config.ui supplies layout, branding and images. LoginForm supports methods, onsendotp, otpLength and resendInterval; password forms accept passwordPolicy. Network and token storage remain in actions.
|
|
847
985
|
|
|
848
|
-
Use `authErrorMessage(error)` from `@h-ai/ui/components/scenes/iam/index` for authentication failures. It maps public codes to the current UI language, combines username/password failures, hides raw unknown/server errors and preserves a valid `traceId`. AuthPanel, OTP sending, sensitive confirmation and fullstack password changes share this mapping. Initial/expired passwords, reuse of the current password (`hai:iam:034`) and session limits have actionable messages. Authentication errors and successful operations use the unified Toast. Password confirmation compares exact strings without Unicode normalization or trimming and reports mismatches through Toast while retaining field associations.
|
|
986
|
+
Use `authErrorMessage(error)` from `@h-ai/ui/components/scenes/iam/index` for authentication failures. It maps public codes to the current UI language, combines username/password failures, hides raw unknown/server errors and preserves a valid `traceId`. AuthPanel, OTP sending, sensitive confirmation and fullstack password changes share this mapping. Initial/expired passwords, reuse of the current password (`hai:iam:034`) and session limits have actionable messages. Authentication errors and successful operations use the unified Toast. Password confirmation compares exact strings without Unicode normalization or trimming and reports mismatches through Toast while retaining field associations. AuthPanel displays the server’s UTC time and synchronization guidance for time errors verified by Kit or API Client.
|
|
849
987
|
|
|
850
988
|
AuthPanel disables native form controls during SSR and enables input after client mount binds events, preventing early input from being lost during hydration. Applications need no extra readiness code. E2E tests wait for editable controls and cover delayed client scripts.
|
|
851
989
|
|
|
@@ -965,7 +1103,6 @@ Agreements open in a Modal and preserve form input. Pages must allow iframe embe
|
|
|
965
1103
|
</AuthPanel>
|
|
966
1104
|
```
|
|
967
1105
|
|
|
968
|
-
|
|
969
1106
|
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.
|
|
970
1107
|
|
|
971
1108
|
### Request locale isolation
|
|
@@ -974,11 +1111,11 @@ Wrap Node requests and SSR in `core.i18n.runWithLocale(locale, () => handleReque
|
|
|
974
1111
|
|
|
975
1112
|
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.
|
|
976
1113
|
|
|
977
|
-
|
|
1114
|
+
### Input limits and HTTP capabilities
|
|
978
1115
|
|
|
979
1116
|
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#存储输入约束与跨端能力).
|
|
980
1117
|
|
|
981
|
-
|
|
1118
|
+
### Compact workspaces and collapsible filters
|
|
982
1119
|
|
|
983
1120
|
`WorkspaceLayout` shares a compact navigation header, a content area with 12/16px padding and an optional footer. An omitted footer reserves no space. title is the page title in navigation; leading/actions/footer are snippets. data-* attributes reach the content main. The host must pass down available height and min-height: 0.
|
|
984
1121
|
|
|
@@ -1006,25 +1143,46 @@ In this example, m, statusOptions, clearFilters and loadRows belong to the host
|
|
|
1006
1143
|
</div>
|
|
1007
1144
|
```
|
|
1008
1145
|
|
|
1009
|
-
|
|
1146
|
+
### Design and interaction acceptance
|
|
1010
1147
|
|
|
1011
1148
|
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).
|
|
1012
1149
|
|
|
1013
1150
|
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. Expanded filters follow document focus order 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.
|
|
1014
1151
|
|
|
1015
|
-
|
|
1152
|
+
### Optional interactive challenges
|
|
1016
1153
|
|
|
1017
|
-
|
|
1154
|
+
AuthPanel uses actions.createCaptcha to automatically create and asynchronously solve self-hosted ALTCHA when config.captcha.enabled, submitting one-use proofs for login/register/sendOtp/passwordReset/renewPassword. The solver is not loaded when disabled. createAuthActions supplies the action; custom actions must preserve captcha and missing actions fail closed. Proofs stay in request memory and are always verified/consumed on the server.
|
|
1018
1155
|
|
|
1019
|
-
|
|
1156
|
+
See policy, defaults and recovery boundaries in [IAM](../iam/README.en.md).
|
|
1020
1157
|
|
|
1021
|
-
##
|
|
1158
|
+
## Configuration
|
|
1022
1159
|
|
|
1023
|
-
|
|
1160
|
+
### Choose configuration by task
|
|
1024
1161
|
|
|
1025
|
-
|
|
1162
|
+
| Configuration entry | Scenario | Input | Effect | Example |
|
|
1163
|
+
| --- | --- | --- | --- | --- |
|
|
1164
|
+
| `Component Props` | Rendering and interaction | typed props, bound values, callbacks, children snippets | DOM, bindings and callback events | `<Input bind:value={draft} />` |
|
|
1165
|
+
| `Theme` | Themes and colors | supported theme ID, color values, preference key | DOM theme/CSS variables; nonsensitive browser preference | `applyTheme("light")` |
|
|
1166
|
+
| `Locale` | Interface language | supportedLocales, defaultLocale, persistKey, detectBrowser | component-tree locale; isolated SSR state | `createLocaleStore({ defaultLocale: "ja-JP", detectBrowser: false })` |
|
|
1167
|
+
| `Guide` | Help and onboarding | tours, articles, nonsecret scope/version, nav adapter | guide/help state and nonsensitive progress | `createGuide({ tours: [], persistence: "memory" })` |
|
|
1168
|
+
| `CRUD` | Resource fields and API | CrudResource fields/API callbacks and controller options | resource view model; API must implement authorization | `createCrudController(crud, { autoLoad: false })` |
|
|
1169
|
+
| `Authentication` | Public auth policy | IAM-whitelisted config and standard actions | AuthPanel submits to host actions; no secret persistence | `<AuthPanel {config} {actions} />` |
|
|
1170
|
+
|
|
1171
|
+
When building Svelte applications with pnpm, register the `deepmerge@4.3.1` patch in the project's `patchedDependencies` and keep the patch file. Retain the DaisyUI style patch when that package is used. CLI-generated projects include applicable entries. Installing a framework npm package does not propagate this repository's pnpm patch configuration; manual integrations must copy the relevant [patch files](../../patches/) and registrations before reinstalling dependencies.
|
|
1172
|
+
|
|
1173
|
+
This package contains Svelte components and utilities and has no init/close lifecycle. Inputs are component props, callbacks and theme options; outputs are rendered UI, bound values and events. Configure Tailwind/DaisyUI and preprocessing as shown above. There is no shared _ui.yml or module environment variable for component props.
|
|
1174
|
+
|
|
1175
|
+
## Error Handling
|
|
1176
|
+
|
|
1177
|
+
The host provides loading/error and completion state. Check business HaiResult.success in the application adapter, then pass safe localized messages. UI helpers use the direct return types above rather than a universal HaiResult wrapper. notifyError/errorMessage hide unknown internal exception text. Catch rejected browser helpers such as downloadAiDocument at the interaction boundary and release loading. UserProfile.onsubmit ends editing only when it returns true.
|
|
1178
|
+
|
|
1179
|
+
### Error messages and correlated logs
|
|
1180
|
+
|
|
1181
|
+
HTTP errors carry safe localized messages and a reference ID. ToastContainer shows only the readable message by default; its diagnostic icon reveals the ID and copy action. The same ID remains in `error.traceId` and `X-Trace-Id`. The framework reuses the request ID to correlate browser and server logs. Sanitized exceptions, stacks and operation context remain in logs; internal cause/ext are not exposed. Field validation returns localized field names and messages only.
|
|
1182
|
+
|
|
1183
|
+
Use `core.error.toPublic(error, traceId?)` at HTTP/UI boundaries and `core.error.formatMessage(error)` after translating messages; formatting is idempotent. Pass complete Error objects to logs instead of discarding their context. Database failures log driver codes, sanitized messages/stacks and table/column context; SQL text, bound values and connection credentials are excluded.
|
|
1026
1184
|
|
|
1027
|
-
## Development
|
|
1185
|
+
## Development
|
|
1028
1186
|
|
|
1029
1187
|
```sh
|
|
1030
1188
|
pnpm --filter @h-ai/ui typecheck
|