@keepkit/ui 0.5.0 → 0.6.0

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
@@ -32,7 +32,7 @@ function SavedArticles() {
32
32
  }
33
33
  ```
34
34
 
35
- `keep.Collection`は検索、ソート、ページング、loading / empty / error、ARIA live通知を標準で提供します。`features={{ tagFilter: true, bulkActions: true }}`でタグフィルターと一括操作も有効にできます。個別の`KeepList`、`KeepSearchInput`、`KeepSortSelect`、`KeepPagination`などは高度なレイアウト用に利用できます。
35
+ `keep.Collection`は検索、ソート、ページング、loading / empty / error、ARIA live通知を標準で提供します。検索は既定で300msデバウンスされます。`features={{ tagFilter: true, bulkActions: true }}`でタグフィルターと一括操作も有効にできます。個別の`KeepList`、`KeepSearchInput`、`KeepSortSelect`、`KeepPagination`、`KeepItemCheckbox`、`KeepTagEditor`などは高度なレイアウト用に利用できます。`KeepBulkActions`はrender propsで操作UIを差し替えられます。
36
36
 
37
37
  一覧のqueryは次の形式に統一されています。
38
38
 
@@ -81,7 +81,7 @@ function SavedArticles() {
81
81
  }
82
82
  ```
83
83
 
