@papermap/papermap 1.1.1 → 1.1.2

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/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React$1 from 'react';
3
- import React__default, { ReactNode, RefObject } from 'react';
3
+ import React__default, { CSSProperties, ReactNode, RefObject } from 'react';
4
4
  import { Layout } from 'react-grid-layout';
5
5
  import { LucideIcon } from 'lucide-react';
6
6
  import * as class_variance_authority_types from 'class-variance-authority/types';
@@ -313,6 +313,16 @@ interface PaperChatSidePanelProps {
313
313
  embedChartDockRef?: React__default.MutableRefObject<HTMLDivElement | null>;
314
314
  /** Dialog embed: sync expanded/history fullscreen overlay foreground for Radix stack tiers. */
315
315
  onEmbedChartForegroundChange?: (foreground: boolean) => void;
316
+ /**
317
+ * Dialog embed: viewport pixels reserved by the chat dialog along its
318
+ * anchored horizontal edge. Forwarded to {@link FloatingChartOverlay} so the
319
+ * compact chart card opens 16px from the dialog.
320
+ */
321
+ embedDialogReservedSidePx?: number;
322
+ /** Dialog embed: viewport edge the chat dialog is anchored to vertically. */
323
+ embedDialogVerticalAnchor?: 'top' | 'bottom';
324
+ /** Dialog embed: dialog's vertical anchor inset from the viewport edge in px. */
325
+ embedDialogVerticalInsetPx?: number;
316
326
  /**
317
327
  * Whether to render user / assistant avatars (User icon and Papermap logo)
318
328
  * in message bubbles. Defaults to `true` for this surface — the side rail
@@ -381,6 +391,16 @@ interface PaperChatFloatingChartOverlayProps {
381
391
  embedChartDockRef?: React__default.MutableRefObject<HTMLDivElement | null>;
382
392
  /** Dialog embed: expanded or history fullscreen should stack above chat and lower dialog chrome. */
383
393
  onEmbedChartForegroundChange?: (foreground: boolean) => void;
394
+ /**
395
+ * Dialog embed: viewport pixels reserved by the chat dialog along its anchored
396
+ * horizontal edge (corner inset + dialog width). The compact chart card uses
397
+ * this to anchor itself 16px away from the dialog's chat-facing edge.
398
+ */
399
+ embedDialogReservedSidePx?: number;
400
+ /** Dialog embed: which viewport edge the chat dialog is anchored to vertically. */
401
+ embedDialogVerticalAnchor?: 'top' | 'bottom';
402
+ /** Dialog embed: dialog's vertical anchor inset from the viewport edge in px. */
403
+ embedDialogVerticalInsetPx?: number;
384
404
  }
385
405
  declare function PaperChatFloatingChartOverlay({ token, workspaceId, dashboardId, apiUrl, initialChatScroll, isViewer, assistantInline, theme, ...overlayProps }: PaperChatFloatingChartOverlayProps): react_jsx_runtime.JSX.Element;
386
406
  /** Backward-compatible alias. Prefer `PaperChatFloatingChartOverlay`. */
@@ -582,6 +602,154 @@ interface PaperCardProps {
582
602
  }
583
603
  declare function PaperCard({ token: tokenProp, workspaceId: workspaceIdProp, dashboardId: dashboardIdProp, apiUrl: apiUrlProp, id, onSave, onPinnedToDashboard, onAssistantClosed, chartId, chart: chartProp, theme, onEditClick, onDelete, isViewer, wide, hideVariants, showToolbar, isEditMode, className, variant, hideStreamingEmptySubtext, dashboardTheme, }: PaperCardProps): react_jsx_runtime.JSX.Element;
584
604
 
