@keepkit/ui 0.6.0 → 0.7.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 +156 -141
- package/dist/index.js +539 -464
- 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を差し替えられます。`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 replacing its operation UI.
|
|
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. `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,39 @@ 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
|
+
allSelected: boolean;
|
|
24
|
+
tagsInput: string;
|
|
25
|
+
setTagsInput: (value: string) => void;
|
|
26
|
+
toggle: (id: string) => void;
|
|
27
|
+
toggleAll: () => void;
|
|
28
|
+
remove: () => Promise<void>;
|
|
29
|
+
updateTags: () => Promise<void>;
|
|
30
|
+
isMutating: boolean;
|
|
31
|
+
};
|
|
32
|
+
type KeepBulkActionsProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes<HTMLElement>, "children"> & {
|
|
33
|
+
query?: KeepListQuery<TMeta>;
|
|
34
|
+
selectedIds?: string[];
|
|
35
|
+
defaultSelectedIds?: string[];
|
|
36
|
+
onSelectedIdsChange?: (ids: string[]) => void;
|
|
37
|
+
renderItem?: (item: KeepItem<TMeta>, selected: boolean) => ReactNode;
|
|
38
|
+
onCompleted?: (action: "remove" | "tags", ids: string[]) => void;
|
|
39
|
+
render?: RenderProp<KeepBulkActionsState<TMeta>>;
|
|
40
|
+
children?: ReactNode | RenderProp<KeepBulkActionsState<TMeta>>;
|
|
41
|
+
};
|
|
42
|
+
/** Selects visible items and performs one storage operation for the whole selection. */
|
|
43
|
+
declare function KeepBulkActions<TMeta = Record<string, unknown>>({ query, selectedIds: controlledSelectedIds, defaultSelectedIds, onSelectedIdsChange, renderItem, onCompleted, render, children, ...props }: KeepBulkActionsProps<TMeta>): react.JSX.Element;
|
|
44
|
+
|
|
100
45
|
type KeepButtonProps<TMeta = Record<string, unknown>> = KeepButtonProps$1<TMeta> & {
|
|
101
46
|
labels?: KeepButtonLabels;
|
|
102
47
|
};
|
|
103
48
|
/** A style-free save toggle with localized labels and the core button's ARIA/asChild behavior. */
|
|
104
49
|
declare function KeepButton<TMeta = Record<string, unknown>>({ labels, ...props }: KeepButtonProps<TMeta>): react.JSX.Element;
|
|
50
|
+
|
|
105
51
|
type KeepItemCardState<TMeta = Record<string, unknown>> = {
|
|
106
52
|
item: KeepItem<TMeta>;
|
|
107
53
|
isSaved: boolean;
|
|
@@ -131,7 +77,8 @@ type KeepItemCardProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes<HT
|
|
|
131
77
|
asChild?: boolean;
|
|
132
78
|
};
|
|
133
79
|
/** 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>>;
|
|
80
|
+
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>>;
|
|
81
|
+
|
|
135
82
|
type KeepListState<TMeta = Record<string, unknown>> = UseKeepListResult<TMeta>;
|
|
136
83
|
type KeepListProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes<HTMLElement>, "children"> & {
|
|
137
84
|
query?: KeepListQuery<TMeta>;
|
|
@@ -144,7 +91,8 @@ type KeepListProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes<HTMLEl
|
|
|
144
91
|
asChild?: boolean;
|
|
145
92
|
};
|
|
146
93
|
/** 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>>;
|
|
94
|
+
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>>;
|
|
95
|
+
|
|
148
96
|
type KeepCollectionFeature = "search" | "sort" | "pagination" | "tagFilter" | "bulkActions";
|
|
149
97
|
type KeepCollectionProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes<HTMLElement>, "children"> & {
|
|
150
98
|
query?: KeepListQuery<TMeta>;
|
|
@@ -158,27 +106,16 @@ type KeepCollectionProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes<
|
|
|
158
106
|
};
|
|
159
107
|
/** A batteries-included collection with query controls and accessible status feedback. */
|
|
160
108
|
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;
|
|
109
|
+
|
|
110
|
+
type KeepItemCheckboxProps<TMeta = Record<string, unknown>> = Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "checked" | "defaultChecked" | "onChange"> & {
|
|
111
|
+
item: KeepItem<TMeta>;
|
|
112
|
+
checked?: boolean;
|
|
113
|
+
label?: ReactNode;
|
|
114
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
179
115
|
};
|
|
180
|
-
/**
|
|
181
|
-
declare function
|
|
116
|
+
/** A reusable accessible selection checkbox for a saved item. */
|
|
117
|
+
declare function KeepItemCheckbox<TMeta = Record<string, unknown>>({ item, checked, label, onCheckedChange, "aria-label": ariaLabel, ...props }: KeepItemCheckboxProps<TMeta>): react.JSX.Element;
|
|
118
|
+
|
|
182
119
|
type KeepNoteEditorState<TMeta = Record<string, unknown>> = {
|
|
183
120
|
item: KeepItem<TMeta>;
|
|
184
121
|
note: string;
|
|
@@ -193,6 +130,8 @@ type KeepNoteEditorProps<TMeta = Record<string, unknown>> = Omit<FormHTMLAttribu
|
|
|
193
130
|
label?: ReactNode;
|
|
194
131
|
saveLabel?: ReactNode;
|
|
195
132
|
placeholder?: string;
|
|
133
|
+
/** Automatically save dirty notes after this delay; set to 0 to disable auto-save. */
|
|
134
|
+
debounceMs?: number;
|
|
196
135
|
onSaved?: (note?: string) => void;
|
|
197
136
|
onSaveError?: (error: unknown) => void;
|
|
198
137
|
render?: RenderProp<KeepNoteEditorState<TMeta>>;
|
|
@@ -200,46 +139,79 @@ type KeepNoteEditorProps<TMeta = Record<string, unknown>> = Omit<FormHTMLAttribu
|
|
|
200
139
|
asChild?: boolean;
|
|
201
140
|
};
|
|
202
141
|
/** 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;
|
|
142
|
+
declare function KeepNoteEditor<TMeta = Record<string, unknown>>({ item, label, saveLabel, placeholder, debounceMs, onSaved, onSaveError, render, children, asChild, className, ...formProps }: KeepNoteEditorProps<TMeta>): react.JSX.Element;
|
|
143
|
+
|
|
144
|
+
type KeepTagEditorState = {
|
|
145
|
+
tags: string[];
|
|
146
|
+
setTags: (tags: string[]) => void;
|
|
147
|
+
save: () => Promise<void>;
|
|
148
|
+
isSaving: boolean;
|
|
149
|
+
};
|
|
204
150
|
type KeepTagEditorProps<TMeta = Record<string, unknown>> = Omit<FormHTMLAttributes<HTMLFormElement>, "children" | "onSubmit"> & {
|
|
205
151
|
item: KeepItem<TMeta>;
|
|
206
152
|
availableTags?: string[];
|
|
207
153
|
onSaved?: (tags?: string[]) => void;
|
|
208
154
|
onSaveError?: (error: unknown) => void;
|
|
209
|
-
render?: RenderProp<
|
|
210
|
-
tags: string[];
|
|
211
|
-
setTags: (tags: string[]) => void;
|
|
212
|
-
save: () => Promise<void>;
|
|
213
|
-
isSaving: boolean;
|
|
214
|
-
}>;
|
|
155
|
+
render?: RenderProp<KeepTagEditorState>;
|
|
215
156
|
};
|
|
216
|
-
/** Edits one item's normalized tag set and
|
|
157
|
+
/** Edits one item's normalized tag set; Enter adds and Backspace removes the last tag. */
|
|
217
158
|
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;
|
|
159
|
+
|
|
160
|
+
type KeepTagFilterState = {
|
|
161
|
+
tags: string[];
|
|
162
|
+
tagCounts: Record<string, number>;
|
|
163
|
+
value?: string;
|
|
164
|
+
select: (tag?: string) => void;
|
|
230
165
|
};
|
|
231
|
-
type
|
|
166
|
+
type KeepTagFilterProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes<HTMLElement>, "children" | "onChange"> & {
|
|
232
167
|
query?: KeepListQuery<TMeta>;
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
168
|
+
value?: string;
|
|
169
|
+
defaultValue?: string;
|
|
170
|
+
onChange?: (tag?: string) => void;
|
|
171
|
+
onValueChange?: (tag?: string) => void;
|
|
172
|
+
allLabel?: ReactNode;
|
|
173
|
+
ariaLabel?: string;
|
|
174
|
+
renderTag?: (tag: string, count: number, selected: boolean) => ReactNode;
|
|
175
|
+
render?: RenderProp<KeepTagFilterState>;
|
|
176
|
+
children?: ReactNode | RenderProp<KeepTagFilterState>;
|
|
177
|
+
asChild?: boolean;
|
|
240
178
|
};
|
|
241
|
-
/**
|
|
242
|
-
declare function
|
|
179
|
+
/** An ARIA button group for tag filtering; consumers can connect value to a collection query. */
|
|
180
|
+
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>>;
|
|
181
|
+
|
|
182
|
+
type KeepSearchInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange"> & {
|
|
183
|
+
value?: string;
|
|
184
|
+
defaultValue?: string;
|
|
185
|
+
/** Delay before notifying consumers; set to 0 to disable debouncing. */
|
|
186
|
+
debounceMs?: number;
|
|
187
|
+
onValueChange?: (value: string) => void;
|
|
188
|
+
};
|
|
189
|
+
/** A controlled/uncontrolled search field with a small built-in debounce. */
|
|
190
|
+
declare function KeepSearchInput({ value: controlledValue, defaultValue, debounceMs, onValueChange, "aria-label": ariaLabel, placeholder, ...props }: KeepSearchInputProps): react.JSX.Element;
|
|
191
|
+
type KeepSortValue = "savedAt:desc" | "savedAt:asc" | "updatedAt:desc" | "updatedAt:asc";
|
|
192
|
+
type KeepSortSelectProps = Omit<SelectHTMLAttributes<HTMLSelectElement>, "value" | "defaultValue" | "onChange"> & {
|
|
193
|
+
value?: KeepSortValue;
|
|
194
|
+
defaultValue?: KeepSortValue;
|
|
195
|
+
onValueChange?: (value: KeepSortValue, sort: NonNullable<KeepListQuery["sort"]>) => void;
|
|
196
|
+
};
|
|
197
|
+
/** Emits a normalized sort descriptor that can be passed directly to useKeepList. */
|
|
198
|
+
declare function KeepSortSelect({ value: controlledValue, defaultValue, onValueChange, "aria-label": ariaLabel, children, ...props }: KeepSortSelectProps): react.JSX.Element;
|
|
199
|
+
type KeepPaginationState = {
|
|
200
|
+
page: number;
|
|
201
|
+
pageCount: number;
|
|
202
|
+
goToPage: (page: number) => void;
|
|
203
|
+
};
|
|
204
|
+
type KeepPaginationProps = Omit<React.HTMLAttributes<HTMLElement>, "children"> & {
|
|
205
|
+
totalCount: number;
|
|
206
|
+
pageSize: number;
|
|
207
|
+
page?: number;
|
|
208
|
+
maxPageButtons?: number;
|
|
209
|
+
onPageChange?: (page: number, offset: number) => void;
|
|
210
|
+
render?: (state: KeepPaginationState) => ReactNode;
|
|
211
|
+
};
|
|
212
|
+
/** Accessible pagination with previous/next controls and numbered page buttons. */
|
|
213
|
+
declare function KeepPagination({ totalCount, pageSize, page, maxPageButtons, onPageChange, render, ...props }: KeepPaginationProps): react.JSX.Element;
|
|
214
|
+
|
|
243
215
|
type KeepEmptyStateProps = Omit<HTMLAttributes<HTMLElement>, "children" | "title"> & {
|
|
244
216
|
title?: ReactNode;
|
|
245
217
|
description?: ReactNode;
|
|
@@ -248,7 +220,7 @@ type KeepEmptyStateProps = Omit<HTMLAttributes<HTMLElement>, "children" | "title
|
|
|
248
220
|
asChild?: boolean;
|
|
249
221
|
};
|
|
250
222
|
/** 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>>;
|
|
223
|
+
declare function KeepEmptyState({ title, description, action, children, asChild, className, ...rootProps }: KeepEmptyStateProps): react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
252
224
|
type KeepStatusValue = "idle" | "empty" | "loading" | "saving" | "syncing" | "error";
|
|
253
225
|
type KeepStatusLabels = Partial<Record<KeepStatusValue, ReactNode>>;
|
|
254
226
|
type KeepStatusState<TMeta = Record<string, unknown>> = {
|
|
@@ -265,11 +237,54 @@ type KeepStatusProps<TMeta = Record<string, unknown>> = Omit<HTMLAttributes<HTML
|
|
|
265
237
|
asChild?: boolean;
|
|
266
238
|
};
|
|
267
239
|
/** 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>>;
|
|
240
|
+
declare function KeepStatus<TMeta = Record<string, unknown>>({ status, labels, children, render, asChild, className, ...rootProps }: KeepStatusProps<TMeta>): react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
269
241
|
type KeepAnnouncementsProps = Omit<HTMLAttributes<HTMLElement>, "children"> & {
|
|
270
242
|
messages?: Partial<Record<"save" | "remove" | "note", string>>;
|
|
271
243
|
};
|
|
272
244
|
/** Announces successful save, remove, and note operations in a polite live region. */
|
|
273
245
|
declare function KeepAnnouncements<TMeta = Record<string, unknown>>({ messages, ...props }: KeepAnnouncementsProps): react.JSX.Element;
|
|
246
|
+
/** Singular alias for applications that mount one announcer explicitly. */
|
|
247
|
+
declare const KeepAnnouncer: typeof KeepAnnouncements;
|
|
248
|
+
|
|
249
|
+
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";
|
|
250
|
+
type KeepUiLabels = Partial<Record<KeepUiLabelKey, string>>;
|
|
251
|
+
type KeepUiLabelContext = {
|
|
252
|
+
locale?: string;
|
|
253
|
+
labels: Readonly<Record<KeepUiLabelKey, string>>;
|
|
254
|
+
labelResolver?: (key: KeepUiLabelKey, context: {
|
|
255
|
+
locale?: string;
|
|
256
|
+
}) => string | undefined;
|
|
257
|
+
};
|
|
258
|
+
type KeepUiProviderProps = {
|
|
259
|
+
labels?: KeepUiLabels;
|
|
260
|
+
locale?: string;
|
|
261
|
+
labelResolver?: KeepUiLabelContext["labelResolver"];
|
|
262
|
+
children?: ReactNode;
|
|
263
|
+
};
|
|
264
|
+
/** Provides one locale-aware label source to every UI primitive. */
|
|
265
|
+
declare function KeepUiProvider({ labels, locale, labelResolver, children }: KeepUiProviderProps): react.JSX.Element;
|
|
266
|
+
declare function useKeepUiLabels(): KeepUiLabelContext;
|
|
267
|
+
|
|
268
|
+
type KeepKitProviderProps<TMeta = Record<string, unknown>> = Omit<KeepProviderProps<TMeta>, "children"> & Omit<KeepUiProviderProps, "children"> & {
|
|
269
|
+
children?: ReactNode;
|
|
270
|
+
};
|
|
271
|
+
/** Combines the core store, UI labels, and the global live announcer. */
|
|
272
|
+
declare function KeepKitProvider<TMeta = Record<string, unknown>>({ labels, locale, labelResolver, children, ...providerProps }: KeepKitProviderProps<TMeta>): react.JSX.Element;
|
|
273
|
+
|
|
274
|
+
type CreateKeepKitOptions<TMeta = Record<string, unknown>> = CreateKeepKitOptions$1<TMeta> & Omit<KeepUiProviderProps, "children"> & {
|
|
275
|
+
getTitle?: (item: KeepItem<TMeta>) => ReactNode;
|
|
276
|
+
getImageProps?: (item: KeepItem<TMeta>, title: ReactNode) => KeepImageProps | undefined;
|
|
277
|
+
};
|
|
278
|
+
type KeepKit<TMeta = Record<string, unknown>> = {
|
|
279
|
+
Provider: ComponentType<KeepKitProviderProps<TMeta>>;
|
|
280
|
+
Button: ComponentType<KeepButtonProps<TMeta>>;
|
|
281
|
+
Collection: ComponentType<KeepCollectionProps<TMeta>>;
|
|
282
|
+
useContext: () => ReturnType<typeof useKeepContext<TMeta>>;
|
|
283
|
+
useItem: (item?: KeepItemInput<TMeta>) => ReturnType<typeof useKeepItem<TMeta>>;
|
|
284
|
+
useList: (query?: KeepListQuery<TMeta>) => ReturnType<typeof useKeepList<TMeta>>;
|
|
285
|
+
useShortcut: (options: KeepShortcutOptions<TMeta>) => void;
|
|
286
|
+
};
|
|
287
|
+
/** Create one typed application API for the core and standard UI layer. */
|
|
288
|
+
declare function createKeepKit<TMeta = Record<string, unknown>>(options?: CreateKeepKitOptions<TMeta>): KeepKit<TMeta>;
|
|
274
289
|
|
|
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 };
|
|
290
|
+
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, useKeepUiLabels };
|