@keepkit/ui 0.28.8 → 0.28.9

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,254 @@
2
2
 
3
3
  [日本語](#日本語) | [English](#english)
4
4
 
5
+ Release: v0.28.9
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)を使えます。
60
-
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順序を維持します。
69
+ `layout`は`list`、`grid`、`compact`、コンテナ幅に追従する`auto`から選べます。
70
+ `urlSync`は検索・タグ・ソート・ページをURLと戻る/進むに同期します。
71
+ Next.js Pages Routerでは`createNextPagesRouterAdapter(router)`を`urlAdapter`に渡します。
68
72
 
69
- ```tsx
70
- const keep = createKeepKit<ArticleMeta>({ storage, locale: "ja" });
73
+ ### 記事・リンクを再訪する一覧
71
74
 
72
- <keep.Provider>
73
- <keep.Workspace preset="sync" collectionProps={{ layout: "auto" }} />
74
- </keep.Provider>;
75
- ```
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ラベル、保存操作の状態は各パーツでも維持されます。
75
+ 記事向け表示は選択式です。既存の既定表示は変わりません。
91
76
 
92
77
  ```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>
105
- </KeepItemCard>
78
+ <keep.Collection
79
+ layout="list"
80
+ query={{ sort: { by: "savedAt", direction: "desc" }, pinnedFirst: true }}
81
+ features={{ bulkActions: true, pin: true, archive: true }}
82
+ bulkActionsVariant="inline"
83
+ itemCardProps={{ presentation: "reading", href: (item) => item.meta.url, trackOpen: true }}
84
+ />
106
85
  ```
107
86
 
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行で接続できます(ライブラリ依存は追加されません)。
87
+ `presentation="reading"`はタイトル、URLの保存元、コレクション名、メモ、タグ、保存・訪問情報を表示します。画像は`getImageProps`で指定した場合だけ表示します。保存トグルは既定で非表示、編集・メモ・訪問情報は表示され、既存の表示フラグで上書きできます。`href`と`trackOpen`は明示指定です。編集は300msの自動保存と「完了」を使い、失敗時は下書きを残します。
109
88
 
110
- ```tsx
111
- const onFeedback = useKeepToastFeedback(toast);
112
- <KeepKitProvider storage={storage} onFeedback={onFeedback}>{children}</KeepKitProvider>;
113
- ```
89
+ `bulkActionsVariant="inline"`は記事行で選択します。全選択は現在ページだけで、検索・フィルター・ページ・表示先を変えると選択を解除します。失敗した一括操作は選択を保持します。既定の`separate`は従来の選択用一覧を維持します。
114
90
 
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を有効にできます。
91
+ 独自の行には`KeepListSelection`(`selectedIds: readonly string[]`、`onSelectedIdsChange`、任意の`disabled`)を`KeepList.selection`に渡せます。`KeepList`と`KeepCollection`の`renderItem(item, state, selection?)`の第三引数は`KeepItemSelection`(`checked`、`onCheckedChange`、任意の`disabled`)で、`KeepItemCheckbox`にそのまま渡せます。従来の二引数コールバックも使用できます。
117
92
 
118
- ### Tailwind/shadcnテーマ
119
-
120
- ```css
121
- /* globals.css */
122
- @import "tailwindcss";
123
- @import "@keepkit/ui/tailwind.css";
124
- ```
93
+ `KeepQuickEditor.closeLabel`で終了ボタンの文言を指定できます。`debounceMs={0}`による手動保存は維持され、完了・Escapeでの終了は保存成功後に行います。単独のエディターはTabを閉じ込めません。
125
94
 
126
- ```tsx
127
- import { KeepThemeProvider, KeepCollection } from "@keepkit/ui";
95
+ ### 用途別のコンポーネント
128
96
 
129
- <KeepThemeProvider theme="ocean" mode="system" density="comfortable" radius="medium">
130
- <KeepCollection layout="grid" />
131
- </KeepThemeProvider>;
132
- ```
97
+ | 用途 | API |
98
+ | --- | --- |
99
+ | 未分類の整理・検索条件の保存 | `keep.Inbox`、`keep.SavedViews` |
100
+ | コレクション管理 | `keep.CollectionManager` |
101
+ | 画面一式 | `keep.Workspace`。`basic` / `standard` / `management` / `sync`プリセット |
102
+ | メモ・タグ・保存直後の編集 | `KeepNoteEditor`、`KeepTagEditor`、`KeepSavePopover`、`KeepQuickEditor` |
103
+ | 再発見・巡回・並び替え | `KeepRediscoveryPanel`、`KeepTourBar`、`KeepFloatingTour`、`KeepReorderableList` |
104
+ | 復元・保存対象の状態・同期状態 | `KeepUndo`、`keep.Backup`、`KeepItemStatusBadge`、`KeepSyncStatusBanner`、`KeepSyncRecoveryDialog` |
133
105
 
