@factorialco/f0-react 1.413.0 → 1.414.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
@@ -479,8 +479,6 @@ declare type AiChatProviderReturnValue = {
479
479
  } & Pick<AiChatState, "greeting" | "agent" | "disclaimer" | "resizable" | "entityResolvers" | "toolHints"> & {
480
480
  /** The current canvas content, or null when canvas is closed */
481
481
  canvasContent: CanvasContent | null;
482
- /** The dashboard config from the current canvas content, or null */
483
- canvasDashboard: ChatDashboardConfig | null;
484
482
  /** Open the canvas panel with the given content */
485
483
  openCanvas: (content: CanvasContent) => void;
486
484
  /** Close the canvas panel and restore the previous visualization mode */
@@ -489,10 +487,6 @@ declare type AiChatProviderReturnValue = {
489
487
  activeToolHint: AiChatToolHint | null;
490
488
  /** Set the active tool hint (pass null to clear) */
491
489
  setActiveToolHint: React.Dispatch<React.SetStateAction<AiChatToolHint | null>>;
492
- /** Get a saved dashboard config by toolCallId (returns updated config after user edits) */
493
- getSavedDashboardConfig: (toolCallId: string) => ChatDashboardConfig | undefined;
494
- /** Save an updated dashboard config keyed by toolCallId */
495
- updateDashboardConfig: (toolCallId: string, config: ChatDashboardConfig) => void;
496
490
  };
497
491
 
498
492
  /**
@@ -633,6 +627,12 @@ export declare const aiTranslations: {
633
627
  dataDownload: {
634
628
  download: string;
635
629
  };
630
+ pong: {
631
+ ai: string;
632
+ you: string;
633
+ youWin: string;
634
+ youLose: string;
635
+ };
636
636
  unsavedChanges: string;
637
637
  saveChanges: string;
638
638
  discardChanges: string;
@@ -1330,19 +1330,54 @@ declare type CalendarView = "day" | "month" | "year" | "week" | "quarter" | "hal
1330
1330
 
1331
1331
  /**
1332
1332
  * Discriminated union for canvas panel content.
1333
- * Expand this union to support new content types in the canvas.
1333
+ * Add new entity types to this union as they are implemented.
1334
1334
  */
1335
- export declare type CanvasContent = {
1336
- type: "dashboard";
1335
+ export declare type CanvasContent = DashboardCanvasContent;
1336
+
1337
+ /**
1338
+ * Base shape shared by all canvas content types.
1339
+ * Every entity adds its own fields on top of this.
1340
+ */
1341
+ export declare type CanvasContentBase = {
1342
+ type: string;
1337
1343
  title: string;
1338
- config: ChatDashboardConfig;
1339
- apiConfig: {
1340
- baseUrl: string;
1341
- headers: Record<string, string>;
1342
- };
1343
1344
  toolCallId?: string;
1344
1345
  };
1345
1346
 
1347
+ /**
1348
+ * Contract for a canvas entity type.
1349
+ *
1350
+ * Each entity (dashboard, survey, goal, job-posting…) implements this
1351
+ * interface and registers itself via `registerCanvasEntity()`.
1352
+ *
1353
+ * To add a new entity type:
1354
+ * 1. Create a folder in `canvas/entities/<your-entity>/`
1355
+ * 2. Define a type extending `CanvasContentBase` in `types.ts`
1356
+ * 3. Implement `CanvasEntityDefinition` in `index.ts`
1357
+ * 4. Import the entity module in `canvas/index.ts`
1358
+ */
1359
+ export declare type CanvasEntityDefinition<T extends CanvasContentBase = CanvasContentBase> = {
1360
+ /** Must match the `type` discriminant on the content object */
1361
+ type: T["type"];
1362
+ /** Renders the main body of the canvas panel */
1363
+ renderContent: (props: {
1364
+ content: T;
1365
+ refreshKey: number;
1366
+ }) => ReactNode;
1367
+ /** Renders header actions (placed before the close button) */
1368
+ renderHeaderActions: (props: {
1369
+ content: T;
1370
+ }) => ReactNode;
1371
+ /**
1372
+ * Optional wrapper providing entity-scoped context around
1373
+ * both header actions and body (e.g. shared edit-mode state).
1374
+ */
1375
+ wrapper?: (props: {
1376
+ content: T;
1377
+ children: ReactNode;
1378
+ }) => ReactNode;
1379
+ };
1380
+
1346
1381
  declare type CardAvatarVariant = AvatarVariant | {
1347
1382
  type: "emoji";
1348
1383
  emoji: string;
@@ -2065,6 +2100,29 @@ declare interface CustomFieldRenderPropsBase {
2065
2100
 
2066
2101
  export declare const Dashboard: WithDataTestIdReturnType_3<ComponentType<DashboardProps_2> & PageLayoutGroupComponent_2>;
2067
2102
 
2103
+ /**
2104
+ * Dashboard canvas content — renders an analytics dashboard.
2105
+ */
2106
+ export declare type DashboardCanvasContent = CanvasContentBase & {
2107
+ type: "dashboard";
2108
+ config: ChatDashboardConfig;
2109
+ apiConfig: {
2110
+ baseUrl: string;
2111
+ headers: Record<string, string>;
2112
+ };
2113
+ };
2114
+
2115
+ /**
2116
+ * Dashboard-specific card that wraps CanvasCard with config-store
2117
+ * subscription logic. Re-renders when the user edits and saves
2118
+ * the dashboard layout.
2119
+ */
2120
+ declare function DashboardCard({ config: originalConfig, onView, toolCallId, }: F0ChatReportCardProps): JSX_2.Element;
2121
+
2122
+ declare namespace DashboardCard {
2123
+ var displayName: string;
2124
+ }
2125
+
2068
2126
  /**
2069
2127
  * Chart display configuration — discriminated on `type`.
2070
2128
  * This object is JSON-serializable (no functions, except optional formatters).
@@ -3058,6 +3116,12 @@ export declare const defaultTranslations: {
3058
3116
  readonly dataDownload: {
3059
3117
  readonly download: "Download {{format}}";
3060
3118
  };
3119
+ readonly pong: {
3120
+ readonly ai: "AI";
3121
+ readonly you: "YOU";
3122
+ readonly youWin: "You win!";
3123
+ readonly youLose: "You lose!";
3124
+ };
3061
3125
  readonly growth: {
3062
3126
  readonly demoCard: {
3063
3127
  readonly title: "See {{moduleName}} in action";
@@ -4290,29 +4354,19 @@ compact?: boolean;
4290
4354
  export declare type F0CardProps = Omit<CardInternalProps, (typeof privateProps_3)[number]>;
4291
4355
 
4292
4356
  /**
4293
- * Compact card shown inline in the AI chat to represent a generated
4294
- * dashboard report. Uses F0Card with an icon avatar, the dashboard
4295
- * title/description, and an item summary in metadata. Clicking the
4296
- * card triggers `onView` to open the canvas panel.
4297
- *
4298
- * Subscribes to the external `savedDashboardConfigStore` via
4299
- * `useSyncExternalStore` so it re-renders when the user edits the
4300
- * dashboard layout and saves — independently of React context.
4357
+ * @deprecated Use `DashboardCard` from `canvas/entities/dashboard` directly.
4358
+ * This re-export exists for backwards compatibility.
4301
4359
  */
4302
- export declare function F0ChatReportCard({ config: originalConfig, onView, toolCallId, }: F0ChatReportCardProps): JSX_2.Element;
4360
+ export declare const F0ChatReportCard: typeof DashboardCard;
4303
4361
 
4304
- export declare namespace F0ChatReportCard {
4305
- var displayName: string;
4306
- }
4307
-
4308
- export declare interface F0ChatReportCardProps {
4362
+ export declare type F0ChatReportCardProps = {
4309
4363
  /** The original dashboard config from the agent */
4310
4364
  config: ChatDashboardConfig;
4311
4365
  /** Callback when the user clicks the card to view the report */
4312
4366
  onView: (config: ChatDashboardConfig) => void;
4313
4367
  /** Tool call ID used to look up saved (edited) dashboard configs */
4314
4368
  toolCallId?: string;
4315
- }
4369
+ };
4316
4370
 
4317
4371
  /**
4318
4372
  * @experimental This is an experimental component use it at your own risk
@@ -6729,6 +6783,12 @@ export declare const getAnimationVariants: (options?: AnimationVariantsOptions)
6729
6783
  };
6730
6784
  };
6731
6785
 
6786
+ /**
6787
+ * Look up a registered entity definition by content type.
6788
+ * Returns `undefined` if the type hasn't been registered.
6789
+ */
6790
+ export declare function getCanvasEntity(type: string): CanvasEntityDefinition<any> | undefined;
6791
+
6732
6792
  /**
6733
6793
  * Get the pagination type of a data adapter
6734
6794
  * @param dataAdapter - The data adapter to get the pagination type of
@@ -8530,6 +8590,12 @@ export declare type RecordType = Record<string, unknown>;
8530
8590
 
8531
8591
  declare type ReferenceType = "none" | "striped";
8532
8592
 
8593
+ /**
8594
+ * Register a canvas entity definition.
8595
+ * Called as a side-effect when each entity module is imported.
8596
+ */
8597
+ export declare function registerCanvasEntity<T extends CanvasContentBase>(definition: CanvasEntityDefinition<T>): void;
8598
+
8533
8599
  declare type RegularAction = BaseAction & {
8534
8600
  type: "regular";
8535
8601
  variant: ButtonVariant;
@@ -10355,8 +10421,10 @@ declare module "@tiptap/core" {
10355
10421
 
10356
10422
  declare module "@tiptap/core" {
10357
10423
  interface Commands<ReturnType> {
10358
- transcript: {
10359
- insertTranscript: (data: TranscriptData) => ReturnType;
10424
+ videoEmbed: {
10425
+ setVideoEmbed: (options: {
10426
+ src: string;
10427
+ }) => ReturnType;
10360
10428
  };
10361
10429
  }
10362
10430
  }
@@ -10364,10 +10432,8 @@ declare module "@tiptap/core" {
10364
10432
 
10365
10433
  declare module "@tiptap/core" {
10366
10434
  interface Commands<ReturnType> {
10367
- videoEmbed: {
10368
- setVideoEmbed: (options: {
10369
- src: string;
10370
- }) => ReturnType;
10435
+ transcript: {
10436
+ insertTranscript: (data: TranscriptData) => ReturnType;
10371
10437
  };
10372
10438
  }
10373
10439
  }