dp-widgets-framework 1.1.3 → 1.1.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.
- package/dist/index.esm.js +22 -303
- package/dist/index.js +16 -297
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -7,7 +7,7 @@ import * as LabelPrimitive from '@radix-ui/react-label';
|
|
|
7
7
|
import { cva } from 'class-variance-authority';
|
|
8
8
|
import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
9
9
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
10
|
-
import { ChevronDown, ChevronUp, Check, AlertCircle, MoveUp, MoveDown, Trash2, Plus, Bot, Type, Layout, LayoutGrid, BarChart
|
|
10
|
+
import { ChevronDown, ChevronUp, Check, AlertCircle, MoveUp, MoveDown, Trash2, Plus, Bot, Type, Layout, LayoutGrid, BarChart, Filter, Search, ArrowUp, ArrowDown, RefreshCw, X, LineChart, PieChart as PieChart$1, Table, FileText, Loader2, GripHorizontal, Edit, MessageCircleX, Edit2 } from 'lucide-react';
|
|
11
11
|
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
12
12
|
import { Slot } from '@radix-ui/react-slot';
|
|
13
13
|
import { debounce as debounce$1 } from 'lodash';
|
|
@@ -1912,7 +1912,7 @@ const IconMap$1 = {
|
|
|
1912
1912
|
search: Search,
|
|
1913
1913
|
filter: Filter,
|
|
1914
1914
|
results: LayoutGrid,
|
|
1915
|
-
analytics: BarChart
|
|
1915
|
+
analytics: BarChart,
|
|
1916
1916
|
custom: LayoutGrid,
|
|
1917
1917
|
header: Layout,
|
|
1918
1918
|
footer: Layout,
|
|
@@ -15048,78 +15048,6 @@ const Line = /* #__PURE__ */ createTypedChart('line', LineController);
|
|
|
15048
15048
|
const Bar = /* #__PURE__ */ createTypedChart('bar', BarController);
|
|
15049
15049
|
const Pie = /* #__PURE__ */ createTypedChart('pie', PieController);
|
|
15050
15050
|
|
|
15051
|
-
Chart$1.register(CategoryScale, LinearScale, BarElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15052
|
-
function BarChart({ orientation, title, data, options, className, units }) {
|
|
15053
|
-
const formatValue = (value) => {
|
|
15054
|
-
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
15055
|
-
if (units === '$' && !isNaN(numValue)) {
|
|
15056
|
-
return numValue.toLocaleString();
|
|
15057
|
-
}
|
|
15058
|
-
return value;
|
|
15059
|
-
};
|
|
15060
|
-
const defaultOptions = {
|
|
15061
|
-
responsive: true,
|
|
15062
|
-
maintainAspectRatio: false,
|
|
15063
|
-
indexAxis: orientation === "horizontal" ? "y" : "x",
|
|
15064
|
-
layout: {
|
|
15065
|
-
padding: {
|
|
15066
|
-
bottom: 0,
|
|
15067
|
-
top: 0,
|
|
15068
|
-
left: 0,
|
|
15069
|
-
right: 0,
|
|
15070
|
-
},
|
|
15071
|
-
},
|
|
15072
|
-
plugins: {
|
|
15073
|
-
legend: {
|
|
15074
|
-
display: false,
|
|
15075
|
-
labels: {
|
|
15076
|
-
boxWidth: 5,
|
|
15077
|
-
boxHeight: 5,
|
|
15078
|
-
},
|
|
15079
|
-
position: "bottom"
|
|
15080
|
-
},
|
|
15081
|
-
title: {
|
|
15082
|
-
display: true,
|
|
15083
|
-
text: title,
|
|
15084
|
-
font: {
|
|
15085
|
-
size: 18,
|
|
15086
|
-
weight: "bold",
|
|
15087
|
-
},
|
|
15088
|
-
color: "#0F172A"
|
|
15089
|
-
},
|
|
15090
|
-
tooltip: {
|
|
15091
|
-
callbacks: {
|
|
15092
|
-
label: function (context) {
|
|
15093
|
-
const value = context.parsed.y || context.parsed.x;
|
|
15094
|
-
return units ? `${context.dataset.label}: ${formatValue(value)} ${units}` : `${context.dataset.label}: ${value}`;
|
|
15095
|
-
}
|
|
15096
|
-
}
|
|
15097
|
-
},
|
|
15098
|
-
},
|
|
15099
|
-
scales: {
|
|
15100
|
-
x: {
|
|
15101
|
-
ticks: {
|
|
15102
|
-
autoSkip: false,
|
|
15103
|
-
maxRotation: 45,
|
|
15104
|
-
minRotation: 45,
|
|
15105
|
-
font: {
|
|
15106
|
-
size: 10
|
|
15107
|
-
}
|
|
15108
|
-
},
|
|
15109
|
-
},
|
|
15110
|
-
y: {
|
|
15111
|
-
beginAtZero: true,
|
|
15112
|
-
ticks: {
|
|
15113
|
-
callback: function (value) {
|
|
15114
|
-
return units ? `${formatValue(value)} ${units}` : value;
|
|
15115
|
-
}
|
|
15116
|
-
}
|
|
15117
|
-
},
|
|
15118
|
-
},
|
|
15119
|
-
};
|
|
15120
|
-
return (jsxRuntimeExports.jsx(Bar, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions }));
|
|
15121
|
-
}
|
|
15122
|
-
|
|
15123
15051
|
Chart$1.register(CategoryScale, LinearScale, BarElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15124
15052
|
function SeriesChart({ orientation, title, data, options, className, units }) {
|
|
15125
15053
|
const formatValue = (value) => {
|
|
@@ -15308,70 +15236,6 @@ const PieChart = (props) => {
|
|
|
15308
15236
|
return jsxRuntimeExports.jsx(Pie, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions });
|
|
15309
15237
|
};
|
|
15310
15238
|
|
|
15311
|
-
Chart$1.register(CategoryScale, LinearScale, PointElement, LineElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15312
|
-
function LineChart({ title, data, options, className, units }) {
|
|
15313
|
-
const formatValue = (value) => {
|
|
15314
|
-
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
15315
|
-
if (units === '$' && !isNaN(numValue)) {
|
|
15316
|
-
return numValue.toLocaleString();
|
|
15317
|
-
}
|
|
15318
|
-
return value;
|
|
15319
|
-
};
|
|
15320
|
-
const defaultOptions = {
|
|
15321
|
-
responsive: true,
|
|
15322
|
-
maintainAspectRatio: false,
|
|
15323
|
-
layout: {
|
|
15324
|
-
padding: {
|
|
15325
|
-
bottom: 0,
|
|
15326
|
-
top: 0,
|
|
15327
|
-
left: 0,
|
|
15328
|
-
right: 0,
|
|
15329
|
-
},
|
|
15330
|
-
},
|
|
15331
|
-
plugins: {
|
|
15332
|
-
legend: {
|
|
15333
|
-
display: false,
|
|
15334
|
-
labels: {
|
|
15335
|
-
boxWidth: 5,
|
|
15336
|
-
boxHeight: 5,
|
|
15337
|
-
},
|
|
15338
|
-
position: "bottom"
|
|
15339
|
-
},
|
|
15340
|
-
title: {
|
|
15341
|
-
display: true,
|
|
15342
|
-
text: title,
|
|
15343
|
-
font: {
|
|
15344
|
-
size: 18,
|
|
15345
|
-
weight: "bold",
|
|
15346
|
-
},
|
|
15347
|
-
color: "#0F172A"
|
|
15348
|
-
},
|
|
15349
|
-
tooltip: {
|
|
15350
|
-
callbacks: {
|
|
15351
|
-
label: function (context) {
|
|
15352
|
-
const value = context.parsed.y;
|
|
15353
|
-
return units ? `${context.dataset.label}: ${formatValue(value)} ${units}` : `${context.dataset.label}: ${value}`;
|
|
15354
|
-
}
|
|
15355
|
-
}
|
|
15356
|
-
},
|
|
15357
|
-
},
|
|
15358
|
-
scales: {
|
|
15359
|
-
x: {
|
|
15360
|
-
ticks: { autoSkip: true, maxTicksLimit: 8, maxRotation: 45, minRotation: 0 },
|
|
15361
|
-
},
|
|
15362
|
-
y: {
|
|
15363
|
-
beginAtZero: true,
|
|
15364
|
-
ticks: {
|
|
15365
|
-
callback: function (value) {
|
|
15366
|
-
return units ? `${formatValue(value)} ${units}` : value;
|
|
15367
|
-
}
|
|
15368
|
-
}
|
|
15369
|
-
},
|
|
15370
|
-
},
|
|
15371
|
-
};
|
|
15372
|
-
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions }));
|
|
15373
|
-
}
|
|
15374
|
-
|
|
15375
15239
|
function DataGrid({ title, data, className }) {
|
|
15376
15240
|
const { columns, rows } = data;
|
|
15377
15241
|
if (!columns || columns.length === 0 || !rows || rows.length === 0) {
|
|
@@ -36072,24 +35936,12 @@ const createInitialChartState = (agentType, widgetIds, datasetId) => {
|
|
|
36072
35936
|
const baseState = { dataset_id: datasetId || "home_generation_dataset" };
|
|
36073
35937
|
switch (agentType) {
|
|
36074
35938
|
case "Pie Chart Agent":
|
|
36075
|
-
return {
|
|
36076
|
-
pie_chart_data: {
|
|
35939
|
+
return Object.assign({ pie_chart_data: {
|
|
36077
35940
|
title: "",
|
|
36078
35941
|
type: "pie",
|
|
36079
35942
|
chart_type: "financial",
|
|
36080
35943
|
data: { labels: [], values: [], percentages: [], total: 0 },
|
|
36081
35944
|
metadata: { categories: 0, largest_category: "", largest_value: 0, largest_percentage: 0 }
|
|
36082
|
-
}
|
|
36083
|
-
};
|
|
36084
|
-
case "Line Chart Agent":
|
|
36085
|
-
case "Bar Chart Agent":
|
|
36086
|
-
return Object.assign({ bar_chart_data: {
|
|
36087
|
-
title: "",
|
|
36088
|
-
type: agentType === "Line Chart Agent" ? "line" : "bar",
|
|
36089
|
-
chart_type: "financial",
|
|
36090
|
-
orientation: agentType === "Line Chart Agent" ? "horizontal" : "vertical",
|
|
36091
|
-
data: { labels: [], values: [], total: 0, average: 0 },
|
|
36092
|
-
metadata: { categories: 0, highest_category: "", highest_value: 0, lowest_category: "", lowest_value: 0, range: 0 }
|
|
36093
35945
|
} }, baseState);
|
|
36094
35946
|
case "Series Bar Chart Agent":
|
|
36095
35947
|
case "Series Line Chart Agent":
|
|
@@ -36098,6 +35950,7 @@ const createInitialChartState = (agentType, widgetIds, datasetId) => {
|
|
|
36098
35950
|
type: "series_bar",
|
|
36099
35951
|
chart_type: "financial",
|
|
36100
35952
|
orientation: "vertical",
|
|
35953
|
+
units: "",
|
|
36101
35954
|
data: { labels: [], series: [], total: 0, average: 0 },
|
|
36102
35955
|
metadata: {
|
|
36103
35956
|
categories: 0, series_count: 0, highest_category: "", highest_value: 0, highest_series: "",
|
|
@@ -36120,7 +35973,7 @@ const createInitialChartState = (agentType, widgetIds, datasetId) => {
|
|
|
36120
35973
|
metadata: { created_at: "", content_type: "text", is_multiline: false }
|
|
36121
35974
|
} }, baseState);
|
|
36122
35975
|
default:
|
|
36123
|
-
return { widget_ids: widgetIds };
|
|
35976
|
+
return Object.assign({ widget_ids: widgetIds }, baseState);
|
|
36124
35977
|
}
|
|
36125
35978
|
};
|
|
36126
35979
|
const loadAgentState = async (widgetBackendUrl, threadId, agentName) => {
|
|
@@ -36218,58 +36071,6 @@ const getStyleValues = (styles = {}) => {
|
|
|
36218
36071
|
textAlign: alignment,
|
|
36219
36072
|
};
|
|
36220
36073
|
};
|
|
36221
|
-
function BarChartComponent({ orientation, barChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36222
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
36223
|
-
const hasCalledRef = useRef(false);
|
|
36224
|
-
const labels = ((_b = (_a = barChartState === null || barChartState === void 0 ? void 0 : barChartState.bar_chart_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.labels) || ((_e = (_d = (_c = barChartState === null || barChartState === void 0 ? void 0 : barChartState.state) === null || _c === void 0 ? void 0 : _c.bar_chart_data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.labels) || [];
|
|
36225
|
-
const values = ((_g = (_f = barChartState === null || barChartState === void 0 ? void 0 : barChartState.bar_chart_data) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.values) || ((_k = (_j = (_h = barChartState === null || barChartState === void 0 ? void 0 : barChartState.state) === null || _h === void 0 ? void 0 : _h.bar_chart_data) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.values) || [];
|
|
36226
|
-
const chartTitle = ((_l = barChartState === null || barChartState === void 0 ? void 0 : barChartState.bar_chart_data) === null || _l === void 0 ? void 0 : _l.title) || ((_o = (_m = barChartState === null || barChartState === void 0 ? void 0 : barChartState.state) === null || _m === void 0 ? void 0 : _m.bar_chart_data) === null || _o === void 0 ? void 0 : _o.title) || "";
|
|
36227
|
-
const units = ((_p = barChartState === null || barChartState === void 0 ? void 0 : barChartState.bar_chart_data) === null || _p === void 0 ? void 0 : _p.units) || ((_r = (_q = barChartState === null || barChartState === void 0 ? void 0 : barChartState.state) === null || _q === void 0 ? void 0 : _q.bar_chart_data) === null || _r === void 0 ? void 0 : _r.units) || "";
|
|
36228
|
-
values.length > 0 ? Math.max(...values) : 0;
|
|
36229
|
-
const isEmpty = labels.length === 0 || values.length === 0;
|
|
36230
|
-
const handleRefresh = async () => {
|
|
36231
|
-
if (query && widgetBackendUrl && widgetId) {
|
|
36232
|
-
await clearChat(widgetBackendUrl, widgetId);
|
|
36233
|
-
appendMessage(new TextMessage({
|
|
36234
|
-
content: `${query} and render data on a bar chart`,
|
|
36235
|
-
role: Role.User,
|
|
36236
|
-
}));
|
|
36237
|
-
}
|
|
36238
|
-
};
|
|
36239
|
-
useEffect(() => {
|
|
36240
|
-
if (isEmpty && query && isFirstLoad && !(barChartState === null || barChartState === void 0 ? void 0 : barChartState.agent_message) && !hasCalledRef.current) {
|
|
36241
|
-
// console.log('calling append message')
|
|
36242
|
-
hasCalledRef.current = true;
|
|
36243
|
-
handleRefresh();
|
|
36244
|
-
}
|
|
36245
|
-
}, [isEmpty, query, isFirstLoad, barChartState]);
|
|
36246
|
-
// Start timeout when chart is empty and loading
|
|
36247
|
-
useEffect(() => {
|
|
36248
|
-
if (isEmpty && startLoadingTimeout && !(barChartState === null || barChartState === void 0 ? void 0 : barChartState.agent_message)) {
|
|
36249
|
-
startLoadingTimeout();
|
|
36250
|
-
}
|
|
36251
|
-
else if (!isEmpty && clearLoadingTimeout) {
|
|
36252
|
-
clearLoadingTimeout();
|
|
36253
|
-
}
|
|
36254
|
-
}, [isEmpty, startLoadingTimeout, clearLoadingTimeout]);
|
|
36255
|
-
const finalColors = useMemo(() => {
|
|
36256
|
-
return shuffleColors(DEFAULT_COLORS, labels === null || labels === void 0 ? void 0 : labels.length);
|
|
36257
|
-
}, [labels.length]);
|
|
36258
|
-
if (isEmpty) {
|
|
36259
|
-
return createLoadingComponent();
|
|
36260
|
-
}
|
|
36261
|
-
const transformedData = {
|
|
36262
|
-
labels: labels,
|
|
36263
|
-
datasets: [
|
|
36264
|
-
{
|
|
36265
|
-
label: chartTitle || "Data",
|
|
36266
|
-
data: values,
|
|
36267
|
-
backgroundColor: finalColors,
|
|
36268
|
-
},
|
|
36269
|
-
],
|
|
36270
|
-
};
|
|
36271
|
-
return (jsxRuntimeExports.jsx(BarChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units }));
|
|
36272
|
-
}
|
|
36273
36074
|
function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36274
36075
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
36275
36076
|
const hasCalledRef = useRef(false);
|
|
@@ -36280,7 +36081,7 @@ function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, app
|
|
|
36280
36081
|
const isEmpty = labels.length === 0 || series.length === 0;
|
|
36281
36082
|
const handleRefresh = async () => {
|
|
36282
36083
|
if (query) {
|
|
36283
|
-
await clearChat();
|
|
36084
|
+
await clearChat(widgetBackendUrl, widgetId);
|
|
36284
36085
|
// Send trigger event to clear chart state
|
|
36285
36086
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36286
36087
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -36331,7 +36132,7 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
|
|
|
36331
36132
|
const isEmpty = labels.length === 0 || series.length === 0;
|
|
36332
36133
|
const handleRefresh = async () => {
|
|
36333
36134
|
if (query) {
|
|
36334
|
-
await clearChat();
|
|
36135
|
+
await clearChat(widgetBackendUrl, widgetId);
|
|
36335
36136
|
// Send trigger event to clear chart state
|
|
36336
36137
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36337
36138
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -36390,7 +36191,7 @@ function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirs
|
|
|
36390
36191
|
const isEmpty = labels.length === 0 || values.length === 0;
|
|
36391
36192
|
const handleRefresh = async () => {
|
|
36392
36193
|
if (query) {
|
|
36393
|
-
await clearChat();
|
|
36194
|
+
await clearChat(widgetBackendUrl, widgetId);
|
|
36394
36195
|
// Send trigger event to clear chart state
|
|
36395
36196
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36396
36197
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -36434,63 +36235,6 @@ function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirs
|
|
|
36434
36235
|
};
|
|
36435
36236
|
return (jsxRuntimeExports.jsx(PieChart, { title: chartTitle, data: transformedData, units: units }));
|
|
36436
36237
|
}
|
|
36437
|
-
function LineChartComponent({ lineChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36438
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
36439
|
-
const hasCalledRef = useRef(false);
|
|
36440
|
-
const labels = ((_b = (_a = lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.bar_chart_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.labels) || ((_e = (_d = (_c = lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.state) === null || _c === void 0 ? void 0 : _c.bar_chart_data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.labels) || [];
|
|
36441
|
-
const values = ((_g = (_f = lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.bar_chart_data) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.values) || ((_k = (_j = (_h = lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.state) === null || _h === void 0 ? void 0 : _h.bar_chart_data) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.values) || [];
|
|
36442
|
-
const chartTitle = ((_l = lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.bar_chart_data) === null || _l === void 0 ? void 0 : _l.title) || ((_o = (_m = lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.state) === null || _m === void 0 ? void 0 : _m.bar_chart_data) === null || _o === void 0 ? void 0 : _o.title) || "";
|
|
36443
|
-
const units = ((_p = lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.bar_chart_data) === null || _p === void 0 ? void 0 : _p.units) || ((_r = (_q = lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.state) === null || _q === void 0 ? void 0 : _q.bar_chart_data) === null || _r === void 0 ? void 0 : _r.units) || "";
|
|
36444
|
-
values.length > 0 ? Math.max(...values) : 0;
|
|
36445
|
-
const isEmpty = labels.length === 0 || values.length === 0;
|
|
36446
|
-
const handleRefresh = async () => {
|
|
36447
|
-
if (query && widgetBackendUrl && widgetId) {
|
|
36448
|
-
await clearChat(widgetBackendUrl, widgetId);
|
|
36449
|
-
appendMessage(new TextMessage({
|
|
36450
|
-
content: `${query} and render data on a bar chart`,
|
|
36451
|
-
role: Role.User,
|
|
36452
|
-
}));
|
|
36453
|
-
}
|
|
36454
|
-
};
|
|
36455
|
-
useEffect(() => {
|
|
36456
|
-
if (isEmpty && query && isFirstLoad && !(lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.agent_message) && !hasCalledRef.current) {
|
|
36457
|
-
hasCalledRef.current = true;
|
|
36458
|
-
handleRefresh();
|
|
36459
|
-
}
|
|
36460
|
-
}, [isEmpty, query, isFirstLoad, lineChartState]);
|
|
36461
|
-
// Start timeout when chart is empty and loading
|
|
36462
|
-
useEffect(() => {
|
|
36463
|
-
if (isEmpty && startLoadingTimeout && !(lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.agent_message)) {
|
|
36464
|
-
startLoadingTimeout();
|
|
36465
|
-
}
|
|
36466
|
-
else if (!isEmpty && clearLoadingTimeout) {
|
|
36467
|
-
clearLoadingTimeout();
|
|
36468
|
-
}
|
|
36469
|
-
}, [isEmpty, startLoadingTimeout, clearLoadingTimeout]);
|
|
36470
|
-
const lineColor = useMemo(() => {
|
|
36471
|
-
return LINE_COLORS[Math.floor(Math.random() * LINE_COLORS.length)];
|
|
36472
|
-
}, [labels.length]);
|
|
36473
|
-
if (isEmpty) {
|
|
36474
|
-
return createLoadingComponent();
|
|
36475
|
-
}
|
|
36476
|
-
const transformedData = {
|
|
36477
|
-
labels: labels,
|
|
36478
|
-
datasets: [
|
|
36479
|
-
{
|
|
36480
|
-
label: chartTitle || "Data",
|
|
36481
|
-
data: values,
|
|
36482
|
-
borderColor: lineColor,
|
|
36483
|
-
backgroundColor: "rgba(96, 165, 250, 0.1)",
|
|
36484
|
-
borderWidth: 2,
|
|
36485
|
-
pointBackgroundColor: lineColor,
|
|
36486
|
-
pointBorderColor: lineColor,
|
|
36487
|
-
pointRadius: 4,
|
|
36488
|
-
fill: true,
|
|
36489
|
-
},
|
|
36490
|
-
],
|
|
36491
|
-
};
|
|
36492
|
-
return (jsxRuntimeExports.jsx(LineChart, { title: chartTitle, data: transformedData, units: units }));
|
|
36493
|
-
}
|
|
36494
36238
|
function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36495
36239
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
36496
36240
|
const hasCalledRef = useRef(false);
|
|
@@ -36500,7 +36244,7 @@ function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirs
|
|
|
36500
36244
|
const isEmpty = columns.length === 0 || rows.length === 0;
|
|
36501
36245
|
const handleRefresh = async () => {
|
|
36502
36246
|
if (query) {
|
|
36503
|
-
await clearChat();
|
|
36247
|
+
await clearChat(widgetBackendUrl, widgetId);
|
|
36504
36248
|
// Send trigger event to clear chart state
|
|
36505
36249
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36506
36250
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -36544,7 +36288,7 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
36544
36288
|
const isEmpty = !content || content.trim() === "";
|
|
36545
36289
|
const handleRefresh = async () => {
|
|
36546
36290
|
if (query) {
|
|
36547
|
-
await clearChat();
|
|
36291
|
+
await clearChat(widgetBackendUrl, widgetId);
|
|
36548
36292
|
// Send trigger event to clear chart state
|
|
36549
36293
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36550
36294
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -36578,7 +36322,7 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
36578
36322
|
return (jsxRuntimeExports.jsx(SummaryWidget, { title: title, data: data, metadata: metadata, className: "" }));
|
|
36579
36323
|
}
|
|
36580
36324
|
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
|
|
36325
|
+
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;
|
|
36582
36326
|
const agentType = (_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentType;
|
|
36583
36327
|
const orientation = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.orientation;
|
|
36584
36328
|
const isFirstLoad = (_c = widget.config) === null || _c === void 0 ? void 0 : _c.isFirstLoad;
|
|
@@ -36687,29 +36431,6 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36687
36431
|
}
|
|
36688
36432
|
}, CHART_REFRESH_TIMEOUT * 10);
|
|
36689
36433
|
}, [widgetBackendUrl, (_f = widget.config) === null || _f === void 0 ? void 0 : _f.agentName, widget.id, apiCallCount, setChartState]);
|
|
36690
|
-
// Function to clear chat and reset chart state
|
|
36691
|
-
useCallback(async (widgetId) => {
|
|
36692
|
-
if (!widgetBackendUrl)
|
|
36693
|
-
return;
|
|
36694
|
-
try {
|
|
36695
|
-
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
36696
|
-
method: 'POST',
|
|
36697
|
-
headers: {
|
|
36698
|
-
'Content-Type': 'application/json',
|
|
36699
|
-
},
|
|
36700
|
-
body: JSON.stringify({
|
|
36701
|
-
session_id: widgetId,
|
|
36702
|
-
delete_state: true
|
|
36703
|
-
}),
|
|
36704
|
-
});
|
|
36705
|
-
setChartState(createInitialChartState(agentType || '', widgetIds, datasetId));
|
|
36706
|
-
setApiCallCount(0);
|
|
36707
|
-
setHasTimeoutError(false);
|
|
36708
|
-
}
|
|
36709
|
-
catch (error) {
|
|
36710
|
-
console.error('Failed to clear chat and state:', error);
|
|
36711
|
-
}
|
|
36712
|
-
}, [widgetBackendUrl, setChartState, agentType, widgetIds]);
|
|
36713
36434
|
// Clean up timeout and polling on unmount
|
|
36714
36435
|
useEffect(() => {
|
|
36715
36436
|
return () => {
|
|
@@ -36788,15 +36509,13 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36788
36509
|
}, [widget.id, appendMessage, agentType, setChartState]);
|
|
36789
36510
|
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
36511
|
// Check if data is empty based on agent type
|
|
36791
|
-
(agentType === "Bar Chart Agent" && (!((_j = (_h = (_g = chartState.
|
|
36792
|
-
(agentType === "Series
|
|
36793
|
-
(agentType === "
|
|
36794
|
-
(agentType === "
|
|
36795
|
-
(agentType === "
|
|
36796
|
-
|
|
36797
|
-
|
|
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?"
|
|
36512
|
+
(agentType === "Series Bar Chart Agent" && (!((_j = (_h = (_g = chartState.series_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.series_bar_chart_data) === null || _k === void 0 ? void 0 : _k.data) === null || _l === void 0 ? void 0 : _l.series) === null || _m === void 0 ? void 0 : _m.length))) ||
|
|
36513
|
+
(agentType === "Series Line 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))) ||
|
|
36514
|
+
(agentType === "Pie Chart Agent" && (!((_w = (_v = (_u = chartState.pie_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.pie_chart_data) === null || _x === void 0 ? void 0 : _x.data) === null || _y === void 0 ? void 0 : _y.values) === null || _z === void 0 ? void 0 : _z.length))) ||
|
|
36515
|
+
(agentType === "Data Grid Agent" && (!((_2 = (_1 = (_0 = chartState.matrix_grid_data) === null || _0 === void 0 ? void 0 : _0.data) === null || _1 === void 0 ? void 0 : _1.headers) === null || _2 === void 0 ? void 0 : _2.length) || !((_5 = (_4 = (_3 = chartState.matrix_grid_data) === null || _3 === void 0 ? void 0 : _3.data) === null || _4 === void 0 ? void 0 : _4.rows) === null || _5 === void 0 ? void 0 : _5.length))) ||
|
|
36516
|
+
(agentType === "Summary Agent" && (!((_7 = (_6 = chartState.summary_data) === null || _6 === void 0 ? void 0 : _6.data) === null || _7 === void 0 ? void 0 : _7.content) || ((_10 = (_9 = (_8 = chartState.summary_data) === null || _8 === void 0 ? void 0 : _8.data) === null || _9 === void 0 ? void 0 : _9.content) === null || _10 === void 0 ? void 0 : _10.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 === "Series Bar Chart Agent" ? (jsxRuntimeExports.jsx(SeriesBarChartComponent, { seriesBarChartState: chartState, styles: styles, orientation: orientation, appendMessage: appendMessage, query: (_11 = widget.config) === null || _11 === void 0 ? void 0 : _11.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: (_12 = widget.config) === null || _12 === void 0 ? void 0 : _12.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: (_13 = widget.config) === null || _13 === void 0 ? void 0 : _13.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: (_14 = widget.config) === null || _14 === void 0 ? void 0 : _14.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: (_15 = widget.config) === null || _15 === void 0 ? void 0 : _15.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: {
|
|
36517
|
+
title: ((_16 = widget.config) === null || _16 === void 0 ? void 0 : _16.copilotTitle) || widget.title,
|
|
36518
|
+
initial: ((_17 = widget.config) === null || _17 === void 0 ? void 0 : _17.copilotInitialMessage) || ((_18 = widget.config) === null || _18 === void 0 ? void 0 : _18.placeholder) || "How can I help you today?"
|
|
36800
36519
|
}, onSubmitMessage: () => {
|
|
36801
36520
|
setChartState(prevState => (Object.assign(Object.assign({}, prevState), { widget_ids: widgetIds, dataset_id: datasetId })));
|
|
36802
36521
|
startPollingForData();
|
|
@@ -36883,14 +36602,14 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
36883
36602
|
{
|
|
36884
36603
|
type: 'series-bar-chart',
|
|
36885
36604
|
title: 'Bar Chart Widget',
|
|
36886
|
-
icon: BarChart
|
|
36605
|
+
icon: BarChart,
|
|
36887
36606
|
description: 'Create interactive series bar charts with custom queries',
|
|
36888
36607
|
configRequired: true
|
|
36889
36608
|
},
|
|
36890
36609
|
{
|
|
36891
36610
|
type: 'series-line-chart',
|
|
36892
36611
|
title: 'Line Chart Widget',
|
|
36893
|
-
icon: LineChart
|
|
36612
|
+
icon: LineChart,
|
|
36894
36613
|
description: 'Create interactive series line charts with custom queries',
|
|
36895
36614
|
configRequired: true
|
|
36896
36615
|
},
|
|
@@ -37066,13 +36785,13 @@ const IconMap = {
|
|
|
37066
36785
|
search: Search,
|
|
37067
36786
|
filter: Filter,
|
|
37068
36787
|
results: LayoutGrid,
|
|
37069
|
-
analytics: BarChart
|
|
36788
|
+
analytics: BarChart,
|
|
37070
36789
|
custom: LayoutGrid,
|
|
37071
36790
|
header: Layout,
|
|
37072
36791
|
footer: Layout,
|
|
37073
36792
|
text: Type,
|
|
37074
36793
|
agent: Bot,
|
|
37075
|
-
'bar-chart': BarChart
|
|
36794
|
+
'bar-chart': BarChart,
|
|
37076
36795
|
'pie-chart': PieChart$1,
|
|
37077
36796
|
'chatbot': Bot,
|
|
37078
36797
|
};
|
package/dist/index.js
CHANGED
|
@@ -15075,78 +15075,6 @@ const Line = /* #__PURE__ */ createTypedChart('line', LineController);
|
|
|
15075
15075
|
const Bar = /* #__PURE__ */ createTypedChart('bar', BarController);
|
|
15076
15076
|
const Pie = /* #__PURE__ */ createTypedChart('pie', PieController);
|
|
15077
15077
|
|
|
15078
|
-
Chart$1.register(CategoryScale, LinearScale, BarElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15079
|
-
function BarChart({ orientation, title, data, options, className, units }) {
|
|
15080
|
-
const formatValue = (value) => {
|
|
15081
|
-
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
15082
|
-
if (units === '$' && !isNaN(numValue)) {
|
|
15083
|
-
return numValue.toLocaleString();
|
|
15084
|
-
}
|
|
15085
|
-
return value;
|
|
15086
|
-
};
|
|
15087
|
-
const defaultOptions = {
|
|
15088
|
-
responsive: true,
|
|
15089
|
-
maintainAspectRatio: false,
|
|
15090
|
-
indexAxis: orientation === "horizontal" ? "y" : "x",
|
|
15091
|
-
layout: {
|
|
15092
|
-
padding: {
|
|
15093
|
-
bottom: 0,
|
|
15094
|
-
top: 0,
|
|
15095
|
-
left: 0,
|
|
15096
|
-
right: 0,
|
|
15097
|
-
},
|
|
15098
|
-
},
|
|
15099
|
-
plugins: {
|
|
15100
|
-
legend: {
|
|
15101
|
-
display: false,
|
|
15102
|
-
labels: {
|
|
15103
|
-
boxWidth: 5,
|
|
15104
|
-
boxHeight: 5,
|
|
15105
|
-
},
|
|
15106
|
-
position: "bottom"
|
|
15107
|
-
},
|
|
15108
|
-
title: {
|
|
15109
|
-
display: true,
|
|
15110
|
-
text: title,
|
|
15111
|
-
font: {
|
|
15112
|
-
size: 18,
|
|
15113
|
-
weight: "bold",
|
|
15114
|
-
},
|
|
15115
|
-
color: "#0F172A"
|
|
15116
|
-
},
|
|
15117
|
-
tooltip: {
|
|
15118
|
-
callbacks: {
|
|
15119
|
-
label: function (context) {
|
|
15120
|
-
const value = context.parsed.y || context.parsed.x;
|
|
15121
|
-
return units ? `${context.dataset.label}: ${formatValue(value)} ${units}` : `${context.dataset.label}: ${value}`;
|
|
15122
|
-
}
|
|
15123
|
-
}
|
|
15124
|
-
},
|
|
15125
|
-
},
|
|
15126
|
-
scales: {
|
|
15127
|
-
x: {
|
|
15128
|
-
ticks: {
|
|
15129
|
-
autoSkip: false,
|
|
15130
|
-
maxRotation: 45,
|
|
15131
|
-
minRotation: 45,
|
|
15132
|
-
font: {
|
|
15133
|
-
size: 10
|
|
15134
|
-
}
|
|
15135
|
-
},
|
|
15136
|
-
},
|
|
15137
|
-
y: {
|
|
15138
|
-
beginAtZero: true,
|
|
15139
|
-
ticks: {
|
|
15140
|
-
callback: function (value) {
|
|
15141
|
-
return units ? `${formatValue(value)} ${units}` : value;
|
|
15142
|
-
}
|
|
15143
|
-
}
|
|
15144
|
-
},
|
|
15145
|
-
},
|
|
15146
|
-
};
|
|
15147
|
-
return (jsxRuntimeExports.jsx(Bar, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions }));
|
|
15148
|
-
}
|
|
15149
|
-
|
|
15150
15078
|
Chart$1.register(CategoryScale, LinearScale, BarElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15151
15079
|
function SeriesChart({ orientation, title, data, options, className, units }) {
|
|
15152
15080
|
const formatValue = (value) => {
|
|
@@ -15335,70 +15263,6 @@ const PieChart = (props) => {
|
|
|
15335
15263
|
return jsxRuntimeExports.jsx(Pie, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions });
|
|
15336
15264
|
};
|
|
15337
15265
|
|
|
15338
|
-
Chart$1.register(CategoryScale, LinearScale, PointElement, LineElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15339
|
-
function LineChart({ title, data, options, className, units }) {
|
|
15340
|
-
const formatValue = (value) => {
|
|
15341
|
-
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
15342
|
-
if (units === '$' && !isNaN(numValue)) {
|
|
15343
|
-
return numValue.toLocaleString();
|
|
15344
|
-
}
|
|
15345
|
-
return value;
|
|
15346
|
-
};
|
|
15347
|
-
const defaultOptions = {
|
|
15348
|
-
responsive: true,
|
|
15349
|
-
maintainAspectRatio: false,
|
|
15350
|
-
layout: {
|
|
15351
|
-
padding: {
|
|
15352
|
-
bottom: 0,
|
|
15353
|
-
top: 0,
|
|
15354
|
-
left: 0,
|
|
15355
|
-
right: 0,
|
|
15356
|
-
},
|
|
15357
|
-
},
|
|
15358
|
-
plugins: {
|
|
15359
|
-
legend: {
|
|
15360
|
-
display: false,
|
|
15361
|
-
labels: {
|
|
15362
|
-
boxWidth: 5,
|
|
15363
|
-
boxHeight: 5,
|
|
15364
|
-
},
|
|
15365
|
-
position: "bottom"
|
|
15366
|
-
},
|
|
15367
|
-
title: {
|
|
15368
|
-
display: true,
|
|
15369
|
-
text: title,
|
|
15370
|
-
font: {
|
|
15371
|
-
size: 18,
|
|
15372
|
-
weight: "bold",
|
|
15373
|
-
},
|
|
15374
|
-
color: "#0F172A"
|
|
15375
|
-
},
|
|
15376
|
-
tooltip: {
|
|
15377
|
-
callbacks: {
|
|
15378
|
-
label: function (context) {
|
|
15379
|
-
const value = context.parsed.y;
|
|
15380
|
-
return units ? `${context.dataset.label}: ${formatValue(value)} ${units}` : `${context.dataset.label}: ${value}`;
|
|
15381
|
-
}
|
|
15382
|
-
}
|
|
15383
|
-
},
|
|
15384
|
-
},
|
|
15385
|
-
scales: {
|
|
15386
|
-
x: {
|
|
15387
|
-
ticks: { autoSkip: true, maxTicksLimit: 8, maxRotation: 45, minRotation: 0 },
|
|
15388
|
-
},
|
|
15389
|
-
y: {
|
|
15390
|
-
beginAtZero: true,
|
|
15391
|
-
ticks: {
|
|
15392
|
-
callback: function (value) {
|
|
15393
|
-
return units ? `${formatValue(value)} ${units}` : value;
|
|
15394
|
-
}
|
|
15395
|
-
}
|
|
15396
|
-
},
|
|
15397
|
-
},
|
|
15398
|
-
};
|
|
15399
|
-
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions }));
|
|
15400
|
-
}
|
|
15401
|
-
|
|
15402
15266
|
function DataGrid({ title, data, className }) {
|
|
15403
15267
|
const { columns, rows } = data;
|
|
15404
15268
|
if (!columns || columns.length === 0 || !rows || rows.length === 0) {
|
|
@@ -36099,24 +35963,12 @@ const createInitialChartState = (agentType, widgetIds, datasetId) => {
|
|
|
36099
35963
|
const baseState = { dataset_id: datasetId || "home_generation_dataset" };
|
|
36100
35964
|
switch (agentType) {
|
|
36101
35965
|
case "Pie Chart Agent":
|
|
36102
|
-
return {
|
|
36103
|
-
pie_chart_data: {
|
|
35966
|
+
return Object.assign({ pie_chart_data: {
|
|
36104
35967
|
title: "",
|
|
36105
35968
|
type: "pie",
|
|
36106
35969
|
chart_type: "financial",
|
|
36107
35970
|
data: { labels: [], values: [], percentages: [], total: 0 },
|
|
36108
35971
|
metadata: { categories: 0, largest_category: "", largest_value: 0, largest_percentage: 0 }
|
|
36109
|
-
}
|
|
36110
|
-
};
|
|
36111
|
-
case "Line Chart Agent":
|
|
36112
|
-
case "Bar Chart Agent":
|
|
36113
|
-
return Object.assign({ bar_chart_data: {
|
|
36114
|
-
title: "",
|
|
36115
|
-
type: agentType === "Line Chart Agent" ? "line" : "bar",
|
|
36116
|
-
chart_type: "financial",
|
|
36117
|
-
orientation: agentType === "Line Chart Agent" ? "horizontal" : "vertical",
|
|
36118
|
-
data: { labels: [], values: [], total: 0, average: 0 },
|
|
36119
|
-
metadata: { categories: 0, highest_category: "", highest_value: 0, lowest_category: "", lowest_value: 0, range: 0 }
|
|
36120
35972
|
} }, baseState);
|
|
36121
35973
|
case "Series Bar Chart Agent":
|
|
36122
35974
|
case "Series Line Chart Agent":
|
|
@@ -36125,6 +35977,7 @@ const createInitialChartState = (agentType, widgetIds, datasetId) => {
|
|
|
36125
35977
|
type: "series_bar",
|
|
36126
35978
|
chart_type: "financial",
|
|
36127
35979
|
orientation: "vertical",
|
|
35980
|
+
units: "",
|
|
36128
35981
|
data: { labels: [], series: [], total: 0, average: 0 },
|
|
36129
35982
|
metadata: {
|
|
36130
35983
|
categories: 0, series_count: 0, highest_category: "", highest_value: 0, highest_series: "",
|
|
@@ -36147,7 +36000,7 @@ const createInitialChartState = (agentType, widgetIds, datasetId) => {
|
|
|
36147
36000
|
metadata: { created_at: "", content_type: "text", is_multiline: false }
|
|
36148
36001
|
} }, baseState);
|
|
36149
36002
|
default:
|
|
36150
|
-
return { widget_ids: widgetIds };
|
|
36003
|
+
return Object.assign({ widget_ids: widgetIds }, baseState);
|
|
36151
36004
|
}
|
|
36152
36005
|
};
|
|
36153
36006
|
const loadAgentState = async (widgetBackendUrl, threadId, agentName) => {
|
|
@@ -36245,58 +36098,6 @@ const getStyleValues = (styles = {}) => {
|
|
|
36245
36098
|
textAlign: alignment,
|
|
36246
36099
|
};
|
|
36247
36100
|
};
|
|
36248
|
-
function BarChartComponent({ orientation, barChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36249
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
36250
|
-
const hasCalledRef = React.useRef(false);
|
|
36251
|
-
const labels = ((_b = (_a = barChartState === null || barChartState === void 0 ? void 0 : barChartState.bar_chart_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.labels) || ((_e = (_d = (_c = barChartState === null || barChartState === void 0 ? void 0 : barChartState.state) === null || _c === void 0 ? void 0 : _c.bar_chart_data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.labels) || [];
|
|
36252
|
-
const values = ((_g = (_f = barChartState === null || barChartState === void 0 ? void 0 : barChartState.bar_chart_data) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.values) || ((_k = (_j = (_h = barChartState === null || barChartState === void 0 ? void 0 : barChartState.state) === null || _h === void 0 ? void 0 : _h.bar_chart_data) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.values) || [];
|
|
36253
|
-
const chartTitle = ((_l = barChartState === null || barChartState === void 0 ? void 0 : barChartState.bar_chart_data) === null || _l === void 0 ? void 0 : _l.title) || ((_o = (_m = barChartState === null || barChartState === void 0 ? void 0 : barChartState.state) === null || _m === void 0 ? void 0 : _m.bar_chart_data) === null || _o === void 0 ? void 0 : _o.title) || "";
|
|
36254
|
-
const units = ((_p = barChartState === null || barChartState === void 0 ? void 0 : barChartState.bar_chart_data) === null || _p === void 0 ? void 0 : _p.units) || ((_r = (_q = barChartState === null || barChartState === void 0 ? void 0 : barChartState.state) === null || _q === void 0 ? void 0 : _q.bar_chart_data) === null || _r === void 0 ? void 0 : _r.units) || "";
|
|
36255
|
-
values.length > 0 ? Math.max(...values) : 0;
|
|
36256
|
-
const isEmpty = labels.length === 0 || values.length === 0;
|
|
36257
|
-
const handleRefresh = async () => {
|
|
36258
|
-
if (query && widgetBackendUrl && widgetId) {
|
|
36259
|
-
await clearChat(widgetBackendUrl, widgetId);
|
|
36260
|
-
appendMessage(new TextMessage({
|
|
36261
|
-
content: `${query} and render data on a bar chart`,
|
|
36262
|
-
role: Role.User,
|
|
36263
|
-
}));
|
|
36264
|
-
}
|
|
36265
|
-
};
|
|
36266
|
-
React.useEffect(() => {
|
|
36267
|
-
if (isEmpty && query && isFirstLoad && !(barChartState === null || barChartState === void 0 ? void 0 : barChartState.agent_message) && !hasCalledRef.current) {
|
|
36268
|
-
// console.log('calling append message')
|
|
36269
|
-
hasCalledRef.current = true;
|
|
36270
|
-
handleRefresh();
|
|
36271
|
-
}
|
|
36272
|
-
}, [isEmpty, query, isFirstLoad, barChartState]);
|
|
36273
|
-
// Start timeout when chart is empty and loading
|
|
36274
|
-
React.useEffect(() => {
|
|
36275
|
-
if (isEmpty && startLoadingTimeout && !(barChartState === null || barChartState === void 0 ? void 0 : barChartState.agent_message)) {
|
|
36276
|
-
startLoadingTimeout();
|
|
36277
|
-
}
|
|
36278
|
-
else if (!isEmpty && clearLoadingTimeout) {
|
|
36279
|
-
clearLoadingTimeout();
|
|
36280
|
-
}
|
|
36281
|
-
}, [isEmpty, startLoadingTimeout, clearLoadingTimeout]);
|
|
36282
|
-
const finalColors = React.useMemo(() => {
|
|
36283
|
-
return shuffleColors(DEFAULT_COLORS, labels === null || labels === void 0 ? void 0 : labels.length);
|
|
36284
|
-
}, [labels.length]);
|
|
36285
|
-
if (isEmpty) {
|
|
36286
|
-
return createLoadingComponent();
|
|
36287
|
-
}
|
|
36288
|
-
const transformedData = {
|
|
36289
|
-
labels: labels,
|
|
36290
|
-
datasets: [
|
|
36291
|
-
{
|
|
36292
|
-
label: chartTitle || "Data",
|
|
36293
|
-
data: values,
|
|
36294
|
-
backgroundColor: finalColors,
|
|
36295
|
-
},
|
|
36296
|
-
],
|
|
36297
|
-
};
|
|
36298
|
-
return (jsxRuntimeExports.jsx(BarChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units }));
|
|
36299
|
-
}
|
|
36300
36101
|
function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36301
36102
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
36302
36103
|
const hasCalledRef = React.useRef(false);
|
|
@@ -36307,7 +36108,7 @@ function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, app
|
|
|
36307
36108
|
const isEmpty = labels.length === 0 || series.length === 0;
|
|
36308
36109
|
const handleRefresh = async () => {
|
|
36309
36110
|
if (query) {
|
|
36310
|
-
await clearChat();
|
|
36111
|
+
await clearChat(widgetBackendUrl, widgetId);
|
|
36311
36112
|
// Send trigger event to clear chart state
|
|
36312
36113
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36313
36114
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -36358,7 +36159,7 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
|
|
|
36358
36159
|
const isEmpty = labels.length === 0 || series.length === 0;
|
|
36359
36160
|
const handleRefresh = async () => {
|
|
36360
36161
|
if (query) {
|
|
36361
|
-
await clearChat();
|
|
36162
|
+
await clearChat(widgetBackendUrl, widgetId);
|
|
36362
36163
|
// Send trigger event to clear chart state
|
|
36363
36164
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36364
36165
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -36417,7 +36218,7 @@ function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirs
|
|
|
36417
36218
|
const isEmpty = labels.length === 0 || values.length === 0;
|
|
36418
36219
|
const handleRefresh = async () => {
|
|
36419
36220
|
if (query) {
|
|
36420
|
-
await clearChat();
|
|
36221
|
+
await clearChat(widgetBackendUrl, widgetId);
|
|
36421
36222
|
// Send trigger event to clear chart state
|
|
36422
36223
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36423
36224
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -36461,63 +36262,6 @@ function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirs
|
|
|
36461
36262
|
};
|
|
36462
36263
|
return (jsxRuntimeExports.jsx(PieChart, { title: chartTitle, data: transformedData, units: units }));
|
|
36463
36264
|
}
|
|
36464
|
-
function LineChartComponent({ lineChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36465
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
36466
|
-
const hasCalledRef = React.useRef(false);
|
|
36467
|
-
const labels = ((_b = (_a = lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.bar_chart_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.labels) || ((_e = (_d = (_c = lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.state) === null || _c === void 0 ? void 0 : _c.bar_chart_data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.labels) || [];
|
|
36468
|
-
const values = ((_g = (_f = lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.bar_chart_data) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.values) || ((_k = (_j = (_h = lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.state) === null || _h === void 0 ? void 0 : _h.bar_chart_data) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.values) || [];
|
|
36469
|
-
const chartTitle = ((_l = lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.bar_chart_data) === null || _l === void 0 ? void 0 : _l.title) || ((_o = (_m = lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.state) === null || _m === void 0 ? void 0 : _m.bar_chart_data) === null || _o === void 0 ? void 0 : _o.title) || "";
|
|
36470
|
-
const units = ((_p = lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.bar_chart_data) === null || _p === void 0 ? void 0 : _p.units) || ((_r = (_q = lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.state) === null || _q === void 0 ? void 0 : _q.bar_chart_data) === null || _r === void 0 ? void 0 : _r.units) || "";
|
|
36471
|
-
values.length > 0 ? Math.max(...values) : 0;
|
|
36472
|
-
const isEmpty = labels.length === 0 || values.length === 0;
|
|
36473
|
-
const handleRefresh = async () => {
|
|
36474
|
-
if (query && widgetBackendUrl && widgetId) {
|
|
36475
|
-
await clearChat(widgetBackendUrl, widgetId);
|
|
36476
|
-
appendMessage(new TextMessage({
|
|
36477
|
-
content: `${query} and render data on a bar chart`,
|
|
36478
|
-
role: Role.User,
|
|
36479
|
-
}));
|
|
36480
|
-
}
|
|
36481
|
-
};
|
|
36482
|
-
React.useEffect(() => {
|
|
36483
|
-
if (isEmpty && query && isFirstLoad && !(lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.agent_message) && !hasCalledRef.current) {
|
|
36484
|
-
hasCalledRef.current = true;
|
|
36485
|
-
handleRefresh();
|
|
36486
|
-
}
|
|
36487
|
-
}, [isEmpty, query, isFirstLoad, lineChartState]);
|
|
36488
|
-
// Start timeout when chart is empty and loading
|
|
36489
|
-
React.useEffect(() => {
|
|
36490
|
-
if (isEmpty && startLoadingTimeout && !(lineChartState === null || lineChartState === void 0 ? void 0 : lineChartState.agent_message)) {
|
|
36491
|
-
startLoadingTimeout();
|
|
36492
|
-
}
|
|
36493
|
-
else if (!isEmpty && clearLoadingTimeout) {
|
|
36494
|
-
clearLoadingTimeout();
|
|
36495
|
-
}
|
|
36496
|
-
}, [isEmpty, startLoadingTimeout, clearLoadingTimeout]);
|
|
36497
|
-
const lineColor = React.useMemo(() => {
|
|
36498
|
-
return LINE_COLORS[Math.floor(Math.random() * LINE_COLORS.length)];
|
|
36499
|
-
}, [labels.length]);
|
|
36500
|
-
if (isEmpty) {
|
|
36501
|
-
return createLoadingComponent();
|
|
36502
|
-
}
|
|
36503
|
-
const transformedData = {
|
|
36504
|
-
labels: labels,
|
|
36505
|
-
datasets: [
|
|
36506
|
-
{
|
|
36507
|
-
label: chartTitle || "Data",
|
|
36508
|
-
data: values,
|
|
36509
|
-
borderColor: lineColor,
|
|
36510
|
-
backgroundColor: "rgba(96, 165, 250, 0.1)",
|
|
36511
|
-
borderWidth: 2,
|
|
36512
|
-
pointBackgroundColor: lineColor,
|
|
36513
|
-
pointBorderColor: lineColor,
|
|
36514
|
-
pointRadius: 4,
|
|
36515
|
-
fill: true,
|
|
36516
|
-
},
|
|
36517
|
-
],
|
|
36518
|
-
};
|
|
36519
|
-
return (jsxRuntimeExports.jsx(LineChart, { title: chartTitle, data: transformedData, units: units }));
|
|
36520
|
-
}
|
|
36521
36265
|
function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36522
36266
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
36523
36267
|
const hasCalledRef = React.useRef(false);
|
|
@@ -36527,7 +36271,7 @@ function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirs
|
|
|
36527
36271
|
const isEmpty = columns.length === 0 || rows.length === 0;
|
|
36528
36272
|
const handleRefresh = async () => {
|
|
36529
36273
|
if (query) {
|
|
36530
|
-
await clearChat();
|
|
36274
|
+
await clearChat(widgetBackendUrl, widgetId);
|
|
36531
36275
|
// Send trigger event to clear chart state
|
|
36532
36276
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36533
36277
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -36571,7 +36315,7 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
36571
36315
|
const isEmpty = !content || content.trim() === "";
|
|
36572
36316
|
const handleRefresh = async () => {
|
|
36573
36317
|
if (query) {
|
|
36574
|
-
await clearChat();
|
|
36318
|
+
await clearChat(widgetBackendUrl, widgetId);
|
|
36575
36319
|
// Send trigger event to clear chart state
|
|
36576
36320
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
36577
36321
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -36605,7 +36349,7 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
36605
36349
|
return (jsxRuntimeExports.jsx(SummaryWidget, { title: title, data: data, metadata: metadata, className: "" }));
|
|
36606
36350
|
}
|
|
36607
36351
|
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
|
|
36352
|
+
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;
|
|
36609
36353
|
const agentType = (_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentType;
|
|
36610
36354
|
const orientation = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.orientation;
|
|
36611
36355
|
const isFirstLoad = (_c = widget.config) === null || _c === void 0 ? void 0 : _c.isFirstLoad;
|
|
@@ -36714,29 +36458,6 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36714
36458
|
}
|
|
36715
36459
|
}, CHART_REFRESH_TIMEOUT * 10);
|
|
36716
36460
|
}, [widgetBackendUrl, (_f = widget.config) === null || _f === void 0 ? void 0 : _f.agentName, widget.id, apiCallCount, setChartState]);
|
|
36717
|
-
// Function to clear chat and reset chart state
|
|
36718
|
-
React.useCallback(async (widgetId) => {
|
|
36719
|
-
if (!widgetBackendUrl)
|
|
36720
|
-
return;
|
|
36721
|
-
try {
|
|
36722
|
-
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
36723
|
-
method: 'POST',
|
|
36724
|
-
headers: {
|
|
36725
|
-
'Content-Type': 'application/json',
|
|
36726
|
-
},
|
|
36727
|
-
body: JSON.stringify({
|
|
36728
|
-
session_id: widgetId,
|
|
36729
|
-
delete_state: true
|
|
36730
|
-
}),
|
|
36731
|
-
});
|
|
36732
|
-
setChartState(createInitialChartState(agentType || '', widgetIds, datasetId));
|
|
36733
|
-
setApiCallCount(0);
|
|
36734
|
-
setHasTimeoutError(false);
|
|
36735
|
-
}
|
|
36736
|
-
catch (error) {
|
|
36737
|
-
console.error('Failed to clear chat and state:', error);
|
|
36738
|
-
}
|
|
36739
|
-
}, [widgetBackendUrl, setChartState, agentType, widgetIds]);
|
|
36740
36461
|
// Clean up timeout and polling on unmount
|
|
36741
36462
|
React.useEffect(() => {
|
|
36742
36463
|
return () => {
|
|
@@ -36815,15 +36536,13 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36815
36536
|
}, [widget.id, appendMessage, agentType, setChartState]);
|
|
36816
36537
|
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
36538
|
// Check if data is empty based on agent type
|
|
36818
|
-
(agentType === "Bar Chart Agent" && (!((_j = (_h = (_g = chartState.
|
|
36819
|
-
(agentType === "Series
|
|
36820
|
-
(agentType === "
|
|
36821
|
-
(agentType === "
|
|
36822
|
-
(agentType === "
|
|
36823
|
-
|
|
36824
|
-
|
|
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?"
|
|
36539
|
+
(agentType === "Series Bar Chart Agent" && (!((_j = (_h = (_g = chartState.series_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.series_bar_chart_data) === null || _k === void 0 ? void 0 : _k.data) === null || _l === void 0 ? void 0 : _l.series) === null || _m === void 0 ? void 0 : _m.length))) ||
|
|
36540
|
+
(agentType === "Series Line 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))) ||
|
|
36541
|
+
(agentType === "Pie Chart Agent" && (!((_w = (_v = (_u = chartState.pie_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.pie_chart_data) === null || _x === void 0 ? void 0 : _x.data) === null || _y === void 0 ? void 0 : _y.values) === null || _z === void 0 ? void 0 : _z.length))) ||
|
|
36542
|
+
(agentType === "Data Grid Agent" && (!((_2 = (_1 = (_0 = chartState.matrix_grid_data) === null || _0 === void 0 ? void 0 : _0.data) === null || _1 === void 0 ? void 0 : _1.headers) === null || _2 === void 0 ? void 0 : _2.length) || !((_5 = (_4 = (_3 = chartState.matrix_grid_data) === null || _3 === void 0 ? void 0 : _3.data) === null || _4 === void 0 ? void 0 : _4.rows) === null || _5 === void 0 ? void 0 : _5.length))) ||
|
|
36543
|
+
(agentType === "Summary Agent" && (!((_7 = (_6 = chartState.summary_data) === null || _6 === void 0 ? void 0 : _6.data) === null || _7 === void 0 ? void 0 : _7.content) || ((_10 = (_9 = (_8 = chartState.summary_data) === null || _8 === void 0 ? void 0 : _8.data) === null || _9 === void 0 ? void 0 : _9.content) === null || _10 === void 0 ? void 0 : _10.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 === "Series Bar Chart Agent" ? (jsxRuntimeExports.jsx(SeriesBarChartComponent, { seriesBarChartState: chartState, styles: styles, orientation: orientation, appendMessage: appendMessage, query: (_11 = widget.config) === null || _11 === void 0 ? void 0 : _11.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: (_12 = widget.config) === null || _12 === void 0 ? void 0 : _12.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: (_13 = widget.config) === null || _13 === void 0 ? void 0 : _13.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: (_14 = widget.config) === null || _14 === void 0 ? void 0 : _14.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: (_15 = widget.config) === null || _15 === void 0 ? void 0 : _15.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: {
|
|
36544
|
+
title: ((_16 = widget.config) === null || _16 === void 0 ? void 0 : _16.copilotTitle) || widget.title,
|
|
36545
|
+
initial: ((_17 = widget.config) === null || _17 === void 0 ? void 0 : _17.copilotInitialMessage) || ((_18 = widget.config) === null || _18 === void 0 ? void 0 : _18.placeholder) || "How can I help you today?"
|
|
36827
36546
|
}, onSubmitMessage: () => {
|
|
36828
36547
|
setChartState(prevState => (Object.assign(Object.assign({}, prevState), { widget_ids: widgetIds, dataset_id: datasetId })));
|
|
36829
36548
|
startPollingForData();
|