@factorialco/f0-react 1.414.1 → 1.415.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/f0.d.ts CHANGED
@@ -140,6 +140,7 @@ import { WithDataTestIdReturnType as WithDataTestIdReturnType_7 } from './f0';
140
140
  import { z } from 'zod';
141
141
  import { ZodEffects } from 'zod';
142
142
  import { ZodRawShape } from 'zod';
143
+ import { ZodType } from 'zod';
143
144
  import { ZodTypeAny } from 'zod';
144
145
 
145
146
  export declare function A({ children, ...props }: React.AnchorHTMLAttributes<HTMLAnchorElement>): JSX_2.Element;
@@ -694,6 +695,18 @@ blurArea?: "l" | "r" | "lr";
694
695
 
695
696
  declare type AsAllowedList = (typeof allTags)[number];
696
697
 
698
+ /**
699
+ * Accepts either a synchronous value or an async function that resolves it.
700
+ * The async function receives an `AbortSignal` for cancellation support.
701
+ */
702
+ export declare type AsyncOrSync<T> = T | ((signal: AbortSignal) => Promise<T>);
703
+
704
+ /**
705
+ * Async function that receives typed params (from AI presentForm).
706
+ * Use this variant when `defaultValuesParamsSchema` is provided.
707
+ */
708
+ declare type AsyncWithParams<T, TParams> = (params: TParams) => Promise<T>;
709
+
697
710
  declare const Avatar: React_2.ForwardRefExoticComponent<Omit<AvatarPrimitive.AvatarProps & React_2.RefAttributes<HTMLSpanElement>, "ref"> & {
698
711
  size?: (typeof internalAvatarSizes)[number];
699
712
  type?: (typeof internalAvatarTypes)[number];
@@ -2070,6 +2083,8 @@ export declare interface CustomFieldRenderProps<TValue = unknown, TConfig = unde
2070
2083
  required?: boolean;
2071
2084
  /** Custom configuration passed via fieldConfig */
2072
2085
  config: TConfig;
2086
+ /** Name identifying this custom field type (used with renderCustomField) */
2087
+ customFieldName?: string;
2073
2088
  }
2074
2089
 
2075
2090
  /**
@@ -2096,6 +2111,8 @@ declare interface CustomFieldRenderPropsBase {
2096
2111
  disabled?: boolean;
2097
2112
  /** Whether the field is required (derived from Zod schema) */
2098
2113
  required?: boolean;
2114
+ /** Name identifying this custom field type (used with renderCustomField) */
2115
+ customFieldName?: string;
2099
2116
  }
2100
2117
 
2101
2118
  export declare const Dashboard: WithDataTestIdReturnType_3<ComponentType<DashboardProps_2> & PageLayoutGroupComponent_2>;
@@ -3347,6 +3364,38 @@ export declare const defaultTranslations: {
3347
3364
  };
3348
3365
  };
3349
3366
 
3367
+ /**
3368
+ * Helper to define an available form with proper params typing.
3369
+ * TypeScript infers `TParams` from `defaultValuesParamsSchema`, so the
3370
+ * `defaultValues` callback receives fully typed params.
3371
+ *
3372
+ * @example
3373
+ * ```tsx
3374
+ * const employeeForm = defineAvailableForm({
3375
+ * name: "edit-employee",
3376
+ * schema: employeeSchema,
3377
+ * defaultValuesParamsSchema: z.object({ employeeId: z.string() }),
3378
+ * defaultValues: (params) => ({
3379
+ * // params.employeeId is typed as string
3380
+ * name: `Employee ${params.employeeId}`,
3381
+ * }),
3382
+ * })
3383
+ * ```
3384
+ */
3385
+ export declare function defineAvailableForm<TParams extends Record<string, unknown> = Record<string, unknown>>(definition: F0AiAvailableFormDefinition<TParams>): F0AiAvailableFormDefinition<TParams>;
3386
+
3387
+ /**
3388
+ * Introspect an F0Form schema and return a serializable array of field descriptions.
3389
+ * Pure function — usable outside React components.
3390
+ *
3391
+ * @example
3392
+ * ```ts
3393
+ * const fields = describeFormSchema(mySchema)
3394
+ * // [{ name: "email", type: "text", label: "Email", required: true, ... }, ...]
3395
+ * ```
3396
+ */
3397
+ export declare function describeFormSchema(schema: F0FormSchema): FormFieldDescription[];
3398
+
3350
3399
  export declare type DialogPosition = (typeof dialogPositions)[number];
3351
3400
 
3352
3401
  declare const dialogPositions: readonly ["center", "left", "right", "fullscreen"];
@@ -3649,6 +3698,41 @@ export declare interface F0ActionItemProps {
3649
3698
  inGroup?: boolean;
3650
3699
  }
3651
3700
 
