@factorialco/f0-react 1.412.0 → 1.413.1

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
@@ -313,6 +313,11 @@ declare type AiChatDisclaimer = {
313
313
  linkText?: string;
314
314
  };
315
315
 
316
+ /**
317
+ * Interaction mode for the AI chat
318
+ */
319
+ export declare type AiChatMode = "chat" | "voice";
320
+
316
321
  /**
317
322
  * Props for the AiChatProvider component
318
323
  */
@@ -349,6 +354,10 @@ export declare type AiChatProviderProps = {
349
354
  * Optional footer content rendered below the textarea
350
355
  */
351
356
  footer?: React.ReactNode;
357
+ /**
358
+ * Optional component rendered in place of the chat UI when voice mode is active.
359
+ */
360
+ VoiceMode?: React.ComponentType;
352
361
  /**
353
362
  * Async resolver functions for entity references in markdown.
354
363
  * Used to fetch profile data for inline entity mentions (hover cards).
@@ -442,6 +451,14 @@ declare type AiChatProviderReturnValue = {
442
451
  * Set the visualization mode
443
452
  */
444
453
  setVisualizationMode: React.Dispatch<React.SetStateAction<VisualizationMode>>;
454
+ /**
455
+ * The current interaction mode
456
+ */
457
+ mode: AiChatMode;
458
+ /**
459
+ * Set the interaction mode
460
+ */
461
+ setMode: React.Dispatch<React.SetStateAction<AiChatMode>>;
445
462
  /**
446
463
  * When true, prevents switching between visualization modes
447
464
  */
@@ -451,6 +468,10 @@ declare type AiChatProviderReturnValue = {
451
468
  * Optional footer content rendered below the textarea
452
469
  */
453
470
  footer?: React.ReactNode;
471
+ /**
472
+ * Optional component rendered when voice mode is active.
473
+ */
474
+ VoiceMode?: React.ComponentType;
454
475
  /**
455
476
  * Set the footer content. Use this to update the footer from outside the provider (e.g. per page/route).
456
477
  */
@@ -458,8 +479,6 @@ declare type AiChatProviderReturnValue = {
458
479
  } & Pick<AiChatState, "greeting" | "agent" | "disclaimer" | "resizable" | "entityResolvers" | "toolHints"> & {
459
480
  /** The current canvas content, or null when canvas is closed */
460
481
  canvasContent: CanvasContent | null;
461
- /** The dashboard config from the current canvas content, or null */
462
- canvasDashboard: ChatDashboardConfig | null;
463
482
  /** Open the canvas panel with the given content */
464
483
  openCanvas: (content: CanvasContent) => void;
465
484
  /** Close the canvas panel and restore the previous visualization mode */
@@ -468,10 +487,6 @@ declare type AiChatProviderReturnValue = {
468
487
  activeToolHint: AiChatToolHint | null;
469
488
  /** Set the active tool hint (pass null to clear) */
470
489
  setActiveToolHint: React.Dispatch<React.SetStateAction<AiChatToolHint | null>>;
471
- /** Get a saved dashboard config by toolCallId (returns updated config after user edits) */
472
- getSavedDashboardConfig: (toolCallId: string) => ChatDashboardConfig | undefined;
473
- /** Save an updated dashboard config keyed by toolCallId */
474
- updateDashboardConfig: (toolCallId: string, config: ChatDashboardConfig) => void;
475
490
  };
476
491
 
477
492
  /**
@@ -489,6 +504,7 @@ declare interface AiChatState {
489
504
  lockVisualizationMode?: boolean;
490
505
  historyEnabled?: boolean;
491
506
  footer?: React.ReactNode;
507
+ VoiceMode?: React.ComponentType;
492
508
  entityResolvers?: EntityResolvers;
493
509
  toolHints?: AiChatToolHint[];
494
510
  placeholders?: string[];
@@ -1308,19 +1324,54 @@ declare type CalendarView = "day" | "month" | "year" | "week" | "quarter" | "hal
1308
1324
 
1309
1325
  /**
1310
1326
  * Discriminated union for canvas panel content.
1311
- * Expand this union to support new content types in the canvas.
1327
+ * Add new entity types to this union as they are implemented.
1312
1328
  */
1313
- export declare type CanvasContent = {
1314
- type: "dashboard";
1329
+ export declare type CanvasContent = DashboardCanvasContent;
1330
+
1331
+ /**
1332
+ * Base shape shared by all canvas content types.
1333
+ * Every entity adds its own fields on top of this.
1334
+ */
1335
+ export declare type CanvasContentBase = {
1336
+ type: string;
1315
1337
  title: string;
1316
- config: ChatDashboardConfig;
1317
- apiConfig: {
1318
- baseUrl: string;
1319
- headers: Record<string, string>;
1320
- };
1321
1338
  toolCallId?: string;
1322
1339
  };
1323
1340
 
1341
+ /**
1342
+ * Contract for a canvas entity type.
1343
+ *
1344
+ * Each entity (dashboard, survey, goal, job-posting…) implements this
1345
+ * interface and registers itself via `registerCanvasEntity()`.
1346
+ *
1347
+ * To add a new entity type:
1348
+ * 1. Create a folder in `canvas/entities/<your-entity>/`
1349
+ * 2. Define a type extending `CanvasContentBase` in `types.ts`
1350
+ * 3. Implement `CanvasEntityDefinition` in `index.ts`
1351
+ * 4. Import the entity module in `canvas/index.ts`
1352
+ */
1353
+ export declare type CanvasEntityDefinition<T extends CanvasContentBase = CanvasContentBase> = {
1354
+ /** Must match the `type` discriminant on the content object */
1355
+ type: T["type"];
1356
+ /** Renders the main body of the canvas panel */
1357
+ renderContent: (props: {
1358
+ content: T;
1359
+ refreshKey: number;
1360
+ }) => ReactNode;
1361
+ /** Renders header actions (placed before the close button) */
1362
+ renderHeaderActions: (props: {
1363
+ content: T;
1364
+ }) => ReactNode;
1365
+ /**
1366
+ * Optional wrapper providing entity-scoped context around
1367
+ * both header actions and body (e.g. shared edit-mode state).
1368
+ */
1369
+ wrapper?: (props: {
1370
+ content: T;
1371
+ children: ReactNode;
1372
+ }) => ReactNode;
1373
+ };
1374
+
1324
1375
  declare type CardAvatarVariant = AvatarVariant | {
1325
1376
  type: "emoji";
1326
1377
  emoji: string;
@@ -2043,6 +2094,29 @@ declare interface CustomFieldRenderPropsBase {
2043
2094
 
2044
2095
  export declare const Dashboard: WithDataTestIdReturnType_3<ComponentType<DashboardProps_2> & PageLayoutGroupComponent_2>;
2045
2096
 
2097
+ /**
2098
+ * Dashboard canvas content — renders an analytics dashboard.
2099
+ */
2100
+ export declare type DashboardCanvasContent = CanvasContentBase & {
2101
+ type: "dashboard";
2102
+ config: ChatDashboardConfig;
2103
+ apiConfig: {
2104
+ baseUrl: string;
2105
+ headers: Record<string, string>;
2106
+ };
2107
+ };
2108
+
2109
+ /**
2110
+ * Dashboard-specific card that wraps CanvasCard with config-store
2111
+ * subscription logic. Re-renders when the user edits and saves
2112
+ * the dashboard layout.
2113
+ */
2114
+ declare function DashboardCard({ config: originalConfig, onView, toolCallId, }: F0ChatReportCardProps): JSX_2.Element;
2115
+
2116
+ declare namespace DashboardCard {
2117
+ var displayName: string;
2118
+ }
2119
+
2046
2120
  /**
2047
2121
  * Chart display configuration — discriminated on `type`.
2048
2122
  * This object is JSON-serializable (no functions, except optional formatters).
@@ -3571,7 +3645,7 @@ export declare const F0AiChat: () => JSX_2.Element | null;
3571
3645
  /**
3572
3646
  * @experimental This is an experimental component use it at your own risk
3573
3647
  */
3574
- export declare const F0AiChatProvider: ({ enabled, greeting, initialMessage, welcomeScreenSuggestions, disclaimer, resizable, defaultVisualizationMode, lockVisualizationMode, historyEnabled, footer, entityResolvers, toolHints, onThumbsUp, onThumbsDown, children, agent, tracking, ...copilotKitProps }: AiChatProviderProps) => JSX_2.Element;
3648
+ export declare const F0AiChatProvider: ({ enabled, greeting, initialMessage, welcomeScreenSuggestions, disclaimer, resizable, defaultVisualizationMode, lockVisualizationMode, historyEnabled, footer, VoiceMode, entityResolvers, toolHints, onThumbsUp, onThumbsDown, children, agent, tracking, ...copilotKitProps }: AiChatProviderProps) => JSX_2.Element;
3575
3649
 
3576
3650
  export declare const F0AiChatTextArea: ({ submitLabel, inProgress, onSend, onStop, placeholders, defaultPlaceholder, autoFocus, entityResolvers, toolHints, activeToolHint, onActiveToolHintChange, }: F0AiChatTextAreaProps) => JSX_2.Element;
3577
3651
 
@@ -4268,29 +4342,19 @@ compact?: boolean;
4268
4342
  export declare type F0CardProps = Omit<CardInternalProps, (typeof privateProps_3)[number]>;
4269
4343
 
4270
4344
  /**
4271
- * Compact card shown inline in the AI chat to represent a generated
4272
- * dashboard report. Uses F0Card with an icon avatar, the dashboard
4273
- * title/description, and an item summary in metadata. Clicking the
4274
- * card triggers `onView` to open the canvas panel.
4275
- *
4276
- * Subscribes to the external `savedDashboardConfigStore` via
4277
- * `useSyncExternalStore` so it re-renders when the user edits the
4278
- * dashboard layout and saves — independently of React context.
4345
+ * @deprecated Use `DashboardCard` from `canvas/entities/dashboard` directly.
4346
+ * This re-export exists for backwards compatibility.
4279
4347
  */
4280
- export declare function F0ChatReportCard({ config: originalConfig, onView, toolCallId, }: F0ChatReportCardProps): JSX_2.Element;
4348
+ export declare const F0ChatReportCard: typeof DashboardCard;
4281
4349
 
4282
- export declare namespace F0ChatReportCard {
4283
- var displayName: string;
4284
- }
4285
-
4286
- export declare interface F0ChatReportCardProps {
4350
+ export declare type F0ChatReportCardProps = {
4287
4351
  /** The original dashboard config from the agent */
4288
4352
  config: ChatDashboardConfig;
4289
4353
  /** Callback when the user clicks the card to view the report */
4290
4354
  onView: (config: ChatDashboardConfig) => void;
4291
4355
  /** Tool call ID used to look up saved (edited) dashboard configs */
4292
4356
  toolCallId?: string;
4293
- }
4357
+ };
4294
4358
 
4295
4359
  /**
4296
4360
  * @experimental This is an experimental component use it at your own risk
@@ -6707,6 +6771,12 @@ export declare const getAnimationVariants: (options?: AnimationVariantsOptions)
6707
6771
  };
6708
6772
  };
6709
6773
 
6774
+ /**
6775
+ * Look up a registered entity definition by content type.
6776
+ * Returns `undefined` if the type hasn't been registered.
6777
+ */
6778
+ export declare function getCanvasEntity(type: string): CanvasEntityDefinition<any> | undefined;
6779
+
6710
6780
  /**
6711
6781
  * Get the pagination type of a data adapter
6712
6782
  * @param dataAdapter - The data adapter to get the pagination type of
@@ -8508,6 +8578,12 @@ export declare type RecordType = Record<string, unknown>;
8508
8578
 
8509
8579
  declare type ReferenceType = "none" | "striped";
8510
8580
 
8581
+ /**
8582
+ * Register a canvas entity definition.
8583
+ * Called as a side-effect when each entity module is imported.
8584
+ */
8585
+ export declare function registerCanvasEntity<T extends CanvasContentBase>(definition: CanvasEntityDefinition<T>): void;
8586
+
8511
8587
  declare type RegularAction = BaseAction & {
8512
8588
  type: "regular";
8513
8589
  variant: ButtonVariant;