605
+ /**
606
+ * Mirrors the main app's `insight` SSE payload — driven by the same
607
+ * `dashboards/:id/insights/stream` endpoint.
608
+ */
609
+ type DashboardInsightType = 'highlight' | 'trends' | 'recommendation';
610
+ interface DashboardInsight {
611
+ id: string;
612
+ insightType: DashboardInsightType;
613
+ headline: string;
614
+ body: string;
615
+ /** Opaque string. For `trends`, often `"<upside> | <downside>"` (split only on ` | `). */
616
+ metric: string | null;
617
+ /** Linked chat id for "Explore in chat" deep links. Omitted when `error`. */
618
+ chatId?: string;
619
+ error?: boolean;
620
+ }
621
+ interface DashboardInsightsResult {
622
+ insights: DashboardInsight[];
623
+ generationTime?: number;
624
+ }
625
+ interface StreamDashboardInsightsOptions {
626
+ dashboardId: string;
627
+ /** Inclusive start of the period. Accepts a `Date` or `yyyy-MM-dd` string. */
628
+ startDate: Date | string;
629
+ /** Inclusive end of the period. Accepts a `Date` or `yyyy-MM-dd` string. */
630
+ endDate: Date | string;
631
+ authHeaders: Record<string, string>;
632
+ apiUrl?: string;
633
+ /** Extra fields merged into the POST body. */
634
+ extraBody?: Record<string, unknown>;
635
+ /** Fired when the server emits `insights_started` — clear UI state here. */
636
+ onStarted?: () => void;
637
+ /** Fired once per `insight` SSE event with the parsed insight. */
638
+ onInsight?: (insight: DashboardInsight) => void;
639
+ /** Fired when the server emits `insights_complete`. */
640
+ onComplete?: (result: DashboardInsightsResult) => void;
641
+ /** Fired on transport error or an `error` SSE event. */
642
+ onError?: (error: Error) => void;
643
+ signal?: AbortSignal;
644
+ }
645
+ declare function normalizeInsightType(raw: unknown): DashboardInsightType;
646
+ /** Stable display order (recommendation → highlight → trends). Preserves order within each type. */
647
+ declare function orderInsightsForDisplay(insights: DashboardInsight[]): DashboardInsight[];
648
+ /** Format a `Date` (or pass through a string) into `yyyy-MM-dd`. */
649
+ declare function formatInsightDate(value: Date | string): string;
650
+ /**
651
+ * Opens the dashboard insights SSE stream and dispatches the main app's
652
+ * named events (`insights_started`, `insight`, `insights_complete`, `error`)
653
+ * to the supplied callbacks. Returns `{ abort }` for lifecycle control.
654
+ */
655
+ declare function streamDashboardInsights(options: StreamDashboardInsightsOptions): {
656
+ abort: () => void;
657
+ };
658
+ /** Pull a numeric percentage out of a `metric` string. Returns `null` when nothing parseable. */
659
+ declare function parseInsightMetricToTrend(metric: string | null | undefined): number | null;
660
+
661
+ /** Quick Insights period dropdown + timeline sync (not SSE `insight.type`). Mirrors main app. */
662
+ type InsightsPeriodPreset = 'last_3_months' | 'this_week' | 'this_month' | 'this_year' | 'custom';
663
+ type InsightsPeriodMenuPreset = Exclude<InsightsPeriodPreset, 'custom'>;
664
+ declare const INSIGHTS_PERIOD_LABELS: Record<InsightsPeriodPreset, string>;
665
+ declare const INSIGHTS_PERIOD_SELECT_OPTIONS: InsightsPeriodPreset[];
666
+ /** Preset → [start, end]; end is always "now". */
667
+ declare function computeInsightsPeriodRange(preset: InsightsPeriodMenuPreset, now?: Date): {
668
+ start: Date;
669
+ end: Date;
670
+ };
671
+ /** "Apr 25 – May 25, 2026" — matches main app `format(d, 'MMM d') – format(d, 'MMM d, yyyy')`. */
672
+ declare function formatInsightsDateLabel(start: Date | undefined, end: Date | undefined): string | null;
673
+
674
+ /** Named slots a host can target with `classNames` / `styles`. */
675
+ type PaperInsightSlot = 'root' | 'header' | 'headerInner' | 'titleGroup' | 'icon' | 'title' | 'spinner' | 'loadingText' | 'dateLabel' | 'actions' | 'periodSelect' | 'refreshButton' | 'body' | 'list' | 'row' | 'rowIcon' | 'rowHeadline' | 'rowBody' | 'rowMetric' | 'exploreButton' | 'skeleton' | 'emptyState' | 'footer';
676
+ type PaperInsightClassNames = Partial<Record<PaperInsightSlot, string>>;
677
+ type PaperInsightStyles = Partial<Record<PaperInsightSlot, CSSProperties>>;
678
+ interface PaperInsightProps {
679
+ /** Inclusive start of the period. `Date` or `yyyy-MM-dd` string. */
680
+ startDate?: Date | string;
681
+ /** Inclusive end of the period. `Date` or `yyyy-MM-dd` string. */
682
+ endDate?: Date | string;
683
+ /** Dashboard id. Falls back to the surrounding `PapermapProvider`. */
684
+ dashboardId?: string;
685
+ /** Connection (falls back to surrounding `PapermapProvider`). */
686
+ token?: string;
687
+ workspaceId?: string;
688
+ apiUrl?: string;
689
+ theme?: 'light' | 'dark' | 'system';
690
+ /** Themed dashboard styling (mirrors main app `dashboardTheme` mark color). */
691
+ dashboardTheme?: DashboardTheme | null;
692
+ /** Root element class. Merged after built-in classes. */
693
+ className?: string;
694
+ /** Root element inline style. */
695
+ style?: CSSProperties;
696
+ /** Per-slot class overrides (header, title, refreshButton, row, body, etc.). */
697
+ classNames?: PaperInsightClassNames;
698
+ /** Per-slot inline style overrides. */
699
+ styles?: PaperInsightStyles;
700
+ /** Disables interactions while the host's grid is in layout-edit mode. */
701
+ isEditMode?: boolean;
702
+ /**
703
+ * Period preset. Optional in standalone use — when omitted, the panel manages
704
+ * its own preset (defaults to `'last_3_months'`) and shows the dropdown so the
705
+ * user can switch range. Pass a value to control externally.
706
+ */
707
+ periodPreset?: InsightsPeriodPreset;
708
+ onPeriodPresetChange?: (preset: InsightsPeriodPreset) => void;
709
+ /** Hide the period dropdown entirely (e.g. host renders its own period picker). */
710
+ hidePeriodSelect?: boolean;
711
+ /**
712
+ * Fired when the user drags the inline custom-range scrubber. Required for the
713
+ * scrubber to function when `periodPreset === 'custom'` — the host owns the
714
+ * `startDate`/`endDate` state.
715
+ */
716
+ onRangeChange?: (start: Date, end: Date) => void;
717
+ /**
718
+ * Show the inline `TimelineRange` scrubber when `periodPreset === 'custom'`.
719
+ * Defaults to `true` for standalone use. Set `false` when a parent (e.g.
720
+ * `PaperBoard`) renders its own scrubber outside the panel.
721
+ */
722
+ showCustomRangeScrubber?: boolean;
723
+ /**
724
+ * Enable the "Custom range" option (dropdown entry + scrubber). Defaults to
725
+ * `true` for standalone use. Set `false` to remove the custom-range entry
726
+ * from the period dropdown and hide the scrubber entirely.
727
+ */
728
+ enableCustomRange?: boolean;
729
+ /** Click handler for the per-row "Explore in Chat" arrow. */
730
+ onExplore?: (chatId: string) => void;
731
+ /**
732
+ * When `true` and no `onExplore` handler is provided, clicking the per-row
733
+ * "Explore in Chat" arrow opens the Papermap chat assistant focused on the
734
+ * insight's linked chat. Requires a surrounding `PapermapProvider`. Defaults
735
+ * to `false`.
736
+ */
737
+ openChatAssistantOnExplore?: boolean;
738
+ /** Fired on each insight event. */
739
+ onInsight?: (insight: DashboardInsight) => void;
740
+ /** Fired when the stream completes. */
741
+ onComplete?: (result: DashboardInsightsResult) => void;
742
+ /** Fired on a stream error. */
743
+ onError?: (error: Error) => void;
744
+ }
745
+ declare function PaperInsight({ startDate, endDate, dashboardId: dashboardIdProp, token: tokenProp, workspaceId: workspaceIdProp, apiUrl: apiUrlProp, theme, dashboardTheme, className, style, classNames, styles, isEditMode, periodPreset, onPeriodPresetChange, hidePeriodSelect, onRangeChange, showCustomRangeScrubber, enableCustomRange, onExplore, openChatAssistantOnExplore, onInsight, onComplete, onError, }: PaperInsightProps): react_jsx_runtime.JSX.Element;
746
+
747
+ /**
748
+ * Stable grid id for the dashboard insight tile. Mirrors the main app's
749
+ * `TIMELINE_INSIGHTS_GRID_ID`; the prefix avoids colliding with chart chat ids.
750
+ */
751
+ declare const PAPER_INSIGHT_GRID_ID = "__papermap_insight_panel__";
752
+
585
753
  interface AgentThought {
586
754
  type: 'agent_thought';
587
755
  content: string;
@@ -1517,7 +1685,7 @@ interface OpenPapermapChatAssistantOptions {
1517
1685
  declare function openPapermapChatAssistant(storeApi: PapermapStoreApi, options?: OpenPapermapChatAssistantOptions): void;
1518
1686
 
1519
1687
  /** Mirrors `package.json` version; run `npm run sync:sdk-version` or `npm run build` to refresh. */
1520
- declare const PAPERMAP_SDK_VERSION: "1.1.1";
1688
+ declare const PAPERMAP_SDK_VERSION: "1.1.2";
1521
1689
  /** Contract revision for hosts that gate advanced features; bump only for breaking contract changes. */
1522
1690
  declare const PAPERMAP_PLUGIN_CONTRACT_VERSION: 1;
1523
1691
  type PapermapCapability = 'chat' | 'charts' | 'dashboard' | 'streaming' | 'workspace' | (string & {});
@@ -1838,9 +2006,36 @@ interface PaperBoardProps {
1838
2006
  /** Default: Papermap web app origin. */
1839
2007
  logoutUrl?: string;
1840
2008
  appHeaderRightSlot?: ReactNode;
2009
+ /**
2010
+ * Mount the dashboard insight tile (mirrors main app `TimelineInsights`).
2011
+ * The tile is injected at the top of every breakpoint layout via
2012
+ * `ensurePaperInsightLayoutItem`. Default `false`.
2013
+ */
2014
+ showInsights?: boolean;
2015
+ /**
2016
+ * Initial / controlled period for the insight tile. Defaults to `'last_3_months'`
2017
+ * when uncontrolled. Selecting `'custom'` keeps the host's existing range.
2018
+ */
2019
+ insightsPeriodPreset?: InsightsPeriodPreset;
2020
+ onInsightsPeriodPresetChange?: (preset: InsightsPeriodPreset) => void;
2021
+ /**
2022
+ * Explicit date range for the insight tile. Overrides the auto-computed range
2023
+ * from the preset (use this together with `'custom'` for timeline-scrubbed ranges).
2024
+ */
2025
+ insightsStartDate?: Date | string;
2026
+ insightsEndDate?: Date | string;
2027
+ /** Click handler for the per-insight "Explore in Chat" arrow. */
2028
+ onInsightExplore?: (chatId: string) => void;
1841
2029
  }
1842
2030
  declare function PaperBoard({ token, workspaceId, dashboardId, apiUrl, theme, showWorkspaceDashboardSelect, onWorkspaceDashboardChange, showAppChrome, navItems: navItemsProp, user: userProp, onLogout, billingHref, settingsHref, logoutUrl, appHeaderRightSlot, ...rest }: PaperBoardProps): react_jsx_runtime.JSX.Element;
1843
2031
 
2032
+ /**
2033
+ * Mirrors the main app's `ensureTimelineInsightsLayoutItem`. Injects a layout slot
2034
+ * for the dashboard insight tile across every breakpoint if one isn't already
2035
+ * present. No-op for breakpoints that already include `gridId`.
2036
+ */
2037
+ declare function ensurePaperInsightLayoutItem(layouts: PaperBoardLayouts, gridId: string, defaults?: Partial<TLayout>): PaperBoardLayouts;
2038
+
1844
2039
  declare function readDashboardTourCompleted(key: string): boolean;
1845
2040
  declare function markDashboardTourCompleted(key: string): void;
1846
2041
  type BuildDashboardTourStepsOptions = {
@@ -1948,4 +2143,4 @@ declare function resolveChartFetchChatId(params: {
1948
2143
  dashboardId?: string;
1949
2144
  }): string | undefined;
1950
2145
 
1951
- export { type AgentThought, AgentThoughtDisplay, BookmarkButton, BranchButton, type BuildDashboardNavItemsParams, ButtonWithTooltip, CHART_CARD_CHAT_MAP_KEY, CHAT_MODAL_TAB, type ChartCardIdLink, type ChartCardStorageNamespace, type ChartDataRow, ChartDialog, ChartHistory, type ChartResponse, ChartView, type ChartVisualizationConfig, ChatAssistant, type ChatModalTabType, ChatSidePanel, type ConversationHistory, CreateDashboardDialog, type CreateDashboardDialogProps, CreateUnifiedWorkspaceDialog, type CreateUnifiedWorkspaceDialogProps, type CreatedDashboard, type CreatedUnifiedWorkspace, DashboardAppHeader, type DashboardNavbarItem, DashboardTabNavigation, type DashboardTabNavigationProps, type DashboardTheme, DataTable, type DecodedToken, FeedbackButtons, type FinalResponse, FloatingChartOverlay, IntegrationsBar, type JsonObject, LogoStandAlone, type Message, type MessageProgressEvent, ModelSelector, MorphGradient, type OpenPapermapChatAssistantOptions, PAPERMAP_CHAT_GREETING_MESSAGE, PAPERMAP_PLUGIN_CONTRACT_VERSION, PAPERMAP_SDK_VERSION, PaperBoard, type TLayout as PaperBoardLayoutItem, type PaperBoardLayouts, PaperCard, type PaperCardProps, PaperChat, type PaperChatAvatars, PaperChatDialogInner, type PaperChatDialogInnerProps, type PaperChatDialogLauncherPosition, PaperChatFloatingChartOverlay, type PaperChatFloatingChartOverlayProps, type PaperChatProps, PaperChatSidePanel, type PaperChatSidePanelProps, type PaperChatSidePosition, type PaperChatVariant, PaperDashboardSelect, type PaperDashboardSelectProps, type PapermapActions, type PapermapCapability, type PapermapColorScheme, PapermapProvider as PapermapConfigProvider, type PapermapConnectionValue, type PapermapHttpServices, type PapermapObservability, type PapermapObservabilityOptions, type PapermapPluginContext, type PapermapPluginLifecycle, type PapermapPluginManifest, type PapermapPluginRegistration, PapermapProvider, type PapermapState, type PapermapStore, type PapermapStoreApi, type PapermapStoreConfig, type PapermapTelemetryEvent, type PapermapTelemetryLevel, RecentConversations, SavedMemory, type StreamState, StreamingChartDialog, StreamingChatPanel, StreamingTimeline, type TChartMeta$1 as TChartMeta, type TChartResponse, ThemeCustomizationSettings, type ThemeCustomizationSettingsProps, type ThemePreset, type ThemeSaveMeta, type TimelineEvent, type ToolCall, ToolCallDisplay, type TourStep, type UseTourOptions, UserNav, type WorkspaceEntity, type WorkspaceMeta, WorkspaceSelector, type WorkspaceSelectorControl, WorkspaceSelectorProvider, buildAuthHeaders, buildDashboardNavItems, buildDashboardTourSteps, checkPluginPeerCompatibility, createApiClient, createPapermapObservability, createPapermapServices, createPapermapStore, createPluginContext, decodeToken, defaultTheme, getChartCardIdLink, markDashboardTourCompleted, openPapermapChatAssistant, papermapApiBaseSegment, papermapQueryKeys, parseSemverPrefix, presetDisplayNames, readDashboardTourCompleted, removeChartCardIdLink, resolveChartFetchChatId, resolveDashboardThemeFromWorkspace, themePresetList, themePresets, unwrapWorkspacePayload, upsertChartCardIdLink, useAnalyticsStream, useAutoFade, useAutoResize, useKeyboardShortcuts, usePapermapConnection, usePapermapConnectionOptional, usePapermapStore, usePapermapStoreApi, usePapermapStoreApiOptional, useTour };
2146
+ export { type AgentThought, AgentThoughtDisplay, BookmarkButton, BranchButton, type BuildDashboardNavItemsParams, ButtonWithTooltip, CHART_CARD_CHAT_MAP_KEY, CHAT_MODAL_TAB, type ChartCardIdLink, type ChartCardStorageNamespace, type ChartDataRow, ChartDialog, ChartHistory, type ChartResponse, ChartView, type ChartVisualizationConfig, ChatAssistant, type ChatModalTabType, ChatSidePanel, type ConversationHistory, CreateDashboardDialog, type CreateDashboardDialogProps, CreateUnifiedWorkspaceDialog, type CreateUnifiedWorkspaceDialogProps, type CreatedDashboard, type CreatedUnifiedWorkspace, DashboardAppHeader, type DashboardInsight, type DashboardInsightType, type DashboardInsightsResult, type DashboardNavbarItem, DashboardTabNavigation, type DashboardTabNavigationProps, type DashboardTheme, DataTable, type DecodedToken, FeedbackButtons, type FinalResponse, FloatingChartOverlay, INSIGHTS_PERIOD_LABELS, INSIGHTS_PERIOD_SELECT_OPTIONS, type InsightsPeriodMenuPreset, type InsightsPeriodPreset, IntegrationsBar, type JsonObject, LogoStandAlone, type Message, type MessageProgressEvent, ModelSelector, MorphGradient, type OpenPapermapChatAssistantOptions, PAPERMAP_CHAT_GREETING_MESSAGE, PAPERMAP_PLUGIN_CONTRACT_VERSION, PAPERMAP_SDK_VERSION, PAPER_INSIGHT_GRID_ID, PaperBoard, type TLayout as PaperBoardLayoutItem, type PaperBoardLayouts, PaperCard, type PaperCardProps, PaperChat, type PaperChatAvatars, PaperChatDialogInner, type PaperChatDialogInnerProps, type PaperChatDialogLauncherPosition, PaperChatFloatingChartOverlay, type PaperChatFloatingChartOverlayProps, type PaperChatProps, PaperChatSidePanel, type PaperChatSidePanelProps, type PaperChatSidePosition, type PaperChatVariant, PaperDashboardSelect, type PaperDashboardSelectProps, PaperInsight, type PaperInsightClassNames, type PaperInsightProps, type PaperInsightSlot, type PaperInsightStyles, type PapermapActions, type PapermapCapability, type PapermapColorScheme, PapermapProvider as PapermapConfigProvider, type PapermapConnectionValue, type PapermapHttpServices, type PapermapObservability, type PapermapObservabilityOptions, type PapermapPluginContext, type PapermapPluginLifecycle, type PapermapPluginManifest, type PapermapPluginRegistration, PapermapProvider, type PapermapState, type PapermapStore, type PapermapStoreApi, type PapermapStoreConfig, type PapermapTelemetryEvent, type PapermapTelemetryLevel, RecentConversations, SavedMemory, type StreamDashboardInsightsOptions, type StreamState, StreamingChartDialog, StreamingChatPanel, StreamingTimeline, type TChartMeta$1 as TChartMeta, type TChartResponse, ThemeCustomizationSettings, type ThemeCustomizationSettingsProps, type ThemePreset, type ThemeSaveMeta, type TimelineEvent, type ToolCall, ToolCallDisplay, type TourStep, type UseTourOptions, UserNav, type WorkspaceEntity, type WorkspaceMeta, WorkspaceSelector, type WorkspaceSelectorControl, WorkspaceSelectorProvider, buildAuthHeaders, buildDashboardNavItems, buildDashboardTourSteps, checkPluginPeerCompatibility, computeInsightsPeriodRange, createApiClient, createPapermapObservability, createPapermapServices, createPapermapStore, createPluginContext, decodeToken, defaultTheme, ensurePaperInsightLayoutItem, formatInsightDate, formatInsightsDateLabel, getChartCardIdLink, markDashboardTourCompleted, normalizeInsightType, openPapermapChatAssistant, orderInsightsForDisplay, papermapApiBaseSegment, papermapQueryKeys, parseInsightMetricToTrend, parseSemverPrefix, presetDisplayNames, readDashboardTourCompleted, removeChartCardIdLink, resolveChartFetchChatId, resolveDashboardThemeFromWorkspace, streamDashboardInsights, themePresetList, themePresets, unwrapWorkspacePayload, upsertChartCardIdLink, useAnalyticsStream, useAutoFade, useAutoResize, useKeyboardShortcuts, usePapermapConnection, usePapermapConnectionOptional, usePapermapStore, usePapermapStoreApi, usePapermapStoreApiOptional, useTour };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React$1 from 'react';
3
- import React__default, { ReactNode, RefObject } from 'react';
3
+ import React__default, { CSSProperties, ReactNode, RefObject } from 'react';
4
4
  import { Layout } from 'react-grid-layout';
5
5
  import { LucideIcon } from 'lucide-react';
6
6
  import * as class_variance_authority_types from 'class-variance-authority/types';
@@ -313,6 +313,16 @@ interface PaperChatSidePanelProps {
313
313
  embedChartDockRef?: React__default.MutableRefObject<HTMLDivElement | null>;
314
314
  /** Dialog embed: sync expanded/history fullscreen overlay foreground for Radix stack tiers. */
315
315
  onEmbedChartForegroundChange?: (foreground: boolean) => void;
316
+ /**
317
+ * Dialog embed: viewport pixels reserved by the chat dialog along its
318
+ * anchored horizontal edge. Forwarded to {@link FloatingChartOverlay} so the
319
+ * compact chart card opens 16px from the dialog.
320
+ */
321
+ embedDialogReservedSidePx?: number;
322
+ /** Dialog embed: viewport edge the chat dialog is anchored to vertically. */
323
+ embedDialogVerticalAnchor?: 'top' | 'bottom';
324
+ /** Dialog embed: dialog's vertical anchor inset from the viewport edge in px. */
325
+ embedDialogVerticalInsetPx?: number;
316
326
  /**
317
327
  * Whether to render user / assistant avatars (User icon and Papermap logo)
318
328
  * in message bubbles. Defaults to `true` for this surface — the side rail
@@ -381,6 +391,16 @@ interface PaperChatFloatingChartOverlayProps {
381
391
  embedChartDockRef?: React__default.MutableRefObject<HTMLDivElement | null>;
382
392
  /** Dialog embed: expanded or history fullscreen should stack above chat and lower dialog chrome. */
383
393
  onEmbedChartForegroundChange?: (foreground: boolean) => void;
394
+ /**
395
+ * Dialog embed: viewport pixels reserved by the chat dialog along its anchored
396
+ * horizontal edge (corner inset + dialog width). The compact chart card uses
397
+ * this to anchor itself 16px away from the dialog's chat-facing edge.
398
+ */
399
+ embedDialogReservedSidePx?: number;
400
+ /** Dialog embed: which viewport edge the chat dialog is anchored to vertically. */
401
+ embedDialogVerticalAnchor?: 'top' | 'bottom';
402
+ /** Dialog embed: dialog's vertical anchor inset from the viewport edge in px. */
403
+ embedDialogVerticalInsetPx?: number;
384
404
  }
385
405
  declare function PaperChatFloatingChartOverlay({ token, workspaceId, dashboardId, apiUrl, initialChatScroll, isViewer, assistantInline, theme, ...overlayProps }: PaperChatFloatingChartOverlayProps): react_jsx_runtime.JSX.Element;
386
406
  /** Backward-compatible alias. Prefer `PaperChatFloatingChartOverlay`. */
@@ -582,6 +602,154 @@ interface PaperCardProps {
582
602
  }
583
603
  declare function PaperCard({ token: tokenProp, workspaceId: workspaceIdProp, dashboardId: dashboardIdProp, apiUrl: apiUrlProp, id, onSave, onPinnedToDashboard, onAssistantClosed, chartId, chart: chartProp, theme, onEditClick, onDelete, isViewer, wide, hideVariants, showToolbar, isEditMode, className, variant, hideStreamingEmptySubtext, dashboardTheme, }: PaperCardProps): react_jsx_runtime.JSX.Element;
584
604
 
605
+ /**
606
+ * Mirrors the main app's `insight` SSE payload — driven by the same
607
+ * `dashboards/:id/insights/stream` endpoint.
608
+ */
609
+ type DashboardInsightType = 'highlight' | 'trends' | 'recommendation';
610
+ interface DashboardInsight {
611
+ id: string;
612
+ insightType: DashboardInsightType;
613
+ headline: string;
614
+ body: string;
615
+ /** Opaque string. For `trends`, often `"<upside> | <downside>"` (split only on ` | `). */
616
+ metric: string | null;
617
+ /** Linked chat id for "Explore in chat" deep links. Omitted when `error`. */
618
+ chatId?: string;
619
+ error?: boolean;
620
+ }
621
+ interface DashboardInsightsResult {
622
+ insights: DashboardInsight[];
623
+ generationTime?: number;
624
+ }
625
+ interface StreamDashboardInsightsOptions {
626
+ dashboardId: string;
627
+ /** Inclusive start of the period. Accepts a `Date` or `yyyy-MM-dd` string. */
628
+ startDate: Date | string;
629
+ /** Inclusive end of the period. Accepts a `Date` or `yyyy-MM-dd` string. */
630
+ endDate: Date | string;
631
+ authHeaders: Record<string, string>;
632
+ apiUrl?: string;
633
+ /** Extra fields merged into the POST body. */
634
+ extraBody?: Record<string, unknown>;
635
+ /** Fired when the server emits `insights_started` — clear UI state here. */
636
+ onStarted?: () => void;
637
+ /** Fired once per `insight` SSE event with the parsed insight. */
638
+ onInsight?: (insight: DashboardInsight) => void;
639
+ /** Fired when the server emits `insights_complete`. */
640
+ onComplete?: (result: DashboardInsightsResult) => void;
641
+ /** Fired on transport error or an `error` SSE event. */
642
+ onError?: (error: Error) => void;
643
+ signal?: AbortSignal;
644
+ }
645
+ declare function normalizeInsightType(raw: unknown): DashboardInsightType;
646
+ /** Stable display order (recommendation → highlight → trends). Preserves order within each type. */
647
+ declare function orderInsightsForDisplay(insights: DashboardInsight[]): DashboardInsight[];
648
+ /** Format a `Date` (or pass through a string) into `yyyy-MM-dd`. */
649
+ declare function formatInsightDate(value: Date | string): string;
650
+ /**
651
+ * Opens the dashboard insights SSE stream and dispatches the main app's
652
+ * named events (`insights_started`, `insight`, `insights_complete`, `error`)
653
+ * to the supplied callbacks. Returns `{ abort }` for lifecycle control.
654
+ */
655
+ declare function streamDashboardInsights(options: StreamDashboardInsightsOptions): {
656
+ abort: () => void;
657
+ };
658
+ /** Pull a numeric percentage out of a `metric` string. Returns `null` when nothing parseable. */
659
+ declare function parseInsightMetricToTrend(metric: string | null | undefined): number | null;
660
+
661
+ /** Quick Insights period dropdown + timeline sync (not SSE `insight.type`). Mirrors main app. */
662
+ type InsightsPeriodPreset = 'last_3_months' | 'this_week' | 'this_month' | 'this_year' | 'custom';
663
+ type InsightsPeriodMenuPreset = Exclude<InsightsPeriodPreset, 'custom'>;
664
+ declare const INSIGHTS_PERIOD_LABELS: Record<InsightsPeriodPreset, string>;
665
+ declare const INSIGHTS_PERIOD_SELECT_OPTIONS: InsightsPeriodPreset[];
666
+ /** Preset → [start, end]; end is always "now". */
667
+ declare function computeInsightsPeriodRange(preset: InsightsPeriodMenuPreset, now?: Date): {
668
+ start: Date;
669
+ end: Date;
670
+ };
671
+ /** "Apr 25 – May 25, 2026" — matches main app `format(d, 'MMM d') – format(d, 'MMM d, yyyy')`. */
672
+ declare function formatInsightsDateLabel(start: Date | undefined, end: Date | undefined): string | null;
673
+
674
+ /** Named slots a host can target with `classNames` / `styles`. */
675
+ type PaperInsightSlot = 'root' | 'header' | 'headerInner' | 'titleGroup' | 'icon' | 'title' | 'spinner' | 'loadingText' | 'dateLabel' | 'actions' | 'periodSelect' | 'refreshButton' | 'body' | 'list' | 'row' | 'rowIcon' | 'rowHeadline' | 'rowBody' | 'rowMetric' | 'exploreButton' | 'skeleton' | 'emptyState' | 'footer';
676
+ type PaperInsightClassNames = Partial<Record<PaperInsightSlot, string>>;
677
+ type PaperInsightStyles = Partial<Record<PaperInsightSlot, CSSProperties>>;
678
+ interface PaperInsightProps {
679
+ /** Inclusive start of the period. `Date` or `yyyy-MM-dd` string. */
680
+ startDate?: Date | string;
681
+ /** Inclusive end of the period. `Date` or `yyyy-MM-dd` string. */
682
+ endDate?: Date | string;
683
+ /** Dashboard id. Falls back to the surrounding `PapermapProvider`. */
684
+ dashboardId?: string;
685
+ /** Connection (falls back to surrounding `PapermapProvider`). */
686
+ token?: string;
687
+ workspaceId?: string;
688
+ apiUrl?: string;
689
+ theme?: 'light' | 'dark' | 'system';
690
+ /** Themed dashboard styling (mirrors main app `dashboardTheme` mark color). */
691
+ dashboardTheme?: DashboardTheme | null;
692
+ /** Root element class. Merged after built-in classes. */
693
+ className?: string;
694
+ /** Root element inline style. */
695
+ style?: CSSProperties;
696
+ /** Per-slot class overrides (header, title, refreshButton, row, body, etc.). */
697
+ classNames?: PaperInsightClassNames;
698
+ /** Per-slot inline style overrides. */
699
+ styles?: PaperInsightStyles;
700
+ /** Disables interactions while the host's grid is in layout-edit mode. */
701
+ isEditMode?: boolean;
702
+ /**
703
+ * Period preset. Optional in standalone use — when omitted, the panel manages
704
+ * its own preset (defaults to `'last_3_months'`) and shows the dropdown so the
705
+ * user can switch range. Pass a value to control externally.
706
+ */
707
+ periodPreset?: InsightsPeriodPreset;
708
+ onPeriodPresetChange?: (preset: InsightsPeriodPreset) => void;
709
+ /** Hide the period dropdown entirely (e.g. host renders its own period picker). */
710
+ hidePeriodSelect?: boolean;
711
+ /**
712
+ * Fired when the user drags the inline custom-range scrubber. Required for the
713
+ * scrubber to function when `periodPreset === 'custom'` — the host owns the
714
+ * `startDate`/`endDate` state.
715
+ */
716
+ onRangeChange?: (start: Date, end: Date) => void;
717
+ /**
718
+ * Show the inline `TimelineRange` scrubber when `periodPreset === 'custom'`.
719
+ * Defaults to `true` for standalone use. Set `false` when a parent (e.g.
720
+ * `PaperBoard`) renders its own scrubber outside the panel.
721
+ */
722
+ showCustomRangeScrubber?: boolean;
723
+ /**
724
+ * Enable the "Custom range" option (dropdown entry + scrubber). Defaults to
725
+ * `true` for standalone use. Set `false` to remove the custom-range entry
726
+ * from the period dropdown and hide the scrubber entirely.
727
+ */
728
+ enableCustomRange?: boolean;
729
+ /** Click handler for the per-row "Explore in Chat" arrow. */
730
+ onExplore?: (chatId: string) => void;
731
+ /**
732
+ * When `true` and no `onExplore` handler is provided, clicking the per-row
733
+ * "Explore in Chat" arrow opens the Papermap chat assistant focused on the
734
+ * insight's linked chat. Requires a surrounding `PapermapProvider`. Defaults
735
+ * to `false`.
736
+ */
737
+ openChatAssistantOnExplore?: boolean;
738
+ /** Fired on each insight event. */
739
+ onInsight?: (insight: DashboardInsight) => void;
740
+ /** Fired when the stream completes. */
741
+ onComplete?: (result: DashboardInsightsResult) => void;
742
+ /** Fired on a stream error. */
743
+ onError?: (error: Error) => void;
744
+ }
745
+ declare function PaperInsight({ startDate, endDate, dashboardId: dashboardIdProp, token: tokenProp, workspaceId: workspaceIdProp, apiUrl: apiUrlProp, theme, dashboardTheme, className, style, classNames, styles, isEditMode, periodPreset, onPeriodPresetChange, hidePeriodSelect, onRangeChange, showCustomRangeScrubber, enableCustomRange, onExplore, openChatAssistantOnExplore, onInsight, onComplete, onError, }: PaperInsightProps): react_jsx_runtime.JSX.Element;
746
+
747
+ /**
748
+ * Stable grid id for the dashboard insight tile. Mirrors the main app's
749
+ * `TIMELINE_INSIGHTS_GRID_ID`; the prefix avoids colliding with chart chat ids.
750
+ */
751
+ declare const PAPER_INSIGHT_GRID_ID = "__papermap_insight_panel__";
752
+
585
753
  interface AgentThought {
586
754
  type: 'agent_thought';
587
755
  content: string;
@@ -1517,7 +1685,7 @@ interface OpenPapermapChatAssistantOptions {
1517
1685
  declare function openPapermapChatAssistant(storeApi: PapermapStoreApi, options?: OpenPapermapChatAssistantOptions): void;
1518
1686
 
1519
1687
  /** Mirrors `package.json` version; run `npm run sync:sdk-version` or `npm run build` to refresh. */
1520
- declare const PAPERMAP_SDK_VERSION: "1.1.1";
1688
+ declare const PAPERMAP_SDK_VERSION: "1.1.2";
1521
1689
  /** Contract revision for hosts that gate advanced features; bump only for breaking contract changes. */
1522
1690
  declare const PAPERMAP_PLUGIN_CONTRACT_VERSION: 1;
1523
1691
  type PapermapCapability = 'chat' | 'charts' | 'dashboard' | 'streaming' | 'workspace' | (string & {});
@@ -1838,9 +2006,36 @@ interface PaperBoardProps {
1838
2006
  /** Default: Papermap web app origin. */
1839
2007
  logoutUrl?: string;
1840
2008
  appHeaderRightSlot?: ReactNode;
2009
+ /**
2010
+ * Mount the dashboard insight tile (mirrors main app `TimelineInsights`).
2011
+ * The tile is injected at the top of every breakpoint layout via
2012
+ * `ensurePaperInsightLayoutItem`. Default `false`.
2013
+ */
2014
+ showInsights?: boolean;
2015
+ /**
2016
+ * Initial / controlled period for the insight tile. Defaults to `'last_3_months'`
2017
+ * when uncontrolled. Selecting `'custom'` keeps the host's existing range.
2018
+ */
2019
+ insightsPeriodPreset?: InsightsPeriodPreset;
2020
+ onInsightsPeriodPresetChange?: (preset: InsightsPeriodPreset) => void;
2021
+ /**
2022
+ * Explicit date range for the insight tile. Overrides the auto-computed range
2023
+ * from the preset (use this together with `'custom'` for timeline-scrubbed ranges).
2024
+ */
2025
+ insightsStartDate?: Date | string;
2026
+ insightsEndDate?: Date | string;
2027
+ /** Click handler for the per-insight "Explore in Chat" arrow. */
2028
+ onInsightExplore?: (chatId: string) => void;
1841
2029
  }
1842
2030
  declare function PaperBoard({ token, workspaceId, dashboardId, apiUrl, theme, showWorkspaceDashboardSelect, onWorkspaceDashboardChange, showAppChrome, navItems: navItemsProp, user: userProp, onLogout, billingHref, settingsHref, logoutUrl, appHeaderRightSlot, ...rest }: PaperBoardProps): react_jsx_runtime.JSX.Element;
1843
2031
 
2032
+ /**
2033
+ * Mirrors the main app's `ensureTimelineInsightsLayoutItem`. Injects a layout slot
2034
+ * for the dashboard insight tile across every breakpoint if one isn't already
2035
+ * present. No-op for breakpoints that already include `gridId`.
2036
+ */
2037
+ declare function ensurePaperInsightLayoutItem(layouts: PaperBoardLayouts, gridId: string, defaults?: Partial<TLayout>): PaperBoardLayouts;
2038
+
1844
2039
  declare function readDashboardTourCompleted(key: string): boolean;
1845
2040
  declare function markDashboardTourCompleted(key: string): void;
1846
2041
  type BuildDashboardTourStepsOptions = {
@@ -1948,4 +2143,4 @@ declare function resolveChartFetchChatId(params: {
1948
2143
  dashboardId?: string;
1949
2144
  }): string | undefined;
1950
2145
 
1951
- export { type AgentThought, AgentThoughtDisplay, BookmarkButton, BranchButton, type BuildDashboardNavItemsParams, ButtonWithTooltip, CHART_CARD_CHAT_MAP_KEY, CHAT_MODAL_TAB, type ChartCardIdLink, type ChartCardStorageNamespace, type ChartDataRow, ChartDialog, ChartHistory, type ChartResponse, ChartView, type ChartVisualizationConfig, ChatAssistant, type ChatModalTabType, ChatSidePanel, type ConversationHistory, CreateDashboardDialog, type CreateDashboardDialogProps, CreateUnifiedWorkspaceDialog, type CreateUnifiedWorkspaceDialogProps, type CreatedDashboard, type CreatedUnifiedWorkspace, DashboardAppHeader, type DashboardNavbarItem, DashboardTabNavigation, type DashboardTabNavigationProps, type DashboardTheme, DataTable, type DecodedToken, FeedbackButtons, type FinalResponse, FloatingChartOverlay, IntegrationsBar, type JsonObject, LogoStandAlone, type Message, type MessageProgressEvent, ModelSelector, MorphGradient, type OpenPapermapChatAssistantOptions, PAPERMAP_CHAT_GREETING_MESSAGE, PAPERMAP_PLUGIN_CONTRACT_VERSION, PAPERMAP_SDK_VERSION, PaperBoard, type TLayout as PaperBoardLayoutItem, type PaperBoardLayouts, PaperCard, type PaperCardProps, PaperChat, type PaperChatAvatars, PaperChatDialogInner, type PaperChatDialogInnerProps, type PaperChatDialogLauncherPosition, PaperChatFloatingChartOverlay, type PaperChatFloatingChartOverlayProps, type PaperChatProps, PaperChatSidePanel, type PaperChatSidePanelProps, type PaperChatSidePosition, type PaperChatVariant, PaperDashboardSelect, type PaperDashboardSelectProps, type PapermapActions, type PapermapCapability, type PapermapColorScheme, PapermapProvider as PapermapConfigProvider, type PapermapConnectionValue, type PapermapHttpServices, type PapermapObservability, type PapermapObservabilityOptions, type PapermapPluginContext, type PapermapPluginLifecycle, type PapermapPluginManifest, type PapermapPluginRegistration, PapermapProvider, type PapermapState, type PapermapStore, type PapermapStoreApi, type PapermapStoreConfig, type PapermapTelemetryEvent, type PapermapTelemetryLevel, RecentConversations, SavedMemory, type StreamState, StreamingChartDialog, StreamingChatPanel, StreamingTimeline, type TChartMeta$1 as TChartMeta, type TChartResponse, ThemeCustomizationSettings, type ThemeCustomizationSettingsProps, type ThemePreset, type ThemeSaveMeta, type TimelineEvent, type ToolCall, ToolCallDisplay, type TourStep, type UseTourOptions, UserNav, type WorkspaceEntity, type WorkspaceMeta, WorkspaceSelector, type WorkspaceSelectorControl, WorkspaceSelectorProvider, buildAuthHeaders, buildDashboardNavItems, buildDashboardTourSteps, checkPluginPeerCompatibility, createApiClient, createPapermapObservability, createPapermapServices, createPapermapStore, createPluginContext, decodeToken, defaultTheme, getChartCardIdLink, markDashboardTourCompleted, openPapermapChatAssistant, papermapApiBaseSegment, papermapQueryKeys, parseSemverPrefix, presetDisplayNames, readDashboardTourCompleted, removeChartCardIdLink, resolveChartFetchChatId, resolveDashboardThemeFromWorkspace, themePresetList, themePresets, unwrapWorkspacePayload, upsertChartCardIdLink, useAnalyticsStream, useAutoFade, useAutoResize, useKeyboardShortcuts, usePapermapConnection, usePapermapConnectionOptional, usePapermapStore, usePapermapStoreApi, usePapermapStoreApiOptional, useTour };
2146
+ export { type AgentThought, AgentThoughtDisplay, BookmarkButton, BranchButton, type BuildDashboardNavItemsParams, ButtonWithTooltip, CHART_CARD_CHAT_MAP_KEY, CHAT_MODAL_TAB, type ChartCardIdLink, type ChartCardStorageNamespace, type ChartDataRow, ChartDialog, ChartHistory, type ChartResponse, ChartView, type ChartVisualizationConfig, ChatAssistant, type ChatModalTabType, ChatSidePanel, type ConversationHistory, CreateDashboardDialog, type CreateDashboardDialogProps, CreateUnifiedWorkspaceDialog, type CreateUnifiedWorkspaceDialogProps, type CreatedDashboard, type CreatedUnifiedWorkspace, DashboardAppHeader, type DashboardInsight, type DashboardInsightType, type DashboardInsightsResult, type DashboardNavbarItem, DashboardTabNavigation, type DashboardTabNavigationProps, type DashboardTheme, DataTable, type DecodedToken, FeedbackButtons, type FinalResponse, FloatingChartOverlay, INSIGHTS_PERIOD_LABELS, INSIGHTS_PERIOD_SELECT_OPTIONS, type InsightsPeriodMenuPreset, type InsightsPeriodPreset, IntegrationsBar, type JsonObject, LogoStandAlone, type Message, type MessageProgressEvent, ModelSelector, MorphGradient, type OpenPapermapChatAssistantOptions, PAPERMAP_CHAT_GREETING_MESSAGE, PAPERMAP_PLUGIN_CONTRACT_VERSION, PAPERMAP_SDK_VERSION, PAPER_INSIGHT_GRID_ID, PaperBoard, type TLayout as PaperBoardLayoutItem, type PaperBoardLayouts, PaperCard, type PaperCardProps, PaperChat, type PaperChatAvatars, PaperChatDialogInner, type PaperChatDialogInnerProps, type PaperChatDialogLauncherPosition, PaperChatFloatingChartOverlay, type PaperChatFloatingChartOverlayProps, type PaperChatProps, PaperChatSidePanel, type PaperChatSidePanelProps, type PaperChatSidePosition, type PaperChatVariant, PaperDashboardSelect, type PaperDashboardSelectProps, PaperInsight, type PaperInsightClassNames, type PaperInsightProps, type PaperInsightSlot, type PaperInsightStyles, type PapermapActions, type PapermapCapability, type PapermapColorScheme, PapermapProvider as PapermapConfigProvider, type PapermapConnectionValue, type PapermapHttpServices, type PapermapObservability, type PapermapObservabilityOptions, type PapermapPluginContext, type PapermapPluginLifecycle, type PapermapPluginManifest, type PapermapPluginRegistration, PapermapProvider, type PapermapState, type PapermapStore, type PapermapStoreApi, type PapermapStoreConfig, type PapermapTelemetryEvent, type PapermapTelemetryLevel, RecentConversations, SavedMemory, type StreamDashboardInsightsOptions, type StreamState, StreamingChartDialog, StreamingChatPanel, StreamingTimeline, type TChartMeta$1 as TChartMeta, type TChartResponse, ThemeCustomizationSettings, type ThemeCustomizationSettingsProps, type ThemePreset, type ThemeSaveMeta, type TimelineEvent, type ToolCall, ToolCallDisplay, type TourStep, type UseTourOptions, UserNav, type WorkspaceEntity, type WorkspaceMeta, WorkspaceSelector, type WorkspaceSelectorControl, WorkspaceSelectorProvider, buildAuthHeaders, buildDashboardNavItems, buildDashboardTourSteps, checkPluginPeerCompatibility, computeInsightsPeriodRange, createApiClient, createPapermapObservability, createPapermapServices, createPapermapStore, createPluginContext, decodeToken, defaultTheme, ensurePaperInsightLayoutItem, formatInsightDate, formatInsightsDateLabel, getChartCardIdLink, markDashboardTourCompleted, normalizeInsightType, openPapermapChatAssistant, orderInsightsForDisplay, papermapApiBaseSegment, papermapQueryKeys, parseInsightMetricToTrend, parseSemverPrefix, presetDisplayNames, readDashboardTourCompleted, removeChartCardIdLink, resolveChartFetchChatId, resolveDashboardThemeFromWorkspace, streamDashboardInsights, themePresetList, themePresets, unwrapWorkspacePayload, upsertChartCardIdLink, useAnalyticsStream, useAutoFade, useAutoResize, useKeyboardShortcuts, usePapermapConnection, usePapermapConnectionOptional, usePapermapStore, usePapermapStoreApi, usePapermapStoreApiOptional, useTour };