@keepkit/ui 0.6.0 → 0.8.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 +2 -2
- package/dist/index.d.ts +162 -141
- package/dist/index.js +550 -456
- package/dist/index.js.map +1 -1
- package/package.json +10 -4
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ function SavedArticles() {
|
|
|
32
32
|
}
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
`keep.Collection`は検索、ソート、ページング、loading / empty / error、ARIA live通知を標準で提供します。検索は既定で300msデバウンスされます。`features={{ tagFilter: true, bulkActions: true }}`でタグフィルターと一括操作も有効にできます。個別の`KeepList`、`KeepSearchInput`、`KeepSortSelect`、`KeepPagination`、`KeepItemCheckbox`、`KeepTagEditor`などは高度なレイアウト用に利用できます。`KeepBulkActions`はrender propsで操作UI
|
|
35
|
+
`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)を使えます。
|
|
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. 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
|
|
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 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.
|
|
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,93 +1,11 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ReactNode, HTMLAttributes, ImgHTMLAttributes, ComponentType, InputHTMLAttributes, FormHTMLAttributes, SelectHTMLAttributes } from 'react';
|
|
3
|
+
import { KeepListQuery, KeepItem, KeepItemInput } from '@keepkit/core/core';
|
|
4
4
|
export { KeepItem, KeepItemInput, KeepListQuery, KeepSyncStatus } from '@keepkit/core/core';
|
|
5
|
-
import {
|
|
6
|
-
export { KeepContextValue, KeepProvider, KeepProviderProps, KeepShortcutOptions, useKeepContext, useKeepItem, useKeepList, useKeepShortcut } from '@keepkit/core/react';
|
|
5
|
+
import { KeepButtonProps as KeepButtonProps$1, UseKeepListResult, CreateKeepKitOptions as CreateKeepKitOptions$1, KeepProviderProps, useKeepContext, useKeepItem, useKeepList, KeepShortcutOptions } from '@keepkit/core/react';
|
|
6
|
+
export { KeepButtonState, 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 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";
|
|
52
|
-
type KeepUiLabels = Partial<Record<KeepUiLabelKey, string>>;
|
|
53
|
-
type KeepUiLabelContext = {
|
|
54
|
-
locale?: string;
|
|
55
|
-
labels: Readonly<Record<KeepUiLabelKey, string>>;
|
|
56
|
-
labelResolver?: (key: KeepUiLabelKey, context: {
|
|
57
|
-
locale?: string;
|
|
58
|
-
}) => string | undefined;
|
|
59
|
-
};
|
|
60
|
-
type KeepUiProviderProps = {
|
|
61
|
-
labels?: KeepUiLabels;
|
|
62
|
-
locale?: string;
|
|
63
|
-
labelResolver?: KeepUiLabelContext["labelResolver"];
|
|
64
|
-
children?: ReactNode;
|
|
65
|
-
};
|
|
66
|
-
/** Provides one locale-aware label source to every UI primitive. */
|
|
67
|
-
declare function KeepUiProvider({ labels, locale, labelResolver, children }: KeepUiProviderProps): react.JSX.Element;
|
|
68
|
-
declare function useKeepUiLabels(): KeepUiLabelContext;
|
|
69
|
-
|
|
70
|
-
type KeepKitProviderProps<TMeta = Record<string, unknown>> = Omit<KeepProviderProps<TMeta>, "children"> & Omit<KeepUiProviderProps, "children"> & {
|
|
71
|
-
children?: ReactNode;
|
|
72
|
-
};
|
|
73
|
-
/** Combines the core store and UI labels into the default application provider. */
|
|
74
|
-
declare function KeepKitProvider<TMeta = Record<string, unknown>>({ labels, locale, labelResolver, children, ...providerProps }: KeepKitProviderProps<TMeta>): react.JSX.Element;
|
|
75
|
-
|
|
76
|
-
type CreateKeepKitOptions<TMeta = Record<string, unknown>> = CreateKeepKitOptions$1<TMeta> & Omit<KeepUiProviderProps, "children"> & {
|
|
77
|
-
getTitle?: (item: KeepItem<TMeta>) => ReactNode;
|
|
78
|
-
getImageProps?: (item: KeepItem<TMeta>, title: ReactNode) => KeepImageProps | undefined;
|
|
79
|
-
};
|
|
80
|
-
type KeepKit<TMeta = Record<string, unknown>> = {
|
|
81
|
-
Provider: ComponentType<KeepKitProviderProps<TMeta>>;
|
|
82
|
-
Button: ComponentType<KeepButtonProps<TMeta>>;
|
|
83
|
-
Collection: ComponentType<KeepCollectionProps<TMeta>>;
|
|
84
|
-
useContext: () => ReturnType<typeof useKeepContext<TMeta>>;
|
|
85
|
-
useItem: (item?: KeepItemInput<TMeta>) => ReturnType<typeof useKeepItem<TMeta>>;
|
|
86
|
-
useList: (query?: KeepListQuery<TMeta>) => UseKeepListResult<TMeta>;
|
|
87
|
-
useShortcut: (options: KeepShortcutOptions<TMeta>) => void;
|
|
88
|
-
};
|
|
89
|
-
/** Create one typed application API for the core and the standard UI layer. */
|
|
90
|
-
declare function createKeepKit<TMeta = Record<string, unknown>>(options?: CreateKeepKitOptions<TMeta>): KeepKit<TMeta>;
|
|
91
9
|
type RenderProp<TState> = (state: TState) => ReactNode;
|
|
92
10
|
type KeepButtonLabels = {
|
|
93
11
|
saved?: ReactNode;
|
|
@@ -97,11 +15,45 @@ type KeepButtonLabels = {
|
|
|
97
15
|
savedAriaLabel?: string;
|
|
98
16
|
unsavedAriaLabel?: string;
|
|
99
17
|
};
|
|
18
|
+
|
|
19
|
+
type KeepBulkActionsState<TMeta = Record<string, unknown>> = {
|
|
20
|
+
items: KeepItem<TMeta>[];
|
|
21
|
+
selectedIds: string[];
|
|
22
|
+
selectedCount: number;
|
|
23
|
+
isAllSelected: boolean;
|
|
24
|
+
allSelected: boolean;
|
|
25
|
+
tagsInput: string;
|
|
26
|
+
setTagsInput: (value: string) => void;
|
|
27
|
+
toggle: (id: string) => void;
|
|
28
|
+
toggleSelectAll: () => void;
|
|
29
|
+
toggleAll: () => void;
|
|
30
|
+
remove: () => Promise<void>;
|
|
31
|
+
updateTags: () => Promise<void>;
|
|
32
|
+
isMutating: boolean;
|
|
33
|
+
};
|
|
34
|
+
/** Returns whether every visible item is selected. Empty lists are never all selected. */
|
|
35
|
+
declare function isAllSelected<TMeta>(items: readonly Pick<KeepItem<TMeta>, "id">[], selectedIds: readonly string[]): boolean;
|
|
36
|
+
/** Toggles only the visible items, preserving selections outside the current query or page. */
|
|
37
|
+
declare function toggleSelectAll<TMeta>(items: readonly Pick<KeepItem<TMeta>, "id">[], selectedIds: readonly string[]): string[];
|
|
38
|
+
type KeepBulkActionsProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes<HTMLElement>, "children"> & {
|
|
39
|
+
query?: KeepListQuery<TMeta>;
|
|
40
|
+
selectedIds?: string[];
|
|
41
|
+
defaultSelectedIds?: string[];
|
|
42
|
+
onSelectedIdsChange?: (ids: string[]) => void;
|
|
43
|
+
renderItem?: (item: KeepItem<TMeta>, selected: boolean) => ReactNode;
|
|
44
|
+
onCompleted?: (action: "remove" | "tags", ids: string[]) => void;
|
|
45
|
+
render?: RenderProp<KeepBulkActionsState<TMeta>>;
|
|
46
|
+
children?: ReactNode | RenderProp<KeepBulkActionsState<TMeta>>;
|
|
47
|
+
};
|
|
48
|
+
/** Selects visible items and performs one storage operation for the whole selection. */
|
|
49
|
+
declare function KeepBulkActions<TMeta = Record<string, unknown>>({ query, selectedIds: controlledSelectedIds, defaultSelectedIds, onSelectedIdsChange, renderItem, onCompleted, render, children, ...props }: KeepBulkActionsProps<TMeta>): react.JSX.Element;
|
|
50
|
+
|
|
100
51
|
type KeepButtonProps<TMeta = Record<string, unknown>> = KeepButtonProps$1<TMeta> & {
|
|
101
52
|
labels?: KeepButtonLabels;
|
|
102
53
|
};
|
|
103
54
|
/** A style-free save toggle with localized labels and the core button's ARIA/asChild behavior. */
|
|
104
55
|
declare function KeepButton<TMeta = Record<string, unknown>>({ labels, ...props }: KeepButtonProps<TMeta>): react.JSX.Element;
|
|
56
|
+
|
|
105
57
|
type KeepItemCardState<TMeta = Record<string, unknown>> = {
|
|
106
58
|
item: KeepItem<TMeta>;
|
|
107
59
|
isSaved: boolean;
|
|
@@ -131,7 +83,8 @@ type KeepItemCardProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes<HT
|
|
|
131
83
|
asChild?: boolean;
|
|
132
84
|
};
|
|
133
85
|
/** A low-dependency item presentation primitive. The default markup can be replaced with render props. */
|
|
134
|
-
declare function KeepItemCard<TMeta = Record<string, unknown>>({ item, title, getTitle, getImageProps, imageComponent: ImageComponent, renderImage, imageAlt, render, children, removeLabel, onRemoveError, onRemoved, showSaveButton, saveButtonLabels, asChild, className, ...rootProps }: KeepItemCardProps<TMeta>): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
86
|
+
declare function KeepItemCard<TMeta = Record<string, unknown>>({ item, title, getTitle, getImageProps, imageComponent: ImageComponent, renderImage, imageAlt, render, children, removeLabel, onRemoveError, onRemoved, showSaveButton, saveButtonLabels, asChild, className, ...rootProps }: KeepItemCardProps<TMeta>): react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
87
|
+
|
|
135
88
|
type KeepListState<TMeta = Record<string, unknown>> = UseKeepListResult<TMeta>;
|
|
136
89
|
type KeepListProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes<HTMLElement>, "children"> & {
|
|
137
90
|
query?: KeepListQuery<TMeta>;
|
|
@@ -144,7 +97,8 @@ type KeepListProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes<HTMLEl
|
|
|
144
97
|
asChild?: boolean;
|
|
145
98
|
};
|
|
146
99
|
/** A list primitive with built-in loading, empty, error, and removal states. */
|
|
147
|
-
declare function KeepList<TMeta = Record<string, unknown>>({ query, children, renderItem, loading, empty, error: errorContent, itemCardProps, asChild, className, ...rootProps }: KeepListProps<TMeta>): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
100
|
+
declare function KeepList<TMeta = Record<string, unknown>>({ query, children, renderItem, loading, empty, error: errorContent, itemCardProps, asChild, className, ...rootProps }: KeepListProps<TMeta>): react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
101
|
+
|
|
148
102
|
type KeepCollectionFeature = "search" | "sort" | "pagination" | "tagFilter" | "bulkActions";
|
|
149
103
|
type KeepCollectionProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes<HTMLElement>, "children"> & {
|
|
150
104
|
query?: KeepListQuery<TMeta>;
|
|
@@ -158,27 +112,16 @@ type KeepCollectionProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes<
|
|
|
158
112
|
};
|
|
159
113
|
/** A batteries-included collection with query controls and accessible status feedback. */
|
|
160
114
|
declare function KeepCollection<TMeta = Record<string, unknown>>({ query, pageSize, features, renderItem, itemCardProps, loading, empty, error, className, ...rootProps }: KeepCollectionProps<TMeta>): react.JSX.Element;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
type KeepTagFilterProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes<HTMLElement>, "children" | "onChange"> & {
|
|
168
|
-
query?: KeepListQuery<TMeta>;
|
|
169
|
-
value?: string;
|
|
170
|
-
defaultValue?: string;
|
|
171
|
-
onChange?: (tag?: string) => void;
|
|
172
|
-
onValueChange?: (tag?: string) => void;
|
|
173
|
-
allLabel?: ReactNode;
|
|
174
|
-
ariaLabel?: string;
|
|
175
|
-
renderTag?: (tag: string, count: number, selected: boolean) => ReactNode;
|
|
176
|
-
render?: RenderProp<KeepTagFilterState>;
|
|
177
|
-
children?: ReactNode | RenderProp<KeepTagFilterState>;
|
|
178
|
-
asChild?: boolean;
|
|
115
|
+
|
|
116
|
+
type KeepItemCheckboxProps<TMeta = Record<string, unknown>> = Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "checked" | "defaultChecked" | "onChange"> & {
|
|
117
|
+
item: KeepItem<TMeta>;
|
|
118
|
+
checked?: boolean;
|
|
119
|
+
label?: ReactNode;
|
|
120
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
179
121
|
};
|
|
180
|
-
/**
|
|
181
|
-
declare function
|
|
122
|
+
/** A reusable accessible selection checkbox for a saved item. */
|
|
123
|
+
declare function KeepItemCheckbox<TMeta = Record<string, unknown>>({ item, checked, label, onCheckedChange, "aria-label": ariaLabel, ...props }: KeepItemCheckboxProps<TMeta>): react.JSX.Element;
|
|
124
|
+
|
|
182
125
|
type KeepNoteEditorState<TMeta = Record<string, unknown>> = {
|
|
183
126
|
item: KeepItem<TMeta>;
|
|
184
127
|
note: string;
|
|
@@ -193,6 +136,8 @@ type KeepNoteEditorProps<TMeta = Record<string, unknown>> = Omit<FormHTMLAttribu
|
|
|
193
136
|
label?: ReactNode;
|
|
194
137
|
saveLabel?: ReactNode;
|
|
195
138
|
placeholder?: string;
|
|
139
|
+
/** Automatically save dirty notes after this delay; set to 0 to disable auto-save. */
|
|
140
|
+
debounceMs?: number;
|
|
196
141
|
onSaved?: (note?: string) => void;
|
|
197
142
|
onSaveError?: (error: unknown) => void;
|
|
198
143
|
render?: RenderProp<KeepNoteEditorState<TMeta>>;
|
|
@@ -200,46 +145,79 @@ type KeepNoteEditorProps<TMeta = Record<string, unknown>> = Omit<FormHTMLAttribu
|
|
|
200
145
|
asChild?: boolean;
|
|
201
146
|
};
|
|
202
147
|
/** A controlled-by-default note editor that persists through useKeepItem. */
|
|
203
|
-
declare function KeepNoteEditor<TMeta = Record<string, unknown>>({ item, label, saveLabel, placeholder, onSaved, onSaveError, render, children, asChild, className, ...formProps }: KeepNoteEditorProps<TMeta>): react.JSX.Element;
|
|
148
|
+
declare function KeepNoteEditor<TMeta = Record<string, unknown>>({ item, label, saveLabel, placeholder, debounceMs, onSaved, onSaveError, render, children, asChild, className, ...formProps }: KeepNoteEditorProps<TMeta>): react.JSX.Element;
|
|
149
|
+
|
|
150
|
+
type KeepTagEditorState = {
|
|
151
|
+
tags: string[];
|
|
152
|
+
setTags: (tags: string[]) => void;
|
|
153
|
+
save: () => Promise<void>;
|
|
154
|
+
isSaving: boolean;
|
|
155
|
+
};
|
|
204
156
|
type KeepTagEditorProps<TMeta = Record<string, unknown>> = Omit<FormHTMLAttributes<HTMLFormElement>, "children" | "onSubmit"> & {
|
|
205
157
|
item: KeepItem<TMeta>;
|
|
206
158
|
availableTags?: string[];
|
|
207
159
|
onSaved?: (tags?: string[]) => void;
|
|
208
160
|
onSaveError?: (error: unknown) => void;
|
|
209
|
-
render?: RenderProp<
|
|
210
|
-
tags: string[];
|
|
211
|
-
setTags: (tags: string[]) => void;
|
|
212
|
-
save: () => Promise<void>;
|
|
213
|
-
isSaving: boolean;
|
|
214
|
-
}>;
|
|
161
|
+
render?: RenderProp<KeepTagEditorState>;
|
|
215
162
|
};
|
|
216
|
-
/** Edits one item's normalized tag set and
|
|
163
|
+
/** Edits one item's normalized tag set; Enter adds and Backspace removes the last tag. */
|
|
217
164
|
declare function KeepTagEditor<TMeta = Record<string, unknown>>({ item, availableTags, onSaved, onSaveError, render, ...props }: KeepTagEditorProps<TMeta>): react.JSX.Element;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
setTagsInput: (value: string) => void;
|
|
225
|
-
toggle: (id: string) => void;
|
|
226
|
-
toggleAll: () => void;
|
|
227
|
-
remove: () => Promise<void>;
|
|
228
|
-
updateTags: () => Promise<void>;
|
|
229
|
-
isMutating: boolean;
|
|
165
|
+
|
|
166
|
+
type KeepTagFilterState = {
|
|
167
|
+
tags: string[];
|
|
168
|
+
tagCounts: Record<string, number>;
|
|
169
|
+
value?: string;
|
|
170
|
+
select: (tag?: string) => void;
|
|
230
171
|
};
|
|
231
|
-
type
|
|
172
|
+
type KeepTagFilterProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes<HTMLElement>, "children" | "onChange"> & {
|
|
232
173
|
query?: KeepListQuery<TMeta>;
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
174
|
+
value?: string;
|
|
175
|
+
defaultValue?: string;
|
|
176
|
+
onChange?: (tag?: string) => void;
|
|
177
|
+
onValueChange?: (tag?: string) => void;
|
|
178
|
+
allLabel?: ReactNode;
|
|
179
|
+
ariaLabel?: string;
|
|
180
|
+
renderTag?: (tag: string, count: number, selected: boolean) => ReactNode;
|
|
181
|
+
render?: RenderProp<KeepTagFilterState>;
|
|
182
|
+
children?: ReactNode | RenderProp<KeepTagFilterState>;
|
|
183
|
+
asChild?: boolean;
|
|
240
184
|
};
|
|
241
|
-
/**
|
|
242
|
-
declare function
|
|
185
|
+
/** An ARIA button group for tag filtering; consumers can connect value to a collection query. */
|
|
186
|
+
declare function KeepTagFilter<TMeta = Record<string, unknown>>({ query, value: controlledValue, defaultValue, onChange, onValueChange, allLabel, ariaLabel, renderTag, render, children, asChild, className, ...rootProps }: KeepTagFilterProps<TMeta>): react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
187
|
+
|
|
188
|
+
type KeepSearchInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange"> & {
|
|
189
|
+
value?: string;
|
|
190
|
+
defaultValue?: string;
|
|
191
|
+
/** Delay before notifying consumers; set to 0 to disable debouncing. */
|
|
192
|
+
debounceMs?: number;
|
|
193
|
+
onValueChange?: (value: string) => void;
|
|
194
|
+
};
|
|
195
|
+
/** A controlled/uncontrolled search field with a small built-in debounce. */
|
|
196
|
+
declare function KeepSearchInput({ value: controlledValue, defaultValue, debounceMs, onValueChange, "aria-label": ariaLabel, placeholder, ...props }: KeepSearchInputProps): react.JSX.Element;
|
|
197
|
+
type KeepSortValue = "savedAt:desc" | "savedAt:asc" | "updatedAt:desc" | "updatedAt:asc";
|
|
198
|
+
type KeepSortSelectProps = Omit<SelectHTMLAttributes<HTMLSelectElement>, "value" | "defaultValue" | "onChange"> & {
|
|
199
|
+
value?: KeepSortValue;
|
|
200
|
+
defaultValue?: KeepSortValue;
|
|
201
|
+
onValueChange?: (value: KeepSortValue, sort: NonNullable<KeepListQuery["sort"]>) => void;
|
|
202
|
+
};
|
|
203
|
+
/** Emits a normalized sort descriptor that can be passed directly to useKeepList. */
|
|
204
|
+
declare function KeepSortSelect({ value: controlledValue, defaultValue, onValueChange, "aria-label": ariaLabel, children, ...props }: KeepSortSelectProps): react.JSX.Element;
|
|
205
|
+
type KeepPaginationState = {
|
|
206
|
+
page: number;
|
|
207
|
+
pageCount: number;
|
|
208
|
+
goToPage: (page: number) => void;
|
|
209
|
+
};
|
|
210
|
+
type KeepPaginationProps = Omit<React.HTMLAttributes<HTMLElement>, "children"> & {
|
|
211
|
+
totalCount: number;
|
|
212
|
+
pageSize: number;
|
|
213
|
+
page?: number;
|
|
214
|
+
maxPageButtons?: number;
|
|
215
|
+
onPageChange?: (page: number, offset: number) => void;
|
|
216
|
+
render?: (state: KeepPaginationState) => ReactNode;
|
|
217
|
+
};
|
|
218
|
+
/** Accessible pagination with previous/next controls and numbered page buttons. */
|
|
219
|
+
declare function KeepPagination({ totalCount, pageSize, page, maxPageButtons, onPageChange, render, ...props }: KeepPaginationProps): react.JSX.Element;
|
|
220
|
+
|
|
243
221
|
type KeepEmptyStateProps = Omit<HTMLAttributes<HTMLElement>, "children" | "title"> & {
|
|
244
222
|
title?: ReactNode;
|
|
245
223
|
description?: ReactNode;
|
|
@@ -248,7 +226,7 @@ type KeepEmptyStateProps = Omit<HTMLAttributes<HTMLElement>, "children" | "title
|
|
|
248
226
|
asChild?: boolean;
|
|
249
227
|
};
|
|
250
228
|
/** A style-free, reusable empty collection state. */
|
|
251
|
-
declare function KeepEmptyState({ title, description, action, children, asChild, className, ...rootProps }: KeepEmptyStateProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
229
|
+
declare function KeepEmptyState({ title, description, action, children, asChild, className, ...rootProps }: KeepEmptyStateProps): react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
252
230
|
type KeepStatusValue = "idle" | "empty" | "loading" | "saving" | "syncing" | "error";
|
|
253
231
|
type KeepStatusLabels = Partial<Record<KeepStatusValue, ReactNode>>;
|
|
254
232
|
type KeepStatusState<TMeta = Record<string, unknown>> = {
|
|
@@ -265,11 +243,54 @@ type KeepStatusProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes<HTML
|
|
|
265
243
|
asChild?: boolean;
|
|
266
244
|
};
|
|
267
245
|
/** Presents provider loading, mutation, synchronization, empty, and error states accessibly. */
|
|
268
|
-
declare function KeepStatus<TMeta = Record<string, unknown>>({ status, labels, children, render, asChild, className, ...rootProps }: KeepStatusProps<TMeta>): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
246
|
+
declare function KeepStatus<TMeta = Record<string, unknown>>({ status, labels, children, render, asChild, className, ...rootProps }: KeepStatusProps<TMeta>): react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
269
247
|
type KeepAnnouncementsProps = Omit<HTMLAttributes<HTMLElement>, "children"> & {
|
|
270
248
|
messages?: Partial<Record<"save" | "remove" | "note", string>>;
|
|
271
249
|
};
|
|
272
250
|
/** Announces successful save, remove, and note operations in a polite live region. */
|
|
273
251
|
declare function KeepAnnouncements<TMeta = Record<string, unknown>>({ messages, ...props }: KeepAnnouncementsProps): react.JSX.Element;
|
|
252
|
+
/** Singular alias for applications that mount one announcer explicitly. */
|
|
253
|
+
declare const KeepAnnouncer: typeof KeepAnnouncements;
|
|
254
|
+
|
|
255
|
+
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";
|
|
256
|
+
type KeepUiLabels = Partial<Record<KeepUiLabelKey, string>>;
|
|
257
|
+
type KeepUiLabelContext = {
|
|
258
|
+
locale?: string;
|
|
259
|
+
labels: Readonly<Record<KeepUiLabelKey, string>>;
|
|
260
|
+
labelResolver?: (key: KeepUiLabelKey, context: {
|
|
261
|
+
locale?: string;
|
|
262
|
+
}) => string | undefined;
|
|
263
|
+
};
|
|
264
|
+
type KeepUiProviderProps = {
|
|
265
|
+
labels?: KeepUiLabels;
|
|
266
|
+
locale?: string;
|
|
267
|
+
labelResolver?: KeepUiLabelContext["labelResolver"];
|
|
268
|
+
children?: ReactNode;
|
|
269
|
+
};
|
|
270
|
+
/** Provides one locale-aware label source to every UI primitive. */
|
|
271
|
+
declare function KeepUiProvider({ labels, locale, labelResolver, children }: KeepUiProviderProps): react.JSX.Element;
|
|
272
|
+
declare function useKeepUiLabels(): KeepUiLabelContext;
|
|
273
|
+
|
|
274
|
+
type KeepKitProviderProps<TMeta = Record<string, unknown>> = Omit<KeepProviderProps<TMeta>, "children"> & Omit<KeepUiProviderProps, "children"> & {
|
|
275
|
+
children?: ReactNode;
|
|
276
|
+
};
|
|
277
|
+
/** Combines the core store, UI labels, and the global live announcer. */
|
|
278
|
+
declare function KeepKitProvider<TMeta = Record<string, unknown>>({ labels, locale, labelResolver, children, ...providerProps }: KeepKitProviderProps<TMeta>): react.JSX.Element;
|
|
279
|
+
|
|
280
|
+
type CreateKeepKitOptions<TMeta = Record<string, unknown>> = CreateKeepKitOptions$1<TMeta> & Omit<KeepUiProviderProps, "children"> & {
|
|
281
|
+
getTitle?: (item: KeepItem<TMeta>) => ReactNode;
|
|
282
|
+
getImageProps?: (item: KeepItem<TMeta>, title: ReactNode) => KeepImageProps | undefined;
|
|
283
|
+
};
|
|
284
|
+
type KeepKit<TMeta = Record<string, unknown>> = {
|
|
285
|
+
Provider: ComponentType<KeepKitProviderProps<TMeta>>;
|
|
286
|
+
Button: ComponentType<KeepButtonProps<TMeta>>;
|
|
287
|
+
Collection: ComponentType<KeepCollectionProps<TMeta>>;
|
|
288
|
+
useContext: () => ReturnType<typeof useKeepContext<TMeta>>;
|
|
289
|
+
useItem: (item?: KeepItemInput<TMeta>) => ReturnType<typeof useKeepItem<TMeta>>;
|
|
290
|
+
useList: (query?: KeepListQuery<TMeta>) => ReturnType<typeof useKeepList<TMeta>>;
|
|
291
|
+
useShortcut: (options: KeepShortcutOptions<TMeta>) => void;
|
|
292
|
+
};
|
|
293
|
+
/** Create one typed application API for the core and standard UI layer. */
|
|
294
|
+
declare function createKeepKit<TMeta = Record<string, unknown>>(options?: CreateKeepKitOptions<TMeta>): KeepKit<TMeta>;
|
|
274
295
|
|
|
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 };
|
|
296
|
+
export { type CreateKeepKitOptions, KeepAnnouncements, type KeepAnnouncementsProps, KeepAnnouncer, 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, type KeepTagEditorState, KeepTagFilter, type KeepTagFilterProps, type KeepTagFilterState, type KeepUiLabelContext, type KeepUiLabelKey, type KeepUiLabels, KeepUiProvider, type KeepUiProviderProps, type RenderProp, createKeepKit, isAllSelected, toggleSelectAll, useKeepUiLabels };
|