134
- 色テーマは`default`、`ocean`、`forest`、`sunset`、`lavender`から選べます。既存の`compact`、`minimal`、`rounded`、`high-contrast`、`dark`も引き続き利用できます。`theme`は`mode`、`density`、`radius`と独立しており、`KeepKitProvider theme="forest" mode="dark"`のように組み合わせられます。選択肢をUIへ表示する場合は`keepThemeNames`を利用できます。
106
+ 各コンポーネントは同じProvider内に配置します。`renderItem`、slots、render propsで独自レイアウトへ組み込めます。
107
+ `KeepItemCard`の`Media` / `Content` / `Title` / `Tags` / `Actions`でカードの一部だけを組み替えることもできます。
135
108
 
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等へ差し替えられます。
109
+ ### テーマとアクセシビリティ
137
110
 
138
- Viewer向け保存カードとカスタムテーマは次のように構成できます。`savedAt`、タイトル、タグ、詳細リンク、保存解除ボタン、期限切れ表示は`KeepItemCard`の標準markupに含まれます。
111
+ 通常は`@keepkit/ui/theme.css`を読み込みます。Tailwind CSS v4/shadcnではグローバルCSSに次を記載します。
139
112
 
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>;
113
+ ```css
114
+ @import "tailwindcss";
115
+ @import "@keepkit/ui/tailwind.css";
154
116
  ```
155
117
 
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`へ注入します。
118
+ Providerの`theme="ocean"`や`mode="light" | "dark" | "system"`、`density`、`radius`で見た目を調整できます。
119
+ `--keep-*`変数で上書きでき、Tailwind連携ではホストの色変数を継承します。
157
120
 
158
- 一覧のqueryは次の形式に統一されています。
159
-
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
- };
168
- ```
121
+ 操作はキーボード・ARIAラベル・状態通知に対応します。`data-state`、`data-loading`、`data-disabled`は独自CSSでも利用できます。
122
+ カード一覧は矢印キー・Home・Endで移動でき、`trackOpen`を指定したカードでのみ開封を記録します。
169
123
 
170
- 保存操作にはID付きの最小入力を渡します。保存・更新時刻はKeepKitが管理します。
124
+ ### 保存と同期
171
125
 
172
- ```tsx
173
- const article = { id: "article-123", targetType: "article", meta: { title, url } };
174
- const item = keep.useItem(article);
175
- ```
126
+ ブラウザー内保存はIndexedDB優先・localStorage fallbackです。端末間同期にはアプリ側のdriver・認証・サーバーAPIが必要です。
127
+ バックアップは保存アイテム・コレクション定義・所属を含み、閲覧履歴・鑑賞記録・進行位置は含みません。
128
+ **Replace(置換)は既存データを置き換え、ロールバックしません。**
176
129
 
177
- 高度なフレームワーク中立APIは`@keepkit/core/core`、低レベルのReact APIは`@keepkit/core/react`、ストレージ実装は`@keepkit/core/storage`から利用できます。
130
+ 保存・同期の契約は[Core README](../keepkit/README.md)、デモとNext.jsサンプルは[リポジトリREADME](../../README.md)を参照してください。
178
131
 
179
132
  ## English
180
133
 
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.
134
+ React UI for KeepKit, including `@keepkit/core`, with a shared provider for save buttons and collections.
135
+ CSS is optional: use the supplied theme or your own styles. Requires React 18 or later.
136
+
137
+ ### Getting started
182
138
 
183
139
  ```bash
184
140
  pnpm add @keepkit/ui
185
141
  ```
186
142
 
187
143
  ```tsx
144
+ import "@keepkit/ui/theme.css";
188
145
  import { createBrowserStorageAdapter, createKeepKit } from "@keepkit/ui";
189
146
 
190
147
  type ArticleMeta = { title: string; url: string };
191
148
  const keep = createKeepKit<ArticleMeta>({
192
- storage: createBrowserStorageAdapter({ key: "articles" }),
193
- labels: { save: "Save", remove: "Remove" },
149
+ storage: createBrowserStorageAdapter({ key: "my-app:items" }),
150
+ locale: "en",
194
151
  });
195
152
 
196
- function SavedArticles() {
153
+ export function App() {
197
154
  return (
198
155
  <keep.Provider>
156
+ <keep.Button
157
+ item={{
158
+ id: "article-123",
159
+ targetType: "article",
160
+ meta: { title: "Example article", url: "/articles/123" },
161
+ }}
162
+ />
199
163
  <keep.Collection query={{ targetType: "article" }} />
200
164
  </keep.Provider>
201
165
  );
202
166
  }
203
167
  ```
204
168
 
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.
206
-
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.
169
+ `createKeepKit<TMeta>()` returns components and hooks sharing your metadata type.
170
+ Use `locale` for built-in labels and `labels` for overrides. Sixteen languages are supported.
213
171
 
214
- ```tsx
215
- const keep = createKeepKit<ArticleMeta>({ storage, locale: "en" });
172
+ ### Extend the collection
216
173
 
217
- <keep.Provider>
218
- <keep.Workspace preset="sync" collectionProps={{ layout: "auto" }} />
219
- </keep.Provider>;
220
- ```
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:
174
+ `keep.Collection` includes search, sorting, pagination, and loading, empty, and error states.
175
+ Search is debounced by 300ms by default. Enable additional controls through `features`.
240
176
 