3701
+ /**
3702
+ * A form definition that the AI can interact with even though the form is not rendered.
3703
+ *
3704
+ * Use the generic parameter to type the params accepted by a functional `defaultValues`.
3705
+ * Prefer using {@link defineAvailableForm} for automatic inference from `defaultValuesParamsSchema`.
3706
+ */
3707
+ export declare interface F0AiAvailableFormDefinition<TParams extends Record<string, unknown> = Record<string, unknown>> {
3708
+ /** Unique name to identify the form */
3709
+ name: string;
3710
+ /** Zod schema that defines the form's fields and validation */
3711
+ schema: F0FormSchema;
3712
+ /**
3713
+ * Default values for the form fields.
3714
+ * Can be a static object or a function that receives params (supplied by the AI via presentForm)
3715
+ * and returns the defaults.
3716
+ */
3717
+ defaultValues?: Record<string, unknown> | ((params: TParams) => Record<string, unknown>);
3718
+ /**
3719
+ * Zod schema that describes the params accepted by a functional `defaultValues`.
3720
+ * When provided, the AI will see this schema and can supply params when calling presentForm.
3721
+ * Params are validated against this schema before being passed to `defaultValues`.
3722
+ */
3723
+ defaultValuesParamsSchema?: ZodType<TParams>;
3724
+ /** Section configs (title, description) keyed by section ID */
3725
+ sections?: Record<string, F0SectionConfig>;
3726
+ /** Optional submit handler. Called when AI triggers formSubmit on this form. */
3727
+ onSubmit?: (values: Record<string, unknown>) => void | Promise<void>;
3728
+ /** Title shown in the dialog header or wizard header */
3729
+ title?: string;
3730
+ /** Description shown under the title in dialog mode */
3731
+ description?: string;
3732
+ /** Wizard steps (required for wizard mode to work with multiple steps) */
3733
+ steps?: F0WizardFormStep[];
3734
+ }
3735
+
3652
3736
  /**
3653
3737
  * @experimental This is an experimental component use it at your own risk
3654
3738
  */
@@ -3737,6 +3821,88 @@ export declare interface F0AiCollapsibleMessageProps {
3737
3821
  children: ReactNode;
3738
3822
  }
3739
3823
 
3824
+ /**
3825
+ * Entry in the AI form registry
3826
+ */
3827
+ export declare interface F0AiFormEntry {
3828
+ ref: React.MutableRefObject<F0FormRef | null>;
3829
+ schema: F0FormSchema;
3830
+ /** Whether this entry was registered from an availableFormDefinition (not a rendered form) */
3831
+ virtual?: boolean;
3832
+ /** Section configs (title, description) keyed by section ID */
3833
+ sections?: Record<string, F0SectionConfig>;
3834
+ /** Zod schema for params accepted by presentForm (virtual entries only) */
3835
+ defaultValuesParamsSchema?: ZodType;
3836
+ /** Raw defaultValues function that accepts params (from rendered forms with defaultValuesParamsSchema) */
3837
+ defaultValuesFn?: (params: Record<string, unknown>) => Promise<Record<string, unknown>>;
3838
+ /** Field names explicitly set via setValue/setValues on a virtual ref */
3839
+ dirtyFields?: Set<string>;
3840
+ }
3841
+
3842
+ /**
3843
+ * Context value for the AI form registry
3844
+ */
3845
+ declare interface F0AiFormRegistryContextValue {
3846
+ register: (name: string, ref: React.MutableRefObject<F0FormRef | null>, schema: F0FormSchema, sections?: Record<string, F0SectionConfig>, defaultValuesParamsSchema?: ZodType, defaultValuesFn?: (params: Record<string, unknown>) => Promise<Record<string, unknown>>) => void;
3847
+ unregister: (name: string) => void;
3848
+ get: (name: string) => F0AiFormEntry | undefined;
3849
+ getFormNames: () => string[];
3850
+ /** Rebuild the form descriptions snapshot (call after mutating form state) */
3851
+ rebuildDescriptions: () => void;
3852
+ /** Structured descriptions of all active forms, updated on register/unregister */
3853
+ formDescriptions: {
3854
+ formName: string;
3855
+ formSchema: Record<string, unknown>;
3856
+ fieldDescriptions: Record<string, {
3857
+ label: string;
3858
+ section?: string;
3859
+ placeholder?: string;
3860
+ helpText?: string;
3861
+ description?: string;
3862
+ }>;
3863
+ sectionDescriptions: Record<string, {
3864
+ title: string;
3865
+ description?: string;
3866
+ }>;
3867
+ formValues: Record<string, unknown>;
3868
+ formErrors: Record<string, unknown>;
3869
+ isDirty: boolean;
3870
+ /** JSON Schema of defaultValuesParams accepted by presentForm (only for forms with defaultValuesParamsSchema) */
3871
+ defaultValuesParamsSchema?: Record<string, unknown>;
3872
+ }[];
3873
+ /** Currently AI-presented form, or null */
3874
+ presentedForm: F0AiPresentedForm | null;
3875
+ /** Called by the AI tool to present a form */
3876
+ presentForm: (formName: string, mode: "dialog" | "wizard", defaultValuesParams?: Record<string, unknown>) => {
3877
+ success: boolean;
3878
+ error?: string;
3879
+ };
3880
+ /** Called when the presented form is closed (submit/cancel) */
3881
+ dismissForm: () => void;
3882
+ }
3883
+
3884
+ /**
3885
+ * Provider that maintains a registry of active F0Forms,
3886
+ * enabling AI tools to look up forms by name.
3887
+ *
3888
+ * Place this inside both the CopilotKit provider and above the F0Form components.
3889
+ *
3890
+ * @example
3891
+ * ```tsx
3892
+ * <F0AiChatProvider>
3893
+ * <F0AiFormRegistryProvider>
3894
+ * <F0Form name="my-form" ... />
3895
+ * <F0AiChat />
3896
+ * </F0AiFormRegistryProvider>
3897
+ * </F0AiChatProvider>
3898
+ * ```
3899
+ */
3900
+ export declare function F0AiFormRegistryProvider({ children, availableFormDefinitions, }: {
3901
+ children: React.ReactNode;
3902
+ /** Form definitions the AI can interact with even if the form is not rendered on the page */
3903
+ availableFormDefinitions?: F0AiAvailableFormDefinition[];
3904
+ }): JSX_2.Element;
3905
+
3740
3906
  /**
3741
3907
  * @experimental This is an experimental component use it at your own risk
3742
3908
  */
