@burdenoff/microfe-bigconsole 2026.730.2 → 2026.730.4

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.
Files changed (34) hide show
  1. package/dist/bigconsole/components/dashboard/DashboardCanvas.js +73 -68
  2. package/dist/bigconsole/components/dashboard/DashboardCanvas.js.map +1 -1
  3. package/dist/bigconsole/components/dashboard/TemplateSetupBanner.js +82 -0
  4. package/dist/bigconsole/components/dashboard/TemplateSetupBanner.js.map +1 -0
  5. package/dist/bigconsole/components/embed/EmbedErrorBoundary.js +25 -0
  6. package/dist/bigconsole/components/embed/EmbedErrorBoundary.js.map +1 -0
  7. package/dist/bigconsole/components/embed/EmbedWidgetRenderer.js +36 -0
  8. package/dist/bigconsole/components/embed/EmbedWidgetRenderer.js.map +1 -0
  9. package/dist/bigconsole/components/embed/ReadOnlyDashboardRenderer.js +62 -0
  10. package/dist/bigconsole/components/embed/ReadOnlyDashboardRenderer.js.map +1 -0
  11. package/dist/bigconsole/components/embed/index.js +7 -0
  12. package/dist/bigconsole/components/embed/renderer-manifest.js +77 -0
  13. package/dist/bigconsole/components/embed/renderer-manifest.js.map +1 -0
  14. package/dist/bigconsole/components/embed/types.js +6 -0
  15. package/dist/bigconsole/components/embed/types.js.map +1 -0
  16. package/dist/bigconsole/components/embed/validate.js +29 -0
  17. package/dist/bigconsole/components/embed/validate.js.map +1 -0
  18. package/dist/bigconsole/components/embed/widgets/KpiComparisonEmbed.js +34 -0
  19. package/dist/bigconsole/components/embed/widgets/KpiComparisonEmbed.js.map +1 -0
  20. package/dist/bigconsole/components/embed/widgets/ListEmbed.js +36 -0
  21. package/dist/bigconsole/components/embed/widgets/ListEmbed.js.map +1 -0
  22. package/dist/bigconsole/components/embed/widgets/MetricCardEmbed.js +20 -0
  23. package/dist/bigconsole/components/embed/widgets/MetricCardEmbed.js.map +1 -0
  24. package/dist/bigconsole/components/embed/widgets/TableEmbed.js +40 -0
  25. package/dist/bigconsole/components/embed/widgets/TableEmbed.js.map +1 -0
  26. package/dist/bigconsole/components/embed/widgets/TextEmbed.js +20 -0
  27. package/dist/bigconsole/components/embed/widgets/TextEmbed.js.map +1 -0
  28. package/dist/bigconsole/components/embed/widgets/shared.js +29 -0
  29. package/dist/bigconsole/components/embed/widgets/shared.js.map +1 -0
  30. package/dist/bigconsole/components/widgets/WidgetWrapper.js +2 -1
  31. package/dist/bigconsole/components/widgets/WidgetWrapper.js.map +1 -1
  32. package/dist/bigconsole/components/widgets/states/EmptyState.js +3 -3
  33. package/dist/bigconsole/components/widgets/states/EmptyState.js.map +1 -1
  34. package/package.json +5 -1
