@factorialco/f0-react 1.482.0 → 2.0.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.
@@ -522,6 +522,14 @@ declare type AiChatProviderProps = {
522
522
  * Provides save/create functions for persisting canvas entities externally.
523
523
  */
524
524
  canvasActions?: CanvasActions;
525
+ /**
526
+ * Canvas entity definitions keyed by `CanvasContent["type"]`. The canvas
527
+ * panel looks up the matching definition when `openCanvas` is called.
528
+ *
529
+ * F0AiChat ships without built-in canvas entities; the host app supplies
530
+ * them here so canvas logic lives in one place.
531
+ */
532
+ canvasEntities?: Record<string, CanvasEntityDefinition>;
525
533
  /**
526
534
  * Available tool hints that the user can activate to provide intent context
527
535
  * to the AI. Renders a selector button next to the send button.
@@ -1387,6 +1395,57 @@ declare type CanvasActions = {
1387
1395
  dashboard?: DashboardCanvasActions;
1388
1396
  };
1389
1397
 
1398
+ /**
1399
+ * Base shape shared by all canvas content types.
1400
+ * Every entity adds its own fields on top of this.
1401
+ */
1402
+ declare type CanvasContentBase = {
1403
+ type: string;
1404
+ title: string;
1405
+ description?: string;
1406
+ toolCallId?: string;
1407
+ };
1408
+
1409
+ /**
1410
+ * Contract for a canvas entity type.
1411
+ *
1412
+ * Each entity (dashboard, survey, goal, job-posting…) implements this
1413
+ * interface and is added to the `canvasEntities` record in `registry.ts`.
1414
+ *
1415
+ * To add a new entity type:
1416
+ * 1. Create a folder in `canvas/entities/<your-entity>/`
1417
+ * 2. Define a type extending `CanvasContentBase` in `types.ts`
1418
+ * 3. Implement and export `CanvasEntityDefinition` in `index.tsx`
1419
+ * 4. Add the entity to the record in `canvas/registry.ts`
1420
+ */
1421
+ declare type CanvasEntityDefinition<T extends CanvasContentBase = CanvasContentBase> = {
1422
+ /** Must match the `type` discriminant on the content object */
1423
+ type: T["type"];
1424
+ /** Renders the main body of the canvas panel */
1425
+ renderContent: (props: {
1426
+ content: T;
1427
+ refreshKey: number;
1428
+ }) => ReactNode;
1429
+ /** Renders the full header (title, actions, close button) */
1430
+ renderHeader: (props: {
1431
+ content: T;
1432
+ onClose: () => void;
1433
+ }) => ReactNode;
1434
+ /**
1435
+ * Optional wrapper providing entity-scoped context around
1436
+ * both header and body (e.g. shared edit-mode state).
1437
+ */
1438
+ wrapper?: (props: {
1439
+ content: T;
1440
+ children: ReactNode;
1441
+ }) => ReactNode;
1442
+ /**
1443
+ * When true the content area uses `overflow-hidden` instead of
1444
+ * `overflow-auto`, letting the entity manage its own scrolling.
1445
+ */
1446
+ overflowHidden?: boolean;
1447
+ };
1448
+
1390
1449
  declare type CardAvatarVariant = AvatarVariant | {
1391
1450
  type: "emoji";
1392
1451
  emoji: string;
@@ -8118,11 +8177,6 @@ declare module "gridstack" {
8118
8177
  }
8119
8178
 
8120
8179
 
8121
- declare namespace Calendar {
8122
- var displayName: string;
8123
- }
8124
-
8125
-
8126
8180
  declare module "@tiptap/core" {
8127
8181
  interface Commands<ReturnType> {
8128
8182
  aiBlock: {
@@ -8170,3 +8224,8 @@ declare module "@tiptap/core" {
8170
8224
  };
8171
8225
  }
8172
8226
  }
8227
+
8228
+
8229
+ declare namespace Calendar {
8230
+ var displayName: string;
8231
+ }