dp-widgets-framework 1.1.3 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -15176,6 +15176,9 @@ function SeriesChart({ orientation, title, data, options, className, units }) {
15176
15176
  beginAtZero: true,
15177
15177
  ticks: {
15178
15178
  callback: function (value) {
15179
+ if (units === '$') {
15180
+ return `${units}${formatValue(value)}`;
15181
+ }
15179
15182
  return units ? `${formatValue(value)} ${units}` : value;
15180
15183
  }
15181
15184
  }
@@ -36098,6 +36101,7 @@ const createInitialChartState = (agentType, widgetIds, datasetId) => {
36098
36101
  type: "series_bar",
36099
36102
  chart_type: "financial",
36100
36103
  orientation: "vertical",
36104
+ units: "",
36101
36105
  data: { labels: [], series: [], total: 0, average: 0 },
36102
36106
  metadata: {
36103
36107
  categories: 0, series_count: 0, highest_category: "", highest_value: 0, highest_series: "",
@@ -36280,7 +36284,7 @@ function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, app
36280
36284
  const isEmpty = labels.length === 0 || series.length === 0;
36281
36285
  const handleRefresh = async () => {
36282
36286
  if (query) {
36283
- await clearChat();
36287
+ await clearChat(widgetBackendUrl, widgetId);
36284
36288
  // Send trigger event to clear chart state
36285
36289
  console.log('Dispatching clearChartState event for widgetId:', widgetId);
36286
36290
  window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
@@ -36331,7 +36335,7 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
36331
36335
  const isEmpty = labels.length === 0 || series.length === 0;
36332
36336
  const handleRefresh = async () => {
36333
36337
  if (query) {
36334
- await clearChat();
36338
+ await clearChat(widgetBackendUrl, widgetId);
36335
36339
  // Send trigger event to clear chart state
36336
36340
  console.log('Dispatching clearChartState event for widgetId:', widgetId);
36337
36341
  window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
@@ -36390,7 +36394,7 @@ function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirs
36390
36394
  const isEmpty = labels.length === 0 || values.length === 0;
36391
36395
  const handleRefresh = async () => {
36392
36396
  if (query) {
36393
- await clearChat();
36397
+ await clearChat(widgetBackendUrl, widgetId);
36394
36398
  // Send trigger event to clear chart state
36395
36399
  console.log('Dispatching clearChartState event for widgetId:', widgetId);
36396
36400
  window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
@@ -36500,7 +36504,7 @@ function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirs
36500
36504
  const isEmpty = columns.length === 0 || rows.length === 0;
36501
36505
  const handleRefresh = async () => {
36502
36506
  if (query) {
36503
- await clearChat();
36507
+ await clearChat(widgetBackendUrl, widgetId);
36504
36508
  // Send trigger event to clear chart state
36505
36509
  console.log('Dispatching clearChartState event for widgetId:', widgetId);
36506
36510
  window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
@@ -36544,7 +36548,7 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
36544
36548
  const isEmpty = !content || content.trim() === "";
36545
36549
  const handleRefresh = async () => {
36546
36550
  if (query) {
36547
- await clearChat();
36551
+ await clearChat(widgetBackendUrl, widgetId);
36548
36552
  // Send trigger event to clear chart state
36549
36553
  console.log('Dispatching clearChartState event for widgetId:', widgetId);
36550
36554
  window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
@@ -36578,7 +36582,7 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
36578
36582
  return (jsxRuntimeExports.jsx(SummaryWidget, { title: title, data: data, metadata: metadata, className: "" }));
36579
36583
  }
36580
36584
  function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds, widgetBackendUrl, datasetId }) {
36581
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32;
36585
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31;
36582
36586
  const agentType = (_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentType;
36583
36587
  const orientation = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.orientation;
36584
36588
  const isFirstLoad = (_c = widget.config) === null || _c === void 0 ? void 0 : _c.isFirstLoad;
@@ -36587,8 +36591,6 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
36587
36591
  const [isTimeoutTriggered, setIsTimeoutTriggered] = useState(false);
36588
36592
  const [apiCallCount, setApiCallCount] = useState(0);
36589
36593
  const [hasTimeoutError, setHasTimeoutError] = useState(false);
36590
- const [isAgentTriggered, setIsAgentTriggered] = useState(false);
36591
- const pollingIntervalRef = useRef(null);
36592
36594
  useEffect(() => {
36593
36595
  setThreadId(widget.id);
36594
36596
  }, [widget.id, setThreadId]);
@@ -36635,58 +36637,6 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
36635
36637
  timeoutRef.current = null;
36636
36638
  }
36637
36639
  }, []);
36638
- // Function to start polling for data availability
36639
- const startPollingForData = useCallback(() => {
36640
- var _a;
36641
- if (!widgetBackendUrl || !((_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentName))
36642
- return;
36643
- setIsAgentTriggered(true);
36644
- setApiCallCount(0);
36645
- setHasTimeoutError(false);
36646
- // Clear any existing polling interval
36647
- if (pollingIntervalRef.current) {
36648
- clearInterval(pollingIntervalRef.current);
36649
- }
36650
- // Start polling immediately, then every CHART_REFRESH_TIMEOUT
36651
- const pollForData = async () => {
36652
- var _a, _b, _c;
36653
- if (apiCallCount >= 10) {
36654
- setHasTimeoutError(true);
36655
- setIsAgentTriggered(false);
36656
- if (pollingIntervalRef.current) {
36657
- clearInterval(pollingIntervalRef.current);
36658
- pollingIntervalRef.current = null;
36659
- }
36660
- return;
36661
- }
36662
- setApiCallCount(prev => prev + 1);
36663
- const agentName = ((_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentName) || "adk-construction-project-agent";
36664
- const apiResponse = await loadAgentState(widgetBackendUrl, widget.id, agentName);
36665
- if (apiResponse && ((_c = (_b = apiResponse.data) === null || _b === void 0 ? void 0 : _b.loadAgentState) === null || _c === void 0 ? void 0 : _c.state)) {
36666
- parseAndUpdateChartState(apiResponse, setChartState);
36667
- setIsAgentTriggered(false);
36668
- if (pollingIntervalRef.current) {
36669
- clearInterval(pollingIntervalRef.current);
36670
- pollingIntervalRef.current = null;
36671
- }
36672
- }
36673
- };
36674
- // Poll immediately
36675
- pollForData();
36676
- // Then poll every CHART_REFRESH_TIMEOUT
36677
- pollingIntervalRef.current = setInterval(pollForData, CHART_REFRESH_TIMEOUT);
36678
- // Set a maximum timeout to stop polling after 10 attempts
36679
- setTimeout(() => {
36680
- if (pollingIntervalRef.current) {
36681
- clearInterval(pollingIntervalRef.current);
36682
- pollingIntervalRef.current = null;
36683
- setIsAgentTriggered(false);
36684
- if (apiCallCount >= 10) {
36685
- setHasTimeoutError(true);
36686
- }
36687
- }
36688
- }, CHART_REFRESH_TIMEOUT * 10);
36689
- }, [widgetBackendUrl, (_f = widget.config) === null || _f === void 0 ? void 0 : _f.agentName, widget.id, apiCallCount, setChartState]);
36690
36640
  // Function to clear chat and reset chart state
36691
36641
  useCallback(async (widgetId) => {
36692
36642
  if (!widgetBackendUrl)
@@ -36710,23 +36660,15 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
36710
36660
  console.error('Failed to clear chat and state:', error);
36711
36661
  }
36712
36662
  }, [widgetBackendUrl, setChartState, agentType, widgetIds]);
36713
- // Clean up timeout and polling on unmount
36663
+ // Clean up timeout on unmount
36714
36664
  useEffect(() => {
36715
36665
  return () => {
36716
36666
  if (timeoutRef.current) {
36717
36667
  clearTimeout(timeoutRef.current);
36718
36668
  }
36719
- if (pollingIntervalRef.current) {
36720
- clearInterval(pollingIntervalRef.current);
36721
- }
36722
36669
  };
36723
36670
  }, []);
36724
- const { appendMessage: originalAppendMessage, reset } = useCopilotChat();
36725
- // Wrapper function for appendMessage that triggers polling
36726
- const appendMessage = useCallback((message) => {
36727
- startPollingForData();
36728
- return originalAppendMessage(message);
36729
- }, [originalAppendMessage, startPollingForData]);
36671
+ const { appendMessage, reset } = useCopilotChat();
36730
36672
  // Register the reset function with the parent component
36731
36673
  useEffect(() => {
36732
36674
  if (onResetReady && reset && widget.id) {
@@ -36740,7 +36682,8 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
36740
36682
  // Listen for triggerAgent events for this widget
36741
36683
  useEffect(() => {
36742
36684
  const handleTriggerAgent = (event) => {
36743
- const { widgetId, query, agentType: eventAgentType } = event.detail;
36685
+ const { widgetId, query, agentType: eventAgentType, datesetId } = event.detail;
36686
+ console.log('event.detail==>', event.detail);
36744
36687
  if (widgetId === widget.id) {
36745
36688
  let messageContent = query;
36746
36689
  // Customize message based on agent type
@@ -36765,6 +36708,8 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
36765
36708
  else if (eventAgentType === "Summary Agent") {
36766
36709
  messageContent = `${query} and render the data on a summary widget`;
36767
36710
  }
36711
+ console.log('triggering to datasetId==>', datasetId);
36712
+ setChartState(createInitialChartState(agentType || '', widgetIds, datasetId));
36768
36713
  appendMessage(new TextMessage({
36769
36714
  content: messageContent,
36770
36715
  role: Role.User,
@@ -36788,18 +36733,17 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
36788
36733
  }, [widget.id, appendMessage, agentType, setChartState]);
36789
36734
  return (jsxRuntimeExports.jsxs("div", { className: cn("flex flex-col h-full"), children: [showHeader && (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-between pb-2 border-b", children: jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }), jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })] }) })), jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState === null || chartState === void 0 ? void 0 : chartState.agent_message) && agentType !== "chatbot" && (
36790
36735
  // Check if data is empty based on agent type
36791
- (agentType === "Bar Chart Agent" && (!((_j = (_h = (_g = chartState.bar_chart_data) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.labels) === null || _j === void 0 ? void 0 : _j.length) || !((_m = (_l = (_k = chartState.bar_chart_data) === null || _k === void 0 ? void 0 : _k.data) === null || _l === void 0 ? void 0 : _l.values) === null || _m === void 0 ? void 0 : _m.length))) ||
36792
- (agentType === "Series Bar Chart Agent" && (!((_q = (_p = (_o = chartState.series_bar_chart_data) === null || _o === void 0 ? void 0 : _o.data) === null || _p === void 0 ? void 0 : _p.labels) === null || _q === void 0 ? void 0 : _q.length) || !((_t = (_s = (_r = chartState.series_bar_chart_data) === null || _r === void 0 ? void 0 : _r.data) === null || _s === void 0 ? void 0 : _s.series) === null || _t === void 0 ? void 0 : _t.length))) ||
36793
- (agentType === "Series Line Chart Agent" && (!((_w = (_v = (_u = chartState.series_bar_chart_data) === null || _u === void 0 ? void 0 : _u.data) === null || _v === void 0 ? void 0 : _v.labels) === null || _w === void 0 ? void 0 : _w.length) || !((_z = (_y = (_x = chartState.series_bar_chart_data) === null || _x === void 0 ? void 0 : _x.data) === null || _y === void 0 ? void 0 : _y.series) === null || _z === void 0 ? void 0 : _z.length))) ||
36794
- (agentType === "Pie Chart Agent" && (!((_2 = (_1 = (_0 = chartState.pie_chart_data) === null || _0 === void 0 ? void 0 : _0.data) === null || _1 === void 0 ? void 0 : _1.labels) === null || _2 === void 0 ? void 0 : _2.length) || !((_5 = (_4 = (_3 = chartState.pie_chart_data) === null || _3 === void 0 ? void 0 : _3.data) === null || _4 === void 0 ? void 0 : _4.values) === null || _5 === void 0 ? void 0 : _5.length))) ||
36795
- (agentType === "Line Chart Agent" && (!((_8 = (_7 = (_6 = chartState.bar_chart_data) === null || _6 === void 0 ? void 0 : _6.data) === null || _7 === void 0 ? void 0 : _7.labels) === null || _8 === void 0 ? void 0 : _8.length) || !((_11 = (_10 = (_9 = chartState.bar_chart_data) === null || _9 === void 0 ? void 0 : _9.data) === null || _10 === void 0 ? void 0 : _10.values) === null || _11 === void 0 ? void 0 : _11.length))) ||
36796
- (agentType === "Data Grid Agent" && (!((_14 = (_13 = (_12 = chartState.matrix_grid_data) === null || _12 === void 0 ? void 0 : _12.data) === null || _13 === void 0 ? void 0 : _13.headers) === null || _14 === void 0 ? void 0 : _14.length) || !((_17 = (_16 = (_15 = chartState.matrix_grid_data) === null || _15 === void 0 ? void 0 : _15.data) === null || _16 === void 0 ? void 0 : _16.rows) === null || _17 === void 0 ? void 0 : _17.length))) ||
36797
- (agentType === "Summary Agent" && (!((_19 = (_18 = chartState.summary_data) === null || _18 === void 0 ? void 0 : _18.data) === null || _19 === void 0 ? void 0 : _19.content) || ((_22 = (_21 = (_20 = chartState.summary_data) === null || _20 === void 0 ? void 0 : _20.data) === null || _21 === void 0 ? void 0 : _21.content) === null || _22 === void 0 ? void 0 : _22.trim()) === ""))) ? (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) })) : isAgentTriggered ? (createLoadingComponent("Agent processing your request...")) : agentType === "Bar Chart Agent" ? (jsxRuntimeExports.jsx(BarChartComponent, { barChartState: chartState, styles: styles, orientation: orientation, appendMessage: appendMessage, query: (_23 = widget.config) === null || _23 === void 0 ? void 0 : _23.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Series Bar Chart Agent" ? (jsxRuntimeExports.jsx(SeriesBarChartComponent, { seriesBarChartState: chartState, styles: styles, orientation: orientation, appendMessage: appendMessage, query: (_24 = widget.config) === null || _24 === void 0 ? void 0 : _24.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Series Line Chart Agent" ? (jsxRuntimeExports.jsx(SeriesLineChartComponent, { seriesLineChartState: chartState, styles: styles, orientation: orientation, appendMessage: appendMessage, query: (_25 = widget.config) === null || _25 === void 0 ? void 0 : _25.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Pie Chart Agent" ? (jsxRuntimeExports.jsx(PieChartComponent, { pieChartState: chartState, styles: styles, appendMessage: appendMessage, query: (_26 = widget.config) === null || _26 === void 0 ? void 0 : _26.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Line Chart Agent" ? (jsxRuntimeExports.jsx(LineChartComponent, { lineChartState: chartState, styles: styles, appendMessage: appendMessage, query: (_27 = widget.config) === null || _27 === void 0 ? void 0 : _27.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Data Grid Agent" ? (jsxRuntimeExports.jsx(DataGridComponent, { dataGridState: chartState, styles: styles, appendMessage: appendMessage, query: (_28 = widget.config) === null || _28 === void 0 ? void 0 : _28.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Summary Agent" ? (jsxRuntimeExports.jsx(SummaryComponent, { summaryState: chartState, styles: styles, appendMessage: appendMessage, query: (_29 = widget.config) === null || _29 === void 0 ? void 0 : _29.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, widget_ids: widgetIds, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout, setChartState: setChartState })) : (jsxRuntimeExports.jsx(CopilotChat, { className: "h-full text-xs [&_.copilot-chat-message]:text-xs [&_.copilot-chat-input]:text-xs", labels: {
36798
- title: ((_30 = widget.config) === null || _30 === void 0 ? void 0 : _30.copilotTitle) || widget.title,
36799
- initial: ((_31 = widget.config) === null || _31 === void 0 ? void 0 : _31.copilotInitialMessage) || ((_32 = widget.config) === null || _32 === void 0 ? void 0 : _32.placeholder) || "How can I help you today?"
36736
+ (agentType === "Bar Chart Agent" && (!((_h = (_g = (_f = chartState.bar_chart_data) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.labels) === null || _h === void 0 ? void 0 : _h.length) || !((_l = (_k = (_j = chartState.bar_chart_data) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.values) === null || _l === void 0 ? void 0 : _l.length))) ||
36737
+ (agentType === "Series Bar Chart Agent" && (!((_p = (_o = (_m = chartState.series_bar_chart_data) === null || _m === void 0 ? void 0 : _m.data) === null || _o === void 0 ? void 0 : _o.labels) === null || _p === void 0 ? void 0 : _p.length) || !((_s = (_r = (_q = chartState.series_bar_chart_data) === null || _q === void 0 ? void 0 : _q.data) === null || _r === void 0 ? void 0 : _r.series) === null || _s === void 0 ? void 0 : _s.length))) ||
36738
+ (agentType === "Series Line Chart Agent" && (!((_v = (_u = (_t = chartState.series_bar_chart_data) === null || _t === void 0 ? void 0 : _t.data) === null || _u === void 0 ? void 0 : _u.labels) === null || _v === void 0 ? void 0 : _v.length) || !((_y = (_x = (_w = chartState.series_bar_chart_data) === null || _w === void 0 ? void 0 : _w.data) === null || _x === void 0 ? void 0 : _x.series) === null || _y === void 0 ? void 0 : _y.length))) ||
36739
+ (agentType === "Pie Chart Agent" && (!((_1 = (_0 = (_z = chartState.pie_chart_data) === null || _z === void 0 ? void 0 : _z.data) === null || _0 === void 0 ? void 0 : _0.labels) === null || _1 === void 0 ? void 0 : _1.length) || !((_4 = (_3 = (_2 = chartState.pie_chart_data) === null || _2 === void 0 ? void 0 : _2.data) === null || _3 === void 0 ? void 0 : _3.values) === null || _4 === void 0 ? void 0 : _4.length))) ||
36740
+ (agentType === "Line Chart Agent" && (!((_7 = (_6 = (_5 = chartState.bar_chart_data) === null || _5 === void 0 ? void 0 : _5.data) === null || _6 === void 0 ? void 0 : _6.labels) === null || _7 === void 0 ? void 0 : _7.length) || !((_10 = (_9 = (_8 = chartState.bar_chart_data) === null || _8 === void 0 ? void 0 : _8.data) === null || _9 === void 0 ? void 0 : _9.values) === null || _10 === void 0 ? void 0 : _10.length))) ||
36741
+ (agentType === "Data Grid Agent" && (!((_13 = (_12 = (_11 = chartState.matrix_grid_data) === null || _11 === void 0 ? void 0 : _11.data) === null || _12 === void 0 ? void 0 : _12.headers) === null || _13 === void 0 ? void 0 : _13.length) || !((_16 = (_15 = (_14 = chartState.matrix_grid_data) === null || _14 === void 0 ? void 0 : _14.data) === null || _15 === void 0 ? void 0 : _15.rows) === null || _16 === void 0 ? void 0 : _16.length))) ||
36742
+ (agentType === "Summary Agent" && (!((_18 = (_17 = chartState.summary_data) === null || _17 === void 0 ? void 0 : _17.data) === null || _18 === void 0 ? void 0 : _18.content) || ((_21 = (_20 = (_19 = chartState.summary_data) === null || _19 === void 0 ? void 0 : _19.data) === null || _20 === void 0 ? void 0 : _20.content) === null || _21 === void 0 ? void 0 : _21.trim()) === ""))) ? (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) })) : agentType === "Bar Chart Agent" ? (jsxRuntimeExports.jsx(BarChartComponent, { barChartState: chartState, styles: styles, orientation: orientation, appendMessage: appendMessage, query: (_22 = widget.config) === null || _22 === void 0 ? void 0 : _22.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Series Bar Chart Agent" ? (jsxRuntimeExports.jsx(SeriesBarChartComponent, { seriesBarChartState: chartState, styles: styles, orientation: orientation, appendMessage: appendMessage, query: (_23 = widget.config) === null || _23 === void 0 ? void 0 : _23.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Series Line Chart Agent" ? (jsxRuntimeExports.jsx(SeriesLineChartComponent, { seriesLineChartState: chartState, styles: styles, orientation: orientation, appendMessage: appendMessage, query: (_24 = widget.config) === null || _24 === void 0 ? void 0 : _24.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Pie Chart Agent" ? (jsxRuntimeExports.jsx(PieChartComponent, { pieChartState: chartState, styles: styles, appendMessage: appendMessage, query: (_25 = widget.config) === null || _25 === void 0 ? void 0 : _25.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Line Chart Agent" ? (jsxRuntimeExports.jsx(LineChartComponent, { lineChartState: chartState, styles: styles, appendMessage: appendMessage, query: (_26 = widget.config) === null || _26 === void 0 ? void 0 : _26.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Data Grid Agent" ? (jsxRuntimeExports.jsx(DataGridComponent, { dataGridState: chartState, styles: styles, appendMessage: appendMessage, query: (_27 = widget.config) === null || _27 === void 0 ? void 0 : _27.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Summary Agent" ? (jsxRuntimeExports.jsx(SummaryComponent, { summaryState: chartState, styles: styles, appendMessage: appendMessage, query: (_28 = widget.config) === null || _28 === void 0 ? void 0 : _28.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, widget_ids: widgetIds, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout, setChartState: setChartState })) : (jsxRuntimeExports.jsx(CopilotChat, { className: "h-full text-xs [&_.copilot-chat-message]:text-xs [&_.copilot-chat-input]:text-xs", labels: {
36743
+ title: ((_29 = widget.config) === null || _29 === void 0 ? void 0 : _29.copilotTitle) || widget.title,
36744
+ initial: ((_30 = widget.config) === null || _30 === void 0 ? void 0 : _30.copilotInitialMessage) || ((_31 = widget.config) === null || _31 === void 0 ? void 0 : _31.placeholder) || "How can I help you today?"
36800
36745
  }, onSubmitMessage: () => {
36801
36746
  setChartState(prevState => (Object.assign(Object.assign({}, prevState), { widget_ids: widgetIds, dataset_id: datasetId })));
36802
- startPollingForData();
36803
36747
  } })) })] }));
36804
36748
  }
36805
36749
  function AgentWidget({ widget, showHeader = true, widgetBackendUrl, onResetReady, widgetIds, datasetId, }) {
@@ -37150,7 +37094,8 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
37150
37094
  detail: {
37151
37095
  widgetId: editingWidget.id,
37152
37096
  query: newQuery,
37153
- agentType: (_a = editingWidget.config) === null || _a === void 0 ? void 0 : _a.agentType
37097
+ agentType: (_a = editingWidget.config) === null || _a === void 0 ? void 0 : _a.agentType,
37098
+ datesetId: datasetId
37154
37099
  }
37155
37100
  });
37156
37101
  window.dispatchEvent(event);
package/dist/index.js CHANGED
@@ -15203,6 +15203,9 @@ function SeriesChart({ orientation, title, data, options, className, units }) {
15203
15203
  beginAtZero: true,
15204
15204
  ticks: {
15205
15205
  callback: function (value) {
15206
+ if (units === '$') {
15207
+ return `${units}${formatValue(value)}`;
15208
+ }
15206
15209
  return units ? `${formatValue(value)} ${units}` : value;
15207
15210
  }
15208
15211
  }
@@ -36125,6 +36128,7 @@ const createInitialChartState = (agentType, widgetIds, datasetId) => {
36125
36128
  type: "series_bar",
36126
36129
  chart_type: "financial",
36127
36130
  orientation: "vertical",
36131
+ units: "",
36128
36132
  data: { labels: [], series: [], total: 0, average: 0 },
36129
36133
  metadata: {
36130
36134
  categories: 0, series_count: 0, highest_category: "", highest_value: 0, highest_series: "",
@@ -36307,7 +36311,7 @@ function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, app
36307
36311
  const isEmpty = labels.length === 0 || series.length === 0;
36308
36312
  const handleRefresh = async () => {
36309
36313
  if (query) {
36310
- await clearChat();
36314
+ await clearChat(widgetBackendUrl, widgetId);
36311
36315
  // Send trigger event to clear chart state
36312
36316
  console.log('Dispatching clearChartState event for widgetId:', widgetId);
36313
36317
  window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
@@ -36358,7 +36362,7 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
36358
36362
  const isEmpty = labels.length === 0 || series.length === 0;
36359
36363
  const handleRefresh = async () => {
36360
36364
  if (query) {
36361
- await clearChat();
36365
+ await clearChat(widgetBackendUrl, widgetId);
36362
36366
  // Send trigger event to clear chart state
36363
36367
  console.log('Dispatching clearChartState event for widgetId:', widgetId);
36364
36368
  window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
@@ -36417,7 +36421,7 @@ function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirs
36417
36421
  const isEmpty = labels.length === 0 || values.length === 0;
36418
36422
  const handleRefresh = async () => {
36419
36423
  if (query) {
36420
- await clearChat();
36424
+ await clearChat(widgetBackendUrl, widgetId);
36421
36425
  // Send trigger event to clear chart state
36422
36426
  console.log('Dispatching clearChartState event for widgetId:', widgetId);
36423
36427
  window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
@@ -36527,7 +36531,7 @@ function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirs
36527
36531
  const isEmpty = columns.length === 0 || rows.length === 0;
36528
36532
  const handleRefresh = async () => {
36529
36533
  if (query) {
36530
- await clearChat();
36534
+ await clearChat(widgetBackendUrl, widgetId);
36531
36535
  // Send trigger event to clear chart state
36532
36536
  console.log('Dispatching clearChartState event for widgetId:', widgetId);
36533
36537
  window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
@@ -36571,7 +36575,7 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
36571
36575
  const isEmpty = !content || content.trim() === "";
36572
36576
  const handleRefresh = async () => {
36573
36577
  if (query) {
36574
- await clearChat();
36578
+ await clearChat(widgetBackendUrl, widgetId);
36575
36579
  // Send trigger event to clear chart state
36576
36580
  console.log('Dispatching clearChartState event for widgetId:', widgetId);
36577
36581
  window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
@@ -36605,7 +36609,7 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
36605
36609
  return (jsxRuntimeExports.jsx(SummaryWidget, { title: title, data: data, metadata: metadata, className: "" }));
36606
36610
  }
36607
36611
  function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds, widgetBackendUrl, datasetId }) {
36608
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32;
36612
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31;
36609
36613
  const agentType = (_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentType;
36610
36614
  const orientation = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.orientation;
36611
36615
  const isFirstLoad = (_c = widget.config) === null || _c === void 0 ? void 0 : _c.isFirstLoad;
@@ -36614,8 +36618,6 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
36614
36618
  const [isTimeoutTriggered, setIsTimeoutTriggered] = React.useState(false);
36615
36619
  const [apiCallCount, setApiCallCount] = React.useState(0);
36616
36620
  const [hasTimeoutError, setHasTimeoutError] = React.useState(false);
36617
- const [isAgentTriggered, setIsAgentTriggered] = React.useState(false);
36618
- const pollingIntervalRef = React.useRef(null);
36619
36621
  React.useEffect(() => {
36620
36622
  setThreadId(widget.id);
36621
36623
  }, [widget.id, setThreadId]);
@@ -36662,58 +36664,6 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
36662
36664
  timeoutRef.current = null;
36663
36665
  }
36664
36666
  }, []);
36665
- // Function to start polling for data availability
36666
- const startPollingForData = React.useCallback(() => {
36667
- var _a;
36668
- if (!widgetBackendUrl || !((_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentName))
36669
- return;
36670
- setIsAgentTriggered(true);
36671
- setApiCallCount(0);
36672
- setHasTimeoutError(false);
36673
- // Clear any existing polling interval
36674
- if (pollingIntervalRef.current) {
36675
- clearInterval(pollingIntervalRef.current);
36676
- }
36677
- // Start polling immediately, then every CHART_REFRESH_TIMEOUT
36678
- const pollForData = async () => {
36679
- var _a, _b, _c;
36680
- if (apiCallCount >= 10) {
36681
- setHasTimeoutError(true);
36682
- setIsAgentTriggered(false);
36683
- if (pollingIntervalRef.current) {
36684
- clearInterval(pollingIntervalRef.current);
36685
- pollingIntervalRef.current = null;
36686
- }
36687
- return;
36688
- }
36689
- setApiCallCount(prev => prev + 1);
36690
- const agentName = ((_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentName) || "adk-construction-project-agent";
36691
- const apiResponse = await loadAgentState(widgetBackendUrl, widget.id, agentName);
36692
- if (apiResponse && ((_c = (_b = apiResponse.data) === null || _b === void 0 ? void 0 : _b.loadAgentState) === null || _c === void 0 ? void 0 : _c.state)) {
36693
- parseAndUpdateChartState(apiResponse, setChartState);
36694
- setIsAgentTriggered(false);
36695
- if (pollingIntervalRef.current) {
36696
- clearInterval(pollingIntervalRef.current);
36697
- pollingIntervalRef.current = null;
36698
- }
36699
- }
36700
- };
36701
- // Poll immediately
36702
- pollForData();
36703
- // Then poll every CHART_REFRESH_TIMEOUT
36704
- pollingIntervalRef.current = setInterval(pollForData, CHART_REFRESH_TIMEOUT);
36705
- // Set a maximum timeout to stop polling after 10 attempts
36706
- setTimeout(() => {
36707
- if (pollingIntervalRef.current) {
36708
- clearInterval(pollingIntervalRef.current);
36709
- pollingIntervalRef.current = null;
36710
- setIsAgentTriggered(false);
36711
- if (apiCallCount >= 10) {
36712
- setHasTimeoutError(true);
36713
- }
36714
- }
36715
- }, CHART_REFRESH_TIMEOUT * 10);
36716
- }, [widgetBackendUrl, (_f = widget.config) === null || _f === void 0 ? void 0 : _f.agentName, widget.id, apiCallCount, setChartState]);
36717
36667
  // Function to clear chat and reset chart state
36718
36668
  React.useCallback(async (widgetId) => {
36719
36669
  if (!widgetBackendUrl)
@@ -36737,23 +36687,15 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
36737
36687
  console.error('Failed to clear chat and state:', error);
36738
36688
  }
36739
36689
  }, [widgetBackendUrl, setChartState, agentType, widgetIds]);
36740
- // Clean up timeout and polling on unmount
36690
+ // Clean up timeout on unmount
36741
36691
  React.useEffect(() => {
36742
36692
  return () => {
36743
36693
  if (timeoutRef.current) {
36744
36694
  clearTimeout(timeoutRef.current);
36745
36695
  }
36746
- if (pollingIntervalRef.current) {
36747
- clearInterval(pollingIntervalRef.current);
36748
- }
36749
36696
  };
36750
36697
  }, []);
36751
- const { appendMessage: originalAppendMessage, reset } = reactCore.useCopilotChat();
36752
- // Wrapper function for appendMessage that triggers polling
36753
- const appendMessage = React.useCallback((message) => {
36754
- startPollingForData();
36755
- return originalAppendMessage(message);
36756
- }, [originalAppendMessage, startPollingForData]);
36698
+ const { appendMessage, reset } = reactCore.useCopilotChat();
36757
36699
  // Register the reset function with the parent component
36758
36700
  React.useEffect(() => {
36759
36701
  if (onResetReady && reset && widget.id) {
@@ -36767,7 +36709,8 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
36767
36709
  // Listen for triggerAgent events for this widget
36768
36710
  React.useEffect(() => {
36769
36711
  const handleTriggerAgent = (event) => {
36770
- const { widgetId, query, agentType: eventAgentType } = event.detail;
36712
+ const { widgetId, query, agentType: eventAgentType, datesetId } = event.detail;
36713
+ console.log('event.detail==>', event.detail);
36771
36714
  if (widgetId === widget.id) {
36772
36715
  let messageContent = query;
36773
36716
  // Customize message based on agent type
@@ -36792,6 +36735,8 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
36792
36735
  else if (eventAgentType === "Summary Agent") {
36793
36736
  messageContent = `${query} and render the data on a summary widget`;
36794
36737
  }
36738
+ console.log('triggering to datasetId==>', datasetId);
36739
+ setChartState(createInitialChartState(agentType || '', widgetIds, datasetId));
36795
36740
  appendMessage(new TextMessage({
36796
36741
  content: messageContent,
36797
36742
  role: Role.User,
@@ -36815,18 +36760,17 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
36815
36760
  }, [widget.id, appendMessage, agentType, setChartState]);
36816
36761
  return (jsxRuntimeExports.jsxs("div", { className: cn("flex flex-col h-full"), children: [showHeader && (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-between pb-2 border-b", children: jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntimeExports.jsx(lucideReact.Bot, { className: "h-4 w-4" }), jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })] }) })), jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState === null || chartState === void 0 ? void 0 : chartState.agent_message) && agentType !== "chatbot" && (
36817
36762
  // Check if data is empty based on agent type
36818
- (agentType === "Bar Chart Agent" && (!((_j = (_h = (_g = chartState.bar_chart_data) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.labels) === null || _j === void 0 ? void 0 : _j.length) || !((_m = (_l = (_k = chartState.bar_chart_data) === null || _k === void 0 ? void 0 : _k.data) === null || _l === void 0 ? void 0 : _l.values) === null || _m === void 0 ? void 0 : _m.length))) ||
36819
- (agentType === "Series Bar Chart Agent" && (!((_q = (_p = (_o = chartState.series_bar_chart_data) === null || _o === void 0 ? void 0 : _o.data) === null || _p === void 0 ? void 0 : _p.labels) === null || _q === void 0 ? void 0 : _q.length) || !((_t = (_s = (_r = chartState.series_bar_chart_data) === null || _r === void 0 ? void 0 : _r.data) === null || _s === void 0 ? void 0 : _s.series) === null || _t === void 0 ? void 0 : _t.length))) ||
36820
- (agentType === "Series Line Chart Agent" && (!((_w = (_v = (_u = chartState.series_bar_chart_data) === null || _u === void 0 ? void 0 : _u.data) === null || _v === void 0 ? void 0 : _v.labels) === null || _w === void 0 ? void 0 : _w.length) || !((_z = (_y = (_x = chartState.series_bar_chart_data) === null || _x === void 0 ? void 0 : _x.data) === null || _y === void 0 ? void 0 : _y.series) === null || _z === void 0 ? void 0 : _z.length))) ||
36821
- (agentType === "Pie Chart Agent" && (!((_2 = (_1 = (_0 = chartState.pie_chart_data) === null || _0 === void 0 ? void 0 : _0.data) === null || _1 === void 0 ? void 0 : _1.labels) === null || _2 === void 0 ? void 0 : _2.length) || !((_5 = (_4 = (_3 = chartState.pie_chart_data) === null || _3 === void 0 ? void 0 : _3.data) === null || _4 === void 0 ? void 0 : _4.values) === null || _5 === void 0 ? void 0 : _5.length))) ||
36822
- (agentType === "Line Chart Agent" && (!((_8 = (_7 = (_6 = chartState.bar_chart_data) === null || _6 === void 0 ? void 0 : _6.data) === null || _7 === void 0 ? void 0 : _7.labels) === null || _8 === void 0 ? void 0 : _8.length) || !((_11 = (_10 = (_9 = chartState.bar_chart_data) === null || _9 === void 0 ? void 0 : _9.data) === null || _10 === void 0 ? void 0 : _10.values) === null || _11 === void 0 ? void 0 : _11.length))) ||
36823
- (agentType === "Data Grid Agent" && (!((_14 = (_13 = (_12 = chartState.matrix_grid_data) === null || _12 === void 0 ? void 0 : _12.data) === null || _13 === void 0 ? void 0 : _13.headers) === null || _14 === void 0 ? void 0 : _14.length) || !((_17 = (_16 = (_15 = chartState.matrix_grid_data) === null || _15 === void 0 ? void 0 : _15.data) === null || _16 === void 0 ? void 0 : _16.rows) === null || _17 === void 0 ? void 0 : _17.length))) ||
36824
- (agentType === "Summary Agent" && (!((_19 = (_18 = chartState.summary_data) === null || _18 === void 0 ? void 0 : _18.data) === null || _19 === void 0 ? void 0 : _19.content) || ((_22 = (_21 = (_20 = chartState.summary_data) === null || _20 === void 0 ? void 0 : _20.data) === null || _21 === void 0 ? void 0 : _21.content) === null || _22 === void 0 ? void 0 : _22.trim()) === ""))) ? (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) })) : isAgentTriggered ? (createLoadingComponent("Agent processing your request...")) : agentType === "Bar Chart Agent" ? (jsxRuntimeExports.jsx(BarChartComponent, { barChartState: chartState, styles: styles, orientation: orientation, appendMessage: appendMessage, query: (_23 = widget.config) === null || _23 === void 0 ? void 0 : _23.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Series Bar Chart Agent" ? (jsxRuntimeExports.jsx(SeriesBarChartComponent, { seriesBarChartState: chartState, styles: styles, orientation: orientation, appendMessage: appendMessage, query: (_24 = widget.config) === null || _24 === void 0 ? void 0 : _24.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Series Line Chart Agent" ? (jsxRuntimeExports.jsx(SeriesLineChartComponent, { seriesLineChartState: chartState, styles: styles, orientation: orientation, appendMessage: appendMessage, query: (_25 = widget.config) === null || _25 === void 0 ? void 0 : _25.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Pie Chart Agent" ? (jsxRuntimeExports.jsx(PieChartComponent, { pieChartState: chartState, styles: styles, appendMessage: appendMessage, query: (_26 = widget.config) === null || _26 === void 0 ? void 0 : _26.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Line Chart Agent" ? (jsxRuntimeExports.jsx(LineChartComponent, { lineChartState: chartState, styles: styles, appendMessage: appendMessage, query: (_27 = widget.config) === null || _27 === void 0 ? void 0 : _27.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Data Grid Agent" ? (jsxRuntimeExports.jsx(DataGridComponent, { dataGridState: chartState, styles: styles, appendMessage: appendMessage, query: (_28 = widget.config) === null || _28 === void 0 ? void 0 : _28.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Summary Agent" ? (jsxRuntimeExports.jsx(SummaryComponent, { summaryState: chartState, styles: styles, appendMessage: appendMessage, query: (_29 = widget.config) === null || _29 === void 0 ? void 0 : _29.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, widget_ids: widgetIds, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout, setChartState: setChartState })) : (jsxRuntimeExports.jsx(reactUi.CopilotChat, { className: "h-full text-xs [&_.copilot-chat-message]:text-xs [&_.copilot-chat-input]:text-xs", labels: {
36825
- title: ((_30 = widget.config) === null || _30 === void 0 ? void 0 : _30.copilotTitle) || widget.title,
36826
- initial: ((_31 = widget.config) === null || _31 === void 0 ? void 0 : _31.copilotInitialMessage) || ((_32 = widget.config) === null || _32 === void 0 ? void 0 : _32.placeholder) || "How can I help you today?"
36763
+ (agentType === "Bar Chart Agent" && (!((_h = (_g = (_f = chartState.bar_chart_data) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.labels) === null || _h === void 0 ? void 0 : _h.length) || !((_l = (_k = (_j = chartState.bar_chart_data) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.values) === null || _l === void 0 ? void 0 : _l.length))) ||
36764
+ (agentType === "Series Bar Chart Agent" && (!((_p = (_o = (_m = chartState.series_bar_chart_data) === null || _m === void 0 ? void 0 : _m.data) === null || _o === void 0 ? void 0 : _o.labels) === null || _p === void 0 ? void 0 : _p.length) || !((_s = (_r = (_q = chartState.series_bar_chart_data) === null || _q === void 0 ? void 0 : _q.data) === null || _r === void 0 ? void 0 : _r.series) === null || _s === void 0 ? void 0 : _s.length))) ||
36765
+ (agentType === "Series Line Chart Agent" && (!((_v = (_u = (_t = chartState.series_bar_chart_data) === null || _t === void 0 ? void 0 : _t.data) === null || _u === void 0 ? void 0 : _u.labels) === null || _v === void 0 ? void 0 : _v.length) || !((_y = (_x = (_w = chartState.series_bar_chart_data) === null || _w === void 0 ? void 0 : _w.data) === null || _x === void 0 ? void 0 : _x.series) === null || _y === void 0 ? void 0 : _y.length))) ||
36766
+ (agentType === "Pie Chart Agent" && (!((_1 = (_0 = (_z = chartState.pie_chart_data) === null || _z === void 0 ? void 0 : _z.data) === null || _0 === void 0 ? void 0 : _0.labels) === null || _1 === void 0 ? void 0 : _1.length) || !((_4 = (_3 = (_2 = chartState.pie_chart_data) === null || _2 === void 0 ? void 0 : _2.data) === null || _3 === void 0 ? void 0 : _3.values) === null || _4 === void 0 ? void 0 : _4.length))) ||
36767
+ (agentType === "Line Chart Agent" && (!((_7 = (_6 = (_5 = chartState.bar_chart_data) === null || _5 === void 0 ? void 0 : _5.data) === null || _6 === void 0 ? void 0 : _6.labels) === null || _7 === void 0 ? void 0 : _7.length) || !((_10 = (_9 = (_8 = chartState.bar_chart_data) === null || _8 === void 0 ? void 0 : _8.data) === null || _9 === void 0 ? void 0 : _9.values) === null || _10 === void 0 ? void 0 : _10.length))) ||
36768
+ (agentType === "Data Grid Agent" && (!((_13 = (_12 = (_11 = chartState.matrix_grid_data) === null || _11 === void 0 ? void 0 : _11.data) === null || _12 === void 0 ? void 0 : _12.headers) === null || _13 === void 0 ? void 0 : _13.length) || !((_16 = (_15 = (_14 = chartState.matrix_grid_data) === null || _14 === void 0 ? void 0 : _14.data) === null || _15 === void 0 ? void 0 : _15.rows) === null || _16 === void 0 ? void 0 : _16.length))) ||
36769
+ (agentType === "Summary Agent" && (!((_18 = (_17 = chartState.summary_data) === null || _17 === void 0 ? void 0 : _17.data) === null || _18 === void 0 ? void 0 : _18.content) || ((_21 = (_20 = (_19 = chartState.summary_data) === null || _19 === void 0 ? void 0 : _19.data) === null || _20 === void 0 ? void 0 : _20.content) === null || _21 === void 0 ? void 0 : _21.trim()) === ""))) ? (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) })) : agentType === "Bar Chart Agent" ? (jsxRuntimeExports.jsx(BarChartComponent, { barChartState: chartState, styles: styles, orientation: orientation, appendMessage: appendMessage, query: (_22 = widget.config) === null || _22 === void 0 ? void 0 : _22.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Series Bar Chart Agent" ? (jsxRuntimeExports.jsx(SeriesBarChartComponent, { seriesBarChartState: chartState, styles: styles, orientation: orientation, appendMessage: appendMessage, query: (_23 = widget.config) === null || _23 === void 0 ? void 0 : _23.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Series Line Chart Agent" ? (jsxRuntimeExports.jsx(SeriesLineChartComponent, { seriesLineChartState: chartState, styles: styles, orientation: orientation, appendMessage: appendMessage, query: (_24 = widget.config) === null || _24 === void 0 ? void 0 : _24.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Pie Chart Agent" ? (jsxRuntimeExports.jsx(PieChartComponent, { pieChartState: chartState, styles: styles, appendMessage: appendMessage, query: (_25 = widget.config) === null || _25 === void 0 ? void 0 : _25.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Line Chart Agent" ? (jsxRuntimeExports.jsx(LineChartComponent, { lineChartState: chartState, styles: styles, appendMessage: appendMessage, query: (_26 = widget.config) === null || _26 === void 0 ? void 0 : _26.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Data Grid Agent" ? (jsxRuntimeExports.jsx(DataGridComponent, { dataGridState: chartState, styles: styles, appendMessage: appendMessage, query: (_27 = widget.config) === null || _27 === void 0 ? void 0 : _27.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout })) : agentType === "Summary Agent" ? (jsxRuntimeExports.jsx(SummaryComponent, { summaryState: chartState, styles: styles, appendMessage: appendMessage, query: (_28 = widget.config) === null || _28 === void 0 ? void 0 : _28.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, widget_ids: widgetIds, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout, setChartState: setChartState })) : (jsxRuntimeExports.jsx(reactUi.CopilotChat, { className: "h-full text-xs [&_.copilot-chat-message]:text-xs [&_.copilot-chat-input]:text-xs", labels: {
36770
+ title: ((_29 = widget.config) === null || _29 === void 0 ? void 0 : _29.copilotTitle) || widget.title,
36771
+ initial: ((_30 = widget.config) === null || _30 === void 0 ? void 0 : _30.copilotInitialMessage) || ((_31 = widget.config) === null || _31 === void 0 ? void 0 : _31.placeholder) || "How can I help you today?"
36827
36772
  }, onSubmitMessage: () => {
36828
36773
  setChartState(prevState => (Object.assign(Object.assign({}, prevState), { widget_ids: widgetIds, dataset_id: datasetId })));
36829
- startPollingForData();
36830
36774
  } })) })] }));
36831
36775
  }
36832
36776
  function AgentWidget({ widget, showHeader = true, widgetBackendUrl, onResetReady, widgetIds, datasetId, }) {
@@ -37177,7 +37121,8 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
37177
37121
  detail: {
37178
37122
  widgetId: editingWidget.id,
37179
37123
  query: newQuery,
37180
- agentType: (_a = editingWidget.config) === null || _a === void 0 ? void 0 : _a.agentType
37124
+ agentType: (_a = editingWidget.config) === null || _a === void 0 ? void 0 : _a.agentType,
37125
+ datesetId: datasetId
37181
37126
  }
37182
37127
  });
37183
37128
  window.dispatchEvent(event);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dp-widgets-framework",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org"