@btst/plugin-form-builder 0.0.0-stage → 1.0.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.
Files changed (213) hide show
  1. package/LICENSE.md +17 -0
  2. package/dist/api/getters.cjs +154 -0
  3. package/dist/api/getters.mjs +145 -0
  4. package/dist/api/index.cjs +25 -0
  5. package/dist/api/index.d.cts +119 -0
  6. package/dist/api/index.d.mts +119 -0
  7. package/dist/api/index.d.ts +119 -0
  8. package/dist/api/index.mjs +6 -0
  9. package/dist/api/lifecycle-migrations.cjs +15 -0
  10. package/dist/api/lifecycle-migrations.mjs +13 -0
  11. package/dist/api/operations.cjs +1093 -0
  12. package/dist/api/operations.mjs +1082 -0
  13. package/dist/api/plugin.cjs +201 -0
  14. package/dist/api/plugin.mjs +192 -0
  15. package/dist/api/query-key-defs.cjs +43 -0
  16. package/dist/api/query-key-defs.mjs +39 -0
  17. package/dist/client/components/forms/form-renderer.cjs +193 -0
  18. package/dist/client/components/forms/form-renderer.mjs +191 -0
  19. package/dist/client/components/index.cjs +29 -0
  20. package/dist/client/components/index.d.cts +97 -0
  21. package/dist/client/components/index.d.mts +97 -0
  22. package/dist/client/components/index.d.ts +97 -0
  23. package/dist/client/components/index.mjs +18 -0
  24. package/dist/client/components/loading/form-builder-skeleton.cjs +32 -0
  25. package/dist/client/components/loading/form-builder-skeleton.mjs +30 -0
  26. package/dist/client/components/loading/form-list-skeleton.cjs +21 -0
  27. package/dist/client/components/loading/form-list-skeleton.mjs +19 -0
  28. package/dist/client/components/loading/submissions-skeleton.cjs +34 -0
  29. package/dist/client/components/loading/submissions-skeleton.mjs +32 -0
  30. package/dist/client/components/pages/404-page.cjs +28 -0
  31. package/dist/client/components/pages/404-page.mjs +26 -0
  32. package/dist/client/components/pages/form-builder-page.cjs +77 -0
  33. package/dist/client/components/pages/form-builder-page.internal.cjs +217 -0
  34. package/dist/client/components/pages/form-builder-page.internal.mjs +215 -0
  35. package/dist/client/components/pages/form-builder-page.mjs +75 -0
  36. package/dist/client/components/pages/form-list-page.cjs +44 -0
  37. package/dist/client/components/pages/form-list-page.internal.cjs +282 -0
  38. package/dist/client/components/pages/form-list-page.internal.mjs +280 -0
  39. package/dist/client/components/pages/form-list-page.mjs +42 -0
  40. package/dist/client/components/pages/submissions-page.cjs +64 -0
  41. package/dist/client/components/pages/submissions-page.internal.cjs +255 -0
  42. package/dist/client/components/pages/submissions-page.internal.mjs +253 -0
  43. package/dist/client/components/pages/submissions-page.mjs +62 -0
  44. package/dist/client/components/shared/default-error.cjs +17 -0
  45. package/dist/client/components/shared/default-error.mjs +15 -0
  46. package/dist/client/components/shared/empty-state.cjs +16 -0
  47. package/dist/client/components/shared/empty-state.mjs +14 -0
  48. package/dist/client/components/shared/page-wrapper.cjs +29 -0
  49. package/dist/client/components/shared/page-wrapper.mjs +27 -0
  50. package/dist/client/components/shared/pagination.cjs +49 -0
  51. package/dist/client/components/shared/pagination.mjs +47 -0
  52. package/dist/client/constants.cjs +5 -0
  53. package/dist/client/constants.mjs +3 -0
  54. package/dist/client/hooks/form-builder-hooks.cjs +203 -0
  55. package/dist/client/hooks/form-builder-hooks.mjs +186 -0
  56. package/dist/client/hooks/form-builder-resource.cjs +13 -0
  57. package/dist/client/hooks/form-builder-resource.mjs +11 -0
  58. package/dist/client/hooks/index.cjs +22 -0
  59. package/dist/client/hooks/index.d.cts +378 -0
  60. package/dist/client/hooks/index.d.mts +378 -0
  61. package/dist/client/hooks/index.d.ts +378 -0
  62. package/dist/client/hooks/index.mjs +1 -0
  63. package/dist/client/index.cjs +13 -0
  64. package/dist/client/index.d.cts +410 -0
  65. package/dist/client/index.d.mts +410 -0
  66. package/dist/client/index.d.ts +410 -0
  67. package/dist/client/index.mjs +2 -0
  68. package/dist/client/plugin.cjs +311 -0
  69. package/dist/client/plugin.mjs +309 -0
  70. package/dist/client.css +3 -0
  71. package/dist/db.cjs +99 -0
  72. package/dist/db.mjs +97 -0
  73. package/dist/permissions.cjs +95 -0
  74. package/dist/permissions.d.cts +94 -0
  75. package/dist/permissions.d.mts +94 -0
  76. package/dist/permissions.d.ts +94 -0
  77. package/dist/permissions.mjs +93 -0
  78. package/dist/query-keys.cjs +140 -0
  79. package/dist/query-keys.d.cts +392 -0
  80. package/dist/query-keys.d.mts +392 -0
  81. package/dist/query-keys.d.ts +392 -0
  82. package/dist/query-keys.mjs +137 -0
  83. package/dist/schemas.cjs +91 -0
  84. package/dist/schemas.mjs +82 -0
  85. package/dist/shared/plugin-form-builder.BZYGyFgT.d.mts +351 -0
  86. package/dist/shared/plugin-form-builder.Bbl9NufB.d.cts +408 -0
  87. package/dist/shared/plugin-form-builder.CSP5HR2O.d.ts +408 -0
  88. package/dist/shared/plugin-form-builder.Cmk083dA.d.cts +351 -0
  89. package/dist/shared/plugin-form-builder.D258Qpb8.d.ts +351 -0
  90. package/dist/shared/plugin-form-builder.DWrQ3lRX.d.cts +118 -0
  91. package/dist/shared/plugin-form-builder.DWrQ3lRX.d.mts +118 -0
  92. package/dist/shared/plugin-form-builder.DWrQ3lRX.d.ts +118 -0
  93. package/dist/shared/plugin-form-builder.lp98rFNl.d.mts +408 -0
  94. package/dist/style.css +6 -0
  95. package/dist/types.cjs +2 -0
  96. package/dist/types.d.cts +6 -0
  97. package/dist/types.d.mts +6 -0
  98. package/dist/types.d.ts +6 -0
  99. package/dist/types.mjs +1 -0
  100. package/dist/ui/src/components/accordion.cjs +81 -0
  101. package/dist/ui/src/components/accordion.mjs +62 -0
  102. package/dist/ui/src/components/alert-dialog.cjs +157 -0
  103. package/dist/ui/src/components/alert-dialog.mjs +132 -0
  104. package/dist/ui/src/components/auto-form/common/label.cjs +18 -0
  105. package/dist/ui/src/components/auto-form/common/label.mjs +16 -0
  106. package/dist/ui/src/components/auto-form/common/tooltip.cjs +9 -0
  107. package/dist/ui/src/components/auto-form/common/tooltip.mjs +7 -0
  108. package/dist/ui/src/components/auto-form/config.cjs +40 -0
  109. package/dist/ui/src/components/auto-form/config.mjs +37 -0
  110. package/dist/ui/src/components/auto-form/dependencies.cjs +48 -0
  111. package/dist/ui/src/components/auto-form/dependencies.mjs +46 -0
  112. package/dist/ui/src/components/auto-form/fields/array.cjs +266 -0
  113. package/dist/ui/src/components/auto-form/fields/array.mjs +264 -0
  114. package/dist/ui/src/components/auto-form/fields/checkbox.cjs +38 -0
  115. package/dist/ui/src/components/auto-form/fields/checkbox.mjs +36 -0
  116. package/dist/ui/src/components/auto-form/fields/date.cjs +67 -0
  117. package/dist/ui/src/components/auto-form/fields/date.mjs +65 -0
  118. package/dist/ui/src/components/auto-form/fields/enum.cjs +73 -0
  119. package/dist/ui/src/components/auto-form/fields/enum.mjs +71 -0
  120. package/dist/ui/src/components/auto-form/fields/input.cjs +32 -0
  121. package/dist/ui/src/components/auto-form/fields/input.mjs +30 -0
  122. package/dist/ui/src/components/auto-form/fields/number.cjs +31 -0
  123. package/dist/ui/src/components/auto-form/fields/number.mjs +29 -0
  124. package/dist/ui/src/components/auto-form/fields/object.cjs +233 -0
  125. package/dist/ui/src/components/auto-form/fields/object.mjs +217 -0
  126. package/dist/ui/src/components/auto-form/fields/radio-group.cjs +67 -0
  127. package/dist/ui/src/components/auto-form/fields/radio-group.mjs +65 -0
  128. package/dist/ui/src/components/auto-form/fields/switch.cjs +38 -0
  129. package/dist/ui/src/components/auto-form/fields/switch.mjs +36 -0
  130. package/dist/ui/src/components/auto-form/fields/textarea.cjs +31 -0
  131. package/dist/ui/src/components/auto-form/fields/textarea.mjs +29 -0
  132. package/dist/ui/src/components/auto-form/helpers.cjs +270 -0
  133. package/dist/ui/src/components/auto-form/helpers.mjs +259 -0
  134. package/dist/ui/src/components/auto-form/index.cjs +92 -0
  135. package/dist/ui/src/components/auto-form/index.mjs +86 -0
  136. package/dist/ui/src/components/auto-form/stepped-auto-form.cjs +374 -0
  137. package/dist/ui/src/components/auto-form/stepped-auto-form.mjs +368 -0
  138. package/dist/ui/src/components/auto-form/types.cjs +11 -0
  139. package/dist/ui/src/components/auto-form/types.mjs +9 -0
  140. package/dist/ui/src/components/button.cjs +56 -0
  141. package/dist/ui/src/components/button.mjs +53 -0
  142. package/dist/ui/src/components/calendar.cjs +207 -0
  143. package/dist/ui/src/components/calendar.mjs +190 -0
  144. package/dist/ui/src/components/checkbox.cjs +48 -0
  145. package/dist/ui/src/components/checkbox.mjs +32 -0
  146. package/dist/ui/src/components/date-picker.cjs +41 -0
  147. package/dist/ui/src/components/date-picker.mjs +39 -0
  148. package/dist/ui/src/components/dialog.cjs +141 -0
  149. package/dist/ui/src/components/dialog.mjs +118 -0
  150. package/dist/ui/src/components/dropdown-menu.cjs +81 -0
  151. package/dist/ui/src/components/dropdown-menu.mjs +62 -0
  152. package/dist/ui/src/components/form-builder/canvas.cjs +111 -0
  153. package/dist/ui/src/components/form-builder/canvas.mjs +109 -0
  154. package/dist/ui/src/components/form-builder/components/index.cjs +571 -0
  155. package/dist/ui/src/components/form-builder/components/index.mjs +554 -0
  156. package/dist/ui/src/components/form-builder/edit-field-dialog.cjs +131 -0
  157. package/dist/ui/src/components/form-builder/edit-field-dialog.mjs +129 -0
  158. package/dist/ui/src/components/form-builder/form-preview.cjs +73 -0
  159. package/dist/ui/src/components/form-builder/form-preview.mjs +71 -0
  160. package/dist/ui/src/components/form-builder/index.cjs +350 -0
  161. package/dist/ui/src/components/form-builder/index.mjs +344 -0
  162. package/dist/ui/src/components/form-builder/nested-field-editor-dialog.cjs +263 -0
  163. package/dist/ui/src/components/form-builder/nested-field-editor-dialog.mjs +261 -0
  164. package/dist/ui/src/components/form-builder/palette.cjs +52 -0
  165. package/dist/ui/src/components/form-builder/palette.mjs +49 -0
  166. package/dist/ui/src/components/form-builder/schema-utils.cjs +128 -0
  167. package/dist/ui/src/components/form-builder/schema-utils.mjs +122 -0
  168. package/dist/ui/src/components/form-builder/sortable-field.cjs +151 -0
  169. package/dist/ui/src/components/form-builder/sortable-field.mjs +148 -0
  170. package/dist/ui/src/components/form-builder/step-tabs.cjs +180 -0
  171. package/dist/ui/src/components/form-builder/step-tabs.mjs +178 -0
  172. package/dist/ui/src/components/form-builder/types.cjs +7 -0
  173. package/dist/ui/src/components/form-builder/types.mjs +5 -0
  174. package/dist/ui/src/components/form-builder/validation-schemas.cjs +67 -0
  175. package/dist/ui/src/components/form-builder/validation-schemas.mjs +56 -0
  176. package/dist/ui/src/components/form.cjs +120 -0
  177. package/dist/ui/src/components/form.mjs +98 -0
  178. package/dist/ui/src/components/input.cjs +23 -0
  179. package/dist/ui/src/components/input.mjs +21 -0
  180. package/dist/ui/src/components/label.cjs +39 -0
  181. package/dist/ui/src/components/label.mjs +23 -0
  182. package/dist/ui/src/components/page-layout.cjs +25 -0
  183. package/dist/ui/src/components/page-layout.mjs +23 -0
  184. package/dist/ui/src/components/page-wrapper.cjs +20 -0
  185. package/dist/ui/src/components/page-wrapper.mjs +18 -0
  186. package/dist/ui/src/components/popover.cjs +60 -0
  187. package/dist/ui/src/components/popover.mjs +42 -0
  188. package/dist/ui/src/components/radio-group.cjs +62 -0
  189. package/dist/ui/src/components/radio-group.mjs +45 -0
  190. package/dist/ui/src/components/select.cjs +161 -0
  191. package/dist/ui/src/components/select.mjs +139 -0
  192. package/dist/ui/src/components/separator.cjs +43 -0
  193. package/dist/ui/src/components/separator.mjs +27 -0
  194. package/dist/ui/src/components/skeleton.cjs +17 -0
  195. package/dist/ui/src/components/skeleton.mjs +15 -0
  196. package/dist/ui/src/components/stack-attribution.cjs +24 -0
  197. package/dist/ui/src/components/stack-attribution.mjs +22 -0
  198. package/dist/ui/src/components/switch.cjs +48 -0
  199. package/dist/ui/src/components/switch.mjs +32 -0
  200. package/dist/ui/src/components/table.cjs +89 -0
  201. package/dist/ui/src/components/table.mjs +82 -0
  202. package/dist/ui/src/components/tabs.cjs +84 -0
  203. package/dist/ui/src/components/tabs.mjs +65 -0
  204. package/dist/ui/src/components/textarea.cjs +20 -0
  205. package/dist/ui/src/components/textarea.mjs +18 -0
  206. package/dist/ui/src/lib/schema-converter.cjs +133 -0
  207. package/dist/ui/src/lib/schema-converter.mjs +127 -0
  208. package/dist/ui/src/lib/utils.cjs +10 -0
  209. package/dist/ui/src/lib/utils.mjs +8 -0
  210. package/dist/utils.cjs +41 -0
  211. package/dist/utils.mjs +32 -0
  212. package/package.json +175 -3
  213. package/README.md +0 -3
