@factorialco/f0-react 4.3.2 → 4.4.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.
@@ -2,8 +2,8 @@ import { h as ga, B as pa, i as ba, j as xa, k as Dt, l as Be, m as Te, n as va,
2
2
  import { c2 as Kc, c1 as qc, ce as Yc, b_ as Jc, b$ as Zc, bS as Xc, bT as Qc, ch as ed, bU as td, bV as nd, ci as ad, c0 as rd, ca as id, cb as ld, cf as sd, bW as od, c4 as cd, c3 as dd, bX as ud, bY as fd, cc as md, cj as hd, cd as gd, cg as pd, c9 as bd, c6 as xd, c8 as vd, c5 as yd, bZ as wd, c7 as Nd } from "./F0CanvasPanel-QUIIThsf.js";
3
3
  import { jsx as e, jsxs as o, Fragment as Z } from "react/jsx-runtime";
4
4
  import ue, { forwardRef as G, useRef as j, useTransition as ni, useState as D, useLayoutEffect as Tn, useId as pt, useContext as Pe, createContext as Qe, useEffect as W, useCallback as ne, useMemo as q, Fragment as ai, isValidElement as ri, cloneElement as zn, Children as Rn } from "react";
5
- import { C as ii, P as li, a as Bn, M as si, p as oi, b as ci, R as Mt, c as $n, u as di, d as ui, e as fi, f as mi, g as hi, h as Mn, S as gi, A as pi, B as bi, L as xi, i as vi, V as yi, j as wi, k as Ni, l as Ci, O as Ii } from "./useDataCollectionSource-CKC4IqL-.js";
6
- import { r as Id, s as kd, o as Sd, H as Fd, t as Ad, z as Ld, a8 as Od, G as Pd, q as Ed, aa as _d, a9 as Dd, Q as Td, ad as zd, F as Rd, Y as Bd, U as $d, J as Md, af as Wd, K as jd, Z as Vd, _ as Ud, v as Hd, ab as Gd, ac as Kd, N as qd, $ as Yd, a5 as Jd, a7 as Zd, w as Xd, y as Qd, D as eu, W as tu, ae as nu, X as au, T as ru, ag as iu, x as lu, E as su, m as ou, n as cu, a1 as du, a2 as uu, a6 as fu, I as mu, a3 as hu, a0 as gu, a4 as pu } from "./useDataCollectionSource-CKC4IqL-.js";
5
+ import { C as ii, P as li, a as Bn, M as si, p as oi, b as ci, R as Mt, c as $n, u as di, d as ui, e as fi, f as mi, g as hi, h as Mn, S as gi, A as pi, B as bi, L as xi, i as vi, V as yi, j as wi, k as Ni, l as Ci, O as Ii } from "./useDataCollectionSource-BKj2I6LP.js";
6
+ import { r as Id, s as kd, o as Sd, H as Fd, t as Ad, z as Ld, a8 as Od, G as Pd, q as Ed, aa as _d, a9 as Dd, Q as Td, ad as zd, F as Rd, Y as Bd, U as $d, J as Md, af as Wd, K as jd, Z as Vd, _ as Ud, v as Hd, ab as Gd, ac as Kd, N as qd, $ as Yd, a5 as Jd, a7 as Zd, w as Xd, y as Qd, D as eu, W as tu, ae as nu, X as au, T as ru, ag as iu, x as lu, E as su, m as ou, n as cu, a1 as du, a2 as uu, a6 as fu, I as mu, a3 as hu, a0 as gu, a4 as pu } from "./useDataCollectionSource-BKj2I6LP.js";
7
7
  const ki = ga("Search", [
8
8
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
9
9
  ["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }]
package/dist/f0.d.ts CHANGED
@@ -5098,26 +5098,6 @@ declare type DetailsItemContent = (ComponentProps<typeof DataList.Item> & {
5098
5098
  type: "file";
5099
5099
  });
5100
5100
 
5101
- /**
5102
- * Imperative API for centered dialogs. Requires `<F0Provider>` (which mounts
5103
- * `DialogsAlikeLayoutProvider`) to be present in the tree.
5104
- *
5105
- * @example
5106
- * const result = await dialog.open({ title, content, actions: { primary: { label: "OK", value: true } } })
5107
- */
5108
- export declare const dialog: {
5109
- /** Open a dialog. Resolves with the value of the action the user picked. */
5110
- open: (definition: Optional<DialogDefinition, "id">) => Promise<DialogActionValue>;
5111
- /** Open a notification-style dialog (info/warning/critical/positive). */
5112
- notification: (options: NotificationDialogOptions) => Promise<DialogActionValue>;
5113
- /** Notification dialog with a single confirm action (defaults to "Ok"). */
5114
- alert: (options: AlertDialogOptions) => Promise<DialogActionValue>;
5115
- /** Notification dialog with confirm + cancel actions (defaults to Ok/Cancel). */
5116
- confirm: (options: ConfirmDialogOptions) => Promise<DialogActionValue>;
5117
- /** Programmatically close a dialog by id (resolves its promise with undefined). */
5118
- close: (id: DialogId) => void;
5119
- };
5120
-
5121
5101
  export declare type DialogAction = Optional<Pick<F0ButtonProps, "label" | "icon" | "disabled">, "icon" | "disabled"> & {
5122
5102
  value: DialogActionValue;
5123
5103
  keepOpen?: boolean;
@@ -5218,6 +5198,28 @@ export declare type DialogPosition = (typeof dialogPositions)[number];
5218
5198
 
5219
5199
  declare const dialogPositions: readonly ["center", "left", "right", "fullscreen"];
5220
5200
 
5201
+ /**
5202
+ * Imperative API for centered dialogs. Requires `<F0Provider>` (which mounts
5203
+ * `DialogsAlikeLayoutProvider`) to be present in the tree.
5204
+ *
5205
+ * @example
5206
+ * import { dialogs } from "@factorialco/f0-react"
5207
+ *
5208
+ * const result = await dialogs.open({ title, content, actions: { primary: { label: "OK", value: true } } })
5209
+ */
5210
+ export declare const dialogs: {
5211
+ /** Open a dialog. Resolves with the value of the action the user picked. */
5212
+ open: (definition: Optional<DialogDefinition, "id">) => Promise<DialogActionValue>;
5213
+ /** Open a notification-style dialog (info/warning/critical/positive). */
5214
+ notification: (options: NotificationDialogOptions) => Promise<DialogActionValue>;
5215
+ /** Notification dialog with a single confirm action (defaults to "Ok"). */
5216
+ alert: (options: AlertDialogOptions) => Promise<DialogActionValue>;
5217
+ /** Notification dialog with confirm + cancel actions (defaults to Ok/Cancel). */
5218
+ confirmation: (options: ConfirmDialogOptions) => Promise<DialogActionValue>;
5219
+ /** Programmatically close a dialog by id (resolves its promise with undefined). */
5220
+ close: (id: DialogId) => void;
5221
+ };
5222
+
5221
5223
  declare type DialogSimpleAction = {
5222
5224
  label?: string;
5223
5225
  value?: DialogActionValue;
@@ -5304,19 +5306,6 @@ export declare type DragPayload<T = unknown> = {
5304
5306
  data?: T;
5305
5307
  };
5306
5308
 
5307
- /**
5308
- * Imperative API for side drawers. Requires `<F0Provider>` to be present.
5309
- *
5310
- * @example
5311
- * const result = await drawer.open({ title, content, actions: { primary: { label: "Save", value: "save" } } })
5312
- */
5313
- export declare const drawer: {
5314
- /** Open a drawer. Resolves with the value of the action the user picked. */
5315
- open: (definition: Optional<DrawerDefinition, "id">) => Promise<DialogActionValue>;
5316
- /** Programmatically close a drawer by id (resolves its promise with undefined). */
5317
- close: (id: DialogId) => void;
5318
- };
5319
-
5320
5309
  export declare type DrawerDefinition = {
5321
5310
  /** The size of the drawer. */
5322
5311
  size?: DrawerSize;
@@ -5348,6 +5337,21 @@ export declare type DrawerDefinition = {
5348
5337
 
5349
5338
  declare const drawerPositions: readonly ["left", "right"];
5350
5339
 
5340
+ /**
5341
+ * Imperative API for side drawers. Requires `<F0Provider>` to be present.
5342
+ *
5343
+ * @example
5344
+ * import { drawers } from "@factorialco/f0-react"
5345
+ *
5346
+ * const result = await drawers.open({ title, content, actions: { primary: { label: "Save", value: "save" } } })
5347
+ */
5348
+ export declare const drawers: {
5349
+ /** Open a drawer. Resolves with the value of the action the user picked. */
5350
+ open: (definition: Optional<DrawerDefinition, "id">) => Promise<DialogActionValue>;
5351
+ /** Programmatically close a drawer by id (resolves its promise with undefined). */
5352
+ close: (id: DialogId) => void;
5353
+ };
5354
+
5351
5355
  declare type DrawerSize = (typeof drawerSizes)[number];
5352
5356
 
5353
5357
  declare const drawerSizes: readonly ["md"];
@@ -11379,6 +11383,23 @@ export declare interface FormFieldProps {
11379
11383
  ref?: React.RefCallback<HTMLElement>;
11380
11384
  }
11381
11385
 
11386
+ /**
11387
+ * Imperative API for opening forms. Pick the presentation with `mode` —
11388
+ * `"dialog"` for a single-screen form, `"wizard"` for a multi-step form.
11389
+ * Requires `<F0Provider>` to be mounted.
11390
+ *
11391
+ * @example
11392
+ * const result = await forms.open({ formDefinition, mode: "dialog", title: "Add member" })
11393
+ * if (result.submitted) save(result.data)
11394
+ *
11395
+ * @example
11396
+ * const result = await forms.open({ formDefinition, mode: "wizard", title: "Onboarding" })
11397
+ * if (result.completed) save(result.data)
11398
+ */
11399
+ export declare const forms: {
11400
+ open: typeof openForm;
11401
+ };
11402
+
11382
11403
  /** Fraction tokens for proportional widths */
11383
11404
  export declare type FractionToken = "1/2" | "1/3" | "2/3" | "1/4" | "2/4" | "3/4" | "1/5" | "2/5" | "3/5" | "4/5" | "1/6" | "5/6";
11384
11405
 
@@ -13471,6 +13492,78 @@ export declare type OnSelectItemsCallback<R extends RecordType, Filters extends
13471
13492
  byLane?: Record<string, SelectedItemsDetailedStatus<R, Filters>>;
13472
13493
  }, clearSelectedItems: () => void, handleSelectAll?: (checked: boolean) => void) => void;
13473
13494
 
13495
+ /** Open a form in a dialog. */
13496
+ declare function openForm<TSchema extends F0FormSchema_2>(options: {
13497
+ mode: "dialog";
13498
+ } & OpenFormDialogOptions<TSchema>): Promise<OpenFormDialogResult<TSchema>>;
13499
+
13500
+ /** Open a form in a multi-step wizard. */
13501
+ declare function openForm<T extends F0FormSchema_2 | F0PerSectionSchema_2>(options: {
13502
+ mode: "wizard";
13503
+ } & OpenFormWizardOptions<T>): Promise<OpenFormWizardResult<T>>;
13504
+
13505
+ export declare type OpenFormDialogOptions<TSchema extends F0FormSchema_2> = {
13506
+ /** The form definition created with `useF0FormDefinition`. */
13507
+ formDefinition: F0FormDefinitionSingleSchema<TSchema>;
13508
+ /** The dialog title. */
13509
+ title: string;
13510
+ /** Optional supporting description below the title. */
13511
+ description?: string;
13512
+ /** The dialog size. @default "md" */
13513
+ size?: F0DialogSize;
13514
+ /** Module shown in the dialog header. */
13515
+ module?: DialogModule;
13516
+ /**
13517
+ * When true, the dialog can only be closed via its actions (no overlay click
13518
+ * or Escape) — so in-progress input isn't lost by an accidental dismissal.
13519
+ * @default true
13520
+ */
13521
+ modal?: boolean;
13522
+ /** Overlay id. Auto-generated if not provided. */
13523
+ id?: DialogId;
13524
+ /** Override the footer button labels (default to i18n save/cancel). */
13525
+ labels?: {
13526
+ submit?: string;
13527
+ cancel?: string;
13528
+ };
13529
+ };
13530
+
13531
+ export declare type OpenFormDialogResult<TSchema extends F0FormSchema_2> = {
13532
+ submitted: true;
13533
+ data: z.infer<TSchema>;
13534
+ } | {
13535
+ submitted: false;
13536
+ };
13537
+
13538
+ export declare type OpenFormWizardOptions<T extends F0FormSchema_2 | F0PerSectionSchema_2> = {
13539
+ /** The form definition created with `useF0FormDefinition`. */
13540
+ formDefinition: F0FormDefinition<T>;
13541
+ /** The wizard dialog title. */
13542
+ title?: string;
13543
+ /** The wizard dialog size. */
13544
+ size?: F0DialogSize;
13545
+ /** Overlay id. Auto-generated if not provided. */
13546
+ id?: DialogId;
13547
+ /** Custom step definitions (otherwise derived from sections). */
13548
+ steps?: F0WizardFormStep[];
13549
+ /** Step to open on. */
13550
+ defaultStepIndex?: number;
13551
+ nextLabel?: string;
13552
+ previousLabel?: string;
13553
+ /** Allow clicking ahead to non-incomplete steps. @default false */
13554
+ allowStepSkipping?: boolean;
13555
+ /** Skip to the first incomplete step on open. @default false */
13556
+ autoSkipCompletedSteps?: boolean;
13557
+ onStepChanged?: (stepIndex: number) => void;
13558
+ };
13559
+
13560
+ export declare type OpenFormWizardResult<T extends F0FormSchema_2 | F0PerSectionSchema_2> = {
13561
+ completed: true;
13562
+ data: WizardData<T>;
13563
+ } | {
13564
+ completed: false;
13565
+ };
13566
+
13474
13567
  declare type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
13475
13568
 
13476
13569
  /** Overflow values */
@@ -16944,6 +17037,8 @@ declare interface WithTooltipDescription {
16944
17037
  description?: string;
16945
17038
  }
16946
17039
 
17040
+ declare type WizardData<T extends F0FormSchema_2 | F0PerSectionSchema_2> = T extends F0FormSchema_2 ? z.infer<T> : T extends F0PerSectionSchema_2 ? InferPerSectionValues_2<T> : never;
17041
+
16947
17042
  /**
16948
17043
  * Synchronously persists a OneDataCollection's state to localStorage, mirroring
16949
17044
  * `readDataCollectionStorage`. Uses the same `datacollection-` prefixed key as