@@ -1 +1 @@
1
- {"version":3,"file":"WidgetWrapper.js","names":[],"sources":["../../../../src/bigconsole/components/widgets/WidgetWrapper.tsx"],"sourcesContent":["/**\n * WidgetWrapper Component (v2.1)\n *\n * Common wrapper for all widget types. Handles:\n * - Header with title and menu\n * - Loading, error, and empty states\n * - Selection highlighting\n * - Edit mode controls\n * - Real data only — no mock fallback; widgets show empty state when data is missing\n * - v2.0: Multi-renderer support via WidgetRendererFactory\n * - v2.0: Widget actions support\n */\n\nimport {\n type FC,\n type ReactNode,\n type RefObject,\n useCallback,\n memo,\n useMemo,\n useRef,\n useState,\n useEffect,\n lazy,\n Suspense,\n} from 'react';\nimport type { Widget } from '../../types';\nimport {\n useWidgetStore,\n useDashboardStore,\n useIsWidgetSelected,\n useWidgetUIState,\n useGlobalFilterValues,\n} from '../../store';\nimport {\n useWidgetAutoRefresh,\n formatTimeUntilRefresh,\n useWidgetExport,\n useDrilldown,\n useWidgetData,\n useWidgetComments,\n type DrilldownContext,\n} from '../../hooks';\nimport { useApolloClient } from '@apollo/client/react';\nimport { GetDashboardDocument } from '../../../generated/wspace-operations';\nimport { getWidgetDefinition } from './WidgetRegistry';\nimport { WidgetHeader } from './WidgetHeader';\nimport { WidgetLoadingState } from './states/LoadingState';\nimport { WidgetErrorState } from './states/ErrorState';\nimport { WidgetEmptyState } from './states/EmptyState';\nimport { WidgetErrorBoundary } from './WidgetErrorBoundary';\nimport { hasRenderableCustomConfig, hasCustomIframeConfig } from './custom/config';\nimport { getBindingForWidget } from '../../utils/widgetBinding';\n\n// v2.0: Renderer factory and actions\nimport { WidgetRendererFactory } from '../../renderers/factory/WidgetRendererFactory';\nimport { WidgetActions } from './widget-actions';\nimport type { WidgetAction, ActionContext, ActionResult, RendererType } from '../../renderers/types/renderer';\n// Widget components - lazy loaded for better code splitting\n// Each widget loads only when its type is rendered\nconst MetricCardWidget = lazy(() => import('./metric-card').then((m) => ({ default: m.MetricCardWidget })));\nconst ChartWidget = lazy(() => import('./chart').then((m) => ({ default: m.ChartWidget })));\nconst TableWidget = lazy(() => import('./table').then((m) => ({ default: m.TableWidget })));\nconst PivotTableWidget = lazy(() => import('./pivot-table').then((m) => ({ default: m.PivotTableWidget })));\nconst GaugeWidget = lazy(() => import('./gauge').then((m) => ({ default: m.GaugeWidget })));\nconst ProgressWidget = lazy(() => import('./progress').then((m) => ({ default: m.ProgressWidget })));\nconst ListWidget = lazy(() => import('./list').then((m) => ({ default: m.ListWidget })));\nconst HeatmapWidget = lazy(() => import('./heatmap').then((m) => ({ default: m.HeatmapWidget })));\nconst RetentionWidget = lazy(() => import('./retention').then((m) => ({ default: m.RetentionWidget })));\nconst CalendarWidget = lazy(() => import('./calendar').then((m) => ({ default: m.CalendarWidget })));\nconst KanbanWidget = lazy(() => import('./kanban').then((m) => ({ default: m.KanbanWidget })));\nconst TimelineWidget = lazy(() => import('./timeline').then((m) => ({ default: m.TimelineWidget })));\nconst KPIComparisonWidget = lazy(() => import('./kpi-comparison').then((m) => ({ default: m.KPIComparisonWidget })));\nconst TextWidget = lazy(() => import('./text-widget').then((m) => ({ default: m.TextWidget })));\nconst MapWidget = lazy(() => import('./map-widget').then((m) => ({ default: m.MapWidget })));\nconst IframeWidget = lazy(() => import('./iframe-widget').then((m) => ({ default: m.IframeWidget })));\nconst CustomWidget = lazy(() => import('./custom').then((m) => ({ default: m.CustomWidget })));\n// AdaptiveCardWidget is HUGE (984KB) - lazy load only when 'form' type is used\nconst AdaptiveCardWidget = lazy(() => import('./adaptive-card').then((m) => ({ default: m.AdaptiveCardWidget })));\n// Comments panel - lazy loaded; only mounts when the user opens comments\nconst WidgetComments = lazy(() => import('./comments/WidgetComments').then((m) => ({ default: m.WidgetComments })));\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface WidgetWrapperProps {\n /** The widget data */\n widget: Widget;\n /** Widget content to render */\n children?: ReactNode;\n /** Data for the widget */\n data?: Record<string, unknown> | null;\n /** Custom class name */\n className?: string;\n /** Whether the widget is loading */\n isLoading?: boolean;\n /** Error message */\n error?: string | null;\n /** Callback to refresh widget data */\n onRefresh?: () => Promise<void>;\n /** Callback for drilldown navigation */\n onDrilldown?: (params: Record<string, unknown>) => void;\n /** v2.0: Widget actions */\n actions?: WidgetAction[];\n /** v2.0: Callback for action events */\n onAction?: (action: WidgetAction, context: ActionContext) => Promise<ActionResult | void>;\n /** Phase 2: Global filter values to apply to widget data */\n filterValues?: Record<string, unknown>;\n}\n\n// ============================================================================\n// Custom comparison for memo - ensures actions changes trigger re-render\n// ============================================================================\n\nfunction arePropsEqual(prevProps: WidgetWrapperProps, nextProps: WidgetWrapperProps): boolean {\n // Always re-render if widget ID changes\n if (prevProps.widget.id !== nextProps.widget.id) return false;\n // Re-render if widget was updated\n if (prevProps.widget.updatedAt !== nextProps.widget.updatedAt) return false;\n // Re-render if loading state changes\n if (prevProps.isLoading !== nextProps.isLoading) return false;\n // Re-render if error changes\n if (prevProps.error !== nextProps.error) return false;\n // Re-render if actions count changes\n if ((prevProps.actions?.length ?? 0) !== (nextProps.actions?.length ?? 0)) return false;\n // Check if any action ID changed\n if (prevProps.actions && nextProps.actions) {\n for (let i = 0; i < prevProps.actions.length; i++) {\n if (prevProps.actions[i]?.id !== nextProps.actions[i]?.id) return false;\n }\n }\n // Also check data changes\n if (prevProps.data !== nextProps.data) return false;\n // Phase 2: Re-render if filter values changed\n if (JSON.stringify(prevProps.filterValues) !== JSON.stringify(nextProps.filterValues)) return false;\n return true;\n}\n\n// ============================================================================\n// Component\n// ============================================================================\n\nexport const WidgetWrapper: FC<WidgetWrapperProps> = memo(function WidgetWrapper({\n widget,\n children,\n data,\n className = '',\n isLoading: isLoadingProp,\n error: errorProp,\n onRefresh,\n onDrilldown,\n actions,\n onAction,\n filterValues,\n}) {\n // Store state - use Dashboard store for edit mode (synced with toolbar)\n const isEditMode = useDashboardStore((state) => state.viewMode === 'edit');\n const selectWidget = useWidgetStore((state) => state.selectWidget);\n const isSelected = useIsWidgetSelected(widget.id);\n const uiState = useWidgetUIState(widget.id);\n const globalFilterValues = useGlobalFilterValues();\n const apolloClient = useApolloClient();\n\n // Map a global-filter's id -> the data field it targets (`config.field`).\n // Global CATEGORY/TEXT filter values are keyed in the store by filter id (a\n // UUID), not by the data column they filter. Without this map, applyClientFilters\n // can only fall back to value/heuristic matching, which fails to narrow rows\n // whose targeted column (e.g. `country`, `cohort`) isn't in the hardcoded\n // heuristic list — so a selected Country/Cohort would not actually filter the\n // widget. We resolve the targeted field from the dashboard's globalFilters\n // (already in the Apollo cache from the page load) so a UUID-keyed filter\n // matches the row's configured field exactly.\n const widgetDashboardId = (widget as unknown as Record<string, unknown>).dashboardId as string | undefined;\n const filterFieldMap = useMemo<Record<string, string>>(() => {\n if (!widgetDashboardId) return {};\n try {\n const cached = apolloClient.readQuery<{\n getDashboard?: {\n globalFilters?: Array<{ id: string; config?: Record<string, unknown> | null }>;\n };\n }>({ query: GetDashboardDocument, variables: { id: widgetDashboardId } });\n const map: Record<string, string> = {};\n for (const f of cached?.getDashboard?.globalFilters ?? []) {\n const field = f.config?.field;\n if (typeof field === 'string' && field) map[f.id] = field;\n }\n return map;\n } catch {\n return {};\n }\n }, [apolloClient, widgetDashboardId]);\n\n // Fetch per-widget data from backend (parser-processed data)\n // This is needed because listWidgetsByDashboard uses WidgetListFields (without data)\n // for performance, so each widget fetches its own data individually\n const widgetBinding = useMemo(() => getBindingForWidget(widget), [widget]);\n const hasDataSource =\n widgetBinding.source.kind !== 'DATASINK' ||\n !!widgetBinding.source.ref ||\n !!widgetBinding.parserId ||\n !!widget.datasetId;\n const { data: fetchedWidgetData, loading: widgetDataLoading } = useWidgetData(widget.id, {\n skip: !hasDataSource,\n pollInterval: (widget.refreshInterval ?? 0) * 1000 || 0,\n });\n\n // WORKAROUND: If Zustand store is empty, directly read filter_* params from URL\n // This handles race conditions where the store hasn't been populated yet\n const urlFilterValues = useMemo(() => {\n if (typeof window === 'undefined') return {};\n\n const params = new URLSearchParams(window.location.search);\n const filters: Record<string, unknown> = {};\n\n params.forEach((value, key) => {\n if (key.startsWith('filter_')) {\n const filterId = key.slice('filter_'.length);\n // Skip internal metadata keys\n if (!filterId.startsWith('__')) {\n filters[filterId] = value;\n }\n }\n });\n\n return filters;\n }, []);\n\n // Phase 2: Merge global filter values (from URL) with explicit filterValues prop\n // This ensures both URL params (filter_*) and drilldown params work together\n const mergedFilterValues = useMemo(() => {\n const merged: Record<string, unknown> = {};\n\n // First, add URL filter values as fallback (in case Zustand store hasn't loaded yet)\n if (urlFilterValues && Object.keys(urlFilterValues).length > 0) {\n Object.assign(merged, urlFilterValues);\n }\n\n // Then, add global filter values from Zustand store (if populated)\n if (globalFilterValues && Object.keys(globalFilterValues).length > 0) {\n Object.assign(merged, globalFilterValues);\n }\n\n // Finally, add/override with explicit filterValues prop (e.g., from drilldown modal)\n if (filterValues && Object.keys(filterValues).length > 0) {\n Object.assign(merged, filterValues);\n }\n\n return merged;\n }, [urlFilterValues, globalFilterValues, filterValues]);\n\n // Track active filters (client-side filtering until backend supports it)\n const hasFilters = Object.keys(mergedFilterValues).length > 0;\n\n // Merge loading/error from props and store\n // Show loading if widget data is being fetched for the first time (no data yet)\n const isLoading = isLoadingProp ?? (widgetDataLoading && !fetchedWidgetData) ?? uiState.isLoading;\n const error = errorProp ?? uiState.errorMessage;\n\n // Get widget definition\n const definition = getWidgetDefinition(widget.type);\n\n // Stable refresh callback - use ref to avoid creating new function on each render\n const onRefreshRef = useRef(onRefresh);\n useEffect(() => {\n onRefreshRef.current = onRefresh;\n }, [onRefresh]);\n\n const stableOnRefresh = useCallback(async () => {\n if (onRefreshRef.current) {\n await onRefreshRef.current();\n }\n }, []);\n\n // Auto-refresh\n const { timeUntilRefresh, isPaused } = useWidgetAutoRefresh({\n widgetId: widget.id,\n refreshInterval: widget.refreshInterval,\n onRefresh: stableOnRefresh,\n enabled: !isEditMode && !!widget.refreshInterval,\n });\n\n // Container ref for PNG export\n const containerRef = useRef<HTMLDivElement>(null);\n\n // Comments panel. The count query stays disabled until the panel is first\n // opened, so a dashboard of N widgets doesn't fire N comment queries on load.\n const [showComments, setShowComments] = useState(false);\n const [commentsEverOpened, setCommentsEverOpened] = useState(false);\n const { count: commentCount } = useWidgetComments(widget.id, commentsEverOpened);\n const toggleComments = useCallback(() => {\n setShowComments((open) => {\n const next = !open;\n if (next) setCommentsEverOpened(true);\n return next;\n });\n }, []);\n\n // Get widget data for export (computed early for hook)\n const exportData = useMemo(() => {\n if (data && Array.isArray(data)) return data;\n const rawData = (widget as unknown as Record<string, unknown>).data as Record<string, unknown> | undefined;\n if (rawData?.processed && Array.isArray(rawData.processed)) {\n return rawData.processed;\n }\n if (rawData?.raw) {\n const parsed = typeof rawData.raw === 'string' ? JSON.parse(rawData.raw) : rawData.raw;\n if (Array.isArray(parsed)) return parsed;\n }\n return null;\n }, [data, widget]);\n\n // Export functionality\n const { exportCSV, exportPNG } = useWidgetExport(widget, {\n data: exportData,\n containerRef: containerRef as unknown as RefObject<HTMLElement>,\n });\n\n // Helper to check if data is actually usable (has real content)\n const isUsableData = useCallback((d: unknown): boolean => {\n if (d === null || d === undefined) return false;\n if (Array.isArray(d)) return d.length > 0;\n if (typeof d === 'object') {\n const obj = d as Record<string, unknown>;\n const keys = Object.keys(obj);\n if (keys.length === 0) return false;\n // Check recursively for actual data content\n return keys.some((key) => {\n const val = obj[key];\n if (val === null || val === undefined || val === '') return false;\n if (Array.isArray(val)) return val.length > 0;\n if (typeof val === 'object') return isUsableData(val);\n return true;\n });\n }\n return true;\n }, []);\n\n // Phase 2: Client-side filter function for widget data\n const applyClientFilters = useCallback(\n (\n widgetData: Record<string, unknown> | Record<string, unknown>[]\n ): Record<string, unknown> | Record<string, unknown>[] => {\n if (!hasFilters || !widgetData) return widgetData;\n\n // Separate drilldown context filters (ctx_*) from regular filters\n const contextFilters: Record<string, unknown> = {};\n const regularFilters: Record<string, unknown> = {};\n\n Object.entries(mergedFilterValues || {}).forEach(([key, value]) => {\n if (key.startsWith('ctx_')) {\n // Strip ctx_ prefix to get the target field name\n const fieldName = key.slice(4); // Remove 'ctx_'\n contextFilters[fieldName] = value;\n } else if (!key.startsWith('__')) {\n // Skip internal metadata keys (__drilldown_depth, etc.)\n regularFilters[key] = value;\n }\n });\n\n // Helper to match a value against a filter (case-insensitive)\n const matchesFilter = (itemValue: unknown, filterValue: unknown): boolean => {\n if (filterValue === undefined || filterValue === null || filterValue === '') return true;\n if (itemValue === undefined || itemValue === null) return false;\n\n const itemStr = String(itemValue).toLowerCase();\n const filterStr = String(filterValue).toLowerCase();\n\n // Exact match or contains\n return itemStr === filterStr || itemStr.includes(filterStr);\n };\n\n // Helper to find a matching field in the item (case-insensitive key matching)\n const findFieldValue = (item: Record<string, unknown>, targetField: string): unknown => {\n const targetLower = targetField.toLowerCase();\n\n // Try exact match first\n if (item[targetField] !== undefined) return item[targetField];\n\n // Try case-insensitive match\n const matchingKey = Object.keys(item).find((k) => k.toLowerCase() === targetLower);\n if (matchingKey) return item[matchingKey];\n\n // Try partial match (e.g., 'region' matches 'regionName' or 'user_region')\n const partialMatch = Object.keys(item).find(\n (k) => k.toLowerCase().includes(targetLower) || targetLower.includes(k.toLowerCase())\n );\n if (partialMatch) return item[partialMatch];\n\n // Try stripping common prefixes from target field (e.g., 'kpiId' -> 'id', 'rowName' -> 'name')\n // This handles drilldown context where widget passes 'kpiId' but data has 'id'\n const commonPrefixes = ['kpi', 'row', 'item', 'data', 'cell', 'record', 'entry'];\n for (const prefix of commonPrefixes) {\n if (targetLower.startsWith(prefix) && targetLower.length > prefix.length) {\n const strippedField = targetLower.slice(prefix.length);\n // Try exact match with stripped field\n const strippedMatch = Object.keys(item).find((k) => k.toLowerCase() === strippedField);\n if (strippedMatch) return item[strippedMatch];\n }\n }\n\n return undefined;\n };\n\n // Helper function to filter an array of items\n const filterItems = (items: Record<string, unknown>[]): Record<string, unknown>[] => {\n return items.filter((item: Record<string, unknown>) => {\n // Only object rows are field-filterable. An array of primitives (e.g.\n // a heatmap's `rows: [\"5W-MedSurg\", …]`) carries no named fields — keep\n // every element. Without this, `findFieldValue` indexes into the string\n // by character offset and spuriously \"matches\" a filter, dropping rows.\n if (item === null || typeof item !== 'object' || Array.isArray(item)) {\n return true;\n }\n // First, apply drilldown context filters (ctx_*) - these have explicit field names\n for (const [fieldName, filterValue] of Object.entries(contextFilters)) {\n if (filterValue === undefined || filterValue === null || filterValue === '') continue;\n\n const itemValue = findFieldValue(item, fieldName);\n // If the field doesn't exist in this data item, skip this context filter.\n // Drilldown context params (e.g., source=support_status) are metadata about\n // the drilldown origin and should NOT filter out data when the target\n // dashboard's widgets don't have a matching field.\n if (itemValue === undefined) continue;\n if (!matchesFilter(itemValue, filterValue)) {\n return false;\n }\n }\n\n // Then, apply regular filters\n for (const [filterKey, filterValue] of Object.entries(regularFilters)) {\n if (filterValue === undefined || filterValue === null || filterValue === '') continue;\n\n // For date range filters\n if (typeof filterValue === 'object') {\n const fv = filterValue as Record<string, unknown>;\n if (fv.start || fv.end) {\n const dateFields = Object.entries(item).filter(\n ([k, _v]) => k.toLowerCase().includes('date') || k.toLowerCase().includes('time')\n );\n if (dateFields.length > 0) {\n const itemDate = new Date(dateFields[0][1] as string);\n if (fv.start && itemDate < new Date(fv.start as string)) return false;\n if (fv.end && itemDate > new Date(fv.end as string)) return false;\n }\n continue;\n }\n }\n\n // For numeric range filters\n if (typeof filterValue === 'object') {\n const nv = filterValue as Record<string, unknown>;\n if (nv.min !== undefined || nv.max !== undefined) {\n const numericFields = Object.entries(item).filter(([_k, v]) => typeof v === 'number');\n if (numericFields.length > 0) {\n const itemNum = numericFields[0][1] as number;\n if (nv.min !== undefined && itemNum < (nv.min as number)) return false;\n if (nv.max !== undefined && itemNum > (nv.max as number)) return false;\n }\n continue;\n }\n }\n\n // Any other object-shaped filter value (e.g. a DATE_RANGE filter set\n // to a preset like { preset: \"last_30_days\" } with no resolved\n // start/end, or a structured value we don't understand) cannot be\n // compared with the scalar matchers below. Passing it through would\n // stringify it to \"[object Object]\" and, via fuzzy field matching\n // (e.g. an `enrolledAt` filter partial-matching an `enrolled` number\n // column), spuriously exclude EVERY row. Treat such values as a no-op\n // for client-side filtering — the row set is unchanged until the\n // filter resolves to concrete start/end or scalar values.\n if (filterValue !== null && typeof filterValue === 'object' && !Array.isArray(filterValue)) {\n continue;\n }\n\n // Global CATEGORY/TEXT filters are keyed by filter id (UUID). Resolve\n // the data column they target from the filter's config.field. When the\n // widget's rows carry that column, the filter is authoritative — a\n // mismatch excludes the row; a missing column is a no-op (the filter\n // simply doesn't apply to this widget's shape). This is what makes a\n // selected Country/Cohort actually narrow the visible data.\n const targetField = filterFieldMap[filterKey];\n if (targetField) {\n const mappedValue = findFieldValue(item, targetField);\n if (mappedValue !== undefined) {\n if (!matchesFilter(mappedValue, filterValue)) {\n return false;\n }\n continue;\n }\n // Configured field absent from this widget's rows → filter is a\n // no-op for this widget (do not fall through to value heuristics,\n // which could spuriously match an unrelated column).\n continue;\n }\n\n // Try to match by filter key name first (for named filters). When\n // the widget's data actually carries the filter's field, the filter\n // is authoritative — a mismatch excludes the row.\n const fieldValue = findFieldValue(item, filterKey);\n if (fieldValue !== undefined) {\n if (!matchesFilter(fieldValue, filterValue)) {\n return false;\n }\n continue;\n }\n\n // For text/category filters - try multiple matching strategies\n const filterStr = String(filterValue).toLowerCase();\n\n // Strategy 1: Check all field values for exact or partial match\n const itemValues = Object.values(item).map((v) => String(v).toLowerCase());\n const hasMatch = itemValues.some((v) => v === filterStr || v.includes(filterStr));\n\n if (!hasMatch) {\n // Strategy 2: Try to find a field name that matches the filter value context\n const fieldNames = Object.keys(item).map((k) => k.toLowerCase());\n const possibleFields = fieldNames.filter(\n (f) =>\n f.includes('category') ||\n f.includes('type') ||\n f.includes('status') ||\n f.includes('name') ||\n f.includes('region') ||\n f.includes('group')\n );\n\n let fieldMatch = false;\n for (const fieldName of possibleFields) {\n const originalKey = Object.keys(item).find((k) => k.toLowerCase() === fieldName);\n if (originalKey) {\n const itemFieldValue = String(item[originalKey]).toLowerCase();\n if (itemFieldValue === filterStr || itemFieldValue.includes(filterStr)) {\n fieldMatch = true;\n break;\n }\n }\n }\n\n // The filter's field is NOT present in this dataset (named-field\n // lookup failed AND no value/heuristic match). A global filter that\n // doesn't apply to a widget's shape must be a no-op for that widget\n // — not a silent \"exclude every row\". This mirrors the ctx_* rule\n // above (skip when the targeted field is absent). Without this, an\n // always-active required filter (e.g. campus=main) blanks every\n // parser-derived widget whose output has no campus column.\n if (!fieldMatch) {\n continue;\n }\n }\n }\n return true;\n });\n };\n\n // If data is an array, filter the items directly\n if (Array.isArray(widgetData)) {\n const filtered = filterItems(widgetData);\n return filtered;\n }\n\n // Handle object with array properties (rows, items, members, questions, data, etc.)\n if (widgetData && typeof widgetData === 'object') {\n // Common array property names in widget data\n const arrayPropertyNames = [\n 'kpis', // KPI Comparison widget\n 'rows', // Table widget\n 'items', // List widget\n 'members', // Team/member widgets\n 'questions', // Form widget\n 'data', // Generic data\n 'records', // Database-style data\n 'results', // Search/query results\n 'entries', // Log/feed entries\n 'list', // Generic list\n 'values', // Value arrays\n 'series', // Chart series\n 'datasets', // Chart datasets\n ];\n\n for (const propName of arrayPropertyNames) {\n if (widgetData[propName] && Array.isArray(widgetData[propName])) {\n const filteredArray = filterItems(widgetData[propName]);\n return {\n ...widgetData,\n [propName]: filteredArray,\n ...(propName === 'rows' ? { totalRows: filteredArray.length } : {}),\n };\n }\n }\n\n // If no known array property found, check for any array property\n const arrayProps = Object.entries(widgetData).filter(([_key, v]) => Array.isArray(v));\n if (arrayProps.length > 0) {\n const [propName, propValue] = arrayProps[0];\n const filteredArray = filterItems(propValue as Record<string, unknown>[]);\n return {\n ...widgetData,\n [propName]: filteredArray,\n };\n }\n }\n\n // For non-filterable data, return as-is\n return widgetData;\n },\n [hasFilters, mergedFilterValues, widget.id, filterFieldMap]\n );\n\n // Get widget data from the widget itself (fetched from backend)\n const realWidgetData = useMemo(() => {\n let rawWidgetData = null;\n\n // Priority 1: Explicitly passed data prop\n if (data && isUsableData(data)) {\n rawWidgetData = data;\n }\n // Priority 2: Per-widget fetched data (from useWidgetData hook)\n // fetchedWidgetData IS a WidgetData object: { raw, processed, fetchedAt, cached }\n else if (fetchedWidgetData) {\n const fetched = fetchedWidgetData as unknown as Record<string, unknown>;\n if (fetched?.processed && isUsableData(fetched.processed)) {\n rawWidgetData = fetched.processed;\n } else if (fetched?.raw) {\n try {\n const parsed = typeof fetched.raw === 'string' ? JSON.parse(fetched.raw as string) : fetched.raw;\n if (isUsableData(parsed)) rawWidgetData = parsed;\n } catch {\n // Invalid JSON, ignore\n }\n }\n }\n // Priority 3: widget.data from GraphQL response (if already on widget object)\n else {\n const rawData = (widget as unknown as Record<string, unknown>).data as Record<string, unknown> | undefined;\n if (rawData?.processed && isUsableData(rawData.processed)) {\n rawWidgetData = rawData.processed;\n } else if (rawData?.raw) {\n try {\n const parsed = typeof rawData.raw === 'string' ? JSON.parse(rawData.raw) : rawData.raw;\n if (isUsableData(parsed)) rawWidgetData = parsed;\n } catch {\n // Invalid JSON, ignore\n }\n }\n }\n\n // Priority 4: config.mockData — user-configured sample JSON from Widget Properties Data tab\n // This is NOT auto-generated mock data; it's explicit JSON the user pasted in the UI\n if (!rawWidgetData) {\n const configMockData = (widget.config as Record<string, unknown> | undefined)?.mockData;\n if (configMockData) {\n try {\n const parsed = typeof configMockData === 'string' ? JSON.parse(configMockData) : configMockData;\n if (isUsableData(parsed)) {\n rawWidgetData = parsed;\n }\n } catch (e) {}\n }\n }\n\n // Generic parser-output resolution: a widget may bind to a parser whose\n // output is an envelope ({ byUnit:[...], house:{...} }) rather than the\n // exact array/object the renderer wants. config.dataKey / dataPath /\n // seriesPath is a dot-path INTO the resolved data that points at the\n // renderable subtree (e.g. \"byUnit\" for a table, \"rows\" for a chart).\n // Resolving it here keeps every renderer generic — the use-case-specific\n // shape knowledge lives in the widget config (set by the seed/UI), not in\n // the renderer. valueField (single-value metric path) is intentionally NOT\n // applied here: MetricCardWidget resolves it itself against the envelope.\n if (rawWidgetData && typeof rawWidgetData === 'object' && !Array.isArray(rawWidgetData)) {\n const cfg = widget.config as Record<string, unknown> | undefined;\n const pathKey = (cfg?.dataKey ?? cfg?.dataPath ?? cfg?.seriesPath) as string | undefined;\n if (pathKey && typeof pathKey === 'string') {\n const resolved = pathKey.split('.').reduce<unknown>((cur, seg) => {\n return cur && typeof cur === 'object' ? (cur as Record<string, unknown>)[seg] : undefined;\n }, rawWidgetData);\n if (resolved !== undefined && resolved !== null && isUsableData(resolved)) {\n rawWidgetData = resolved as Record<string, unknown>;\n }\n }\n }\n\n // Phase 2: Apply client-side filters if active\n if (hasFilters && rawWidgetData) {\n const filtered = applyClientFilters(rawWidgetData);\n return filtered;\n }\n\n return rawWidgetData;\n }, [data, widget, fetchedWidgetData, hasFilters, applyClientFilters, mergedFilterValues, isUsableData]);\n\n // Final widget data - real data only, no mock fallback\n const widgetData = useMemo(() => {\n return realWidgetData ?? null;\n }, [realWidgetData]);\n\n // Drilldown navigation (must be after widgetData is defined)\n const { executeDrilldown, canDrilldown } = useDrilldown({\n onDrilldown: (params, _mode) => {\n onDrilldown?.(params);\n },\n });\n\n // Check if widget has drilldown configured\n const hasDrilldown = useMemo(() => canDrilldown(widget), [widget, canDrilldown]);\n\n // Handle drilldown execution with context\n const handleDrilldown = useCallback(\n (selectedData?: Record<string, unknown>) => {\n if (!widget.drilldown?.enabled) return;\n\n const context: DrilldownContext = {\n selectedData: selectedData || {},\n globalFilters: globalFilterValues || {},\n widgetData: widgetData || {},\n metadata: {\n widgetId: widget.id,\n widgetType: widget.type,\n widgetTitle: widget.title,\n },\n sourceDashboardId: widget.dashboardId,\n };\n\n executeDrilldown(widget.drilldown, context);\n },\n [widget, widgetData, globalFilterValues, executeDrilldown]\n );\n\n // Track mouse position to distinguish click from drag\n const mouseDownPos = useRef<{ x: number; y: number } | null>(null);\n const DRAG_THRESHOLD = 5; // pixels - if mouse moves more than this, it's a drag\n\n // Handle mouse down - record position\n const handleMouseDown = useCallback((e: React.MouseEvent) => {\n mouseDownPos.current = { x: e.clientX, y: e.clientY };\n }, []);\n\n // Handle widget click - Edit mode only (View mode drilldown is triggered by data clicks)\n // Only trigger if mouse hasn't moved much (not a drag)\n const handleClick = useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation(); // Prevent DashboardGrid from also handling\n\n // Check if this was a drag (mouse moved significantly)\n if (mouseDownPos.current) {\n const dx = Math.abs(e.clientX - mouseDownPos.current.x);\n const dy = Math.abs(e.clientY - mouseDownPos.current.y);\n if (dx > DRAG_THRESHOLD || dy > DRAG_THRESHOLD) {\n // This was a drag, not a click - don't open config panel\n mouseDownPos.current = null;\n return;\n }\n }\n mouseDownPos.current = null;\n\n if (isEditMode) {\n // Edit mode: select widget for editing\n selectWidget(widget.id);\n }\n // View mode: drilldown is triggered by clicking specific data elements\n // (table rows, chart points, etc.) - not by clicking the widget itself\n },\n [isEditMode, selectWidget, widget.id]\n );\n\n // Handle keyboard navigation (Edit mode only)\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n event.stopPropagation();\n if (isEditMode) {\n selectWidget(widget.id);\n }\n }\n },\n [isEditMode, selectWidget, widget.id]\n );\n\n const hasRenderableCustomWidgetConfig = useMemo(\n () => widget.type === 'custom' && hasRenderableCustomConfig(widget.config),\n [widget.type, widget.config]\n );\n\n const customWidgetHasIframeConfig = useMemo(\n () => widget.type === 'custom' && hasCustomIframeConfig(widget.config),\n [widget.type, widget.config]\n );\n\n const showContainerDrilldownHints = hasDrilldown && !customWidgetHasIframeConfig;\n\n // Determine if data is empty\n const isEmpty = !isLoading && !error && !widgetData && !hasRenderableCustomWidgetConfig;\n\n // v2.0: Check if widget has a renderer specified (non-BIGCONSOLE)\n const widgetRenderer = useMemo(() => {\n const widgetWithRenderer = widget as Widget & { renderer?: RendererType };\n return widgetWithRenderer.renderer;\n }, [widget]);\n\n // v2.0: Determine if we should use the factory (non-BIGCONSOLE renderer)\n const useRendererFactory = useMemo(() => {\n const shouldUse = widgetRenderer && widgetRenderer !== 'BIGCONSOLE';\n return shouldUse;\n }, [widgetRenderer]);\n\n // v2.0: Create action context\n const actionContext = useMemo<ActionContext>(\n () => ({\n widgetId: widget.id,\n data: widgetData || {},\n }),\n [widget.id, widgetData]\n );\n\n // v2.0: Handle action callback from WidgetRendererFactory\n // Receives (action: WidgetAction, context: ActionContext) and forwards to parent\n // Checks if a more detailed backend action exists with same name\n const handleActionFromFactory = useCallback(\n (action: WidgetAction, context: ActionContext) => {\n if (!onAction) return;\n\n // Try to find a matching backend action by name (has more details like confirmation)\n const existingAction = actions?.find((a) => a.name === action.name);\n\n if (existingAction) {\n // Use existing backend action (has confirmation, style, icon, etc.)\n onAction(existingAction, context);\n } else {\n // Use the action from WidgetRendererFactory as-is\n onAction(action, context);\n }\n },\n [onAction, actions]\n );\n\n // Render the appropriate widget component based on type (v1.0 snake_case)\n const renderWidgetComponent = useCallback(() => {\n // Extract data based on widget type expectations\n // Different widgets expect different data formats\n const getDataForWidget = () => {\n if (!widgetData) return widgetData;\n\n // If data has 'rows' property (table data), extract rows\n if (widget.type === 'table' || widget.type === 'pivot_table') {\n if (Array.isArray(widgetData)) return widgetData;\n if (widgetData && typeof widgetData === 'object' && 'rows' in widgetData) {\n return (widgetData as { rows: unknown[] }).rows;\n }\n }\n\n // If data has 'items' property (list data), extract items\n if (widget.type === 'list') {\n if (Array.isArray(widgetData)) return widgetData;\n if (widgetData && typeof widgetData === 'object' && 'items' in widgetData) {\n return (widgetData as { items: unknown[] }).items;\n }\n }\n\n // If data has 'stages' property (old funnel format), extract stages\n if (widget.type === 'funnel_chart') {\n if (Array.isArray(widgetData)) return widgetData;\n if (widgetData && typeof widgetData === 'object' && 'stages' in widgetData) {\n return (widgetData as { stages: unknown[] }).stages;\n }\n }\n\n // If data has 'datasets' property (old chart format), convert to array format\n if (widget.type === 'chart') {\n if (Array.isArray(widgetData)) return widgetData;\n if (widgetData && typeof widgetData === 'object' && 'datasets' in widgetData) {\n // Convert old format to new array format\n const oldData = widgetData as { labels?: string[]; datasets?: { name: string; data: number[] }[] };\n if (oldData.labels && oldData.datasets) {\n return oldData.labels.map((label, i) => {\n const point: Record<string, unknown> = { name: label };\n oldData.datasets?.forEach((ds) => {\n point[ds.name.toLowerCase()] = ds.data[i];\n });\n return point;\n });\n }\n }\n }\n\n // For text widgets: convert parsed object data to {content, format} shape\n if (widget.type === 'text') {\n if (widgetData && typeof widgetData === 'object' && !('content' in (widgetData as Record<string, unknown>))) {\n // Auto-format parsed data as markdown content\n const obj = widgetData as Record<string, unknown>;\n const lines: string[] = [];\n for (const [key, val] of Object.entries(obj)) {\n if (val && typeof val === 'object' && !Array.isArray(val)) {\n lines.push(`### ${key}`);\n for (const [k2, v2] of Object.entries(val as Record<string, unknown>)) {\n lines.push(`- **${k2}:** ${v2}`);\n }\n } else if (Array.isArray(val)) {\n lines.push(`### ${key}`);\n val.slice(0, 10).forEach((item: unknown) => {\n if (item && typeof item === 'object') {\n const entries = Object.entries(item as Record<string, unknown>);\n lines.push(`- ${entries.map(([k, v]) => `**${k}:** ${v}`).join(' | ')}`);\n } else {\n lines.push(`- ${item}`);\n }\n });\n } else {\n lines.push(`- **${key}:** ${val}`);\n }\n }\n return { content: lines.join('\\n'), format: 'markdown' };\n }\n }\n\n // For custom widgets: pass data through with extracted value if configured\n if (widget.type === 'custom') {\n const config = widget.config as Record<string, unknown> | undefined;\n const valueField = config?.valueField as string | undefined;\n if (valueField && widgetData && typeof widgetData === 'object' && !Array.isArray(widgetData)) {\n const obj = widgetData as Record<string, unknown>;\n if (valueField in obj) {\n return { value: obj[valueField], label: widget.title, data: obj };\n }\n }\n }\n\n return widgetData;\n };\n\n const normalizedData = getDataForWidget();\n const props = {\n widget,\n data: normalizedData,\n onDrilldown: hasDrilldown ? handleDrilldown : undefined,\n };\n\n // v2.0: Use WidgetRendererFactory for non-BIGCONSOLE renderers\n if (useRendererFactory) {\n // For factory renderers (Adaptive Card, BlockKit, Custom), pass the RAW\n // processed data — NOT the type-normalized data. Normalization (e.g., text→markdown)\n // is only for BIGCONSOLE renderer widgets. Factory renderers handle their own\n // template interpolation against the raw data object.\n let factoryData: Record<string, unknown> = {};\n\n if (\n realWidgetData &&\n typeof realWidgetData === 'object' &&\n !Array.isArray(realWidgetData) &&\n Object.keys(realWidgetData as Record<string, unknown>).length > 0\n ) {\n // Use real data from backend (raw processed, not type-normalized)\n factoryData = { ...(realWidgetData as Record<string, unknown>) };\n }\n\n // For CUSTOM renderer: enrich data with standard fields expected by built-in components.\n // Built-in components (Counter, Card, SimpleText) read specific fields from data:\n // Counter: data.value, Card: data.title/data.description, SimpleText: data.text\n // Parsed data from datasinks has domain-specific fields (totalFiles, totalMessages, etc.)\n // Use config.valueField to extract the primary value and map it to standard fields.\n const internalType = (widget.config as Record<string, unknown> | undefined)?._internalWidgetType as\n string | undefined;\n if (internalType === 'custom' && Object.keys(factoryData).length > 0) {\n const config = widget.config as Record<string, unknown> | undefined;\n const valueField = config?.valueField as string | undefined;\n if (valueField && valueField in factoryData) {\n const val = factoryData[valueField];\n const formatted = typeof val === 'number' ? val.toLocaleString() : String(val);\n // Map to standard fields for all built-in custom components\n factoryData = {\n ...factoryData,\n value: val, // Counter component\n title: factoryData.title || formatted, // Card component\n description: factoryData.description || widget.title || '', // Card component\n text: factoryData.text || formatted, // SimpleText component\n };\n }\n }\n\n return (\n <WidgetRendererFactory\n widget={widget}\n data={factoryData}\n isEditMode={isEditMode}\n isSelected={isSelected}\n isLoading={isLoading}\n error={error}\n onDrilldown={hasDrilldown ? handleDrilldown : undefined}\n onAction={handleActionFromFactory}\n />\n );\n }\n\n // v1.0: Use switch-case for BIGCONSOLE renderer (default)\n // Normalize widget type to lowercase for case-insensitive matching\n const normalizedType = widget.type?.toLowerCase() || '';\n switch (normalizedType) {\n case 'metric_card':\n return <MetricCardWidget {...props} />;\n case 'kpi_card_comparison':\n return <KPIComparisonWidget {...props} />;\n case 'chart':\n case 'funnel_chart':\n return <ChartWidget {...props} />;\n case 'table':\n return <TableWidget {...props} />;\n case 'pivot_table':\n return <PivotTableWidget {...props} />;\n case 'gauge':\n return <GaugeWidget {...props} />;\n case 'progress':\n return <ProgressWidget {...props} />;\n case 'list':\n return <ListWidget {...props} />;\n case 'heatmap':\n return <HeatmapWidget {...props} />;\n case 'retention':\n return <RetentionWidget {...props} />;\n case 'calendar':\n return <CalendarWidget {...props} />;\n case 'timeline':\n return <TimelineWidget {...props} />;\n case 'kanban':\n return <KanbanWidget {...props} />;\n case 'form':\n return <AdaptiveCardWidget {...props} />;\n case 'text':\n return <TextWidget {...props} />;\n case 'iframe':\n return <IframeWidget {...props} />;\n case 'map':\n return <MapWidget {...props} />;\n case 'custom':\n return <CustomWidget {...props} />;\n default:\n return children || <WidgetEmptyState widgetType={widget.type} />;\n }\n }, [\n widget,\n widgetData,\n children,\n hasDrilldown,\n handleDrilldown,\n useRendererFactory,\n isEditMode,\n isSelected,\n isLoading,\n error,\n handleActionFromFactory,\n realWidgetData,\n ]);\n\n // Determine content to render\n const renderContent = () => {\n if (isLoading) {\n return <WidgetLoadingState />;\n }\n\n if (error) {\n return <WidgetErrorState error={error} onRetry={onRefresh} />;\n }\n\n if (isEmpty && !children) {\n // v2.0: Check parserId (primary) or dataSinkId (for context/drilldowns)\n return <WidgetEmptyState widgetType={widget.type} hasDataSource={hasDataSource} />;\n }\n\n // resetKey auto-resets the boundary on parser/sink re-bind or config edit without widget.id changing (BOFF-2242).\n const resetKey = `${widgetBinding.source.kind}|${widgetBinding.source.ref ?? ''}|${widgetBinding.parserId ?? ''}|${widget.updatedAt ?? ''}`;\n\n return (\n <WidgetErrorBoundary widgetId={widget.id} widgetType={widget.type} widgetTitle={widget.title} resetKey={resetKey}>\n {children ?? <Suspense fallback={<WidgetLoadingState />}>{renderWidgetComponent()}</Suspense>}\n </WidgetErrorBoundary>\n );\n };\n\n return (\n <div\n ref={containerRef}\n className={`\n group relative flex flex-col\n h-full w-full\n rounded-lg border\n bg-bg-surface\n transition-all duration-200\n ${\n isSelected && isEditMode\n ? 'border-action-primary-border ring-2 ring-action-primary-border/30'\n : 'border-border-default hover:border-action-primary-bg'\n }\n ${isEditMode ? 'cursor-pointer' : ''}\n ${className}\n `}\n onMouseDown={handleMouseDown}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n tabIndex={isEditMode ? 0 : -1}\n role={isEditMode ? 'button' : undefined}\n aria-selected={isSelected}\n aria-label={`Widget: ${widget.title}`}\n data-widget-id={widget.id}\n data-widget-type={widget.type}\n >\n {/* Header */}\n <WidgetHeader\n widget={widget}\n definition={definition}\n isSelected={isSelected}\n isEditMode={isEditMode}\n isLoading={isLoading}\n timeUntilRefresh={widget.refreshInterval && !isPaused ? formatTimeUntilRefresh(timeUntilRefresh) : undefined}\n hasDrilldown={hasDrilldown}\n onRefresh={onRefresh}\n onExportCSV={exportData ? exportCSV : undefined}\n onExportPNG={exportPNG}\n onDrilldown={hasDrilldown ? () => handleDrilldown() : undefined}\n onToggleComments={toggleComments}\n commentsOpen={showComments}\n commentCount={commentsEverOpened ? commentCount : undefined}\n />\n\n {/* Content Area */}\n <div\n className={`\n flex-1 overflow-hidden p-4 min-h-0\n ${showContainerDrilldownHints && !isEditMode ? 'cursor-pointer' : ''}\n `}\n title={showContainerDrilldownHints && !isEditMode ? 'Click data to drill down' : undefined}\n >\n <div className=\"h-full overflow-auto\">{renderContent()}</div>\n </div>\n\n {/* v2.0: Widget Actions */}\n {actions && actions.length > 0 && !isLoading && !error && (\n <div className=\"px-4 py-3 border-t border-border-default bg-bg-sunken\" style={{ flexShrink: 0 }}>\n <WidgetActions\n actions={actions}\n context={actionContext}\n onAction={onAction}\n disabled={isEditMode}\n layout=\"horizontal\"\n size=\"sm\"\n />\n </div>\n )}\n\n {/* Edit mode: react-grid-layout provides resize handles */}\n\n {/* Drilldown Indicator */}\n {showContainerDrilldownHints && !isEditMode && (\n <div\n className=\"\n absolute bottom-2 right-2\n opacity-0 group-hover:opacity-100\n transition-opacity duration-200\n \"\n title=\"Click to drill down\"\n >\n <svg className=\"w-4 h-4 text-text-secondary\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M13 7l5 5m0 0l-5 5m5-5H6\" />\n </svg>\n </div>\n )}\n\n {/* Comments panel (overlay) */}\n {showComments && (\n <Suspense fallback={null}>\n <WidgetComments widgetId={widget.id} onClose={() => setShowComments(false)} />\n </Suspense>\n )}\n </div>\n );\n}, arePropsEqual);\n\nexport default WidgetWrapper;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,IAAM,KAAmB,QAAW,OAAO,0BAAiB,MAAM,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC,EACrG,KAAc,QAAW,OAAO,oBAAW,MAAM,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,EACrF,KAAc,QAAW,OAAO,oBAAW,MAAM,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,EACrF,KAAmB,QAAW,OAAO,0BAAiB,MAAM,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC,EACrG,KAAc,QAAW,OAAO,oBAAW,MAAM,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,EACrF,KAAiB,Q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OAAI,YAAY,EAAO;OAAM,aAAa,EAAO;OAAiB;iBACrG,KAAY,kBAAC,IAAD;QAAU,UAAU,kBAAC,GAAD,EAAsB,CAAA;kBAAG,IAAuB;QAAY,CAAA;OACzE,CAAA;SAyDkC;KAAO,CAAA;IACzD,CAAA;GAGL,KAAW,EAAQ,SAAS,KAAK,CAAC,KAAa,CAAC,KAC/C,kBAAC,OAAD;IAAK,WAAU;IAAwD,OAAO,EAAE,YAAY,GAAG;cAC7F,kBAAC,IAAD;KACW;KACT,SAAS;KACC;KACV,UAAU;KACV,QAAO;KACP,MAAK;KACL,CAAA;IACE,CAAA;GAMP,KAA+B,CAAC,KAC/B,kBAAC,OAAD;IACE,WAAU;IAKV,OAAM;cAEN,kBAAC,OAAD;KAAK,WAAU;KAA8B,MAAK;KAAO,QAAO;KAAe,SAAQ;eACrF,kBAAC,QAAD;MAAM,eAAc;MAAQ,gBAAe;MAAQ,aAAa;MAAG,GAAE;MAA6B,CAAA;KAC9F,CAAA;IACF,CAAA;GAIP,KACC,kBAAC,IAAD;IAAU,UAAU;cAClB,kBAAC,IAAD;KAAgB,UAAU,EAAO;KAAI,eAAe,EAAgB,GAAM;KAAI,CAAA;IACrE,CAAA;GAET;;GAEP,EAAc"}
1
+ {"version":3,"file":"WidgetWrapper.js","names":[],"sources":["../../../../src/bigconsole/components/widgets/WidgetWrapper.tsx"],"sourcesContent":["/**\n * WidgetWrapper Component (v2.1)\n *\n * Common wrapper for all widget types. Handles:\n * - Header with title and menu\n * - Loading, error, and empty states\n * - Selection highlighting\n * - Edit mode controls\n * - Real data only — no mock fallback; widgets show empty state when data is missing\n * - v2.0: Multi-renderer support via WidgetRendererFactory\n * - v2.0: Widget actions support\n */\n\nimport {\n type FC,\n type ReactNode,\n type RefObject,\n useCallback,\n memo,\n useMemo,\n useRef,\n useState,\n useEffect,\n lazy,\n Suspense,\n} from 'react';\nimport type { Widget } from '../../types';\nimport {\n useWidgetStore,\n useDashboardStore,\n useIsWidgetSelected,\n useWidgetUIState,\n useGlobalFilterValues,\n} from '../../store';\nimport {\n useWidgetAutoRefresh,\n formatTimeUntilRefresh,\n useWidgetExport,\n useDrilldown,\n useWidgetData,\n useWidgetComments,\n type DrilldownContext,\n} from '../../hooks';\nimport { useApolloClient } from '@apollo/client/react';\nimport { GetDashboardDocument } from '../../../generated/wspace-operations';\nimport { getWidgetDefinition } from './WidgetRegistry';\nimport { WidgetHeader } from './WidgetHeader';\nimport { WidgetLoadingState } from './states/LoadingState';\nimport { WidgetErrorState } from './states/ErrorState';\nimport { WidgetEmptyState } from './states/EmptyState';\nimport { WidgetErrorBoundary } from './WidgetErrorBoundary';\nimport { hasRenderableCustomConfig, hasCustomIframeConfig } from './custom/config';\nimport { getBindingForWidget } from '../../utils/widgetBinding';\n\n// v2.0: Renderer factory and actions\nimport { WidgetRendererFactory } from '../../renderers/factory/WidgetRendererFactory';\nimport { WidgetActions } from './widget-actions';\nimport type { WidgetAction, ActionContext, ActionResult, RendererType } from '../../renderers/types/renderer';\n// Widget components - lazy loaded for better code splitting\n// Each widget loads only when its type is rendered\nconst MetricCardWidget = lazy(() => import('./metric-card').then((m) => ({ default: m.MetricCardWidget })));\nconst ChartWidget = lazy(() => import('./chart').then((m) => ({ default: m.ChartWidget })));\nconst TableWidget = lazy(() => import('./table').then((m) => ({ default: m.TableWidget })));\nconst PivotTableWidget = lazy(() => import('./pivot-table').then((m) => ({ default: m.PivotTableWidget })));\nconst GaugeWidget = lazy(() => import('./gauge').then((m) => ({ default: m.GaugeWidget })));\nconst ProgressWidget = lazy(() => import('./progress').then((m) => ({ default: m.ProgressWidget })));\nconst ListWidget = lazy(() => import('./list').then((m) => ({ default: m.ListWidget })));\nconst HeatmapWidget = lazy(() => import('./heatmap').then((m) => ({ default: m.HeatmapWidget })));\nconst RetentionWidget = lazy(() => import('./retention').then((m) => ({ default: m.RetentionWidget })));\nconst CalendarWidget = lazy(() => import('./calendar').then((m) => ({ default: m.CalendarWidget })));\nconst KanbanWidget = lazy(() => import('./kanban').then((m) => ({ default: m.KanbanWidget })));\nconst TimelineWidget = lazy(() => import('./timeline').then((m) => ({ default: m.TimelineWidget })));\nconst KPIComparisonWidget = lazy(() => import('./kpi-comparison').then((m) => ({ default: m.KPIComparisonWidget })));\nconst TextWidget = lazy(() => import('./text-widget').then((m) => ({ default: m.TextWidget })));\nconst MapWidget = lazy(() => import('./map-widget').then((m) => ({ default: m.MapWidget })));\nconst IframeWidget = lazy(() => import('./iframe-widget').then((m) => ({ default: m.IframeWidget })));\nconst CustomWidget = lazy(() => import('./custom').then((m) => ({ default: m.CustomWidget })));\n// AdaptiveCardWidget is HUGE (984KB) - lazy load only when 'form' type is used\nconst AdaptiveCardWidget = lazy(() => import('./adaptive-card').then((m) => ({ default: m.AdaptiveCardWidget })));\n// Comments panel - lazy loaded; only mounts when the user opens comments\nconst WidgetComments = lazy(() => import('./comments/WidgetComments').then((m) => ({ default: m.WidgetComments })));\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface WidgetWrapperProps {\n /** The widget data */\n widget: Widget;\n /** Widget content to render */\n children?: ReactNode;\n /** Data for the widget */\n data?: Record<string, unknown> | null;\n /** Custom class name */\n className?: string;\n /** Whether the widget is loading */\n isLoading?: boolean;\n /** Error message */\n error?: string | null;\n /** Callback to refresh widget data */\n onRefresh?: () => Promise<void>;\n /** Callback for drilldown navigation */\n onDrilldown?: (params: Record<string, unknown>) => void;\n /** v2.0: Widget actions */\n actions?: WidgetAction[];\n /** v2.0: Callback for action events */\n onAction?: (action: WidgetAction, context: ActionContext) => Promise<ActionResult | void>;\n /** Phase 2: Global filter values to apply to widget data */\n filterValues?: Record<string, unknown>;\n}\n\n// ============================================================================\n// Custom comparison for memo - ensures actions changes trigger re-render\n// ============================================================================\n\nfunction arePropsEqual(prevProps: WidgetWrapperProps, nextProps: WidgetWrapperProps): boolean {\n // Always re-render if widget ID changes\n if (prevProps.widget.id !== nextProps.widget.id) return false;\n // Re-render if widget was updated\n if (prevProps.widget.updatedAt !== nextProps.widget.updatedAt) return false;\n // Re-render if loading state changes\n if (prevProps.isLoading !== nextProps.isLoading) return false;\n // Re-render if error changes\n if (prevProps.error !== nextProps.error) return false;\n // Re-render if actions count changes\n if ((prevProps.actions?.length ?? 0) !== (nextProps.actions?.length ?? 0)) return false;\n // Check if any action ID changed\n if (prevProps.actions && nextProps.actions) {\n for (let i = 0; i < prevProps.actions.length; i++) {\n if (prevProps.actions[i]?.id !== nextProps.actions[i]?.id) return false;\n }\n }\n // Also check data changes\n if (prevProps.data !== nextProps.data) return false;\n // Phase 2: Re-render if filter values changed\n if (JSON.stringify(prevProps.filterValues) !== JSON.stringify(nextProps.filterValues)) return false;\n return true;\n}\n\n// ============================================================================\n// Component\n// ============================================================================\n\nexport const WidgetWrapper: FC<WidgetWrapperProps> = memo(function WidgetWrapper({\n widget,\n children,\n data,\n className = '',\n isLoading: isLoadingProp,\n error: errorProp,\n onRefresh,\n onDrilldown,\n actions,\n onAction,\n filterValues,\n}) {\n // Store state - use Dashboard store for edit mode (synced with toolbar)\n const isEditMode = useDashboardStore((state) => state.viewMode === 'edit');\n const selectWidget = useWidgetStore((state) => state.selectWidget);\n const isSelected = useIsWidgetSelected(widget.id);\n const uiState = useWidgetUIState(widget.id);\n const globalFilterValues = useGlobalFilterValues();\n const apolloClient = useApolloClient();\n\n // Map a global-filter's id -> the data field it targets (`config.field`).\n // Global CATEGORY/TEXT filter values are keyed in the store by filter id (a\n // UUID), not by the data column they filter. Without this map, applyClientFilters\n // can only fall back to value/heuristic matching, which fails to narrow rows\n // whose targeted column (e.g. `country`, `cohort`) isn't in the hardcoded\n // heuristic list — so a selected Country/Cohort would not actually filter the\n // widget. We resolve the targeted field from the dashboard's globalFilters\n // (already in the Apollo cache from the page load) so a UUID-keyed filter\n // matches the row's configured field exactly.\n const widgetDashboardId = (widget as unknown as Record<string, unknown>).dashboardId as string | undefined;\n const filterFieldMap = useMemo<Record<string, string>>(() => {\n if (!widgetDashboardId) return {};\n try {\n const cached = apolloClient.readQuery<{\n getDashboard?: {\n globalFilters?: Array<{ id: string; config?: Record<string, unknown> | null }>;\n };\n }>({ query: GetDashboardDocument, variables: { id: widgetDashboardId } });\n const map: Record<string, string> = {};\n for (const f of cached?.getDashboard?.globalFilters ?? []) {\n const field = f.config?.field;\n if (typeof field === 'string' && field) map[f.id] = field;\n }\n return map;\n } catch {\n return {};\n }\n }, [apolloClient, widgetDashboardId]);\n\n // Fetch per-widget data from backend (parser-processed data)\n // This is needed because listWidgetsByDashboard uses WidgetListFields (without data)\n // for performance, so each widget fetches its own data individually\n const widgetBinding = useMemo(() => getBindingForWidget(widget), [widget]);\n const hasDataSource =\n widgetBinding.source.kind !== 'DATASINK' ||\n !!widgetBinding.source.ref ||\n !!widgetBinding.parserId ||\n !!widget.datasetId;\n const { data: fetchedWidgetData, loading: widgetDataLoading } = useWidgetData(widget.id, {\n skip: !hasDataSource,\n pollInterval: (widget.refreshInterval ?? 0) * 1000 || 0,\n });\n\n // WORKAROUND: If Zustand store is empty, directly read filter_* params from URL\n // This handles race conditions where the store hasn't been populated yet\n const urlFilterValues = useMemo(() => {\n if (typeof window === 'undefined') return {};\n\n const params = new URLSearchParams(window.location.search);\n const filters: Record<string, unknown> = {};\n\n params.forEach((value, key) => {\n if (key.startsWith('filter_')) {\n const filterId = key.slice('filter_'.length);\n // Skip internal metadata keys\n if (!filterId.startsWith('__')) {\n filters[filterId] = value;\n }\n }\n });\n\n return filters;\n }, []);\n\n // Phase 2: Merge global filter values (from URL) with explicit filterValues prop\n // This ensures both URL params (filter_*) and drilldown params work together\n const mergedFilterValues = useMemo(() => {\n const merged: Record<string, unknown> = {};\n\n // First, add URL filter values as fallback (in case Zustand store hasn't loaded yet)\n if (urlFilterValues && Object.keys(urlFilterValues).length > 0) {\n Object.assign(merged, urlFilterValues);\n }\n\n // Then, add global filter values from Zustand store (if populated)\n if (globalFilterValues && Object.keys(globalFilterValues).length > 0) {\n Object.assign(merged, globalFilterValues);\n }\n\n // Finally, add/override with explicit filterValues prop (e.g., from drilldown modal)\n if (filterValues && Object.keys(filterValues).length > 0) {\n Object.assign(merged, filterValues);\n }\n\n return merged;\n }, [urlFilterValues, globalFilterValues, filterValues]);\n\n // Track active filters (client-side filtering until backend supports it)\n const hasFilters = Object.keys(mergedFilterValues).length > 0;\n\n // Merge loading/error from props and store\n // Show loading if widget data is being fetched for the first time (no data yet)\n const isLoading = isLoadingProp ?? (widgetDataLoading && !fetchedWidgetData) ?? uiState.isLoading;\n const error = errorProp ?? uiState.errorMessage;\n\n // Get widget definition\n const definition = getWidgetDefinition(widget.type);\n\n // Stable refresh callback - use ref to avoid creating new function on each render\n const onRefreshRef = useRef(onRefresh);\n useEffect(() => {\n onRefreshRef.current = onRefresh;\n }, [onRefresh]);\n\n const stableOnRefresh = useCallback(async () => {\n if (onRefreshRef.current) {\n await onRefreshRef.current();\n }\n }, []);\n\n // Auto-refresh\n const { timeUntilRefresh, isPaused } = useWidgetAutoRefresh({\n widgetId: widget.id,\n refreshInterval: widget.refreshInterval,\n onRefresh: stableOnRefresh,\n enabled: !isEditMode && !!widget.refreshInterval,\n });\n\n // Container ref for PNG export\n const containerRef = useRef<HTMLDivElement>(null);\n\n // Comments panel. The count query stays disabled until the panel is first\n // opened, so a dashboard of N widgets doesn't fire N comment queries on load.\n const [showComments, setShowComments] = useState(false);\n const [commentsEverOpened, setCommentsEverOpened] = useState(false);\n const { count: commentCount } = useWidgetComments(widget.id, commentsEverOpened);\n const toggleComments = useCallback(() => {\n setShowComments((open) => {\n const next = !open;\n if (next) setCommentsEverOpened(true);\n return next;\n });\n }, []);\n\n // Get widget data for export (computed early for hook)\n const exportData = useMemo(() => {\n if (data && Array.isArray(data)) return data;\n const rawData = (widget as unknown as Record<string, unknown>).data as Record<string, unknown> | undefined;\n if (rawData?.processed && Array.isArray(rawData.processed)) {\n return rawData.processed;\n }\n if (rawData?.raw) {\n const parsed = typeof rawData.raw === 'string' ? JSON.parse(rawData.raw) : rawData.raw;\n if (Array.isArray(parsed)) return parsed;\n }\n return null;\n }, [data, widget]);\n\n // Export functionality\n const { exportCSV, exportPNG } = useWidgetExport(widget, {\n data: exportData,\n containerRef: containerRef as unknown as RefObject<HTMLElement>,\n });\n\n // Helper to check if data is actually usable (has real content)\n const isUsableData = useCallback((d: unknown): boolean => {\n if (d === null || d === undefined) return false;\n if (Array.isArray(d)) return d.length > 0;\n if (typeof d === 'object') {\n const obj = d as Record<string, unknown>;\n const keys = Object.keys(obj);\n if (keys.length === 0) return false;\n // Check recursively for actual data content\n return keys.some((key) => {\n const val = obj[key];\n if (val === null || val === undefined || val === '') return false;\n if (Array.isArray(val)) return val.length > 0;\n if (typeof val === 'object') return isUsableData(val);\n return true;\n });\n }\n return true;\n }, []);\n\n // Phase 2: Client-side filter function for widget data\n const applyClientFilters = useCallback(\n (\n widgetData: Record<string, unknown> | Record<string, unknown>[]\n ): Record<string, unknown> | Record<string, unknown>[] => {\n if (!hasFilters || !widgetData) return widgetData;\n\n // Separate drilldown context filters (ctx_*) from regular filters\n const contextFilters: Record<string, unknown> = {};\n const regularFilters: Record<string, unknown> = {};\n\n Object.entries(mergedFilterValues || {}).forEach(([key, value]) => {\n if (key.startsWith('ctx_')) {\n // Strip ctx_ prefix to get the target field name\n const fieldName = key.slice(4); // Remove 'ctx_'\n contextFilters[fieldName] = value;\n } else if (!key.startsWith('__')) {\n // Skip internal metadata keys (__drilldown_depth, etc.)\n regularFilters[key] = value;\n }\n });\n\n // Helper to match a value against a filter (case-insensitive)\n const matchesFilter = (itemValue: unknown, filterValue: unknown): boolean => {\n if (filterValue === undefined || filterValue === null || filterValue === '') return true;\n if (itemValue === undefined || itemValue === null) return false;\n\n const itemStr = String(itemValue).toLowerCase();\n const filterStr = String(filterValue).toLowerCase();\n\n // Exact match or contains\n return itemStr === filterStr || itemStr.includes(filterStr);\n };\n\n // Helper to find a matching field in the item (case-insensitive key matching)\n const findFieldValue = (item: Record<string, unknown>, targetField: string): unknown => {\n const targetLower = targetField.toLowerCase();\n\n // Try exact match first\n if (item[targetField] !== undefined) return item[targetField];\n\n // Try case-insensitive match\n const matchingKey = Object.keys(item).find((k) => k.toLowerCase() === targetLower);\n if (matchingKey) return item[matchingKey];\n\n // Try partial match (e.g., 'region' matches 'regionName' or 'user_region')\n const partialMatch = Object.keys(item).find(\n (k) => k.toLowerCase().includes(targetLower) || targetLower.includes(k.toLowerCase())\n );\n if (partialMatch) return item[partialMatch];\n\n // Try stripping common prefixes from target field (e.g., 'kpiId' -> 'id', 'rowName' -> 'name')\n // This handles drilldown context where widget passes 'kpiId' but data has 'id'\n const commonPrefixes = ['kpi', 'row', 'item', 'data', 'cell', 'record', 'entry'];\n for (const prefix of commonPrefixes) {\n if (targetLower.startsWith(prefix) && targetLower.length > prefix.length) {\n const strippedField = targetLower.slice(prefix.length);\n // Try exact match with stripped field\n const strippedMatch = Object.keys(item).find((k) => k.toLowerCase() === strippedField);\n if (strippedMatch) return item[strippedMatch];\n }\n }\n\n return undefined;\n };\n\n // Helper function to filter an array of items\n const filterItems = (items: Record<string, unknown>[]): Record<string, unknown>[] => {\n return items.filter((item: Record<string, unknown>) => {\n // Only object rows are field-filterable. An array of primitives (e.g.\n // a heatmap's `rows: [\"5W-MedSurg\", …]`) carries no named fields — keep\n // every element. Without this, `findFieldValue` indexes into the string\n // by character offset and spuriously \"matches\" a filter, dropping rows.\n if (item === null || typeof item !== 'object' || Array.isArray(item)) {\n return true;\n }\n // First, apply drilldown context filters (ctx_*) - these have explicit field names\n for (const [fieldName, filterValue] of Object.entries(contextFilters)) {\n if (filterValue === undefined || filterValue === null || filterValue === '') continue;\n\n const itemValue = findFieldValue(item, fieldName);\n // If the field doesn't exist in this data item, skip this context filter.\n // Drilldown context params (e.g., source=support_status) are metadata about\n // the drilldown origin and should NOT filter out data when the target\n // dashboard's widgets don't have a matching field.\n if (itemValue === undefined) continue;\n if (!matchesFilter(itemValue, filterValue)) {\n return false;\n }\n }\n\n // Then, apply regular filters\n for (const [filterKey, filterValue] of Object.entries(regularFilters)) {\n if (filterValue === undefined || filterValue === null || filterValue === '') continue;\n\n // For date range filters\n if (typeof filterValue === 'object') {\n const fv = filterValue as Record<string, unknown>;\n if (fv.start || fv.end) {\n const dateFields = Object.entries(item).filter(\n ([k, _v]) => k.toLowerCase().includes('date') || k.toLowerCase().includes('time')\n );\n if (dateFields.length > 0) {\n const itemDate = new Date(dateFields[0][1] as string);\n if (fv.start && itemDate < new Date(fv.start as string)) return false;\n if (fv.end && itemDate > new Date(fv.end as string)) return false;\n }\n continue;\n }\n }\n\n // For numeric range filters\n if (typeof filterValue === 'object') {\n const nv = filterValue as Record<string, unknown>;\n if (nv.min !== undefined || nv.max !== undefined) {\n const numericFields = Object.entries(item).filter(([_k, v]) => typeof v === 'number');\n if (numericFields.length > 0) {\n const itemNum = numericFields[0][1] as number;\n if (nv.min !== undefined && itemNum < (nv.min as number)) return false;\n if (nv.max !== undefined && itemNum > (nv.max as number)) return false;\n }\n continue;\n }\n }\n\n // Any other object-shaped filter value (e.g. a DATE_RANGE filter set\n // to a preset like { preset: \"last_30_days\" } with no resolved\n // start/end, or a structured value we don't understand) cannot be\n // compared with the scalar matchers below. Passing it through would\n // stringify it to \"[object Object]\" and, via fuzzy field matching\n // (e.g. an `enrolledAt` filter partial-matching an `enrolled` number\n // column), spuriously exclude EVERY row. Treat such values as a no-op\n // for client-side filtering — the row set is unchanged until the\n // filter resolves to concrete start/end or scalar values.\n if (filterValue !== null && typeof filterValue === 'object' && !Array.isArray(filterValue)) {\n continue;\n }\n\n // Global CATEGORY/TEXT filters are keyed by filter id (UUID). Resolve\n // the data column they target from the filter's config.field. When the\n // widget's rows carry that column, the filter is authoritative — a\n // mismatch excludes the row; a missing column is a no-op (the filter\n // simply doesn't apply to this widget's shape). This is what makes a\n // selected Country/Cohort actually narrow the visible data.\n const targetField = filterFieldMap[filterKey];\n if (targetField) {\n const mappedValue = findFieldValue(item, targetField);\n if (mappedValue !== undefined) {\n if (!matchesFilter(mappedValue, filterValue)) {\n return false;\n }\n continue;\n }\n // Configured field absent from this widget's rows → filter is a\n // no-op for this widget (do not fall through to value heuristics,\n // which could spuriously match an unrelated column).\n continue;\n }\n\n // Try to match by filter key name first (for named filters). When\n // the widget's data actually carries the filter's field, the filter\n // is authoritative — a mismatch excludes the row.\n const fieldValue = findFieldValue(item, filterKey);\n if (fieldValue !== undefined) {\n if (!matchesFilter(fieldValue, filterValue)) {\n return false;\n }\n continue;\n }\n\n // For text/category filters - try multiple matching strategies\n const filterStr = String(filterValue).toLowerCase();\n\n // Strategy 1: Check all field values for exact or partial match\n const itemValues = Object.values(item).map((v) => String(v).toLowerCase());\n const hasMatch = itemValues.some((v) => v === filterStr || v.includes(filterStr));\n\n if (!hasMatch) {\n // Strategy 2: Try to find a field name that matches the filter value context\n const fieldNames = Object.keys(item).map((k) => k.toLowerCase());\n const possibleFields = fieldNames.filter(\n (f) =>\n f.includes('category') ||\n f.includes('type') ||\n f.includes('status') ||\n f.includes('name') ||\n f.includes('region') ||\n f.includes('group')\n );\n\n let fieldMatch = false;\n for (const fieldName of possibleFields) {\n const originalKey = Object.keys(item).find((k) => k.toLowerCase() === fieldName);\n if (originalKey) {\n const itemFieldValue = String(item[originalKey]).toLowerCase();\n if (itemFieldValue === filterStr || itemFieldValue.includes(filterStr)) {\n fieldMatch = true;\n break;\n }\n }\n }\n\n // The filter's field is NOT present in this dataset (named-field\n // lookup failed AND no value/heuristic match). A global filter that\n // doesn't apply to a widget's shape must be a no-op for that widget\n // — not a silent \"exclude every row\". This mirrors the ctx_* rule\n // above (skip when the targeted field is absent). Without this, an\n // always-active required filter (e.g. campus=main) blanks every\n // parser-derived widget whose output has no campus column.\n if (!fieldMatch) {\n continue;\n }\n }\n }\n return true;\n });\n };\n\n // If data is an array, filter the items directly\n if (Array.isArray(widgetData)) {\n const filtered = filterItems(widgetData);\n return filtered;\n }\n\n // Handle object with array properties (rows, items, members, questions, data, etc.)\n if (widgetData && typeof widgetData === 'object') {\n // Common array property names in widget data\n const arrayPropertyNames = [\n 'kpis', // KPI Comparison widget\n 'rows', // Table widget\n 'items', // List widget\n 'members', // Team/member widgets\n 'questions', // Form widget\n 'data', // Generic data\n 'records', // Database-style data\n 'results', // Search/query results\n 'entries', // Log/feed entries\n 'list', // Generic list\n 'values', // Value arrays\n 'series', // Chart series\n 'datasets', // Chart datasets\n ];\n\n for (const propName of arrayPropertyNames) {\n if (widgetData[propName] && Array.isArray(widgetData[propName])) {\n const filteredArray = filterItems(widgetData[propName]);\n return {\n ...widgetData,\n [propName]: filteredArray,\n ...(propName === 'rows' ? { totalRows: filteredArray.length } : {}),\n };\n }\n }\n\n // If no known array property found, check for any array property\n const arrayProps = Object.entries(widgetData).filter(([_key, v]) => Array.isArray(v));\n if (arrayProps.length > 0) {\n const [propName, propValue] = arrayProps[0];\n const filteredArray = filterItems(propValue as Record<string, unknown>[]);\n return {\n ...widgetData,\n [propName]: filteredArray,\n };\n }\n }\n\n // For non-filterable data, return as-is\n return widgetData;\n },\n [hasFilters, mergedFilterValues, widget.id, filterFieldMap]\n );\n\n // Get widget data from the widget itself (fetched from backend)\n const realWidgetData = useMemo(() => {\n let rawWidgetData = null;\n\n // Priority 1: Explicitly passed data prop\n if (data && isUsableData(data)) {\n rawWidgetData = data;\n }\n // Priority 2: Per-widget fetched data (from useWidgetData hook)\n // fetchedWidgetData IS a WidgetData object: { raw, processed, fetchedAt, cached }\n else if (fetchedWidgetData) {\n const fetched = fetchedWidgetData as unknown as Record<string, unknown>;\n if (fetched?.processed && isUsableData(fetched.processed)) {\n rawWidgetData = fetched.processed;\n } else if (fetched?.raw) {\n try {\n const parsed = typeof fetched.raw === 'string' ? JSON.parse(fetched.raw as string) : fetched.raw;\n if (isUsableData(parsed)) rawWidgetData = parsed;\n } catch {\n // Invalid JSON, ignore\n }\n }\n }\n // Priority 3: widget.data from GraphQL response (if already on widget object)\n else {\n const rawData = (widget as unknown as Record<string, unknown>).data as Record<string, unknown> | undefined;\n if (rawData?.processed && isUsableData(rawData.processed)) {\n rawWidgetData = rawData.processed;\n } else if (rawData?.raw) {\n try {\n const parsed = typeof rawData.raw === 'string' ? JSON.parse(rawData.raw) : rawData.raw;\n if (isUsableData(parsed)) rawWidgetData = parsed;\n } catch {\n // Invalid JSON, ignore\n }\n }\n }\n\n // Priority 4: config.mockData — user-configured sample JSON from Widget Properties Data tab\n // This is NOT auto-generated mock data; it's explicit JSON the user pasted in the UI\n if (!rawWidgetData) {\n const configMockData = (widget.config as Record<string, unknown> | undefined)?.mockData;\n if (configMockData) {\n try {\n const parsed = typeof configMockData === 'string' ? JSON.parse(configMockData) : configMockData;\n if (isUsableData(parsed)) {\n rawWidgetData = parsed;\n }\n } catch (e) {}\n }\n }\n\n // Generic parser-output resolution: a widget may bind to a parser whose\n // output is an envelope ({ byUnit:[...], house:{...} }) rather than the\n // exact array/object the renderer wants. config.dataKey / dataPath /\n // seriesPath is a dot-path INTO the resolved data that points at the\n // renderable subtree (e.g. \"byUnit\" for a table, \"rows\" for a chart).\n // Resolving it here keeps every renderer generic — the use-case-specific\n // shape knowledge lives in the widget config (set by the seed/UI), not in\n // the renderer. valueField (single-value metric path) is intentionally NOT\n // applied here: MetricCardWidget resolves it itself against the envelope.\n if (rawWidgetData && typeof rawWidgetData === 'object' && !Array.isArray(rawWidgetData)) {\n const cfg = widget.config as Record<string, unknown> | undefined;\n const pathKey = (cfg?.dataKey ?? cfg?.dataPath ?? cfg?.seriesPath) as string | undefined;\n if (pathKey && typeof pathKey === 'string') {\n const resolved = pathKey.split('.').reduce<unknown>((cur, seg) => {\n return cur && typeof cur === 'object' ? (cur as Record<string, unknown>)[seg] : undefined;\n }, rawWidgetData);\n if (resolved !== undefined && resolved !== null && isUsableData(resolved)) {\n rawWidgetData = resolved as Record<string, unknown>;\n }\n }\n }\n\n // Phase 2: Apply client-side filters if active\n if (hasFilters && rawWidgetData) {\n const filtered = applyClientFilters(rawWidgetData);\n return filtered;\n }\n\n return rawWidgetData;\n }, [data, widget, fetchedWidgetData, hasFilters, applyClientFilters, mergedFilterValues, isUsableData]);\n\n // Final widget data - real data only, no mock fallback\n const widgetData = useMemo(() => {\n return realWidgetData ?? null;\n }, [realWidgetData]);\n\n // Drilldown navigation (must be after widgetData is defined)\n const { executeDrilldown, canDrilldown } = useDrilldown({\n onDrilldown: (params, _mode) => {\n onDrilldown?.(params);\n },\n });\n\n // Check if widget has drilldown configured\n const hasDrilldown = useMemo(() => canDrilldown(widget), [widget, canDrilldown]);\n\n // Handle drilldown execution with context\n const handleDrilldown = useCallback(\n (selectedData?: Record<string, unknown>) => {\n if (!widget.drilldown?.enabled) return;\n\n const context: DrilldownContext = {\n selectedData: selectedData || {},\n globalFilters: globalFilterValues || {},\n widgetData: widgetData || {},\n metadata: {\n widgetId: widget.id,\n widgetType: widget.type,\n widgetTitle: widget.title,\n },\n sourceDashboardId: widget.dashboardId,\n };\n\n executeDrilldown(widget.drilldown, context);\n },\n [widget, widgetData, globalFilterValues, executeDrilldown]\n );\n\n // Track mouse position to distinguish click from drag\n const mouseDownPos = useRef<{ x: number; y: number } | null>(null);\n const DRAG_THRESHOLD = 5; // pixels - if mouse moves more than this, it's a drag\n\n // Handle mouse down - record position\n const handleMouseDown = useCallback((e: React.MouseEvent) => {\n mouseDownPos.current = { x: e.clientX, y: e.clientY };\n }, []);\n\n // Handle widget click - Edit mode only (View mode drilldown is triggered by data clicks)\n // Only trigger if mouse hasn't moved much (not a drag)\n const handleClick = useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation(); // Prevent DashboardGrid from also handling\n\n // Check if this was a drag (mouse moved significantly)\n if (mouseDownPos.current) {\n const dx = Math.abs(e.clientX - mouseDownPos.current.x);\n const dy = Math.abs(e.clientY - mouseDownPos.current.y);\n if (dx > DRAG_THRESHOLD || dy > DRAG_THRESHOLD) {\n // This was a drag, not a click - don't open config panel\n mouseDownPos.current = null;\n return;\n }\n }\n mouseDownPos.current = null;\n\n if (isEditMode) {\n // Edit mode: select widget for editing\n selectWidget(widget.id);\n }\n // View mode: drilldown is triggered by clicking specific data elements\n // (table rows, chart points, etc.) - not by clicking the widget itself\n },\n [isEditMode, selectWidget, widget.id]\n );\n\n // Handle keyboard navigation (Edit mode only)\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n event.stopPropagation();\n if (isEditMode) {\n selectWidget(widget.id);\n }\n }\n },\n [isEditMode, selectWidget, widget.id]\n );\n\n const hasRenderableCustomWidgetConfig = useMemo(\n () => widget.type === 'custom' && hasRenderableCustomConfig(widget.config),\n [widget.type, widget.config]\n );\n\n const customWidgetHasIframeConfig = useMemo(\n () => widget.type === 'custom' && hasCustomIframeConfig(widget.config),\n [widget.type, widget.config]\n );\n\n const showContainerDrilldownHints = hasDrilldown && !customWidgetHasIframeConfig;\n\n // Determine if data is empty\n const isEmpty = !isLoading && !error && !widgetData && !hasRenderableCustomWidgetConfig;\n\n // v2.0: Check if widget has a renderer specified (non-BIGCONSOLE)\n const widgetRenderer = useMemo(() => {\n const widgetWithRenderer = widget as Widget & { renderer?: RendererType };\n return widgetWithRenderer.renderer;\n }, [widget]);\n\n // v2.0: Determine if we should use the factory (non-BIGCONSOLE renderer)\n const useRendererFactory = useMemo(() => {\n const shouldUse = widgetRenderer && widgetRenderer !== 'BIGCONSOLE';\n return shouldUse;\n }, [widgetRenderer]);\n\n // v2.0: Create action context\n const actionContext = useMemo<ActionContext>(\n () => ({\n widgetId: widget.id,\n data: widgetData || {},\n }),\n [widget.id, widgetData]\n );\n\n // v2.0: Handle action callback from WidgetRendererFactory\n // Receives (action: WidgetAction, context: ActionContext) and forwards to parent\n // Checks if a more detailed backend action exists with same name\n const handleActionFromFactory = useCallback(\n (action: WidgetAction, context: ActionContext) => {\n if (!onAction) return;\n\n // Try to find a matching backend action by name (has more details like confirmation)\n const existingAction = actions?.find((a) => a.name === action.name);\n\n if (existingAction) {\n // Use existing backend action (has confirmation, style, icon, etc.)\n onAction(existingAction, context);\n } else {\n // Use the action from WidgetRendererFactory as-is\n onAction(action, context);\n }\n },\n [onAction, actions]\n );\n\n // Render the appropriate widget component based on type (v1.0 snake_case)\n const renderWidgetComponent = useCallback(() => {\n // Extract data based on widget type expectations\n // Different widgets expect different data formats\n const getDataForWidget = () => {\n if (!widgetData) return widgetData;\n\n // If data has 'rows' property (table data), extract rows\n if (widget.type === 'table' || widget.type === 'pivot_table') {\n if (Array.isArray(widgetData)) return widgetData;\n if (widgetData && typeof widgetData === 'object' && 'rows' in widgetData) {\n return (widgetData as { rows: unknown[] }).rows;\n }\n }\n\n // If data has 'items' property (list data), extract items\n if (widget.type === 'list') {\n if (Array.isArray(widgetData)) return widgetData;\n if (widgetData && typeof widgetData === 'object' && 'items' in widgetData) {\n return (widgetData as { items: unknown[] }).items;\n }\n }\n\n // If data has 'stages' property (old funnel format), extract stages\n if (widget.type === 'funnel_chart') {\n if (Array.isArray(widgetData)) return widgetData;\n if (widgetData && typeof widgetData === 'object' && 'stages' in widgetData) {\n return (widgetData as { stages: unknown[] }).stages;\n }\n }\n\n // If data has 'datasets' property (old chart format), convert to array format\n if (widget.type === 'chart') {\n if (Array.isArray(widgetData)) return widgetData;\n if (widgetData && typeof widgetData === 'object' && 'datasets' in widgetData) {\n // Convert old format to new array format\n const oldData = widgetData as { labels?: string[]; datasets?: { name: string; data: number[] }[] };\n if (oldData.labels && oldData.datasets) {\n return oldData.labels.map((label, i) => {\n const point: Record<string, unknown> = { name: label };\n oldData.datasets?.forEach((ds) => {\n point[ds.name.toLowerCase()] = ds.data[i];\n });\n return point;\n });\n }\n }\n }\n\n // For text widgets: convert parsed object data to {content, format} shape\n if (widget.type === 'text') {\n if (widgetData && typeof widgetData === 'object' && !('content' in (widgetData as Record<string, unknown>))) {\n // Auto-format parsed data as markdown content\n const obj = widgetData as Record<string, unknown>;\n const lines: string[] = [];\n for (const [key, val] of Object.entries(obj)) {\n if (val && typeof val === 'object' && !Array.isArray(val)) {\n lines.push(`### ${key}`);\n for (const [k2, v2] of Object.entries(val as Record<string, unknown>)) {\n lines.push(`- **${k2}:** ${v2}`);\n }\n } else if (Array.isArray(val)) {\n lines.push(`### ${key}`);\n val.slice(0, 10).forEach((item: unknown) => {\n if (item && typeof item === 'object') {\n const entries = Object.entries(item as Record<string, unknown>);\n lines.push(`- ${entries.map(([k, v]) => `**${k}:** ${v}`).join(' | ')}`);\n } else {\n lines.push(`- ${item}`);\n }\n });\n } else {\n lines.push(`- **${key}:** ${val}`);\n }\n }\n return { content: lines.join('\\n'), format: 'markdown' };\n }\n }\n\n // For custom widgets: pass data through with extracted value if configured\n if (widget.type === 'custom') {\n const config = widget.config as Record<string, unknown> | undefined;\n const valueField = config?.valueField as string | undefined;\n if (valueField && widgetData && typeof widgetData === 'object' && !Array.isArray(widgetData)) {\n const obj = widgetData as Record<string, unknown>;\n if (valueField in obj) {\n return { value: obj[valueField], label: widget.title, data: obj };\n }\n }\n }\n\n return widgetData;\n };\n\n const normalizedData = getDataForWidget();\n const props = {\n widget,\n data: normalizedData,\n onDrilldown: hasDrilldown ? handleDrilldown : undefined,\n };\n\n // v2.0: Use WidgetRendererFactory for non-BIGCONSOLE renderers\n if (useRendererFactory) {\n // For factory renderers (Adaptive Card, BlockKit, Custom), pass the RAW\n // processed data — NOT the type-normalized data. Normalization (e.g., text→markdown)\n // is only for BIGCONSOLE renderer widgets. Factory renderers handle their own\n // template interpolation against the raw data object.\n let factoryData: Record<string, unknown> = {};\n\n if (\n realWidgetData &&\n typeof realWidgetData === 'object' &&\n !Array.isArray(realWidgetData) &&\n Object.keys(realWidgetData as Record<string, unknown>).length > 0\n ) {\n // Use real data from backend (raw processed, not type-normalized)\n factoryData = { ...(realWidgetData as Record<string, unknown>) };\n }\n\n // For CUSTOM renderer: enrich data with standard fields expected by built-in components.\n // Built-in components (Counter, Card, SimpleText) read specific fields from data:\n // Counter: data.value, Card: data.title/data.description, SimpleText: data.text\n // Parsed data from datasinks has domain-specific fields (totalFiles, totalMessages, etc.)\n // Use config.valueField to extract the primary value and map it to standard fields.\n const internalType = (widget.config as Record<string, unknown> | undefined)?._internalWidgetType as\n string | undefined;\n if (internalType === 'custom' && Object.keys(factoryData).length > 0) {\n const config = widget.config as Record<string, unknown> | undefined;\n const valueField = config?.valueField as string | undefined;\n if (valueField && valueField in factoryData) {\n const val = factoryData[valueField];\n const formatted = typeof val === 'number' ? val.toLocaleString() : String(val);\n // Map to standard fields for all built-in custom components\n factoryData = {\n ...factoryData,\n value: val, // Counter component\n title: factoryData.title || formatted, // Card component\n description: factoryData.description || widget.title || '', // Card component\n text: factoryData.text || formatted, // SimpleText component\n };\n }\n }\n\n return (\n <WidgetRendererFactory\n widget={widget}\n data={factoryData}\n isEditMode={isEditMode}\n isSelected={isSelected}\n isLoading={isLoading}\n error={error}\n onDrilldown={hasDrilldown ? handleDrilldown : undefined}\n onAction={handleActionFromFactory}\n />\n );\n }\n\n // v1.0: Use switch-case for BIGCONSOLE renderer (default)\n // Normalize widget type to lowercase for case-insensitive matching\n const normalizedType = widget.type?.toLowerCase() || '';\n switch (normalizedType) {\n case 'metric_card':\n return <MetricCardWidget {...props} />;\n case 'kpi_card_comparison':\n return <KPIComparisonWidget {...props} />;\n case 'chart':\n case 'funnel_chart':\n return <ChartWidget {...props} />;\n case 'table':\n return <TableWidget {...props} />;\n case 'pivot_table':\n return <PivotTableWidget {...props} />;\n case 'gauge':\n return <GaugeWidget {...props} />;\n case 'progress':\n return <ProgressWidget {...props} />;\n case 'list':\n return <ListWidget {...props} />;\n case 'heatmap':\n return <HeatmapWidget {...props} />;\n case 'retention':\n return <RetentionWidget {...props} />;\n case 'calendar':\n return <CalendarWidget {...props} />;\n case 'timeline':\n return <TimelineWidget {...props} />;\n case 'kanban':\n return <KanbanWidget {...props} />;\n case 'form':\n return <AdaptiveCardWidget {...props} />;\n case 'text':\n return <TextWidget {...props} />;\n case 'iframe':\n return <IframeWidget {...props} />;\n case 'map':\n return <MapWidget {...props} />;\n case 'custom':\n return <CustomWidget {...props} />;\n default:\n return children || <WidgetEmptyState widgetType={widget.type} />;\n }\n }, [\n widget,\n widgetData,\n children,\n hasDrilldown,\n handleDrilldown,\n useRendererFactory,\n isEditMode,\n isSelected,\n isLoading,\n error,\n handleActionFromFactory,\n realWidgetData,\n ]);\n\n // Determine content to render\n const renderContent = () => {\n if (isLoading) {\n return <WidgetLoadingState />;\n }\n\n if (error) {\n return <WidgetErrorState error={error} onRetry={onRefresh} />;\n }\n\n if (isEmpty && !children) {\n // v2.0: Check parserId (primary) or dataSinkId (for context/drilldowns)\n return (\n <WidgetEmptyState\n widgetType={widget.type}\n hasDataSource={hasDataSource}\n templateSlot={\n typeof widget.metadata?.['templateDataSinkSlot'] === 'string'\n ? (widget.metadata['templateDataSinkSlot'] as string)\n : null\n }\n />\n );\n }\n\n // resetKey auto-resets the boundary on parser/sink re-bind or config edit without widget.id changing (BOFF-2242).\n const resetKey = `${widgetBinding.source.kind}|${widgetBinding.source.ref ?? ''}|${widgetBinding.parserId ?? ''}|${widget.updatedAt ?? ''}`;\n\n return (\n <WidgetErrorBoundary widgetId={widget.id} widgetType={widget.type} widgetTitle={widget.title} resetKey={resetKey}>\n {children ?? <Suspense fallback={<WidgetLoadingState />}>{renderWidgetComponent()}</Suspense>}\n </WidgetErrorBoundary>\n );\n };\n\n return (\n <div\n ref={containerRef}\n className={`\n group relative flex flex-col\n h-full w-full\n rounded-lg border\n bg-bg-surface\n transition-all duration-200\n ${\n isSelected && isEditMode\n ? 'border-action-primary-border ring-2 ring-action-primary-border/30'\n : 'border-border-default hover:border-action-primary-bg'\n }\n ${isEditMode ? 'cursor-pointer' : ''}\n ${className}\n `}\n onMouseDown={handleMouseDown}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n tabIndex={isEditMode ? 0 : -1}\n role={isEditMode ? 'button' : undefined}\n aria-selected={isSelected}\n aria-label={`Widget: ${widget.title}`}\n data-widget-id={widget.id}\n data-widget-type={widget.type}\n >\n {/* Header */}\n <WidgetHeader\n widget={widget}\n definition={definition}\n isSelected={isSelected}\n isEditMode={isEditMode}\n isLoading={isLoading}\n timeUntilRefresh={widget.refreshInterval && !isPaused ? formatTimeUntilRefresh(timeUntilRefresh) : undefined}\n hasDrilldown={hasDrilldown}\n onRefresh={onRefresh}\n onExportCSV={exportData ? exportCSV : undefined}\n onExportPNG={exportPNG}\n onDrilldown={hasDrilldown ? () => handleDrilldown() : undefined}\n onToggleComments={toggleComments}\n commentsOpen={showComments}\n commentCount={commentsEverOpened ? commentCount : undefined}\n />\n\n {/* Content Area */}\n <div\n className={`\n flex-1 overflow-hidden p-4 min-h-0\n ${showContainerDrilldownHints && !isEditMode ? 'cursor-pointer' : ''}\n `}\n title={showContainerDrilldownHints && !isEditMode ? 'Click data to drill down' : undefined}\n >\n <div className=\"h-full overflow-auto\">{renderContent()}</div>\n </div>\n\n {/* v2.0: Widget Actions */}\n {actions && actions.length > 0 && !isLoading && !error && (\n <div className=\"px-4 py-3 border-t border-border-default bg-bg-sunken\" style={{ flexShrink: 0 }}>\n <WidgetActions\n actions={actions}\n context={actionContext}\n onAction={onAction}\n disabled={isEditMode}\n layout=\"horizontal\"\n size=\"sm\"\n />\n </div>\n )}\n\n {/* Edit mode: react-grid-layout provides resize handles */}\n\n {/* Drilldown Indicator */}\n {showContainerDrilldownHints && !isEditMode && (\n <div\n className=\"\n absolute bottom-2 right-2\n opacity-0 group-hover:opacity-100\n transition-opacity duration-200\n \"\n title=\"Click to drill down\"\n >\n <svg className=\"w-4 h-4 text-text-secondary\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M13 7l5 5m0 0l-5 5m5-5H6\" />\n </svg>\n </div>\n )}\n\n {/* Comments panel (overlay) */}\n {showComments && (\n <Suspense fallback={null}>\n <WidgetComments widgetId={widget.id} onClose={() => setShowComments(false)} />\n </Suspense>\n )}\n </div>\n );\n}, arePropsEqual);\n\nexport default WidgetWrapper;\n"],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,EAAgB,GAAM;KAAI,CAAA;IACrE,CAAA;GAET;;GAEP,EAAc"}
@@ -1,8 +1,8 @@
1
1
  import { memo as e } from "react";
2
2
  import { jsx as t, jsxs as n } from "react/jsx-runtime";
3
3
  //#region src/bigconsole/components/widgets/states/EmptyState.tsx
4
- var r = e(function({ widgetType: e, hasDataSource: r = !1, message: a }) {
5
- let o = a || (r ? i(e) : "Connect a data source to display data");
4
+ var r = e(function({ widgetType: e, hasDataSource: r = !1, message: a, templateSlot: o }) {
5
+ let s = a || (!r && o ? `Connect the "${o}" data source to finish setting up this widget` : r ? i(e) : "Connect a data source to display data");
6
6
  return /* @__PURE__ */ n("div", {
7
7
  className: "\n flex flex-col items-center justify-center\n h-full w-full min-h-[120px]\n text-center\n px-4\n ",
8
8
  children: [
@@ -23,7 +23,7 @@ var r = e(function({ widgetType: e, hasDataSource: r = !1, message: a }) {
23
23
  }),
24
24
  /* @__PURE__ */ t("p", {
25
25
  className: "text-sm text-text-secondary",
26
- children: o
26
+ children: s
27
27
  }),
28
28
  !r && /* @__PURE__ */ t("p", {
29
29
  className: "text-xs text-text-secondary mt-2 max-w-[200px]",
@@ -1 +1 @@
1
- {"version":3,"file":"EmptyState.js","names":[],"sources":["../../../../../src/bigconsole/components/widgets/states/EmptyState.tsx"],"sourcesContent":["/**\n * WidgetEmptyState Component\n *\n * Empty state displayed when widget has no data.\n */\n\nimport { type FC, memo } from 'react';\nimport type { WidgetType } from '../../../types';\n\nexport interface WidgetEmptyStateProps {\n /** Widget type for context-specific messaging */\n widgetType?: WidgetType;\n /** Whether a data source is configured */\n hasDataSource?: boolean;\n /** Custom message */\n message?: string;\n}\n\nexport const WidgetEmptyState: FC<WidgetEmptyStateProps> = memo(function WidgetEmptyState({\n widgetType,\n hasDataSource = false,\n message,\n}) {\n // Determine appropriate message\n const displayMessage =\n message || (!hasDataSource ? 'Connect a data source to display data' : getEmptyMessageForType(widgetType));\n\n return (\n <div\n className=\"\n flex flex-col items-center justify-center\n h-full w-full min-h-[120px]\n text-center\n px-4\n \"\n >\n {/* Empty Icon */}\n <div\n className=\"\n w-12 h-12 mb-3\n flex items-center justify-center\n rounded-full\n bg-bg-sunken\n text-text-secondary\n \"\n >\n <svg className=\"w-6 h-6\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4\"\n />\n </svg>\n </div>\n\n {/* Message */}\n <p className=\"text-sm text-text-secondary\">{displayMessage}</p>\n\n {/* Data source hint */}\n {!hasDataSource && (\n <p className=\"text-xs text-text-secondary mt-2 max-w-[200px]\">Click Edit to configure this widget</p>\n )}\n </div>\n );\n});\n\n/**\n * Get context-specific empty message for widget type (v1.0 snake_case)\n */\nfunction getEmptyMessageForType(type?: WidgetType): string {\n switch (type) {\n case 'metric_card':\n case 'kpi_card_comparison':\n return 'No metrics available';\n case 'chart':\n case 'funnel_chart':\n return 'No chart data available';\n case 'table':\n case 'pivot_table':\n return 'No rows to display';\n case 'gauge':\n case 'progress':\n return 'No value available';\n case 'list':\n return 'No items to display';\n case 'heatmap':\n return 'No heatmap data available';\n case 'calendar':\n case 'timeline':\n case 'kanban':\n return 'No schedule data available';\n case 'map':\n return 'No location data available';\n case 'form':\n return 'Form not configured';\n case 'text':\n case 'iframe':\n return 'No content configured';\n case 'custom':\n return 'Custom widget not configured';\n default:\n return 'No data available';\n }\n}\n\nexport default WidgetEmptyState;\n"],"mappings":";;;AAkBA,IAAa,IAA8C,EAAK,SAA0B,EACxF,eACA,mBAAgB,IAChB,cACC;CAED,IAAM,IACJ,MAAa,IAA0D,EAAuB,EAAW,GAA5E;AAE/B,QACE,kBAAC,OAAD;EACE,WAAU;YADZ;GASE,kBAAC,OAAD;IACE,WAAU;cAQV,kBAAC,OAAD;KAAK,WAAU;KAAU,MAAK;KAAO,QAAO;KAAe,SAAQ;eACjE,kBAAC,QAAD;MACE,eAAc;MACd,gBAAe;MACf,aAAa;MACb,GAAE;MACF,CAAA;KACE,CAAA;IACF,CAAA;GAGN,kBAAC,KAAD;IAAG,WAAU;cAA+B;IAAmB,CAAA;GAG9D,CAAC,KACA,kBAAC,KAAD;IAAG,WAAU;cAAiD;IAAuC,CAAA;GAEnG;;EAER;AAKF,SAAS,EAAuB,GAA2B;AACzD,SAAQ,GAAR;EACE,KAAK;EACL,KAAK,sBACH,QAAO;EACT,KAAK;EACL,KAAK,eACH,QAAO;EACT,KAAK;EACL,KAAK,cACH,QAAO;EACT,KAAK;EACL,KAAK,WACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,UACH,QAAO;EACT,KAAK;EACL,KAAK;EACL,KAAK,SACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK;EACL,KAAK,SACH,QAAO;EACT,KAAK,SACH,QAAO;EACT,QACE,QAAO"}
1
+ {"version":3,"file":"EmptyState.js","names":[],"sources":["../../../../../src/bigconsole/components/widgets/states/EmptyState.tsx"],"sourcesContent":["/**\n * WidgetEmptyState Component\n *\n * Empty state displayed when widget has no data.\n */\n\nimport { type FC, memo } from 'react';\nimport type { WidgetType } from '../../../types';\n\nexport interface WidgetEmptyStateProps {\n /** Widget type for context-specific messaging */\n widgetType?: WidgetType;\n /** Whether a data source is configured */\n hasDataSource?: boolean;\n /** Custom message */\n message?: string;\n /**\n * Slot name when this widget came from a store template and its data source\n * has not been connected yet. Turns the generic empty state into an\n * explicitly unfinished-setup state, so it does not read as a broken widget.\n */\n templateSlot?: string | null;\n}\n\nexport const WidgetEmptyState: FC<WidgetEmptyStateProps> = memo(function WidgetEmptyState({\n widgetType,\n hasDataSource = false,\n message,\n templateSlot,\n}) {\n // A template widget awaiting its data source is a designed setup state, not\n // an absence of results — say so explicitly and name the slot to connect.\n const awaitingTemplateBinding = !hasDataSource && !!templateSlot;\n\n // Determine appropriate message\n const displayMessage =\n message ||\n (awaitingTemplateBinding\n ? `Connect the \"${templateSlot}\" data source to finish setting up this widget`\n : !hasDataSource\n ? 'Connect a data source to display data'\n : getEmptyMessageForType(widgetType));\n\n return (\n <div\n className=\"\n flex flex-col items-center justify-center\n h-full w-full min-h-[120px]\n text-center\n px-4\n \"\n >\n {/* Empty Icon */}\n <div\n className=\"\n w-12 h-12 mb-3\n flex items-center justify-center\n rounded-full\n bg-bg-sunken\n text-text-secondary\n \"\n >\n <svg className=\"w-6 h-6\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4\"\n />\n </svg>\n </div>\n\n {/* Message */}\n <p className=\"text-sm text-text-secondary\">{displayMessage}</p>\n\n {/* Data source hint */}\n {!hasDataSource && (\n <p className=\"text-xs text-text-secondary mt-2 max-w-[200px]\">Click Edit to configure this widget</p>\n )}\n </div>\n );\n});\n\n/**\n * Get context-specific empty message for widget type (v1.0 snake_case)\n */\nfunction getEmptyMessageForType(type?: WidgetType): string {\n switch (type) {\n case 'metric_card':\n case 'kpi_card_comparison':\n return 'No metrics available';\n case 'chart':\n case 'funnel_chart':\n return 'No chart data available';\n case 'table':\n case 'pivot_table':\n return 'No rows to display';\n case 'gauge':\n case 'progress':\n return 'No value available';\n case 'list':\n return 'No items to display';\n case 'heatmap':\n return 'No heatmap data available';\n case 'calendar':\n case 'timeline':\n case 'kanban':\n return 'No schedule data available';\n case 'map':\n return 'No location data available';\n case 'form':\n return 'Form not configured';\n case 'text':\n case 'iframe':\n return 'No content configured';\n case 'custom':\n return 'Custom widget not configured';\n default:\n return 'No data available';\n }\n}\n\nexport default WidgetEmptyState;\n"],"mappings":";;;AAwBA,IAAa,IAA8C,EAAK,SAA0B,EACxF,eACA,mBAAgB,IAChB,YACA,mBACC;CAMD,IAAM,IACJ,MAJ8B,CAAC,KAAmB,IAM9C,gBAAgB,EAAa,kDAC5B,IAEC,EAAuB,EAAW,GADlC;AAGR,QACE,kBAAC,OAAD;EACE,WAAU;YADZ;GASE,kBAAC,OAAD;IACE,WAAU;cAQV,kBAAC,OAAD;KAAK,WAAU;KAAU,MAAK;KAAO,QAAO;KAAe,SAAQ;eACjE,kBAAC,QAAD;MACE,eAAc;MACd,gBAAe;MACf,aAAa;MACb,GAAE;MACF,CAAA;KACE,CAAA;IACF,CAAA;GAGN,kBAAC,KAAD;IAAG,WAAU;cAA+B;IAAmB,CAAA;GAG9D,CAAC,KACA,kBAAC,KAAD;IAAG,WAAU;cAAiD;IAAuC,CAAA;GAEnG;;EAER;AAKF,SAAS,EAAuB,GAA2B;AACzD,SAAQ,GAAR;EACE,KAAK;EACL,KAAK,sBACH,QAAO;EACT,KAAK;EACL,KAAK,eACH,QAAO;EACT,KAAK;EACL,KAAK,cACH,QAAO;EACT,KAAK;EACL,KAAK,WACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,UACH,QAAO;EACT,KAAK;EACL,KAAK;EACL,KAAK,SACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK;EACL,KAAK,SACH,QAAO;EACT,KAAK,SACH,QAAO;EACT,QACE,QAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-bigconsole",
3
- "version": "2026.730.2",
3
+ "version": "2026.730.4",
4
4
  "description": "BigConsole - AI-powered analytics and dashboard platform",
5
5
  "type": "module",
6
6
  "files": [
@@ -16,6 +16,10 @@
16
16
  "./assistant": {
17
17
  "types": "./dist/bigconsole/assistant/index.d.ts",
18
18
  "import": "./dist/bigconsole/assistant/index.js"
19
+ },
20
+ "./embed": {
21
+ "types": "./dist/bigconsole/components/embed/index.d.ts",
22
+ "import": "./dist/bigconsole/components/embed/index.js"
19
23
  }
20
24
  },
21
25
  "main": "./dist/index.js",