@factorialco/f0-react 1.362.2 → 1.362.3

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/ai.d.ts CHANGED
@@ -1164,9 +1164,9 @@ declare namespace Calendar {
1164
1164
 
1165
1165
  declare module "@tiptap/core" {
1166
1166
  interface Commands<ReturnType> {
1167
- aiBlock: {
1168
- insertAIBlock: (data: AIBlockData, config: AIBlockConfig) => ReturnType;
1169
- executeAIAction: (actionType: string, config: AIBlockConfig) => ReturnType;
1167
+ enhanceHighlight: {
1168
+ setEnhanceHighlight: (from: number, to: number) => ReturnType;
1169
+ clearEnhanceHighlight: () => ReturnType;
1170
1170
  };
1171
1171
  }
1172
1172
  }
@@ -1174,9 +1174,9 @@ declare module "@tiptap/core" {
1174
1174
 
1175
1175
  declare module "@tiptap/core" {
1176
1176
  interface Commands<ReturnType> {
1177
- enhanceHighlight: {
1178
- setEnhanceHighlight: (from: number, to: number) => ReturnType;
1179
- clearEnhanceHighlight: () => ReturnType;
1177
+ aiBlock: {
1178
+ insertAIBlock: (data: AIBlockData, config: AIBlockConfig) => ReturnType;
1179
+ executeAIAction: (actionType: string, config: AIBlockConfig) => ReturnType;
1180
1180
  };
1181
1181
  }
1182
1182
  }
@@ -6634,9 +6634,9 @@ declare namespace Calendar {
6634
6634
 
6635
6635
  declare module "@tiptap/core" {
6636
6636
  interface Commands<ReturnType> {
6637
- aiBlock: {
6638
- insertAIBlock: (data: AIBlockData, config: AIBlockConfig) => ReturnType;
6639
- executeAIAction: (actionType: string, config: AIBlockConfig) => ReturnType;
6637
+ enhanceHighlight: {
6638
+ setEnhanceHighlight: (from: number, to: number) => ReturnType;
6639
+ clearEnhanceHighlight: () => ReturnType;
6640
6640
  };
6641
6641
  }
6642
6642
  }
@@ -6644,9 +6644,9 @@ declare module "@tiptap/core" {
6644
6644
 
6645
6645
  declare module "@tiptap/core" {
6646
6646
  interface Commands<ReturnType> {
6647
- enhanceHighlight: {
6648
- setEnhanceHighlight: (from: number, to: number) => ReturnType;
6649
- clearEnhanceHighlight: () => ReturnType;
6647
+ aiBlock: {
6648
+ insertAIBlock: (data: AIBlockData, config: AIBlockConfig) => ReturnType;
6649
+ executeAIAction: (actionType: string, config: AIBlockConfig) => ReturnType;
6650
6650
  };
6651
6651
  }
6652
6652
  }
package/dist/f0.d.ts CHANGED
@@ -106,6 +106,7 @@ import { TrackReferenceOrPlaceholder } from '@livekit/components-react';
106
106
  import { ValueDisplayRendererContext } from '../../../ui/value-display';
107
107
  import { VariantProps } from 'cva';
108
108
  import { z } from 'zod';
109
+ import { ZodEffects } from 'zod';
109
110
  import { ZodRawShape } from 'zod';
110
111
  import { ZodTypeAny } from 'zod';
111
112
 
@@ -3415,28 +3416,78 @@ declare type F0CustomFieldConfigWithConfig<TValue = unknown, TConfig = unknown>
3415
3416
  /**
3416
3417
  * F0 config options specific to date fields
3417
3418
  *
3418
- * Note: `minDate`, `maxDate`, and `clearable` are derived from the Zod schema:
3419
+ * Note: `clearable` is derived from the Zod schema:
3420
+ * - `z.date().optional()` or `z.date().nullable()` → clearable
3421
+ *
3422
+ * Static minDate/maxDate can also be derived from the Zod schema:
3419
3423
  * - `z.date().min(date)` → minDate
3420
3424
  * - `z.date().max(date)` → maxDate
3421
- * - `z.date().optional()` or `z.date().nullable()` → clearable
3425
+ *
3426
+ * For dynamic constraints based on other fields, use function syntax:
3427
+ * @example
3428
+ * ```ts
3429
+ * endDate: f0FormField(z.date(), {
3430
+ * label: "End Date",
3431
+ * minDate: ({ values }) => values.startDate, // Dynamic: after start date
3432
+ * })
3433
+ * ```
3422
3434
  */
3423
3435
  export declare interface F0DateConfig {
3424
3436
  /** Available granularities for the date picker */
3425
3437
  granularities?: DateGranularity[];
3426
3438
  /** Preset date options to display */
3427
3439
  presets?: DatePreset[];
3440
+ /**
3441
+ * Minimum selectable date.
3442
+ * Can be a static Date or a function that receives form values for dynamic constraints.
3443
+ * Overrides z.date().min() if provided.
3444
+ * @example
3445
+ * // Static constraint
3446
+ * minDate: new Date("2024-01-01")
3447
+ *
3448
+ * // Dynamic constraint based on another field
3449
+ * minDate: ({ values }) => values.startDate
3450
+ */
3451
+ minDate?: F0DateConstraintProp;
3452
+ /**
3453
+ * Maximum selectable date.
3454
+ * Can be a static Date or a function that receives form values for dynamic constraints.
3455
+ * Overrides z.date().max() if provided.
3456
+ * @example
3457
+ * // Static constraint
3458
+ * maxDate: new Date("2025-12-31")
3459
+ *
3460
+ * // Dynamic constraint based on another field
3461
+ * maxDate: ({ values }) => values.endDate
3462
+ */
3463
+ maxDate?: F0DateConstraintProp;
3428
3464
  }
3429
3465
 
3466
+ /**
3467
+ * Function type for dynamic date constraint evaluation based on form values.
3468
+ * Used for minDate/maxDate that depend on other field values.
3469
+ *
3470
+ * @example
3471
+ * ```ts
3472
+ * // End date must be after start date
3473
+ * minDate: ({ values }) => values.startDate
3474
+ * ```
3475
+ */
3476
+ declare type F0DateConstraintFunction = (context: {
3477
+ values: Record<string, unknown>;
3478
+ }) => Date | undefined;
3479
+
3480
+ /**
3481
+ * Date constraint can be a static Date or a function that receives form values
3482
+ */
3483
+ declare type F0DateConstraintProp = Date | F0DateConstraintFunction;
3484
+
3430
3485
  /**
3431
3486
  * Date field with all properties for rendering
3432
3487
  * Includes properties derived from Zod schema
3433
3488
  */
3434
3489
  export declare type F0DateField = F0BaseField & F0DateConfig & {
3435
3490
  type: "date";
3436
- /** Minimum selectable date (derived from z.date().min()) */
3437
- minDate?: Date;
3438
- /** Maximum selectable date (derived from z.date().max()) */
3439
- maxDate?: Date;
3440
3491
  /** Whether the date can be cleared (derived from optional/nullable) */
3441
3492
  clearable?: boolean;
3442
3493
  /** Conditional rendering based on another field's value */
@@ -3509,9 +3560,7 @@ export declare type F0DateRangeFieldConfig = F0BaseConfig & F0DateRangeConfig &
3509
3560
  /**
3510
3561
  * F0 config options specific to datetime fields
3511
3562
  *
3512
- * Note: `minDate`, `maxDate`, and `clearable` are derived from the Zod schema:
3513
- * - `z.date().min(date)` → minDate
3514
- * - `z.date().max(date)` → maxDate
3563
+ * Note: `clearable` is derived from the Zod schema:
3515
3564
  * - `z.date().optional()` or `z.date().nullable()` → clearable
3516
3565
  */
3517
3566
  export declare interface F0DateTimeConfig {
@@ -3519,6 +3568,18 @@ export declare interface F0DateTimeConfig {
3519
3568
  granularities?: DateGranularity[];
3520
3569
  /** Preset date options to display in the date picker */
3521
3570
  presets?: DatePreset[];
3571
+ /**
3572
+ * Minimum selectable datetime.
3573
+ * Can be a static Date or a function that receives form values for dynamic constraints.
3574
+ * Overrides z.date().min() if provided.
3575
+ */
3576
+ minDate?: F0DateConstraintProp;
3577
+ /**
3578
+ * Maximum selectable datetime.
3579
+ * Can be a static Date or a function that receives form values for dynamic constraints.
3580
+ * Overrides z.date().max() if provided.
3581
+ */
3582
+ maxDate?: F0DateConstraintProp;
3522
3583
  }
3523
3584
 
3524
3585
  /**
@@ -3527,10 +3588,6 @@ export declare interface F0DateTimeConfig {
3527
3588
  */
3528
3589
  export declare type F0DateTimeField = F0BaseField & F0DateTimeConfig & {
3529
3590
  type: "datetime";
3530
- /** Minimum selectable datetime (derived from z.date().min()) */
3531
- minDate?: Date;
3532
- /** Maximum selectable datetime (derived from z.date().max()) */
3533
- maxDate?: Date;
3534
3591
  /** Whether the datetime can be cleared (derived from optional/nullable) */
3535
3592
  clearable?: boolean;
3536
3593
  /** Conditional rendering based on another field's value */
@@ -3707,7 +3764,7 @@ export declare interface F0FilterPickerContentProps<Filters extends FiltersDefin
3707
3764
  /**
3708
3765
  * @experimental This is an experimental component, use it at your own risk
3709
3766
  */
3710
- export declare const F0Form: <TSchema extends z.ZodObject<ZodRawShape>>(props: F0FormProps<TSchema>) => React.ReactElement;
3767
+ export declare const F0Form: <TSchema extends F0FormSchema>(props: F0FormProps<TSchema>) => React.ReactElement;
3711
3768
 
3712
3769
  /**
3713
3770
  * Submit configuration for action bar type
@@ -3851,6 +3908,7 @@ export declare function f0FormField<T extends ZodTypeAny, V extends string | num
3851
3908
  * Props for the F0Form component
3852
3909
  *
3853
3910
  * @typeParam TSchema - The Zod object schema type. The form data type is inferred from this.
3911
+ * Can be a plain ZodObject or a refined ZodObject (using .refine()).
3854
3912
  *
3855
3913
  * @example
3856
3914
  * ```tsx
@@ -3867,20 +3925,17 @@ export declare function f0FormField<T extends ZodTypeAny, V extends string | num
3867
3925
  * onSubmit={(data) => ({ success: true })}
3868
3926
  * />
3869
3927
  *
3870
- * // Action bar with discard button
3871
- * <F0Form
3872
- * name="my-form"
3873
- * schema={schema}
3874
- * submitConfig={{
3875
- * type: "action-bar",
3876
- * discardable: true,
3877
- * }}
3878
- * defaultValues={{ name: "" }}
3879
- * onSubmit={(data) => ({ success: true })}
3880
- * />
3928
+ * // With cross-field validation using .refine()
3929
+ * const schemaWithRefine = z.object({
3930
+ * startDate: f0FormField(z.date(), { label: "Start" }),
3931
+ * endDate: f0FormField(z.date(), { label: "End" }),
3932
+ * }).refine((data) => data.endDate > data.startDate, {
3933
+ * message: "End date must be after start date",
3934
+ * path: ["endDate"],
3935
+ * })
3881
3936
  * ```
3882
3937
  */
3883
- export declare interface F0FormProps<TSchema extends z.ZodObject<ZodRawShape>> {
3938
+ export declare interface F0FormProps<TSchema extends F0FormSchema> {
3884
3939
  /** Unique name for the form, used for generating anchor links (e.g., #forms.[name].[sectionId].[fieldId]) */
3885
3940
  name: string;
3886
3941
  /** Zod object schema with F0 field configurations */
@@ -3945,9 +4000,9 @@ export declare interface F0FormRef {
3945
4000
  }
3946
4001
 
3947
4002
  /**
3948
- * Type helper for creating a form schema with F0 fields
4003
+ * Type for F0Form schemas - can be a plain ZodObject or a refined ZodObject (ZodEffects)
3949
4004
  */
3950
- export declare type F0FormSchema<T extends Record<string, ZodTypeAny>> = z.ZodObject<T>;
4005
+ export declare type F0FormSchema<T extends ZodRawShape = ZodRawShape> = z.ZodObject<T> | ZodEffects<z.ZodObject<T>>;
3951
4006
 
3952
4007
  /**
3953
4008
  * Callback to update form state in the hook
@@ -4626,6 +4681,16 @@ export declare type F0ThinkingProps = {
4626
4681
  * - `z.string().optional()` or `z.string().nullable()` → clearable
4627
4682
  */
4628
4683
  export declare interface F0TimeConfig {
4684
+ /**
4685
+ * Minimum selectable time.
4686
+ * Can be a static Date or a function that receives form values for dynamic constraints.
4687
+ */
4688
+ minDate?: F0DateConstraintProp;
4689
+ /**
4690
+ * Maximum selectable time.
4691
+ * Can be a static Date or a function that receives form values for dynamic constraints.
4692
+ */
4693
+ maxDate?: F0DateConstraintProp;
4629
4694
  }
4630
4695
 
4631
4696
  /**
@@ -4634,10 +4699,6 @@ export declare interface F0TimeConfig {
4634
4699
  */
4635
4700
  export declare type F0TimeField = F0BaseField & F0TimeConfig & {
4636
4701
  type: "time";
4637
- /** Minimum selectable date/time (derived from z.date().min()) */
4638
- minDate?: Date;
4639
- /** Maximum selectable date/time (derived from z.date().max()) */
4640
- maxDate?: Date;
4641
4702
  /** Whether the time can be cleared (derived from optional/nullable) */
4642
4703
  clearable?: boolean;
4643
4704
  /** Conditional rendering based on another field's value */
@@ -4920,7 +4981,7 @@ export declare function getF0Config(schema: ZodTypeAny): F0FieldConfig | undefin
4920
4981
  * @param sections - Optional section configurations keyed by section ID
4921
4982
  * @returns Array of form definition items
4922
4983
  */
4923
- export declare function getSchemaDefinition(schema: z.ZodObject<ZodRawShape>, sections?: Record<string, F0SectionConfig>): FormDefinitionItem[];
4984
+ export declare function getSchemaDefinition(schema: F0FormSchema, sections?: Record<string, F0SectionConfig>): FormDefinitionItem[];
4924
4985
 
4925
4986
  declare interface GranularityDefinition {
4926
4987
  calendarMode?: CalendarMode;
@@ -7434,7 +7495,7 @@ export declare const useReducedMotion: () => boolean;
7434
7495
  * })
7435
7496
  * ```
7436
7497
  */
7437
- export declare function useSchemaDefinition(schema: z.ZodObject<ZodRawShape>, sections?: Record<string, F0SectionConfig>): FormDefinitionItem[];
7498
+ export declare function useSchemaDefinition(schema: F0FormSchema, sections?: Record<string, F0SectionConfig>): FormDefinitionItem[];
7438
7499
 
7439
7500
  /**
7440
7501
  * Custom hook to manage selection state for items and groups in a data table
@@ -7634,7 +7695,7 @@ declare interface WithTooltipDescription {
7634
7695
  * Zod type names for type checking without instanceof
7635
7696
  * Using _def.typeName is more reliable across module boundaries than instanceof
7636
7697
  */
7637
- declare type ZodTypeName = "ZodString" | "ZodNumber" | "ZodBoolean" | "ZodDate" | "ZodEnum" | "ZodArray" | "ZodObject" | "ZodOptional" | "ZodNullable" | "ZodDefault" | "ZodLiteral";
7698
+ declare type ZodTypeName = "ZodString" | "ZodNumber" | "ZodBoolean" | "ZodDate" | "ZodEnum" | "ZodArray" | "ZodObject" | "ZodOptional" | "ZodNullable" | "ZodDefault" | "ZodLiteral" | "ZodEffects";
7638
7699
 
7639
7700
  export { }
7640
7701
 
@@ -7683,9 +7744,9 @@ declare namespace Calendar {
7683
7744
 
7684
7745
  declare module "@tiptap/core" {
7685
7746
  interface Commands<ReturnType> {
7686
- aiBlock: {
7687
- insertAIBlock: (data: AIBlockData, config: AIBlockConfig) => ReturnType;
7688
- executeAIAction: (actionType: string, config: AIBlockConfig) => ReturnType;
7747
+ enhanceHighlight: {
7748
+ setEnhanceHighlight: (from: number, to: number) => ReturnType;
7749
+ clearEnhanceHighlight: () => ReturnType;
7689
7750
  };
7690
7751
  }
7691
7752
  }
@@ -7693,9 +7754,9 @@ declare module "@tiptap/core" {
7693
7754
 
7694
7755
  declare module "@tiptap/core" {
7695
7756
  interface Commands<ReturnType> {
7696
- enhanceHighlight: {
7697
- setEnhanceHighlight: (from: number, to: number) => ReturnType;
7698
- clearEnhanceHighlight: () => ReturnType;
7757
+ aiBlock: {
7758
+ insertAIBlock: (data: AIBlockData, config: AIBlockConfig) => ReturnType;
7759
+ executeAIAction: (actionType: string, config: AIBlockConfig) => ReturnType;
7699
7760
  };
7700
7761
  }
7701
7762
  }