@@ -3771,6 +3937,20 @@ export declare class F0AiMask {
3771
3937
  private render;
3772
3938
  }
3773
3939
 
3940
+ /**
3941
+ * Tracks an AI-presented form (opened via the presentForm tool)
3942
+ */
3943
+ export declare interface F0AiPresentedForm {
3944
+ /** Name of the form (matches an availableFormDefinition) */
3945
+ name: string;
3946
+ /** Render mode chosen by the LLM */
3947
+ mode: "dialog" | "wizard";
3948
+ /** Resolved definition from availableFormDefinitions */
3949
+ definition: F0AiAvailableFormDefinition;
3950
+ /** Snapshot of the virtual form's values at the time presentForm was called */
3951
+ initialValues: Record<string, unknown>;
3952
+ }
3953
+
3774
3954
  export declare const F0Alert: WithDataTestIdReturnType_3<({ title, description, action, link, icon, variant, }: F0AlertProps) => JSX_2.Element>;
3775
3955
 
3776
3956
  export declare interface F0AlertProps {
@@ -4110,6 +4290,12 @@ export declare interface F0BaseConfig {
4110
4290
  * renderIf: ({ values }) => values.status === 'active'
4111
4291
  */
4112
4292
  renderIf?: F0BaseFieldRenderIfProp;
4293
+ /**
4294
+ * Name identifying a reusable custom field type.
4295
+ * When set, the form-level `renderCustomField` callback is invoked to provide
4296
+ * field-specific configuration (e.g. data source, options) or a custom component.
4297
+ */
4298
+ customFieldName?: string;
4113
4299
  }
4114
4300
 
4115
4301
  /**
@@ -4145,6 +4331,11 @@ export declare interface F0BaseField {
4145
4331
  * @default false
4146
4332
  */
4147
4333
  resetOnDisable?: boolean;
4334
+ /**
4335
+ * Name identifying a reusable custom field type.
4336
+ * Used with the form-level `renderCustomField` callback.
4337
+ */
4338
+ customFieldName?: string;
4148
4339
  }
4149
4340
 
4150
4341
  /**
@@ -4448,10 +4639,15 @@ export declare type F0CustomConfig<TValue = unknown, TConfig = undefined> = TCon
4448
4639
  *
4449
4640
  * @typeParam TValue - Type of the field value
4450
4641
  */
4451
- declare interface F0CustomConfigBase<TValue = unknown> {
4642
+ declare type F0CustomConfigBase<TValue = unknown> = {
4452
4643
  /** Render function for the custom component */
4453
4644
  render: (props: CustomFieldRenderProps<TValue, undefined>) => ReactNode;
4454
- }
4645
+ } | {
4646
+ /** Name identifying this custom field type (resolved by renderCustomField on the form) */
4647
+ customFieldName: string;
4648
+ /** Optional render function (overridden by form-level renderCustomField when customFieldName is set) */
4649
+ render?: (props: CustomFieldRenderProps<TValue, undefined>) => ReactNode;
4650
+ };
4455
4651
 
4456
4652
  /**
4457
4653
  * Custom config with fieldConfig (render receives typed config)
@@ -4459,12 +4655,19 @@ declare interface F0CustomConfigBase<TValue = unknown> {
4459
4655
  * @typeParam TValue - Type of the field value
4460
4656
  * @typeParam TConfig - Type of the fieldConfig object
4461
4657
  */
4462
- declare interface F0CustomConfigWithFieldConfig<TValue = unknown, TConfig = unknown> {
4658
+ declare type F0CustomConfigWithFieldConfig<TValue = unknown, TConfig = unknown> = {
4463
4659
  /** Custom configuration to pass to the render function */
4464
4660
  fieldConfig: TConfig;
4465
4661
  /** Render function for the custom component */
4466
4662
  render: (props: CustomFieldRenderProps<TValue, TConfig>) => ReactNode;
4467
- }
4663
+ } | {
4664
+ /** Custom configuration to pass to the render function */
4665
+ fieldConfig: TConfig;
4666
+ /** Name identifying this custom field type (resolved by renderCustomField on the form) */
4667
+ customFieldName: string;
4668
+ /** Optional render function (overridden by form-level renderCustomField when customFieldName is set) */
4669
+ render?: (props: CustomFieldRenderProps<TValue, TConfig>) => ReactNode;
4670
+ };
4468
4671
 
