@btst/stack 1.5.2 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.cjs +7 -1
- package/dist/api/index.d.cts +2 -2
- package/dist/api/index.d.mts +2 -2
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.mjs +7 -1
- package/dist/client/index.d.cts +1 -1
- package/dist/client/index.d.mts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- 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/better-stack/src/plugins/open-api/api/generator.cjs +300 -0
- package/dist/packages/better-stack/src/plugins/open-api/api/generator.mjs +284 -0
- package/dist/packages/better-stack/src/plugins/open-api/api/plugin.cjs +115 -0
- package/dist/packages/better-stack/src/plugins/open-api/api/plugin.mjs +113 -0
- package/dist/packages/better-stack/src/plugins/open-api/db.cjs +7 -0
- package/dist/packages/better-stack/src/plugins/open-api/db.mjs +5 -0
- package/dist/packages/better-stack/src/plugins/open-api/logo.cjs +8 -0
- package/dist/packages/better-stack/src/plugins/open-api/logo.mjs +6 -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/api/index.d.cts +2 -2
- package/dist/plugins/api/index.d.mts +2 -2
- package/dist/plugins/api/index.d.ts +2 -2
- 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/client/index.d.cts +2 -2
- package/dist/plugins/client/index.d.mts +2 -2
- package/dist/plugins/client/index.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/plugins/open-api/api/index.cjs +9 -0
- package/dist/plugins/open-api/api/index.d.cts +95 -0
- package/dist/plugins/open-api/api/index.d.mts +95 -0
- package/dist/plugins/open-api/api/index.d.ts +95 -0
- package/dist/plugins/open-api/api/index.mjs +2 -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.ByOugz9d.d.cts → stack.CSce37mX.d.cts} +15 -2
- package/dist/shared/{stack.ByOugz9d.d.mts → stack.CSce37mX.d.mts} +15 -2
- package/dist/shared/{stack.ByOugz9d.d.ts → stack.CSce37mX.d.ts} +15 -2
- 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 +67 -1
- package/src/api/index.ts +14 -2
- 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/src/plugins/open-api/api/generator.ts +433 -0
- package/src/plugins/open-api/api/index.ts +8 -0
- package/src/plugins/open-api/api/plugin.ts +243 -0
- package/src/plugins/open-api/db.ts +7 -0
- package/src/plugins/open-api/logo.ts +7 -0
- package/src/types.ts +15 -1
- package/dist/shared/{stack.DLhzx1-D.d.mts → stack.CcI4sYJP.d.cts} +1 -1
- package/dist/shared/{stack.DLhzx1-D.d.ts → stack.CcI4sYJP.d.mts} +1 -1
- package/dist/shared/{stack.DLhzx1-D.d.cts → stack.CcI4sYJP.d.ts} +1 -1
|
@@ -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 };
|
|
@@ -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 };
|
|
@@ -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 };
|
|
@@ -2,6 +2,18 @@ import { Route, createRouter } from '@btst/yar';
|
|
|
2
2
|
import { Adapter, DbPlugin, DatabaseDefinition } from '@btst/db';
|
|
3
3
|
import { Endpoint, Router } from 'better-call';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Context passed to backend plugins during route creation
|
|
7
|
+
* Provides access to all registered plugins for introspection (used by openAPI plugin)
|
|
8
|
+
*/
|
|
9
|
+
interface BetterStackContext {
|
|
10
|
+
/** All registered backend plugins */
|
|
11
|
+
plugins: Record<string, BackendPlugin<any>>;
|
|
12
|
+
/** The API base path (e.g., "/api/data") */
|
|
13
|
+
basePath: string;
|
|
14
|
+
/** The database adapter */
|
|
15
|
+
adapter: Adapter;
|
|
16
|
+
}
|
|
5
17
|
/**
|
|
6
18
|
* Backend plugin definition
|
|
7
19
|
* Defines API routes and data access for a feature
|
|
@@ -20,8 +32,9 @@ interface BackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string
|
|
|
20
32
|
*
|
|
21
33
|
* @param adapter - Better DB adapter instance with methods:
|
|
22
34
|
* create, update, updateMany, delete, deleteMany, findOne, findMany, count
|
|
35
|
+
* @param context - Optional context with access to all plugins (for introspection)
|
|
23
36
|
*/
|
|
24
|
-
routes: (adapter: Adapter) => TRoutes;
|
|
37
|
+
routes: (adapter: Adapter, context?: BetterStackContext) => TRoutes;
|
|
25
38
|
dbPlugin: DbPlugin;
|
|
26
39
|
}
|
|
27
40
|
/**
|
|
@@ -129,4 +142,4 @@ type SitemapEntry = {
|
|
|
129
142
|
};
|
|
130
143
|
type Sitemap = Array<SitemapEntry>;
|
|
131
144
|
|
|
132
|
-
export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, Sitemap as S,
|
|
145
|
+
export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, Sitemap as S, BetterStackContext as a, PluginRoutes as b, ClientLibConfig as c, ClientLib as d, PrefixedPluginRoutes as e, BackendLibConfig as f, BackendLib as g };
|
|
@@ -2,6 +2,18 @@ import { Route, createRouter } from '@btst/yar';
|
|
|
2
2
|
import { Adapter, DbPlugin, DatabaseDefinition } from '@btst/db';
|
|
3
3
|
import { Endpoint, Router } from 'better-call';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Context passed to backend plugins during route creation
|
|
7
|
+
* Provides access to all registered plugins for introspection (used by openAPI plugin)
|
|
8
|
+
*/
|
|
9
|
+
interface BetterStackContext {
|
|
10
|
+
/** All registered backend plugins */
|
|
11
|
+
plugins: Record<string, BackendPlugin<any>>;
|
|
12
|
+
/** The API base path (e.g., "/api/data") */
|
|
13
|
+
basePath: string;
|
|
14
|
+
/** The database adapter */
|
|
15
|
+
adapter: Adapter;
|
|
16
|
+
}
|
|
5
17
|
/**
|
|
6
18
|
* Backend plugin definition
|
|
7
19
|
* Defines API routes and data access for a feature
|
|
@@ -20,8 +32,9 @@ interface BackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string
|
|
|
20
32
|
*
|
|
21
33
|
* @param adapter - Better DB adapter instance with methods:
|
|
22
34
|
* create, update, updateMany, delete, deleteMany, findOne, findMany, count
|
|
35
|
+
* @param context - Optional context with access to all plugins (for introspection)
|
|
23
36
|
*/
|
|
24
|
-
routes: (adapter: Adapter) => TRoutes;
|
|
37
|
+
routes: (adapter: Adapter, context?: BetterStackContext) => TRoutes;
|
|
25
38
|
dbPlugin: DbPlugin;
|
|
26
39
|
}
|
|
27
40
|
/**
|
|
@@ -129,4 +142,4 @@ type SitemapEntry = {
|
|
|
129
142
|
};
|
|
130
143
|
type Sitemap = Array<SitemapEntry>;
|
|
131
144
|
|
|
132
|
-
export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, Sitemap as S,
|
|
145
|
+
export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, Sitemap as S, BetterStackContext as a, PluginRoutes as b, ClientLibConfig as c, ClientLib as d, PrefixedPluginRoutes as e, BackendLibConfig as f, BackendLib as g };
|
|
@@ -2,6 +2,18 @@ import { Route, createRouter } from '@btst/yar';
|
|
|
2
2
|
import { Adapter, DbPlugin, DatabaseDefinition } from '@btst/db';
|
|
3
3
|
import { Endpoint, Router } from 'better-call';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Context passed to backend plugins during route creation
|
|
7
|
+
* Provides access to all registered plugins for introspection (used by openAPI plugin)
|
|
8
|
+
*/
|
|
9
|
+
interface BetterStackContext {
|
|
10
|
+
/** All registered backend plugins */
|
|
11
|
+
plugins: Record<string, BackendPlugin<any>>;
|
|
12
|
+
/** The API base path (e.g., "/api/data") */
|
|
13
|
+
basePath: string;
|
|
14
|
+
/** The database adapter */
|
|
15
|
+
adapter: Adapter;
|
|
16
|
+
}
|
|
5
17
|
/**
|
|
6
18
|
* Backend plugin definition
|
|
7
19
|
* Defines API routes and data access for a feature
|
|
@@ -20,8 +32,9 @@ interface BackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string
|
|
|
20
32
|
*
|
|
21
33
|
* @param adapter - Better DB adapter instance with methods:
|
|
22
34
|
* create, update, updateMany, delete, deleteMany, findOne, findMany, count
|
|
35
|
+
* @param context - Optional context with access to all plugins (for introspection)
|
|
23
36
|
*/
|
|
24
|
-
routes: (adapter: Adapter) => TRoutes;
|
|
37
|
+
routes: (adapter: Adapter, context?: BetterStackContext) => TRoutes;
|
|
25
38
|
dbPlugin: DbPlugin;
|
|
26
39
|
}
|
|
27
40
|
/**
|
|
@@ -129,4 +142,4 @@ type SitemapEntry = {
|
|
|
129
142
|
};
|
|
130
143
|
type Sitemap = Array<SitemapEntry>;
|
|
131
144
|
|
|
132
|
-
export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, Sitemap as S,
|
|
145
|
+
export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, Sitemap as S, BetterStackContext as a, PluginRoutes as b, ClientLibConfig as c, ClientLib as d, PrefixedPluginRoutes as e, BackendLibConfig as f, BackendLib as g };
|