@factorialco/f0-react 1.413.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
@@ -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
  /**
@@ -1330,19 +1324,54 @@ declare type CalendarView = "day" | "month" | "year" | "week" | "quarter" | "hal
1330
1324
 
1331
1325
  /**
1332
1326
  * Discriminated union for canvas panel content.
1333
- * Expand this union to support new content types in the canvas.
1327
+ * Add new entity types to this union as they are implemented.
1334
1328
  */
1335
- export declare type CanvasContent = {
1336
- 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;
1337
1337
  title: string;
1338
- config: ChatDashboardConfig;
1339
- apiConfig: {
1340
- baseUrl: string;
1341
- headers: Record<string, string>;
1342
- };
1343
1338
  toolCallId?: string;
1344
1339
  };
1345
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
+
1346
1375
  declare type CardAvatarVariant = AvatarVariant | {
1347
1376
  type: "emoji";
1348
1377
  emoji: string;
@@ -2065,6 +2094,29 @@ declare interface CustomFieldRenderPropsBase {
2065
2094
 
2066
2095
  export declare const Dashboard: WithDataTestIdReturnType_3<ComponentType<DashboardProps_2> & PageLayoutGroupComponent_2>;
2067
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
+
2068
2120
  /**
2069
2121
  * Chart display configuration — discriminated on `type`.
2070
2122
  * This object is JSON-serializable (no functions, except optional formatters).
@@ -4290,29 +4342,19 @@ compact?: boolean;
4290
4342
  export declare type F0CardProps = Omit<CardInternalProps, (typeof privateProps_3)[number]>;
4291
4343
 
4292
4344
  /**
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.
4345
+ * @deprecated Use `DashboardCard` from `canvas/entities/dashboard` directly.
4346
+ * This re-export exists for backwards compatibility.
4301
4347
  */
4302
- export declare function F0ChatReportCard({ config: originalConfig, onView, toolCallId, }: F0ChatReportCardProps): JSX_2.Element;
4303
-
4304
- export declare namespace F0ChatReportCard {
4305
- var displayName: string;
4306
- }
4348
+ export declare const F0ChatReportCard: typeof DashboardCard;
4307
4349
 
4308
- export declare interface F0ChatReportCardProps {
4350
+ export declare type F0ChatReportCardProps = {
4309
4351
  /** The original dashboard config from the agent */
4310
4352
  config: ChatDashboardConfig;
4311
4353
  /** Callback when the user clicks the card to view the report */
4312
4354
  onView: (config: ChatDashboardConfig) => void;
4313
4355
  /** Tool call ID used to look up saved (edited) dashboard configs */
4314
4356
  toolCallId?: string;
4315
- }
4357
+ };
4316
4358
 
4317
4359
  /**
4318
4360
  * @experimental This is an experimental component use it at your own risk
@@ -6729,6 +6771,12 @@ export declare const getAnimationVariants: (options?: AnimationVariantsOptions)
6729
6771
  };
6730
6772
  };
6731
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
+
6732
6780
  /**
6733
6781
  * Get the pagination type of a data adapter
6734
6782
  * @param dataAdapter - The data adapter to get the pagination type of
@@ -8530,6 +8578,12 @@ export declare type RecordType = Record<string, unknown>;
8530
8578
 
8531
8579
  declare type ReferenceType = "none" | "striped";
8532
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
+
8533
8587
  declare type RegularAction = BaseAction & {
8534
8588
  type: "regular";
8535
8589
  variant: ButtonVariant;