@h-ai/ui 0.1.0-alpha.74 → 0.1.0-alpha.75
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 +36 -4
- package/README.ja.md +36 -4
- package/README.md +36 -4
- package/auto-import.d.ts +2 -0
- package/auto-import.js +2 -0
- package/dist/components/compounds/Confirm.svelte +12 -2
- package/dist/components/compounds/Drawer.svelte +32 -14
- package/dist/components/compounds/FilterBar.svelte +77 -0
- package/dist/components/compounds/FilterBar.svelte.d.ts +39 -0
- package/dist/components/compounds/Modal.svelte +4 -37
- package/dist/components/compounds/PageHeader.svelte +18 -11
- package/dist/components/compounds/TableToolbar.svelte +1 -1
- package/dist/components/compounds/index.d.ts +1 -0
- package/dist/components/compounds/index.js +1 -0
- package/dist/components/primitives/Button.svelte +7 -0
- package/dist/components/primitives/Input.svelte +1 -1
- package/dist/components/primitives/Textarea.svelte +1 -1
- package/dist/components/scenes/app/FeedbackDetail.svelte +2 -2
- package/dist/components/scenes/app/FeedbackList.svelte +4 -4
- package/dist/components/scenes/app/SettingsLayout.svelte +4 -15
- package/dist/components/scenes/app/ThemeSelector.svelte +56 -16
- package/dist/components/scenes/app/WorkspaceLayout.svelte +64 -0
- package/dist/components/scenes/app/WorkspaceLayout.svelte.d.ts +36 -0
- package/dist/components/scenes/app/feedback-functions.d.ts +16 -0
- package/dist/components/scenes/app/feedback-functions.js +31 -0
- package/dist/components/scenes/app/index.d.ts +1 -0
- package/dist/components/scenes/app/index.js +1 -0
- package/dist/components/scenes/crud/CrudEditPanel.svelte +18 -9
- package/dist/components/scenes/crud/CrudFilterBar.svelte +39 -30
- package/dist/components/scenes/crud/CrudFilterBar.svelte.d.ts +4 -1
- package/dist/components/scenes/crud/CrudPage.svelte +27 -7
- package/dist/components/scenes/crud/CrudPage.svelte.d.ts +1 -1
- package/dist/components/scenes/crud/crud-types.d.ts +1 -1
- package/dist/components/scenes/guide/GuideHost.svelte +22 -102
- package/dist/components/scenes/guide/GuideHost.svelte.d.ts +5 -13
- package/dist/components/scenes/guide/GuideHostContent.svelte +143 -0
- package/dist/components/scenes/guide/GuideHostContent.svelte.d.ts +43 -0
- package/dist/components/scenes/guide/HelpCenter.svelte +22 -9
- package/dist/components/scenes/iam/LoginForm.svelte +25 -1
- package/dist/components/scenes/iam/PasswordInput.svelte +1 -1
- package/dist/components/scenes/types.d.ts +2 -0
- package/dist/guide.svelte.js +61 -26
- package/dist/internal/dialog-focus.d.ts +21 -0
- package/dist/internal/dialog-focus.js +77 -0
- package/dist/internal/form-validation.svelte.d.ts +2 -1
- package/dist/internal/form-validation.svelte.js +9 -1
- package/dist/messages/en-US.json +9 -2
- package/dist/messages/ja-JP.json +9 -2
- package/dist/messages/zh-CN.json +9 -2
- package/dist/styles/formal.css +55 -0
- package/dist/styles/high-contrast.css +64 -0
- package/dist/styles/theme.css +2 -0
- package/dist/theme-config.d.ts +2 -2
- package/dist/theme-config.js +5 -2
- package/dist/types.d.ts +4 -0
- package/dist/workspace-context.d.ts +20 -0
- package/dist/workspace-context.js +9 -0
- package/package.json +2 -2
package/README.en.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
Built-in messages support `zh-CN`, `en-US` and `ja-JP`; the language selector offers all three by default.
|
|
10
10
|
|
|
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.
|
|
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 and square business themes.
|
|
12
12
|
|
|
13
13
|
## Core features
|
|
14
14
|
|
|
@@ -201,7 +201,7 @@ Labels connect to nested UI controls automatically; use `<FormField for="control
|
|
|
201
201
|
|
|
202
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.
|
|
203
203
|
|
|
204
|
-
|
|
204
|
+
Text controls validate on blur after input and update errors as input is corrected. Pristine empty fields validate on submit, so leaving default focus does not shift actions. CRUD create/edit forms also validate on blur after input or on submit, 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.
|
|
205
205
|
|
|
206
206
|
`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.
|
|
207
207
|
|
|
@@ -704,7 +704,11 @@ npm install -D @iconify/tailwind4 @iconify-json/tabler
|
|
|
704
704
|
|
|
705
705
|
#### Theme switching
|
|
706
706
|
|
|
707
|
-
Manage 15 curated DaisyUI themes through built-in utilities:
|
|
707
|
+
Manage 15 curated DaisyUI themes plus high contrast and square business themes through built-in utilities:
|
|
708
|
+
|
|
709
|
+
`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.
|
|
710
|
+
|
|
711
|
+
`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.
|
|
708
712
|
|
|
709
713
|
```ts
|
|
710
714
|
import {
|
|
@@ -717,7 +721,7 @@ import {
|
|
|
717
721
|
normalizeHexColor, // 归一化 #RGB / #RRGGBB 主题色
|
|
718
722
|
normalizeThemeId, // 校验主题 ID 并自动回退
|
|
719
723
|
THEME_GROUPS, // 按亮色/暗色分组
|
|
720
|
-
THEMES, // ThemeInfo[] —
|
|
724
|
+
THEMES, // ThemeInfo[] — 17 个主题元数据
|
|
721
725
|
} from '@h-ai/ui/theme'
|
|
722
726
|
```
|
|
723
727
|
|
|
@@ -957,6 +961,34 @@ Browsers keep application-level `setGlobalLocale` / `createLocaleStore`. During
|
|
|
957
961
|
|
|
958
962
|
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#存储输入约束与跨端能力).
|
|
959
963
|
|
|
964
|
+
## Compact workspaces and collapsible filters
|
|
965
|
+
|
|
966
|
+
`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.
|
|
967
|
+
|
|
968
|
+
A matching `PageHeader` omits the repeated title and retains its description and actions; `SettingsLayout` shares this behavior. Inside a workspace, `CrudPage` defaults to one navigation title and keeps actions in its toolbar. Standalone usage retains its title; showHeader explicitly overrides the default.
|
|
969
|
+
|
|
970
|
+
`FilterBar` keeps leading and actions visible, with children collapsed by default. bind:expanded controls disclosure, activeCount reports active conditions, and onreset supplies the built-in localized reset button. Collapsing preserves controls and values. The host resets state and performs queries. `CrudFilterBar` reuses it, supports custom actions and cancels pending debounce queries when destroyed.
|
|
971
|
+
|
|
972
|
+
In this example, m, statusOptions, clearFilters and loadRows belong to the host application. The reset callback must clear search and all conditions.
|
|
973
|
+
|
|
974
|
+
```svelte
|
|
975
|
+
<script lang="ts">
|
|
976
|
+
import { Button, FilterBar, Input, Select, WorkspaceLayout } from '@h-ai/ui'
|
|
977
|
+
let search = $state('')
|
|
978
|
+
let status = $state('')
|
|
979
|
+
</script>
|
|
980
|
+
|
|
981
|
+
<div class="flex h-dvh min-h-0">
|
|
982
|
+
<WorkspaceLayout title={m.page_title()}>
|
|
983
|
+
<FilterBar activeCount={status ? 1 : 0} onreset={clearFilters}>
|
|
984
|
+
{#snippet leading()}<Input size="sm" bind:value={search} placeholder={m.search()} />{/snippet}
|
|
985
|
+
{#snippet actions()}<Button size="sm" onclick={loadRows}>{m.search()}</Button>{/snippet}
|
|
986
|
+
<div class="w-40"><Select size="sm" bind:value={status} options={statusOptions} /></div>
|
|
987
|
+
</FilterBar>
|
|
988
|
+
</WorkspaceLayout>
|
|
989
|
+
</div>
|
|
990
|
+
```
|
|
991
|
+
|
|
960
992
|
## Design and interaction acceptance
|
|
961
993
|
|
|
962
994
|
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).
|
package/README.ja.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
内蔵メッセージは `zh-CN`、`en-US`、`ja-JP` に対応し、言語セレクターは既定で3言語を表示します。
|
|
10
10
|
|
|
11
|
-
Svelte 5 Runes のクロスプラットフォーム UI ライブラリーです。DaisyUI v5 + Tailwind CSS v4 のスタイル、Bits UI v2 のヘッドレス UI、内蔵 i18n(zh-CN / en-US)、15
|
|
11
|
+
Svelte 5 Runes のクロスプラットフォーム UI ライブラリーです。DaisyUI v5 + Tailwind CSS v4 のスタイル、Bits UI v2 のヘッドレス UI、内蔵 i18n(zh-CN / en-US / ja-JP)、15 種類の厳選テーマ、ハイコントラストと直角のビジネステーマを提供します。
|
|
12
12
|
|
|
13
13
|
## 主な機能
|
|
14
14
|
|
|
@@ -201,7 +201,7 @@ components/
|
|
|
201
201
|
|
|
202
202
|
`Input`、`Textarea`、`Select`、`PasswordInput` のネイティブ検証は中国語・英語・日本語に対応します。`validationMessage` は失敗時だけ適用され、有効な入力を無効にし続けません。UI の `setGlobalLocale` / `createLocaleStore` で言語を同期すると表示中のエラーも更新されます。`Textarea` は `minlength` / `maxlength`、`Select` は `name`・必須検証・FormData に対応します。
|
|
203
203
|
|
|
204
|
-
|
|
204
|
+
テキスト入力後のフォーカス離脱時に検証し、修正中も更新します。未入力の空欄は送信時に検証し、初期フォーカスの移動で操作を押し下げません。CRUD も入力後のフォーカス離脱時または送信時に検証し、カスタムメッセージに対応して再表示時に検証状態をリセットします。`Select` はトリガーと選択肢の両方からフォーカスが離れた時に検証します。`PasswordInput.minLength` は長さ制約と強度計算に使い、省略時はログイン用の長さ制限を設けず、強度のみ8文字を基準にします。
|
|
205
205
|
|
|
206
206
|
`UserProfile.fieldConstraints` は項目別に `required`、`minlength`、`maxlength`、`pattern`、`validationMessage` を受け取り、ユーザー名などの業務ルールをフォーカス離脱時に検証します。`pattern` は単一行の入力に適用し、`validationMessage` は翻訳関数にも対応します。
|
|
207
207
|
|
|
@@ -704,7 +704,11 @@ npm install -D @iconify/tailwind4 @iconify-json/tabler
|
|
|
704
704
|
|
|
705
705
|
#### テーマ切り替え
|
|
706
706
|
|
|
707
|
-
内蔵ツールで 15 種類の厳選 DaisyUI
|
|
707
|
+
内蔵ツールで 15 種類の厳選 DaisyUI テーマ、ハイコントラストと直角のビジネステーマを管理します:
|
|
708
|
+
|
|
709
|
+
`high-contrast` は共有 theme.css に含まれます。暗い背景と明るい文字、明確な境界線・フォーカス、補助文字とプレースホルダーの強いコントラストを提供します。ThemeSelector は3言語に対応し、サンプルと既定の生成プロジェクトで選択できます。fullstack の明示的な themes はホスト設定を尊重します。通常文字の配色目標は7:1ですが、各業務コンテンツは別途アクセシビリティ確認が必要です。
|
|
710
|
+
|
|
711
|
+
`formal` はボタン・入力欄・カード・ダイアログを直角にし、サンプルと既定テンプレートで選択できます。Button の submitHint は type=submit のネイティブ Enter 操作だけを表示します。LoginForm はデスクトップで準備完了時に既存のフォーカスがなければ識別子へ移動し、autoFocus=false で無効化できます。検索の Enter は IME 確定を除いて即時実行します。テーマは方向キー/Home/End、Enter/Space、Esc とフォーカス復帰に対応し、確認画面は取消を初期選択して Esc の状態を同期します。
|
|
708
712
|
|
|
709
713
|
```ts
|
|
710
714
|
import {
|
|
@@ -717,7 +721,7 @@ import {
|
|
|
717
721
|
normalizeHexColor, // 归一化 #RGB / #RRGGBB 主题色
|
|
718
722
|
normalizeThemeId, // 校验主题 ID 并自动回退
|
|
719
723
|
THEME_GROUPS, // 按亮色/暗色分组
|
|
720
|
-
THEMES, // ThemeInfo[] —
|
|
724
|
+
THEMES, // ThemeInfo[] — 17 个主题元数据
|
|
721
725
|
} from '@h-ai/ui/theme'
|
|
722
726
|
```
|
|
723
727
|
|
|
@@ -957,6 +961,34 @@ Node リクエストと SSR は `core.i18n.runWithLocale(locale, () => handleReq
|
|
|
957
961
|
|
|
958
962
|
キーは 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#存储输入约束与跨端能力)を参照してください。
|
|
959
963
|
|
|
964
|
+
## コンパクトな作業領域と折りたたみ式の絞り込み
|
|
965
|
+
|
|
966
|
+
`WorkspaceLayout` はコンパクトなナビゲーション、12/16px の余白を持つ本文、任意のフッターを統一します。フッターを省略すると高さを確保しません。title はナビゲーションのページ名、leading/actions/footer は snippet です。data-* は本文の main に渡します。親レイアウトから残りの高さと min-height: 0 を引き継いでください。
|
|
967
|
+
|
|
968
|
+
同名の `PageHeader` は重複する見出しを省略し、説明と操作を保持します。`SettingsLayout` も同じ動作です。作業領域内の `CrudPage` は既定でナビゲーションの見出しだけを表示し、操作をツールバーに残します。単独利用時は見出しを表示し、showHeader で明示的に変更できます。
|
|
969
|
+
|
|
970
|
+
`FilterBar` は leading と actions を常に表示し、children を既定で折りたたみます。bind:expanded は開閉、activeCount は適用中の件数、onreset は3言語対応のリセットボタンです。折りたたんでも入力を保持し、条件の初期化と問い合わせは業務側のコールバックが担当します。`CrudFilterBar` もこれを利用し、actions を追加でき、破棄時に未送信の遅延検索を取り消します。
|
|
971
|
+
|
|
972
|
+
例の m、statusOptions、clearFilters、loadRows は業務アプリが提供します。リセット時は検索語と全条件を初期化してください。
|
|
973
|
+
|
|
974
|
+
```svelte
|
|
975
|
+
<script lang="ts">
|
|
976
|
+
import { Button, FilterBar, Input, Select, WorkspaceLayout } from '@h-ai/ui'
|
|
977
|
+
let search = $state('')
|
|
978
|
+
let status = $state('')
|
|
979
|
+
</script>
|
|
980
|
+
|
|
981
|
+
<div class="flex h-dvh min-h-0">
|
|
982
|
+
<WorkspaceLayout title={m.page_title()}>
|
|
983
|
+
<FilterBar activeCount={status ? 1 : 0} onreset={clearFilters}>
|
|
984
|
+
{#snippet leading()}<Input size="sm" bind:value={search} placeholder={m.search()} />{/snippet}
|
|
985
|
+
{#snippet actions()}<Button size="sm" onclick={loadRows}>{m.search()}</Button>{/snippet}
|
|
986
|
+
<div class="w-40"><Select size="sm" bind:value={status} options={statusOptions} /></div>
|
|
987
|
+
</FilterBar>
|
|
988
|
+
</WorkspaceLayout>
|
|
989
|
+
</div>
|
|
990
|
+
```
|
|
991
|
+
|
|
960
992
|
## デザインと操作の検証
|
|
961
993
|
|
|
962
994
|
画面設計は [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) も利用できます。
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
内置中英日文消息(`zh-CN` / `en-US` / `ja-JP`),语言选择器默认提供三种语言。
|
|
10
10
|
|
|
11
|
-
基于 Svelte 5 Runes 的多端 UI 组件库,采用 DaisyUI v5 + Tailwind CSS v4 样式 + Bits UI v2 headless 交互,内置 i18n(zh-CN / en-US),内置 15 个精选 DaisyUI
|
|
11
|
+
基于 Svelte 5 Runes 的多端 UI 组件库,采用 DaisyUI v5 + Tailwind CSS v4 样式 + Bits UI v2 headless 交互,内置 i18n(zh-CN / en-US / ja-JP),内置 15 个精选 DaisyUI 主题、高对比及直角商务主题。
|
|
12
12
|
|
|
13
13
|
## 核心功能清单
|
|
14
14
|
|
|
@@ -201,7 +201,7 @@ components/
|
|
|
201
201
|
|
|
202
202
|
`Input`、`Textarea`、`Select` 和 `PasswordInput` 的原生校验使用内置中英日文提示;`validationMessage` 只覆盖失败提示,不让有效输入一直无效。应用通过 UI 的 `setGlobalLocale` / `createLocaleStore` 同步语言,已显示的校验错误即时更新。`Textarea` 支持 `minlength` / `maxlength`,`Select` 支持 `name`、必填校验和 FormData 序列化。
|
|
203
203
|
|
|
204
|
-
|
|
204
|
+
文本控件输入后失焦显示前端校验错误,修正输入时即时更新;未输入的空字段留到提交时校验,避免默认焦点离开时挤动操作。CRUD 新增/编辑同样在输入后失焦或提交时校验,支持自定义校验文案,关闭重开清空校验状态。`Select` 在焦点离开触发器和选项后校验。`PasswordInput.minLength` 同时约束长度并用于强度计算;省略时不限制登录密码长度,强度计算仍以 8 位为基准。
|
|
205
205
|
|
|
206
206
|
`UserProfile.fieldConstraints` 按字段接收 `required`、`minlength`、`maxlength`、`pattern` 和 `validationMessage`(`pattern` 用于单行输入),让应用的用户名等业务规则复用失焦校验;`validationMessage` 支持延迟翻译函数。
|
|
207
207
|
|
|
@@ -703,7 +703,11 @@ npm install -D @iconify/tailwind4 @iconify-json/tabler
|
|
|
703
703
|
|
|
704
704
|
#### 主题切换
|
|
705
705
|
|
|
706
|
-
使用内置的主题工具函数管理 15 个精选 DaisyUI
|
|
706
|
+
使用内置的主题工具函数管理 15 个精选 DaisyUI 主题、高对比及直角商务主题:
|
|
707
|
+
|
|
708
|
+
`high-contrast` 随共享 theme.css 提供:黑底亮字、清晰边框/焦点、增强次要文字及占位符对比度。ThemeSelector 提供三语名称;示例与默认生成工程可选择,fullstack 的显式 themes 列表仍由宿主决定。配色按普通文字 7:1 的目标验收,不代表任意业务内容已通过整站无障碍认证。
|
|
709
|
+
|
|
710
|
+
`formal` 提供直角的商务外观,按钮、输入框、卡片与弹窗不使用装饰性圆角;主题选择器提供三语名称,示例和默认模板可选择。Button 的 submitHint 仅在 type=submit 时显示原生 Enter 提示,不绑定全局快捷键;LoginForm 默认在桌面首次就绪且页面无焦点时聚焦标识,autoFocus=false 可关闭。筛选 Enter 即时查询且忽略输入法确认;主题菜单支持方向键/Home/End、Enter/Space 及 Esc 恢复焦点;确认框默认聚焦取消,Esc 同步取消状态。
|
|
707
711
|
|
|
708
712
|
```ts
|
|
709
713
|
import {
|
|
@@ -716,7 +720,7 @@ import {
|
|
|
716
720
|
normalizeHexColor, // 归一化 #RGB / #RRGGBB 主题色
|
|
717
721
|
normalizeThemeId, // 校验主题 ID 并自动回退
|
|
718
722
|
THEME_GROUPS, // 按亮色/暗色分组
|
|
719
|
-
THEMES, // ThemeInfo[] —
|
|
723
|
+
THEMES, // ThemeInfo[] — 17 个主题元数据
|
|
720
724
|
} from '@h-ai/ui/theme'
|
|
721
725
|
```
|
|
722
726
|
|
|
@@ -960,6 +964,34 @@ Node 请求与 SSR 使用 `core.i18n.runWithLocale(locale, () => handleRequest()
|
|
|
960
964
|
|
|
961
965
|
存储 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#存储输入约束与跨端能力)。
|
|
962
966
|
|
|
967
|
+
## 紧凑工作区与可收起筛选
|
|
968
|
+
|
|
969
|
+
`WorkspaceLayout` 统一导航、内容区和可选页脚:顶栏采用紧凑高度,主内容使用 12/16px 内边距;没有页脚时不预留高度。通过 `title` 提供导航中的页面标题,`leading/actions/footer` 为 snippet,`data-*` 透传内容 main。父布局需传递剩余高度及 min-height: 0。
|
|
970
|
+
|
|
971
|
+
同名 `PageHeader` 自动省略重复标题,保留说明和操作;`SettingsLayout` 复用该行为。工作区中的 `CrudPage` 默认不重复显示页面标题,操作并入工具栏;独立使用仍显示标题,可用 `showHeader` 显式覆盖。
|
|
972
|
+
|
|
973
|
+
`FilterBar` 的 leading 和 actions 保持可见,children 默认收起,`bind:expanded` 控制展开,`activeCount` 提示已启用条件,`onreset` 提供内置三语重置按钮。收起保留控件和值;重置和请求逻辑由宿主回调处理。`CrudFilterBar` 已复用它,支持自定义 actions,卸载时取消待发出的防抖查询。
|
|
974
|
+
|
|
975
|
+
下例的 m、statusOptions、clearFilters 和 loadRows 由业务应用提供;清空回调须重置搜索及全部条件。
|
|
976
|
+
|
|
977
|
+
```svelte
|
|
978
|
+
<script lang="ts">
|
|
979
|
+
import { Button, FilterBar, Input, Select, WorkspaceLayout } from '@h-ai/ui'
|
|
980
|
+
let search = $state('')
|
|
981
|
+
let status = $state('')
|
|
982
|
+
</script>
|
|
983
|
+
|
|
984
|
+
<div class="flex h-dvh min-h-0">
|
|
985
|
+
<WorkspaceLayout title={m.page_title()}>
|
|
986
|
+
<FilterBar activeCount={status ? 1 : 0} onreset={clearFilters}>
|
|
987
|
+
{#snippet leading()}<Input size="sm" bind:value={search} placeholder={m.search()} />{/snippet}
|
|
988
|
+
{#snippet actions()}<Button size="sm" onclick={loadRows}>{m.search()}</Button>{/snippet}
|
|
989
|
+
<div class="w-40"><Select size="sm" bind:value={status} options={statusOptions} /></div>
|
|
990
|
+
</FilterBar>
|
|
991
|
+
</WorkspaceLayout>
|
|
992
|
+
</div>
|
|
993
|
+
```
|
|
994
|
+
|
|
963
995
|
## 设计与交互验收
|
|
964
996
|
|
|
965
997
|
页面设计使用 [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) 说明布局、状态和示例。
|
package/auto-import.d.ts
CHANGED
|
@@ -66,6 +66,8 @@ declare global {
|
|
|
66
66
|
const MessageBoxDialog: typeof import('@h-ai/ui')['MessageBoxDialog']
|
|
67
67
|
const Modal: typeof import('@h-ai/ui')['Modal']
|
|
68
68
|
const PageHeader: typeof import('@h-ai/ui')['PageHeader']
|
|
69
|
+
const FilterBar: typeof import('@h-ai/ui')['FilterBar']
|
|
70
|
+
const WorkspaceLayout: typeof import('@h-ai/ui')['WorkspaceLayout']
|
|
69
71
|
const Pagination: typeof import('@h-ai/ui')['Pagination']
|
|
70
72
|
const Popover: typeof import('@h-ai/ui')['Popover']
|
|
71
73
|
const PullRefresh: typeof import('@h-ai/ui')['PullRefresh']
|
package/auto-import.js
CHANGED
|
@@ -40,6 +40,8 @@
|
|
|
40
40
|
}: ConfirmProps & DataAttributes = $props()
|
|
41
41
|
|
|
42
42
|
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
43
|
+
const titleId = $props.id()
|
|
44
|
+
const messageId = `${titleId}-message`
|
|
43
45
|
/** 响应式 i18n 显示值 */
|
|
44
46
|
const displayTitle = $derived(title ?? uiM('confirm_title'))
|
|
45
47
|
const displayMessage = $derived(message ?? uiM('confirm_message'))
|
|
@@ -63,6 +65,8 @@
|
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
function handleCancel() {
|
|
68
|
+
if (loading)
|
|
69
|
+
return
|
|
66
70
|
oncancel?.()
|
|
67
71
|
open = false
|
|
68
72
|
}
|
|
@@ -78,10 +82,16 @@
|
|
|
78
82
|
bind:this={modalElement}
|
|
79
83
|
class={cn('modal', className)}
|
|
80
84
|
onclick={handleBackdropClick}
|
|
85
|
+
aria-labelledby={titleId}
|
|
86
|
+
aria-describedby={messageId}
|
|
87
|
+
oncancel={(event) => {
|
|
88
|
+
event.preventDefault()
|
|
89
|
+
handleCancel()
|
|
90
|
+
}}
|
|
81
91
|
>
|
|
82
92
|
<div class='modal-box'>
|
|
83
|
-
<h3 class='font-bold text-lg'>{displayTitle}</h3>
|
|
84
|
-
<p class='py-4'>{displayMessage}</p>
|
|
93
|
+
<h3 id={titleId} class='font-bold text-lg'>{displayTitle}</h3>
|
|
94
|
+
<p id={messageId} class='py-4'>{displayMessage}</p>
|
|
85
95
|
<div class='modal-action'>
|
|
86
96
|
<Button
|
|
87
97
|
variant='ghost'
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
import type { DataAttributes, DrawerProps } from '../../types.js'
|
|
24
24
|
import { onDestroy, onMount, setContext } from 'svelte'
|
|
25
25
|
import { readStoredValue, writeStoredValue } from '../../internal/browser-safety.js'
|
|
26
|
+
import { focusDialog, handleDialogKeydown } from '../../internal/dialog-focus.js'
|
|
26
27
|
import { FORM_VISIBILITY_CONTEXT } from '../../internal/form-context.js'
|
|
27
28
|
import { uiM } from '../../messages.js'
|
|
28
|
-
import { cn,
|
|
29
|
+
import { cn, getDataAttributes } from '../../utils.js'
|
|
29
30
|
import IconButton from '../primitives/IconButton.svelte'
|
|
30
|
-
import ToggleCheckbox from '../primitives/ToggleCheckbox.svelte'
|
|
31
31
|
|
|
32
32
|
let {
|
|
33
33
|
open = $bindable(false),
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
resizable = false,
|
|
39
39
|
widthStorageKey,
|
|
40
40
|
closeOnBackdrop = true,
|
|
41
|
+
closeOnEscape = true,
|
|
41
42
|
showClose = true,
|
|
42
43
|
class: className = '',
|
|
43
44
|
onclose,
|
|
@@ -49,7 +50,19 @@
|
|
|
49
50
|
setContext(FORM_VISIBILITY_CONTEXT, {
|
|
50
51
|
get open() { return open },
|
|
51
52
|
})
|
|
52
|
-
const id =
|
|
53
|
+
const id = $props.id()
|
|
54
|
+
const titleId = `${id}-title`
|
|
55
|
+
let panel = $state<HTMLDivElement>()
|
|
56
|
+
let resizing = false
|
|
57
|
+
$effect(() => {
|
|
58
|
+
if (!open || !panel)
|
|
59
|
+
return
|
|
60
|
+
const restore = focusDialog(panel)
|
|
61
|
+
return () => {
|
|
62
|
+
finishResize()
|
|
63
|
+
restore()
|
|
64
|
+
}
|
|
65
|
+
})
|
|
53
66
|
/** 用户拖动后的像素宽度;优先于 width 与 size。 */
|
|
54
67
|
let resizedWidth = $state<number | null>(null)
|
|
55
68
|
/** 与响应式渲染解耦的同步宽度,确保 mouseup 时持久化最后一次 mousemove 的值。 */
|
|
@@ -106,6 +119,7 @@
|
|
|
106
119
|
)
|
|
107
120
|
|
|
108
121
|
function handleClose() {
|
|
122
|
+
finishResize()
|
|
109
123
|
open = false
|
|
110
124
|
onclose?.()
|
|
111
125
|
}
|
|
@@ -135,8 +149,9 @@
|
|
|
135
149
|
|
|
136
150
|
/** 结束拖动并在配置了 key 时记忆最终宽度。 */
|
|
137
151
|
function finishResize() {
|
|
138
|
-
if (typeof document === 'undefined')
|
|
152
|
+
if (typeof document === 'undefined' || !resizing)
|
|
139
153
|
return
|
|
154
|
+
resizing = false
|
|
140
155
|
|
|
141
156
|
globalThis.removeEventListener('mousemove', handleResizeMove)
|
|
142
157
|
globalThis.removeEventListener('mouseup', finishResize)
|
|
@@ -162,6 +177,7 @@
|
|
|
162
177
|
resizeStartWidth = drawer.getBoundingClientRect().width
|
|
163
178
|
resizeWidthForStorage = resizeStartWidth
|
|
164
179
|
previousUserSelect = document.documentElement.style.userSelect
|
|
180
|
+
resizing = true
|
|
165
181
|
document.documentElement.style.userSelect = 'none'
|
|
166
182
|
globalThis.addEventListener('mousemove', handleResizeMove)
|
|
167
183
|
globalThis.addEventListener('mouseup', finishResize, { once: true })
|
|
@@ -203,20 +219,22 @@
|
|
|
203
219
|
onDestroy(finishResize)
|
|
204
220
|
</script>
|
|
205
221
|
|
|
206
|
-
<div {...dataAttributes} class={drawerClass}
|
|
207
|
-
|
|
222
|
+
<div {...dataAttributes} class={drawerClass} role='presentation' onkeydown={(event) => {
|
|
223
|
+
if (open && panel)
|
|
224
|
+
handleDialogKeydown(event, panel, closeOnEscape ? handleClose : undefined)
|
|
225
|
+
}}>
|
|
226
|
+
<input {id} type='checkbox' class='drawer-toggle' tabindex='-1' aria-hidden='true' bind:checked={open} />
|
|
208
227
|
|
|
209
|
-
<div class={sideClass}>
|
|
210
|
-
<
|
|
211
|
-
|
|
212
|
-
tabindex='
|
|
228
|
+
<div class={sideClass} inert={!open}>
|
|
229
|
+
<button
|
|
230
|
+
type='button'
|
|
231
|
+
tabindex='-1'
|
|
213
232
|
aria-label={uiM('drawer_close')}
|
|
214
233
|
class='drawer-overlay'
|
|
215
234
|
onclick={handleBackdropClick}
|
|
216
|
-
|
|
217
|
-
></div>
|
|
235
|
+
></button>
|
|
218
236
|
|
|
219
|
-
<div class={contentClass} style={widthStyle}>
|
|
237
|
+
<div bind:this={panel} class={contentClass} style={widthStyle} role='dialog' aria-modal={open ? 'true' : undefined} aria-labelledby={title ? titleId : undefined} aria-label={title ? undefined : uiM('common_dialog')} tabindex='-1'>
|
|
220
238
|
{#if canResize}
|
|
221
239
|
<button
|
|
222
240
|
type='button'
|
|
@@ -230,7 +248,7 @@
|
|
|
230
248
|
|
|
231
249
|
<div class='flex items-center justify-between mb-4'>
|
|
232
250
|
{#if title}
|
|
233
|
-
<h3 class='text-lg font-bold'>{title}</h3>
|
|
251
|
+
<h3 id={titleId} class='text-lg font-bold'>{title}</h3>
|
|
234
252
|
{:else}
|
|
235
253
|
<div></div>
|
|
236
254
|
{/if}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component FilterBar
|
|
3
|
+
常用搜索与操作保持可见,更多筛选可展开收起;收起不卸载控件或清除值。
|
|
4
|
+
@example
|
|
5
|
+
```ts
|
|
6
|
+
import type { ComponentProps } from 'svelte'
|
|
7
|
+
import { FilterBar } from '@h-ai/ui/components/compounds/index'
|
|
8
|
+
const props: Pick<ComponentProps<typeof FilterBar>, 'expanded' | 'activeCount'> = { expanded: false, activeCount: 2 }
|
|
9
|
+
```
|
|
10
|
+
-->
|
|
11
|
+
<script lang='ts'>
|
|
12
|
+
import type { Snippet } from 'svelte'
|
|
13
|
+
import type { DataAttributes } from '../../types.js'
|
|
14
|
+
import { uiM } from '../../messages.js'
|
|
15
|
+
import { cn, getDataAttributes } from '../../utils.js'
|
|
16
|
+
import Button from '../primitives/Button.svelte'
|
|
17
|
+
|
|
18
|
+
/** FilterBar 组件的属性契约。
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import type { ComponentProps } from 'svelte'
|
|
22
|
+
* import { FilterBar } from '@h-ai/ui'
|
|
23
|
+
* const props: Partial<ComponentProps<typeof FilterBar>> = {}
|
|
24
|
+
* void props
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
interface Props extends DataAttributes {
|
|
28
|
+
/** 常驻搜索或主要条件。 */
|
|
29
|
+
leading?: Snippet
|
|
30
|
+
/** 查询、重置和业务操作。 */
|
|
31
|
+
actions?: Snippet
|
|
32
|
+
/** 可收起的筛选字段。 */
|
|
33
|
+
children?: Snippet
|
|
34
|
+
/** 是否展开;默认收起,可 bind:expanded。 */
|
|
35
|
+
expanded?: boolean
|
|
36
|
+
/** 已启用条件数量,收起时仍提示。 */
|
|
37
|
+
activeCount?: number
|
|
38
|
+
/** 清空查询与全部筛选;按钮文案由 UI 提供。 */
|
|
39
|
+
onreset?: () => void
|
|
40
|
+
class?: string
|
|
41
|
+
}
|
|
42
|
+
let { leading, actions, children, expanded = $bindable(false), activeCount = 0, onreset, class: className = '', ...restProps }: Props = $props()
|
|
43
|
+
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
44
|
+
const panelId = $props.id()
|
|
45
|
+
const toggleLabel = $derived(uiM(expanded ? 'filter_bar_collapse' : 'filter_bar_expand'))
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<div {...dataAttributes} class={cn('hai-filter-bar min-w-0 space-y-2 [&_.fieldset]:m-0 [&_.fieldset]:min-w-0', className)}>
|
|
49
|
+
<div class='flex min-w-0 flex-wrap items-center gap-2'>
|
|
50
|
+
{#if leading}<div class='flex min-w-0 max-w-full flex-[1_1_14rem] flex-wrap items-center gap-2'>{@render leading()}</div>{/if}
|
|
51
|
+
<div class='ml-auto flex max-w-full shrink-0 flex-wrap items-center gap-2'>
|
|
52
|
+
{#if actions}{@render actions()}{/if}
|
|
53
|
+
{#if onreset}<Button type='button' variant='ghost' size='sm' onclick={onreset}>{uiM('crud_reset')}</Button>{/if}
|
|
54
|
+
{#if children}
|
|
55
|
+
<button type='button' class='hai-filter-bar__toggle inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-md px-2 text-sm text-base-content/65 hover:bg-base-content/5 hover:text-base-content' aria-expanded={expanded} aria-controls={panelId} onclick={() => { expanded = !expanded }}>
|
|
56
|
+
<span>{toggleLabel}</span>
|
|
57
|
+
{#if activeCount > 0}<span class='rounded bg-primary/10 px-1.5 text-xs text-primary' aria-label={uiM('filter_bar_active').replace('{count}', String(activeCount))}>{activeCount}</span>{/if}
|
|
58
|
+
<span class='icon-[tabler--chevron-down] size-4 transition-transform' class:rotate-180={expanded} aria-hidden='true'></span>
|
|
59
|
+
</button>
|
|
60
|
+
{/if}
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
{#if children}
|
|
64
|
+
<div id={panelId} hidden={!expanded} class={expanded ? 'flex min-w-0 flex-wrap items-end gap-2 border-t border-base-content/8 pt-2' : 'hidden'}>
|
|
65
|
+
{@render children()}
|
|
66
|
+
</div>
|
|
67
|
+
{/if}
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<style>
|
|
71
|
+
@media (pointer: coarse) {
|
|
72
|
+
.hai-filter-bar__toggle {
|
|
73
|
+
min-height: var(--hai-touch-target-min, 44px);
|
|
74
|
+
min-width: var(--hai-touch-target-min, 44px);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
</style>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { DataAttributes } from '../../types.js';
|
|
3
|
+
/** FilterBar 组件的属性契约。
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import type { ComponentProps } from 'svelte'
|
|
7
|
+
* import { FilterBar } from '@h-ai/ui'
|
|
8
|
+
* const props: Partial<ComponentProps<typeof FilterBar>> = {}
|
|
9
|
+
* void props
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
interface Props extends DataAttributes {
|
|
13
|
+
/** 常驻搜索或主要条件。 */
|
|
14
|
+
leading?: Snippet;
|
|
15
|
+
/** 查询、重置和业务操作。 */
|
|
16
|
+
actions?: Snippet;
|
|
17
|
+
/** 可收起的筛选字段。 */
|
|
18
|
+
children?: Snippet;
|
|
19
|
+
/** 是否展开;默认收起,可 bind:expanded。 */
|
|
20
|
+
expanded?: boolean;
|
|
21
|
+
/** 已启用条件数量,收起时仍提示。 */
|
|
22
|
+
activeCount?: number;
|
|
23
|
+
/** 清空查询与全部筛选;按钮文案由 UI 提供。 */
|
|
24
|
+
onreset?: () => void;
|
|
25
|
+
class?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* FilterBar
|
|
29
|
+
* 常用搜索与操作保持可见,更多筛选可展开收起;收起不卸载控件或清除值。
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* import type { ComponentProps } from 'svelte'
|
|
33
|
+
* import { FilterBar } from '@h-ai/ui/components/compounds/index'
|
|
34
|
+
* const props: Pick<ComponentProps<typeof FilterBar>, 'expanded' | 'activeCount'> = { expanded: false, activeCount: 2 }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
declare const FilterBar: import("svelte").Component<Props, {}, "expanded">;
|
|
38
|
+
type FilterBar = ReturnType<typeof FilterBar>;
|
|
39
|
+
export default FilterBar;
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
<script lang='ts'>
|
|
16
16
|
import type { DataAttributes, ModalProps } from '../../types.js'
|
|
17
17
|
import { setContext } from 'svelte'
|
|
18
|
+
import { focusDialog, handleDialogKeydown } from '../../internal/dialog-focus.js'
|
|
18
19
|
import { FORM_VISIBILITY_CONTEXT } from '../../internal/form-context.js'
|
|
19
20
|
import { uiM } from '../../messages.js'
|
|
20
21
|
import { cn, getDataAttributes } from '../../utils.js'
|
|
@@ -109,51 +110,17 @@
|
|
|
109
110
|
onclose?.()
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
function focusableElements(): HTMLElement[] {
|
|
113
|
-
return [...(panel?.querySelectorAll<HTMLElement>('button, a[href], input:not([type="hidden"]), select, textarea, [tabindex]') ?? [])]
|
|
114
|
-
.filter(element => element.tabIndex >= 0 && !element.hasAttribute('disabled') && element.getClientRects().length > 0)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
113
|
// 打开时把焦点移入弹窗,关闭后恢复原操作位置。
|
|
118
114
|
$effect(() => {
|
|
119
115
|
if (!open || !panel)
|
|
120
116
|
return
|
|
121
|
-
|
|
122
|
-
const elements = focusableElements()
|
|
123
|
-
const input = elements.find(element => element.matches('input:not([readonly]), textarea, select'))
|
|
124
|
-
const target = input ?? elements[0] ?? panel
|
|
125
|
-
target.focus()
|
|
126
|
-
return () => {
|
|
127
|
-
if (previous?.isConnected)
|
|
128
|
-
previous.focus()
|
|
129
|
-
}
|
|
117
|
+
return focusDialog(panel)
|
|
130
118
|
})
|
|
131
119
|
|
|
132
120
|
function handleKeydown(event: KeyboardEvent) {
|
|
133
|
-
if (!open)
|
|
121
|
+
if (!open || !panel)
|
|
134
122
|
return
|
|
135
|
-
|
|
136
|
-
event.preventDefault()
|
|
137
|
-
event.stopPropagation()
|
|
138
|
-
handleClose()
|
|
139
|
-
}
|
|
140
|
-
else if (event.key === 'Tab') {
|
|
141
|
-
const elements = focusableElements()
|
|
142
|
-
const first = elements[0]
|
|
143
|
-
const last = elements.at(-1)
|
|
144
|
-
if (!first) {
|
|
145
|
-
event.preventDefault()
|
|
146
|
-
panel?.focus()
|
|
147
|
-
}
|
|
148
|
-
else if (event.shiftKey && (document.activeElement === first || document.activeElement === panel)) {
|
|
149
|
-
event.preventDefault()
|
|
150
|
-
last?.focus()
|
|
151
|
-
}
|
|
152
|
-
else if (!event.shiftKey && document.activeElement === last) {
|
|
153
|
-
event.preventDefault()
|
|
154
|
-
first.focus()
|
|
155
|
-
}
|
|
156
|
-
}
|
|
123
|
+
handleDialogKeydown(event, panel, closeOnEscape ? handleClose : undefined)
|
|
157
124
|
}
|
|
158
125
|
|
|
159
126
|
</script>
|
|
@@ -19,7 +19,10 @@
|
|
|
19
19
|
<script lang='ts'>
|
|
20
20
|
import type { Snippet } from 'svelte'
|
|
21
21
|
import type { DataAttributes } from '../../types.js'
|
|
22
|
+
import type { WorkspaceContext } from '../../workspace-context.js'
|
|
23
|
+
import { getContext } from 'svelte'
|
|
22
24
|
import { getDataAttributes } from '../../utils.js'
|
|
25
|
+
import { workspaceContextKey } from '../../workspace-context.js'
|
|
23
26
|
|
|
24
27
|
/**
|
|
25
28
|
* PageHeader 组件的属性契约;通过公开组件配置使用。
|
|
@@ -44,18 +47,22 @@
|
|
|
44
47
|
const { title, description, actions, class: className = '', ...restProps }: Props & DataAttributes = $props()
|
|
45
48
|
|
|
46
49
|
const dataAttributes = $derived(getDataAttributes(restProps))
|
|
50
|
+
const workspace = getContext<WorkspaceContext | undefined>(workspaceContextKey)
|
|
51
|
+
const showTitle = $derived(Boolean(title) && workspace?.title !== title)
|
|
47
52
|
</script>
|
|
48
53
|
|
|
49
|
-
|
|
50
|
-
<div>
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
{#if showTitle || description || actions}
|
|
55
|
+
<div {...dataAttributes} class='flex flex-col sm:flex-row sm:items-center justify-between gap-2 mb-3 {className}'>
|
|
56
|
+
{#if showTitle || description}<div class='min-w-0'>
|
|
57
|
+
{#if showTitle}<h1 class='text-xl font-semibold tracking-tight'>{title}</h1>{/if}
|
|
58
|
+
{#if description}
|
|
59
|
+
<p class='text-sm text-base-content/45' class:mt-0.5={showTitle}>{description}</p>
|
|
60
|
+
{/if}
|
|
61
|
+
</div>{/if}
|
|
62
|
+
{#if actions}
|
|
63
|
+
<div class='flex items-center gap-2'>
|
|
64
|
+
{@render actions()}
|
|
65
|
+
</div>
|
|
54
66
|
{/if}
|
|
55
67
|
</div>
|
|
56
|
-
|
|
57
|
-
<div class='flex items-center gap-2'>
|
|
58
|
-
{@render actions()}
|
|
59
|
-
</div>
|
|
60
|
-
{/if}
|
|
61
|
-
</div>
|
|
68
|
+
{/if}
|
|
@@ -438,7 +438,7 @@
|
|
|
438
438
|
class='input input-sm w-full pl-9 bg-base-100 border-base-content/15'
|
|
439
439
|
placeholder={searchPlaceholder || uiM('crud_search_placeholder')}
|
|
440
440
|
onkeydown={(e) => {
|
|
441
|
-
if (e.key === 'Enter') {
|
|
441
|
+
if (e.key === 'Enter' && !e.isComposing) {
|
|
442
442
|
e.preventDefault()
|
|
443
443
|
onsearch?.(searchValue)
|
|
444
444
|
}
|
|
@@ -22,6 +22,7 @@ export { default as DatePicker } from './DatePicker.svelte';
|
|
|
22
22
|
export { default as Drawer } from './Drawer.svelte';
|
|
23
23
|
export { default as Dropdown } from './Dropdown.svelte';
|
|
24
24
|
export { default as Empty } from './Empty.svelte';
|
|
25
|
+
export { default as FilterBar } from './FilterBar.svelte';
|
|
25
26
|
export { default as Form } from './Form.svelte';
|
|
26
27
|
export { default as FormField } from './FormField.svelte';
|
|
27
28
|
export { default as FormLayout } from './FormLayout.svelte';
|