4469
4672
  /**
4470
4673
  * Custom field with all properties for rendering (runtime type)
@@ -4472,11 +4675,13 @@ declare interface F0CustomConfigWithFieldConfig<TValue = unknown, TConfig = unkn
4472
4675
  export declare type F0CustomField = F0BaseField & {
4473
4676
  type: "custom";
4474
4677
  /** Render function for the custom component */
4475
- render: (props: CustomFieldRenderPropsBase & {
4678
+ render?: (props: CustomFieldRenderPropsBase & {
4476
4679
  config: unknown;
4477
4680
  }) => ReactNode;
4478
4681
  /** Custom configuration (if provided) */
4479
4682
  fieldConfig?: unknown;
4683
+ /** Name identifying this custom field type (resolved by renderCustomField on the form) */
4684
+ customFieldName?: string;
4480
4685
  /** Conditional rendering based on another field's value */
4481
4686
  renderIf?: CustomFieldRenderIf;
4482
4687
  };
@@ -5166,6 +5371,14 @@ export declare interface F0FormDefinitionPerSection<T extends F0PerSectionSchema
5166
5371
  onSubmit: (arg: F0WizardFormPerSectionSubmitArg<T>) => Promise<F0FormSubmitResult> | F0FormSubmitResult;
5167
5372
  submitConfig?: F0PerSectionSubmitConfig;
5168
5373
  errorTriggerMode?: F0FormErrorTriggerMode;
5374
+ /** Whether async defaultValues are still being resolved */
5375
+ isLoading?: boolean;
5376
+ /** Zod schema describing params the AI can supply when calling presentForm */
5377
+ defaultValuesParamsSchema?: ZodType;
5378
+ /** Raw defaultValues function for AI registry use when params are involved */
5379
+ defaultValuesFn?: (params: Record<string, unknown>) => Promise<{
5380
+ [K in keyof T]?: Partial<z.infer<T[K]>>;
5381
+ }>;
5169
5382
  }
5170
5383
 
5171
5384
  export declare interface F0FormDefinitionSingleSchema<TSchema extends F0FormSchema_2> {
@@ -5177,6 +5390,12 @@ export declare interface F0FormDefinitionSingleSchema<TSchema extends F0FormSche
5177
5390
  onSubmit: (arg: F0WizardFormSingleSubmitArg<TSchema>) => Promise<F0FormSubmitResult> | F0FormSubmitResult;
5178
5391
  submitConfig?: F0FormSubmitConfig;
5179
5392
  errorTriggerMode?: F0FormErrorTriggerMode;
5393
+ /** Whether async defaultValues are still being resolved */
5394
+ isLoading?: boolean;
5395
+ /** Zod schema describing params the AI can supply when calling presentForm */
5396
+ defaultValuesParamsSchema?: ZodType;
5397
+ /** Raw defaultValues function for AI registry use when params are involved */
5398
+ defaultValuesFn?: (params: Record<string, unknown>) => Promise<Partial<z.infer<TSchema>>>;
5180
5399
  }
5181
5400
 
5182
5401
  /**
@@ -5349,6 +5568,17 @@ export declare interface F0FormPropsWithPerSectionDefinition<T extends F0PerSect
5349
5568
  styling?: F0FormStylingConfig;
5350
5569
  formRef?: React.MutableRefObject<F0FormRef | null>;
5351
5570
  initialFiles?: InitialFile[];
5571
+ /**
5572
+ * Callback that renders custom fields identified by `customFieldName`.
5573
+ * When a field has `customFieldName`, this function is called instead of the inline `render`.
5574
+ */
5575
+ renderCustomField?: RenderCustomFieldFunction;
5576
+ /**
5577
+ * Whether async defaultValues are still being resolved.
5578
+ * When true, the form renders with loading indicators inside each field
5579
+ * instead of replacing the entire form with skeleton placeholders.
5580
+ */
5581
+ isLoading?: boolean;
5352
5582
  }
5353
5583
 
5354
5584
  /**
@@ -5392,6 +5622,17 @@ export declare interface F0FormPropsWithPerSectionSchema<T extends F0PerSectionS
5392
5622
  * `defaultValues` against `InitialFile.value`.
5393
5623
  */
5394
5624
  initialFiles?: InitialFile[];
5625
+ /**
5626
+ * Callback that renders custom fields identified by `customFieldName`.
5627
+ * When a field has `customFieldName`, this function is called instead of the inline `render`.
5628
+ */
5629
+ renderCustomField?: RenderCustomFieldFunction;
5630
+ /**
5631
+ * Whether async defaultValues are still being resolved.
5632
+ * When true, the form renders with loading indicators inside each field
5633
+ * instead of replacing the entire form with skeleton placeholders.
5634
+ */
5635
+ isLoading?: boolean;
5395
5636
  }
5396
5637
 
5397
5638
  /**
@@ -5436,6 +5677,27 @@ export declare interface F0FormPropsWithSingleSchema<TSchema extends F0FormSchem
5436
5677
  * `defaultValues` against `InitialFile.value`.
5437
5678
  */
5438
5679
  initialFiles?: InitialFile[];