84
- `keep.Collection` includes search, sorting, pagination, loading/empty/error states, and polite live announcements. Enable `features={{ tagFilter: true, bulkActions: true }}` for tag filtering and bulk operations. Use the individual `KeepList`, `KeepSearchInput`, `KeepSortSelect`, and `KeepPagination` primitives when you need a custom layout.
84
+ `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 for replacing its operation UI.
85
85
 
86
86
  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.
87
87
 
package/dist/index.d.ts CHANGED
@@ -1,12 +1,54 @@
1
1
  import * as react from 'react';
2
- import { ReactNode, ImgHTMLAttributes, HTMLAttributes, ComponentType, ReactElement, FormHTMLAttributes, InputHTMLAttributes, SelectHTMLAttributes } from 'react';
2
+ import { InputHTMLAttributes, ReactNode, SelectHTMLAttributes, ImgHTMLAttributes, HTMLAttributes, ComponentType, ReactElement, FormHTMLAttributes } from 'react';
3
3
  import { KeepItem, KeepListQuery, KeepItemInput } from '@keepkit/core/core';
4
4
  export { KeepItem, KeepItemInput, KeepListQuery, KeepSyncStatus } from '@keepkit/core/core';
5
5
  import { CreateKeepKitOptions as CreateKeepKitOptions$1, KeepButtonProps as KeepButtonProps$1, UseKeepListResult, KeepProviderProps, useKeepContext, useKeepItem, KeepShortcutOptions } from '@keepkit/core/react';
6
6
  export { KeepContextValue, KeepProvider, KeepProviderProps, KeepShortcutOptions, useKeepContext, useKeepItem, useKeepList, useKeepShortcut } from '@keepkit/core/react';
7
7
  export { FallbackStorageAdapter, IndexedDBAdapter, IndexedDBSyncQueueAdapter, LocalStorageAdapter, LocalStorageSyncQueueAdapter, SyncStorageAdapter, createBrowserStorageAdapter, createStorageAdapter } from '@keepkit/core/storage';
8
8
 
9
- type KeepUiLabelKey = "save" | "saved" | "remove" | "loading" | "saving" | "syncing" | "error" | "allTags" | "filterTags" | "note" | "saveNote" | "noItems" | "loadingItems" | "errorItems" | "search" | "sort" | "newest" | "oldest" | "previousPage" | "nextPage" | "pagination" | "page" | "selectItems" | "selectedCount" | "deleteSelected" | "tagsToApply" | "applyTags" | "savedMessage" | "removedMessage" | "noteSavedMessage";
9
+ type KeepItemCheckboxProps<TMeta = Record<string, unknown>> = Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "checked" | "defaultChecked" | "onChange"> & {
10
+ item: KeepItem<TMeta>;
11
+ checked?: boolean;
12
+ label?: ReactNode;
13
+ onCheckedChange?: (checked: boolean) => void;
14
+ };
15
+ /** A reusable accessible selection checkbox for a saved item. */
16
+ declare function KeepItemCheckbox<TMeta = Record<string, unknown>>({ item, checked, label, onCheckedChange, "aria-label": ariaLabel, ...props }: KeepItemCheckboxProps<TMeta>): react.JSX.Element;
17
+
18
+ type KeepSearchInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange"> & {
19
+ value?: string;
20
+ defaultValue?: string;
21
+ /** Delay before notifying consumers; set to 0 to disable debouncing. */
22
+ debounceMs?: number;
23
+ onValueChange?: (value: string) => void;
24
+ };
25
+ /** A controlled/uncontrolled search field with a small built-in debounce. */
26
+ declare function KeepSearchInput({ value: controlledValue, defaultValue, debounceMs, onValueChange, "aria-label": ariaLabel, placeholder, ...props }: KeepSearchInputProps): react.JSX.Element;
27
+ type KeepSortValue = "savedAt:desc" | "savedAt:asc" | "updatedAt:desc" | "updatedAt:asc";
28
+ type KeepSortSelectProps = Omit<SelectHTMLAttributes<HTMLSelectElement>, "value" | "defaultValue" | "onChange"> & {
29
+ value?: KeepSortValue;
30
+ defaultValue?: KeepSortValue;
31
+ onValueChange?: (value: KeepSortValue, sort: NonNullable<KeepListQuery["sort"]>) => void;
32
+ };
33
+ /** Emits a normalized sort descriptor that can be passed directly to useKeepList. */
34
+ declare function KeepSortSelect({ value: controlledValue, defaultValue, onValueChange, "aria-label": ariaLabel, children, ...props }: KeepSortSelectProps): react.JSX.Element;
35
+ type KeepPaginationState = {
36
+ page: number;
37
+ pageCount: number;
38
+ goToPage: (page: number) => void;
39
+ };
40
+ type KeepPaginationProps = Omit<React.HTMLAttributes<HTMLElement>, "children"> & {
41
+ totalCount: number;
42
+ pageSize: number;
43
+ page?: number;
44
+ maxPageButtons?: number;
45
+ onPageChange?: (page: number, offset: number) => void;
46
+ render?: (state: KeepPaginationState) => ReactNode;
47
+ };
48
+ /** Accessible pagination with previous/next controls and numbered page buttons. */
49
+ declare function KeepPagination({ totalCount, pageSize, page, maxPageButtons, onPageChange, render, ...props }: KeepPaginationProps): react.JSX.Element;
50
+
51
+ type KeepUiLabelKey = "save" | "saved" | "remove" | "loading" | "saving" | "syncing" | "error" | "allTags" | "filterTags" | "note" | "saveNote" | "noItems" | "loadingItems" | "errorItems" | "search" | "sort" | "newest" | "oldest" | "savedNewest" | "savedOldest" | "updatedNewest" | "updatedOldest" | "previousPage" | "nextPage" | "pagination" | "page" | "selectItems" | "selectedCount" | "deleteSelected" | "tagsToApply" | "applyTags" | "savedMessage" | "removedMessage" | "noteSavedMessage";
10
52
  type KeepUiLabels = Partial<Record<KeepUiLabelKey, string>>;
11
53
  type KeepUiLabelContext = {
12
54
  locale?: string;
@@ -23,12 +65,13 @@ type KeepUiProviderProps = {
23
65
  };
24
66
  /** Provides one locale-aware label source to every UI primitive. */
25
67
  declare function KeepUiProvider({ labels, locale, labelResolver, children }: KeepUiProviderProps): react.JSX.Element;
68
+ declare function useKeepUiLabels(): KeepUiLabelContext;
69
+
26
70
  type KeepKitProviderProps<TMeta = Record<string, unknown>> = Omit<KeepProviderProps<TMeta>, "children"> & Omit<KeepUiProviderProps, "children"> & {
27
71
  children?: ReactNode;
28
72
  };
29
73
  /** Combines the core store and UI labels into the default application provider. */
30
74
  declare function KeepKitProvider<TMeta = Record<string, unknown>>({ labels, locale, labelResolver, children, ...providerProps }: KeepKitProviderProps<TMeta>): react.JSX.Element;
31
- declare function useKeepUiLabels(): KeepUiLabelContext;
32
75
 
33
76
  type CreateKeepKitOptions<TMeta = Record<string, unknown>> = CreateKeepKitOptions$1<TMeta> & Omit<KeepUiProviderProps, "children"> & {
34
77
  getTitle?: (item: KeepItem<TMeta>) => ReactNode;
@@ -158,34 +201,6 @@ type KeepNoteEditorProps<TMeta = Record<string, unknown>> = Omit<FormHTMLAttribu
158
201
  };
159
202
  /** A controlled-by-default note editor that persists through useKeepItem. */
160
203
  declare function KeepNoteEditor<TMeta = Record<string, unknown>>({ item, label, saveLabel, placeholder, onSaved, onSaveError, render, children, asChild, className, ...formProps }: KeepNoteEditorProps<TMeta>): react.JSX.Element;
161
- type KeepSearchInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange"> & {
162
- value?: string;
163
- defaultValue?: string;
164
- onValueChange?: (value: string) => void;
165
- };
166
- /** A controlled/uncontrolled search field for wiring into KeepListQuery.search. */
167
- declare function KeepSearchInput({ value: controlledValue, defaultValue, onValueChange, "aria-label": ariaLabel, placeholder, ...props }: KeepSearchInputProps): react.JSX.Element;
168
- type KeepSortValue = "savedAt:desc" | "savedAt:asc" | "updatedAt:desc" | "updatedAt:asc";
169
- type KeepSortSelectProps = Omit<SelectHTMLAttributes<HTMLSelectElement>, "value" | "defaultValue" | "onChange"> & {
170
- value?: KeepSortValue;
171
- defaultValue?: KeepSortValue;
172
- onValueChange?: (value: KeepSortValue, sort: NonNullable<KeepListQuery["sort"]>) => void;
173
- };
174
- /** Emits a normalized sort descriptor that can be passed directly to useKeepList. */
175
- declare function KeepSortSelect({ value: controlledValue, defaultValue, onValueChange, "aria-label": ariaLabel, children, ...props }: KeepSortSelectProps): react.JSX.Element;
176
- type KeepPaginationProps = Omit<HTMLAttributes<HTMLElement>, "children"> & {
177
- totalCount: number;
178
- pageSize: number;
179
- page?: number;
180
- onPageChange?: (page: number, offset: number) => void;
181
- render?: RenderProp<{
182
- page: number;
183
- pageCount: number;
184
- goToPage: (page: number) => void;
185
- }>;
186
- };
187
- /** A small accessible pagination control using one-based pages and zero-based offsets. */
188
- declare function KeepPagination({ totalCount, pageSize, page, onPageChange, render, ...props }: KeepPaginationProps): react.JSX.Element;
189
204
  type KeepTagEditorProps<TMeta = Record<string, unknown>> = Omit<FormHTMLAttributes<HTMLFormElement>, "children" | "onSubmit"> & {
190
205
  item: KeepItem<TMeta>;
191
206
  availableTags?: string[];
@@ -200,6 +215,19 @@ type KeepTagEditorProps<TMeta = Record<string, unknown>> = Omit<FormHTMLAttribut
200
215
  };
201
216
  /** Edits one item's normalized tag set and exposes a render-prop escape hatch. */
202
217
  declare function KeepTagEditor<TMeta = Record<string, unknown>>({ item, availableTags, onSaved, onSaveError, render, ...props }: KeepTagEditorProps<TMeta>): react.JSX.Element;
218
+ type KeepBulkActionsState<TMeta = Record<string, unknown>> = {
219
+ items: KeepItem<TMeta>[];
220
+ selectedIds: string[];
221
+ selectedCount: number;
222
+ allSelected: boolean;
223
+ tagsInput: string;
224
+ setTagsInput: (value: string) => void;
225
+ toggle: (id: string) => void;
226
+ toggleAll: () => void;
227
+ remove: () => Promise<void>;
228
+ updateTags: () => Promise<void>;
229
+ isMutating: boolean;
230
+ };
203
231
  type KeepBulkActionsProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes<HTMLElement>, "children"> & {
204
232
  query?: KeepListQuery<TMeta>;
205
233
  selectedIds?: string[];
@@ -207,9 +235,11 @@ type KeepBulkActionsProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes
207
235
  onSelectedIdsChange?: (ids: string[]) => void;
208
236
  renderItem?: (item: KeepItem<TMeta>, selected: boolean) => ReactNode;
209
237
  onCompleted?: (action: "remove" | "tags", ids: string[]) => void;
238
+ render?: RenderProp<KeepBulkActionsState<TMeta>>;
239
+ children?: ReactNode | RenderProp<KeepBulkActionsState<TMeta>>;
210
240
  };
211
241
  /** Selects visible items and performs one storage operation for the whole selection. */
212
- declare function KeepBulkActions<TMeta = Record<string, unknown>>({ query, selectedIds: controlledSelectedIds, defaultSelectedIds, onSelectedIdsChange, renderItem, onCompleted, ...props }: KeepBulkActionsProps<TMeta>): react.JSX.Element;
242
+ declare function KeepBulkActions<TMeta = Record<string, unknown>>({ query, selectedIds: controlledSelectedIds, defaultSelectedIds, onSelectedIdsChange, renderItem, onCompleted, render, children, ...props }: KeepBulkActionsProps<TMeta>): react.JSX.Element;
213
243
  type KeepEmptyStateProps = Omit<HTMLAttributes<HTMLElement>, "children" | "title"> & {
214
244
  title?: ReactNode;
215
245
  description?: ReactNode;
@@ -242,4 +272,4 @@ type KeepAnnouncementsProps = Omit<HTMLAttributes<HTMLElement>, "children"> & {
242
272
  /** Announces successful save, remove, and note operations in a polite live region. */
243
273
  declare function KeepAnnouncements<TMeta = Record<string, unknown>>({ messages, ...props }: KeepAnnouncementsProps): react.JSX.Element;
244
274
 
245
- export { type CreateKeepKitOptions, KeepAnnouncements, type KeepAnnouncementsProps, KeepBulkActions, type KeepBulkActionsProps, KeepButton, type KeepButtonLabels, type KeepButtonProps, KeepCollection, type KeepCollectionFeature, type KeepCollectionProps, KeepEmptyState, type KeepEmptyStateProps, type KeepImageProps, KeepItemCard, type KeepItemCardProps, type KeepItemCardState, type KeepKit, KeepKitProvider, type KeepKitProviderProps, KeepList, type KeepListProps, type KeepListState, KeepNoteEditor, type KeepNoteEditorProps, type KeepNoteEditorState, KeepPagination, type KeepPaginationProps, KeepSearchInput, type KeepSearchInputProps, KeepSortSelect, type KeepSortSelectProps, type KeepSortValue, KeepStatus, type KeepStatusLabels, type KeepStatusProps, type KeepStatusState, type KeepStatusValue, KeepTagEditor, type KeepTagEditorProps, KeepTagFilter, type KeepTagFilterProps, type KeepTagFilterState, type KeepUiLabelContext, type KeepUiLabelKey, type KeepUiLabels, KeepUiProvider, type KeepUiProviderProps, type RenderProp, createKeepKit, useKeepUiLabels };
275
+ export { type CreateKeepKitOptions, KeepAnnouncements, type KeepAnnouncementsProps, KeepBulkActions, type KeepBulkActionsProps, type KeepBulkActionsState, KeepButton, type KeepButtonLabels, type KeepButtonProps, KeepCollection, type KeepCollectionFeature, type KeepCollectionProps, KeepEmptyState, type KeepEmptyStateProps, type KeepImageProps, KeepItemCard, type KeepItemCardProps, type KeepItemCardState, KeepItemCheckbox, type KeepItemCheckboxProps, type KeepKit, KeepKitProvider, type KeepKitProviderProps, KeepList, type KeepListProps, type KeepListState, KeepNoteEditor, type KeepNoteEditorProps, type KeepNoteEditorState, KeepPagination, type KeepPaginationProps, type KeepPaginationState, KeepSearchInput, type KeepSearchInputProps, KeepSortSelect, type KeepSortSelectProps, type KeepSortValue, KeepStatus, type KeepStatusLabels, type KeepStatusProps, type KeepStatusState, type KeepStatusValue, KeepTagEditor, type KeepTagEditorProps, KeepTagFilter, type KeepTagFilterProps, type KeepTagFilterState, type KeepUiLabelContext, type KeepUiLabelKey, type KeepUiLabels, KeepUiProvider, type KeepUiProviderProps, type RenderProp, createKeepKit, useKeepUiLabels };