@btst/stack 2.5.5 → 2.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 +23 -0
- package/dist/client/components/index.d.cts +9 -9
- package/dist/client/components/index.d.mts +9 -9
- package/dist/client/components/index.d.ts +9 -9
- package/dist/packages/stack/src/plugins/ai-chat/client/components/shared/default-error.cjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/shared/default-error.mjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/plugin.cjs +44 -35
- package/dist/packages/stack/src/plugins/ai-chat/client/plugin.mjs +44 -35
- package/dist/packages/stack/src/plugins/blog/client/components/shared/default-error.cjs +1 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/default-error.mjs +1 -1
- package/dist/packages/stack/src/plugins/blog/client/hooks/use-debounce.cjs +22 -0
- package/dist/packages/stack/src/plugins/blog/client/hooks/use-debounce.mjs +23 -2
- package/dist/packages/stack/src/plugins/blog/client/plugin.cjs +12 -6
- package/dist/packages/stack/src/plugins/blog/client/plugin.mjs +12 -6
- package/dist/packages/stack/src/plugins/cms/client/components/shared/default-error.cjs +1 -1
- package/dist/packages/stack/src/plugins/cms/client/components/shared/default-error.mjs +1 -1
- package/dist/packages/stack/src/plugins/cms/client/plugin.cjs +38 -26
- package/dist/packages/stack/src/plugins/cms/client/plugin.mjs +38 -26
- package/dist/packages/stack/src/plugins/form-builder/client/components/shared/default-error.cjs +1 -1
- package/dist/packages/stack/src/plugins/form-builder/client/components/shared/default-error.mjs +1 -1
- package/dist/packages/stack/src/plugins/form-builder/client/plugin.cjs +32 -20
- package/dist/packages/stack/src/plugins/form-builder/client/plugin.mjs +32 -20
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/default-error.cjs +1 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/default-error.mjs +1 -1
- package/dist/packages/stack/src/plugins/kanban/client/plugin.cjs +6 -3
- package/dist/packages/stack/src/plugins/kanban/client/plugin.mjs +6 -3
- package/dist/packages/stack/src/plugins/ui-builder/client/components/page-renderer.cjs +1 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/components/page-renderer.mjs +1 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.internal.cjs +3 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.internal.mjs +3 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/default-error.cjs +1 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/default-error.mjs +1 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/plugin.cjs +24 -15
- package/dist/packages/stack/src/plugins/ui-builder/client/plugin.mjs +24 -15
- package/dist/packages/ui/src/components/search-select.cjs +13 -3
- package/dist/packages/ui/src/components/search-select.mjs +14 -4
- package/dist/plugins/ai-chat/client/index.d.cts +17 -4
- package/dist/plugins/ai-chat/client/index.d.mts +17 -4
- package/dist/plugins/ai-chat/client/index.d.ts +17 -4
- package/dist/plugins/blog/client/hooks/index.cjs +3 -0
- package/dist/plugins/blog/client/hooks/index.d.cts +7 -226
- package/dist/plugins/blog/client/hooks/index.d.mts +7 -226
- package/dist/plugins/blog/client/hooks/index.d.ts +7 -226
- package/dist/plugins/blog/client/hooks/index.mjs +1 -0
- package/dist/plugins/blog/client/index.d.cts +45 -21
- package/dist/plugins/blog/client/index.d.mts +45 -21
- package/dist/plugins/blog/client/index.d.ts +45 -21
- package/dist/plugins/cms/client/index.d.cts +35 -14
- package/dist/plugins/cms/client/index.d.mts +35 -14
- package/dist/plugins/cms/client/index.d.ts +35 -14
- package/dist/plugins/form-builder/client/components/index.d.cts +1 -1
- package/dist/plugins/form-builder/client/components/index.d.mts +1 -1
- package/dist/plugins/form-builder/client/components/index.d.ts +1 -1
- package/dist/plugins/form-builder/client/index.d.cts +32 -14
- package/dist/plugins/form-builder/client/index.d.mts +32 -14
- package/dist/plugins/form-builder/client/index.d.ts +32 -14
- package/dist/plugins/kanban/api/index.d.cts +1 -1
- package/dist/plugins/kanban/api/index.d.mts +1 -1
- package/dist/plugins/kanban/api/index.d.ts +1 -1
- package/dist/plugins/kanban/client/components/index.d.cts +5 -5
- package/dist/plugins/kanban/client/components/index.d.mts +5 -5
- package/dist/plugins/kanban/client/components/index.d.ts +5 -5
- package/dist/plugins/kanban/client/index.d.cts +25 -10
- package/dist/plugins/kanban/client/index.d.mts +25 -10
- package/dist/plugins/kanban/client/index.d.ts +25 -10
- package/dist/plugins/kanban/query-keys.d.cts +1 -1
- package/dist/plugins/kanban/query-keys.d.mts +1 -1
- package/dist/plugins/kanban/query-keys.d.ts +1 -1
- package/dist/plugins/route-docs/client/index.d.cts +4 -4
- package/dist/plugins/route-docs/client/index.d.mts +4 -4
- package/dist/plugins/route-docs/client/index.d.ts +4 -4
- package/dist/plugins/ui-builder/client/components/index.d.cts +1 -1
- package/dist/plugins/ui-builder/client/components/index.d.mts +1 -1
- package/dist/plugins/ui-builder/client/components/index.d.ts +1 -1
- package/dist/plugins/ui-builder/client/index.d.cts +35 -16
- package/dist/plugins/ui-builder/client/index.d.mts +35 -16
- package/dist/plugins/ui-builder/client/index.d.ts +35 -16
- package/dist/shared/stack.CNLHlv7r.d.mts +228 -0
- package/dist/shared/stack.CQAZwXhV.d.cts +228 -0
- package/dist/shared/stack.D3BsrpAz.d.ts +228 -0
- package/package.json +19 -2
- package/src/__tests__/page-component-overrides.test.tsx +147 -0
- package/src/plugins/ai-chat/client/components/shared/default-error.tsx +1 -1
- package/src/plugins/ai-chat/client/plugin.tsx +60 -32
- package/src/plugins/blog/client/components/shared/default-error.tsx +2 -1
- package/src/plugins/blog/client/hooks/index.tsx +1 -0
- package/src/plugins/blog/client/plugin.tsx +41 -6
- package/src/plugins/cms/client/components/shared/default-error.tsx +3 -2
- package/src/plugins/cms/client/plugin.tsx +65 -32
- package/src/plugins/form-builder/client/components/shared/default-error.tsx +3 -2
- package/src/plugins/form-builder/client/plugin.tsx +56 -23
- package/src/plugins/kanban/client/components/shared/default-error.tsx +3 -2
- package/src/plugins/kanban/client/plugin.tsx +23 -3
- package/src/plugins/ui-builder/client/components/page-renderer.tsx +5 -3
- package/src/plugins/ui-builder/client/components/pages/page-builder-page.internal.tsx +2 -0
- package/src/plugins/ui-builder/client/components/shared/default-error.tsx +3 -2
- package/src/plugins/ui-builder/client/overrides.ts +10 -1
- package/src/plugins/ui-builder/client/plugin.tsx +41 -15
- package/dist/shared/{stack.CxNeGV2z.d.mts → stack.Ba_Ks8qi.d.mts} +9 -9
- package/dist/shared/{stack.DSxTDZBQ.d.cts → stack.CFqqZUes.d.cts} +9 -9
- package/dist/shared/{stack.BFcg0tDz.d.ts → stack.DMobugrZ.d.ts} +9 -9
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as _btst_stack_plugins_client from '@btst/stack/plugins/client';
|
|
2
|
-
import * as react from 'react';
|
|
3
|
-
import react__default, { ComponentType } from 'react';
|
|
4
2
|
import * as _btst_yar from '@btst/yar';
|
|
3
|
+
import React__default, { ComponentType } from 'react';
|
|
5
4
|
import { QueryClient } from '@tanstack/react-query';
|
|
6
5
|
import { c as UIBuilderClientHooks } from '../../../shared/stack.B2DwzF3r.js';
|
|
7
|
-
import { a as ComponentRegistry, b as FieldConfigFunction, C as ComponentLayer } from '../../../shared/stack.D0QupDcQ.js';
|
|
6
|
+
import { a as ComponentRegistry, b as FieldConfigFunction, C as ComponentLayer, F as FunctionRegistry } from '../../../shared/stack.D0QupDcQ.js';
|
|
8
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
9
8
|
import { A as AutoFormInputComponentProps, F as FieldConfigItem } from '../../../shared/stack.8nldKomx.js';
|
|
10
9
|
export { PageBuilderPage, PageListPage, PageRenderer, PageRendererProps, SuspensePageRenderer } from './components/index.js';
|
|
@@ -32,6 +31,21 @@ interface UIBuilderClientConfig {
|
|
|
32
31
|
hooks?: UIBuilderClientHooks;
|
|
33
32
|
/** Component registry to use for the UI Builder */
|
|
34
33
|
componentRegistry?: ComponentRegistry;
|
|
34
|
+
/**
|
|
35
|
+
* Optional page component overrides.
|
|
36
|
+
* Replace any plugin page with a custom React component.
|
|
37
|
+
* The built-in component is used as the fallback when not provided.
|
|
38
|
+
*/
|
|
39
|
+
pageComponents?: {
|
|
40
|
+
/** Replaces the page list page */
|
|
41
|
+
pageList?: ComponentType;
|
|
42
|
+
/** Replaces the new page builder page */
|
|
43
|
+
newPage?: ComponentType;
|
|
44
|
+
/** Replaces the edit page builder page */
|
|
45
|
+
editPage?: ComponentType<{
|
|
46
|
+
id: string;
|
|
47
|
+
}>;
|
|
48
|
+
};
|
|
35
49
|
}
|
|
36
50
|
/**
|
|
37
51
|
* UI Builder client plugin
|
|
@@ -64,9 +78,9 @@ interface UIBuilderClientConfig {
|
|
|
64
78
|
declare const uiBuilderClientPlugin: (config: UIBuilderClientConfig) => _btst_stack_plugins_client.ClientPlugin<Record<string, never>, {
|
|
65
79
|
pageList: {
|
|
66
80
|
(inputCtx_0?: _btst_yar.InputContext<"/ui-builder", _btst_yar.RouteOptions> | undefined): {
|
|
67
|
-
PageComponent?:
|
|
68
|
-
LoadingComponent?:
|
|
69
|
-
ErrorComponent?:
|
|
81
|
+
PageComponent?: ComponentType<{}> | undefined;
|
|
82
|
+
LoadingComponent?: ComponentType<{}> | undefined;
|
|
83
|
+
ErrorComponent?: ComponentType<{}> | undefined;
|
|
70
84
|
loader?: (() => Promise<void>) | undefined;
|
|
71
85
|
meta?: (() => ({
|
|
72
86
|
title: string;
|
|
@@ -85,9 +99,9 @@ declare const uiBuilderClientPlugin: (config: UIBuilderClientConfig) => _btst_st
|
|
|
85
99
|
};
|
|
86
100
|
newPage: {
|
|
87
101
|
(inputCtx_0?: _btst_yar.InputContext<"/ui-builder/new", _btst_yar.RouteOptions> | undefined): {
|
|
88
|
-
PageComponent?:
|
|
89
|
-
LoadingComponent?:
|
|
90
|
-
ErrorComponent?:
|
|
102
|
+
PageComponent?: ComponentType<{}> | undefined;
|
|
103
|
+
LoadingComponent?: ComponentType<{}> | undefined;
|
|
104
|
+
ErrorComponent?: ComponentType<{}> | undefined;
|
|
91
105
|
loader?: (() => Promise<void>) | undefined;
|
|
92
106
|
meta?: (() => ({
|
|
93
107
|
title: string;
|
|
@@ -106,9 +120,9 @@ declare const uiBuilderClientPlugin: (config: UIBuilderClientConfig) => _btst_st
|
|
|
106
120
|
};
|
|
107
121
|
editPage: {
|
|
108
122
|
(inputCtx_0: _btst_yar.InputContext<"/ui-builder/:id/edit", _btst_yar.RouteOptions>): {
|
|
109
|
-
PageComponent?:
|
|
110
|
-
LoadingComponent?:
|
|
111
|
-
ErrorComponent?:
|
|
123
|
+
PageComponent?: ComponentType<unknown> | undefined;
|
|
124
|
+
LoadingComponent?: ComponentType<unknown> | undefined;
|
|
125
|
+
ErrorComponent?: ComponentType<unknown> | undefined;
|
|
112
126
|
loader?: (() => Promise<void>) | undefined;
|
|
113
127
|
meta?: (() => ({
|
|
114
128
|
title: string;
|
|
@@ -202,20 +216,20 @@ declare function createComponentRegistry(components: ComponentRegistry): Compone
|
|
|
202
216
|
declare const classNameFieldOverrides: FieldConfigFunction;
|
|
203
217
|
declare const childrenFieldOverrides: (layer: ComponentLayer, allowVariableBinding?: boolean) => {
|
|
204
218
|
renderParent: (({ children }: {
|
|
205
|
-
children:
|
|
219
|
+
children: React__default.ReactNode;
|
|
206
220
|
}) => react_jsx_runtime.JSX.Element) | undefined;
|
|
207
221
|
fieldType: ({ label, isRequired, fieldConfigItem, field, fieldProps, }: AutoFormInputComponentProps) => react_jsx_runtime.JSX.Element;
|
|
208
222
|
};
|
|
209
223
|
declare const iconNameFieldOverrides: FieldConfigFunction;
|
|
210
224
|
declare const childrenAsTextareaFieldOverrides: (layer: ComponentLayer, allowVariableBinding?: boolean) => {
|
|
211
225
|
renderParent: (({ children }: {
|
|
212
|
-
children:
|
|
226
|
+
children: React__default.ReactNode;
|
|
213
227
|
}) => react_jsx_runtime.JSX.Element) | undefined;
|
|
214
228
|
fieldType: ({ label, isRequired, fieldConfigItem, field, fieldProps, }: AutoFormInputComponentProps) => react_jsx_runtime.JSX.Element;
|
|
215
229
|
};
|
|
216
230
|
declare const childrenAsTipTapFieldOverrides: (layer: ComponentLayer, allowVariableBinding?: boolean) => {
|
|
217
231
|
renderParent: (({ children }: {
|
|
218
|
-
children:
|
|
232
|
+
children: React__default.ReactNode;
|
|
219
233
|
}) => react_jsx_runtime.JSX.Element) | undefined;
|
|
220
234
|
fieldType: ({ label, isRequired, fieldConfigItem, field, fieldProps, }: AutoFormInputComponentProps) => react_jsx_runtime.JSX.Element;
|
|
221
235
|
};
|
|
@@ -223,7 +237,7 @@ declare const commonFieldOverrides: (allowBinding?: boolean) => Record<string, (
|
|
|
223
237
|
className: (layer: ComponentLayer) => FieldConfigItem;
|
|
224
238
|
children: (layer: ComponentLayer) => {
|
|
225
239
|
renderParent: (({ children }: {
|
|
226
|
-
children:
|
|
240
|
+
children: React__default.ReactNode;
|
|
227
241
|
}) => react_jsx_runtime.JSX.Element) | undefined;
|
|
228
242
|
fieldType: ({ label, isRequired, fieldConfigItem, field, fieldProps, }: AutoFormInputComponentProps) => react_jsx_runtime.JSX.Element;
|
|
229
243
|
};
|
|
@@ -342,6 +356,11 @@ interface UIBuilderPluginOverrides {
|
|
|
342
356
|
* Component registry for the UI Builder
|
|
343
357
|
*/
|
|
344
358
|
componentRegistry?: ComponentRegistry;
|
|
359
|
+
/**
|
|
360
|
+
* Function registry for resolving bindable event handlers (onClick, onSubmit, etc.)
|
|
361
|
+
* in the preview modal and layer renderer.
|
|
362
|
+
*/
|
|
363
|
+
functionRegistry?: FunctionRegistry;
|
|
345
364
|
/**
|
|
346
365
|
* Base path for UI Builder admin pages (default: /pages/ui-builder)
|
|
347
366
|
*/
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
+
import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from './stack.BWp0hcm9.mjs';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Options for the usePosts hook
|
|
7
|
+
*/
|
|
8
|
+
interface UsePostsOptions {
|
|
9
|
+
/** Filter posts by tag name */
|
|
10
|
+
tag?: string;
|
|
11
|
+
/** Filter posts by tag slug */
|
|
12
|
+
tagSlug?: string;
|
|
13
|
+
/** Number of posts to fetch per page (default: 10) */
|
|
14
|
+
limit?: number;
|
|
15
|
+
/** Whether to enable the query (default: true) */
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
/** Search query to filter posts by title, content, or excerpt */
|
|
18
|
+
query?: string;
|
|
19
|
+
/** Filter by published status */
|
|
20
|
+
published?: boolean;
|
|
21
|
+
/** Filter by specific post slug */
|
|
22
|
+
slug?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Result from the usePosts hook
|
|
26
|
+
*/
|
|
27
|
+
interface UsePostsResult {
|
|
28
|
+
/** Array of fetched posts */
|
|
29
|
+
posts: SerializedPost[];
|
|
30
|
+
/** Whether the initial load is in progress */
|
|
31
|
+
isLoading: boolean;
|
|
32
|
+
/** Error if the query failed */
|
|
33
|
+
error: Error | null;
|
|
34
|
+
/** Function to load the next page of posts */
|
|
35
|
+
loadMore: () => void;
|
|
36
|
+
/** Whether there are more posts to load */
|
|
37
|
+
hasMore: boolean;
|
|
38
|
+
/** Whether the next page is being loaded */
|
|
39
|
+
isLoadingMore: boolean;
|
|
40
|
+
/** Function to refetch the posts */
|
|
41
|
+
refetch: () => void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Options for the usePostSearch hook
|
|
45
|
+
*/
|
|
46
|
+
interface UsePostSearchOptions {
|
|
47
|
+
/** Search query string to filter posts */
|
|
48
|
+
query: string;
|
|
49
|
+
/** Whether to enable the search query (default: true) */
|
|
50
|
+
enabled?: boolean;
|
|
51
|
+
/** Debounce delay in milliseconds (default: 300) */
|
|
52
|
+
debounceMs?: number;
|
|
53
|
+
/** Number of results to return (default: 10) */
|
|
54
|
+
limit?: number;
|
|
55
|
+
/** Filter by published status (default: true) */
|
|
56
|
+
published?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Result from the usePostSearch hook
|
|
60
|
+
*/
|
|
61
|
+
interface UsePostSearchResult {
|
|
62
|
+
/** Array of posts matching the search query */
|
|
63
|
+
posts: SerializedPost[];
|
|
64
|
+
/** Alias for posts (React Query compatibility) */
|
|
65
|
+
data: SerializedPost[];
|
|
66
|
+
/** Whether the search is in progress */
|
|
67
|
+
isLoading: boolean;
|
|
68
|
+
/** Error if the search failed */
|
|
69
|
+
error: Error | null;
|
|
70
|
+
/** Function to refetch the search results */
|
|
71
|
+
refetch: () => void;
|
|
72
|
+
/** Whether a search is currently in progress (includes debounce time) */
|
|
73
|
+
isSearching: boolean;
|
|
74
|
+
/** The debounced search query being used */
|
|
75
|
+
searchQuery: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Result from the usePost hook
|
|
79
|
+
*/
|
|
80
|
+
interface UsePostResult {
|
|
81
|
+
/** The fetched post, or null if not found */
|
|
82
|
+
post: SerializedPost | null;
|
|
83
|
+
/** Whether the post is being loaded */
|
|
84
|
+
isLoading: boolean;
|
|
85
|
+
/** Error if the query failed */
|
|
86
|
+
error: Error | null;
|
|
87
|
+
/** Function to refetch the post */
|
|
88
|
+
refetch: () => void;
|
|
89
|
+
}
|
|
90
|
+
/** Input type for creating a new post */
|
|
91
|
+
type PostCreateInput = z.infer<typeof createPostSchema>;
|
|
92
|
+
/** Input type for updating an existing post */
|
|
93
|
+
type PostUpdateInput = z.infer<typeof updatePostSchema>;
|
|
94
|
+
/**
|
|
95
|
+
* Hook for fetching paginated posts with load more functionality
|
|
96
|
+
*/
|
|
97
|
+
declare function usePosts(options?: UsePostsOptions): UsePostsResult;
|
|
98
|
+
/** Suspense variant of usePosts */
|
|
99
|
+
declare function useSuspensePosts(options?: UsePostsOptions): {
|
|
100
|
+
posts: SerializedPost[];
|
|
101
|
+
loadMore: () => Promise<unknown>;
|
|
102
|
+
hasMore: boolean;
|
|
103
|
+
isLoadingMore: boolean;
|
|
104
|
+
refetch: () => Promise<unknown>;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Hook for fetching a single post by slug
|
|
108
|
+
*/
|
|
109
|
+
declare function usePost(slug?: string): UsePostResult;
|
|
110
|
+
/** Suspense variant of usePost */
|
|
111
|
+
declare function useSuspensePost(slug: string): {
|
|
112
|
+
post: SerializedPost | null;
|
|
113
|
+
refetch: () => Promise<unknown>;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Hook for fetching all unique tags across posts
|
|
117
|
+
*/
|
|
118
|
+
declare function useTags(): {
|
|
119
|
+
tags: SerializedTag[];
|
|
120
|
+
isLoading: boolean;
|
|
121
|
+
error: Error | null;
|
|
122
|
+
refetch: () => void;
|
|
123
|
+
};
|
|
124
|
+
/** Suspense variant of useTags */
|
|
125
|
+
declare function useSuspenseTags(): {
|
|
126
|
+
tags: SerializedTag[];
|
|
127
|
+
refetch: () => Promise<unknown>;
|
|
128
|
+
};
|
|
129
|
+
/** Create a new post */
|
|
130
|
+
declare function useCreatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
|
|
131
|
+
tags: ({
|
|
132
|
+
name: string;
|
|
133
|
+
} | {
|
|
134
|
+
id: string;
|
|
135
|
+
name: string;
|
|
136
|
+
slug: string;
|
|
137
|
+
})[];
|
|
138
|
+
published: boolean;
|
|
139
|
+
title: string;
|
|
140
|
+
content: string;
|
|
141
|
+
excerpt: string;
|
|
142
|
+
slug?: string | undefined;
|
|
143
|
+
publishedAt?: Date | undefined;
|
|
144
|
+
createdAt?: Date | undefined;
|
|
145
|
+
updatedAt?: Date | undefined;
|
|
146
|
+
image?: string | undefined;
|
|
147
|
+
}, unknown>;
|
|
148
|
+
/** Update an existing post by id */
|
|
149
|
+
declare function useUpdatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
|
|
150
|
+
id: string;
|
|
151
|
+
data: PostUpdateInput;
|
|
152
|
+
}, unknown>;
|
|
153
|
+
/** Delete a post by id */
|
|
154
|
+
declare function useDeletePost(): _tanstack_react_query.UseMutationResult<{
|
|
155
|
+
success: boolean;
|
|
156
|
+
}, Error, {
|
|
157
|
+
id: string;
|
|
158
|
+
}, unknown>;
|
|
159
|
+
/**
|
|
160
|
+
* Hook for searching posts by a free-text query. Uses `usePosts` under the hood.
|
|
161
|
+
* Debounces the query and preserves last successful results to avoid flicker.
|
|
162
|
+
*/
|
|
163
|
+
declare function usePostSearch({ query, enabled, debounceMs, limit, published, }: UsePostSearchOptions): UsePostSearchResult;
|
|
164
|
+
/**
|
|
165
|
+
* Options for the useNextPreviousPosts hook
|
|
166
|
+
*/
|
|
167
|
+
interface UseNextPreviousPostsOptions {
|
|
168
|
+
/** Whether to enable the query (default: true) */
|
|
169
|
+
enabled?: boolean;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Result from the useNextPreviousPosts hook
|
|
173
|
+
*/
|
|
174
|
+
interface UseNextPreviousPostsResult {
|
|
175
|
+
/** The previous post (older), or null if none exists */
|
|
176
|
+
previousPost: SerializedPost | null;
|
|
177
|
+
/** The next post (newer), or null if none exists */
|
|
178
|
+
nextPost: SerializedPost | null;
|
|
179
|
+
/** Whether the query is loading */
|
|
180
|
+
isLoading: boolean;
|
|
181
|
+
/** Error if the query failed */
|
|
182
|
+
error: Error | null;
|
|
183
|
+
/** Function to refetch the posts */
|
|
184
|
+
refetch: () => void;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Hook for fetching previous and next posts relative to a given date
|
|
188
|
+
* Uses useInView to only fetch when the component is in view
|
|
189
|
+
*/
|
|
190
|
+
declare function useNextPreviousPosts(createdAt: string | Date, options?: UseNextPreviousPostsOptions): UseNextPreviousPostsResult & {
|
|
191
|
+
ref: (node: Element | null) => void;
|
|
192
|
+
inView: boolean;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Options for the useRecentPosts hook
|
|
196
|
+
*/
|
|
197
|
+
interface UseRecentPostsOptions {
|
|
198
|
+
/** Maximum number of recent posts to fetch (default: 5) */
|
|
199
|
+
limit?: number;
|
|
200
|
+
/** Slug of a post to exclude from results */
|
|
201
|
+
excludeSlug?: string;
|
|
202
|
+
/** Whether to enable the query (default: true) */
|
|
203
|
+
enabled?: boolean;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Result from the useRecentPosts hook
|
|
207
|
+
*/
|
|
208
|
+
interface UseRecentPostsResult {
|
|
209
|
+
/** Array of recent posts */
|
|
210
|
+
recentPosts: SerializedPost[];
|
|
211
|
+
/** Whether the query is loading */
|
|
212
|
+
isLoading: boolean;
|
|
213
|
+
/** Error if the query failed */
|
|
214
|
+
error: Error | null;
|
|
215
|
+
/** Function to refetch the posts */
|
|
216
|
+
refetch: () => void;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Hook for fetching recent posts
|
|
220
|
+
* Uses useInView to only fetch when the component is in view
|
|
221
|
+
*/
|
|
222
|
+
declare function useRecentPosts(options?: UseRecentPostsOptions): UseRecentPostsResult & {
|
|
223
|
+
ref: (node: Element | null) => void;
|
|
224
|
+
inView: boolean;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export { useSuspensePosts as f, usePost as g, useSuspensePost as h, useTags as i, useSuspenseTags as j, useCreatePost as k, useUpdatePost as l, useDeletePost as m, usePostSearch as n, useNextPreviousPosts as q, useRecentPosts as t, usePosts as u };
|
|
228
|
+
export type { PostCreateInput as P, UsePostsOptions as U, UsePostsResult as a, UsePostSearchOptions as b, UsePostSearchResult as c, UsePostResult as d, PostUpdateInput as e, UseNextPreviousPostsOptions as o, UseNextPreviousPostsResult as p, UseRecentPostsOptions as r, UseRecentPostsResult as s };
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
+
import { S as SerializedPost, c as createPostSchema, u as updatePostSchema, a as SerializedTag } from './stack.BWp0hcm9.cjs';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Options for the usePosts hook
|
|
7
|
+
*/
|
|
8
|
+
interface UsePostsOptions {
|
|
9
|
+
/** Filter posts by tag name */
|
|
10
|
+
tag?: string;
|
|
11
|
+
/** Filter posts by tag slug */
|
|
12
|
+
tagSlug?: string;
|
|
13
|
+
/** Number of posts to fetch per page (default: 10) */
|
|
14
|
+
limit?: number;
|
|
15
|
+
/** Whether to enable the query (default: true) */
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
/** Search query to filter posts by title, content, or excerpt */
|
|
18
|
+
query?: string;
|
|
19
|
+
/** Filter by published status */
|
|
20
|
+
published?: boolean;
|
|
21
|
+
/** Filter by specific post slug */
|
|
22
|
+
slug?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Result from the usePosts hook
|
|
26
|
+
*/
|
|
27
|
+
interface UsePostsResult {
|
|
28
|
+
/** Array of fetched posts */
|
|
29
|
+
posts: SerializedPost[];
|
|
30
|
+
/** Whether the initial load is in progress */
|
|
31
|
+
isLoading: boolean;
|
|
32
|
+
/** Error if the query failed */
|
|
33
|
+
error: Error | null;
|
|
34
|
+
/** Function to load the next page of posts */
|
|
35
|
+
loadMore: () => void;
|
|
36
|
+
/** Whether there are more posts to load */
|
|
37
|
+
hasMore: boolean;
|
|
38
|
+
/** Whether the next page is being loaded */
|
|
39
|
+
isLoadingMore: boolean;
|
|
40
|
+
/** Function to refetch the posts */
|
|
41
|
+
refetch: () => void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Options for the usePostSearch hook
|
|
45
|
+
*/
|
|
46
|
+
interface UsePostSearchOptions {
|
|
47
|
+
/** Search query string to filter posts */
|
|
48
|
+
query: string;
|
|
49
|
+
/** Whether to enable the search query (default: true) */
|
|
50
|
+
enabled?: boolean;
|
|
51
|
+
/** Debounce delay in milliseconds (default: 300) */
|
|
52
|
+
debounceMs?: number;
|
|
53
|
+
/** Number of results to return (default: 10) */
|
|
54
|
+
limit?: number;
|
|
55
|
+
/** Filter by published status (default: true) */
|
|
56
|
+
published?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Result from the usePostSearch hook
|
|
60
|
+
*/
|
|
61
|
+
interface UsePostSearchResult {
|
|
62
|
+
/** Array of posts matching the search query */
|
|
63
|
+
posts: SerializedPost[];
|
|
64
|
+
/** Alias for posts (React Query compatibility) */
|
|
65
|
+
data: SerializedPost[];
|
|
66
|
+
/** Whether the search is in progress */
|
|
67
|
+
isLoading: boolean;
|
|
68
|
+
/** Error if the search failed */
|
|
69
|
+
error: Error | null;
|
|
70
|
+
/** Function to refetch the search results */
|
|
71
|
+
refetch: () => void;
|
|
72
|
+
/** Whether a search is currently in progress (includes debounce time) */
|
|
73
|
+
isSearching: boolean;
|
|
74
|
+
/** The debounced search query being used */
|
|
75
|
+
searchQuery: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Result from the usePost hook
|
|
79
|
+
*/
|
|
80
|
+
interface UsePostResult {
|
|
81
|
+
/** The fetched post, or null if not found */
|
|
82
|
+
post: SerializedPost | null;
|
|
83
|
+
/** Whether the post is being loaded */
|
|
84
|
+
isLoading: boolean;
|
|
85
|
+
/** Error if the query failed */
|
|
86
|
+
error: Error | null;
|
|
87
|
+
/** Function to refetch the post */
|
|
88
|
+
refetch: () => void;
|
|
89
|
+
}
|
|
90
|
+
/** Input type for creating a new post */
|
|
91
|
+
type PostCreateInput = z.infer<typeof createPostSchema>;
|
|
92
|
+
/** Input type for updating an existing post */
|
|
93
|
+
type PostUpdateInput = z.infer<typeof updatePostSchema>;
|
|
94
|
+
/**
|
|
95
|
+
* Hook for fetching paginated posts with load more functionality
|
|
96
|
+
*/
|
|
97
|
+
declare function usePosts(options?: UsePostsOptions): UsePostsResult;
|
|
98
|
+
/** Suspense variant of usePosts */
|
|
99
|
+
declare function useSuspensePosts(options?: UsePostsOptions): {
|
|
100
|
+
posts: SerializedPost[];
|
|
101
|
+
loadMore: () => Promise<unknown>;
|
|
102
|
+
hasMore: boolean;
|
|
103
|
+
isLoadingMore: boolean;
|
|
104
|
+
refetch: () => Promise<unknown>;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Hook for fetching a single post by slug
|
|
108
|
+
*/
|
|
109
|
+
declare function usePost(slug?: string): UsePostResult;
|
|
110
|
+
/** Suspense variant of usePost */
|
|
111
|
+
declare function useSuspensePost(slug: string): {
|
|
112
|
+
post: SerializedPost | null;
|
|
113
|
+
refetch: () => Promise<unknown>;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Hook for fetching all unique tags across posts
|
|
117
|
+
*/
|
|
118
|
+
declare function useTags(): {
|
|
119
|
+
tags: SerializedTag[];
|
|
120
|
+
isLoading: boolean;
|
|
121
|
+
error: Error | null;
|
|
122
|
+
refetch: () => void;
|
|
123
|
+
};
|
|
124
|
+
/** Suspense variant of useTags */
|
|
125
|
+
declare function useSuspenseTags(): {
|
|
126
|
+
tags: SerializedTag[];
|
|
127
|
+
refetch: () => Promise<unknown>;
|
|
128
|
+
};
|
|
129
|
+
/** Create a new post */
|
|
130
|
+
declare function useCreatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
|
|
131
|
+
tags: ({
|
|
132
|
+
name: string;
|
|
133
|
+
} | {
|
|
134
|
+
id: string;
|
|
135
|
+
name: string;
|
|
136
|
+
slug: string;
|
|
137
|
+
})[];
|
|
138
|
+
published: boolean;
|
|
139
|
+
title: string;
|
|
140
|
+
content: string;
|
|
141
|
+
excerpt: string;
|
|
142
|
+
slug?: string | undefined;
|
|
143
|
+
publishedAt?: Date | undefined;
|
|
144
|
+
createdAt?: Date | undefined;
|
|
145
|
+
updatedAt?: Date | undefined;
|
|
146
|
+
image?: string | undefined;
|
|
147
|
+
}, unknown>;
|
|
148
|
+
/** Update an existing post by id */
|
|
149
|
+
declare function useUpdatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
|
|
150
|
+
id: string;
|
|
151
|
+
data: PostUpdateInput;
|
|
152
|
+
}, unknown>;
|
|
153
|
+
/** Delete a post by id */
|
|
154
|
+
declare function useDeletePost(): _tanstack_react_query.UseMutationResult<{
|
|
155
|
+
success: boolean;
|
|
156
|
+
}, Error, {
|
|
157
|
+
id: string;
|
|
158
|
+
}, unknown>;
|
|
159
|
+
/**
|
|
160
|
+
* Hook for searching posts by a free-text query. Uses `usePosts` under the hood.
|
|
161
|
+
* Debounces the query and preserves last successful results to avoid flicker.
|
|
162
|
+
*/
|
|
163
|
+
declare function usePostSearch({ query, enabled, debounceMs, limit, published, }: UsePostSearchOptions): UsePostSearchResult;
|
|
164
|
+
/**
|
|
165
|
+
* Options for the useNextPreviousPosts hook
|
|
166
|
+
*/
|
|
167
|
+
interface UseNextPreviousPostsOptions {
|
|
168
|
+
/** Whether to enable the query (default: true) */
|
|
169
|
+
enabled?: boolean;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Result from the useNextPreviousPosts hook
|
|
173
|
+
*/
|
|
174
|
+
interface UseNextPreviousPostsResult {
|
|
175
|
+
/** The previous post (older), or null if none exists */
|
|
176
|
+
previousPost: SerializedPost | null;
|
|
177
|
+
/** The next post (newer), or null if none exists */
|
|
178
|
+
nextPost: SerializedPost | null;
|
|
179
|
+
/** Whether the query is loading */
|
|
180
|
+
isLoading: boolean;
|
|
181
|
+
/** Error if the query failed */
|
|
182
|
+
error: Error | null;
|
|
183
|
+
/** Function to refetch the posts */
|
|
184
|
+
refetch: () => void;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Hook for fetching previous and next posts relative to a given date
|
|
188
|
+
* Uses useInView to only fetch when the component is in view
|
|
189
|
+
*/
|
|
190
|
+
declare function useNextPreviousPosts(createdAt: string | Date, options?: UseNextPreviousPostsOptions): UseNextPreviousPostsResult & {
|
|
191
|
+
ref: (node: Element | null) => void;
|
|
192
|
+
inView: boolean;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Options for the useRecentPosts hook
|
|
196
|
+
*/
|
|
197
|
+
interface UseRecentPostsOptions {
|
|
198
|
+
/** Maximum number of recent posts to fetch (default: 5) */
|
|
199
|
+
limit?: number;
|
|
200
|
+
/** Slug of a post to exclude from results */
|
|
201
|
+
excludeSlug?: string;
|
|
202
|
+
/** Whether to enable the query (default: true) */
|
|
203
|
+
enabled?: boolean;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Result from the useRecentPosts hook
|
|
207
|
+
*/
|
|
208
|
+
interface UseRecentPostsResult {
|
|
209
|
+
/** Array of recent posts */
|
|
210
|
+
recentPosts: SerializedPost[];
|
|
211
|
+
/** Whether the query is loading */
|
|
212
|
+
isLoading: boolean;
|
|
213
|
+
/** Error if the query failed */
|
|
214
|
+
error: Error | null;
|
|
215
|
+
/** Function to refetch the posts */
|
|
216
|
+
refetch: () => void;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Hook for fetching recent posts
|
|
220
|
+
* Uses useInView to only fetch when the component is in view
|
|
221
|
+
*/
|
|
222
|
+
declare function useRecentPosts(options?: UseRecentPostsOptions): UseRecentPostsResult & {
|
|
223
|
+
ref: (node: Element | null) => void;
|
|
224
|
+
inView: boolean;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export { useSuspensePosts as f, usePost as g, useSuspensePost as h, useTags as i, useSuspenseTags as j, useCreatePost as k, useUpdatePost as l, useDeletePost as m, usePostSearch as n, useNextPreviousPosts as q, useRecentPosts as t, usePosts as u };
|
|
228
|
+
export type { PostCreateInput as P, UsePostsOptions as U, UsePostsResult as a, UsePostSearchOptions as b, UsePostSearchResult as c, UsePostResult as d, PostUpdateInput as e, UseNextPreviousPostsOptions as o, UseNextPreviousPostsResult as p, UseRecentPostsOptions as r, UseRecentPostsResult as s };
|