dp-widgets-framework 1.2.8 → 1.3.0
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 +108 -43
- package/dist/index.js +108 -43
- package/package.json +2 -1
package/dist/index.esm.js
CHANGED
|
@@ -16,6 +16,7 @@ import { WidthProvider, Responsive } from 'react-grid-layout';
|
|
|
16
16
|
import { v4 } from 'uuid';
|
|
17
17
|
import { CopilotKit, useCopilotContext, useCoAgent, useCopilotChat } from '@copilotkit/react-core';
|
|
18
18
|
import { CopilotChat } from '@copilotkit/react-ui';
|
|
19
|
+
import ChartDataLabels from 'chartjs-plugin-datalabels';
|
|
19
20
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
20
21
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
21
22
|
|
|
@@ -15038,7 +15039,8 @@ const Bar = /* #__PURE__ */ createTypedChart('bar', BarController);
|
|
|
15038
15039
|
const Pie = /* #__PURE__ */ createTypedChart('pie', PieController);
|
|
15039
15040
|
|
|
15040
15041
|
Chart$1.register(CategoryScale, LinearScale, BarElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15041
|
-
function BarChart({ orientation, title, data, options, className, units }) {
|
|
15042
|
+
function BarChart({ orientation, title, data, options, className, units, content }) {
|
|
15043
|
+
var _a;
|
|
15042
15044
|
const formatValue = (value) => {
|
|
15043
15045
|
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
15044
15046
|
if (units === '$' && !isNaN(numValue)) {
|
|
@@ -15067,6 +15069,12 @@ function BarChart({ orientation, title, data, options, className, units }) {
|
|
|
15067
15069
|
},
|
|
15068
15070
|
position: "bottom"
|
|
15069
15071
|
},
|
|
15072
|
+
datalabels: {
|
|
15073
|
+
display: (_a = content === null || content === void 0 ? void 0 : content.showLabels) !== null && _a !== void 0 ? _a : false,
|
|
15074
|
+
color: "white",
|
|
15075
|
+
font: { size: 12 },
|
|
15076
|
+
formatter: (value) => value,
|
|
15077
|
+
},
|
|
15070
15078
|
title: {
|
|
15071
15079
|
display: true,
|
|
15072
15080
|
text: title,
|
|
@@ -15106,11 +15114,12 @@ function BarChart({ orientation, title, data, options, className, units }) {
|
|
|
15106
15114
|
},
|
|
15107
15115
|
},
|
|
15108
15116
|
};
|
|
15109
|
-
return (jsxRuntimeExports.jsx(Bar, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions }));
|
|
15117
|
+
return (jsxRuntimeExports.jsx(Bar, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [ChartDataLabels] }));
|
|
15110
15118
|
}
|
|
15111
15119
|
|
|
15112
15120
|
Chart$1.register(CategoryScale, LinearScale, BarElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15113
|
-
function SeriesChart({ orientation, title, data, options, className, units }) {
|
|
15121
|
+
function SeriesChart({ orientation, title, data, options, className, units, content }) {
|
|
15122
|
+
var _a;
|
|
15114
15123
|
const formatValue = (value) => {
|
|
15115
15124
|
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
15116
15125
|
if (units === '$' && !isNaN(numValue)) {
|
|
@@ -15139,6 +15148,12 @@ function SeriesChart({ orientation, title, data, options, className, units }) {
|
|
|
15139
15148
|
},
|
|
15140
15149
|
position: "bottom"
|
|
15141
15150
|
},
|
|
15151
|
+
datalabels: {
|
|
15152
|
+
display: (_a = content === null || content === void 0 ? void 0 : content.showLabels) !== null && _a !== void 0 ? _a : false,
|
|
15153
|
+
color: "white",
|
|
15154
|
+
font: { size: 12 },
|
|
15155
|
+
formatter: (value) => value,
|
|
15156
|
+
},
|
|
15142
15157
|
title: {
|
|
15143
15158
|
display: true,
|
|
15144
15159
|
text: title,
|
|
@@ -15174,11 +15189,12 @@ function SeriesChart({ orientation, title, data, options, className, units }) {
|
|
|
15174
15189
|
},
|
|
15175
15190
|
},
|
|
15176
15191
|
};
|
|
15177
|
-
return (jsxRuntimeExports.jsx(Bar, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions }));
|
|
15192
|
+
return (jsxRuntimeExports.jsx(Bar, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [ChartDataLabels] }));
|
|
15178
15193
|
}
|
|
15179
15194
|
|
|
15180
15195
|
Chart$1.register(CategoryScale, LinearScale, PointElement, LineElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15181
|
-
function SeriesLineChart({ orientation, title, data, options, className, units }) {
|
|
15196
|
+
function SeriesLineChart({ orientation, title, data, options, className, units, content }) {
|
|
15197
|
+
var _a;
|
|
15182
15198
|
const formatValue = (value) => {
|
|
15183
15199
|
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
15184
15200
|
if (units === '$' && !isNaN(numValue)) {
|
|
@@ -15206,6 +15222,19 @@ function SeriesLineChart({ orientation, title, data, options, className, units }
|
|
|
15206
15222
|
},
|
|
15207
15223
|
position: "bottom"
|
|
15208
15224
|
},
|
|
15225
|
+
datalabels: {
|
|
15226
|
+
display: (_a = content === null || content === void 0 ? void 0 : content.showLabels) !== null && _a !== void 0 ? _a : false,
|
|
15227
|
+
color: "#0F172A",
|
|
15228
|
+
font: { size: 12 },
|
|
15229
|
+
offset: 6,
|
|
15230
|
+
anchor: "end",
|
|
15231
|
+
backgroundColor: "#f1f1f1",
|
|
15232
|
+
borderRadius: 3,
|
|
15233
|
+
align: (context) => {
|
|
15234
|
+
return context.dataIndex % 2 === 0 ? "top" : "bottom";
|
|
15235
|
+
},
|
|
15236
|
+
formatter: (value) => value,
|
|
15237
|
+
},
|
|
15209
15238
|
title: {
|
|
15210
15239
|
display: true,
|
|
15211
15240
|
text: title,
|
|
@@ -15246,12 +15275,13 @@ function SeriesLineChart({ orientation, title, data, options, className, units }
|
|
|
15246
15275
|
},
|
|
15247
15276
|
},
|
|
15248
15277
|
};
|
|
15249
|
-
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions }));
|
|
15278
|
+
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [ChartDataLabels] }));
|
|
15250
15279
|
}
|
|
15251
15280
|
|
|
15252
15281
|
Chart$1.register(ArcElement, plugin_tooltip, plugin_legend);
|
|
15253
15282
|
const PieChart = (props) => {
|
|
15254
|
-
|
|
15283
|
+
var _a;
|
|
15284
|
+
const { data, title, options, units, content } = props;
|
|
15255
15285
|
const formatValue = (value) => {
|
|
15256
15286
|
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
15257
15287
|
if (units === '$' && !isNaN(numValue)) {
|
|
@@ -15270,6 +15300,12 @@ const PieChart = (props) => {
|
|
|
15270
15300
|
},
|
|
15271
15301
|
position: "bottom",
|
|
15272
15302
|
},
|
|
15303
|
+
datalabels: {
|
|
15304
|
+
display: (_a = content === null || content === void 0 ? void 0 : content.showLabels) !== null && _a !== void 0 ? _a : false,
|
|
15305
|
+
color: "white",
|
|
15306
|
+
font: { size: 12 },
|
|
15307
|
+
formatter: (value) => value,
|
|
15308
|
+
},
|
|
15273
15309
|
title: {
|
|
15274
15310
|
display: true,
|
|
15275
15311
|
text: title,
|
|
@@ -15297,11 +15333,12 @@ const PieChart = (props) => {
|
|
|
15297
15333
|
},
|
|
15298
15334
|
},
|
|
15299
15335
|
};
|
|
15300
|
-
return jsxRuntimeExports.jsx(Pie, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions });
|
|
15336
|
+
return jsxRuntimeExports.jsx(Pie, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [ChartDataLabels] });
|
|
15301
15337
|
};
|
|
15302
15338
|
|
|
15303
15339
|
Chart$1.register(CategoryScale, LinearScale, PointElement, LineElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15304
|
-
function LineChart({ title, data, options, className, units }) {
|
|
15340
|
+
function LineChart({ title, data, options, className, units, content }) {
|
|
15341
|
+
var _a;
|
|
15305
15342
|
const formatValue = (value) => {
|
|
15306
15343
|
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
15307
15344
|
if (units === '$' && !isNaN(numValue)) {
|
|
@@ -15329,6 +15366,19 @@ function LineChart({ title, data, options, className, units }) {
|
|
|
15329
15366
|
},
|
|
15330
15367
|
position: "bottom"
|
|
15331
15368
|
},
|
|
15369
|
+
datalabels: {
|
|
15370
|
+
display: (_a = content === null || content === void 0 ? void 0 : content.showLabels) !== null && _a !== void 0 ? _a : false,
|
|
15371
|
+
color: "#0F172A",
|
|
15372
|
+
font: { size: 12 },
|
|
15373
|
+
offset: 6,
|
|
15374
|
+
anchor: "end",
|
|
15375
|
+
backgroundColor: "#f1f1f1",
|
|
15376
|
+
borderRadius: 3,
|
|
15377
|
+
align: (context) => {
|
|
15378
|
+
return context.dataIndex % 2 === 0 ? "top" : "bottom";
|
|
15379
|
+
},
|
|
15380
|
+
formatter: (value) => value,
|
|
15381
|
+
},
|
|
15332
15382
|
title: {
|
|
15333
15383
|
display: true,
|
|
15334
15384
|
text: title,
|
|
@@ -15361,7 +15411,7 @@ function LineChart({ title, data, options, className, units }) {
|
|
|
15361
15411
|
},
|
|
15362
15412
|
},
|
|
15363
15413
|
};
|
|
15364
|
-
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions }));
|
|
15414
|
+
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [ChartDataLabels] }));
|
|
15365
15415
|
}
|
|
15366
15416
|
|
|
15367
15417
|
function DataGrid({ title, data, className }) {
|
|
@@ -36269,7 +36319,7 @@ const getStyleValues$1 = (styles = {}) => {
|
|
|
36269
36319
|
textAlign: alignment,
|
|
36270
36320
|
};
|
|
36271
36321
|
};
|
|
36272
|
-
function BarChartComponent({ orientation, barChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36322
|
+
function BarChartComponent({ orientation, barChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout, content }) {
|
|
36273
36323
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
36274
36324
|
const hasCalledRef = useRef(false);
|
|
36275
36325
|
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) || [];
|
|
@@ -36319,9 +36369,9 @@ function BarChartComponent({ orientation, barChartState, styles, appendMessage,
|
|
|
36319
36369
|
},
|
|
36320
36370
|
],
|
|
36321
36371
|
};
|
|
36322
|
-
return (jsxRuntimeExports.jsx(BarChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units }));
|
|
36372
|
+
return (jsxRuntimeExports.jsx(BarChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units, content: content }));
|
|
36323
36373
|
}
|
|
36324
|
-
function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36374
|
+
function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout, content }) {
|
|
36325
36375
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
36326
36376
|
const hasCalledRef = useRef(false);
|
|
36327
36377
|
const labels = ((_b = (_a = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.series_bar_chart_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.labels) || ((_e = (_d = (_c = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.state) === null || _c === void 0 ? void 0 : _c.series_bar_chart_data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.labels) || [];
|
|
@@ -36367,12 +36417,12 @@ function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, app
|
|
|
36367
36417
|
datasets: series.map((seriesItem, index) => ({
|
|
36368
36418
|
label: seriesItem.name,
|
|
36369
36419
|
data: seriesItem.values,
|
|
36370
|
-
backgroundColor: seriesItem.color || finalColors[index % finalColors.length],
|
|
36420
|
+
backgroundColor: (seriesItem === null || seriesItem === void 0 ? void 0 : seriesItem.colors) || (seriesItem === null || seriesItem === void 0 ? void 0 : seriesItem.color) || finalColors[index % finalColors.length],
|
|
36371
36421
|
})),
|
|
36372
36422
|
};
|
|
36373
|
-
return (jsxRuntimeExports.jsx(SeriesChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units }));
|
|
36423
|
+
return (jsxRuntimeExports.jsx(SeriesChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units, content: content }));
|
|
36374
36424
|
}
|
|
36375
|
-
function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36425
|
+
function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, appendMessage, content, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36376
36426
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
36377
36427
|
const hasCalledRef = useRef(false);
|
|
36378
36428
|
const labels = ((_b = (_a = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.series_bar_chart_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.labels) || ((_e = (_d = (_c = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.state) === null || _c === void 0 ? void 0 : _c.series_bar_chart_data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.labels) || [];
|
|
@@ -36428,9 +36478,9 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
|
|
|
36428
36478
|
tension: 0.1,
|
|
36429
36479
|
})),
|
|
36430
36480
|
};
|
|
36431
|
-
return (jsxRuntimeExports.jsx(SeriesLineChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units }));
|
|
36481
|
+
return (jsxRuntimeExports.jsx(SeriesLineChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units, content: content }));
|
|
36432
36482
|
}
|
|
36433
|
-
function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36483
|
+
function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout, content }) {
|
|
36434
36484
|
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;
|
|
36435
36485
|
const hasCalledRef = useRef(false);
|
|
36436
36486
|
const labels = ((_b = (_a = pieChartState === null || pieChartState === void 0 ? void 0 : pieChartState.pie_chart_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.labels) || ((_e = (_d = (_c = pieChartState === null || pieChartState === void 0 ? void 0 : pieChartState.state) === null || _c === void 0 ? void 0 : _c.pie_chart_data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.labels) || [];
|
|
@@ -36484,9 +36534,9 @@ function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirs
|
|
|
36484
36534
|
},
|
|
36485
36535
|
],
|
|
36486
36536
|
};
|
|
36487
|
-
return (jsxRuntimeExports.jsx(PieChart, { title: chartTitle, data: transformedData, units: units }));
|
|
36537
|
+
return (jsxRuntimeExports.jsx(PieChart, { title: chartTitle, data: transformedData, units: units, content: content }));
|
|
36488
36538
|
}
|
|
36489
|
-
function LineChartComponent({ lineChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36539
|
+
function LineChartComponent({ lineChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout, content }) {
|
|
36490
36540
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
36491
36541
|
const hasCalledRef = useRef(false);
|
|
36492
36542
|
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) || [];
|
|
@@ -36541,7 +36591,7 @@ function LineChartComponent({ lineChartState, styles, appendMessage, query, isFi
|
|
|
36541
36591
|
},
|
|
36542
36592
|
],
|
|
36543
36593
|
};
|
|
36544
|
-
return (jsxRuntimeExports.jsx(LineChart, { title: chartTitle, data: transformedData, units: units }));
|
|
36594
|
+
return (jsxRuntimeExports.jsx(LineChart, { title: chartTitle, data: transformedData, units: units, content: content }));
|
|
36545
36595
|
}
|
|
36546
36596
|
function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36547
36597
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
@@ -36632,10 +36682,11 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
36632
36682
|
return (jsxRuntimeExports.jsx(SummaryWidget, { title: title, data: data, metadata: metadata, className: "" }));
|
|
36633
36683
|
}
|
|
36634
36684
|
function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds, widgetBackendUrl, datasetId }) {
|
|
36635
|
-
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;
|
|
36685
|
+
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;
|
|
36636
36686
|
const agentType = (_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentType;
|
|
36637
36687
|
const orientation = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.orientation;
|
|
36638
36688
|
const isFirstLoad = (_c = widget.config) === null || _c === void 0 ? void 0 : _c.isFirstLoad;
|
|
36689
|
+
const content = (_d = widget.config) === null || _d === void 0 ? void 0 : _d.content;
|
|
36639
36690
|
const { threadId, setThreadId } = useCopilotContext();
|
|
36640
36691
|
const timeoutRef = useRef(null);
|
|
36641
36692
|
const [isTimeoutTriggered, setIsTimeoutTriggered] = useState(false);
|
|
@@ -36645,7 +36696,7 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36645
36696
|
setThreadId(widget.id);
|
|
36646
36697
|
}, [widget.id, setThreadId]);
|
|
36647
36698
|
const { state: chartState, setState: setChartState } = useCoAgent({
|
|
36648
|
-
name: (
|
|
36699
|
+
name: (_e = widget.config) === null || _e === void 0 ? void 0 : _e.agentName,
|
|
36649
36700
|
initialState: createInitialChartState(agentType || '', widgetIds, datasetId),
|
|
36650
36701
|
});
|
|
36651
36702
|
// Function to handle timeout and call loadAgentState API
|
|
@@ -36669,7 +36720,7 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36669
36720
|
if (apiResponse && !(chartState === null || chartState === void 0 ? void 0 : chartState.agent_message)) {
|
|
36670
36721
|
parseAndUpdateChartState(apiResponse, setChartState);
|
|
36671
36722
|
}
|
|
36672
|
-
}, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (
|
|
36723
|
+
}, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (_f = widget.config) === null || _f === void 0 ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
36673
36724
|
// Function to start timeout
|
|
36674
36725
|
const startLoadingTimeout = useCallback(() => {
|
|
36675
36726
|
if (timeoutRef.current) {
|
|
@@ -36783,15 +36834,15 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36783
36834
|
}, [widget.id, appendMessage, agentType, setChartState]);
|
|
36784
36835
|
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" && (
|
|
36785
36836
|
// Check if data is empty based on agent type
|
|
36786
|
-
(agentType === "Bar Chart Agent" && (!((
|
|
36787
|
-
(agentType === "Series Bar Chart Agent" && (!((
|
|
36788
|
-
(agentType === "Series Line Chart Agent" && (!((
|
|
36789
|
-
(agentType === "Pie Chart Agent" && (!((
|
|
36790
|
-
(agentType === "Line Chart Agent" && (!((
|
|
36791
|
-
(agentType === "Data Grid Agent" && (!((
|
|
36792
|
-
(agentType === "Summary Agent" && (!((
|
|
36793
|
-
title: ((
|
|
36794
|
-
initial: ((
|
|
36837
|
+
(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))) ||
|
|
36838
|
+
(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))) ||
|
|
36839
|
+
(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))) ||
|
|
36840
|
+
(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))) ||
|
|
36841
|
+
(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))) ||
|
|
36842
|
+
(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))) ||
|
|
36843
|
+
(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 }) }) })) : agentType === "Bar Chart Agent" ? (jsxRuntimeExports.jsx(BarChartComponent, { barChartState: chartState, styles: styles, orientation: orientation, content: content, 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, content: content, 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, content: content, 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, content: content, 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, content: content, 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: {
|
|
36844
|
+
title: ((_30 = widget.config) === null || _30 === void 0 ? void 0 : _30.copilotTitle) || widget.title,
|
|
36845
|
+
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?"
|
|
36795
36846
|
}, onSubmitMessage: () => {
|
|
36796
36847
|
setChartState(prevState => (Object.assign(Object.assign({}, prevState), { widget_ids: widgetIds, dataset_id: datasetId })));
|
|
36797
36848
|
} })) })] }));
|
|
@@ -36922,11 +36973,14 @@ function Modal({ isOpen, onClose, title, children, size = 'md', initialFocusRef,
|
|
|
36922
36973
|
}
|
|
36923
36974
|
|
|
36924
36975
|
function EditWidgetDialog({ editingWidget, setWidgets, initialText, isOpen, onClose, onSubmit }) {
|
|
36976
|
+
var _a;
|
|
36977
|
+
const agentType = (_a = editingWidget === null || editingWidget === void 0 ? void 0 : editingWidget.config) === null || _a === void 0 ? void 0 : _a.agentType;
|
|
36925
36978
|
const [query, setQuery] = useState("");
|
|
36926
36979
|
const [displayText, setDisplayText] = useState("");
|
|
36927
36980
|
const [blockType, setBlockType] = useState("");
|
|
36928
36981
|
const [alignment, setAlignment] = useState("");
|
|
36929
36982
|
const [divider, setDivider] = useState("no");
|
|
36983
|
+
const [showLabels, setShowLabels] = useState(false);
|
|
36930
36984
|
const [styles, setStyles] = useState("");
|
|
36931
36985
|
useEffect(() => {
|
|
36932
36986
|
setQuery(initialText);
|
|
@@ -36951,10 +37005,14 @@ function EditWidgetDialog({ editingWidget, setWidgets, initialText, isOpen, onCl
|
|
|
36951
37005
|
if (hasDivider === null || hasDivider === void 0 ? void 0 : hasDivider.length) {
|
|
36952
37006
|
setDivider(hasDivider);
|
|
36953
37007
|
}
|
|
37008
|
+
const hasShowLabel = content === null || content === void 0 ? void 0 : content.showLabels;
|
|
37009
|
+
if (hasShowLabel !== undefined) {
|
|
37010
|
+
setShowLabels(hasShowLabel);
|
|
37011
|
+
}
|
|
36954
37012
|
}, [editingWidget]);
|
|
36955
37013
|
const handleSubmit = () => {
|
|
36956
37014
|
if (onSubmit && query.trim()) {
|
|
36957
|
-
onSubmit(query);
|
|
37015
|
+
onSubmit(query, showLabels);
|
|
36958
37016
|
}
|
|
36959
37017
|
if (editingWidget.type === 'text') {
|
|
36960
37018
|
const widgetId = editingWidget === null || editingWidget === void 0 ? void 0 : editingWidget.id;
|
|
@@ -36976,10 +37034,10 @@ function EditWidgetDialog({ editingWidget, setWidgets, initialText, isOpen, onCl
|
|
|
36976
37034
|
return null;
|
|
36977
37035
|
return (jsxRuntimeExports.jsx(Modal, { isOpen: isOpen, onClose: onClose, title: "Edit Widget", size: "lg",
|
|
36978
37036
|
// initialFocusRef={inputRef}
|
|
36979
|
-
noOverflowHidden: true, children: jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("p", { className: "text-gray-700", children: "Customize the widget\u2019s appearance" }), jsxRuntimeExports.
|
|
36980
|
-
|
|
36981
|
-
|
|
36982
|
-
|
|
37037
|
+
noOverflowHidden: true, children: jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("p", { className: "text-gray-700", children: "Customize the widget\u2019s appearance" }), jsxRuntimeExports.jsxs("div", { className: "pt-7", children: [(agentType === "Pie Chart Agent" || agentType === "Line Chart Agent" || agentType === "Series Line Chart Agent" || agentType === "Bar Chart Agent" || agentType === "Series Bar Chart Agent") && (jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2 mb-4", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Data Labels:" }), jsxRuntimeExports.jsxs(Select, { value: showLabels ? "yes" : "no", onValueChange: (value) => setShowLabels(value === "yes"), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Visible data labels?" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "no", children: "No" }), jsxRuntimeExports.jsx(SelectItem, { value: "yes", children: "Yes" })] })] })] })), (editingWidget === null || editingWidget === void 0 ? void 0 : editingWidget.type) === "text" ?
|
|
37038
|
+
jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-5", children: [jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Display text:" }), jsxRuntimeExports.jsx(Input, { value: displayText, onChange: (e) => setDisplayText(e.target.value), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Block type:" }), jsxRuntimeExports.jsxs(Select, { value: blockType, onValueChange: (value) => setBlockType(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select block type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "heading-1", children: "Heading 1" }), jsxRuntimeExports.jsx(SelectItem, { value: "heading-2", children: "Heading 2" }), jsxRuntimeExports.jsx(SelectItem, { value: "heading-3", children: "Heading 3" }), jsxRuntimeExports.jsx(SelectItem, { value: "paragraph", children: "Paragraph" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Align:" }), jsxRuntimeExports.jsxs(Select, { value: alignment, onValueChange: (value) => setAlignment(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select block type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "left", children: "Left" }), jsxRuntimeExports.jsx(SelectItem, { value: "center", children: "Center" }), jsxRuntimeExports.jsx(SelectItem, { value: "right", children: "Right" }), jsxRuntimeExports.jsx(SelectItem, { value: "justify", children: "Justify" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Divider:" }), jsxRuntimeExports.jsxs(Select, { value: divider, onValueChange: (value) => setDivider(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "No" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "yes", children: "Yes" }), jsxRuntimeExports.jsx(SelectItem, { value: "no", children: "No" })] })] })] }), jsxRuntimeExports.jsx("div", { className: "flex justify-end", children: jsxRuntimeExports.jsx("button", { onClick: handleSubmit, className: "font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none bg-primary-600 text-white hover:bg-primary-700 focus:ring-primary-500 px-6 py-2 text-sm flex items-center gap-2", children: "Submit" }) })] })
|
|
37039
|
+
:
|
|
37040
|
+
jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Query:" }), jsxRuntimeExports.jsx(Textarea, { className: "w-full p-2", value: query, onChange: (e) => { var _a; return setQuery((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.value); } })] }), jsxRuntimeExports.jsx("div", { className: "flex justify-end pt-3", children: jsxRuntimeExports.jsx("button", { onClick: handleSubmit, className: "font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none bg-primary-600 text-white hover:bg-primary-700 focus:ring-primary-500 px-6 py-2 text-sm flex items-center gap-2", children: "Submit" }) })] })] })] }) }));
|
|
36983
37041
|
}
|
|
36984
37042
|
|
|
36985
37043
|
function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk-construction-project-agent" }) {
|
|
@@ -36991,6 +37049,7 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
36991
37049
|
const [blockType, setBlockType] = useState("paragraph");
|
|
36992
37050
|
const [alignment, setAlignment] = useState("left");
|
|
36993
37051
|
const [divider, setDivider] = useState("no");
|
|
37052
|
+
const [showLabels, setShowLabels] = useState(false);
|
|
36994
37053
|
const widgetOptions = [
|
|
36995
37054
|
// {
|
|
36996
37055
|
// type: 'bar-chart',
|
|
@@ -37111,14 +37170,20 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
37111
37170
|
config = {
|
|
37112
37171
|
query: query,
|
|
37113
37172
|
agentName: defaultAgentName,
|
|
37114
|
-
agentType: "Series Line Chart Agent"
|
|
37173
|
+
agentType: "Series Line Chart Agent",
|
|
37174
|
+
content: {
|
|
37175
|
+
showLabels
|
|
37176
|
+
},
|
|
37115
37177
|
};
|
|
37116
37178
|
}
|
|
37117
37179
|
else if (selectedWidgetType === 'line-chart') {
|
|
37118
37180
|
config = {
|
|
37119
37181
|
query: query,
|
|
37120
37182
|
agentName: defaultAgentName,
|
|
37121
|
-
agentType: "Line Chart Agent"
|
|
37183
|
+
agentType: "Line Chart Agent",
|
|
37184
|
+
content: {
|
|
37185
|
+
showLabels
|
|
37186
|
+
},
|
|
37122
37187
|
};
|
|
37123
37188
|
}
|
|
37124
37189
|
else if (selectedWidgetType === 'pie-chart') {
|
|
@@ -37181,7 +37246,7 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
37181
37246
|
noOverflowHidden: true, children: jsxRuntimeExports.jsx("div", { children: jsxRuntimeExports.jsx("div", { className: "pt-4", children: !showConfigStep ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: "mb-4", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: "Choose a widget to add to your dashboard:" }) }), jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 gap-3 max-h-[400px] overflow-y-auto", children: widgetOptions.map((widget) => {
|
|
37182
37247
|
const IconComponent = widget.icon;
|
|
37183
37248
|
return (jsxRuntimeExports.jsxs("button", { onClick: () => handleWidgetSelect(widget.type), className: "flex items-start gap-3 p-4 border border-slate-200 rounded-lg hover:bg-gray-50 transition-colors text-left", children: [jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 p-2 bg-primary-100 rounded-md", children: jsxRuntimeExports.jsx(IconComponent, { className: "w-5 h-5 text-primary-600" }) }), jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [jsxRuntimeExports.jsx("h3", { className: "font-medium text-sm", children: widget.title }), jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 !mt-1", children: widget.description })] })] }, widget.type));
|
|
37184
|
-
}) })] })) : (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: "mb-2", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: selectedWidgetType === 'chatbot'
|
|
37249
|
+
}) })] })) : (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [(selectedWidgetType === 'bar-chart' || selectedWidgetType === 'series-bar-chart' || selectedWidgetType === 'series-line-chart' || selectedWidgetType === 'line-chart' || selectedWidgetType === 'pie-chart') && (jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2 mb-4 mt-2", children: [jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: "Data Labels:" }), jsxRuntimeExports.jsxs(Select, { value: showLabels ? "yes" : "no", onValueChange: (value) => setShowLabels(value === "yes"), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Visible data labels?" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "no", children: "No" }), jsxRuntimeExports.jsx(SelectItem, { value: "yes", children: "Yes" })] })] })] })), jsxRuntimeExports.jsx("div", { className: "mb-2", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: selectedWidgetType === 'chatbot'
|
|
37185
37250
|
? 'Chatbot widget will be configured with the default agent.'
|
|
37186
37251
|
: selectedWidgetType === 'text' ? "Customize the widget's appearance" : 'Enter a query for your chart widget:' }) }), (selectedWidgetType === 'bar-chart' || selectedWidgetType === 'series-bar-chart' || selectedWidgetType === 'series-line-chart' || selectedWidgetType === 'line-chart' || selectedWidgetType === 'pie-chart' || selectedWidgetType === 'data-grid' || selectedWidgetType === 'summary') && (jsxRuntimeExports.jsx("div", { className: "mb-6", children: jsxRuntimeExports.jsx(Textarea, { value: query, onChange: (e) => setQuery(e.target.value), placeholder: "e.g., List out the product types by its count and render it on bar chart", className: "w-full h-24 resize-none" }) })), selectedWidgetType === 'text' && (jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-5 pb-5 pt-2", children: [jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Display text:" }), jsxRuntimeExports.jsx(Input, { value: displayText, onChange: (e) => setDisplayText(e.target.value), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Block type:" }), jsxRuntimeExports.jsxs(Select, { value: blockType, onValueChange: (value) => setBlockType(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select block type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "heading-1", children: "Heading 1" }), jsxRuntimeExports.jsx(SelectItem, { value: "heading-2", children: "Heading 2" }), jsxRuntimeExports.jsx(SelectItem, { value: "heading-3", children: "Heading 3" }), jsxRuntimeExports.jsx(SelectItem, { value: "paragraph", children: "Paragraph" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Align:" }), jsxRuntimeExports.jsxs(Select, { value: alignment, onValueChange: (value) => setAlignment(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select block type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "left", children: "Left" }), jsxRuntimeExports.jsx(SelectItem, { value: "center", children: "Center" }), jsxRuntimeExports.jsx(SelectItem, { value: "right", children: "Right" }), jsxRuntimeExports.jsx(SelectItem, { value: "justify", children: "Justify" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Divider:" }), jsxRuntimeExports.jsxs(Select, { value: divider, onValueChange: (value) => setDivider(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "No" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "yes", children: "Yes" }), jsxRuntimeExports.jsx(SelectItem, { value: "no", children: "No" })] })] })] })] })), jsxRuntimeExports.jsxs("div", { className: "flex gap-3 justify-end", children: [jsxRuntimeExports.jsx(Button, { variant: "outline", onClick: () => setShowConfigStep(false), children: "Back" }), jsxRuntimeExports.jsx(Button, { onClick: handleConfigSubmit, disabled: (selectedWidgetType === 'bar-chart' || selectedWidgetType === 'series-bar-chart' || selectedWidgetType === 'series-line-chart' || selectedWidgetType === 'line-chart' || selectedWidgetType === 'pie-chart' || selectedWidgetType === 'data-grid' || selectedWidgetType === 'summary') && !query.trim(), children: "Add Widget" })] })] })) }) }) }));
|
|
37187
37252
|
}
|
|
@@ -37257,13 +37322,13 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
37257
37322
|
setEditInitialQuery("");
|
|
37258
37323
|
}
|
|
37259
37324
|
};
|
|
37260
|
-
const handleEditSubmit = async (newQuery) => {
|
|
37325
|
+
const handleEditSubmit = async (newQuery, showLabels) => {
|
|
37261
37326
|
var _a;
|
|
37262
37327
|
if (!editingWidget)
|
|
37263
37328
|
return;
|
|
37264
37329
|
// Update the widget's config with the new query
|
|
37265
37330
|
const updatedWidgets = widgets.map(w => w.id === editingWidget.id
|
|
37266
|
-
? Object.assign(Object.assign({}, w), { config: Object.assign(Object.assign({}, w.config), { query: newQuery }) }) : w);
|
|
37331
|
+
? Object.assign(Object.assign({}, w), { config: Object.assign(Object.assign({}, w.config), { query: newQuery, content: Object.assign(Object.assign({}, w.config.content), { showLabels }) }) }) : w);
|
|
37267
37332
|
setWidgets(updatedWidgets);
|
|
37268
37333
|
// Close the modal
|
|
37269
37334
|
setShowEditModal(false);
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ var reactGridLayout = require('react-grid-layout');
|
|
|
17
17
|
var uuid = require('uuid');
|
|
18
18
|
var reactCore = require('@copilotkit/react-core');
|
|
19
19
|
var reactUi = require('@copilotkit/react-ui');
|
|
20
|
+
var ChartDataLabels = require('chartjs-plugin-datalabels');
|
|
20
21
|
var CheckboxPrimitive = require('@radix-ui/react-checkbox');
|
|
21
22
|
var DialogPrimitive = require('@radix-ui/react-dialog');
|
|
22
23
|
|
|
@@ -15065,7 +15066,8 @@ const Bar = /* #__PURE__ */ createTypedChart('bar', BarController);
|
|
|
15065
15066
|
const Pie = /* #__PURE__ */ createTypedChart('pie', PieController);
|
|
15066
15067
|
|
|
15067
15068
|
Chart$1.register(CategoryScale, LinearScale, BarElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15068
|
-
function BarChart({ orientation, title, data, options, className, units }) {
|
|
15069
|
+
function BarChart({ orientation, title, data, options, className, units, content }) {
|
|
15070
|
+
var _a;
|
|
15069
15071
|
const formatValue = (value) => {
|
|
15070
15072
|
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
15071
15073
|
if (units === '$' && !isNaN(numValue)) {
|
|
@@ -15094,6 +15096,12 @@ function BarChart({ orientation, title, data, options, className, units }) {
|
|
|
15094
15096
|
},
|
|
15095
15097
|
position: "bottom"
|
|
15096
15098
|
},
|
|
15099
|
+
datalabels: {
|
|
15100
|
+
display: (_a = content === null || content === void 0 ? void 0 : content.showLabels) !== null && _a !== void 0 ? _a : false,
|
|
15101
|
+
color: "white",
|
|
15102
|
+
font: { size: 12 },
|
|
15103
|
+
formatter: (value) => value,
|
|
15104
|
+
},
|
|
15097
15105
|
title: {
|
|
15098
15106
|
display: true,
|
|
15099
15107
|
text: title,
|
|
@@ -15133,11 +15141,12 @@ function BarChart({ orientation, title, data, options, className, units }) {
|
|
|
15133
15141
|
},
|
|
15134
15142
|
},
|
|
15135
15143
|
};
|
|
15136
|
-
return (jsxRuntimeExports.jsx(Bar, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions }));
|
|
15144
|
+
return (jsxRuntimeExports.jsx(Bar, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [ChartDataLabels] }));
|
|
15137
15145
|
}
|
|
15138
15146
|
|
|
15139
15147
|
Chart$1.register(CategoryScale, LinearScale, BarElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15140
|
-
function SeriesChart({ orientation, title, data, options, className, units }) {
|
|
15148
|
+
function SeriesChart({ orientation, title, data, options, className, units, content }) {
|
|
15149
|
+
var _a;
|
|
15141
15150
|
const formatValue = (value) => {
|
|
15142
15151
|
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
15143
15152
|
if (units === '$' && !isNaN(numValue)) {
|
|
@@ -15166,6 +15175,12 @@ function SeriesChart({ orientation, title, data, options, className, units }) {
|
|
|
15166
15175
|
},
|
|
15167
15176
|
position: "bottom"
|
|
15168
15177
|
},
|
|
15178
|
+
datalabels: {
|
|
15179
|
+
display: (_a = content === null || content === void 0 ? void 0 : content.showLabels) !== null && _a !== void 0 ? _a : false,
|
|
15180
|
+
color: "white",
|
|
15181
|
+
font: { size: 12 },
|
|
15182
|
+
formatter: (value) => value,
|
|
15183
|
+
},
|
|
15169
15184
|
title: {
|
|
15170
15185
|
display: true,
|
|
15171
15186
|
text: title,
|
|
@@ -15201,11 +15216,12 @@ function SeriesChart({ orientation, title, data, options, className, units }) {
|
|
|
15201
15216
|
},
|
|
15202
15217
|
},
|
|
15203
15218
|
};
|
|
15204
|
-
return (jsxRuntimeExports.jsx(Bar, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions }));
|
|
15219
|
+
return (jsxRuntimeExports.jsx(Bar, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [ChartDataLabels] }));
|
|
15205
15220
|
}
|
|
15206
15221
|
|
|
15207
15222
|
Chart$1.register(CategoryScale, LinearScale, PointElement, LineElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15208
|
-
function SeriesLineChart({ orientation, title, data, options, className, units }) {
|
|
15223
|
+
function SeriesLineChart({ orientation, title, data, options, className, units, content }) {
|
|
15224
|
+
var _a;
|
|
15209
15225
|
const formatValue = (value) => {
|
|
15210
15226
|
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
15211
15227
|
if (units === '$' && !isNaN(numValue)) {
|
|
@@ -15233,6 +15249,19 @@ function SeriesLineChart({ orientation, title, data, options, className, units }
|
|
|
15233
15249
|
},
|
|
15234
15250
|
position: "bottom"
|
|
15235
15251
|
},
|
|
15252
|
+
datalabels: {
|
|
15253
|
+
display: (_a = content === null || content === void 0 ? void 0 : content.showLabels) !== null && _a !== void 0 ? _a : false,
|
|
15254
|
+
color: "#0F172A",
|
|
15255
|
+
font: { size: 12 },
|
|
15256
|
+
offset: 6,
|
|
15257
|
+
anchor: "end",
|
|
15258
|
+
backgroundColor: "#f1f1f1",
|
|
15259
|
+
borderRadius: 3,
|
|
15260
|
+
align: (context) => {
|
|
15261
|
+
return context.dataIndex % 2 === 0 ? "top" : "bottom";
|
|
15262
|
+
},
|
|
15263
|
+
formatter: (value) => value,
|
|
15264
|
+
},
|
|
15236
15265
|
title: {
|
|
15237
15266
|
display: true,
|
|
15238
15267
|
text: title,
|
|
@@ -15273,12 +15302,13 @@ function SeriesLineChart({ orientation, title, data, options, className, units }
|
|
|
15273
15302
|
},
|
|
15274
15303
|
},
|
|
15275
15304
|
};
|
|
15276
|
-
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions }));
|
|
15305
|
+
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [ChartDataLabels] }));
|
|
15277
15306
|
}
|
|
15278
15307
|
|
|
15279
15308
|
Chart$1.register(ArcElement, plugin_tooltip, plugin_legend);
|
|
15280
15309
|
const PieChart = (props) => {
|
|
15281
|
-
|
|
15310
|
+
var _a;
|
|
15311
|
+
const { data, title, options, units, content } = props;
|
|
15282
15312
|
const formatValue = (value) => {
|
|
15283
15313
|
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
15284
15314
|
if (units === '$' && !isNaN(numValue)) {
|
|
@@ -15297,6 +15327,12 @@ const PieChart = (props) => {
|
|
|
15297
15327
|
},
|
|
15298
15328
|
position: "bottom",
|
|
15299
15329
|
},
|
|
15330
|
+
datalabels: {
|
|
15331
|
+
display: (_a = content === null || content === void 0 ? void 0 : content.showLabels) !== null && _a !== void 0 ? _a : false,
|
|
15332
|
+
color: "white",
|
|
15333
|
+
font: { size: 12 },
|
|
15334
|
+
formatter: (value) => value,
|
|
15335
|
+
},
|
|
15300
15336
|
title: {
|
|
15301
15337
|
display: true,
|
|
15302
15338
|
text: title,
|
|
@@ -15324,11 +15360,12 @@ const PieChart = (props) => {
|
|
|
15324
15360
|
},
|
|
15325
15361
|
},
|
|
15326
15362
|
};
|
|
15327
|
-
return jsxRuntimeExports.jsx(Pie, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions });
|
|
15363
|
+
return jsxRuntimeExports.jsx(Pie, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [ChartDataLabels] });
|
|
15328
15364
|
};
|
|
15329
15365
|
|
|
15330
15366
|
Chart$1.register(CategoryScale, LinearScale, PointElement, LineElement, plugin_title, plugin_tooltip, plugin_legend);
|
|
15331
|
-
function LineChart({ title, data, options, className, units }) {
|
|
15367
|
+
function LineChart({ title, data, options, className, units, content }) {
|
|
15368
|
+
var _a;
|
|
15332
15369
|
const formatValue = (value) => {
|
|
15333
15370
|
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
15334
15371
|
if (units === '$' && !isNaN(numValue)) {
|
|
@@ -15356,6 +15393,19 @@ function LineChart({ title, data, options, className, units }) {
|
|
|
15356
15393
|
},
|
|
15357
15394
|
position: "bottom"
|
|
15358
15395
|
},
|
|
15396
|
+
datalabels: {
|
|
15397
|
+
display: (_a = content === null || content === void 0 ? void 0 : content.showLabels) !== null && _a !== void 0 ? _a : false,
|
|
15398
|
+
color: "#0F172A",
|
|
15399
|
+
font: { size: 12 },
|
|
15400
|
+
offset: 6,
|
|
15401
|
+
anchor: "end",
|
|
15402
|
+
backgroundColor: "#f1f1f1",
|
|
15403
|
+
borderRadius: 3,
|
|
15404
|
+
align: (context) => {
|
|
15405
|
+
return context.dataIndex % 2 === 0 ? "top" : "bottom";
|
|
15406
|
+
},
|
|
15407
|
+
formatter: (value) => value,
|
|
15408
|
+
},
|
|
15359
15409
|
title: {
|
|
15360
15410
|
display: true,
|
|
15361
15411
|
text: title,
|
|
@@ -15388,7 +15438,7 @@ function LineChart({ title, data, options, className, units }) {
|
|
|
15388
15438
|
},
|
|
15389
15439
|
},
|
|
15390
15440
|
};
|
|
15391
|
-
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions }));
|
|
15441
|
+
return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [ChartDataLabels] }));
|
|
15392
15442
|
}
|
|
15393
15443
|
|
|
15394
15444
|
function DataGrid({ title, data, className }) {
|
|
@@ -36296,7 +36346,7 @@ const getStyleValues$1 = (styles = {}) => {
|
|
|
36296
36346
|
textAlign: alignment,
|
|
36297
36347
|
};
|
|
36298
36348
|
};
|
|
36299
|
-
function BarChartComponent({ orientation, barChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36349
|
+
function BarChartComponent({ orientation, barChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout, content }) {
|
|
36300
36350
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
36301
36351
|
const hasCalledRef = React.useRef(false);
|
|
36302
36352
|
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) || [];
|
|
@@ -36346,9 +36396,9 @@ function BarChartComponent({ orientation, barChartState, styles, appendMessage,
|
|
|
36346
36396
|
},
|
|
36347
36397
|
],
|
|
36348
36398
|
};
|
|
36349
|
-
return (jsxRuntimeExports.jsx(BarChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units }));
|
|
36399
|
+
return (jsxRuntimeExports.jsx(BarChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units, content: content }));
|
|
36350
36400
|
}
|
|
36351
|
-
function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36401
|
+
function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout, content }) {
|
|
36352
36402
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
36353
36403
|
const hasCalledRef = React.useRef(false);
|
|
36354
36404
|
const labels = ((_b = (_a = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.series_bar_chart_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.labels) || ((_e = (_d = (_c = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.state) === null || _c === void 0 ? void 0 : _c.series_bar_chart_data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.labels) || [];
|
|
@@ -36394,12 +36444,12 @@ function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, app
|
|
|
36394
36444
|
datasets: series.map((seriesItem, index) => ({
|
|
36395
36445
|
label: seriesItem.name,
|
|
36396
36446
|
data: seriesItem.values,
|
|
36397
|
-
backgroundColor: seriesItem.color || finalColors[index % finalColors.length],
|
|
36447
|
+
backgroundColor: (seriesItem === null || seriesItem === void 0 ? void 0 : seriesItem.colors) || (seriesItem === null || seriesItem === void 0 ? void 0 : seriesItem.color) || finalColors[index % finalColors.length],
|
|
36398
36448
|
})),
|
|
36399
36449
|
};
|
|
36400
|
-
return (jsxRuntimeExports.jsx(SeriesChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units }));
|
|
36450
|
+
return (jsxRuntimeExports.jsx(SeriesChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units, content: content }));
|
|
36401
36451
|
}
|
|
36402
|
-
function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36452
|
+
function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, appendMessage, content, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36403
36453
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
36404
36454
|
const hasCalledRef = React.useRef(false);
|
|
36405
36455
|
const labels = ((_b = (_a = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.series_bar_chart_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.labels) || ((_e = (_d = (_c = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.state) === null || _c === void 0 ? void 0 : _c.series_bar_chart_data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.labels) || [];
|
|
@@ -36455,9 +36505,9 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
|
|
|
36455
36505
|
tension: 0.1,
|
|
36456
36506
|
})),
|
|
36457
36507
|
};
|
|
36458
|
-
return (jsxRuntimeExports.jsx(SeriesLineChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units }));
|
|
36508
|
+
return (jsxRuntimeExports.jsx(SeriesLineChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units, content: content }));
|
|
36459
36509
|
}
|
|
36460
|
-
function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36510
|
+
function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout, content }) {
|
|
36461
36511
|
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;
|
|
36462
36512
|
const hasCalledRef = React.useRef(false);
|
|
36463
36513
|
const labels = ((_b = (_a = pieChartState === null || pieChartState === void 0 ? void 0 : pieChartState.pie_chart_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.labels) || ((_e = (_d = (_c = pieChartState === null || pieChartState === void 0 ? void 0 : pieChartState.state) === null || _c === void 0 ? void 0 : _c.pie_chart_data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.labels) || [];
|
|
@@ -36511,9 +36561,9 @@ function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirs
|
|
|
36511
36561
|
},
|
|
36512
36562
|
],
|
|
36513
36563
|
};
|
|
36514
|
-
return (jsxRuntimeExports.jsx(PieChart, { title: chartTitle, data: transformedData, units: units }));
|
|
36564
|
+
return (jsxRuntimeExports.jsx(PieChart, { title: chartTitle, data: transformedData, units: units, content: content }));
|
|
36515
36565
|
}
|
|
36516
|
-
function LineChartComponent({ lineChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36566
|
+
function LineChartComponent({ lineChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout, content }) {
|
|
36517
36567
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
36518
36568
|
const hasCalledRef = React.useRef(false);
|
|
36519
36569
|
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) || [];
|
|
@@ -36568,7 +36618,7 @@ function LineChartComponent({ lineChartState, styles, appendMessage, query, isFi
|
|
|
36568
36618
|
},
|
|
36569
36619
|
],
|
|
36570
36620
|
};
|
|
36571
|
-
return (jsxRuntimeExports.jsx(LineChart, { title: chartTitle, data: transformedData, units: units }));
|
|
36621
|
+
return (jsxRuntimeExports.jsx(LineChart, { title: chartTitle, data: transformedData, units: units, content: content }));
|
|
36572
36622
|
}
|
|
36573
36623
|
function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
|
|
36574
36624
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
@@ -36659,10 +36709,11 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
36659
36709
|
return (jsxRuntimeExports.jsx(SummaryWidget, { title: title, data: data, metadata: metadata, className: "" }));
|
|
36660
36710
|
}
|
|
36661
36711
|
function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds, widgetBackendUrl, datasetId }) {
|
|
36662
|
-
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;
|
|
36712
|
+
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;
|
|
36663
36713
|
const agentType = (_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentType;
|
|
36664
36714
|
const orientation = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.orientation;
|
|
36665
36715
|
const isFirstLoad = (_c = widget.config) === null || _c === void 0 ? void 0 : _c.isFirstLoad;
|
|
36716
|
+
const content = (_d = widget.config) === null || _d === void 0 ? void 0 : _d.content;
|
|
36666
36717
|
const { threadId, setThreadId } = reactCore.useCopilotContext();
|
|
36667
36718
|
const timeoutRef = React.useRef(null);
|
|
36668
36719
|
const [isTimeoutTriggered, setIsTimeoutTriggered] = React.useState(false);
|
|
@@ -36672,7 +36723,7 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36672
36723
|
setThreadId(widget.id);
|
|
36673
36724
|
}, [widget.id, setThreadId]);
|
|
36674
36725
|
const { state: chartState, setState: setChartState } = reactCore.useCoAgent({
|
|
36675
|
-
name: (
|
|
36726
|
+
name: (_e = widget.config) === null || _e === void 0 ? void 0 : _e.agentName,
|
|
36676
36727
|
initialState: createInitialChartState(agentType || '', widgetIds, datasetId),
|
|
36677
36728
|
});
|
|
36678
36729
|
// Function to handle timeout and call loadAgentState API
|
|
@@ -36696,7 +36747,7 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36696
36747
|
if (apiResponse && !(chartState === null || chartState === void 0 ? void 0 : chartState.agent_message)) {
|
|
36697
36748
|
parseAndUpdateChartState(apiResponse, setChartState);
|
|
36698
36749
|
}
|
|
36699
|
-
}, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (
|
|
36750
|
+
}, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (_f = widget.config) === null || _f === void 0 ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
36700
36751
|
// Function to start timeout
|
|
36701
36752
|
const startLoadingTimeout = React.useCallback(() => {
|
|
36702
36753
|
if (timeoutRef.current) {
|
|
@@ -36810,15 +36861,15 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
36810
36861
|
}, [widget.id, appendMessage, agentType, setChartState]);
|
|
36811
36862
|
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" && (
|
|
36812
36863
|
// Check if data is empty based on agent type
|
|
36813
|
-
(agentType === "Bar Chart Agent" && (!((
|
|
36814
|
-
(agentType === "Series Bar Chart Agent" && (!((
|
|
36815
|
-
(agentType === "Series Line Chart Agent" && (!((
|
|
36816
|
-
(agentType === "Pie Chart Agent" && (!((
|
|
36817
|
-
(agentType === "Line Chart Agent" && (!((
|
|
36818
|
-
(agentType === "Data Grid Agent" && (!((
|
|
36819
|
-
(agentType === "Summary Agent" && (!((
|
|
36820
|
-
title: ((
|
|
36821
|
-
initial: ((
|
|
36864
|
+
(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))) ||
|
|
36865
|
+
(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))) ||
|
|
36866
|
+
(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))) ||
|
|
36867
|
+
(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))) ||
|
|
36868
|
+
(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))) ||
|
|
36869
|
+
(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))) ||
|
|
36870
|
+
(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 }) }) })) : agentType === "Bar Chart Agent" ? (jsxRuntimeExports.jsx(BarChartComponent, { barChartState: chartState, styles: styles, orientation: orientation, content: content, 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, content: content, 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, content: content, 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, content: content, 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, content: content, 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: {
|
|
36871
|
+
title: ((_30 = widget.config) === null || _30 === void 0 ? void 0 : _30.copilotTitle) || widget.title,
|
|
36872
|
+
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?"
|
|
36822
36873
|
}, onSubmitMessage: () => {
|
|
36823
36874
|
setChartState(prevState => (Object.assign(Object.assign({}, prevState), { widget_ids: widgetIds, dataset_id: datasetId })));
|
|
36824
36875
|
} })) })] }));
|
|
@@ -36949,11 +37000,14 @@ function Modal({ isOpen, onClose, title, children, size = 'md', initialFocusRef,
|
|
|
36949
37000
|
}
|
|
36950
37001
|
|
|
36951
37002
|
function EditWidgetDialog({ editingWidget, setWidgets, initialText, isOpen, onClose, onSubmit }) {
|
|
37003
|
+
var _a;
|
|
37004
|
+
const agentType = (_a = editingWidget === null || editingWidget === void 0 ? void 0 : editingWidget.config) === null || _a === void 0 ? void 0 : _a.agentType;
|
|
36952
37005
|
const [query, setQuery] = React.useState("");
|
|
36953
37006
|
const [displayText, setDisplayText] = React.useState("");
|
|
36954
37007
|
const [blockType, setBlockType] = React.useState("");
|
|
36955
37008
|
const [alignment, setAlignment] = React.useState("");
|
|
36956
37009
|
const [divider, setDivider] = React.useState("no");
|
|
37010
|
+
const [showLabels, setShowLabels] = React.useState(false);
|
|
36957
37011
|
const [styles, setStyles] = React.useState("");
|
|
36958
37012
|
React.useEffect(() => {
|
|
36959
37013
|
setQuery(initialText);
|
|
@@ -36978,10 +37032,14 @@ function EditWidgetDialog({ editingWidget, setWidgets, initialText, isOpen, onCl
|
|
|
36978
37032
|
if (hasDivider === null || hasDivider === void 0 ? void 0 : hasDivider.length) {
|
|
36979
37033
|
setDivider(hasDivider);
|
|
36980
37034
|
}
|
|
37035
|
+
const hasShowLabel = content === null || content === void 0 ? void 0 : content.showLabels;
|
|
37036
|
+
if (hasShowLabel !== undefined) {
|
|
37037
|
+
setShowLabels(hasShowLabel);
|
|
37038
|
+
}
|
|
36981
37039
|
}, [editingWidget]);
|
|
36982
37040
|
const handleSubmit = () => {
|
|
36983
37041
|
if (onSubmit && query.trim()) {
|
|
36984
|
-
onSubmit(query);
|
|
37042
|
+
onSubmit(query, showLabels);
|
|
36985
37043
|
}
|
|
36986
37044
|
if (editingWidget.type === 'text') {
|
|
36987
37045
|
const widgetId = editingWidget === null || editingWidget === void 0 ? void 0 : editingWidget.id;
|
|
@@ -37003,10 +37061,10 @@ function EditWidgetDialog({ editingWidget, setWidgets, initialText, isOpen, onCl
|
|
|
37003
37061
|
return null;
|
|
37004
37062
|
return (jsxRuntimeExports.jsx(Modal, { isOpen: isOpen, onClose: onClose, title: "Edit Widget", size: "lg",
|
|
37005
37063
|
// initialFocusRef={inputRef}
|
|
37006
|
-
noOverflowHidden: true, children: jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("p", { className: "text-gray-700", children: "Customize the widget\u2019s appearance" }), jsxRuntimeExports.
|
|
37007
|
-
|
|
37008
|
-
|
|
37009
|
-
|
|
37064
|
+
noOverflowHidden: true, children: jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("p", { className: "text-gray-700", children: "Customize the widget\u2019s appearance" }), jsxRuntimeExports.jsxs("div", { className: "pt-7", children: [(agentType === "Pie Chart Agent" || agentType === "Line Chart Agent" || agentType === "Series Line Chart Agent" || agentType === "Bar Chart Agent" || agentType === "Series Bar Chart Agent") && (jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2 mb-4", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Data Labels:" }), jsxRuntimeExports.jsxs(Select, { value: showLabels ? "yes" : "no", onValueChange: (value) => setShowLabels(value === "yes"), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Visible data labels?" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "no", children: "No" }), jsxRuntimeExports.jsx(SelectItem, { value: "yes", children: "Yes" })] })] })] })), (editingWidget === null || editingWidget === void 0 ? void 0 : editingWidget.type) === "text" ?
|
|
37065
|
+
jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-5", children: [jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Display text:" }), jsxRuntimeExports.jsx(Input, { value: displayText, onChange: (e) => setDisplayText(e.target.value), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Block type:" }), jsxRuntimeExports.jsxs(Select, { value: blockType, onValueChange: (value) => setBlockType(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select block type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "heading-1", children: "Heading 1" }), jsxRuntimeExports.jsx(SelectItem, { value: "heading-2", children: "Heading 2" }), jsxRuntimeExports.jsx(SelectItem, { value: "heading-3", children: "Heading 3" }), jsxRuntimeExports.jsx(SelectItem, { value: "paragraph", children: "Paragraph" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Align:" }), jsxRuntimeExports.jsxs(Select, { value: alignment, onValueChange: (value) => setAlignment(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select block type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "left", children: "Left" }), jsxRuntimeExports.jsx(SelectItem, { value: "center", children: "Center" }), jsxRuntimeExports.jsx(SelectItem, { value: "right", children: "Right" }), jsxRuntimeExports.jsx(SelectItem, { value: "justify", children: "Justify" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Divider:" }), jsxRuntimeExports.jsxs(Select, { value: divider, onValueChange: (value) => setDivider(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "No" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "yes", children: "Yes" }), jsxRuntimeExports.jsx(SelectItem, { value: "no", children: "No" })] })] })] }), jsxRuntimeExports.jsx("div", { className: "flex justify-end", children: jsxRuntimeExports.jsx("button", { onClick: handleSubmit, className: "font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none bg-primary-600 text-white hover:bg-primary-700 focus:ring-primary-500 px-6 py-2 text-sm flex items-center gap-2", children: "Submit" }) })] })
|
|
37066
|
+
:
|
|
37067
|
+
jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Query:" }), jsxRuntimeExports.jsx(Textarea, { className: "w-full p-2", value: query, onChange: (e) => { var _a; return setQuery((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.value); } })] }), jsxRuntimeExports.jsx("div", { className: "flex justify-end pt-3", children: jsxRuntimeExports.jsx("button", { onClick: handleSubmit, className: "font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none bg-primary-600 text-white hover:bg-primary-700 focus:ring-primary-500 px-6 py-2 text-sm flex items-center gap-2", children: "Submit" }) })] })] })] }) }));
|
|
37010
37068
|
}
|
|
37011
37069
|
|
|
37012
37070
|
function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk-construction-project-agent" }) {
|
|
@@ -37018,6 +37076,7 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
37018
37076
|
const [blockType, setBlockType] = React.useState("paragraph");
|
|
37019
37077
|
const [alignment, setAlignment] = React.useState("left");
|
|
37020
37078
|
const [divider, setDivider] = React.useState("no");
|
|
37079
|
+
const [showLabels, setShowLabels] = React.useState(false);
|
|
37021
37080
|
const widgetOptions = [
|
|
37022
37081
|
// {
|
|
37023
37082
|
// type: 'bar-chart',
|
|
@@ -37138,14 +37197,20 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
37138
37197
|
config = {
|
|
37139
37198
|
query: query,
|
|
37140
37199
|
agentName: defaultAgentName,
|
|
37141
|
-
agentType: "Series Line Chart Agent"
|
|
37200
|
+
agentType: "Series Line Chart Agent",
|
|
37201
|
+
content: {
|
|
37202
|
+
showLabels
|
|
37203
|
+
},
|
|
37142
37204
|
};
|
|
37143
37205
|
}
|
|
37144
37206
|
else if (selectedWidgetType === 'line-chart') {
|
|
37145
37207
|
config = {
|
|
37146
37208
|
query: query,
|
|
37147
37209
|
agentName: defaultAgentName,
|
|
37148
|
-
agentType: "Line Chart Agent"
|
|
37210
|
+
agentType: "Line Chart Agent",
|
|
37211
|
+
content: {
|
|
37212
|
+
showLabels
|
|
37213
|
+
},
|
|
37149
37214
|
};
|
|
37150
37215
|
}
|
|
37151
37216
|
else if (selectedWidgetType === 'pie-chart') {
|
|
@@ -37208,7 +37273,7 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
37208
37273
|
noOverflowHidden: true, children: jsxRuntimeExports.jsx("div", { children: jsxRuntimeExports.jsx("div", { className: "pt-4", children: !showConfigStep ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: "mb-4", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: "Choose a widget to add to your dashboard:" }) }), jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 gap-3 max-h-[400px] overflow-y-auto", children: widgetOptions.map((widget) => {
|
|
37209
37274
|
const IconComponent = widget.icon;
|
|
37210
37275
|
return (jsxRuntimeExports.jsxs("button", { onClick: () => handleWidgetSelect(widget.type), className: "flex items-start gap-3 p-4 border border-slate-200 rounded-lg hover:bg-gray-50 transition-colors text-left", children: [jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 p-2 bg-primary-100 rounded-md", children: jsxRuntimeExports.jsx(IconComponent, { className: "w-5 h-5 text-primary-600" }) }), jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [jsxRuntimeExports.jsx("h3", { className: "font-medium text-sm", children: widget.title }), jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 !mt-1", children: widget.description })] })] }, widget.type));
|
|
37211
|
-
}) })] })) : (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: "mb-2", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: selectedWidgetType === 'chatbot'
|
|
37276
|
+
}) })] })) : (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [(selectedWidgetType === 'bar-chart' || selectedWidgetType === 'series-bar-chart' || selectedWidgetType === 'series-line-chart' || selectedWidgetType === 'line-chart' || selectedWidgetType === 'pie-chart') && (jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2 mb-4 mt-2", children: [jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: "Data Labels:" }), jsxRuntimeExports.jsxs(Select, { value: showLabels ? "yes" : "no", onValueChange: (value) => setShowLabels(value === "yes"), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Visible data labels?" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "no", children: "No" }), jsxRuntimeExports.jsx(SelectItem, { value: "yes", children: "Yes" })] })] })] })), jsxRuntimeExports.jsx("div", { className: "mb-2", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: selectedWidgetType === 'chatbot'
|
|
37212
37277
|
? 'Chatbot widget will be configured with the default agent.'
|
|
37213
37278
|
: selectedWidgetType === 'text' ? "Customize the widget's appearance" : 'Enter a query for your chart widget:' }) }), (selectedWidgetType === 'bar-chart' || selectedWidgetType === 'series-bar-chart' || selectedWidgetType === 'series-line-chart' || selectedWidgetType === 'line-chart' || selectedWidgetType === 'pie-chart' || selectedWidgetType === 'data-grid' || selectedWidgetType === 'summary') && (jsxRuntimeExports.jsx("div", { className: "mb-6", children: jsxRuntimeExports.jsx(Textarea, { value: query, onChange: (e) => setQuery(e.target.value), placeholder: "e.g., List out the product types by its count and render it on bar chart", className: "w-full h-24 resize-none" }) })), selectedWidgetType === 'text' && (jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-5 pb-5 pt-2", children: [jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Display text:" }), jsxRuntimeExports.jsx(Input, { value: displayText, onChange: (e) => setDisplayText(e.target.value), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Block type:" }), jsxRuntimeExports.jsxs(Select, { value: blockType, onValueChange: (value) => setBlockType(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select block type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "heading-1", children: "Heading 1" }), jsxRuntimeExports.jsx(SelectItem, { value: "heading-2", children: "Heading 2" }), jsxRuntimeExports.jsx(SelectItem, { value: "heading-3", children: "Heading 3" }), jsxRuntimeExports.jsx(SelectItem, { value: "paragraph", children: "Paragraph" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Align:" }), jsxRuntimeExports.jsxs(Select, { value: alignment, onValueChange: (value) => setAlignment(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select block type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "left", children: "Left" }), jsxRuntimeExports.jsx(SelectItem, { value: "center", children: "Center" }), jsxRuntimeExports.jsx(SelectItem, { value: "right", children: "Right" }), jsxRuntimeExports.jsx(SelectItem, { value: "justify", children: "Justify" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Divider:" }), jsxRuntimeExports.jsxs(Select, { value: divider, onValueChange: (value) => setDivider(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "No" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "yes", children: "Yes" }), jsxRuntimeExports.jsx(SelectItem, { value: "no", children: "No" })] })] })] })] })), jsxRuntimeExports.jsxs("div", { className: "flex gap-3 justify-end", children: [jsxRuntimeExports.jsx(Button, { variant: "outline", onClick: () => setShowConfigStep(false), children: "Back" }), jsxRuntimeExports.jsx(Button, { onClick: handleConfigSubmit, disabled: (selectedWidgetType === 'bar-chart' || selectedWidgetType === 'series-bar-chart' || selectedWidgetType === 'series-line-chart' || selectedWidgetType === 'line-chart' || selectedWidgetType === 'pie-chart' || selectedWidgetType === 'data-grid' || selectedWidgetType === 'summary') && !query.trim(), children: "Add Widget" })] })] })) }) }) }));
|
|
37214
37279
|
}
|
|
@@ -37284,13 +37349,13 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
37284
37349
|
setEditInitialQuery("");
|
|
37285
37350
|
}
|
|
37286
37351
|
};
|
|
37287
|
-
const handleEditSubmit = async (newQuery) => {
|
|
37352
|
+
const handleEditSubmit = async (newQuery, showLabels) => {
|
|
37288
37353
|
var _a;
|
|
37289
37354
|
if (!editingWidget)
|
|
37290
37355
|
return;
|
|
37291
37356
|
// Update the widget's config with the new query
|
|
37292
37357
|
const updatedWidgets = widgets.map(w => w.id === editingWidget.id
|
|
37293
|
-
? Object.assign(Object.assign({}, w), { config: Object.assign(Object.assign({}, w.config), { query: newQuery }) }) : w);
|
|
37358
|
+
? Object.assign(Object.assign({}, w), { config: Object.assign(Object.assign({}, w.config), { query: newQuery, content: Object.assign(Object.assign({}, w.config.content), { showLabels }) }) }) : w);
|
|
37294
37359
|
setWidgets(updatedWidgets);
|
|
37295
37360
|
// Close the modal
|
|
37296
37361
|
setShowEditModal(false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dp-widgets-framework",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"@types/react-datepicker": "^7.0.0",
|
|
80
80
|
"@types/react-grid-layout": "^1.3.5",
|
|
81
81
|
"chart.js": "^4.5.0",
|
|
82
|
+
"chartjs-plugin-datalabels": "^2.2.0",
|
|
82
83
|
"class-variance-authority": "^0.7.1",
|
|
83
84
|
"clsx": "^2.1.1",
|
|
84
85
|
"cors": "^2.8.5",
|