@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 +150 -208
- package/dist/index.d.ts +21 -5
- package/dist/index.js +704 -444
- package/dist/index.js.map +1 -1
- package/dist/styles/base.css +17 -9
- package/dist/styles/collection.css +153 -1
- package/package.json +2 -2
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
|
|
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
|
|
20
|
-
const keep = createKeepKit<
|
|
21
|
-
storage: createBrowserStorageAdapter({ key: "
|
|
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
|
|
28
|
+
export function App() {
|
|
25
29
|
return (
|
|
26
|
-
<keep.Provider
|
|
27
|
-
<keep.Button
|
|
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
|
-
|
|
44
|
+
`createKeepKit<TMeta>()`は同じメタデータ型のコンポーネントとhooksを返します。
|
|
45
|
+
`locale`で組み込みラベルを切り替え、`labels`で文言を上書きできます。16言語に対応しています。
|
|
35
46
|
|
|
36
|
-
|
|
37
|
-
import "@keepkit/ui/theme.css";
|
|
38
|
-
import { createBrowserStorageAdapter, createKeepKit } from "@keepkit/ui";
|
|
47
|
+
### 一覧を拡張する
|
|
39
48
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
storage: createBrowserStorageAdapter({ key: "articles" }),
|
|
43
|
-
locale: "ja-JP",
|
|
44
|
-
labels: { save: "保存", remove: "削除" },
|
|
45
|
-
});
|
|
49
|
+
`keep.Collection`は検索・ソート・ページング、読み込み中・空・エラー表示を標準で備えます。
|
|
50
|
+
検索は既定で300msデバウンスされます。必要な機能を`features`で有効にします。
|
|
46
51
|
|
|
47
|
-
|
|
52
|
+
```tsx
|
|
53
|
+
export function Library() {
|
|
48
54
|
return (
|
|
49
55
|
<keep.Provider>
|
|
50
56
|
<keep.Collection
|
|
51
57
|
query={{ targetType: "article" }}
|
|
52
|
-
|
|
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
|
-
`
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
70
|
-
const keep = createKeepKit<ArticleMeta>({ storage, locale: "ja" });
|
|
73
|
+
### 記事・リンクを再訪する一覧
|
|
71
74
|
|
|
72
|
-
|
|
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
|
-
<
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
`
|
|
87
|
+
`presentation="reading"`はタイトル、URLの保存元、コレクション名、メモ、タグ、保存・訪問情報を表示します。画像は`getImageProps`で指定した場合だけ表示します。保存トグルは既定で非表示、編集・メモ・訪問情報は表示され、既存の表示フラグで上書きできます。`href`と`trackOpen`は明示指定です。編集は300msの自動保存と「完了」を使い、失敗時は下書きを残します。
|
|
109
88
|
|
|
110
|
-
|
|
111
|
-
const onFeedback = useKeepToastFeedback(toast);
|
|
112
|
-
<KeepKitProvider storage={storage} onFeedback={onFeedback}>{children}</KeepKitProvider>;
|
|
113
|
-
```
|
|
89
|
+
`bulkActionsVariant="inline"`は記事行で選択します。全選択は現在ページだけで、検索・フィルター・ページ・表示先を変えると選択を解除します。失敗した一括操作は選択を保持します。既定の`separate`は従来の選択用一覧を維持します。
|
|
114
90
|
|
|
115
|
-
|
|
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
|
-
|
|
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
|
-
|
|
127
|
-
import { KeepThemeProvider, KeepCollection } from "@keepkit/ui";
|
|
95
|
+
### 用途別のコンポーネント
|
|
128
96
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
106
|
+
各コンポーネントは同じProvider内に配置します。`renderItem`、slots、render propsで独自レイアウトへ組み込めます。
|
|
107
|
+
`KeepItemCard`の`Media` / `Content` / `Title` / `Tags` / `Actions`でカードの一部だけを組み替えることもできます。
|
|
135
108
|
|
|
136
|
-
|
|
109
|
+
### テーマとアクセシビリティ
|
|
137
110
|
|
|
138
|
-
|
|
111
|
+
通常は`@keepkit/ui/theme.css`を読み込みます。Tailwind CSS v4/shadcnではグローバルCSSに次を記載します。
|
|
139
112
|
|
|
140
|
-
```
|
|
141
|
-
import "
|
|
142
|
-
import
|
|
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
|
-
|
|
118
|
+
Providerの`theme="ocean"`や`mode="light" | "dark" | "system"`、`density`、`radius`で見た目を調整できます。
|
|
119
|
+
`--keep-*`変数で上書きでき、Tailwind連携ではホストの色変数を継承します。
|
|
157
120
|
|
|
158
|
-
|
|
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
|
-
|
|
124
|
+
### 保存と同期
|
|
171
125
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
```
|
|
126
|
+
ブラウザー内保存はIndexedDB優先・localStorage fallbackです。端末間同期にはアプリ側のdriver・認証・サーバーAPIが必要です。
|
|
127
|
+
バックアップは保存アイテム・コレクション定義・所属を含み、閲覧履歴・鑑賞記録・進行位置は含みません。
|
|
128
|
+
**Replace(置換)は既存データを置き換え、ロールバックしません。**
|
|
176
129
|
|
|
177
|
-
|
|
130
|
+
保存・同期の契約は[Core README](../keepkit/README.md)、デモとNext.jsサンプルは[リポジトリREADME](../../README.md)を参照してください。
|
|
178
131
|
|
|
179
132
|
## English
|
|
180
133
|
|
|
181
|
-
|
|
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: "
|
|
193
|
-
|
|
149
|
+
storage: createBrowserStorageAdapter({ key: "my-app:items" }),
|
|
150
|
+
locale: "en",
|
|
194
151
|
});
|
|
195
152
|
|
|
196
|
-
function
|
|
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
|
-
`
|
|
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
|
-
|
|
215
|
-
const keep = createKeepKit<ArticleMeta>({ storage, locale: "en" });
|
|
172
|
+
### Extend the collection
|
|
216
173
|
|
|
217
|
-
|
|
218
|
-
|
|
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
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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
|
-
|
|
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
|
-
|
|
256
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
220
|
+
### Components by task
|
|
279
221
|
|
|
280
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
236
|
+
Import `@keepkit/ui/theme.css` for the standard theme. For Tailwind CSS v4 or shadcn, add these global CSS imports:
|
|
301
237
|
|
|
302
|
-
|
|
303
|
-
|
|
238
|
+
```css
|
|
239
|
+
@import "tailwindcss";
|
|
240
|
+
@import "@keepkit/ui/tailwind.css";
|
|
241
|
+
```
|
|
304
242
|
|
|
305
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
255
|
+
See the [Core README](../keepkit/README.md) for persistence contracts and the [repository README](../../README.md) for demos and Next.js examples.
|