@btst/stack 1.5.2 → 1.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/dist/node_modules/.pnpm/@dnd-kit_accessibility@3.1.1_react@19.2.0/node_modules/@dnd-kit/accessibility/dist/accessibility.esm.cjs +68 -0
- package/dist/node_modules/.pnpm/@dnd-kit_accessibility@3.1.1_react@19.2.0/node_modules/@dnd-kit/accessibility/dist/accessibility.esm.mjs +60 -0
- package/dist/node_modules/.pnpm/@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@dnd-kit/core/dist/core.esm.cjs +3937 -0
- package/dist/node_modules/.pnpm/@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@dnd-kit/core/dist/core.esm.mjs +3907 -0
- package/dist/node_modules/.pnpm/@dnd-kit_modifiers@9.0.0_@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0__react@19.2.0/node_modules/@dnd-kit/modifiers/dist/modifiers.esm.cjs +30 -0
- package/dist/node_modules/.pnpm/@dnd-kit_modifiers@9.0.0_@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0__react@19.2.0/node_modules/@dnd-kit/modifiers/dist/modifiers.esm.mjs +28 -0
- package/dist/node_modules/.pnpm/@dnd-kit_sortable@10.0.0_@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0__react@19.2.0/node_modules/@dnd-kit/sortable/dist/sortable.esm.cjs +675 -0
- package/dist/node_modules/.pnpm/@dnd-kit_sortable@10.0.0_@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0__react@19.2.0/node_modules/@dnd-kit/sortable/dist/sortable.esm.mjs +661 -0
- package/dist/node_modules/.pnpm/@dnd-kit_utilities@3.2.2_react@19.2.0/node_modules/@dnd-kit/utilities/dist/utilities.esm.cjs +358 -0
- package/dist/node_modules/.pnpm/@dnd-kit_utilities@3.2.2_react@19.2.0/node_modules/@dnd-kit/utilities/dist/utilities.esm.mjs +332 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-tabs@1.1.13_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_865f042350eb43f3338b0fffb33f6246/node_modules/@radix-ui/react-tabs/dist/index.cjs +211 -0
- package/dist/node_modules/.pnpm/@radix-ui_react-tabs@1.1.13_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_865f042350eb43f3338b0fffb33f6246/node_modules/@radix-ui/react-tabs/dist/index.mjs +188 -0
- package/dist/packages/better-stack/src/plugins/cms/api/plugin.cjs +3 -2
- package/dist/packages/better-stack/src/plugins/cms/api/plugin.mjs +3 -2
- package/dist/packages/better-stack/src/plugins/cms/client/components/forms/content-form.cjs +15 -15
- package/dist/packages/better-stack/src/plugins/cms/client/components/forms/content-form.mjs +16 -16
- package/dist/packages/better-stack/src/plugins/form-builder/api/plugin.cjs +588 -0
- package/dist/packages/better-stack/src/plugins/form-builder/api/plugin.mjs +586 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/forms/form-renderer.cjs +131 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/forms/form-renderer.mjs +129 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-builder-skeleton.cjs +32 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-builder-skeleton.mjs +30 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-list-skeleton.cjs +21 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-list-skeleton.mjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/submissions-skeleton.cjs +34 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/submissions-skeleton.mjs +32 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/404-page.cjs +20 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/404-page.mjs +18 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.cjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.cjs +186 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.mjs +184 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.mjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.cjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.cjs +165 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.mjs +163 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.mjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.cjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.cjs +177 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.mjs +175 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.mjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/default-error.cjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/default-error.mjs +15 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/empty-state.cjs +16 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/empty-state.mjs +14 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/page-wrapper.cjs +27 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/page-wrapper.mjs +25 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/pagination.cjs +39 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/pagination.mjs +37 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/hooks/form-builder-hooks.cjs +551 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/hooks/form-builder-hooks.mjs +537 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-common.cjs +36 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-common.mjs +34 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-editor.cjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-editor.mjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-list.cjs +21 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-list.mjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-submissions.cjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-submissions.mjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-toasts.cjs +14 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-toasts.mjs +12 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/index.cjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/index.mjs +15 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/plugin.cjs +278 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/plugin.mjs +276 -0
- package/dist/packages/better-stack/src/plugins/form-builder/db.cjs +99 -0
- package/dist/packages/better-stack/src/plugins/form-builder/db.mjs +97 -0
- package/dist/packages/better-stack/src/plugins/form-builder/schemas.cjs +82 -0
- package/dist/packages/better-stack/src/plugins/form-builder/schemas.mjs +74 -0
- package/dist/packages/better-stack/src/plugins/form-builder/utils.cjs +37 -0
- package/dist/packages/better-stack/src/plugins/form-builder/utils.mjs +29 -0
- package/dist/packages/ui/src/components/auto-form/index.cjs +2 -12
- package/dist/packages/ui/src/components/auto-form/index.mjs +2 -9
- package/dist/packages/ui/src/components/auto-form/stepped-auto-form.cjs +377 -0
- package/dist/packages/ui/src/components/auto-form/stepped-auto-form.mjs +368 -0
- package/dist/packages/ui/src/components/auto-form/utils.cjs +1 -56
- package/dist/packages/ui/src/components/auto-form/utils.mjs +2 -56
- package/dist/packages/ui/src/components/form-builder/canvas.cjs +111 -0
- package/dist/packages/ui/src/components/form-builder/canvas.mjs +109 -0
- package/dist/packages/ui/src/components/form-builder/components/index.cjs +570 -0
- package/dist/packages/ui/src/components/form-builder/components/index.mjs +553 -0
- package/dist/packages/ui/src/components/form-builder/edit-field-dialog.cjs +131 -0
- package/dist/packages/ui/src/components/form-builder/edit-field-dialog.mjs +129 -0
- package/dist/packages/ui/src/components/form-builder/form-preview.cjs +73 -0
- package/dist/packages/ui/src/components/form-builder/form-preview.mjs +71 -0
- package/dist/packages/ui/src/components/form-builder/index.cjs +353 -0
- package/dist/packages/ui/src/components/form-builder/index.mjs +344 -0
- package/dist/packages/ui/src/components/form-builder/nested-field-editor-dialog.cjs +263 -0
- package/dist/packages/ui/src/components/form-builder/nested-field-editor-dialog.mjs +261 -0
- package/dist/packages/ui/src/components/form-builder/palette.cjs +52 -0
- package/dist/packages/ui/src/components/form-builder/palette.mjs +49 -0
- package/dist/packages/ui/src/components/form-builder/schema-utils.cjs +120 -0
- package/dist/packages/ui/src/components/form-builder/schema-utils.mjs +114 -0
- package/dist/packages/ui/src/components/form-builder/sortable-field.cjs +151 -0
- package/dist/packages/ui/src/components/form-builder/sortable-field.mjs +148 -0
- package/dist/packages/ui/src/components/form-builder/step-tabs.cjs +180 -0
- package/dist/packages/ui/src/components/form-builder/step-tabs.mjs +178 -0
- package/dist/packages/ui/src/components/form-builder/types.cjs +7 -0
- package/dist/packages/ui/src/components/form-builder/types.mjs +5 -0
- package/dist/packages/ui/src/components/form-builder/validation-schemas.cjs +67 -0
- package/dist/packages/ui/src/components/form-builder/validation-schemas.mjs +56 -0
- package/dist/packages/ui/src/components/tabs.cjs +70 -0
- package/dist/packages/ui/src/components/tabs.mjs +65 -0
- package/dist/packages/ui/src/lib/schema-converter.cjs +130 -0
- package/dist/packages/ui/src/lib/schema-converter.mjs +124 -0
- package/dist/plugins/blog/api/index.d.cts +1 -1
- package/dist/plugins/blog/api/index.d.mts +1 -1
- package/dist/plugins/blog/api/index.d.ts +1 -1
- package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
- package/dist/plugins/blog/client/index.d.cts +1 -1
- package/dist/plugins/blog/client/index.d.mts +1 -1
- package/dist/plugins/blog/client/index.d.ts +1 -1
- package/dist/plugins/blog/query-keys.d.cts +2 -2
- package/dist/plugins/blog/query-keys.d.mts +2 -2
- package/dist/plugins/blog/query-keys.d.ts +2 -2
- package/dist/plugins/cms/client/index.cjs +6 -0
- package/dist/plugins/cms/client/index.d.cts +6 -113
- package/dist/plugins/cms/client/index.d.mts +6 -113
- package/dist/plugins/cms/client/index.d.ts +6 -113
- package/dist/plugins/cms/client/index.mjs +1 -0
- package/dist/plugins/form-builder/api/index.cjs +7 -0
- package/dist/plugins/form-builder/api/index.d.cts +141 -0
- package/dist/plugins/form-builder/api/index.d.mts +141 -0
- package/dist/plugins/form-builder/api/index.d.ts +141 -0
- package/dist/plugins/form-builder/api/index.mjs +1 -0
- package/dist/plugins/form-builder/client/components/index.cjs +29 -0
- package/dist/plugins/form-builder/client/components/index.d.cts +93 -0
- package/dist/plugins/form-builder/client/components/index.d.mts +93 -0
- package/dist/plugins/form-builder/client/components/index.d.ts +93 -0
- package/dist/plugins/form-builder/client/components/index.mjs +18 -0
- package/dist/plugins/form-builder/client/hooks/index.cjs +19 -0
- package/dist/plugins/form-builder/client/hooks/index.d.cts +154 -0
- package/dist/plugins/form-builder/client/hooks/index.d.mts +154 -0
- package/dist/plugins/form-builder/client/hooks/index.d.ts +154 -0
- package/dist/plugins/form-builder/client/hooks/index.mjs +1 -0
- package/dist/plugins/form-builder/client/index.cjs +13 -0
- package/dist/plugins/form-builder/client/index.d.cts +381 -0
- package/dist/plugins/form-builder/client/index.d.mts +381 -0
- package/dist/plugins/form-builder/client/index.d.ts +381 -0
- package/dist/plugins/form-builder/client/index.mjs +2 -0
- package/dist/plugins/form-builder/client.css +3 -0
- package/dist/plugins/form-builder/query-keys.cjs +143 -0
- package/dist/plugins/form-builder/query-keys.d.cts +74 -0
- package/dist/plugins/form-builder/query-keys.d.mts +74 -0
- package/dist/plugins/form-builder/query-keys.d.ts +74 -0
- package/dist/plugins/form-builder/query-keys.mjs +141 -0
- package/dist/plugins/form-builder/style.css +19 -0
- package/dist/shared/stack.AX5nZ6A3.d.cts +86 -0
- package/dist/shared/stack.AX5nZ6A3.d.mts +86 -0
- package/dist/shared/stack.AX5nZ6A3.d.ts +86 -0
- package/dist/shared/stack.BIh2AXaW.d.cts +123 -0
- package/dist/shared/stack.BIh2AXaW.d.mts +123 -0
- package/dist/shared/stack.BIh2AXaW.d.ts +123 -0
- package/dist/shared/stack.DzH_wcvr.d.cts +195 -0
- package/dist/shared/stack.DzH_wcvr.d.mts +195 -0
- package/dist/shared/stack.DzH_wcvr.d.ts +195 -0
- package/package.json +54 -1
- package/src/plugins/cms/api/plugin.ts +9 -4
- package/src/plugins/cms/client/components/forms/content-form.tsx +23 -25
- package/src/plugins/cms/client/index.ts +11 -0
- package/src/plugins/form-builder/api/index.ts +1 -0
- package/src/plugins/form-builder/api/plugin.ts +776 -0
- package/src/plugins/form-builder/client/components/forms/form-renderer.tsx +253 -0
- package/src/plugins/form-builder/client/components/index.tsx +24 -0
- package/src/plugins/form-builder/client/components/loading/form-builder-skeleton.tsx +42 -0
- package/src/plugins/form-builder/client/components/loading/form-list-skeleton.tsx +25 -0
- package/src/plugins/form-builder/client/components/loading/index.tsx +3 -0
- package/src/plugins/form-builder/client/components/loading/submissions-skeleton.tsx +40 -0
- package/src/plugins/form-builder/client/components/pages/404-page.tsx +28 -0
- package/src/plugins/form-builder/client/components/pages/form-builder-page.internal.tsx +253 -0
- package/src/plugins/form-builder/client/components/pages/form-builder-page.tsx +26 -0
- package/src/plugins/form-builder/client/components/pages/form-list-page.internal.tsx +231 -0
- package/src/plugins/form-builder/client/components/pages/form-list-page.tsx +22 -0
- package/src/plugins/form-builder/client/components/pages/submissions-page.internal.tsx +268 -0
- package/src/plugins/form-builder/client/components/pages/submissions-page.tsx +26 -0
- package/src/plugins/form-builder/client/components/shared/default-error.tsx +30 -0
- package/src/plugins/form-builder/client/components/shared/empty-state.tsx +26 -0
- package/src/plugins/form-builder/client/components/shared/page-wrapper.tsx +32 -0
- package/src/plugins/form-builder/client/components/shared/pagination.tsx +52 -0
- package/src/plugins/form-builder/client/hooks/form-builder-hooks.tsx +799 -0
- package/src/plugins/form-builder/client/hooks/index.tsx +1 -0
- package/src/plugins/form-builder/client/index.ts +22 -0
- package/src/plugins/form-builder/client/localization/form-builder-common.ts +36 -0
- package/src/plugins/form-builder/client/localization/form-builder-editor.ts +18 -0
- package/src/plugins/form-builder/client/localization/form-builder-list.ts +17 -0
- package/src/plugins/form-builder/client/localization/form-builder-submissions.ts +17 -0
- package/src/plugins/form-builder/client/localization/form-builder-toasts.ts +10 -0
- package/src/plugins/form-builder/client/localization/index.ts +15 -0
- package/src/plugins/form-builder/client/overrides.ts +146 -0
- package/src/plugins/form-builder/client/plugin.tsx +488 -0
- package/src/plugins/form-builder/client.css +3 -0
- package/src/plugins/form-builder/db.ts +99 -0
- package/src/plugins/form-builder/query-keys.ts +198 -0
- package/src/plugins/form-builder/schemas.ts +122 -0
- package/src/plugins/form-builder/style.css +19 -0
- package/src/plugins/form-builder/types.ts +317 -0
- package/src/plugins/form-builder/utils.ts +63 -0
- package/dist/shared/{stack.DLhzx1-D.d.cts → stack.CcI4sYJP.d.cts} +1 -1
- package/dist/shared/{stack.DLhzx1-D.d.mts → stack.CcI4sYJP.d.mts} +1 -1
- package/dist/shared/{stack.DLhzx1-D.d.ts → stack.CcI4sYJP.d.ts} +1 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
+
import { createApiClient } from '@btst/stack/plugins/client';
|
|
3
|
+
import { P as PaginatedForms, S as SerializedForm, c as PaginatedFormSubmissions, b as SerializedFormSubmissionWithData } from '../../shared/stack.DzH_wcvr.js';
|
|
4
|
+
import { FormBuilderApiRouter } from './api/index.js';
|
|
5
|
+
import '@btst/stack/plugins/api';
|
|
6
|
+
import 'better-call';
|
|
7
|
+
import 'zod';
|
|
8
|
+
|
|
9
|
+
interface FormListParams {
|
|
10
|
+
status?: "active" | "inactive" | "archived";
|
|
11
|
+
limit?: number;
|
|
12
|
+
offset?: number;
|
|
13
|
+
}
|
|
14
|
+
interface SubmissionListParams {
|
|
15
|
+
formId: string;
|
|
16
|
+
limit?: number;
|
|
17
|
+
offset?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create Form Builder query keys for React Query
|
|
21
|
+
* Used by consumers to fetch forms and submissions
|
|
22
|
+
*/
|
|
23
|
+
declare function createFormBuilderQueryKeys(client: ReturnType<typeof createApiClient<FormBuilderApiRouter>>, headers?: HeadersInit): {
|
|
24
|
+
forms: {
|
|
25
|
+
_def: readonly ["forms"];
|
|
26
|
+
} & {
|
|
27
|
+
list: ((params?: FormListParams | undefined) => Omit<{
|
|
28
|
+
queryKey: readonly ["forms", "list", string, FormListParams];
|
|
29
|
+
queryFn: _tanstack_react_query.QueryFunction<PaginatedForms, readonly ["forms", "list", string, FormListParams]>;
|
|
30
|
+
} & {
|
|
31
|
+
_def: readonly ["forms", "list"];
|
|
32
|
+
}, "_def">) & {
|
|
33
|
+
_def: readonly ["forms", "list"];
|
|
34
|
+
};
|
|
35
|
+
bySlug: ((slug: string) => Omit<{
|
|
36
|
+
queryKey: readonly ["forms", "bySlug", string, string];
|
|
37
|
+
queryFn: _tanstack_react_query.QueryFunction<SerializedForm | null, readonly ["forms", "bySlug", string, string]>;
|
|
38
|
+
} & {
|
|
39
|
+
_def: readonly ["forms", "bySlug"];
|
|
40
|
+
}, "_def">) & {
|
|
41
|
+
_def: readonly ["forms", "bySlug"];
|
|
42
|
+
};
|
|
43
|
+
byId: ((id: string) => Omit<{
|
|
44
|
+
queryKey: readonly ["forms", "byId", string, string];
|
|
45
|
+
queryFn: _tanstack_react_query.QueryFunction<SerializedForm | null, readonly ["forms", "byId", string, string]>;
|
|
46
|
+
} & {
|
|
47
|
+
_def: readonly ["forms", "byId"];
|
|
48
|
+
}, "_def">) & {
|
|
49
|
+
_def: readonly ["forms", "byId"];
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
formSubmissions: {
|
|
53
|
+
_def: readonly ["formSubmissions"];
|
|
54
|
+
} & {
|
|
55
|
+
list: ((params: SubmissionListParams) => Omit<{
|
|
56
|
+
queryKey: readonly ["formSubmissions", "list", SubmissionListParams];
|
|
57
|
+
queryFn: _tanstack_react_query.QueryFunction<PaginatedFormSubmissions<Record<string, unknown>>, readonly ["formSubmissions", "list", SubmissionListParams]>;
|
|
58
|
+
} & {
|
|
59
|
+
_def: readonly ["formSubmissions", "list"];
|
|
60
|
+
}, "_def">) & {
|
|
61
|
+
_def: readonly ["formSubmissions", "list"];
|
|
62
|
+
};
|
|
63
|
+
detail: ((formId: string, subId: string) => Omit<{
|
|
64
|
+
queryKey: readonly ["formSubmissions", "detail", string, string];
|
|
65
|
+
queryFn: _tanstack_react_query.QueryFunction<SerializedFormSubmissionWithData<Record<string, unknown>> | null, readonly ["formSubmissions", "detail", string, string]>;
|
|
66
|
+
} & {
|
|
67
|
+
_def: readonly ["formSubmissions", "detail"];
|
|
68
|
+
}, "_def">) & {
|
|
69
|
+
_def: readonly ["formSubmissions", "detail"];
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { createFormBuilderQueryKeys };
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { mergeQueryKeys, createQueryKeys } from '@lukemorales/query-key-factory';
|
|
2
|
+
|
|
3
|
+
function isErrorResponse(response) {
|
|
4
|
+
if (typeof response !== "object" || response === null) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
const obj = response;
|
|
8
|
+
return "error" in obj && obj.error !== null && obj.error !== void 0;
|
|
9
|
+
}
|
|
10
|
+
function toError(error) {
|
|
11
|
+
if (error instanceof Error) {
|
|
12
|
+
return error;
|
|
13
|
+
}
|
|
14
|
+
if (typeof error === "object" && error !== null) {
|
|
15
|
+
const errorObj = error;
|
|
16
|
+
const message = (typeof errorObj.message === "string" ? errorObj.message : null) || (typeof errorObj.error === "string" ? errorObj.error : null) || JSON.stringify(error);
|
|
17
|
+
const err = new Error(message);
|
|
18
|
+
Object.assign(err, error);
|
|
19
|
+
return err;
|
|
20
|
+
}
|
|
21
|
+
return new Error(String(error));
|
|
22
|
+
}
|
|
23
|
+
function createFormBuilderQueryKeys(client, headers) {
|
|
24
|
+
const forms = createFormsQueries(client, headers);
|
|
25
|
+
const submissions = createSubmissionsQueries(client, headers);
|
|
26
|
+
return mergeQueryKeys(forms, submissions);
|
|
27
|
+
}
|
|
28
|
+
function createFormsQueries(client, headers) {
|
|
29
|
+
return createQueryKeys("forms", {
|
|
30
|
+
list: (params = {}) => ({
|
|
31
|
+
queryKey: ["list", params],
|
|
32
|
+
queryFn: async () => {
|
|
33
|
+
try {
|
|
34
|
+
const response = await client("/forms", {
|
|
35
|
+
method: "GET",
|
|
36
|
+
query: {
|
|
37
|
+
status: params.status,
|
|
38
|
+
limit: params.limit ?? 20,
|
|
39
|
+
offset: params.offset ?? 0
|
|
40
|
+
},
|
|
41
|
+
headers
|
|
42
|
+
});
|
|
43
|
+
if (isErrorResponse(response)) {
|
|
44
|
+
throw toError(response.error);
|
|
45
|
+
}
|
|
46
|
+
return response.data;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}),
|
|
52
|
+
bySlug: (slug) => ({
|
|
53
|
+
queryKey: ["bySlug", slug],
|
|
54
|
+
queryFn: async () => {
|
|
55
|
+
if (!slug) return null;
|
|
56
|
+
try {
|
|
57
|
+
const response = await client("/forms/:slug", {
|
|
58
|
+
method: "GET",
|
|
59
|
+
params: { slug },
|
|
60
|
+
headers
|
|
61
|
+
});
|
|
62
|
+
if (isErrorResponse(response)) {
|
|
63
|
+
throw toError(response.error);
|
|
64
|
+
}
|
|
65
|
+
return response.data;
|
|
66
|
+
} catch (error) {
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}),
|
|
71
|
+
byId: (id) => ({
|
|
72
|
+
queryKey: ["byId", id],
|
|
73
|
+
queryFn: async () => {
|
|
74
|
+
if (!id) return null;
|
|
75
|
+
try {
|
|
76
|
+
const response = await client("/forms/id/:id", {
|
|
77
|
+
method: "GET",
|
|
78
|
+
params: { id },
|
|
79
|
+
headers
|
|
80
|
+
});
|
|
81
|
+
if (isErrorResponse(response)) {
|
|
82
|
+
throw toError(response.error);
|
|
83
|
+
}
|
|
84
|
+
return response.data;
|
|
85
|
+
} catch (error) {
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function createSubmissionsQueries(client, headers) {
|
|
93
|
+
return createQueryKeys("formSubmissions", {
|
|
94
|
+
list: (params) => ({
|
|
95
|
+
queryKey: [params],
|
|
96
|
+
queryFn: async () => {
|
|
97
|
+
try {
|
|
98
|
+
const response = await client("/forms/:formId/submissions", {
|
|
99
|
+
method: "GET",
|
|
100
|
+
params: { formId: params.formId },
|
|
101
|
+
query: {
|
|
102
|
+
limit: params.limit ?? 20,
|
|
103
|
+
offset: params.offset ?? 0
|
|
104
|
+
},
|
|
105
|
+
headers
|
|
106
|
+
});
|
|
107
|
+
if (isErrorResponse(response)) {
|
|
108
|
+
throw toError(response.error);
|
|
109
|
+
}
|
|
110
|
+
return response.data;
|
|
111
|
+
} catch (error) {
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}),
|
|
116
|
+
detail: (formId, subId) => ({
|
|
117
|
+
queryKey: [formId, subId],
|
|
118
|
+
queryFn: async () => {
|
|
119
|
+
if (!formId || !subId) return null;
|
|
120
|
+
try {
|
|
121
|
+
const response = await client(
|
|
122
|
+
"/forms/:formId/submissions/:subId",
|
|
123
|
+
{
|
|
124
|
+
method: "GET",
|
|
125
|
+
params: { formId, subId },
|
|
126
|
+
headers
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
if (isErrorResponse(response)) {
|
|
130
|
+
throw toError(response.error);
|
|
131
|
+
}
|
|
132
|
+
return response.data;
|
|
133
|
+
} catch (error) {
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export { createFormBuilderQueryKeys };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
@import "./client.css";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Form Builder Plugin CSS - Includes Tailwind class scanning
|
|
5
|
+
*
|
|
6
|
+
* When consumed from npm, Tailwind v4 will automatically scan this package's
|
|
7
|
+
* source files for Tailwind classes. Consumers only need:
|
|
8
|
+
* @import "@btst/stack/plugins/form-builder/css";
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/* Scan this package's source files for Tailwind classes */
|
|
12
|
+
@source "../../../src/**/*.{ts,tsx}";
|
|
13
|
+
|
|
14
|
+
/* Scan UI package components (when installed as npm package the UI package will be in this dir) */
|
|
15
|
+
@source "../../packages/ui/src";
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* alternatively consumer can use @source "../node_modules/@btst/stack/src/**\/*.{ts,tsx}";
|
|
19
|
+
*/
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Unified Schema Converter Module
|
|
5
|
+
*
|
|
6
|
+
* Provides consistent bidirectional conversion between Zod schemas and JSON Schema,
|
|
7
|
+
* handling all edge cases in one place:
|
|
8
|
+
*
|
|
9
|
+
* 1. Date handling: z.date() ↔ { type: "string", format: "date-time" }
|
|
10
|
+
* 2. Steps metadata: Preserves multi-step form configuration
|
|
11
|
+
* 3. Step group mapping: Tracks which fields belong to which step
|
|
12
|
+
* 4. Date constraints: Preserves min/max date validations
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* ```ts
|
|
16
|
+
* // Zod → JSON Schema (for storage/transport)
|
|
17
|
+
* const jsonSchema = zodToFormSchema(myZodSchema);
|
|
18
|
+
*
|
|
19
|
+
* // JSON Schema → Zod (for validation)
|
|
20
|
+
* const zodSchema = formSchemaToZod(jsonSchema);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
interface FormStep {
|
|
25
|
+
id: string;
|
|
26
|
+
title: string;
|
|
27
|
+
}
|
|
28
|
+
interface FormSchemaMetadata {
|
|
29
|
+
/** Multi-step form step definitions */
|
|
30
|
+
steps?: FormStep[];
|
|
31
|
+
/** Map of field names to their step indices */
|
|
32
|
+
stepGroupMap?: Record<string, number>;
|
|
33
|
+
}
|
|
34
|
+
interface JsonSchemaProperty {
|
|
35
|
+
type?: string;
|
|
36
|
+
format?: string;
|
|
37
|
+
formatMinimum?: string;
|
|
38
|
+
formatMaximum?: string;
|
|
39
|
+
stepGroup?: number;
|
|
40
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
interface FormJsonSchema {
|
|
44
|
+
type?: string;
|
|
45
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
46
|
+
required?: string[];
|
|
47
|
+
steps?: FormStep[];
|
|
48
|
+
stepGroupMap?: Record<string, number>;
|
|
49
|
+
[key: string]: unknown;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Convert a Zod schema to JSON Schema with proper handling for:
|
|
53
|
+
* - z.date() → { type: "string", format: "date-time" }
|
|
54
|
+
* - Date min/max constraints → formatMinimum/formatMaximum
|
|
55
|
+
* - Steps metadata (if provided via schema.meta() or explicit metadata param)
|
|
56
|
+
*
|
|
57
|
+
* @param schema - The Zod schema to convert
|
|
58
|
+
* @param metadata - Optional explicit metadata to include (overrides schema meta)
|
|
59
|
+
*/
|
|
60
|
+
declare function zodToFormSchema<T extends z.ZodType>(schema: T, metadata?: FormSchemaMetadata): FormJsonSchema;
|
|
61
|
+
/**
|
|
62
|
+
* Convert JSON Schema to Zod schema with proper handling for:
|
|
63
|
+
* - { type: "string", format: "date-time" } → date field (with constraints)
|
|
64
|
+
* - Steps metadata re-attachment (preserved via .meta())
|
|
65
|
+
* - Step group mapping
|
|
66
|
+
*
|
|
67
|
+
* @param jsonSchema - The JSON Schema to convert
|
|
68
|
+
* @returns A Zod schema ready for validation, with all metadata preserved
|
|
69
|
+
*/
|
|
70
|
+
declare function formSchemaToZod(jsonSchema: FormJsonSchema): z.ZodType;
|
|
71
|
+
/**
|
|
72
|
+
* Check if a JSON Schema has multi-step configuration.
|
|
73
|
+
*/
|
|
74
|
+
declare function hasSteps(jsonSchema: FormJsonSchema): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Get steps from a JSON Schema.
|
|
77
|
+
*/
|
|
78
|
+
declare function getSteps(jsonSchema: FormJsonSchema): FormStep[];
|
|
79
|
+
/**
|
|
80
|
+
* Get the step group map from a JSON Schema.
|
|
81
|
+
* Returns a map of field names to step indices.
|
|
82
|
+
*/
|
|
83
|
+
declare function getStepGroupMap(jsonSchema: FormJsonSchema): Record<string, number>;
|
|
84
|
+
|
|
85
|
+
export { getStepGroupMap as a, formSchemaToZod as f, getSteps as g, hasSteps as h, zodToFormSchema as z };
|
|
86
|
+
export type { FormStep as F, FormSchemaMetadata as b };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Unified Schema Converter Module
|
|
5
|
+
*
|
|
6
|
+
* Provides consistent bidirectional conversion between Zod schemas and JSON Schema,
|
|
7
|
+
* handling all edge cases in one place:
|
|
8
|
+
*
|
|
9
|
+
* 1. Date handling: z.date() ↔ { type: "string", format: "date-time" }
|
|
10
|
+
* 2. Steps metadata: Preserves multi-step form configuration
|
|
11
|
+
* 3. Step group mapping: Tracks which fields belong to which step
|
|
12
|
+
* 4. Date constraints: Preserves min/max date validations
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* ```ts
|
|
16
|
+
* // Zod → JSON Schema (for storage/transport)
|
|
17
|
+
* const jsonSchema = zodToFormSchema(myZodSchema);
|
|
18
|
+
*
|
|
19
|
+
* // JSON Schema → Zod (for validation)
|
|
20
|
+
* const zodSchema = formSchemaToZod(jsonSchema);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
interface FormStep {
|
|
25
|
+
id: string;
|
|
26
|
+
title: string;
|
|
27
|
+
}
|
|
28
|
+
interface FormSchemaMetadata {
|
|
29
|
+
/** Multi-step form step definitions */
|
|
30
|
+
steps?: FormStep[];
|
|
31
|
+
/** Map of field names to their step indices */
|
|
32
|
+
stepGroupMap?: Record<string, number>;
|
|
33
|
+
}
|
|
34
|
+
interface JsonSchemaProperty {
|
|
35
|
+
type?: string;
|
|
36
|
+
format?: string;
|
|
37
|
+
formatMinimum?: string;
|
|
38
|
+
formatMaximum?: string;
|
|
39
|
+
stepGroup?: number;
|
|
40
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
interface FormJsonSchema {
|
|
44
|
+
type?: string;
|
|
45
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
46
|
+
required?: string[];
|
|
47
|
+
steps?: FormStep[];
|
|
48
|
+
stepGroupMap?: Record<string, number>;
|
|
49
|
+
[key: string]: unknown;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Convert a Zod schema to JSON Schema with proper handling for:
|
|
53
|
+
* - z.date() → { type: "string", format: "date-time" }
|
|
54
|
+
* - Date min/max constraints → formatMinimum/formatMaximum
|
|
55
|
+
* - Steps metadata (if provided via schema.meta() or explicit metadata param)
|
|
56
|
+
*
|
|
57
|
+
* @param schema - The Zod schema to convert
|
|
58
|
+
* @param metadata - Optional explicit metadata to include (overrides schema meta)
|
|
59
|
+
*/
|
|
60
|
+
declare function zodToFormSchema<T extends z.ZodType>(schema: T, metadata?: FormSchemaMetadata): FormJsonSchema;
|
|
61
|
+
/**
|
|
62
|
+
* Convert JSON Schema to Zod schema with proper handling for:
|
|
63
|
+
* - { type: "string", format: "date-time" } → date field (with constraints)
|
|
64
|
+
* - Steps metadata re-attachment (preserved via .meta())
|
|
65
|
+
* - Step group mapping
|
|
66
|
+
*
|
|
67
|
+
* @param jsonSchema - The JSON Schema to convert
|
|
68
|
+
* @returns A Zod schema ready for validation, with all metadata preserved
|
|
69
|
+
*/
|
|
70
|
+
declare function formSchemaToZod(jsonSchema: FormJsonSchema): z.ZodType;
|
|
71
|
+
/**
|
|
72
|
+
* Check if a JSON Schema has multi-step configuration.
|
|
73
|
+
*/
|
|
74
|
+
declare function hasSteps(jsonSchema: FormJsonSchema): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Get steps from a JSON Schema.
|
|
77
|
+
*/
|
|
78
|
+
declare function getSteps(jsonSchema: FormJsonSchema): FormStep[];
|
|
79
|
+
/**
|
|
80
|
+
* Get the step group map from a JSON Schema.
|
|
81
|
+
* Returns a map of field names to step indices.
|
|
82
|
+
*/
|
|
83
|
+
declare function getStepGroupMap(jsonSchema: FormJsonSchema): Record<string, number>;
|
|
84
|
+
|
|
85
|
+
export { getStepGroupMap as a, formSchemaToZod as f, getSteps as g, hasSteps as h, zodToFormSchema as z };
|
|
86
|
+
export type { FormStep as F, FormSchemaMetadata as b };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Unified Schema Converter Module
|
|
5
|
+
*
|
|
6
|
+
* Provides consistent bidirectional conversion between Zod schemas and JSON Schema,
|
|
7
|
+
* handling all edge cases in one place:
|
|
8
|
+
*
|
|
9
|
+
* 1. Date handling: z.date() ↔ { type: "string", format: "date-time" }
|
|
10
|
+
* 2. Steps metadata: Preserves multi-step form configuration
|
|
11
|
+
* 3. Step group mapping: Tracks which fields belong to which step
|
|
12
|
+
* 4. Date constraints: Preserves min/max date validations
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* ```ts
|
|
16
|
+
* // Zod → JSON Schema (for storage/transport)
|
|
17
|
+
* const jsonSchema = zodToFormSchema(myZodSchema);
|
|
18
|
+
*
|
|
19
|
+
* // JSON Schema → Zod (for validation)
|
|
20
|
+
* const zodSchema = formSchemaToZod(jsonSchema);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
interface FormStep {
|
|
25
|
+
id: string;
|
|
26
|
+
title: string;
|
|
27
|
+
}
|
|
28
|
+
interface FormSchemaMetadata {
|
|
29
|
+
/** Multi-step form step definitions */
|
|
30
|
+
steps?: FormStep[];
|
|
31
|
+
/** Map of field names to their step indices */
|
|
32
|
+
stepGroupMap?: Record<string, number>;
|
|
33
|
+
}
|
|
34
|
+
interface JsonSchemaProperty {
|
|
35
|
+
type?: string;
|
|
36
|
+
format?: string;
|
|
37
|
+
formatMinimum?: string;
|
|
38
|
+
formatMaximum?: string;
|
|
39
|
+
stepGroup?: number;
|
|
40
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
interface FormJsonSchema {
|
|
44
|
+
type?: string;
|
|
45
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
46
|
+
required?: string[];
|
|
47
|
+
steps?: FormStep[];
|
|
48
|
+
stepGroupMap?: Record<string, number>;
|
|
49
|
+
[key: string]: unknown;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Convert a Zod schema to JSON Schema with proper handling for:
|
|
53
|
+
* - z.date() → { type: "string", format: "date-time" }
|
|
54
|
+
* - Date min/max constraints → formatMinimum/formatMaximum
|
|
55
|
+
* - Steps metadata (if provided via schema.meta() or explicit metadata param)
|
|
56
|
+
*
|
|
57
|
+
* @param schema - The Zod schema to convert
|
|
58
|
+
* @param metadata - Optional explicit metadata to include (overrides schema meta)
|
|
59
|
+
*/
|
|
60
|
+
declare function zodToFormSchema<T extends z.ZodType>(schema: T, metadata?: FormSchemaMetadata): FormJsonSchema;
|
|
61
|
+
/**
|
|
62
|
+
* Convert JSON Schema to Zod schema with proper handling for:
|
|
63
|
+
* - { type: "string", format: "date-time" } → date field (with constraints)
|
|
64
|
+
* - Steps metadata re-attachment (preserved via .meta())
|
|
65
|
+
* - Step group mapping
|
|
66
|
+
*
|
|
67
|
+
* @param jsonSchema - The JSON Schema to convert
|
|
68
|
+
* @returns A Zod schema ready for validation, with all metadata preserved
|
|
69
|
+
*/
|
|
70
|
+
declare function formSchemaToZod(jsonSchema: FormJsonSchema): z.ZodType;
|
|
71
|
+
/**
|
|
72
|
+
* Check if a JSON Schema has multi-step configuration.
|
|
73
|
+
*/
|
|
74
|
+
declare function hasSteps(jsonSchema: FormJsonSchema): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Get steps from a JSON Schema.
|
|
77
|
+
*/
|
|
78
|
+
declare function getSteps(jsonSchema: FormJsonSchema): FormStep[];
|
|
79
|
+
/**
|
|
80
|
+
* Get the step group map from a JSON Schema.
|
|
81
|
+
* Returns a map of field names to step indices.
|
|
82
|
+
*/
|
|
83
|
+
declare function getStepGroupMap(jsonSchema: FormJsonSchema): Record<string, number>;
|
|
84
|
+
|
|
85
|
+
export { getStepGroupMap as a, formSchemaToZod as f, getSteps as g, hasSteps as h, zodToFormSchema as z };
|
|
86
|
+
export type { FormStep as F, FormSchemaMetadata as b };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { ControllerRenderProps, FieldValues } from 'react-hook-form';
|
|
2
|
+
import * as zod from 'zod';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
declare function AutoFormCheckbox({ label, isRequired, field, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
|
|
6
|
+
|
|
7
|
+
declare function AutoFormDate({ label, isRequired, field, fieldConfigItem, fieldProps, zodItem, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
|
|
8
|
+
|
|
9
|
+
declare function AutoFormEnum({ label, isRequired, field, fieldConfigItem, zodItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
declare function AutoFormInput({ label, isRequired, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
|
|
12
|
+
|
|
13
|
+
declare function AutoFormNumber({ label, isRequired, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
|
|
14
|
+
|
|
15
|
+
declare function AutoFormRadioGroup({ label, isRequired, field, zodItem, fieldProps, fieldConfigItem, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
|
|
16
|
+
|
|
17
|
+
declare function AutoFormSwitch({ label, isRequired, field, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
|
|
18
|
+
|
|
19
|
+
declare function AutoFormTextarea({ label, isRequired, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
|
|
20
|
+
|
|
21
|
+
declare const INPUT_COMPONENTS: {
|
|
22
|
+
checkbox: typeof AutoFormCheckbox;
|
|
23
|
+
date: typeof AutoFormDate;
|
|
24
|
+
select: typeof AutoFormEnum;
|
|
25
|
+
radio: typeof AutoFormRadioGroup;
|
|
26
|
+
switch: typeof AutoFormSwitch;
|
|
27
|
+
textarea: typeof AutoFormTextarea;
|
|
28
|
+
number: typeof AutoFormNumber;
|
|
29
|
+
fallback: typeof AutoFormInput;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Shared types between form-builder and auto-form.
|
|
34
|
+
*
|
|
35
|
+
* These types ensure consistency when:
|
|
36
|
+
* - form-builder creates JSON Schema properties
|
|
37
|
+
* - auto-form consumes JSON Schema properties
|
|
38
|
+
* - inputProps flow from form-builder → JSON Schema → auto-form
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Common input props shared by all field types.
|
|
43
|
+
*/
|
|
44
|
+
interface BaseInputProps {
|
|
45
|
+
/** Whether the field is disabled */
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
/** Whether the field is read-only */
|
|
48
|
+
readOnly?: boolean;
|
|
49
|
+
/** Whether the field is required */
|
|
50
|
+
required?: boolean;
|
|
51
|
+
/** Whether to show the label (auto-form specific) */
|
|
52
|
+
showLabel?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Generic input props that accept any field type.
|
|
56
|
+
* Use this when the backing type is not known at compile time.
|
|
57
|
+
*
|
|
58
|
+
* This is the catch-all type used for runtime flexibility.
|
|
59
|
+
*/
|
|
60
|
+
interface SerializableInputProps extends BaseInputProps {
|
|
61
|
+
placeholder?: string;
|
|
62
|
+
type?: string;
|
|
63
|
+
defaultValue?: unknown;
|
|
64
|
+
min?: number | string;
|
|
65
|
+
max?: number | string;
|
|
66
|
+
step?: number | string;
|
|
67
|
+
minLength?: number;
|
|
68
|
+
maxLength?: number;
|
|
69
|
+
pattern?: string;
|
|
70
|
+
autoComplete?: string;
|
|
71
|
+
/** Allow additional props for extensibility */
|
|
72
|
+
[key: string]: unknown;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Input props for form fields.
|
|
77
|
+
*
|
|
78
|
+
* This is the runtime type that accepts any input props.
|
|
79
|
+
* For type-safe props, use the discriminated types:
|
|
80
|
+
* - StringInputProps for text inputs
|
|
81
|
+
* - NumberInputProps for number inputs
|
|
82
|
+
* - BooleanInputProps for checkboxes/switches
|
|
83
|
+
* - DateInputProps for date pickers
|
|
84
|
+
* - EnumInputProps for selects/radios
|
|
85
|
+
*/
|
|
86
|
+
type FieldInputProps = SerializableInputProps & Omit<React.InputHTMLAttributes<HTMLInputElement>, keyof SerializableInputProps> & Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, keyof SerializableInputProps>;
|
|
87
|
+
/**
|
|
88
|
+
* Configuration for a single field in AutoForm.
|
|
89
|
+
*
|
|
90
|
+
* Note: This type is designed to align with form-builder's FormBuilderFieldProps
|
|
91
|
+
* so that JSON Schema properties can be easily converted to field configs.
|
|
92
|
+
*/
|
|
93
|
+
type FieldConfigItem = {
|
|
94
|
+
/** Description text or React node */
|
|
95
|
+
description?: React.ReactNode;
|
|
96
|
+
/** Input props passed to the field component */
|
|
97
|
+
inputProps?: FieldInputProps;
|
|
98
|
+
/** Display label */
|
|
99
|
+
label?: string;
|
|
100
|
+
/** Field type override - built-in type or custom component */
|
|
101
|
+
fieldType?: keyof typeof INPUT_COMPONENTS | React.FC<AutoFormInputComponentProps>;
|
|
102
|
+
/** Wrapper component for custom field layout */
|
|
103
|
+
renderParent?: (props: {
|
|
104
|
+
children: React.ReactNode;
|
|
105
|
+
}) => React.ReactElement | null;
|
|
106
|
+
/** Display order for field ordering */
|
|
107
|
+
order?: number;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* A FormInput component can handle a specific Zod type (e.g. "ZodBoolean")
|
|
111
|
+
*/
|
|
112
|
+
type AutoFormInputComponentProps = {
|
|
113
|
+
zodInputProps: React.InputHTMLAttributes<HTMLInputElement>;
|
|
114
|
+
field: ControllerRenderProps<FieldValues, any>;
|
|
115
|
+
fieldConfigItem: FieldConfigItem;
|
|
116
|
+
label: string;
|
|
117
|
+
isRequired: boolean;
|
|
118
|
+
fieldProps: any;
|
|
119
|
+
zodItem: zod.ZodType;
|
|
120
|
+
className?: string;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export type { AutoFormInputComponentProps as A };
|