@factorialco/f0-react 1.374.1 → 1.375.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/ai.d.ts CHANGED
@@ -1196,11 +1196,6 @@ declare module "gridstack" {
1196
1196
  }
1197
1197
 
1198
1198
 
1199
- declare namespace Calendar {
1200
- var displayName: string;
1201
- }
1202
-
1203
-
1204
1199
  declare module "@tiptap/core" {
1205
1200
  interface Commands<ReturnType> {
1206
1201
  aiBlock: {
@@ -1248,3 +1243,8 @@ declare module "@tiptap/core" {
1248
1243
  };
1249
1244
  }
1250
1245
  }
1246
+
1247
+
1248
+ declare namespace Calendar {
1249
+ var displayName: string;
1250
+ }
@@ -6700,11 +6700,6 @@ declare module "gridstack" {
6700
6700
  }
6701
6701
 
6702
6702
 
6703
- declare namespace Calendar {
6704
- var displayName: string;
6705
- }
6706
-
6707
-
6708
6703
  declare module "@tiptap/core" {
6709
6704
  interface Commands<ReturnType> {
6710
6705
  aiBlock: {
@@ -6752,3 +6747,8 @@ declare module "@tiptap/core" {
6752
6747
  };
6753
6748
  }
6754
6749
  }
6750
+
6751
+
6752
+ declare namespace Calendar {
6753
+ var displayName: string;
6754
+ }
@@ -3,8 +3,8 @@ import { eK as _L, eJ as LL, eI as OL, eP as RL, eQ as FL, eM as ML, eL as PL, e
3
3
  import { jsx as l, jsxs as g, Fragment as Z } from "react/jsx-runtime";
4
4
  import * as Fe from "react";
5
5
  import Q, { createContext as Pt, forwardRef as J, useRef as W, useEffect as V, useContext as zt, PureComponent as l0, useTransition as a0, useState as R, useLayoutEffect as Kn, useId as Tl, useCallback as ne, useMemo as P, useImperativeHandle as Ou, memo as lo, Fragment as $n, isValidElement as Ru, cloneElement as Dl, createElement as Oa, Children as Fu } from "react";
6
- import { f as _n, aG as fr, j as qr, aH as c0, b as Bo, aI as d0, A as u0, d as Kr, i as f0, m as h0, G as m0, g as Ra, aJ as p0, l as Fa, aK as g0, p as b0, aL as Mu, aM as Pu, aN as v0, C as y0, az as x0, ae as jn, D as De, aO as ot, aP as St, aQ as Ge, aR as w0, aS as ci, aT as lt, aU as zu, aV as Xe, aW as _l, aX as nt, aY as Ma, aZ as C0, a_ as $u, a$ as He, b0 as et, b1 as hr, b2 as Ti, b3 as ju, b4 as k0, b5 as vn, b6 as N0, b7 as S0, b8 as I0, b9 as Or, ba as Rr, bb as Ll, bc as A0, bd as Bu, be as Hu, bf as Vu, bg as E0, bh as Wu, bi as Uu, bj as Gu, bk as qu, bl as Ku, bm as Ju, bn as ws, bo as T0, bp as Pa, bq as D0, br as _0, bs as L0, t as O0, x as R0, y as F0, F as M0, M as za, N as $a, O as P0, P as z0, a4 as $0, a5 as j0, bt as B0, bu as H0, a7 as V0, bv as Yu, bw as W0, bx as U0, by as G0, am as ao, bz as Ol, bA as Qu, al as Cs, bB as q0, ak as Xu, a2 as Fr, ag as K0, bC as J0, bD as Y0, bE as Q0, ap as Rl, bF as X0, aD as Z0, bG as ks, bH as ev, bI as Di, bJ as tv, aE as nv, bK as rv, aC as Zu, aB as iv, aA as ov, bL as sv, bM as lv, bN as av, bO as cv, bP as dv, bQ as uv, bR as fv, bS as hv, bT as mv, bU as pv, bV as gv, bW as bv, bX as vv, bY as yv, bZ as xv, aF as ef, at as tf, b_ as wv, R as Cv, T as kv, V as Nv, W as Sv, Z as Iv, U as Av, b$ as ja, c0 as Ev, c1 as Tv, n as Dv } from "./DataCollectionStorageProvider-CWC0VRoY.js";
7
- import { ah as HL, c2 as VL, a8 as WL, a3 as UL, aa as GL, c6 as qL, c5 as KL, c3 as JL, c4 as YL, a6 as QL, a9 as XL, aq as ZL, ar as eO } from "./DataCollectionStorageProvider-CWC0VRoY.js";
6
+ import { f as _n, aG as fr, j as qr, aH as c0, b as Bo, aI as d0, A as u0, d as Kr, i as f0, m as h0, G as m0, g as Ra, aJ as p0, l as Fa, aK as g0, p as b0, aL as Mu, aM as Pu, aN as v0, C as y0, az as x0, ae as jn, D as De, aO as ot, aP as St, aQ as Ge, aR as w0, aS as ci, aT as lt, aU as zu, aV as Xe, aW as _l, aX as nt, aY as Ma, aZ as C0, a_ as $u, a$ as He, b0 as et, b1 as hr, b2 as Ti, b3 as ju, b4 as k0, b5 as vn, b6 as N0, b7 as S0, b8 as I0, b9 as Or, ba as Rr, bb as Ll, bc as A0, bd as Bu, be as Hu, bf as Vu, bg as E0, bh as Wu, bi as Uu, bj as Gu, bk as qu, bl as Ku, bm as Ju, bn as ws, bo as T0, bp as Pa, bq as D0, br as _0, bs as L0, t as O0, x as R0, y as F0, F as M0, M as za, N as $a, O as P0, P as z0, a4 as $0, a5 as j0, bt as B0, bu as H0, a7 as V0, bv as Yu, bw as W0, bx as U0, by as G0, am as ao, bz as Ol, bA as Qu, al as Cs, bB as q0, ak as Xu, a2 as Fr, ag as K0, bC as J0, bD as Y0, bE as Q0, ap as Rl, bF as X0, aD as Z0, bG as ks, bH as ev, bI as Di, bJ as tv, aE as nv, bK as rv, aC as Zu, aB as iv, aA as ov, bL as sv, bM as lv, bN as av, bO as cv, bP as dv, bQ as uv, bR as fv, bS as hv, bT as mv, bU as pv, bV as gv, bW as bv, bX as vv, bY as yv, bZ as xv, aF as ef, at as tf, b_ as wv, R as Cv, T as kv, V as Nv, W as Sv, Z as Iv, U as Av, b$ as ja, c0 as Ev, c1 as Tv, n as Dv } from "./DataCollectionStorageProvider-CKziJ9he.js";
7
+ import { ah as HL, c2 as VL, a8 as WL, a3 as UL, aa as GL, c6 as qL, c5 as KL, c3 as JL, c4 as YL, a6 as QL, a9 as XL, aq as ZL, ar as eO } from "./DataCollectionStorageProvider-CKziJ9he.js";
8
8
  import './experimental.css';function nf(t, e) {
9
9
  const n = Vd(e()), r = () => n.set(e());
10
10
  return r(), Hp(() => {
@@ -14046,7 +14046,7 @@ function PS({ totalPages: t, currentPage: e = 1, onPageChange: n, showControls:
14046
14046
  }
14047
14047
  const zS = se("OnePagination", PS), ql = ({ paginationInfo: t, setPage: e, className: n }) => {
14048
14048
  const r = Y();
14049
- return Rb(t) && g("div", {
14049
+ return !Rb(t) || t.pagesCount <= 1 ? null : g("div", {
14050
14050
  className: k("flex w-full items-center justify-between px-4", n),
14051
14051
  children: [l("span", {
14052
14052
  className: "shrink-0 text-f1-foreground-secondary",
@@ -14056,8 +14056,7 @@ const zS = se("OnePagination", PS), ql = ({ paginationInfo: t, setPage: e, class
14056
14056
  children: l(zS, {
14057
14057
  totalPages: t.pagesCount,
14058
14058
  currentPage: t.currentPage,
14059
- onPageChange: e,
14060
- disabled: t.pagesCount <= 1
14059
+ onPageChange: e
14061
14060
  })
14062
14061
  })]
14063
14062
  });
package/dist/f0.d.ts CHANGED
@@ -3797,7 +3797,10 @@ export declare interface F0FilterPickerContentProps<Filters extends FiltersDefin
3797
3797
  /**
3798
3798
  * @experimental This is an experimental component, use it at your own risk
3799
3799
  */
3800
- export declare const F0Form: <TSchema extends F0FormSchema>(props: F0FormProps<TSchema>) => React.ReactElement;
3800
+ export declare const F0Form: {
3801
+ <TSchema extends F0FormSchema>(props: F0FormPropsWithSingleSchema<TSchema>): React.ReactElement;
3802
+ <T extends F0PerSectionSchema>(props: F0FormPropsWithPerSectionSchema<T>): React.ReactElement;
3803
+ };
3801
3804
 
3802
3805
  /**
3803
3806
  * Submit configuration for action bar type
@@ -3938,44 +3941,60 @@ export declare function f0FormField<T extends ZodTypeAny, TConfig = undefined>(s
3938
3941
  export declare function f0FormField<T extends ZodTypeAny, V extends string | number = string | number, R extends Record<string, unknown> = Record<string, unknown>>(schema: T, config: F0FieldConfig<V, R>): T & F0ZodType<T>;
3939
3942
 
3940
3943
  /**
3941
- * Props for the F0Form component
3942
- *
3943
- * @typeParam TSchema - The Zod object schema type. The form data type is inferred from this.
3944
- * Can be a plain ZodObject or a refined ZodObject (using .refine()).
3945
- *
3946
- * @example
3947
- * ```tsx
3948
- * const schema = z.object({
3949
- * name: f0FormField(z.string(), { label: "Name" }),
3950
- * age: f0FormField(z.number(), { label: "Age" }),
3951
- * })
3952
- *
3953
- * // Default submit button
3954
- * <F0Form
3955
- * name="my-form"
3956
- * schema={schema}
3957
- * defaultValues={{ name: "" }}
3958
- * onSubmit={(data) => ({ success: true })}
3959
- * />
3960
- *
3961
- * // With cross-field validation using .refine()
3962
- * const schemaWithRefine = z.object({
3963
- * startDate: f0FormField(z.date(), { label: "Start" }),
3964
- * endDate: f0FormField(z.date(), { label: "End" }),
3965
- * }).refine((data) => data.endDate > data.startDate, {
3966
- * message: "End date must be after start date",
3967
- * path: ["endDate"],
3968
- * })
3969
- * ```
3944
+ * Union of both F0Form prop variants.
3945
+ * The component detects the mode based on whether `schema` is a single Zod schema
3946
+ * or a record of schemas keyed by section ID.
3947
+ */
3948
+ export declare type F0FormProps<TSchema extends F0FormSchema | F0PerSectionSchema = F0FormSchema | F0PerSectionSchema> = TSchema extends F0FormSchema ? F0FormPropsWithSingleSchema<TSchema> : TSchema extends F0PerSectionSchema ? F0FormPropsWithPerSectionSchema<TSchema> : never;
3949
+
3950
+ /**
3951
+ * Props for the F0Form component (per-section schema mode).
3952
+ * Each section key in the schema maps to an independent form with its own
3953
+ * validation and submit button.
3954
+ */
3955
+ export declare interface F0FormPropsWithPerSectionSchema<T extends F0PerSectionSchema> {
3956
+ /** Unique name for the form, used for generating anchor links */
3957
+ name: string;
3958
+ /** Record mapping section IDs to their Zod schemas. Each section is independently validated and submitted. */
3959
+ schema: T;
3960
+ /** Section configurations keyed by section ID */
3961
+ sections?: Record<string, F0PerSectionSectionConfig>;
3962
+ /** Default values for each section, keyed by section ID */
3963
+ defaultValues?: {
3964
+ [K in keyof T]?: Partial<z.infer<T[K]>>;
3965
+ };
3966
+ /** Callback when a section is submitted. Receives the section ID and its validated data, both correctly typed. */
3967
+ onSubmit: PerSectionSubmitHandler<T>;
3968
+ /** Global submit config applied to all sections (can be overridden per section) */
3969
+ submitConfig?: F0PerSectionSubmitConfig;
3970
+ /** Additional class name for the form container */
3971
+ className?: string;
3972
+ /**
3973
+ * When to trigger and display validation errors
3974
+ * @default "on-blur"
3975
+ */
3976
+ errorTriggerMode?: F0FormErrorTriggerMode;
3977
+ /**
3978
+ * Styling configuration for form layout and appearance.
3979
+ */
3980
+ styling?: F0FormStylingConfig;
3981
+ /**
3982
+ * Ref to control the form programmatically from outside.
3983
+ */
3984
+ formRef?: React.MutableRefObject<F0FormRef | null>;
3985
+ }
3986
+
3987
+ /**
3988
+ * Props for the F0Form component (single schema mode)
3970
3989
  */
3971
- export declare interface F0FormProps<TSchema extends F0FormSchema> {
3972
- /** Unique name for the form, used for generating anchor links (e.g., #forms.[name].[sectionId].[fieldId]) */
3990
+ export declare interface F0FormPropsWithSingleSchema<TSchema extends F0FormSchema> {
3991
+ /** Unique name for the form, used for generating anchor links */
3973
3992
  name: string;
3974
3993
  /** Zod object schema with F0 field configurations */
3975
3994
  schema: TSchema;
3976
3995
  /** Section configurations keyed by section ID */
3977
3996
  sections?: Record<string, F0SectionConfig>;
3978
- /** Default values for the form fields (partial of the schema type) */
3997
+ /** Default values for the form fields */
3979
3998
  defaultValues?: Partial<z.infer<TSchema>>;
3980
3999
  /** Callback when the form is submitted with valid data */
3981
4000
  onSubmit: (data: z.infer<TSchema>) => Promise<F0FormSubmitResult> | F0FormSubmitResult;
@@ -3999,14 +4018,6 @@ export declare interface F0FormProps<TSchema extends F0FormSchema> {
3999
4018
  /**
4000
4019
  * Ref to control the form programmatically from outside.
4001
4020
  * Use with the `useF0Form` hook to get a ref and submit/reset functions.
4002
- *
4003
- * @example
4004
- * ```tsx
4005
- * const { formRef, submit } = useF0Form()
4006
- *
4007
- * <F0Form formRef={formRef} ... />
4008
- * <Button onClick={submit}>Submit</Button>
4009
- * ```
4010
4021
  */
4011
4022
  formRef?: React.MutableRefObject<F0FormRef | null>;
4012
4023
  }
@@ -4265,6 +4276,42 @@ export declare const F0OneSwitch: ({ className, disabled }: F0OneSwitchProps) =>
4265
4276
  */
4266
4277
  export declare type F0OneSwitchProps = React.ComponentPropsWithoutRef<typeof SwitchPrimitive.Root>;
4267
4278
 
4279
+ /**
4280
+ * A record mapping section IDs to their individual schemas.
4281
+ * When used, each section gets independent validation and its own submit button.
4282
+ */
4283
+ export declare type F0PerSectionSchema = Record<string, F0FormSchema>;
4284
+
4285
+ /**
4286
+ * Section configuration for per-section schema mode.
4287
+ * Extends F0SectionConfig with per-section submit and default values.
4288
+ */
4289
+ export declare interface F0PerSectionSectionConfig extends F0SectionConfig {
4290
+ /** Override submit config for this specific section */
4291
+ submitConfig?: F0PerSectionSubmitConfig;
4292
+ }
4293
+
4294
+ /**
4295
+ * Per-section submit configuration, extending the base submit config
4296
+ * with an optional per-section label override.
4297
+ */
4298
+ export declare interface F0PerSectionSubmitConfig {
4299
+ /** Custom label for the submit button (per section) */
4300
+ label?: string;
4301
+ /**
4302
+ * Custom icon for the submit button
4303
+ * - undefined: uses default Save icon
4304
+ * - null: no icon shown
4305
+ * - IconType: custom icon
4306
+ */
4307
+ icon?: IconType | null;
4308
+ /**
4309
+ * When true, the submit button is only visible once the section has unsaved changes.
4310
+ * @default false
4311
+ */
4312
+ showSubmitWhenDirty?: boolean;
4313
+ }
4314
+
4268
4315
  export declare const F0Provider: React.FC<{
4269
4316
  children: React.ReactNode;
4270
4317
  link?: LinkContextValue;
@@ -5260,6 +5307,14 @@ export declare type InferF0FormValues<T extends z.ZodObject<z.ZodRawShape>> = z.
5260
5307
  */
5261
5308
  export declare function inferFieldType(schema: ZodTypeAny, config: F0FieldConfig): F0FieldType;
5262
5309
 
5310
+ /**
5311
+ * Helper type to infer the combined values from a per-section schema record.
5312
+ * Merges all section schemas into a single type.
5313
+ */
5314
+ export declare type InferPerSectionValues<T extends F0PerSectionSchema> = {
5315
+ [K in keyof T]: z.infer<T[K]>;
5316
+ };
5317
+
5263
5318
  export declare type InFilterDefinition<T = string | number, R extends RecordType = RecordType> = BaseFilterDefinition<"in"> & {
5264
5319
  options: InFilterOptions_2<T, R>;
5265
5320
  };
@@ -6081,6 +6136,24 @@ declare type PathsToStringProps<T> = T extends string ? [] : {
6081
6136
  [K in Extract<keyof T, string>]: [K, ...PathsToStringProps<T[K]>];
6082
6137
  }[Extract<keyof T, string>];
6083
6138
 
6139
+ /**
6140
+ * Creates a union of `[sectionId, data]` pairs for each key in T.
6141
+ * Used to build a callback where TypeScript narrows `data` based on `sectionId`.
6142
+ *
6143
+ * @example
6144
+ * For T = { profile: ZodObject<{name: ZodString}>, settings: ZodObject<{theme: ZodEnum}> }
6145
+ * Produces: ["profile", { name: string }] | ["settings", { theme: "light" | "dark" }]
6146
+ */
6147
+ declare type PerSectionSubmitArgs<T extends F0PerSectionSchema> = {
6148
+ [K in keyof T & string]: [sectionId: K, data: z.infer<T[K]>];
6149
+ }[keyof T & string];
6150
+
6151
+ /**
6152
+ * Callback type for per-section submit. Uses a discriminated union of argument
6153
+ * tuples so that narrowing `sectionId` also narrows `data` to the correct type.
6154
+ */
6155
+ declare type PerSectionSubmitHandler<T extends F0PerSectionSchema> = (...args: PerSectionSubmitArgs<T>) => Promise<F0FormSubmitResult> | F0FormSubmitResult;
6156
+
6084
6157
  export declare type PersonAvatarVariant = Extract<AvatarVariant, {
6085
6158
  type: "person";
6086
6159
  }>;
@@ -7821,11 +7894,6 @@ declare module "gridstack" {
7821
7894
  }
7822
7895
 
7823
7896
 
7824
- declare namespace Calendar {
7825
- var displayName: string;
7826
- }
7827
-
7828
-
7829
7897
  declare module "@tiptap/core" {
7830
7898
  interface Commands<ReturnType> {
7831
7899
  aiBlock: {
@@ -7873,3 +7941,8 @@ declare module "@tiptap/core" {
7873
7941
  };
7874
7942
  }
7875
7943
  }
7944
+
7945
+
7946
+ declare namespace Calendar {
7947
+ var displayName: string;
7948
+ }