5680
+ /**
5681
+ * Callback that renders custom fields identified by `customFieldName`.
5682
+ * When a field has `customFieldName`, this function is called instead of the inline `render`.
5683
+ */
5684
+ renderCustomField?: RenderCustomFieldFunction;
5685
+ /**
5686
+ * Whether async defaultValues are still being resolved.
5687
+ * When true, the form renders with loading indicators inside each field
5688
+ * instead of replacing the entire form with skeleton placeholders.
5689
+ */
5690
+ isLoading?: boolean;
5691
+ /**
5692
+ * Zod schema describing params the AI can supply when calling presentForm.
5693
+ * Passed through to the AI form registry.
5694
+ */
5695
+ defaultValuesParamsSchema?: ZodType;
5696
+ /**
5697
+ * Raw defaultValues function for the AI registry to call with params.
5698
+ * Set automatically when using `useF0FormDefinition` with a functional `defaultValues`.
5699
+ */
5700
+ defaultValuesFn?: (params: Record<string, unknown>) => Promise<Record<string, unknown>>;
5439
5701
  }
5440
5702
 
5441
5703
  /**
@@ -5449,6 +5711,11 @@ export declare interface F0FormPropsWithSingleSchemaDefinition<TSchema extends F
5449
5711
  styling?: F0FormStylingConfig;
5450
5712
  formRef?: React.MutableRefObject<F0FormRef | null>;
5451
5713
  initialFiles?: InitialFile[];
5714
+ /**
5715
+ * Callback that renders custom fields identified by `customFieldName`.
5716
+ * When a field has `customFieldName`, this function is called instead of the inline `render`.
5717
+ */
5718
+ renderCustomField?: RenderCustomFieldFunction;
5452
5719
  }
5453
5720
 
5454
5721
  /**
@@ -5473,6 +5740,27 @@ export declare interface F0FormRef {
5473
5740
  * Get the current form values (including unsaved changes)
5474
5741
  */
5475
5742
  getValues: () => Record<string, unknown>;
5743
+ /**
5744
+ * Set a single field value programmatically
5745
+ */
5746
+ setValue: (fieldName: string, value: unknown, options?: F0FormSetValueOptions) => void;
5747
+ /**
5748
+ * Set multiple field values at once
5749
+ */
5750
+ setValues: (values: Record<string, unknown>, options?: F0FormSetValueOptions) => void;
5751
+ /**
5752
+ * Manually trigger validation for a specific field or all fields
5753
+ * @returns true if validation passes
5754
+ */
5755
+ trigger: (fieldName?: string) => Promise<boolean>;
5756
+ /**
5757
+ * Get current validation errors as a map of field name to error message
5758
+ */
5759
+ getErrors: () => Record<string, string>;
5760
+ /**
5761
+ * Get the list of field names in the form
5762
+ */
5763
+ getFieldNames: () => string[];
5476
5764
  /* Excluded from this release type: _setStateCallback */
5477
5765
  }
5478
5766
 
@@ -5483,6 +5771,14 @@ export declare type F0FormSchema<T extends ZodRawShape = ZodRawShape> = z.ZodObj
5483
5771
 
5484
5772
  declare type F0FormSchema_2<T extends ZodRawShape = ZodRawShape> = z.ZodObject<T> | ZodEffects<z.ZodObject<T>>;
5485
5773
 
5774
+ /**
5775
+ * Options for setValue
5776
+ */
5777
+ export declare interface F0FormSetValueOptions {
5778
+ shouldValidate?: boolean;
5779
+ shouldDirty?: boolean;
5780
+ }
5781
+
5486
5782
  /**
5487
5783
  * Callback to update form state in the hook
5488
5784
  */
