@btst/plugin-form-builder 0.0.0-stage → 1.0.0-beta.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/LICENSE.md +17 -0
- package/dist/api/getters.cjs +154 -0
- package/dist/api/getters.mjs +145 -0
- package/dist/api/index.cjs +25 -0
- package/dist/api/index.d.cts +119 -0
- package/dist/api/index.d.mts +119 -0
- package/dist/api/index.d.ts +119 -0
- package/dist/api/index.mjs +6 -0
- package/dist/api/lifecycle-migrations.cjs +15 -0
- package/dist/api/lifecycle-migrations.mjs +13 -0
- package/dist/api/operations.cjs +1093 -0
- package/dist/api/operations.mjs +1082 -0
- package/dist/api/plugin.cjs +201 -0
- package/dist/api/plugin.mjs +192 -0
- package/dist/api/query-key-defs.cjs +43 -0
- package/dist/api/query-key-defs.mjs +39 -0
- package/dist/client/components/forms/form-renderer.cjs +193 -0
- package/dist/client/components/forms/form-renderer.mjs +191 -0
- package/dist/client/components/index.cjs +29 -0
- package/dist/client/components/index.d.cts +97 -0
- package/dist/client/components/index.d.mts +97 -0
- package/dist/client/components/index.d.ts +97 -0
- package/dist/client/components/index.mjs +18 -0
- package/dist/client/components/loading/form-builder-skeleton.cjs +32 -0
- package/dist/client/components/loading/form-builder-skeleton.mjs +30 -0
- package/dist/client/components/loading/form-list-skeleton.cjs +21 -0
- package/dist/client/components/loading/form-list-skeleton.mjs +19 -0
- package/dist/client/components/loading/submissions-skeleton.cjs +34 -0
- package/dist/client/components/loading/submissions-skeleton.mjs +32 -0
- package/dist/client/components/pages/404-page.cjs +28 -0
- package/dist/client/components/pages/404-page.mjs +26 -0
- package/dist/client/components/pages/form-builder-page.cjs +77 -0
- package/dist/client/components/pages/form-builder-page.internal.cjs +217 -0
- package/dist/client/components/pages/form-builder-page.internal.mjs +215 -0
- package/dist/client/components/pages/form-builder-page.mjs +75 -0
- package/dist/client/components/pages/form-list-page.cjs +44 -0
- package/dist/client/components/pages/form-list-page.internal.cjs +282 -0
- package/dist/client/components/pages/form-list-page.internal.mjs +280 -0
- package/dist/client/components/pages/form-list-page.mjs +42 -0
- package/dist/client/components/pages/submissions-page.cjs +64 -0
- package/dist/client/components/pages/submissions-page.internal.cjs +255 -0
- package/dist/client/components/pages/submissions-page.internal.mjs +253 -0
- package/dist/client/components/pages/submissions-page.mjs +62 -0
- package/dist/client/components/shared/default-error.cjs +17 -0
- package/dist/client/components/shared/default-error.mjs +15 -0
- package/dist/client/components/shared/empty-state.cjs +16 -0
- package/dist/client/components/shared/empty-state.mjs +14 -0
- package/dist/client/components/shared/page-wrapper.cjs +29 -0
- package/dist/client/components/shared/page-wrapper.mjs +27 -0
- package/dist/client/components/shared/pagination.cjs +49 -0
- package/dist/client/components/shared/pagination.mjs +47 -0
- package/dist/client/constants.cjs +5 -0
- package/dist/client/constants.mjs +3 -0
- package/dist/client/hooks/form-builder-hooks.cjs +203 -0
- package/dist/client/hooks/form-builder-hooks.mjs +186 -0
- package/dist/client/hooks/form-builder-resource.cjs +13 -0
- package/dist/client/hooks/form-builder-resource.mjs +11 -0
- package/dist/client/hooks/index.cjs +22 -0
- package/dist/client/hooks/index.d.cts +378 -0
- package/dist/client/hooks/index.d.mts +378 -0
- package/dist/client/hooks/index.d.ts +378 -0
- package/dist/client/hooks/index.mjs +1 -0
- package/dist/client/index.cjs +13 -0
- package/dist/client/index.d.cts +410 -0
- package/dist/client/index.d.mts +410 -0
- package/dist/client/index.d.ts +410 -0
- package/dist/client/index.mjs +2 -0
- package/dist/client/plugin.cjs +311 -0
- package/dist/client/plugin.mjs +309 -0
- package/dist/client.css +3 -0
- package/dist/db.cjs +99 -0
- package/dist/db.mjs +97 -0
- package/dist/permissions.cjs +95 -0
- package/dist/permissions.d.cts +94 -0
- package/dist/permissions.d.mts +94 -0
- package/dist/permissions.d.ts +94 -0
- package/dist/permissions.mjs +93 -0
- package/dist/query-keys.cjs +140 -0
- package/dist/query-keys.d.cts +392 -0
- package/dist/query-keys.d.mts +392 -0
- package/dist/query-keys.d.ts +392 -0
- package/dist/query-keys.mjs +137 -0
- package/dist/schemas.cjs +91 -0
- package/dist/schemas.mjs +82 -0
- package/dist/shared/plugin-form-builder.BZYGyFgT.d.mts +351 -0
- package/dist/shared/plugin-form-builder.Bbl9NufB.d.cts +408 -0
- package/dist/shared/plugin-form-builder.CSP5HR2O.d.ts +408 -0
- package/dist/shared/plugin-form-builder.Cmk083dA.d.cts +351 -0
- package/dist/shared/plugin-form-builder.D258Qpb8.d.ts +351 -0
- package/dist/shared/plugin-form-builder.DWrQ3lRX.d.cts +118 -0
- package/dist/shared/plugin-form-builder.DWrQ3lRX.d.mts +118 -0
- package/dist/shared/plugin-form-builder.DWrQ3lRX.d.ts +118 -0
- package/dist/shared/plugin-form-builder.lp98rFNl.d.mts +408 -0
- package/dist/style.css +6 -0
- package/dist/types.cjs +2 -0
- package/dist/types.d.cts +6 -0
- package/dist/types.d.mts +6 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.mjs +1 -0
- package/dist/ui/src/components/accordion.cjs +81 -0
- package/dist/ui/src/components/accordion.mjs +62 -0
- package/dist/ui/src/components/alert-dialog.cjs +157 -0
- package/dist/ui/src/components/alert-dialog.mjs +132 -0
- package/dist/ui/src/components/auto-form/common/label.cjs +18 -0
- package/dist/ui/src/components/auto-form/common/label.mjs +16 -0
- package/dist/ui/src/components/auto-form/common/tooltip.cjs +9 -0
- package/dist/ui/src/components/auto-form/common/tooltip.mjs +7 -0
- package/dist/ui/src/components/auto-form/config.cjs +40 -0
- package/dist/ui/src/components/auto-form/config.mjs +37 -0
- package/dist/ui/src/components/auto-form/dependencies.cjs +48 -0
- package/dist/ui/src/components/auto-form/dependencies.mjs +46 -0
- package/dist/ui/src/components/auto-form/fields/array.cjs +266 -0
- package/dist/ui/src/components/auto-form/fields/array.mjs +264 -0
- package/dist/ui/src/components/auto-form/fields/checkbox.cjs +38 -0
- package/dist/ui/src/components/auto-form/fields/checkbox.mjs +36 -0
- package/dist/ui/src/components/auto-form/fields/date.cjs +67 -0
- package/dist/ui/src/components/auto-form/fields/date.mjs +65 -0
- package/dist/ui/src/components/auto-form/fields/enum.cjs +73 -0
- package/dist/ui/src/components/auto-form/fields/enum.mjs +71 -0
- package/dist/ui/src/components/auto-form/fields/input.cjs +32 -0
- package/dist/ui/src/components/auto-form/fields/input.mjs +30 -0
- package/dist/ui/src/components/auto-form/fields/number.cjs +31 -0
- package/dist/ui/src/components/auto-form/fields/number.mjs +29 -0
- package/dist/ui/src/components/auto-form/fields/object.cjs +233 -0
- package/dist/ui/src/components/auto-form/fields/object.mjs +217 -0
- package/dist/ui/src/components/auto-form/fields/radio-group.cjs +67 -0
- package/dist/ui/src/components/auto-form/fields/radio-group.mjs +65 -0
- package/dist/ui/src/components/auto-form/fields/switch.cjs +38 -0
- package/dist/ui/src/components/auto-form/fields/switch.mjs +36 -0
- package/dist/ui/src/components/auto-form/fields/textarea.cjs +31 -0
- package/dist/ui/src/components/auto-form/fields/textarea.mjs +29 -0
- package/dist/ui/src/components/auto-form/helpers.cjs +270 -0
- package/dist/ui/src/components/auto-form/helpers.mjs +259 -0
- package/dist/ui/src/components/auto-form/index.cjs +92 -0
- package/dist/ui/src/components/auto-form/index.mjs +86 -0
- package/dist/ui/src/components/auto-form/stepped-auto-form.cjs +374 -0
- package/dist/ui/src/components/auto-form/stepped-auto-form.mjs +368 -0
- package/dist/ui/src/components/auto-form/types.cjs +11 -0
- package/dist/ui/src/components/auto-form/types.mjs +9 -0
- package/dist/ui/src/components/button.cjs +56 -0
- package/dist/ui/src/components/button.mjs +53 -0
- package/dist/ui/src/components/calendar.cjs +207 -0
- package/dist/ui/src/components/calendar.mjs +190 -0
- package/dist/ui/src/components/checkbox.cjs +48 -0
- package/dist/ui/src/components/checkbox.mjs +32 -0
- package/dist/ui/src/components/date-picker.cjs +41 -0
- package/dist/ui/src/components/date-picker.mjs +39 -0
- package/dist/ui/src/components/dialog.cjs +141 -0
- package/dist/ui/src/components/dialog.mjs +118 -0
- package/dist/ui/src/components/dropdown-menu.cjs +81 -0
- package/dist/ui/src/components/dropdown-menu.mjs +62 -0
- package/dist/ui/src/components/form-builder/canvas.cjs +111 -0
- package/dist/ui/src/components/form-builder/canvas.mjs +109 -0
- package/dist/ui/src/components/form-builder/components/index.cjs +571 -0
- package/dist/ui/src/components/form-builder/components/index.mjs +554 -0
- package/dist/ui/src/components/form-builder/edit-field-dialog.cjs +131 -0
- package/dist/ui/src/components/form-builder/edit-field-dialog.mjs +129 -0
- package/dist/ui/src/components/form-builder/form-preview.cjs +73 -0
- package/dist/ui/src/components/form-builder/form-preview.mjs +71 -0
- package/dist/ui/src/components/form-builder/index.cjs +350 -0
- package/dist/ui/src/components/form-builder/index.mjs +344 -0
- package/dist/ui/src/components/form-builder/nested-field-editor-dialog.cjs +263 -0
- package/dist/ui/src/components/form-builder/nested-field-editor-dialog.mjs +261 -0
- package/dist/ui/src/components/form-builder/palette.cjs +52 -0
- package/dist/ui/src/components/form-builder/palette.mjs +49 -0
- package/dist/ui/src/components/form-builder/schema-utils.cjs +128 -0
- package/dist/ui/src/components/form-builder/schema-utils.mjs +122 -0
- package/dist/ui/src/components/form-builder/sortable-field.cjs +151 -0
- package/dist/ui/src/components/form-builder/sortable-field.mjs +148 -0
- package/dist/ui/src/components/form-builder/step-tabs.cjs +180 -0
- package/dist/ui/src/components/form-builder/step-tabs.mjs +178 -0
- package/dist/ui/src/components/form-builder/types.cjs +7 -0
- package/dist/ui/src/components/form-builder/types.mjs +5 -0
- package/dist/ui/src/components/form-builder/validation-schemas.cjs +67 -0
- package/dist/ui/src/components/form-builder/validation-schemas.mjs +56 -0
- package/dist/ui/src/components/form.cjs +120 -0
- package/dist/ui/src/components/form.mjs +98 -0
- package/dist/ui/src/components/input.cjs +23 -0
- package/dist/ui/src/components/input.mjs +21 -0
- package/dist/ui/src/components/label.cjs +39 -0
- package/dist/ui/src/components/label.mjs +23 -0
- package/dist/ui/src/components/page-layout.cjs +25 -0
- package/dist/ui/src/components/page-layout.mjs +23 -0
- package/dist/ui/src/components/page-wrapper.cjs +20 -0
- package/dist/ui/src/components/page-wrapper.mjs +18 -0
- package/dist/ui/src/components/popover.cjs +60 -0
- package/dist/ui/src/components/popover.mjs +42 -0
- package/dist/ui/src/components/radio-group.cjs +62 -0
- package/dist/ui/src/components/radio-group.mjs +45 -0
- package/dist/ui/src/components/select.cjs +161 -0
- package/dist/ui/src/components/select.mjs +139 -0
- package/dist/ui/src/components/separator.cjs +43 -0
- package/dist/ui/src/components/separator.mjs +27 -0
- package/dist/ui/src/components/skeleton.cjs +17 -0
- package/dist/ui/src/components/skeleton.mjs +15 -0
- package/dist/ui/src/components/stack-attribution.cjs +24 -0
- package/dist/ui/src/components/stack-attribution.mjs +22 -0
- package/dist/ui/src/components/switch.cjs +48 -0
- package/dist/ui/src/components/switch.mjs +32 -0
- package/dist/ui/src/components/table.cjs +89 -0
- package/dist/ui/src/components/table.mjs +82 -0
- package/dist/ui/src/components/tabs.cjs +84 -0
- package/dist/ui/src/components/tabs.mjs +65 -0
- package/dist/ui/src/components/textarea.cjs +20 -0
- package/dist/ui/src/components/textarea.mjs +18 -0
- package/dist/ui/src/lib/schema-converter.cjs +133 -0
- package/dist/ui/src/lib/schema-converter.mjs +127 -0
- package/dist/ui/src/lib/utils.cjs +10 -0
- package/dist/ui/src/lib/utils.mjs +8 -0
- package/dist/utils.cjs +41 -0
- package/dist/utils.mjs +32 -0
- package/package.json +175 -3
- package/README.md +0 -3
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { d as SerializedFormSubmissionSummary } from '../../shared/plugin-form-builder.BZYGyFgT.mjs';
|
|
3
|
+
import { SubmissionListFormContext } from '../../api/index.mjs';
|
|
4
|
+
import { SerializedForm, SerializedFormSubmissionWithData, SerializedFormSubmission } from '../../types.mjs';
|
|
5
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
6
|
+
import { ResourceFormConfig, ResourceFormResult } from '@btst/stack/plugins/client/hooks';
|
|
7
|
+
import { CreateFormInput, UpdateFormInput } from '../../query-keys.mjs';
|
|
8
|
+
import '@btst/stack/plugins/api';
|
|
9
|
+
import '@btst/stack/authorization';
|
|
10
|
+
import '@btst/stack/context';
|
|
11
|
+
import '../../permissions.mjs';
|
|
12
|
+
import 'zod';
|
|
13
|
+
import '@btst/stack/plugins/client';
|
|
14
|
+
import '../../shared/plugin-form-builder.lp98rFNl.mjs';
|
|
15
|
+
import '@btst/db';
|
|
16
|
+
import 'zod/v4/core';
|
|
17
|
+
import 'better-call';
|
|
18
|
+
|
|
19
|
+
interface UseFormsOptions {
|
|
20
|
+
/** Filter by status */
|
|
21
|
+
status?: "active" | "inactive" | "archived";
|
|
22
|
+
/** Number of items per page (default: 20) */
|
|
23
|
+
limit?: number;
|
|
24
|
+
/** Whether to enable the query (default: true) */
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
/** Free-text search across form names and slugs */
|
|
27
|
+
search?: string;
|
|
28
|
+
}
|
|
29
|
+
interface UseFormsResult {
|
|
30
|
+
forms: SerializedForm[];
|
|
31
|
+
total: number;
|
|
32
|
+
isLoading: boolean;
|
|
33
|
+
error: Error | null;
|
|
34
|
+
loadMore: () => void;
|
|
35
|
+
hasMore: boolean;
|
|
36
|
+
isLoadingMore: boolean;
|
|
37
|
+
refetch: () => void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Hook for fetching paginated forms (admin)
|
|
41
|
+
*/
|
|
42
|
+
declare function useForms(options?: UseFormsOptions): UseFormsResult;
|
|
43
|
+
/**
|
|
44
|
+
* Suspense variant of useForms
|
|
45
|
+
*/
|
|
46
|
+
declare function useSuspenseForms(options?: UseFormsOptions): {
|
|
47
|
+
forms: SerializedForm[];
|
|
48
|
+
total: number;
|
|
49
|
+
loadMore: () => Promise<unknown>;
|
|
50
|
+
hasMore: boolean;
|
|
51
|
+
isLoadingMore: boolean;
|
|
52
|
+
refetch: () => Promise<unknown>;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Hook for fetching a form by ID (admin)
|
|
56
|
+
*/
|
|
57
|
+
declare function useFormById(id: string): {
|
|
58
|
+
form: SerializedForm | null;
|
|
59
|
+
isLoading: boolean;
|
|
60
|
+
error: Error | null;
|
|
61
|
+
refetch: () => void;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Suspense variant of useFormById
|
|
65
|
+
*/
|
|
66
|
+
declare function useSuspenseFormById(id: string): {
|
|
67
|
+
form: SerializedForm | null;
|
|
68
|
+
refetch: () => Promise<unknown>;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Fetches editor data through the same update permission as the edit route.
|
|
72
|
+
*/
|
|
73
|
+
declare function useSuspenseFormForUpdate(id: string): {
|
|
74
|
+
form: SerializedForm | null;
|
|
75
|
+
refetch: () => Promise<unknown>;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Hook for fetching a form by slug (public)
|
|
79
|
+
*/
|
|
80
|
+
declare function useFormBySlug(slug: string): {
|
|
81
|
+
form: SerializedForm | null;
|
|
82
|
+
isLoading: boolean;
|
|
83
|
+
error: Error | null;
|
|
84
|
+
refetch: () => void;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Suspense variant of useFormBySlug
|
|
88
|
+
*/
|
|
89
|
+
declare function useSuspenseFormBySlug(slug: string): {
|
|
90
|
+
form: SerializedForm | null;
|
|
91
|
+
refetch: () => Promise<unknown>;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Hook for creating a form
|
|
95
|
+
*/
|
|
96
|
+
declare function useCreateForm(): _tanstack_react_query.UseMutationResult<SerializedForm, Error, CreateFormInput>;
|
|
97
|
+
/**
|
|
98
|
+
* Hook for updating a form
|
|
99
|
+
*/
|
|
100
|
+
declare function useUpdateForm(): _tanstack_react_query.UseMutationResult<SerializedForm, Error, {
|
|
101
|
+
id: string;
|
|
102
|
+
data: UpdateFormInput;
|
|
103
|
+
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Hook for deleting a form
|
|
106
|
+
*/
|
|
107
|
+
declare function useDeleteForm(): _tanstack_react_query.UseMutationResult<{
|
|
108
|
+
success: boolean;
|
|
109
|
+
}, Error, string>;
|
|
110
|
+
/**
|
|
111
|
+
* Form lifecycle hook for creating/editing forms, built on the core resource
|
|
112
|
+
* `useForm`: submits the right mutation, awaits invalidation, notifies via
|
|
113
|
+
* `useNotify()`, redirects, and maps server validation issues to
|
|
114
|
+
* `fieldErrors`.
|
|
115
|
+
*/
|
|
116
|
+
declare function useFormBuilderForm<TValues>(config: ResourceFormConfig<TValues, SerializedForm | null, SerializedForm>): ResourceFormResult<TValues, SerializedForm | null, SerializedForm>;
|
|
117
|
+
/**
|
|
118
|
+
* Hook for submitting a form (public)
|
|
119
|
+
*/
|
|
120
|
+
declare function useSubmitForm(slug: string): {
|
|
121
|
+
mutate: (vars: {
|
|
122
|
+
data: Record<string, unknown>;
|
|
123
|
+
}) => void;
|
|
124
|
+
mutateAsync: (vars: {
|
|
125
|
+
data: Record<string, unknown>;
|
|
126
|
+
}) => Promise<SerializedFormSubmission & {
|
|
127
|
+
form: {
|
|
128
|
+
successMessage?: string;
|
|
129
|
+
redirectUrl?: string;
|
|
130
|
+
};
|
|
131
|
+
}>;
|
|
132
|
+
data: undefined;
|
|
133
|
+
variables: undefined;
|
|
134
|
+
error: null;
|
|
135
|
+
isError: false;
|
|
136
|
+
isIdle: true;
|
|
137
|
+
isPending: false;
|
|
138
|
+
isSuccess: false;
|
|
139
|
+
status: "idle";
|
|
140
|
+
reset: () => void;
|
|
141
|
+
context: unknown;
|
|
142
|
+
failureCount: number;
|
|
143
|
+
failureReason: Error | null;
|
|
144
|
+
isPaused: boolean;
|
|
145
|
+
submittedAt: number;
|
|
146
|
+
} | {
|
|
147
|
+
mutate: (vars: {
|
|
148
|
+
data: Record<string, unknown>;
|
|
149
|
+
}) => void;
|
|
150
|
+
mutateAsync: (vars: {
|
|
151
|
+
data: Record<string, unknown>;
|
|
152
|
+
}) => Promise<SerializedFormSubmission & {
|
|
153
|
+
form: {
|
|
154
|
+
successMessage?: string;
|
|
155
|
+
redirectUrl?: string;
|
|
156
|
+
};
|
|
157
|
+
}>;
|
|
158
|
+
data: undefined;
|
|
159
|
+
variables: {
|
|
160
|
+
slug: string;
|
|
161
|
+
data: Record<string, unknown>;
|
|
162
|
+
};
|
|
163
|
+
error: null;
|
|
164
|
+
isError: false;
|
|
165
|
+
isIdle: false;
|
|
166
|
+
isPending: true;
|
|
167
|
+
isSuccess: false;
|
|
168
|
+
status: "pending";
|
|
169
|
+
reset: () => void;
|
|
170
|
+
context: unknown;
|
|
171
|
+
failureCount: number;
|
|
172
|
+
failureReason: Error | null;
|
|
173
|
+
isPaused: boolean;
|
|
174
|
+
submittedAt: number;
|
|
175
|
+
} | {
|
|
176
|
+
mutate: (vars: {
|
|
177
|
+
data: Record<string, unknown>;
|
|
178
|
+
}) => void;
|
|
179
|
+
mutateAsync: (vars: {
|
|
180
|
+
data: Record<string, unknown>;
|
|
181
|
+
}) => Promise<SerializedFormSubmission & {
|
|
182
|
+
form: {
|
|
183
|
+
successMessage?: string;
|
|
184
|
+
redirectUrl?: string;
|
|
185
|
+
};
|
|
186
|
+
}>;
|
|
187
|
+
data: undefined;
|
|
188
|
+
error: Error;
|
|
189
|
+
variables: {
|
|
190
|
+
slug: string;
|
|
191
|
+
data: Record<string, unknown>;
|
|
192
|
+
};
|
|
193
|
+
isError: true;
|
|
194
|
+
isIdle: false;
|
|
195
|
+
isPending: false;
|
|
196
|
+
isSuccess: false;
|
|
197
|
+
status: "error";
|
|
198
|
+
reset: () => void;
|
|
199
|
+
context: unknown;
|
|
200
|
+
failureCount: number;
|
|
201
|
+
failureReason: Error | null;
|
|
202
|
+
isPaused: boolean;
|
|
203
|
+
submittedAt: number;
|
|
204
|
+
} | {
|
|
205
|
+
mutate: (vars: {
|
|
206
|
+
data: Record<string, unknown>;
|
|
207
|
+
}) => void;
|
|
208
|
+
mutateAsync: (vars: {
|
|
209
|
+
data: Record<string, unknown>;
|
|
210
|
+
}) => Promise<SerializedFormSubmission & {
|
|
211
|
+
form: {
|
|
212
|
+
successMessage?: string;
|
|
213
|
+
redirectUrl?: string;
|
|
214
|
+
};
|
|
215
|
+
}>;
|
|
216
|
+
data: SerializedFormSubmission & {
|
|
217
|
+
form: {
|
|
218
|
+
successMessage?: string;
|
|
219
|
+
redirectUrl?: string;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
error: null;
|
|
223
|
+
variables: {
|
|
224
|
+
slug: string;
|
|
225
|
+
data: Record<string, unknown>;
|
|
226
|
+
};
|
|
227
|
+
isError: false;
|
|
228
|
+
isIdle: false;
|
|
229
|
+
isPending: false;
|
|
230
|
+
isSuccess: true;
|
|
231
|
+
status: "success";
|
|
232
|
+
reset: () => void;
|
|
233
|
+
context: unknown;
|
|
234
|
+
failureCount: number;
|
|
235
|
+
failureReason: Error | null;
|
|
236
|
+
isPaused: boolean;
|
|
237
|
+
submittedAt: number;
|
|
238
|
+
};
|
|
239
|
+
interface UseSubmissionsOptions {
|
|
240
|
+
/** Number of items per page (default: 20) */
|
|
241
|
+
limit?: number;
|
|
242
|
+
/** Whether to enable the query (default: true) */
|
|
243
|
+
enabled?: boolean;
|
|
244
|
+
}
|
|
245
|
+
interface UseSubmissionsResult {
|
|
246
|
+
form: SubmissionListFormContext | null;
|
|
247
|
+
submissions: SerializedFormSubmissionSummary[];
|
|
248
|
+
total: number;
|
|
249
|
+
isLoading: boolean;
|
|
250
|
+
error: Error | null;
|
|
251
|
+
loadMore: () => void;
|
|
252
|
+
hasMore: boolean;
|
|
253
|
+
isLoadingMore: boolean;
|
|
254
|
+
refetch: () => void;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Hook for fetching paginated submissions for a form (admin)
|
|
258
|
+
*/
|
|
259
|
+
declare function useSubmissions(formId: string, options?: UseSubmissionsOptions): UseSubmissionsResult;
|
|
260
|
+
/**
|
|
261
|
+
* Suspense variant of useSubmissions
|
|
262
|
+
*/
|
|
263
|
+
declare function useSuspenseSubmissions(formId: string, options?: UseSubmissionsOptions): {
|
|
264
|
+
form: SubmissionListFormContext | null;
|
|
265
|
+
submissions: SerializedFormSubmissionSummary[];
|
|
266
|
+
total: number;
|
|
267
|
+
loadMore: () => Promise<unknown>;
|
|
268
|
+
hasMore: boolean;
|
|
269
|
+
isLoadingMore: boolean;
|
|
270
|
+
refetch: () => Promise<unknown>;
|
|
271
|
+
};
|
|
272
|
+
interface UseSubmissionOptions {
|
|
273
|
+
/** Whether to enable the query (default: true). */
|
|
274
|
+
enabled?: boolean;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Fetch one submission through its record-scoped authorization rule.
|
|
278
|
+
*/
|
|
279
|
+
declare function useSubmission(formId: string, submissionId?: string, options?: UseSubmissionOptions): {
|
|
280
|
+
submission: SerializedFormSubmissionWithData | null;
|
|
281
|
+
isLoading: boolean;
|
|
282
|
+
error: Error | null;
|
|
283
|
+
refetch: () => void;
|
|
284
|
+
};
|
|
285
|
+
/**
|
|
286
|
+
* Hook for deleting a submission
|
|
287
|
+
*/
|
|
288
|
+
declare function useDeleteSubmission(formId: string): {
|
|
289
|
+
mutate: (subId: string) => void;
|
|
290
|
+
mutateAsync: (subId: string) => Promise<{
|
|
291
|
+
success: boolean;
|
|
292
|
+
}>;
|
|
293
|
+
data: undefined;
|
|
294
|
+
variables: undefined;
|
|
295
|
+
error: null;
|
|
296
|
+
isError: false;
|
|
297
|
+
isIdle: true;
|
|
298
|
+
isPending: false;
|
|
299
|
+
isSuccess: false;
|
|
300
|
+
status: "idle";
|
|
301
|
+
reset: () => void;
|
|
302
|
+
context: unknown;
|
|
303
|
+
failureCount: number;
|
|
304
|
+
failureReason: Error | null;
|
|
305
|
+
isPaused: boolean;
|
|
306
|
+
submittedAt: number;
|
|
307
|
+
} | {
|
|
308
|
+
mutate: (subId: string) => void;
|
|
309
|
+
mutateAsync: (subId: string) => Promise<{
|
|
310
|
+
success: boolean;
|
|
311
|
+
}>;
|
|
312
|
+
data: undefined;
|
|
313
|
+
variables: {
|
|
314
|
+
formId: string;
|
|
315
|
+
subId: string;
|
|
316
|
+
};
|
|
317
|
+
error: null;
|
|
318
|
+
isError: false;
|
|
319
|
+
isIdle: false;
|
|
320
|
+
isPending: true;
|
|
321
|
+
isSuccess: false;
|
|
322
|
+
status: "pending";
|
|
323
|
+
reset: () => void;
|
|
324
|
+
context: unknown;
|
|
325
|
+
failureCount: number;
|
|
326
|
+
failureReason: Error | null;
|
|
327
|
+
isPaused: boolean;
|
|
328
|
+
submittedAt: number;
|
|
329
|
+
} | {
|
|
330
|
+
mutate: (subId: string) => void;
|
|
331
|
+
mutateAsync: (subId: string) => Promise<{
|
|
332
|
+
success: boolean;
|
|
333
|
+
}>;
|
|
334
|
+
data: undefined;
|
|
335
|
+
error: Error;
|
|
336
|
+
variables: {
|
|
337
|
+
formId: string;
|
|
338
|
+
subId: string;
|
|
339
|
+
};
|
|
340
|
+
isError: true;
|
|
341
|
+
isIdle: false;
|
|
342
|
+
isPending: false;
|
|
343
|
+
isSuccess: false;
|
|
344
|
+
status: "error";
|
|
345
|
+
reset: () => void;
|
|
346
|
+
context: unknown;
|
|
347
|
+
failureCount: number;
|
|
348
|
+
failureReason: Error | null;
|
|
349
|
+
isPaused: boolean;
|
|
350
|
+
submittedAt: number;
|
|
351
|
+
} | {
|
|
352
|
+
mutate: (subId: string) => void;
|
|
353
|
+
mutateAsync: (subId: string) => Promise<{
|
|
354
|
+
success: boolean;
|
|
355
|
+
}>;
|
|
356
|
+
data: {
|
|
357
|
+
success: boolean;
|
|
358
|
+
};
|
|
359
|
+
error: null;
|
|
360
|
+
variables: {
|
|
361
|
+
formId: string;
|
|
362
|
+
subId: string;
|
|
363
|
+
};
|
|
364
|
+
isError: false;
|
|
365
|
+
isIdle: false;
|
|
366
|
+
isPending: false;
|
|
367
|
+
isSuccess: true;
|
|
368
|
+
status: "success";
|
|
369
|
+
reset: () => void;
|
|
370
|
+
context: unknown;
|
|
371
|
+
failureCount: number;
|
|
372
|
+
failureReason: Error | null;
|
|
373
|
+
isPaused: boolean;
|
|
374
|
+
submittedAt: number;
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
export { CreateFormInput, SerializedFormSubmissionSummary, UpdateFormInput, useCreateForm, useDeleteForm, useDeleteSubmission, useFormBuilderForm, useFormById, useFormBySlug, useForms, useSubmission, useSubmissions, useSubmitForm, useSuspenseFormById, useSuspenseFormBySlug, useSuspenseFormForUpdate, useSuspenseForms, useSuspenseSubmissions, useUpdateForm };
|
|
378
|
+
export type { UseFormsOptions, UseFormsResult, UseSubmissionOptions, UseSubmissionsOptions, UseSubmissionsResult };
|