@@ -0,0 +1,118 @@
1
+ 'use client';
2
+ import * as react from 'react';
3
+ import { ControllerRenderProps, FieldValues } from 'react-hook-form';
4
+ import * as z from 'zod';
5
+
6
+ declare function FormListPageComponent(): react.JSX.Element;
7
+
8
+ declare function AutoFormCheckbox({ label, isRequired, field, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react.JSX.Element;
9
+
10
+ declare function AutoFormDate({ label, isRequired, field, fieldConfigItem, fieldProps, zodItem, }: AutoFormInputComponentProps): react.JSX.Element;
11
+
12
+ declare function AutoFormEnum({ label, isRequired, field, fieldConfigItem, zodItem, fieldProps, }: AutoFormInputComponentProps): react.JSX.Element;
13
+
14
+ declare function AutoFormInput({ label, isRequired, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react.JSX.Element;
15
+
16
+ declare function AutoFormNumber({ label, isRequired, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react.JSX.Element;
17
+
18
+ declare function AutoFormRadioGroup({ label, isRequired, field, zodItem, fieldProps, fieldConfigItem, }: AutoFormInputComponentProps): react.JSX.Element;
19
+
20
+ declare function AutoFormSwitch({ label, isRequired, field, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react.JSX.Element;
21
+
22
+ declare function AutoFormTextarea({ label, isRequired, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react.JSX.Element;
23
+
24
+ declare const INPUT_COMPONENTS: {
25
+ checkbox: typeof AutoFormCheckbox;
26
+ date: typeof AutoFormDate;
27
+ select: typeof AutoFormEnum;
28
+ radio: typeof AutoFormRadioGroup;
29
+ switch: typeof AutoFormSwitch;
30
+ textarea: typeof AutoFormTextarea;
31
+ number: typeof AutoFormNumber;
32
+ fallback: typeof AutoFormInput;
33
+ };
34
+
35
+ /**
36
+ * Common input props shared by all field types.
37
+ */
38
+ interface BaseInputProps {
39
+ /** Whether the field is disabled */
40
+ disabled?: boolean;
41
+ /** Whether the field is read-only */
42
+ readOnly?: boolean;
43
+ /** Whether the field is required */
44
+ required?: boolean;
45
+ /** Whether to show the label (auto-form specific) */
46
+ showLabel?: boolean;
47
+ }
48
+ /**
49
+ * Generic input props that accept any field type.
50
+ * Use this when the backing type is not known at compile time.
51
+ *
52
+ * This is the catch-all type used for runtime flexibility.
53
+ */
54
+ interface SerializableInputProps extends BaseInputProps {
55
+ placeholder?: string;
56
+ type?: string;
57
+ defaultValue?: unknown;
58
+ min?: number | string;
59
+ max?: number | string;
60
+ step?: number | string;
61
+ minLength?: number;
62
+ maxLength?: number;
63
+ pattern?: string;
64
+ autoComplete?: string;
65
+ /** Allow additional props for extensibility */
66
+ [key: string]: unknown;
67
+ }
68
+
69
+ /**
70
+ * Input props for form fields.
71
+ *
72
+ * This is the runtime type that accepts any input props.
73
+ * For type-safe props, use the discriminated types:
74
+ * - StringInputProps for text inputs
75
+ * - NumberInputProps for number inputs
76
+ * - BooleanInputProps for checkboxes/switches
77
+ * - DateInputProps for date pickers
78
+ * - EnumInputProps for selects/radios
79
+ */
80
+ type FieldInputProps = SerializableInputProps & Omit<React.InputHTMLAttributes<HTMLInputElement>, keyof SerializableInputProps> & Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, keyof SerializableInputProps>;
81
+ /**
82
+ * Configuration for a single field in AutoForm.
83
+ *
84
+ * Note: This type is designed to align with form-builder's FormBuilderFieldProps
85
+ * so that JSON Schema properties can be easily converted to field configs.
86
+ */
87
+ type FieldConfigItem = {
88
+ /** Description text or React node */
89
+ description?: React.ReactNode;
90
+ /** Input props passed to the field component */
91
+ inputProps?: FieldInputProps;
92
+ /** Display label */
93
+ label?: string;
94
+ /** Field type override - built-in type or custom component */
95
+ fieldType?: keyof typeof INPUT_COMPONENTS | React.FC<AutoFormInputComponentProps>;
96
+ /** Wrapper component for custom field layout */
97
+ renderParent?: (props: {
98
+ children: React.ReactNode;
99
+ }) => React.ReactElement | null;
100
+ /** Display order for field ordering */
101
+ order?: number;
102
+ };
103
+ /**
104
+ * A FormInput component can handle a specific Zod type (e.g. "ZodBoolean")
105
+ */
106
+ type AutoFormInputComponentProps = {
107
+ zodInputProps: React.InputHTMLAttributes<HTMLInputElement>;
108
+ field: ControllerRenderProps<FieldValues, any>;
109
+ fieldConfigItem: FieldConfigItem;
110
+ label: string;
111
+ isRequired: boolean;
112
+ fieldProps: any;
113
+ zodItem: z.ZodType;
114
+ className?: string;
115
+ };
116
+
117
+ export { FormListPageComponent as F };
118
+ export type { AutoFormInputComponentProps as A };
@@ -0,0 +1,408 @@
1
+ import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
2
+ import { Operation, OperationData, OperationHttpError } from '@btst/stack/plugins/api';
3
+ import { DBAdapter } from '@btst/db';
4
+ import * as z from 'zod';
5
+ import { z as z$1 } from 'zod';
6
+ import { formBuilderPermissions } from '../permissions.mjs';
7
+ import { w as listFormsQuerySchema, S as SerializedForm, x as createFormSchema, c as SerializedFormSubmission, t as SubmissionListFormContext, d as SerializedFormSubmissionSummary, g as FormBuilderBackendHooks, f as FormBuilderBackendConfig, F as Form } from './plugin-form-builder.BZYGyFgT.mjs';
8
+ import * as zod_v4_core from 'zod/v4/core';
9
+ import * as better_call from 'better-call';
10
+ import { QueryClient } from '@tanstack/react-query';
11
+
12
+ declare const SubmitFormOperationInputSchema: z$1.ZodObject<{
13
+ slug: z$1.ZodString;
14
+ data: z$1.ZodPipe<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>, z$1.ZodTransform<Record<string, OperationData>, Record<string, unknown>>>;
15
+ }, z$1.core.$strip>;
16
+ declare const UpdateFormOperationInputSchema: z$1.ZodObject<{
17
+ id: z$1.ZodString;
18
+ data: z$1.ZodObject<{
19
+ name: z$1.ZodOptional<z$1.ZodString>;
20
+ slug: z$1.ZodOptional<z$1.ZodString>;
21
+ description: z$1.ZodOptional<z$1.ZodString>;
22
+ schema: z$1.ZodOptional<z$1.ZodString>;
23
+ successMessage: z$1.ZodOptional<z$1.ZodString>;
24
+ redirectUrl: z$1.ZodUnion<[z$1.ZodOptional<z$1.ZodString>, z$1.ZodLiteral<"">]>;
25
+ status: z$1.ZodOptional<z$1.ZodEnum<{
26
+ active: "active";
27
+ inactive: "inactive";
28
+ archived: "archived";
29
+ }>>;
30
+ }, z$1.core.$strip>;
31
+ }, z$1.core.$strip>;
32
+ declare const DeleteFormOperationInputSchema: z$1.ZodObject<{
33
+ id: z$1.ZodString;
34
+ }, z$1.core.$strip>;
35
+ declare const GetFormBySlugOperationInputSchema: z$1.ZodObject<{
36
+ slug: z$1.ZodString;
37
+ }, z$1.core.$strip>;
38
+ declare const GetFormByIdOperationInputSchema: z$1.ZodObject<{
39
+ id: z$1.ZodString;
40
+ }, z$1.core.$strip>;
41
+ declare const GetFormForUpdateOperationInputSchema: z$1.ZodObject<{
42
+ id: z$1.ZodString;
43
+ }, z$1.core.$strip>;
44
+ declare const ListSubmissionsOperationInputSchema: z$1.ZodObject<{
45
+ formId: z$1.ZodString;
46
+ query: z$1.ZodObject<{
47
+ limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodCoercedNumber<unknown>>>;
48
+ offset: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodCoercedNumber<unknown>>>;
49
+ }, z$1.core.$strip>;
50
+ }, z$1.core.$strip>;
51
+ declare const GetSubmissionOperationInputSchema: z$1.ZodObject<{
52
+ formId: z$1.ZodString;
53
+ submissionId: z$1.ZodString;
54
+ }, z$1.core.$strip>;
55
+ type SubmissionOperationData = Record<string, OperationData>;
56
+ interface FormListOperationResult {
57
+ readonly items: readonly SerializedForm[];
58
+ readonly total: number;
59
+ readonly limit?: number;
60
+ readonly offset?: number;
61
+ }
62
+ interface SubmissionDetailOperationResult extends SerializedFormSubmission {
63
+ readonly parsedData: SubmissionOperationData | null;
64
+ }
65
+ interface SubmissionListOperationResult {
66
+ readonly form: SubmissionListFormContext;
67
+ readonly items: readonly SerializedFormSubmissionSummary[];
68
+ readonly total: number;
69
+ readonly limit?: number;
70
+ readonly offset?: number;
71
+ }
72
+ interface SubmitOperationResult extends SerializedFormSubmission {
73
+ readonly form: Pick<SerializedForm, "successMessage" | "redirectUrl">;
74
+ }
75
+ type FormBuilderOperations = {
76
+ readonly listForms: Operation<typeof listFormsQuerySchema, typeof formBuilderPermissions.form.read, FormListOperationResult>;
77
+ readonly getFormBySlug: Operation<typeof GetFormBySlugOperationInputSchema, typeof formBuilderPermissions.form.render, SerializedForm>;
78
+ readonly getFormById: Operation<typeof GetFormByIdOperationInputSchema, typeof formBuilderPermissions.form.read, SerializedForm>;
79
+ readonly getFormForUpdate: Operation<typeof GetFormForUpdateOperationInputSchema, typeof formBuilderPermissions.form.update, SerializedForm>;
80
+ readonly createForm: Operation<typeof createFormSchema, typeof formBuilderPermissions.form.create, SerializedForm>;
81
+ readonly updateForm: Operation<typeof UpdateFormOperationInputSchema, typeof formBuilderPermissions.form.update, SerializedForm>;
82
+ readonly deleteForm: Operation<typeof DeleteFormOperationInputSchema, typeof formBuilderPermissions.form.delete, {
83
+ readonly success: true;
84
+ }>;
85
+ readonly submitForm: Operation<typeof SubmitFormOperationInputSchema, typeof formBuilderPermissions.submission.create, SubmitOperationResult>;
86
+ readonly listSubmissions: Operation<typeof ListSubmissionsOperationInputSchema, typeof formBuilderPermissions.submission.read, SubmissionListOperationResult>;
87
+ readonly getSubmission: Operation<typeof GetSubmissionOperationInputSchema, typeof formBuilderPermissions.submission.read, SubmissionDetailOperationResult>;
88
+ readonly deleteSubmission: Operation<typeof GetSubmissionOperationInputSchema, typeof formBuilderPermissions.submission.delete, {
89
+ readonly success: true;
90
+ }>;
91
+ };
92
+ /** A domain/HTTP error raised after Form Builder authorization succeeds. */
93
+ declare class FormBuilderOperationError extends OperationHttpError {
94
+ constructor(statusCode: number, message: string, code: string, issues?: readonly unknown[]);
95
+ }
96
+ /** Create the complete Form Builder operation inventory for every transport. */
97
+ declare function createFormBuilderOperations(adapter: DBAdapter, hooks?: FormBuilderBackendHooks): FormBuilderOperations;
98
+
99
+ /** Route keys returned by the Form Builder client plugin. */
100
+ type FormBuilderRouteKey = "formList" | "newForm" | "editForm" | "submissions";
101
+ interface FormBuilderPrefetchForRoute {
102
+ (key: "formList" | "newForm", qc: QueryClient): Promise<void>;
103
+ (key: "editForm" | "submissions", qc: QueryClient, params: {
104
+ id: string;
105
+ }): Promise<void>;
106
+ }
107
+ /** Form Builder backend plugin backed by one operation inventory. */
108
+ declare const formBuilderBackendPlugin: (config?: FormBuilderBackendConfig) => _btst_stack_plugins_api.BackendPlugin<{
109
+ readonly listForms: better_call.StrictEndpoint<"/forms", {
110
+ requireRequest: true;
111
+ } & {
112
+ method: "GET";
113
+ } & {
114
+ query: better_call.StandardSchemaV1<{
115
+ status?: "active" | "inactive" | "archived" | undefined;
116
+ limit?: unknown;
117
+ offset?: unknown;
118
+ search?: string | undefined;
119
+ }, {
120
+ status?: "active" | "inactive" | "archived" | undefined;
121
+ limit?: unknown;
122
+ offset?: unknown;
123
+ search?: string | undefined;
124
+ }>;
125
+ }, {
126
+ readonly items: readonly {
127
+ readonly status: Form["status"];
128
+ readonly createdAt: string;
129
+ readonly updatedAt: string;
130
+ readonly name: string;
131
+ readonly slug: string;
132
+ readonly description?: string | undefined;
133
+ readonly schema: string;
134
+ readonly successMessage?: string | undefined;
135
+ readonly redirectUrl?: string | undefined;
136
+ readonly id: string;
137
+ readonly createdBy?: string | undefined;
138
+ }[];
139
+ readonly total: number;
140
+ readonly limit?: number | undefined;
141
+ readonly offset?: number | undefined;
142
+ }>;
143
+ readonly getFormBySlug: better_call.StrictEndpoint<"/forms/:slug", {
144
+ params: z.ZodObject<{
145
+ slug: z.ZodString;
146
+ }, zod_v4_core.$strip>;
147
+ requireRequest: true;
148
+ } & {
149
+ method: "GET";
150
+ }, {
151
+ readonly status: Form["status"];
152
+ readonly createdAt: string;
153
+ readonly updatedAt: string;
154
+ readonly name: string;
155
+ readonly slug: string;
156
+ readonly description?: string | undefined;
157
+ readonly schema: string;
158
+ readonly successMessage?: string | undefined;
159
+ readonly redirectUrl?: string | undefined;
160
+ readonly id: string;
161
+ readonly createdBy?: string | undefined;
162
+ }>;
163
+ readonly getFormById: better_call.StrictEndpoint<"/forms/id/:id", {
164
+ params: z.ZodObject<{
165
+ id: z.ZodString;
166
+ }, zod_v4_core.$strip>;
167
+ requireRequest: true;
168
+ } & {
169
+ method: "GET";
170
+ }, {
171
+ readonly status: Form["status"];
172
+ readonly createdAt: string;
173
+ readonly updatedAt: string;
174
+ readonly name: string;
175
+ readonly slug: string;
176
+ readonly description?: string | undefined;
177
+ readonly schema: string;
178
+ readonly successMessage?: string | undefined;
179
+ readonly redirectUrl?: string | undefined;
180
+ readonly id: string;
181
+ readonly createdBy?: string | undefined;
182
+ }>;
183
+ readonly getFormForUpdate: better_call.StrictEndpoint<"/forms/id/:id/edit", {
184
+ params: z.ZodObject<{
185
+ id: z.ZodString;
186
+ }, zod_v4_core.$strip>;
187
+ requireRequest: true;
188
+ } & {
189
+ method: "GET";
190
+ }, {
191
+ readonly status: Form["status"];
192
+ readonly createdAt: string;
193
+ readonly updatedAt: string;
194
+ readonly name: string;
195
+ readonly slug: string;
196
+ readonly description?: string | undefined;
197
+ readonly schema: string;
198
+ readonly successMessage?: string | undefined;
199
+ readonly redirectUrl?: string | undefined;
200
+ readonly id: string;
201
+ readonly createdBy?: string | undefined;
202
+ }>;
203
+ readonly createForm: better_call.StrictEndpoint<"/forms", {
204
+ requireRequest: true;
205
+ } & {
206
+ method: "POST";
207
+ body: better_call.StandardSchemaV1<{
208
+ name: string;
209
+ slug: string;
210
+ schema: string;
211
+ description?: string | undefined;
212
+ successMessage?: string | undefined;
213
+ redirectUrl?: string | undefined;
214
+ status?: "active" | "inactive" | "archived" | undefined;
215
+ }, {
216
+ name: string;
217
+ slug: string;
218
+ schema: string;
219
+ description?: string | undefined;
220
+ successMessage?: string | undefined;
221
+ redirectUrl?: string | undefined;
222
+ status?: "active" | "inactive" | "archived" | undefined;
223
+ }>;
224
+ }, {
225
+ readonly status: Form["status"];
226
+ readonly createdAt: string;
227
+ readonly updatedAt: string;
228
+ readonly name: string;
229
+ readonly slug: string;
230
+ readonly description?: string | undefined;
231
+ readonly schema: string;
232
+ readonly successMessage?: string | undefined;
233
+ readonly redirectUrl?: string | undefined;
234
+ readonly id: string;
235
+ readonly createdBy?: string | undefined;
236
+ }>;
237
+ readonly updateForm: better_call.StrictEndpoint<"/forms/:id", {
238
+ requireRequest: true;
239
+ } & {
240
+ method: "PUT";
241
+ body: better_call.StandardSchemaV1<{
242
+ name?: string | undefined;
243
+ slug?: string | undefined;
244
+ description?: string | undefined;
245
+ schema?: string | undefined;
246
+ successMessage?: string | undefined;
247
+ redirectUrl?: string | undefined;
248
+ status?: "active" | "inactive" | "archived" | undefined;
249
+ }, {
250
+ name?: string | undefined;
251
+ slug?: string | undefined;
252
+ description?: string | undefined;
253
+ schema?: string | undefined;
254
+ successMessage?: string | undefined;
255
+ redirectUrl?: string | undefined;
256
+ status?: "active" | "inactive" | "archived" | undefined;
257
+ }>;
258
+ }, {
259
+ readonly status: Form["status"];
260
+ readonly createdAt: string;
261
+ readonly updatedAt: string;
262
+ readonly name: string;
263
+ readonly slug: string;
264
+ readonly description?: string | undefined;
265
+ readonly schema: string;
266
+ readonly successMessage?: string | undefined;
267
+ readonly redirectUrl?: string | undefined;
268
+ readonly id: string;
269
+ readonly createdBy?: string | undefined;
270
+ }>;
271
+ readonly deleteForm: better_call.StrictEndpoint<"/forms/:id", {
272
+ requireRequest: true;
273
+ } & {
274
+ method: "DELETE";
275
+ body: better_call.StandardSchemaV1<unknown, unknown>;
276
+ }, {
277
+ readonly success: true;
278
+ }>;
279
+ readonly submitForm: better_call.StrictEndpoint<"/forms/:slug/submit", {
280
+ requireRequest: true;
281
+ } & {
282
+ method: "POST";
283
+ body: better_call.StandardSchemaV1<{
284
+ data: Record<string, unknown>;
285
+ }, {
286
+ data: Record<string, unknown>;
287
+ }>;
288
+ }, {
289
+ readonly form: {
290
+ readonly successMessage?: string | undefined;
291
+ readonly redirectUrl?: string | undefined;
292
+ };
293
+ readonly submittedAt: string;
294
+ readonly id: string;
295
+ readonly data: string;
296
+ readonly formId: string;
297
+ readonly submittedBy?: string | undefined;
298
+ readonly ipAddress?: string | undefined;
299
+ readonly userAgent?: string | undefined;
300
+ }>;
301
+ readonly listSubmissions: better_call.StrictEndpoint<"/forms/:formId/submissions", {
302
+ requireRequest: true;
303
+ } & {
304
+ method: "GET";
305
+ } & {
306
+ query: better_call.StandardSchemaV1<{
307
+ limit?: unknown;
308
+ offset?: unknown;
309
+ }, {
310
+ limit?: unknown;
311
+ offset?: unknown;
312
+ }>;
313
+ }, {
314
+ readonly form: {
315
+ readonly id: string;
316
+ readonly name: string;
317
+ readonly createdBy?: string | undefined;
318
+ };
319
+ readonly items: readonly {
320
+ readonly id: string;
321
+ readonly formId: string;
322
+ readonly submittedAt: string;
323
+ readonly submittedBy?: string | undefined;
324
+ }[];
325
+ readonly total: number;
326
+ readonly limit?: number | undefined;
327
+ readonly offset?: number | undefined;
328
+ }>;
329
+ readonly getSubmission: better_call.StrictEndpoint<"/forms/:formId/submissions/:subId", {
330
+ requireRequest: true;
331
+ } & {
332
+ method: "GET";
333
+ }, {
334
+ readonly parsedData: {
335
+ readonly [x: string]: any;
336
+ } | null;
337
+ readonly submittedAt: string;
338
+ readonly id: string;
339
+ readonly data: string;
340
+ readonly formId: string;
341
+ readonly submittedBy?: string | undefined;
342
+ readonly ipAddress?: string | undefined;
343
+ readonly userAgent?: string | undefined;
344
+ }>;
345
+ readonly deleteSubmission: better_call.StrictEndpoint<"/forms/:formId/submissions/:subId", {
346
+ requireRequest: true;
347
+ } & {
348
+ method: "DELETE";
349
+ body: better_call.StandardSchemaV1<unknown, unknown>;
350
+ }, {
351
+ readonly success: true;
352
+ }>;
353
+ }, {
354
+ prefetchForRoute: FormBuilderPrefetchForRoute;
355
+ }, FormBuilderOperations, "formBuilder">;
356
+ type FormBuilderApiRouter = ReturnType<ReturnType<typeof formBuilderBackendPlugin>["routes"]>;
357
+
358
+ /**
359
+ * Internal query key constants for the Form Builder plugin.
360
+ * Shared between query-keys.ts (HTTP path) and prefetchForRoute (DB path)
361
+ * to prevent key drift between SSR loaders and SSG prefetching.
362
+ */
363
+ interface FormsListDiscriminator {
364
+ status?: "active" | "inactive" | "archived";
365
+ limit: number;
366
+ offset: number;
367
+ search: string | undefined;
368
+ }
369
+ interface SubmissionsListDiscriminator {
370
+ formId: string;
371
+ limit: number;
372
+ offset: number;
373
+ }
374
+ /** Full query key builders — use these with queryClient.setQueryData() */
375
+ declare const FORM_QUERY_KEYS: {
376
+ /**
377
+ * Key for forms.list(params) query.
378
+ * Full key: ["forms", "list", "list", { status, limit, offset }]
379
+ */
380
+ formsList: (params?: {
381
+ status?: "active" | "inactive" | "archived";
382
+ limit?: number;
383
+ offset?: number;
384
+ search?: string;
385
+ }) => readonly ["forms", "list", "list", FormsListDiscriminator];
386
+ /**
387
+ * Key for forms.byId(id) query.
388
+ * Full key: ["forms", "byId", "byId", id]
389
+ */
390
+ formById: (id: string) => readonly ["forms", "byId", "byId", string];
391
+ /**
392
+ * Key for forms.forUpdate(id) query.
393
+ * Full key: ["forms", "forUpdate", "forUpdate", id]
394
+ */
395
+ formForUpdate: (id: string) => readonly ["forms", "forUpdate", "forUpdate", string];
396
+ /**
397
+ * Key for formSubmissions.list(params) query.
398
+ * Full key: ["formSubmissions", "list", { formId, limit, offset }]
399
+ */
400
+ submissionsList: (params: {
401
+ formId: string;
402
+ limit?: number;
403
+ offset?: number;
404
+ }) => readonly ["formSubmissions", "list", SubmissionsListDiscriminator];
405
+ };
406
+
407
+ export { FORM_QUERY_KEYS as F, FormBuilderOperationError as b, createFormBuilderOperations as h, formBuilderBackendPlugin as i };
408
+ export type { SubmissionDetailOperationResult as S, FormBuilderApiRouter as a, FormBuilderOperations as c, FormBuilderRouteKey as d, FormListOperationResult as e, SubmissionListOperationResult as f, SubmitOperationResult as g, FormsListDiscriminator as j, SubmissionsListDiscriminator as k };
package/dist/style.css ADDED
@@ -0,0 +1,6 @@
1
+
2
+ /* Form Builder Plugin Client CSS */
3
+ /* No custom styles needed - uses shadcn/ui components */
4
+
5
+
6
+ @source "./**/*.{mjs,cjs}";
package/dist/types.cjs ADDED
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1,6 @@
1
+ import '@btst/stack/plugins/api';
2
+ import '@btst/stack/authorization';
3
+ import '@btst/stack/context';
4
+ import './permissions.cjs';
5
+ export { F as Form, f as FormBuilderBackendConfig, g as FormBuilderBackendHooks, h as FormBuilderHookContext, i as FormBuilderOperationHookContext, j as FormCreateOperationContext, k as FormDeleteOperationContext, l as FormGetForUpdateOperationContext, m as FormGetOperationContext, y as FormInput, n as FormListOperationContext, b as FormSubmission, e as FormSubmissionWithForm, z as FormUpdate, o as FormUpdateOperationContext, v as PaginatedFormSubmissions, P as PaginatedForms, S as SerializedForm, c as SerializedFormSubmission, d as SerializedFormSubmissionSummary, a as SerializedFormSubmissionWithData, p as SubmissionCreateOperationContext, q as SubmissionDeleteOperationContext, r as SubmissionGetOperationContext, s as SubmissionHookContext, t as SubmissionListFormContext, u as SubmissionListOperationContext } from './shared/plugin-form-builder.Cmk083dA.cjs';
6
+ import 'zod';
@@ -0,0 +1,6 @@
1
+ import '@btst/stack/plugins/api';
2
+ import '@btst/stack/authorization';
3
+ import '@btst/stack/context';
4
+ import './permissions.mjs';
5
+ export { F as Form, f as FormBuilderBackendConfig, g as FormBuilderBackendHooks, h as FormBuilderHookContext, i as FormBuilderOperationHookContext, j as FormCreateOperationContext, k as FormDeleteOperationContext, l as FormGetForUpdateOperationContext, m as FormGetOperationContext, y as FormInput, n as FormListOperationContext, b as FormSubmission, e as FormSubmissionWithForm, z as FormUpdate, o as FormUpdateOperationContext, v as PaginatedFormSubmissions, P as PaginatedForms, S as SerializedForm, c as SerializedFormSubmission, d as SerializedFormSubmissionSummary, a as SerializedFormSubmissionWithData, p as SubmissionCreateOperationContext, q as SubmissionDeleteOperationContext, r as SubmissionGetOperationContext, s as SubmissionHookContext, t as SubmissionListFormContext, u as SubmissionListOperationContext } from './shared/plugin-form-builder.BZYGyFgT.mjs';
6
+ import 'zod';
@@ -0,0 +1,6 @@
1
+ import '@btst/stack/plugins/api';
2
+ import '@btst/stack/authorization';
3
+ import '@btst/stack/context';
4
+ import './permissions.js';
5
+ export { F as Form, f as FormBuilderBackendConfig, g as FormBuilderBackendHooks, h as FormBuilderHookContext, i as FormBuilderOperationHookContext, j as FormCreateOperationContext, k as FormDeleteOperationContext, l as FormGetForUpdateOperationContext, m as FormGetOperationContext, y as FormInput, n as FormListOperationContext, b as FormSubmission, e as FormSubmissionWithForm, z as FormUpdate, o as FormUpdateOperationContext, v as PaginatedFormSubmissions, P as PaginatedForms, S as SerializedForm, c as SerializedFormSubmission, d as SerializedFormSubmissionSummary, a as SerializedFormSubmissionWithData, p as SubmissionCreateOperationContext, q as SubmissionDeleteOperationContext, r as SubmissionGetOperationContext, s as SubmissionHookContext, t as SubmissionListFormContext, u as SubmissionListOperationContext } from './shared/plugin-form-builder.D258Qpb8.js';
6
+ import 'zod';
package/dist/types.mjs ADDED
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,81 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ const jsxRuntime = require('react/jsx-runtime');
5
+ const AccordionPrimitive = require('@radix-ui/react-accordion');
6
+ const lucideReact = require('lucide-react');
7
+ const utils = require('../lib/utils.cjs');
8
+
9
+ function _interopNamespaceCompat(e) {
10
+ if (e && typeof e === 'object' && 'default' in e) return e;
11
+ const n = Object.create(null);
12
+ if (e) {
13
+ for (const k in e) {
14
+ n[k] = e[k];
15
+ }
16
+ }
17
+ n.default = e;
18
+ return n;
19
+ }
20
+
21
+ const AccordionPrimitive__namespace = /*#__PURE__*/_interopNamespaceCompat(AccordionPrimitive);
22
+
23
+ function Accordion({
24
+ ...props
25
+ }) {
26
+ return /* @__PURE__ */ jsxRuntime.jsx(AccordionPrimitive__namespace.Root, { "data-slot": "accordion", ...props });
27
+ }
28
+ function AccordionItem({
29
+ className,
30
+ ...props
31
+ }) {
32
+ return /* @__PURE__ */ jsxRuntime.jsx(
33
+ AccordionPrimitive__namespace.Item,
34
+ {
35
+ "data-slot": "accordion-item",
36
+ className: utils.cn("border-b last:border-b-0", className),
37
+ ...props
38
+ }
39
+ );
40
+ }
41
+ function AccordionTrigger({
42
+ className,
43
+ children,
44
+ ...props
45
+ }) {
46
+ return /* @__PURE__ */ jsxRuntime.jsx(AccordionPrimitive__namespace.Header, { className: "flex", children: /* @__PURE__ */ jsxRuntime.jsxs(
47
+ AccordionPrimitive__namespace.Trigger,
48
+ {
49
+ "data-slot": "accordion-trigger",
50
+ className: utils.cn(
51
+ "focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",
52
+ className
53
+ ),
54
+ ...props,
55
+ children: [
56
+ children,
57
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDownIcon, { className: "text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200" })
58
+ ]
59
+ }
60
+ ) });
61
+ }
62
+ function AccordionContent({
63
+ className,
64
+ children,
65
+ ...props
66
+ }) {
67
+ return /* @__PURE__ */ jsxRuntime.jsx(
68
+ AccordionPrimitive__namespace.Content,
69
+ {
70
+ "data-slot": "accordion-content",
71
+ className: "data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",
72
+ ...props,
73
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: utils.cn("pt-0 pb-4", className), children })
74
+ }
75
+ );
76
+ }
77
+
78
+ exports.Accordion = Accordion;
79
+ exports.AccordionContent = AccordionContent;
80
+ exports.AccordionItem = AccordionItem;
81
+ exports.AccordionTrigger = AccordionTrigger;