@keepkit/ui 0.28.8 → 0.28.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,312 +2,344 @@
2
2
 
3
3
  [日本語](#日本語) | [English](#english)
4
4
 
5
+ Release: v0.28.10
6
+
5
7
  ## 日本語
6
8
 
7
- Reactアプリケーション向けの標準利用パッケージです。`@keepkit/core`を内包し、Provider、保存ボタン、検索・ソート・ページング付きの一覧を少ないコードで構成できます。
9
+ KeepKitのReact向けUIパッケージです。`@keepkit/core`を含み、保存ボタンと一覧を共通のProviderで利用できます。
10
+ CSSは任意で、標準テーマでも独自のスタイルでも使えます。React 18以降に対応します。
11
+
12
+ ### はじめる
8
13
 
9
14
  ```bash
10
15
  pnpm add @keepkit/ui
11
16
  ```
12
17
 
13
- ## Minimal Starter Recipe
14
-
15
18
  ```tsx
16
19
  import "@keepkit/ui/theme.css";
17
20
  import { createBrowserStorageAdapter, createKeepKit } from "@keepkit/ui";
18
21
 
19
- type Meta = { title: string; url: string };
20
- const keep = createKeepKit<Meta>({
21
- storage: createBrowserStorageAdapter({ key: "demo:keeps" }),
22
+ type ArticleMeta = { title: string; url: string };
23
+ const keep = createKeepKit<ArticleMeta>({
24
+ storage: createBrowserStorageAdapter({ key: "my-app:items" }),
25
+ locale: "ja",
22
26
  });
23
27
 
24
- export function SavedArticle({ article }: { article: Meta & { id: string } }) {
28
+ export function App() {
25
29
  return (
26
- <keep.Provider fallback={<p>Saved items are temporarily unavailable.</p>}>
27
- <keep.Button item={{ id: article.id, targetType: "article", meta: article }} />
30
+ <keep.Provider>
31
+ <keep.Button
32
+ item={{
33
+ id: "article-123",
34
+ targetType: "article",
35
+ meta: { title: "Example article", url: "/articles/123" },
36
+ }}
37
+ />
28
38
  <keep.Collection query={{ targetType: "article" }} />
29
39
  </keep.Provider>
30
40
  );
31
41
  }
32
42
  ```
33
43
 
34
- すべてのプリミティブは`data-state`を公開し、処理中は`data-loading="true"`、無効時は`data-disabled="true"`になります。`@keepkit/ui/theme.css`を読み込むと、標準の枠、面色、影、フォーカス表示と装飾アイコンが有効になります。通常の削除・一括削除・stale削除は薄い赤の枠線と文字色、hover時の淡い面色で表示し、強い赤の塗りつぶしは確認が必要なエラー状態に限定します。個別の操作は`data-keep-action`で選択でき、`--keep-icon-size`、`--keep-control-gap`、`--keep-shadow`、`--keep-success`、`--keep-warning`で調整できます。CSSを読み込まないheadless利用と`KeepButton icons`による差し替えは維持されます。
44
+ `createKeepKit<TMeta>()`は同じメタデータ型のコンポーネントとhooksを返します。
45
+ `locale`で組み込みラベルを切り替え、`labels`で文言を上書きできます。16言語に対応しています。
35
46
 
36
- ```tsx
37
- import "@keepkit/ui/theme.css";
38
- import { createBrowserStorageAdapter, createKeepKit } from "@keepkit/ui";
47
+ ### 一覧を拡張する
39
48
 
40
- type ArticleMeta = { title: string; url: string };
41
- const keep = createKeepKit<ArticleMeta>({
42
- storage: createBrowserStorageAdapter({ key: "articles" }),
43
- locale: "ja-JP",
44
- labels: { save: "保存", remove: "削除" },
45
- });
49
+ `keep.Collection`は検索・ソート・ページング、読み込み中・空・エラー表示を標準で備えます。
50
+ 検索は既定で300msデバウンスされます。必要な機能を`features`で有効にします。
46
51
 
47
- function SavedArticles() {
52
+ ```tsx
53
+ export function Library() {
48
54
  return (
49
55
  <keep.Provider>
50
56
  <keep.Collection
51
57
  query={{ targetType: "article" }}
52
- renderItem={(item) => <keep.Button item={{ id: item.id, targetType: item.targetType, meta: item.meta }} />}
58
+ layout="auto"
59
+ urlSync
60
+ features={{ tagFilter: true, collectionFilter: true, bulkActions: true, savedViews: true }}
61
+ itemCardProps={{ href: (item) => item.meta.url }}
53
62
  />
63
+ <keep.Backup />
54
64
  </keep.Provider>
55
65
  );
56
66
  }
57
67
  ```
58
68
 
59
- `keep.Collection`は検索、ソート、ページング、loading / empty / error、ARIA live通知を標準で提供します。検索は既定で300msデバウンスされます。`features={{ tagFilter: true, bulkActions: true }}`でタグフィルターと一括操作も有効にできます。個別の`KeepList`、`KeepSearchInput`、`KeepSortSelect`、`KeepPagination`、`KeepItemCheckbox`、`KeepTagEditor`などは高度なレイアウト用に利用できます。`KeepBulkActions`はrender propsで操作UIを差し替えられ、`isAllSelected` / `toggleSelectAll`で表示中アイテムを一括操作できます。`KeepNoteEditor`は既定300msのデバウンス保存に対応し、`debounceMs={0}`でフォーム送信のみへ戻せます。通知領域だけを明示的に置く場合は`KeepAnnouncer`(`KeepAnnouncements`のalias)を使えます。
69
+ `layout`は`list`、`grid`、`compact`、コンテナ幅に追従する`auto`から選べます。
70
+ `urlSync`は検索・タグ・ソート・ページをURLと戻る/進むに同期します。
71
+ Next.js Pages Routerでは`createNextPagesRouterAdapter(router)`を`urlAdapter`に渡します。
60
72
 
61
- 未分類アイテムを整理するには`<keep.Inbox />`を使います。Inboxは一括移動・archive・pinと、カードのnote/tag編集を有効にします。`KeepCollection features={{ savedViews: true }}`は現在のqueryを保存し、保存済みqueryの適用・名前変更・pin・削除を提供します。`KeepWorkspace modules={{ inbox: true, savedViews: true }}`でも両方をopt-inできます。Saved Viewデータはアイテムとは別の`keepkit:saved-views` localStorage keyに保存されます。
62
- 再発見には`useKeepItem(item).recordOpen()`で`lastOpenedAt`を記録し、`activity`クエリまたは`createRediscoveryQuery()` / `useKeepRediscovery()`を利用できます。`inactiveForMs`は未閲覧なら`savedAt`、閲覧済みなら`lastOpenedAt`を基準にし、開封記録だけでは`updatedAt`を変更しません。`<KeepRediscovery strategy="forgotten" limit={5} />`は低レベルの一覧プリセット、`<KeepRediscoveryPanel strategy="forgotten" limit={5} />`は表示理由とActivityバッジ付きの標準UIです。カード単位では`trackOpen`を指定したときだけ開封記録を有効にします。
63
- 保存確認から対象へ戻すには`revealRequest={{ requestId, itemId }}`を渡し、`onRevealResult`で結果を受け取れます。検索・タグ・保存先フィルターとページを調整して対象を表示します。
64
- `KeepWorkspace`はこれらのプリミティブを一つにまとめ、`basic`、`standard`、`management`、`sync`のプリセットを提供します。`createKeepKit()`を利用する場合は同じ実装を`keep.Workspace`から型付きで利用できます。`modules`、`slots`、子コンポーネントごとのpropsで部分的に差し替えられます。
65
- `KeepCollectionManager`は作成・名前変更・削除・件数表示をまとめたheadless UIです。`allowCreate`、`allowRename`、`allowDelete`、`showCounts`で機能を個別に切り替えられ、`collectionLabels`、`title`、`description`、`empty`で表示を差し替えられます。
66
- 標準ブラウザーストレージは空のコレクションと変更後の名前を再読み込み後も復元します。独自の`StorageAdapter`では`getCollections`、`setCollection`、`removeCollection`を実装して永続化できます。
67
- 画面領域を明示する場合は`surface="panel"`または領域別の`surface`と、`sectionGap="compact" | "comfortable"`を指定できます。空のslotは枠を生成せず、未指定時と`surface="plain"`では従来のDOM順序を維持します。
73
+ `reorderable`を有効にすると、明示ソートがない一覧は「手動順序」になります。日時ソートと切り替えられ、並べ替えは手動順序かつ`pinnedFirst`なしの場合に有効です。表示中の項目が占める位置だけを入れ替え、別ページ・非表示項目の位置を保ちます。矢印操作は即時保存、Escapeはつかみ状態の解除、保存済み順序の取り消しは5秒間のUndoで行います。
68
74
 
69
- ```tsx
70
- const keep = createKeepKit<ArticleMeta>({ storage, locale: "ja" });
75
+ 独自の`KeepSortSelect`では`onManualSort`を渡すと`value="manual"`を選択できます。既存の`onValueChange(value, sort)`は日時ソートのみを通知します。手動順序のURL/Saved Viewでは`sort`を省略します。URL同期が有効ならURLが優先し、`sort`省略は以前の日時ソートを解除します。通常の一覧は更新日時降順へ戻ります。同じURLへの遷移は省略し、履歴は既定でpush、`urlSync={{ history: "replace" }}`でreplaceを選べます。
76
+
77
+ 未分類のSaved Viewは`organization.collection="unassigned"`で保存します。利用側の関数`query.filter`は引き続き保存できません。`revealRequest`はローカルの検索・タグ・整理・日時条件を解除しますが、利用側の固定`targetType`・`filter`で除外される対象には`excluded`を返します。`creatable`と`slots.toolbarEnd`は併用できます。
71
78
 
72
- <keep.Provider>
73
- <keep.Workspace preset="sync" collectionProps={{ layout: "auto" }} />
74
- </keep.Provider>;
79
+ ### 記事・リンクを再訪する一覧
80
+
81
+ 記事向け表示は選択式です。既存の既定表示は変わりません。
82
+
83
+ `linkTarget="card"`の既定表示は通常の画像・静的内容をリンクにし、タグ・操作ボタン・編集フォームをリンク外に置きます。カスタム画像や`children`/`render`全体は自動で包みません。compoundの`Title`はタイトルリンクを提供します。カスタム構成では`KeepItemCard.Link`で非対話コンテンツを明示的に包みます。URL、router用`linkComponent`、外部リンク属性、利用不能状態、`trackOpen`/`onOpen`はrootと共有します。内側の`Title`は静的表示、`Content`は自動タグなしです。独自のボタンやフォームもリンク外に置いてください。
84
+
85
+ ```tsx
86
+ <keep.Collection
87
+ layout="list"
88
+ query={{ sort: { by: "savedAt", direction: "desc" }, pinnedFirst: true }}
89
+ features={{ bulkActions: true, pin: true, archive: true }}
90
+ bulkActionsVariant="inline"
91
+ itemCardProps={{ presentation: "reading", href: (item) => item.meta.url, trackOpen: true }}
92
+ />
75
93
  ```
76
- 一覧の標準カードで必要な機能だけを有効化する場合は、`features={{ pin: true, archive: true, tags: false }}`を指定できます。`pin` / `archive` はカード操作ボタン、`tags` はカード内のタグ表示を切り替えます。タグフィルターは`tagFilter`、タグ編集は`KeepTagEditor`で個別に制御でき、`itemCardProps`の明示指定が`features`より優先されます。
77
- `KeepCollection`は検索語と選択タグを`KeepActiveFiltersSummary`のチップとして表示し、個別解除と「すべての条件をクリア」を提供します。`activeFilters`でこの領域を差し替えられます。標準の`KeepList` / `KeepCollection`は、全件0件の`empty-storage`と絞り込み結果0件の`empty-filtered`を区別し、後者では`onClearFilters`付きの解除ボタンを表示します。
78
- `toolbarLayout="grouped"`と`toolbarVariant="panel"`を指定すると、`slots.toolbarStart` / `slots.toolbarEnd`を含む主操作、検索・ソート、フィルターの各グループをローカライズされた`role="group"`として描画します。狭い幅ではグループ内のコントロールを縦に折り返します。
79
- `KeepItemCard`は`href`、`onOpen`、`linkTarget`、`linkComponent`に対応し、保存アイテムから詳細ページへ遷移できます。非公開・期限切れ等の`status`を持つアイテムは自動的にリンクを無効化します。`KeepBackup`はJSONのエクスポート、merge / replaceインポート、結果件数、容量エラー表示を提供します。
80
- `KeepTourBar`(alias: `KeepNavigator`)は進行度、前へ・次へ、一覧へ戻る操作をURLまたはコールバックで提供します。`getItemHref`、`getBackHref`、`onNavigate`でホストのルーティングを注入できます。前後ボタンには隣接アイテム名のプレビューが付き、`getItemTitle`で表示名を差し替えられます。`keyboardShortcuts`を指定するとJ/Kまたは]/[で巡回でき、`useKeepTourShortcuts`ではキーと動作を個別に差し替えられます。`KeepReorderableList`はドラッグ操作と矢印キーによる並び替えを提供し、ドラッグ中の挿入位置を表示します。`KeepCollection reorderable`ではこの導線と標準Undoを差し替えなしで利用できます。
81
- `KeepShortcutHint`はセマンティックな`<kbd>`バッジを表示します。`KeepTourBar showShortcutHint`は前へ/次へのキーを、`KeepNoteEditor showShortcutHint`は`Ctrl+Enter`を標準ボタン内に表示します。`mergeProps` / `createSlot`は`asChild`でclassName、style、ARIA属性、イベント、子と親のrefを合成し、`composeRefs`はcallback refとobject refをまとめる共通基盤です。フィルターチップは削除後に隣接チップへ戻り、ArrowLeft / ArrowRightで移動できます。
82
- `KeepList`や`KeepCollection`のカードは検索語を大文字小文字を区別せず`<mark class="keep-highlight" data-highlight="true">`で表示します。単体の`KeepItemCard`では`highlightQuery`、任意のテキストでは`KeepHighlight`を使えます。`KeepItemCard.Media`は読み込み状態を`data-media-status`で公開し、失敗時は`fallback`または標準SVGへ切り替わります。
83
- テーマCSSではハイライト用の`--keep-highlight-bg` / `--keep-highlight-fg`(ライト/ダーク対応)、タイトル2行・メモプレビュー3行の制限、メディアの固定アスペクト比を適用します。`KeepItemStatusBadge`は状態ラベルに加えてチェック・時計・進入禁止・鍵のSVGアイコンを表示し、状態ごとの形状とトーンを組み合わせます。個別の状態スタイルは`@keepkit/ui/styles/status.css`からも読み込めます。
84
- 外部URLの詳細リンクには`target="_blank"`と`rel="noreferrer"`が既定で補完され、利用できないカードには`aria-disabled="true"`と`data-item-status`が付与されます。同期競合ダイアログではローカルとリモートの更新日時・メモを並べて確認できます。
85
- カードは`cardVariant="outlined" | "elevated" | "filled"`で面の表現を選べます。`--keep-card-border` / `--keep-card-shadow`と`--keep-surface-border` / `--keep-surface-background`はカード、ツールバー、Workspace領域を個別に調整するテーマトークンです。
86
-
87
- `KeepList`は初回ロード中、`layout`に合う`KeepItemCardSkeleton`を既定で6枚表示します。`loadingCount`で枚数を変更でき、従来の`loading`または`renderLoading`で完全に差し替えられます。`layout="auto"`は画面幅ではなく配置コンテナ幅に追従し、サイドバーやモーダルでも1列から複数列へ切り替わります。スケルトンのパルスは`prefers-reduced-motion`で静止表示になります。
88
- カードグループはRoving Tabindexを採用しており、カードにフォーカスして矢印キー、Home、Endで移動できます。
89
-
90
- カードの一部だけを配置し直す場合はCompound APIを利用できます。画像alt、タイトルリンク、タグ一覧のARIAラベル、保存操作の状態は各パーツでも維持されます。
91
94
 
92
95
  ```tsx
93
- <KeepItemCard item={item} href={`/items/${item.id}`} getImageProps={getImageProps}>
94
- <KeepItemCard.Media fallback="No image" />
95
- <KeepItemCard.Content>
96
- <KeepItemCard.Title />
97
- <KeepItemCard.Tags />
98
- </KeepItemCard.Content>
99
- <KeepItemCard.Actions>
100
- <KeepItemCard.Save />
101
- <KeepItemCard.Pin />
102
- <KeepItemCard.Archive />
103
- <KeepItemCard.Remove />
104
- </KeepItemCard.Actions>
96
+ <KeepItemCard item={item} href={item.meta.url} trackOpen>
97
+ <KeepItemCard.Link>
98
+ <KeepItemCard.Media />
99
+ <KeepItemCard.Content />
100
+ </KeepItemCard.Link>
101
+ <KeepItemCard.Tags />
102
+ <KeepItemCard.Actions />
105
103
  </KeepItemCard>
106
104
  ```
107
105
 
108
- `KeepKitProvider` / `KeepUiProvider`の`onFeedback`は`item-saved`、`item-removed`、`item-restored`、`sync-completed`、`sync-failed`、`stale-pruned`を通知します。削除系イベントには`undo`と現在ロケールの`undoLabel`が含まれます。ラベルは既存の`labels: { save: "保存" }`形式で内容を上書きし、`labelOptions: { collection: { text: "カテゴリ", visible: false } }`で内容と表示/非表示を設定できます。非表示の表示ラベルでも、操作に必要なARIA名は維持されます。Sonner互換の関数なら次の1行で接続できます(ライブラリ依存は追加されません)。
106
+ `presentation="reading"`はタイトル、URLの保存元、コレクション名、メモ、タグ、保存・訪問情報を表示します。画像は`getImageProps`で指定した場合だけ表示します。保存トグルは既定で非表示、編集・メモ・訪問情報は表示され、既存の表示フラグで上書きできます。`href`と`trackOpen`は明示指定です。編集は300msの自動保存と「完了」を使い、失敗時は下書きを残します。
109
107
 
110
- ```tsx
111
- const onFeedback = useKeepToastFeedback(toast);
112
- <KeepKitProvider storage={storage} onFeedback={onFeedback}>{children}</KeepKitProvider>;
113
- ```
108
+ `bulkActionsVariant="inline"`は記事行で選択します。全選択は現在ページだけで、検索・フィルター・ページ・表示先を変えると選択を解除します。失敗した一括操作は選択を保持します。既定の`separate`は従来の選択用一覧を維持します。
114
109
 
115
- v0.28.8では個人用リンクライブラリのデモを刷新し、Inbox、Pinned、Unread、Archive、コレクションの操作を試せます。v0.28.8ではスコープをまたぐ結合、並行所属変更、履歴・鑑賞記録・進行位置の同一キー更新を補強しました。
116
- Phase 4の状態UIとして`KeepItemStatusBadge`、`KeepStaleNotice`、`KeepPruneStaleButton`、`KeepSyncStatusBanner`、`KeepSyncRecoveryDialog`を利用できます。`import "@keepkit/ui/theme.css"`でテーマCSSを有効にできます。
110
+ 独自の行には`KeepListSelection`(`selectedIds: readonly string[]`、`onSelectedIdsChange`、任意の`disabled`)を`KeepList.selection`に渡せます。`KeepList`と`KeepCollection`の`renderItem(item, state, selection?)`の第三引数は`KeepItemSelection`(`checked`、`onCheckedChange`、任意の`disabled`)で、`KeepItemCheckbox`にそのまま渡せます。従来の二引数コールバックも使用できます。
117
111
 
118
- ### Tailwind/shadcnテーマ
112
+ `KeepBulkActions`と`KeepCollection`の`confirmRemoval`は既定falseです。`confirmRemoval`を渡すと削除前に件数と確定・取消を表示します。確認開始時の全選択ID(ページ外も含む)を固定し、選択・scope・検索条件の変更で取り消します。失敗時は再試行でき、成功後は既存のUndoで復元できます。render-propsには`removalConfirmation`、`requestRemoval()`、`confirmRemoval()`、`cancelRemoval()`を公開します。
119
113
 
120
- ```css
121
- /* globals.css */
122
- @import "tailwindcss";
123
- @import "@keepkit/ui/tailwind.css";
114
+ ```tsx
115
+ <keep.Collection confirmRemoval features={{ bulkActions: true }} />
124
116
  ```
125
117
 
118
+ ### fallback分岐を確認・復元する
119
+
120
+ `KeepFallbackRecovery`はProviderと独立した画面です。対象adapterの`recovery`を明示的に渡します。表示や比較では書き込まず、競合の保存元を選び、所属などの変更プレビューを確認して適用します。未解決の競合や不整合がある場合は適用できません。データが変わった場合は再比較が必要です。「反映待ち」は修復内容が保存済みなので、再提出せず再試行します。
121
+
126
122
  ```tsx
127
- import { KeepThemeProvider, KeepCollection } from "@keepkit/ui";
123
+ import { createBrowserStorageAdapter, KeepFallbackRecovery, KeepUiProvider } from "@keepkit/ui";
124
+
125
+ const storage = createBrowserStorageAdapter({ key: "my-app:items", scope: { userId: "alice" } });
128
126
 
129
- <KeepThemeProvider theme="ocean" mode="system" density="comfortable" radius="medium">
130
- <KeepCollection layout="grid" />
131
- </KeepThemeProvider>;
127
+ function RecoveryScreen() {
128
+ return storage.recovery ? (
129
+ <KeepUiProvider locale="ja">
130
+ <KeepFallbackRecovery recovery={storage.recovery} />
131
+ </KeepUiProvider>
132
+ ) : null;
133
+ }
132
134
  ```
133
135
 
134
- 色テーマは`default`、`ocean`、`forest`、`sunset`、`lavender`から選べます。既存の`compact`、`minimal`、`rounded`、`high-contrast`、`dark`も引き続き利用できます。`theme`は`mode`、`density`、`radius`と独立しており、`KeepKitProvider theme="forest" mode="dark"`のように組み合わせられます。選択肢をUIへ表示する場合は`keepThemeNames`を利用できます。
136
+ `SyncStorageAdapter`経由では状態のみ表示します。修復は同期開始前のstandalone local adapterで行ってください。修復前バックアップは自動削除しません。導入時は旧実装のタブをすべて更新し、[Coreガイド](../keepkit/README.md)の保存制約を確認してください。
135
137
 
136
- Tailwind v4の`--color-background`、`--color-foreground`、`--color-card`、`--color-muted`、`--color-border`、`--color-primary`、`--color-destructive`、`--color-ring`をKeepKitのスコープ内へ継承します。KeepKitはホストの`--color-*`変数を上書きせず、`--color-keep-*`としてTailwindへ公開します。`variables`、`accentColor`、`highContrast`、`reducedMotion`による上書きも維持されます。`keepKitTheme`は`@keepkit/ui/tailwind`から、分割CSSは`@keepkit/ui/styles/base.css`、`button.css`、`collection.css`、`sync.css`から読み込めます。`KeepButton icons={{ save, saved, remove }}`と`iconOnly`でLucide等へ差し替えられます。
138
+ `KeepQuickEditor.closeLabel`で終了ボタンの文言を指定できます。`debounceMs={0}`による手動保存は維持され、完了・Escapeでの終了は保存成功後に行います。単独のエディターはTabを閉じ込めません。
137
139
 
138
- Viewer向け保存カードとカスタムテーマは次のように構成できます。`savedAt`、タイトル、タグ、詳細リンク、保存解除ボタン、期限切れ表示は`KeepItemCard`の標準markupに含まれます。
140
+ ### 用途別のコンポーネント
139
141
 
140
- ```tsx
141
- import "@keepkit/ui/theme.css";
142
- import { KeepItemCard, KeepThemeProvider } from "@keepkit/ui";
143
-
144
- <KeepThemeProvider
145
- theme="rounded"
146
- variables={{ "--keep-primary": "oklch(0.55 0.2 250)", "--keep-card-gap": "0.75rem" }}
147
- >
148
- <KeepItemCard
149
- item={item}
150
- href={`/guide/${item.id}`}
151
- getImageProps={(entry) => ({ src: entry.meta.image, alt: entry.meta.title })}
152
- />
153
- </KeepThemeProvider>;
154
- ```
142
+ | 用途 | API |
143
+ | --- | --- |
144
+ | 未分類の整理・検索条件の保存 | `keep.Inbox`、`keep.SavedViews` |
145
+ | コレクション管理 | `keep.CollectionManager` |
146
+ | 画面一式 | `keep.Workspace`。`basic` / `standard` / `management` / `sync`プリセット |
147
+ | メモ・タグ・保存直後の編集 | `KeepNoteEditor`、`KeepTagEditor`、`KeepSavePopover`、`KeepQuickEditor` |
148
+ | 再発見・巡回・並び替え | `KeepRediscoveryPanel`、`KeepTourBar`、`KeepFloatingTour`、`KeepReorderableList` |
149
+ | 復元・保存対象の状態・同期状態 | `KeepUndo`、`keep.Backup`、`KeepItemStatusBadge`、`KeepSyncStatusBanner`、`KeepSyncRecoveryDialog` |
155
150
 
156
- 状態は色だけに依存せず、ラベルと属性でも利用できます。`[data-state="saved"]`、`[data-state="unsaved"]`、`[data-loading="true"]`、`[data-state="error"]`、`[data-state="empty"]`、`[data-state="stale"]`、`[data-status="expired"]`、`[data-status="removed"]`、`[data-state="selected"]`をホストCSSやTailwindのdata variantから参照できます。既存テーマから移行する場合は、`@keepkit/ui/theme.css`を残したまま`--keepkit-*`参照を`--keep-*`へ置き換えてください。Pages Routerでは`createNextPagesRouterAdapter(router)`を`urlAdapter`へ注入します。
151
+ 各コンポーネントは同じProvider内に配置します。`renderItem`、slots、render propsで独自レイアウトへ組み込めます。
152
+ `KeepItemCard`の`Link` / `Media` / `Content` / `Title` / `Tags` / `Actions`でカードの一部だけを組み替えることもできます。
157
153
 
158
- 一覧のqueryは次の形式に統一されています。
154
+ ### テーマとアクセシビリティ
159
155
 
160
- ```tsx
161
- const query = {
162
- targetType: "article",
163
- tags: ["read"],
164
- search: { query: "react", mode: "and" as const },
165
- sort: { by: "updatedAt" as const, direction: "desc" as const },
166
- pagination: { page: 1, pageSize: 20 },
167
- };
156
+ 通常は`@keepkit/ui/theme.css`を読み込みます。Tailwind CSS v4/shadcnではグローバルCSSに次を記載します。
157
+
158
+ ```css
159
+ @import "tailwindcss";
160
+ @import "@keepkit/ui/tailwind.css";
168
161
  ```
169
162
 
170
- 保存操作にはID付きの最小入力を渡します。保存・更新時刻はKeepKitが管理します。
163
+ Providerの`theme="ocean"`や`mode="light" | "dark" | "system"`、`density`、`radius`で見た目を調整できます。
164
+ `--keep-*`変数で上書きでき、Tailwind連携ではホストの色変数を継承します。
171
165
 
172
- ```tsx
173
- const article = { id: "article-123", targetType: "article", meta: { title, url } };
174
- const item = keep.useItem(article);
175
- ```
166
+ 操作はキーボード・ARIAラベル・状態通知に対応します。`data-state`、`data-loading`、`data-disabled`は独自CSSでも利用できます。
167
+ カード一覧は矢印キー・Home・Endで移動でき、`trackOpen`を指定したカードでのみ開封を記録します。
168
+
169
+ ### 保存と同期
176
170
 
177
- 高度なフレームワーク中立APIは`@keepkit/core/core`、低レベルのReact APIは`@keepkit/core/react`、ストレージ実装は`@keepkit/core/storage`から利用できます。
171
+ ブラウザー内保存はIndexedDB優先・localStorage fallbackです。端末間同期にはアプリ側のdriver・認証・サーバーAPIが必要です。
172
+ バックアップは保存アイテム・コレクション定義・所属を含み、閲覧履歴・鑑賞記録・進行位置は含みません。
173
+ **Replace(置換)は既存データを置き換え、ロールバックしません。**
174
+
175
+ 保存・同期の契約は[Core README](../keepkit/README.md)、デモとNext.jsサンプルは[リポジトリREADME](../../README.md)を参照してください。
178
176
 
179
177
  ## English
180
178
 
181
- The standard React package for KeepKit. It includes `@keepkit/core` and provides a single typed provider, save button, and searchable/sortable/paginated collection workflow.
179
+ React UI for KeepKit, including `@keepkit/core`, with a shared provider for save buttons and collections.
180
+ CSS is optional: use the supplied theme or your own styles. Requires React 18 or later.
181
+
182
+ ### Getting started
182
183
 
183
184
  ```bash
184
185
  pnpm add @keepkit/ui
185
186
  ```
186
187
 
187
188
  ```tsx
189
+ import "@keepkit/ui/theme.css";
188
190
  import { createBrowserStorageAdapter, createKeepKit } from "@keepkit/ui";
189
191
 
190
192
  type ArticleMeta = { title: string; url: string };
191
193
  const keep = createKeepKit<ArticleMeta>({
192
- storage: createBrowserStorageAdapter({ key: "articles" }),
193
- labels: { save: "Save", remove: "Remove" },
194
+ storage: createBrowserStorageAdapter({ key: "my-app:items" }),
195
+ locale: "en",
194
196
  });
195
197
 
196
- function SavedArticles() {
198
+ export function App() {
197
199
  return (
198
200
  <keep.Provider>
201
+ <keep.Button
202
+ item={{
203
+ id: "article-123",
204
+ targetType: "article",
205
+ meta: { title: "Example article", url: "/articles/123" },
206
+ }}
207
+ />
199
208
  <keep.Collection query={{ targetType: "article" }} />
200
209
  </keep.Provider>
201
210
  );
202
211
  }
203
212
  ```
204
213
 
205
- `keep.Collection` includes search, sorting, pagination, loading/empty/error states, and polite live announcements. Search is debounced by 300ms by default. Enable `features={{ tagFilter: true, bulkActions: true }}` for tag filtering and bulk operations. Use the individual `KeepList`, `KeepSearchInput`, `KeepSortSelect`, `KeepPagination`, `KeepItemCheckbox`, and `KeepTagEditor` primitives when you need a custom layout. `KeepBulkActions` supports render props and exposes `isAllSelected` / `toggleSelectAll` for visible-item selection. `KeepNoteEditor` auto-saves dirty notes after 300ms by default; set `debounceMs={0}` to use form submission only. Mount `KeepAnnouncer` (`KeepAnnouncements` alias) when you need the live region explicitly.
214
+ `createKeepKit<TMeta>()` returns components and hooks sharing your metadata type.
215
+ Use `locale` for built-in labels and `labels` for overrides. Sixteen languages are supported.
216
+
217
+ ### Extend the collection
206
218
 
207
- Use `<keep.Inbox />` to triage unassigned items. It enables batch collection moves, archive/pin actions, and card note/tag editing. `KeepCollection features={{ savedViews: true }}` saves the current query and supports applying, renaming, pinning, and deleting saved queries. `KeepWorkspace modules={{ inbox: true, savedViews: true }}` opts into both. Saved Views use the separate `keepkit:saved-views` localStorage key.
208
- Pass `revealRequest={{ requestId, itemId }}` to return to an item from a save confirmation; `onRevealResult` reports the outcome after search, tag, collection, and pagination state is adjusted.
209
- `KeepWorkspace` composes these primitives into `basic`, `standard`, `management`, and `sync` presets. `createKeepKit()` exposes the same implementation as a typed `keep.Workspace`. Override individual areas through `modules`, `slots`, and child-component props.
210
- `KeepCollectionManager` is a headless collection-management UI for creating, renaming, deleting, and counting collections. Toggle each capability with `allowCreate`, `allowRename`, `allowDelete`, and `showCounts`; customize `collectionLabels`, `title`, `description`, and `empty`.
211
- Standard browser storage restores empty collections and renamed labels after reload. Custom `StorageAdapter` implementations can persist them by implementing `getCollections`, `setCollection`, and `removeCollection`.
212
- Use `surface="panel"` or a per-region `surface` map together with `sectionGap="compact" | "comfortable"` to make workspace boundaries explicit. Empty slots do not create frames, and omitted `surface` or `surface="plain"` preserves the existing DOM order.
219
+ `keep.Collection` includes search, sorting, pagination, and loading, empty, and error states.
220
+ Search is debounced by 300ms by default. Enable additional controls through `features`.
213
221
 
214
222
  ```tsx
215
- const keep = createKeepKit<ArticleMeta>({ storage, locale: "en" });
223
+ export function Library() {
224
+ return (
225
+ <keep.Provider>
226
+ <keep.Collection
227
+ query={{ targetType: "article" }}
228
+ layout="auto"
229
+ urlSync
230
+ features={{ tagFilter: true, collectionFilter: true, bulkActions: true, savedViews: true }}
231
+ itemCardProps={{ href: (item) => item.meta.url }}
232
+ />
233
+ <keep.Backup />
234
+ </keep.Provider>
235
+ );
236
+ }
237
+ ```
238
+
239
+ Choose `list`, `grid`, `compact`, or container-responsive `auto` for `layout`.
240
+ `urlSync` synchronizes search, tags, sorting, and pagination with the URL and browser history.
241
+ For Next.js Pages Router, pass `createNextPagesRouterAdapter(router)` as `urlAdapter`.
242
+
243
+ With `reorderable`, collections without an explicit sort default to manual order. The selector also supports date sorting; reorder handles appear only in manual order without `pinnedFirst`. Reordering replaces only the positions occupied by visible items, preserving other pages and hidden items. Arrow keys save immediately, Escape releases the grabbed item, and the existing five-second Undo restores committed order.
244
+
245
+ Pass `onManualSort` to a standalone `KeepSortSelect` to enable `value="manual"`. Its existing `onValueChange(value, sort)` callback still handles date sorts only. Manual-order URLs and Saved Views omit `sort`. Enabled URL synchronization takes priority; omitted `sort` clears the previous date sort. Ordinary collections fall back to newest update first. Unchanged URLs do not navigate; history defaults to push, with replace available through `urlSync={{ history: "replace" }}`.
246
+
247
+ Unassigned Saved Views use `organization.collection="unassigned"`. Host-supplied function filters remain unserializable. `revealRequest` clears local search, tag, organization, and date constraints, but returns `excluded` for items rejected by the host's fixed `targetType` or `filter`. `creatable` and `slots.toolbarEnd` can be combined.
248
+
249
+ ### Revisit articles and links
250
+
251
+ The reading presentation is opt-in; existing defaults are preserved.
252
+
253
+ Default `linkTarget="card"` links ordinary media and static content, placing tags, actions, and edit forms outside the link. Custom images and entire `children` / `render` bodies are no longer automatically wrapped. Compound `Title` supplies a title link. Use `KeepItemCard.Link` to explicitly wrap non-interactive content in custom layouts. It shares the root URL, router `linkComponent`, external-link attributes, availability, and `trackOpen` / `onOpen`. Nested `Title` is static, and `Content` omits automatic tags. Keep custom buttons and forms outside the link as well.
216
254
 
217
- <keep.Provider>
218
- <keep.Workspace preset="sync" collectionProps={{ layout: "auto" }} />
219
- </keep.Provider>;
255
+ ```tsx
256
+ <keep.Collection
257
+ layout="list"
258
+ query={{ sort: { by: "savedAt", direction: "desc" }, pinnedFirst: true }}
259
+ features={{ bulkActions: true, pin: true, archive: true }}
260
+ bulkActionsVariant="inline"
261
+ itemCardProps={{ presentation: "reading", href: (item) => item.meta.url, trackOpen: true }}
262
+ />
220
263
  ```
221
- Enable only the standard card features you need with `features={{ pin: true, archive: true, tags: false }}`. `pin` and `archive` toggle card action buttons, while `tags` controls tag display inside cards. Tag filtering remains independently controlled by `tagFilter`, tag editing by `KeepTagEditor`, and explicit `itemCardProps` values take precedence over `features`.
222
- `KeepCollection` renders the current search and tag filters as `KeepActiveFiltersSummary` chips with individual removal and a “Clear all filters” action. Replace that area with the `activeFilters` slot. Default `KeepList` / `KeepCollection` output distinguishes `empty-storage` from `empty-filtered`; the filtered state includes a reset button when `onClearFilters` is provided.
223
- Set `toolbarLayout="grouped"` and `toolbarVariant="panel"` to render host `slots.toolbarStart` / `slots.toolbarEnd`, query controls, and filters as localized `role="group"` regions. The query and filter groups stack their controls at narrow widths.
224
-
225
- The opt-in theme adds neutral borders, surfaces, shadows, focus treatment, and decorative action icons without changing accessible names. Regular remove, bulk-delete, and stale-prune actions use a subtle red outline and text with a light hover surface; solid red is reserved for error states that need confirmation. Target individual controls with `data-keep-action`, or override `--keep-icon-size`, `--keep-control-gap`, `--keep-shadow`, `--keep-success`, and `--keep-warning`. Consumers that omit the CSS keep the headless markup, and `KeepButton icons` continues to take precedence over the built-in icon.
226
- `KeepItemCard` accepts `href`, `onOpen`, `linkTarget`, and `linkComponent` for detail-page navigation. Links are disabled for unavailable `status` values such as private or expired. `KeepBackup` provides JSON export, merge/replace import, result counts, and quota-error messaging.
227
- `KeepTourBar` (aliased as `KeepNavigator`) provides progress, previous/next, and return-to-list actions through URLs or callbacks. Inject host routing with `getItemHref`, `getBackHref`, and `onNavigate`. Adjacent item titles are previewed below the navigation labels; customize them with `getItemTitle`. Set `keyboardShortcuts` for J/K or ]/[ tour navigation, or use `useKeepTourShortcuts` for custom bindings. `KeepReorderableList` supports drag and keyboard reordering and shows the active insertion position; `KeepCollection reorderable` includes that path and standard undo without a slot replacement.
228
- `KeepTourProvider` / `useKeepTour` manage a session-scoped tour, and `KeepFloatingTour` renders controls in a body portal so the host layout needs no reserved space. Start with `start({ itemIds })`, configure `position`, `offset`, `zIndex`, and routing callbacks. Same-tab state resumes from `sessionStorage`; set `tour={{ sessionKey }}` on `KeepKitProvider` to namespace it.
229
- `KeepShortcutHint` renders semantic `<kbd>` badges. `KeepTourBar showShortcutHint` displays the previous/next keys, while `KeepNoteEditor showShortcutHint` displays `Ctrl+Enter` in the save button. `mergeProps` / `createSlot` compose className, style, ARIA, events, and child/parent refs for `asChild` slots; `composeRefs` combines callback and object refs. Filter chips restore focus to an adjacent chip after removal and support ArrowLeft / ArrowRight navigation.
230
- `KeepFloatingTour` is a fixed portal-rendered tour control that does not consume page layout space. Use `KeepTourProvider` / `useKeepTour` to start an ordered session with `start({ itemIds })` and configure host routing with `getItemHref`, `getBackHref`, or `onNavigate`.
231
- Cards rendered by `KeepList` and `KeepCollection` highlight case-insensitive search matches with `<mark class="keep-highlight" data-highlight="true">`. Use `highlightQuery` on a standalone `KeepItemCard` or `KeepHighlight` for arbitrary text. `KeepItemCard.Media` exposes its loading state through `data-media-status` and replaces failed images with `fallback` or the built-in SVG placeholder.
232
- The theme defines WCAG-oriented `--keep-highlight-bg` / `--keep-highlight-fg` pairs for light and dark modes, clamps titles to two lines and memo previews to three, and reserves a stable media aspect ratio. `KeepItemStatusBadge` combines visible status text with check, clock, ban, or lock SVG icons; import `@keepkit/ui/styles/status.css` when using the status styles independently.
233
- External detail URLs receive `target="_blank"` and `rel="noreferrer"` defaults. Unavailable cards expose `aria-disabled="true"` and normalized `data-item-status` values, and the sync recovery dialog compares local and remote updated dates and notes side by side.
234
- Choose `cardVariant="outlined" | "elevated" | "filled"` for card surfaces. Override `--keep-card-border` / `--keep-card-shadow` and `--keep-surface-border` / `--keep-surface-background` independently for cards, toolbars, and workspace regions.
235
-
236
- During initial loading, `KeepList` renders six layout-matched `KeepItemCardSkeleton` placeholders by default. Change the count with `loadingCount`, or replace them with the existing `loading` prop or its `renderLoading` alias. `layout="auto"` responds to the available container width rather than viewport width, so embedded sidebars and dialogs collapse to one column. Skeleton pulses become static under `prefers-reduced-motion`.
237
- Card groups use Roving Tabindex, so a focused card can move to adjacent cards with arrow keys or jump with Home and End.
238
-
239
- Use the compound parts to rearrange only the card regions you own while preserving image alt text, linked headings, the labelled tag list, and action state:
240
264
 
241
265
  ```tsx
242
- <KeepItemCard item={item} href={`/items/${item.id}`} getImageProps={getImageProps}>
243
- <KeepItemCard.Media fallback="No image" />
244
- <KeepItemCard.Content>
245
- <KeepItemCard.Title />
246
- <KeepItemCard.Tags />
247
- </KeepItemCard.Content>
266
+ <KeepItemCard item={item} href={item.meta.url} trackOpen>
267
+ <KeepItemCard.Link>
268
+ <KeepItemCard.Media />
269
+ <KeepItemCard.Content />
270
+ </KeepItemCard.Link>
271
+ <KeepItemCard.Tags />
248
272
  <KeepItemCard.Actions />
249
273
  </KeepItemCard>
250
274
  ```
251
275
 
252
- `onFeedback` on `KeepKitProvider` / `KeepUiProvider` receives `item-saved`, `item-removed`, `item-restored`, `sync-completed`, `sync-failed`, and `stale-pruned`. Override text with the existing `labels: { save: "Save" }` form and configure text or visibility with `labelOptions: { collection: { text: "Category", visible: false } }`; required ARIA names remain available when visible text is hidden. Removal events include an `undo` function and locale-aware `undoLabel`. Connect a Sonner-compatible function without adding a package dependency:
276
+ `presentation="reading"` shows the title, URL source, collection name, note, tags, and save/open information. Images appear only when supplied through `getImageProps`. It hides the save toggle and shows editing, notes, and activity by default; existing visibility flags override these defaults. Supply `href` and `trackOpen` explicitly. Editing uses 300ms autosave and Done, retaining the draft on failure.
253
277
 
254
- ```tsx
255
- const onFeedback = useKeepToastFeedback(toast);
256
- <KeepKitProvider storage={storage} onFeedback={onFeedback}>{children}</KeepKitProvider>;
257
- ```
278
+ `bulkActionsVariant="inline"` selects items on their article rows. Select-all targets only the current page; changes to search, filters, page, or view clear selection. Failed bulk operations retain selection. The default `separate` preserves the existing selection list.
258
279
 
259
- v0.28.8 refreshes the personal link library demo with Inbox, Pinned, Unread, Archive, and collection workflows. v0.28.8 strengthened scope-aware merging, concurrent membership changes, and same-key updates to history, viewing records, and progress. Inbox triage, Saved Views, activity tracking, Rediscovery, and removable active-filter summaries remain available.
260
- Phase 4 adds `KeepItemStatusBadge`, `KeepStaleNotice`, `KeepPruneStaleButton`, `KeepSyncStatusBanner`, and `KeepSyncRecoveryDialog` for unavailable items, sync failures, conflict resolution, and backup recovery. Import `@keepkit/ui/theme.css` or `@keepkit/ui/tailwind.css` for the opt-in theme layer.
280
+ For custom rows, pass `KeepListSelection` (`selectedIds: readonly string[]`, `onSelectedIdsChange`, optional `disabled`) to `KeepList.selection`. The third argument of `KeepList` and `KeepCollection`'s `renderItem(item, state, selection?)` is `KeepItemSelection` (`checked`, `onCheckedChange`, optional `disabled`), ready to spread onto `KeepItemCheckbox`. Existing two-argument callbacks still work.
261
281
 
262
- ### Tailwind and shadcn theme
282
+ `KeepBulkActions` and `KeepCollection` default `confirmRemoval` to false. Enable it to show the count and confirm/cancel controls before removal. Confirmation freezes all selected IDs, including selections outside the page, and cancels when selection, scope, or query changes. Failures can be retried; successful removal retains existing Undo. Render props expose `removalConfirmation`, `requestRemoval()`, `confirmRemoval()`, and `cancelRemoval()`.
263
283
 
264
- ```css
265
- /* globals.css */
266
- @import "tailwindcss";
267
- @import "@keepkit/ui/tailwind.css";
284
+ ```tsx
285
+ <keep.Collection confirmRemoval features={{ bulkActions: true }} />
268
286
  ```
269
287
 
288
+ ### Compare and restore fallback branches
289
+
290
+ `KeepFallbackRecovery` works independently of KeepProvider and accepts the target adapter's `recovery` explicitly. Display and inspection do not write. Select the source for conflicting records, review dependent membership changes, then apply. Unresolved conflicts or inconsistent relationships prevent applying. Changed data requires another inspection. A pending projection means the repair is already saved: retry it instead of submitting it again.
291
+
270
292
  ```tsx
271
- import { KeepThemeProvider, KeepCollection } from "@keepkit/ui";
293
+ import { createBrowserStorageAdapter, KeepFallbackRecovery, KeepUiProvider } from "@keepkit/ui";
294
+
295
+ const storage = createBrowserStorageAdapter({ key: "my-app:items", scope: { userId: "alice" } });
272
296
 
273
- <KeepThemeProvider theme="ocean" mode="system" density="comfortable" radius="medium">
274
- <KeepCollection layout="grid" />
275
- </KeepThemeProvider>;
297
+ function RecoveryScreen() {
298
+ return storage.recovery ? (
299
+ <KeepUiProvider locale="en">
300
+ <KeepFallbackRecovery recovery={storage.recovery} />
301
+ </KeepUiProvider>
302
+ ) : null;
303
+ }
276
304
  ```
277
305
 
278
- Color themes include `default`, `ocean`, `forest`, `sunset`, and `lavender`. Existing `compact`, `minimal`, `rounded`, `high-contrast`, and `dark` presets remain available. `theme` composes independently with `mode`, `density`, and `radius`, so `theme="forest" mode="dark"` is supported. Use the exported `keepThemeNames` list when building a selector.
306
+ A `SyncStorageAdapter` exposes status only. Repair through a standalone local adapter before starting sync. Pre-repair backups are not automatically deleted. Refresh all older tabs when adopting this journal, and check the storage limits in the [Core guide](../keepkit/README.md).
279
307
 
280
- The scoped `--keep-*` tokens inherit complete Tailwind v4 `--color-*` values from shadcn/ui when present. KeepKit does not replace the host's generic color aliases; its Tailwind aliases are namespaced as `--color-keep-*`. The provider supports `.dark`, system preference, `variables`, `accentColor`, `highContrast`, and `reducedMotion`. Use `keepKitTheme` from `@keepkit/ui/tailwind`, feature CSS from `@keepkit/ui/styles/*`, and `icons={{ save, saved, remove }}` / `iconOnly` on `KeepButton` for Lucide or shadcn replacements. The existing Next.js Pages Router recipe remains unchanged: inject `createNextPagesRouterAdapter(router)` into `urlAdapter`.
308
+ Use `KeepQuickEditor.closeLabel` to customize the completion button. Manual saving with `debounceMs={0}` is preserved; completion and Escape close only after successful saving. Standalone editors do not trap Tab.
281
309
 
282
- For a Viewer card, the default `KeepItemCard` markup includes the title, tags, saved date, detail link, remove action, thumbnail, and expired-item notice. Override tokens without replacing the markup, or use render props for a complete replacement:
310
+ ### Components by task
283
311
 
284
- ```tsx
285
- import "@keepkit/ui/theme.css";
286
- import { KeepItemCard, KeepThemeProvider } from "@keepkit/ui";
287
-
288
- <KeepThemeProvider
289
- theme="rounded"
290
- variables={{ "--keep-primary": "oklch(0.55 0.2 250)", "--keep-card-gap": "0.75rem" }}
291
- >
292
- <KeepItemCard
293
- item={item}
294
- href={`/guide/${item.id}`}
295
- getImageProps={(entry) => ({ src: entry.meta.image, alt: entry.meta.title })}
296
- />
297
- </KeepThemeProvider>;
298
- ```
312
+ | Task | API |
313
+ | --- | --- |
314
+ | Inbox and saved queries | `keep.Inbox`, `keep.SavedViews` |
315
+ | Collection management | `keep.CollectionManager` |
316
+ | Complete screen | `keep.Workspace` with `basic` / `standard` / `management` / `sync` presets |
317
+ | Notes, tags, and editing after saving | `KeepNoteEditor`, `KeepTagEditor`, `KeepSavePopover`, `KeepQuickEditor` |
318
+ | Rediscovery, tours, and ordering | `KeepRediscoveryPanel`, `KeepTourBar`, `KeepFloatingTour`, `KeepReorderableList` |
319
+ | Undo, backup, availability, and sync | `KeepUndo`, `keep.Backup`, `KeepItemStatusBadge`, `KeepSyncStatusBanner`, `KeepSyncRecoveryDialog` |
320
+
321
+ Place components under the same provider. Use `renderItem`, slots, or render props for custom layouts.
322
+ Rearrange card regions through `KeepItemCard.Link` / `Media` / `Content` / `Title` / `Tags` / `Actions`.
299
323
 
300
- Use `[data-state="saved"]`, `[data-state="unsaved"]`, `[data-loading="true"]`, `[data-state="error"]`, `[data-state="empty"]`, `[data-state="stale"]`, `[data-status="expired"]`, `[data-status="removed"]`, and `[data-state="selected"]` from host CSS or Tailwind data variants. For migration, keep importing `@keepkit/ui/theme.css` while replacing direct `--keepkit-*` references with `--keep-*`. In the Pages Router, inject `createNextPagesRouterAdapter(router)` into `urlAdapter`.
324
+ ### Theme and accessibility
301
325
 
302
- Collection queries use one canonical shape: `targetType`, `tags`, `search`, `sort`, `pagination`, `filter`, and `savedBetween`. Saved item inputs contain only `id`, `meta`, `targetType`, `note`, and `tags`; KeepKit owns persistence timestamps.
303
- For rediscovery, use `useKeepItem(item).recordOpen()` to persist `lastOpenedAt`, then query `activity` with `opened`, `lastOpenedBefore`, `lastOpenedAfter`, or `inactiveForMs`. `inactiveForMs` uses `savedAt` for never-opened items and `lastOpenedAt` for opened items; recording an open does not change `updatedAt`. `createRediscoveryQuery()` / `useKeepRediscovery()` provide standard `never-opened`, `forgotten`, and `recently-opened` views. `<KeepRediscovery>` remains the low-level list, while `<KeepRediscoveryPanel>` adds an explanation and Activity badges. `KeepItemCard trackOpen` opts into tracking without changing existing cards.
326
+ Import `@keepkit/ui/theme.css` for the standard theme. For Tailwind CSS v4 or shadcn, add these global CSS imports:
327
+
328
+ ```css
329
+ @import "tailwindcss";
330
+ @import "@keepkit/ui/tailwind.css";
331
+ ```
304
332
 
305
- Framework-neutral APIs remain available from `@keepkit/core/core`, low-level React bindings from `@keepkit/core/react`, and storage adapters from `@keepkit/core/storage`.
333
+ Configure the provider with `theme="ocean"`, `mode="light" | "dark" | "system"`, `density`, and `radius`.
334
+ Override `--keep-*` variables as needed; the Tailwind integration inherits host color variables.
306
335
 
307
- ## Archive, pin, collections, and quick save editing
336
+ Controls support keyboard interaction, ARIA labels, and live announcements. Use `data-state`, `data-loading`, and `data-disabled` in custom CSS.
337
+ Card lists support arrow keys, Home, and End. Cards record opens only when `trackOpen` is enabled.
308
338
 
309
- The UI package exports `KeepArchiveButton`, `KeepArchiveScopeSelect`, `KeepPinButton`, `KeepCollectionSelect`, `KeepCollectionFilter`, `KeepSavePopover`, `KeepQuickEditor`, and `useKeepQuickEditor`. `KeepCollection archiveScope="active" | "archived" | "all"` provides a localized scope selector and URL synchronization; `reorderable` provides standard drag/keyboard ordering and undo. Buttons expose `aria-pressed`, `data-archived`/`data-pinned`, and `data-keep-action`. Collection labels default to IDs and can be overridden with `collectionLabels`. `KeepItemCard showEditButton` opens the standard QuickEditor dialog and `editSlot` customizes its content. Enable `features={{ collectionFilter: true }}` on `KeepCollection` to include the collection filter. `KeepSavePopover` wraps `KeepButton`, opens after a new save, labels and focuses its dialog, flushes pending edits before closing, and restores focus to the trigger. Its quick editor debounces note, tags, and collection updates by 300ms and exposes `saveStatus`. Set `showSaveButton={false}` when visible save status should replace the submit button. `KeepItemCard.Save` and `KeepItemCard.Remove` let compound cards place those actions alongside `Pin` and `Archive` without replacing the default card API.
339
+ ### Persistence and sync
310
340
 
311
- ## アーカイブ・ピン留め・コレクション・保存直後編集
341
+ Browser storage prefers IndexedDB with a localStorage fallback. Cross-device sync needs your app's driver, authentication, and server APIs.
342
+ Backups include saved items, collection definitions, and memberships; history, viewing records, and progress are excluded.
343
+ **Replace imports overwrite existing data and do not roll back.**
312
344
 
313
- UI パッケージは `KeepArchiveButton`、`KeepArchiveScopeSelect`、`KeepPinButton`、`KeepCollectionSelect`、`KeepCollectionFilter`、`KeepSavePopover`、`KeepQuickEditor`、`useKeepQuickEditor` を公開します。`KeepCollection archiveScope="active" | "archived" | "all"` はローカライズされたスコープ選択とURL同期を、`reorderable` は標準のドラッグ/キーボード並び替えとUndoを提供します。ボタンは `aria-pressed`、`data-archived` / `data-pinned`、`data-keep-action` を出力します。`KeepItemCard showEditButton` は標準QuickEditor dialogを開き、`editSlot`で内容を差し替えられます。コレクション名は既定で ID を表示し、`collectionLabels` で置換できます。`KeepCollection` に `features={{ collectionFilter: true }}` を指定するとフィルターを統合できます。`KeepSavePopover` は `KeepButton` を内部 trigger とし、新規保存後にdialogへフォーカスし、閉じる前に未保存編集をflushしてtriggerへフォーカスを戻します。クイックエディターはメモ・タグ・コレクションを一時状態として扱い、既定300msで保存し、`saveStatus`で状態を公開します。自動保存だけを表示する場合は`showSaveButton={false}`を指定します。compound cardでは`KeepItemCard.Save` / `Remove`を`Pin` / `Archive`と同じ操作領域に配置できます。
345
+ See the [Core README](../keepkit/README.md) for persistence contracts and the [repository README](../../README.md) for demos and Next.js examples.