241
177
  ```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>
248
- <KeepItemCard.Actions />
249
- </KeepItemCard>
178
+ export function Library() {
179
+ return (
180
+ <keep.Provider>
181
+ <keep.Collection
182
+ query={{ targetType: "article" }}
183
+ layout="auto"
184
+ urlSync
185
+ features={{ tagFilter: true, collectionFilter: true, bulkActions: true, savedViews: true }}
186
+ itemCardProps={{ href: (item) => item.meta.url }}
187
+ />
188
+ <keep.Backup />
189
+ </keep.Provider>
190
+ );
191
+ }
250
192
  ```
251
193
 
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:
194
+ Choose `list`, `grid`, `compact`, or container-responsive `auto` for `layout`.
195
+ `urlSync` synchronizes search, tags, sorting, and pagination with the URL and browser history.
196
+ For Next.js Pages Router, pass `createNextPagesRouterAdapter(router)` as `urlAdapter`.
197
+
198
+ ### Revisit articles and links
199
+
200
+ The reading presentation is opt-in; existing defaults are preserved.
253
201
 
254
202
  ```tsx
255
- const onFeedback = useKeepToastFeedback(toast);
256
- <KeepKitProvider storage={storage} onFeedback={onFeedback}>{children}</KeepKitProvider>;
203
+ <keep.Collection
204
+ layout="list"
205
+ query={{ sort: { by: "savedAt", direction: "desc" }, pinnedFirst: true }}
206
+ features={{ bulkActions: true, pin: true, archive: true }}
207
+ bulkActionsVariant="inline"
208
+ itemCardProps={{ presentation: "reading", href: (item) => item.meta.url, trackOpen: true }}
209
+ />
257
210
  ```
258
211
 
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.
212
+ `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.
261
213
 
262
- ### Tailwind and shadcn theme
263
-
264
- ```css
265
- /* globals.css */
266
- @import "tailwindcss";
267
- @import "@keepkit/ui/tailwind.css";
268
- ```
214
+ `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.
269
215
 
270
- ```tsx
271
- import { KeepThemeProvider, KeepCollection } from "@keepkit/ui";
216
+ 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.
272
217
 
273
- <KeepThemeProvider theme="ocean" mode="system" density="comfortable" radius="medium">
274
- <KeepCollection layout="grid" />
275
- </KeepThemeProvider>;
276
- ```
218
+ 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.
277
219
 
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.
220
+ ### Components by task
279
221
 
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`.
222
+ | Task | API |
223
+ | --- | --- |
224
+ | Inbox and saved queries | `keep.Inbox`, `keep.SavedViews` |
225
+ | Collection management | `keep.CollectionManager` |
226
+ | Complete screen | `keep.Workspace` with `basic` / `standard` / `management` / `sync` presets |
227
+ | Notes, tags, and editing after saving | `KeepNoteEditor`, `KeepTagEditor`, `KeepSavePopover`, `KeepQuickEditor` |
228
+ | Rediscovery, tours, and ordering | `KeepRediscoveryPanel`, `KeepTourBar`, `KeepFloatingTour`, `KeepReorderableList` |
229
+ | Undo, backup, availability, and sync | `KeepUndo`, `keep.Backup`, `KeepItemStatusBadge`, `KeepSyncStatusBanner`, `KeepSyncRecoveryDialog` |
281
230
 
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:
231
+ Place components under the same provider. Use `renderItem`, slots, or render props for custom layouts.
232
+ Rearrange card regions through `KeepItemCard.Media` / `Content` / `Title` / `Tags` / `Actions`.
283
233
 
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
- ```
234
+ ### Theme and accessibility
299
235
 
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`.
236
+ Import `@keepkit/ui/theme.css` for the standard theme. For Tailwind CSS v4 or shadcn, add these global CSS imports:
301
237
 
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.
238
+ ```css
239
+ @import "tailwindcss";
240
+ @import "@keepkit/ui/tailwind.css";
241
+ ```
304
242
 
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`.
243
+ Configure the provider with `theme="ocean"`, `mode="light" | "dark" | "system"`, `density`, and `radius`.
244
+ Override `--keep-*` variables as needed; the Tailwind integration inherits host color variables.
306
245
 
307
- ## Archive, pin, collections, and quick save editing
246
+ Controls support keyboard interaction, ARIA labels, and live announcements. Use `data-state`, `data-loading`, and `data-disabled` in custom CSS.
247
+ Card lists support arrow keys, Home, and End. Cards record opens only when `trackOpen` is enabled.
308
248
 
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.
249
+ ### Persistence and sync
310
250
 
311
- ## アーカイブ・ピン留め・コレクション・保存直後編集
251
+ Browser storage prefers IndexedDB with a localStorage fallback. Cross-device sync needs your app's driver, authentication, and server APIs.
252
+ Backups include saved items, collection definitions, and memberships; history, viewing records, and progress are excluded.
253
+ **Replace imports overwrite existing data and do not roll back.**
312
254
 
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`と同じ操作領域に配置できます。
255
+ See the [Core README](../keepkit/README.md) for persistence contracts and the [repository README](../../README.md) for demos and Next.js examples.