@@ -5904,6 +6200,7 @@ declare type F0SelectBaseProps<T extends string, R = unknown> = {
5904
6200
  * Supports either:
5905
6201
  * - Static `options` array
5906
6202
  * - Dynamic `source` with `mapOptions` function
6203
+ * - Runtime-provided via `customFieldName` (no options/source needed at definition time)
5907
6204
  *
5908
6205
  * @typeParam T - The value type (string or number)
5909
6206
  * @typeParam R - Record type from the data source
@@ -5911,7 +6208,7 @@ declare type F0SelectBaseProps<T extends string, R = unknown> = {
5911
6208
  * Note: `clearable` is derived from the Zod schema:
5912
6209
  * - `z.string().optional()` or `z.string().nullable()` → clearable
5913
6210
  */
5914
- export declare type F0SelectConfig<T extends SelectValueType = string, R extends RecordType = RecordType> = F0SelectConfigWithOptions<T> | F0SelectConfigWithSource<T, R>;
6211
+ export declare type F0SelectConfig<T extends SelectValueType = string, R extends RecordType = RecordType> = F0SelectConfigWithOptions<T> | F0SelectConfigWithSource<T, R> | F0SelectConfigWithCustomFieldName;
5915
6212
 
5916
6213
  /**
5917
6214
  * Base config options shared by all select field variants
@@ -5925,6 +6222,18 @@ declare interface F0SelectConfigBase {
5925
6222
  searchBoxPlaceholder?: string;
5926
6223
  }
5927
6224
 
6225
+ /**
6226
+ * Config for select fields whose options/source are provided at runtime
6227
+ * via `customFieldName` and `renderCustomField`.
6228
+ */
6229
+ declare interface F0SelectConfigWithCustomFieldName extends F0SelectConfigBase {
6230
+ options?: never;
6231
+ source?: never;
6232
+ mapOptions?: never;
6233
+ /** Required: identifies the custom field provider */
6234
+ customFieldName: string;
6235
+ }
6236
+
5928
6237
  /**
5929
6238
  * Config for select fields with static options
5930
6239
  * @typeParam T - The value type (string or number)
@@ -6335,6 +6644,11 @@ declare interface F0WizardFormBaseProps {
6335
6644
  * @default false
6336
6645
  */
6337
6646
  autoSkipCompletedSteps?: boolean;
6647
+ /**
6648
+ * Callback that renders custom fields identified by `customFieldName`.
6649
+ * When a field has `customFieldName`, this function is called instead of the inline `render`.
6650
+ */
6651
+ renderCustomField?: RenderCustomFieldFunction;
6338
6652
  }
6339
6653
 
6340
6654
  export declare interface F0WizardFormPerSectionProps<T extends F0PerSectionSchema_2> extends F0WizardFormBaseProps {
@@ -6665,6 +6979,26 @@ export declare type FormatPreset = {
6665
6979
 
6666
6980
  /* Excluded from this release type: FormDefinitionItem */
6667
6981
 
6982
+ /**
6983
+ * Serializable description of a single form field,
6984
+ * intended for AI tools to understand form structure.
6985
+ */
6986
+ export declare interface FormFieldDescription {
6987
+ name: string;
6988
+ type: F0FieldType;
6989
+ label: string;
6990
+ required: boolean;
6991
+ placeholder?: string;
6992
+ helpText?: string;
6993
+ options?: {
6994
+ label: string;
6995
+ value: string | number;
6996
+ }[];
6997
+ optionsSource?: "dynamic";
6998
+ section?: string;
6999
+ customFieldName?: string;
7000
+ }
7001
+
6668
7002
  /**
6669
7003
  * Standalone form field props — decoupled from react-hook-form.
6670
7004
  * This is the minimal contract that field renderers need to operate.
@@ -8609,6 +8943,59 @@ declare type RelaxedNumericWithFormatter = Omit<NumericWithFormatter, "numericVa
8609
8943
  numericValue: Numeric;
8610
8944
  };
8611
8945
 
8946
+ /**
8947
+ * Callback provided to F0Form / F0WizardForm that renders custom fields
8948
+ * identified by `customFieldName` instead of an inline `render` function.
8949
+ *
8950
+ * For `fieldType: "custom"` — return a ReactNode (component) as before.
8951
+ * For `fieldType: "select"` — return either a ReactNode or a `RenderCustomFieldSelectConfig`
8952
+ * with `{ _type: "select-config", source, mapOptions }` to configure the select dynamically.
8953
+ */
8954
+ export declare type RenderCustomFieldFunction = (props: RenderCustomFieldProps) => RenderCustomFieldResult;
8955
+
8956
+ /**
8957
+ * Props passed to the form-level `renderCustomField` callback.
8958
+ * Extends the base custom field render props with a required `customFieldName`.
8959
+ */
8960
+ export declare interface RenderCustomFieldProps extends CustomFieldRenderPropsBase {
8961
+ /** Name identifying this custom field type */
8962
+ customFieldName: string;
8963
+ /** Custom configuration (if provided via fieldConfig) */
8964
+ config: unknown;
8965
+ /** The field type this customFieldName is attached to (e.g. "select", "custom") */
8966
+ fieldType: string;
8967
+ }
8968
+
8969
+ /**
8970
+ * Return type for the `renderCustomField` callback.
8971
+ * Can return either:
8972
+ * - A React node (rendered directly as a custom component)
8973
+ * - A select config object (merged into the select field props)
8974
+ */
8975
+ declare type RenderCustomFieldResult = React.ReactNode | RenderCustomFieldSelectConfig;
8976
+
8977
+ /**
8978
+ * Select field configuration that `renderCustomField` can return
8979
+ * for select fields with `customFieldName` (e.g. reusable entity selectors).
8980
+ *
8981
+ * Mirrors the select field config shape — either static `options` or dynamic `source`+`mapOptions`.
8982
+ */
8983
+ export declare interface RenderCustomFieldSelectConfig {
8984
+ _type: "select-config";
8985
+ /** Data source for fetching options dynamically */
8986
+ source?: unknown;
8987
+ /** Function to map data source items to select options */
8988
+ mapOptions?: (item: never) => unknown;
8989
+ /** Static options array */
8990
+ options?: unknown[];
8991
+ /** Whether multiple selection is allowed */
8992
+ multiple?: boolean;
8993
+ /** Whether to show the search box */
8994
+ showSearchBox?: boolean;
8995
+ /** Placeholder for the search box */
8996
+ searchBoxPlaceholder?: string;
8997
+ }
8998
+
8612
8999
  declare type RendererDefinition = ValueDisplayRendererDefinition;
8613
9000
 
8614
9001
  /**
@@ -9924,6 +10311,23 @@ export declare const useEmojiConfetti: () => {
9924
10311
  fireEmojiConfetti: (emoji: string, elementRef: RefObject<HTMLElement>) => void;
9925
10312
  };
9926
10313
 
10314
+ /**
10315
+ * Hook that registers all AI form interaction tools and pushes
10316
+ * form context to the co-agent shared state via `useCoAgent`.
10317
+ *
10318
+ * Must be called inside a component tree that has both:
10319
+ * - A `F0AiFormRegistryProvider` ancestor (for form lookup)
10320
+ * - A CopilotKit context (for tool registration + co-agent state)
10321
+ * - An `AiChatStateProvider` ancestor (for the agent name)
10322
+ */
10323
+ export declare const useF0AiFormActions: () => void;
10324
+
10325
+ /**
10326
+ * Hook to access the AI form registry.
10327
+ * Returns null if not inside a F0AiFormRegistryProvider.
10328
+ */
10329
+ export declare function useF0AiFormRegistry(): F0AiFormRegistryContextValue | null;
10330
+
9927
10331
  export declare const useF0Dialog: () => F0DialogContextType;
9928
10332
 
9929
10333
  /**
@@ -9967,32 +10371,68 @@ export declare const useF0Dialog: () => F0DialogContextType;
9967
10371
  */
9968
10372
  export declare function useF0Form(): UseF0FormReturn;
9969
10373
 
9970
- export declare function useF0FormDefinition<TSchema extends F0FormSchema_2>(input: UseF0FormDefinitionSingleSchemaInput<TSchema>): F0FormDefinitionSingleSchema<TSchema>;
10374
+ /** Single schema, no params */
10375
+ export declare function useF0FormDefinition<TSchema extends F0FormSchema_2>(input: UseF0FormDefinitionSingleSchemaInputWithoutParams<TSchema>): F0FormDefinitionSingleSchema<TSchema>;
9971
10376
 
9972
- export declare function useF0FormDefinition<T extends F0PerSectionSchema_2>(input: UseF0FormDefinitionPerSectionInput<T>): F0FormDefinitionPerSection<T>;
10377
+ /** Single schema, with params */
10378
+ export declare function useF0FormDefinition<TSchema extends F0FormSchema_2, TParams extends Record<string, unknown>>(input: UseF0FormDefinitionSingleSchemaInputWithParams<TSchema, TParams>): F0FormDefinitionSingleSchema<TSchema>;
9973
10379
 
9974
- declare interface UseF0FormDefinitionPerSectionInput<T extends F0PerSectionSchema_2> {
10380
+ /** Per-section, no params */
10381
+ export declare function useF0FormDefinition<T extends F0PerSectionSchema_2>(input: UseF0FormDefinitionPerSectionInputWithoutParams<T>): F0FormDefinitionPerSection<T>;
10382
+
10383
+ /** Per-section, with params */
10384
+ export declare function useF0FormDefinition<T extends F0PerSectionSchema_2, TParams extends Record<string, unknown>>(input: UseF0FormDefinitionPerSectionInputWithParams<T, TParams>): F0FormDefinitionPerSection<T>;
10385
+
10386
+ /** Base fields shared by all per-section input variants */
10387
+ declare interface UseF0FormDefinitionPerSectionInputBase<T extends F0PerSectionSchema_2> {
9975
10388
  name: string;
9976
10389
  schema: T;
9977
10390
  sections?: Record<string, F0PerSectionSectionConfig>;
9978
- defaultValues?: {
9979
- [K in keyof T]?: Partial<z.infer<T[K]>>;
9980
- };
9981
10391
  onSubmit: (arg: F0WizardFormPerSectionSubmitArg<T>) => Promise<F0FormSubmitResult> | F0FormSubmitResult;
9982
10392
  submitConfig?: F0PerSectionSubmitConfig;
9983
10393
  errorTriggerMode?: F0FormErrorTriggerMode;
9984
10394
  }
9985
10395
 
9986
- declare interface UseF0FormDefinitionSingleSchemaInput<TSchema extends F0FormSchema_2> {
10396
+ /** Per-section input WITHOUT `defaultValuesParamsSchema` */
10397
+ declare interface UseF0FormDefinitionPerSectionInputWithoutParams<T extends F0PerSectionSchema_2> extends UseF0FormDefinitionPerSectionInputBase<T> {
10398
+ defaultValues?: AsyncOrSync<{
10399
+ [K in keyof T]?: Partial<z.infer<T[K]>>;
10400
+ }>;
10401
+ defaultValuesParamsSchema?: undefined;
10402
+ }
10403
+
10404
+ /** Per-section input WITH `defaultValuesParamsSchema` */
10405
+ declare interface UseF0FormDefinitionPerSectionInputWithParams<T extends F0PerSectionSchema_2, TParams extends Record<string, unknown>> extends UseF0FormDefinitionPerSectionInputBase<T> {
10406
+ defaultValues?: {
10407
+ [K in keyof T]?: Partial<z.infer<T[K]>>;
10408
+ } | AsyncWithParams<{
10409
+ [K in keyof T]?: Partial<z.infer<T[K]>>;
10410
+ }, TParams>;
10411
+ defaultValuesParamsSchema: ZodType<TParams>;
10412
+ }
10413
+
10414
+ /** Base fields shared by all single-schema input variants */
10415
+ declare interface UseF0FormDefinitionSingleSchemaInputBase<TSchema extends F0FormSchema_2> {
9987
10416
  name: string;
9988
10417
  schema: TSchema;
9989
10418
  sections?: Record<string, F0SectionConfig>;
9990
- defaultValues?: Partial<z.infer<TSchema>>;
9991
10419
  onSubmit: (arg: F0WizardFormSingleSubmitArg<TSchema>) => Promise<F0FormSubmitResult> | F0FormSubmitResult;
9992
10420
  submitConfig?: F0FormSubmitConfig;
9993
10421
  errorTriggerMode?: F0FormErrorTriggerMode;
9994
10422
  }
9995
10423
 
10424
+ /** Single-schema input WITHOUT `defaultValuesParamsSchema` → `defaultValues` is sync or `(signal) => Promise<T>` */
10425
+ declare interface UseF0FormDefinitionSingleSchemaInputWithoutParams<TSchema extends F0FormSchema_2> extends UseF0FormDefinitionSingleSchemaInputBase<TSchema> {
10426
+ defaultValues?: AsyncOrSync<Partial<z.infer<TSchema>>>;
10427
+ defaultValuesParamsSchema?: undefined;
10428
+ }
10429
+
10430
+ /** Single-schema input WITH `defaultValuesParamsSchema` → `defaultValues` is sync or `(params) => Promise<T>` */
10431
+ declare interface UseF0FormDefinitionSingleSchemaInputWithParams<TSchema extends F0FormSchema_2, TParams extends Record<string, unknown>> extends UseF0FormDefinitionSingleSchemaInputBase<TSchema> {
10432
+ defaultValues?: Partial<z.infer<TSchema>> | AsyncWithParams<Partial<z.infer<TSchema>>, TParams>;
10433
+ defaultValuesParamsSchema: ZodType<TParams>;
10434
+ }
10435
+
9996
10436
  /**
9997
10437
  * Return type for the useF0Form hook
9998
10438
  */
@@ -10019,6 +10459,27 @@ export declare interface UseF0FormReturn {
10019
10459
  * Get the current form values (including unsaved changes)
10020
10460
  */
10021
10461
  getValues: () => Record<string, unknown>;
10462
+ /**
10463
+ * Set a single field value programmatically
10464
+ */
10465
+ setValue: (fieldName: string, value: unknown, options?: F0FormSetValueOptions) => void;
10466
+ /**
10467
+ * Set multiple field values at once
10468
+ */
10469
+ setValues: (values: Record<string, unknown>, options?: F0FormSetValueOptions) => void;
10470
+ /**
10471
+ * Manually trigger validation for a specific field or all fields
10472
+ * @returns true if validation passes
10473
+ */
10474
+ trigger: (fieldName?: string) => Promise<boolean>;
10475
+ /**
10476
+ * Get current validation errors as a map of field name to error message
10477
+ */
10478
+ getErrors: () => Record<string, string>;
10479
+ /**
10480
+ * Get the list of field names in the form
10481
+ */
10482
+ getFieldNames: () => string[];
10022
10483
  /**
10023
10484
  * Whether the form is currently submitting
10024
10485
  */
@@ -10045,6 +10506,24 @@ export declare interface UseF0FormReturn {
10045
10506
  */
10046
10507
  export declare type UseFileUpload = () => FileUploadHookReturn;
10047
10508
 
10509
+ /**
10510
+ * AI tool that fills one or more fields in an active F0Form.
10511
+ * After setting values, it triggers validation and returns any errors.
10512
+ */
10513
+ export declare const useFormFillAction: () => void;
10514
+
10515
+ /**
10516
+ * AI tool that reads the current state of an active F0Form —
10517
+ * current values, dirty status, and validation errors.
10518
+ */
10519
+ export declare const useFormGetStateAction: () => void;
10520
+
10521
+ /**
10522
+ * AI tool that submits an active F0Form.
10523
+ * Triggers validation first — only calls onSubmit if all fields pass.
10524
+ */
10525
+ export declare const useFormSubmitAction: () => void;
10526
+
10048
10527
  export declare const useGroups: <R extends RecordType>(groups: GroupRecord<R>[], defaultOpenGroups?: boolean | GroupRecord<R>["key"][]) => {
10049
10528
  openGroups: Record<string, boolean>;
10050
10529
  setGroupOpen: (key: string, open: boolean) => void;
@@ -10385,11 +10864,6 @@ declare module "gridstack" {
10385
10864
  }
10386
10865
 
10387
10866
 
10388
- declare namespace Calendar {
10389
- var displayName: string;
10390
- }
10391
-
10392
-
10393
10867
  declare module "@tiptap/core" {
10394
10868
  interface Commands<ReturnType> {
10395
10869
  aiBlock: {
@@ -10437,3 +10911,8 @@ declare module "@tiptap/core" {
10437
10911
  };
10438
10912
  }
10439
10913
  }
10914
+
10915
+
10916
+ declare namespace Calendar {
10917
+ var displayName: string;
10918
+ }