dp-widgets-framework 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +381 -34
- package/dist/index.js +380 -33
- package/package.json +6 -6
package/dist/index.esm.js
CHANGED
|
@@ -7,7 +7,7 @@ import * as LabelPrimitive from '@radix-ui/react-label';
|
|
|
7
7
|
import { cva } from 'class-variance-authority';
|
|
8
8
|
import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
9
9
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
10
|
-
import { ChevronDown, ChevronUp, Check, AlertCircle, MoveUp, MoveDown, Trash2, Plus, Bot, Type, Layout, LayoutGrid, BarChart as BarChart$1, Filter, Search, ArrowUp, ArrowDown, ChevronRight, RefreshCw, Send, X, AlignVerticalSpaceAround, LineChart as LineChart$1, PieChart as PieChart$1, Table, FileText, Loader2, GripHorizontal, Edit, MessageCircleX, Edit2 } from 'lucide-react';
|
|
10
|
+
import { ChevronDown, ChevronUp, Check, AlertCircle, MoveUp, MoveDown, Trash2, Plus, Bot, Type, Layout, LayoutGrid, BarChart as BarChart$1, Filter, Search, ArrowUp, ArrowDown, ChevronRight, RefreshCw, Send, X, AlignVerticalSpaceAround, LineChart as LineChart$1, PieChart as PieChart$1, Table, FileText, SlidersHorizontal, Loader2, GripHorizontal, Edit, MessageCircleX, Edit2 } from 'lucide-react';
|
|
11
11
|
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
12
12
|
import { Slot } from '@radix-ui/react-slot';
|
|
13
13
|
import { debounce as debounce$1 } from 'lodash';
|
|
@@ -17649,8 +17649,6 @@ function LineChart({ title, data, options, className, units, content }) {
|
|
|
17649
17649
|
function DataGrid({ title, data, className }) {
|
|
17650
17650
|
var _a;
|
|
17651
17651
|
const { columns, rows, units, grouped = false, grouping } = data;
|
|
17652
|
-
console.log('title==>', title);
|
|
17653
|
-
console.log('grouping==>', grouping);
|
|
17654
17652
|
const [expandedGroups, setExpandedGroups] = useState(new Set(((_a = grouping === null || grouping === void 0 ? void 0 : grouping.sections) === null || _a === void 0 ? void 0 : _a.filter(s => s.expanded).map(s => s.group_value)) || []));
|
|
17655
17653
|
const toggleGroup = (groupValue) => {
|
|
17656
17654
|
const newExpanded = new Set(expandedGroups);
|
|
@@ -38412,7 +38410,7 @@ function SummaryWidget({ title, data, metadata, className }) {
|
|
|
38412
38410
|
const CHART_REFRESH_TIMEOUT$4 = 3000;
|
|
38413
38411
|
const DEFAULT_COLORS$3 = ["#E4DCB8", "#DAC46C", "#808080", "#582809", "#A3ADD0", "#398E6F", "#AF123D", "#8C99C4", "#5290AC", "#601B07", "#50649D", "#B4A8A0", "#6F2587"];
|
|
38414
38412
|
const LINE_COLORS = ["#243D84", "#69238B", "#4A959F", "#D0A677", "#B31E47", "#396431"];
|
|
38415
|
-
const clearChat$
|
|
38413
|
+
const clearChat$5 = async (widgetBackendUrl, widgetId) => {
|
|
38416
38414
|
if (!widgetBackendUrl || !widgetId)
|
|
38417
38415
|
return;
|
|
38418
38416
|
console.log('clearChat called for widgetId:', widgetId);
|
|
@@ -38434,7 +38432,7 @@ const clearChat$4 = async (widgetBackendUrl, widgetId) => {
|
|
|
38434
38432
|
console.error('Failed to clear chat:', error);
|
|
38435
38433
|
}
|
|
38436
38434
|
};
|
|
38437
|
-
const createLoadingComponent$
|
|
38435
|
+
const createLoadingComponent$5 = (message = "Loading chart data...") => (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center gap-2", children: [jsxRuntimeExports.jsx(RefreshCw, { className: "h-6 w-6 animate-spin text-gray-800" }), jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500", children: message })] }) }));
|
|
38438
38436
|
const createInitialChartState$4 = (agentType, widgetIds, datasetId) => {
|
|
38439
38437
|
const baseState = { dataset_id: datasetId || "home_generation_dataset" };
|
|
38440
38438
|
switch (agentType) {
|
|
@@ -38492,7 +38490,7 @@ const createInitialChartState$4 = (agentType, widgetIds, datasetId) => {
|
|
|
38492
38490
|
return Object.assign({ widget_ids: widgetIds }, baseState);
|
|
38493
38491
|
}
|
|
38494
38492
|
};
|
|
38495
|
-
const loadAgentState$
|
|
38493
|
+
const loadAgentState$5 = async (widgetBackendUrl, threadId, agentName) => {
|
|
38496
38494
|
try {
|
|
38497
38495
|
const response = await fetch(`${widgetBackendUrl}/api/copilot/${agentName}`, {
|
|
38498
38496
|
method: 'POST',
|
|
@@ -38598,7 +38596,7 @@ function BarChartComponent({ orientation, barChartState, styles, appendMessage,
|
|
|
38598
38596
|
const isEmpty = labels.length === 0 || values.length === 0;
|
|
38599
38597
|
const handleRefresh = async () => {
|
|
38600
38598
|
if (query && widgetBackendUrl && widgetId) {
|
|
38601
|
-
await clearChat$
|
|
38599
|
+
await clearChat$5(widgetBackendUrl, widgetId);
|
|
38602
38600
|
appendMessage(new TextMessage({
|
|
38603
38601
|
content: `${query} and render data on a bar chart`,
|
|
38604
38602
|
role: Role.User,
|
|
@@ -38625,7 +38623,7 @@ function BarChartComponent({ orientation, barChartState, styles, appendMessage,
|
|
|
38625
38623
|
return shuffleColors(DEFAULT_COLORS$3, labels === null || labels === void 0 ? void 0 : labels.length);
|
|
38626
38624
|
}, [labels.length]);
|
|
38627
38625
|
if (isEmpty) {
|
|
38628
|
-
return createLoadingComponent$
|
|
38626
|
+
return createLoadingComponent$5();
|
|
38629
38627
|
}
|
|
38630
38628
|
const transformedData = {
|
|
38631
38629
|
labels: labels,
|
|
@@ -38651,7 +38649,7 @@ function SeriesBarChartComponent$2({ orientation, seriesBarChartState, styles, a
|
|
|
38651
38649
|
const isEmpty = labels.length === 0 || series.length === 0;
|
|
38652
38650
|
const handleRefresh = async () => {
|
|
38653
38651
|
if (query) {
|
|
38654
|
-
await clearChat$
|
|
38652
|
+
await clearChat$5(widgetBackendUrl, widgetId);
|
|
38655
38653
|
// Send trigger event to clear chart state
|
|
38656
38654
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
38657
38655
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -38680,7 +38678,7 @@ function SeriesBarChartComponent$2({ orientation, seriesBarChartState, styles, a
|
|
|
38680
38678
|
return shuffleColors(DEFAULT_COLORS$3, series === null || series === void 0 ? void 0 : series.length);
|
|
38681
38679
|
}, [series.length]);
|
|
38682
38680
|
if (isEmpty) {
|
|
38683
|
-
return createLoadingComponent$
|
|
38681
|
+
return createLoadingComponent$5();
|
|
38684
38682
|
}
|
|
38685
38683
|
const transformedData = {
|
|
38686
38684
|
labels: labels,
|
|
@@ -38704,7 +38702,7 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
|
|
|
38704
38702
|
const isEmpty = labels.length === 0 || series.length === 0;
|
|
38705
38703
|
const handleRefresh = async () => {
|
|
38706
38704
|
if (query) {
|
|
38707
|
-
await clearChat$
|
|
38705
|
+
await clearChat$5(widgetBackendUrl, widgetId);
|
|
38708
38706
|
// Send trigger event to clear chart state
|
|
38709
38707
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
38710
38708
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -38733,7 +38731,7 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
|
|
|
38733
38731
|
return shuffleColors([...LINE_COLORS, ...DEFAULT_COLORS$3], series === null || series === void 0 ? void 0 : series.length);
|
|
38734
38732
|
}, [series.length]);
|
|
38735
38733
|
if (isEmpty) {
|
|
38736
|
-
return createLoadingComponent$
|
|
38734
|
+
return createLoadingComponent$5();
|
|
38737
38735
|
}
|
|
38738
38736
|
const transformedData = {
|
|
38739
38737
|
labels: labels,
|
|
@@ -38763,7 +38761,7 @@ function PieChartComponent$1({ pieChartState, styles, appendMessage, query, isFi
|
|
|
38763
38761
|
const isEmpty = labels.length === 0 || values.length === 0;
|
|
38764
38762
|
const handleRefresh = async () => {
|
|
38765
38763
|
if (query) {
|
|
38766
|
-
await clearChat$
|
|
38764
|
+
await clearChat$5(widgetBackendUrl, widgetId);
|
|
38767
38765
|
// Send trigger event to clear chart state
|
|
38768
38766
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
38769
38767
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -38792,7 +38790,7 @@ function PieChartComponent$1({ pieChartState, styles, appendMessage, query, isFi
|
|
|
38792
38790
|
return shuffleColors(DEFAULT_COLORS$3, labels.length);
|
|
38793
38791
|
}, [labels.length]);
|
|
38794
38792
|
if (isEmpty) {
|
|
38795
|
-
return createLoadingComponent$
|
|
38793
|
+
return createLoadingComponent$5();
|
|
38796
38794
|
}
|
|
38797
38795
|
const colors = ((_y = (_x = pieChartState === null || pieChartState === void 0 ? void 0 : pieChartState.pie_chart_data) === null || _x === void 0 ? void 0 : _x.data) === null || _y === void 0 ? void 0 : _y.colors) || ((_1 = (_0 = (_z = pieChartState === null || pieChartState === void 0 ? void 0 : pieChartState.state) === null || _z === void 0 ? void 0 : _z.pie_chart_data) === null || _0 === void 0 ? void 0 : _0.data) === null || _1 === void 0 ? void 0 : _1.colors) || labels.map((_, index) => backgroundColors[index % backgroundColors.length]);
|
|
38798
38796
|
const transformedData = {
|
|
@@ -38819,7 +38817,7 @@ function LineChartComponent({ lineChartState, styles, appendMessage, query, isFi
|
|
|
38819
38817
|
const isEmpty = labels.length === 0 || values.length === 0;
|
|
38820
38818
|
const handleRefresh = async () => {
|
|
38821
38819
|
if (query && widgetBackendUrl && widgetId) {
|
|
38822
|
-
await clearChat$
|
|
38820
|
+
await clearChat$5(widgetBackendUrl, widgetId);
|
|
38823
38821
|
appendMessage(new TextMessage({
|
|
38824
38822
|
content: `${query} and render data on a bar chart`,
|
|
38825
38823
|
role: Role.User,
|
|
@@ -38845,7 +38843,7 @@ function LineChartComponent({ lineChartState, styles, appendMessage, query, isFi
|
|
|
38845
38843
|
return LINE_COLORS[Math.floor(Math.random() * LINE_COLORS.length)];
|
|
38846
38844
|
}, [labels.length]);
|
|
38847
38845
|
if (isEmpty) {
|
|
38848
|
-
return createLoadingComponent$
|
|
38846
|
+
return createLoadingComponent$5();
|
|
38849
38847
|
}
|
|
38850
38848
|
const transformedData = {
|
|
38851
38849
|
labels: labels,
|
|
@@ -38875,7 +38873,7 @@ function DataGridComponent$1({ dataGridState, styles, appendMessage, query, isFi
|
|
|
38875
38873
|
const isEmpty = columns.length === 0 || rows.length === 0;
|
|
38876
38874
|
const handleRefresh = async () => {
|
|
38877
38875
|
if (query) {
|
|
38878
|
-
await clearChat$
|
|
38876
|
+
await clearChat$5(widgetBackendUrl, widgetId);
|
|
38879
38877
|
// Send trigger event to clear chart state
|
|
38880
38878
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
38881
38879
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -38901,7 +38899,7 @@ function DataGridComponent$1({ dataGridState, styles, appendMessage, query, isFi
|
|
|
38901
38899
|
}
|
|
38902
38900
|
}, [isEmpty, startLoadingTimeout, clearLoadingTimeout]);
|
|
38903
38901
|
if (isEmpty) {
|
|
38904
|
-
return createLoadingComponent$
|
|
38902
|
+
return createLoadingComponent$5("Loading table data...");
|
|
38905
38903
|
}
|
|
38906
38904
|
const transformedData = {
|
|
38907
38905
|
columns: columns,
|
|
@@ -38922,7 +38920,7 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
38922
38920
|
const isEmpty = !content || content.trim() === "";
|
|
38923
38921
|
const handleRefresh = async () => {
|
|
38924
38922
|
if (query) {
|
|
38925
|
-
await clearChat$
|
|
38923
|
+
await clearChat$5(widgetBackendUrl, widgetId);
|
|
38926
38924
|
// Send trigger event to clear chart state
|
|
38927
38925
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
38928
38926
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -38951,7 +38949,7 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
38951
38949
|
}
|
|
38952
38950
|
}, [isEmpty, startLoadingTimeout, clearLoadingTimeout]);
|
|
38953
38951
|
if (isEmpty) {
|
|
38954
|
-
return createLoadingComponent$
|
|
38952
|
+
return createLoadingComponent$5("Loading summary...");
|
|
38955
38953
|
}
|
|
38956
38954
|
return (jsxRuntimeExports.jsx(SummaryWidget, { title: title, data: data, metadata: metadata, className: "" }));
|
|
38957
38955
|
}
|
|
@@ -38990,7 +38988,7 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
38990
38988
|
// Increment the API call counter
|
|
38991
38989
|
setApiCallCount(prev => prev + 1);
|
|
38992
38990
|
const agentName = ((_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentName) || "adk-construction-project-agent";
|
|
38993
|
-
const apiResponse = await loadAgentState$
|
|
38991
|
+
const apiResponse = await loadAgentState$5(widgetBackendUrl, widget.id, agentName);
|
|
38994
38992
|
if (apiResponse && !(chartState === null || chartState === void 0 ? void 0 : chartState.agent_message)) {
|
|
38995
38993
|
parseAndUpdateChartState$4(apiResponse, setChartState);
|
|
38996
38994
|
}
|
|
@@ -39248,6 +39246,339 @@ function ChatbotWidget({ widget, showHeader = true, widgetBackendUrl, onResetRea
|
|
|
39248
39246
|
return (jsxRuntimeExports.jsx(CopilotKit, { runtimeUrl: getRuntimeUrl(), showDevConsole: false, agent: ((_b = widget.config) === null || _b === void 0 ? void 0 : _b.agentName) || "widget_assistant", children: jsxRuntimeExports.jsx(CopilotKitChatbot, { widget: widget, showHeader: showHeader, styles: styles, onResetReady: onResetReady, widgetIds: widgetIds, datasetId: datasetId }) }));
|
|
39249
39247
|
}
|
|
39250
39248
|
|
|
39249
|
+
const Checkbox = React.forwardRef((_a, ref) => {
|
|
39250
|
+
var { className } = _a, props = __rest(_a, ["className"]);
|
|
39251
|
+
return (jsxRuntimeExports.jsx(CheckboxPrimitive.Root, Object.assign({ ref: ref, className: cn("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground", className) }, props, { children: jsxRuntimeExports.jsx(CheckboxPrimitive.Indicator, { className: cn("flex items-center justify-center text-current"), children: jsxRuntimeExports.jsx(Check, { className: "h-4 w-4" }) }) })));
|
|
39252
|
+
});
|
|
39253
|
+
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
|
|
39254
|
+
|
|
39255
|
+
const FILTER_REFRESH_TIMEOUT = 3000;
|
|
39256
|
+
const clearChat$4 = async (widgetBackendUrl, widgetId) => {
|
|
39257
|
+
if (!widgetBackendUrl || !widgetId)
|
|
39258
|
+
return;
|
|
39259
|
+
console.log('clearChat called for widgetId:', widgetId);
|
|
39260
|
+
try {
|
|
39261
|
+
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
39262
|
+
method: 'POST',
|
|
39263
|
+
headers: {
|
|
39264
|
+
'Content-Type': 'application/json',
|
|
39265
|
+
},
|
|
39266
|
+
body: JSON.stringify({
|
|
39267
|
+
session_id: widgetId,
|
|
39268
|
+
delete_state: true
|
|
39269
|
+
}),
|
|
39270
|
+
});
|
|
39271
|
+
console.log('Dispatching clearFilterState event from clearChat for widgetId:', widgetId);
|
|
39272
|
+
window.dispatchEvent(new CustomEvent('clearFilterState', { detail: { widgetId } }));
|
|
39273
|
+
}
|
|
39274
|
+
catch (error) {
|
|
39275
|
+
console.error('Failed to clear chat:', error);
|
|
39276
|
+
}
|
|
39277
|
+
};
|
|
39278
|
+
const createLoadingComponent$4 = (message = "Loading filter data...") => (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center gap-2", children: [jsxRuntimeExports.jsx(RefreshCw, { className: "h-6 w-6 animate-spin text-gray-800" }), jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500", children: message })] }) }));
|
|
39279
|
+
const createInitialFilterState = (datasetId, filterData) => {
|
|
39280
|
+
return {
|
|
39281
|
+
column_values: filterData || [],
|
|
39282
|
+
dataset_id: datasetId || ""
|
|
39283
|
+
};
|
|
39284
|
+
};
|
|
39285
|
+
const loadAgentState$4 = async (widgetBackendUrl, threadId, agentName) => {
|
|
39286
|
+
try {
|
|
39287
|
+
const response = await fetch(`${widgetBackendUrl}/api/copilot/${agentName}`, {
|
|
39288
|
+
method: 'POST',
|
|
39289
|
+
headers: {
|
|
39290
|
+
'Content-Type': 'application/json',
|
|
39291
|
+
},
|
|
39292
|
+
body: JSON.stringify({
|
|
39293
|
+
"operationName": "loadAgentState",
|
|
39294
|
+
"query": "query loadAgentState($data: LoadAgentStateInput!) {\n loadAgentState(data: $data) {\n threadId\n threadExists\n state\n messages\n __typename\n }\n}",
|
|
39295
|
+
"variables": {
|
|
39296
|
+
"data": {
|
|
39297
|
+
"agentName": agentName,
|
|
39298
|
+
"threadId": threadId
|
|
39299
|
+
}
|
|
39300
|
+
}
|
|
39301
|
+
}),
|
|
39302
|
+
});
|
|
39303
|
+
if (!response.ok) {
|
|
39304
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
39305
|
+
}
|
|
39306
|
+
const result = await response.json();
|
|
39307
|
+
return result;
|
|
39308
|
+
}
|
|
39309
|
+
catch (error) {
|
|
39310
|
+
console.error('Failed to load agent state:', error);
|
|
39311
|
+
return null;
|
|
39312
|
+
}
|
|
39313
|
+
};
|
|
39314
|
+
const parseAndUpdateFilterState = (apiResponse, setFilterState) => {
|
|
39315
|
+
var _a, _b;
|
|
39316
|
+
try {
|
|
39317
|
+
if ((_b = (_a = apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.data) === null || _a === void 0 ? void 0 : _a.loadAgentState) === null || _b === void 0 ? void 0 : _b.state) {
|
|
39318
|
+
const stateString = apiResponse.data.loadAgentState.state;
|
|
39319
|
+
const parsedState = JSON.parse(stateString);
|
|
39320
|
+
if (parsedState.state) {
|
|
39321
|
+
const filterData = parsedState.state;
|
|
39322
|
+
setFilterState((prevState) => {
|
|
39323
|
+
const newFilterState = Object.assign({}, prevState);
|
|
39324
|
+
if (filterData.column_values) {
|
|
39325
|
+
newFilterState.column_values = filterData.column_values;
|
|
39326
|
+
}
|
|
39327
|
+
if (filterData.agent_message) {
|
|
39328
|
+
newFilterState.agent_message = filterData.agent_message;
|
|
39329
|
+
}
|
|
39330
|
+
return newFilterState;
|
|
39331
|
+
});
|
|
39332
|
+
}
|
|
39333
|
+
}
|
|
39334
|
+
}
|
|
39335
|
+
catch (error) {
|
|
39336
|
+
console.error('Failed to parse and update filter state:', error);
|
|
39337
|
+
}
|
|
39338
|
+
};
|
|
39339
|
+
// Helper function to convert FilterState to FilterGroup array
|
|
39340
|
+
const convertFilterStateToGroups = (filterState) => {
|
|
39341
|
+
if (!filterState.column_values || filterState.column_values.length === 0) {
|
|
39342
|
+
return [];
|
|
39343
|
+
}
|
|
39344
|
+
return filterState.column_values.map((filter) => ({
|
|
39345
|
+
id: `${filter.table_name}_${filter.column}`,
|
|
39346
|
+
name: filter.column.replace(/_/g, ' ').replace(/\b\w/g, (l) => l.toUpperCase()),
|
|
39347
|
+
options: filter.values.map((value) => ({
|
|
39348
|
+
id: value.toLowerCase().replace(/\s+/g, '-'),
|
|
39349
|
+
label: value,
|
|
39350
|
+
})),
|
|
39351
|
+
}));
|
|
39352
|
+
};
|
|
39353
|
+
function FiltersContent({ filterGroups, showHeader, onFilterChange, widget, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout, filterState, onApplyFilters, }) {
|
|
39354
|
+
const hasCalledRef = useRef(false);
|
|
39355
|
+
const [expandedGroups, setExpandedGroups] = useState({});
|
|
39356
|
+
const [selectedFilters, setSelectedFilters] = useState({});
|
|
39357
|
+
const [searchQueries, setSearchQueries] = useState({});
|
|
39358
|
+
const isEmpty = filterGroups.length === 0;
|
|
39359
|
+
const handleRefresh = async () => {
|
|
39360
|
+
if (query) {
|
|
39361
|
+
await clearChat$4(widgetBackendUrl, widgetId);
|
|
39362
|
+
console.log('Dispatching clearFilterState event for widgetId:', widgetId);
|
|
39363
|
+
window.dispatchEvent(new CustomEvent('clearFilterState', { detail: { widgetId } }));
|
|
39364
|
+
appendMessage(new TextMessage({
|
|
39365
|
+
content: `${query}`,
|
|
39366
|
+
role: Role.User,
|
|
39367
|
+
}));
|
|
39368
|
+
}
|
|
39369
|
+
};
|
|
39370
|
+
useEffect(() => {
|
|
39371
|
+
if (isEmpty && query && isFirstLoad && !(filterState === null || filterState === void 0 ? void 0 : filterState.agent_message) && !hasCalledRef.current) {
|
|
39372
|
+
hasCalledRef.current = true;
|
|
39373
|
+
handleRefresh();
|
|
39374
|
+
}
|
|
39375
|
+
}, [isEmpty, query, isFirstLoad, filterState]);
|
|
39376
|
+
useEffect(() => {
|
|
39377
|
+
console.log('FiltersContent useEffect - isEmpty:', isEmpty, 'hasMessage:', !!(filterState === null || filterState === void 0 ? void 0 : filterState.agent_message), 'isFirstLoad:', isFirstLoad);
|
|
39378
|
+
if (isEmpty && startLoadingTimeout && !(filterState === null || filterState === void 0 ? void 0 : filterState.agent_message)) {
|
|
39379
|
+
console.log('Starting loading timeout from FiltersContent useEffect');
|
|
39380
|
+
startLoadingTimeout();
|
|
39381
|
+
}
|
|
39382
|
+
else if (!isEmpty && clearLoadingTimeout) {
|
|
39383
|
+
clearLoadingTimeout();
|
|
39384
|
+
}
|
|
39385
|
+
}, [isEmpty, startLoadingTimeout, clearLoadingTimeout, filterState]);
|
|
39386
|
+
// Initialize expanded state for all groups
|
|
39387
|
+
useEffect(() => {
|
|
39388
|
+
const initialExpanded = {};
|
|
39389
|
+
filterGroups.forEach((group) => {
|
|
39390
|
+
var _a;
|
|
39391
|
+
initialExpanded[group.id] = ((_a = widget.config) === null || _a === void 0 ? void 0 : _a.defaultExpanded) !== false;
|
|
39392
|
+
});
|
|
39393
|
+
setExpandedGroups(initialExpanded);
|
|
39394
|
+
}, [filterGroups]);
|
|
39395
|
+
const toggleGroup = (groupId) => {
|
|
39396
|
+
setExpandedGroups((prev) => (Object.assign(Object.assign({}, prev), { [groupId]: !prev[groupId] })));
|
|
39397
|
+
};
|
|
39398
|
+
const handleCheckboxChange = (groupId, optionId, checked) => {
|
|
39399
|
+
setSelectedFilters((prev) => {
|
|
39400
|
+
const groupFilters = prev[groupId] || [];
|
|
39401
|
+
let newGroupFilters;
|
|
39402
|
+
if (checked) {
|
|
39403
|
+
newGroupFilters = [...groupFilters, optionId];
|
|
39404
|
+
}
|
|
39405
|
+
else {
|
|
39406
|
+
newGroupFilters = groupFilters.filter((id) => id !== optionId);
|
|
39407
|
+
}
|
|
39408
|
+
const newFilters = Object.assign(Object.assign({}, prev), { [groupId]: newGroupFilters });
|
|
39409
|
+
if (onFilterChange) {
|
|
39410
|
+
onFilterChange(newFilters);
|
|
39411
|
+
}
|
|
39412
|
+
return newFilters;
|
|
39413
|
+
});
|
|
39414
|
+
};
|
|
39415
|
+
const handleSearchChange = (groupId, query) => {
|
|
39416
|
+
setSearchQueries((prev) => (Object.assign(Object.assign({}, prev), { [groupId]: query })));
|
|
39417
|
+
};
|
|
39418
|
+
const getFilteredOptions = (group) => {
|
|
39419
|
+
var _a;
|
|
39420
|
+
const query = ((_a = searchQueries[group.id]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || "";
|
|
39421
|
+
if (!query)
|
|
39422
|
+
return group.options;
|
|
39423
|
+
return group.options.filter((option) => option.label.toLowerCase().includes(query));
|
|
39424
|
+
};
|
|
39425
|
+
const getSelectedCount = (groupId) => {
|
|
39426
|
+
var _a;
|
|
39427
|
+
return ((_a = selectedFilters[groupId]) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
39428
|
+
};
|
|
39429
|
+
const clearGroupFilters = (groupId) => {
|
|
39430
|
+
setSelectedFilters((prev) => {
|
|
39431
|
+
const newFilters = Object.assign(Object.assign({}, prev), { [groupId]: [] });
|
|
39432
|
+
if (onFilterChange) {
|
|
39433
|
+
onFilterChange(newFilters);
|
|
39434
|
+
}
|
|
39435
|
+
return newFilters;
|
|
39436
|
+
});
|
|
39437
|
+
};
|
|
39438
|
+
if (isEmpty) {
|
|
39439
|
+
return createLoadingComponent$4();
|
|
39440
|
+
}
|
|
39441
|
+
return (jsxRuntimeExports.jsxs("div", { className: "h-full flex flex-col bg-white rounded-lg", children: [showHeader && (jsxRuntimeExports.jsx("div", { className: "px-4 py-3 border-b border-gray-100", children: jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }), jsxRuntimeExports.jsx("h3", { className: "font-semibold text-gray-800", children: "Filters" })] }) })), jsxRuntimeExports.jsx(ScrollArea, { className: "flex-1", children: jsxRuntimeExports.jsx("div", { className: "p-2", children: filterGroups.map((group) => {
|
|
39442
|
+
const isExpanded = expandedGroups[group.id];
|
|
39443
|
+
const selectedCount = getSelectedCount(group.id);
|
|
39444
|
+
const filteredOptions = getFilteredOptions(group);
|
|
39445
|
+
return (jsxRuntimeExports.jsxs("div", { className: "mb-2 border border-gray-100 rounded-lg overflow-hidden", children: [jsxRuntimeExports.jsxs("button", { onClick: () => toggleGroup(group.id), className: cn("w-full flex items-center justify-between px-3 py-2.5", "bg-gray-50 hover:bg-gray-100 transition-colors", "focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-inset"), children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [isExpanded ? (jsxRuntimeExports.jsx(ChevronDown, { className: "w-4 h-4 text-primary-600" })) : (jsxRuntimeExports.jsx(ChevronRight, { className: "w-4 h-4 text-gray-500" })), jsxRuntimeExports.jsx("span", { className: "font-medium text-sm text-gray-700", children: group.name }), selectedCount > 0 && (jsxRuntimeExports.jsx("span", { className: "ml-1 px-1.5 py-0.5 text-xs font-medium bg-primary-100 text-primary-700 rounded-full", children: selectedCount }))] }), selectedCount > 0 && (jsxRuntimeExports.jsx("button", { onClick: (e) => {
|
|
39446
|
+
e.stopPropagation();
|
|
39447
|
+
clearGroupFilters(group.id);
|
|
39448
|
+
}, className: "text-xs text-primary-600 hover:text-primary-800 hover:underline", children: "Clear" }))] }), jsxRuntimeExports.jsx("div", { className: cn("overflow-hidden transition-all duration-200 ease-in-out", isExpanded ? "max-h-[400px]" : "max-h-0"), children: jsxRuntimeExports.jsxs("div", { className: "px-3 py-2 bg-white", children: [group.options.length > 5 && (jsxRuntimeExports.jsxs("div", { className: "relative mb-2", children: [jsxRuntimeExports.jsx(Search, { className: "absolute left-2.5 top-1/2 transform -translate-y-1/2 w-3.5 h-3.5 text-gray-400" }), jsxRuntimeExports.jsx(Input, { type: "text", placeholder: `Search ${group.name.toLowerCase()}...`, value: searchQueries[group.id] || "", onChange: (e) => handleSearchChange(group.id, e.target.value), className: "pl-8 h-8 text-sm border-gray-200 focus:border-primary-400 focus:ring-primary-400" })] })), jsxRuntimeExports.jsx("div", { className: "space-y-1 max-h-[250px] overflow-y-auto pr-1", children: filteredOptions.length === 0 ? (jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500 py-2 text-center", children: "No options found" })) : (filteredOptions.map((option) => {
|
|
39449
|
+
var _a;
|
|
39450
|
+
const isChecked = ((_a = selectedFilters[group.id]) === null || _a === void 0 ? void 0 : _a.includes(option.id)) || false;
|
|
39451
|
+
return (jsxRuntimeExports.jsxs("label", { className: cn("flex items-center gap-2.5 px-2 py-1.5 rounded-md cursor-pointer", "hover:bg-gray-50 transition-colors", isChecked && "bg-primary-50"), children: [jsxRuntimeExports.jsx(Checkbox, { checked: isChecked, onCheckedChange: (checked) => handleCheckboxChange(group.id, option.id, checked), className: cn("h-4 w-4 rounded border-gray-300", "data-[state=checked]:bg-primary-600 data-[state=checked]:border-primary-600") }), jsxRuntimeExports.jsx("span", { className: cn("text-sm flex-1 truncate", isChecked ? "text-primary-700 font-medium" : "text-gray-600"), title: option.label, children: option.label }), option.count !== undefined && (jsxRuntimeExports.jsxs("span", { className: "text-xs text-gray-400", children: ["(", option.count, ")"] }))] }, option.id));
|
|
39452
|
+
})) })] }) })] }, group.id));
|
|
39453
|
+
}) }) }), jsxRuntimeExports.jsx("div", { className: "px-4 py-2 border-t border-gray-100 bg-gray-50", children: jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [Object.values(selectedFilters).some((arr) => arr.length > 0) ? (jsxRuntimeExports.jsx("button", { onClick: () => {
|
|
39454
|
+
setSelectedFilters({});
|
|
39455
|
+
if (onFilterChange) {
|
|
39456
|
+
onFilterChange({});
|
|
39457
|
+
}
|
|
39458
|
+
}, className: "py-1.5 text-sm font-medium text-primary-600 hover:text-primary-800 hover:bg-primary-50 rounded-md transition-colors px-2", children: "Clear All Filters" })) : (jsxRuntimeExports.jsx("div", {})), jsxRuntimeExports.jsx(Button, { onClick: () => { onApplyFilters === null || onApplyFilters === void 0 ? void 0 : onApplyFilters(selectedFilters); }, className: "bg-primary-600 hover:bg-primary-700 text-white", children: "Apply Filters" })] }) })] }));
|
|
39459
|
+
}
|
|
39460
|
+
function CopilotKitFilters({ widget, showHeader, onFilterChange, onResetReady, widgetBackendUrl, datasetId, onApplyFilters, }) {
|
|
39461
|
+
var _a, _b, _c, _d, _e, _f;
|
|
39462
|
+
const isFirstLoad = (_a = widget.config) === null || _a === void 0 ? void 0 : _a.isFirstLoad;
|
|
39463
|
+
const widget_data = (_b = widget.widget_data) === null || _b === void 0 ? void 0 : _b.column_values;
|
|
39464
|
+
const { setThreadId } = useCopilotContext();
|
|
39465
|
+
const timeoutRef = useRef(null);
|
|
39466
|
+
const [apiCallCount, setApiCallCount] = useState(0);
|
|
39467
|
+
const [hasTimeoutError, setHasTimeoutError] = useState(false);
|
|
39468
|
+
useEffect(() => {
|
|
39469
|
+
setThreadId(widget.id);
|
|
39470
|
+
}, [widget.id, setThreadId]);
|
|
39471
|
+
const { state: agentState, setState: setAgentState } = useCoAgent({
|
|
39472
|
+
name: (_c = widget.config) === null || _c === void 0 ? void 0 : _c.agentName,
|
|
39473
|
+
initialState: createInitialFilterState(datasetId, widget_data),
|
|
39474
|
+
});
|
|
39475
|
+
const [filterState, setFilterState] = useState(createInitialFilterState(datasetId, widget_data));
|
|
39476
|
+
const handleLoadingTimeout = useCallback(async () => {
|
|
39477
|
+
var _a;
|
|
39478
|
+
if (!widgetBackendUrl || !widget.id || (filterState === null || filterState === void 0 ? void 0 : filterState.agent_message) || hasTimeoutError) {
|
|
39479
|
+
console.log('Skipping API call - conditions not met');
|
|
39480
|
+
return;
|
|
39481
|
+
}
|
|
39482
|
+
console.log('Loading timeout triggered for widget:', widget.id, 'API call count:', apiCallCount);
|
|
39483
|
+
if (apiCallCount >= 30) {
|
|
39484
|
+
console.log('API call limit reached for widget:', widget.id);
|
|
39485
|
+
setHasTimeoutError(true);
|
|
39486
|
+
setFilterState(prevState => (Object.assign(Object.assign({}, prevState), { agent_message: "Timeout: Unable to load filter data after multiple attempts. Please try refreshing the widget." })));
|
|
39487
|
+
return;
|
|
39488
|
+
}
|
|
39489
|
+
setApiCallCount(prev => prev + 1);
|
|
39490
|
+
const agentName = ((_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentName) || "adk-construction-project-agent";
|
|
39491
|
+
console.log('Calling loadAgentState API for widget:', widget.id);
|
|
39492
|
+
const apiResponse = await loadAgentState$4(widgetBackendUrl, widget.id, agentName);
|
|
39493
|
+
console.log('API response received:', apiResponse);
|
|
39494
|
+
if (apiResponse && !(filterState === null || filterState === void 0 ? void 0 : filterState.agent_message)) {
|
|
39495
|
+
parseAndUpdateFilterState(apiResponse, setFilterState);
|
|
39496
|
+
}
|
|
39497
|
+
}, [widgetBackendUrl, widget.id, setFilterState, (_d = widget.config) === null || _d === void 0 ? void 0 : _d.agentName, filterState, apiCallCount, hasTimeoutError]);
|
|
39498
|
+
const startLoadingTimeout = useCallback(() => {
|
|
39499
|
+
if (timeoutRef.current) {
|
|
39500
|
+
clearTimeout(timeoutRef.current);
|
|
39501
|
+
}
|
|
39502
|
+
console.log('Scheduling next API call in 3 seconds');
|
|
39503
|
+
timeoutRef.current = setTimeout(() => {
|
|
39504
|
+
handleLoadingTimeout();
|
|
39505
|
+
}, FILTER_REFRESH_TIMEOUT);
|
|
39506
|
+
}, [handleLoadingTimeout]);
|
|
39507
|
+
const clearLoadingTimeout = useCallback(() => {
|
|
39508
|
+
if (timeoutRef.current) {
|
|
39509
|
+
clearTimeout(timeoutRef.current);
|
|
39510
|
+
timeoutRef.current = null;
|
|
39511
|
+
}
|
|
39512
|
+
}, []);
|
|
39513
|
+
useEffect(() => {
|
|
39514
|
+
return () => {
|
|
39515
|
+
if (timeoutRef.current) {
|
|
39516
|
+
clearTimeout(timeoutRef.current);
|
|
39517
|
+
}
|
|
39518
|
+
};
|
|
39519
|
+
}, []);
|
|
39520
|
+
const { appendMessage, reset } = useCopilotChat();
|
|
39521
|
+
useEffect(() => {
|
|
39522
|
+
if (onResetReady && reset && widget.id) {
|
|
39523
|
+
const wrappedReset = () => {
|
|
39524
|
+
reset();
|
|
39525
|
+
window.dispatchEvent(new CustomEvent('clearFilterState', { detail: { widgetId: widget.id } }));
|
|
39526
|
+
};
|
|
39527
|
+
onResetReady(widget.id, wrappedReset);
|
|
39528
|
+
}
|
|
39529
|
+
}, [reset, widget.id, onResetReady]);
|
|
39530
|
+
useEffect(() => {
|
|
39531
|
+
const handleTriggerAgent = (event) => {
|
|
39532
|
+
const { widgetId, query, datasetId } = event.detail;
|
|
39533
|
+
reset();
|
|
39534
|
+
if (widgetId === widget.id) {
|
|
39535
|
+
let messageContent = `${query}`;
|
|
39536
|
+
console.log('triggering to datasetId==>', datasetId);
|
|
39537
|
+
setFilterState(createInitialFilterState(datasetId));
|
|
39538
|
+
setAgentState(createInitialFilterState(datasetId));
|
|
39539
|
+
setApiCallCount(0);
|
|
39540
|
+
setHasTimeoutError(false);
|
|
39541
|
+
appendMessage(new TextMessage({
|
|
39542
|
+
content: messageContent,
|
|
39543
|
+
role: Role.User,
|
|
39544
|
+
}));
|
|
39545
|
+
// Start polling for filter data
|
|
39546
|
+
startLoadingTimeout();
|
|
39547
|
+
}
|
|
39548
|
+
};
|
|
39549
|
+
const handleClearFilterState = (event) => {
|
|
39550
|
+
const { widgetId } = event.detail;
|
|
39551
|
+
if (widgetId === widget.id) {
|
|
39552
|
+
setFilterState(createInitialFilterState(datasetId));
|
|
39553
|
+
setAgentState(createInitialFilterState(datasetId));
|
|
39554
|
+
setApiCallCount(0);
|
|
39555
|
+
setHasTimeoutError(false);
|
|
39556
|
+
}
|
|
39557
|
+
};
|
|
39558
|
+
window.addEventListener('triggerAgent', handleTriggerAgent);
|
|
39559
|
+
window.addEventListener('clearFilterState', handleClearFilterState);
|
|
39560
|
+
return () => {
|
|
39561
|
+
window.removeEventListener('triggerAgent', handleTriggerAgent);
|
|
39562
|
+
window.removeEventListener('clearFilterState', handleClearFilterState);
|
|
39563
|
+
};
|
|
39564
|
+
}, [widget.id, appendMessage, setFilterState, startLoadingTimeout]);
|
|
39565
|
+
// Convert filter state to filter groups
|
|
39566
|
+
const filterGroups = convertFilterStateToGroups(filterState);
|
|
39567
|
+
return (jsxRuntimeExports.jsx("div", { className: cn("flex flex-col h-full"), children: (filterState === null || filterState === void 0 ? void 0 : filterState.agent_message) &&
|
|
39568
|
+
(!((_e = filterState.column_values) === null || _e === void 0 ? void 0 : _e.length))
|
|
39569
|
+
? (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: filterState.agent_message }) }) })) : (jsxRuntimeExports.jsx(FiltersContent, { filterGroups: filterGroups, showHeader: showHeader, onFilterChange: onFilterChange, widget: widget, appendMessage: appendMessage, query: (_f = widget.config) === null || _f === void 0 ? void 0 : _f.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout, filterState: filterState, onApplyFilters: onApplyFilters })) }));
|
|
39570
|
+
}
|
|
39571
|
+
function FiltersWidget({ widget, showHeader = true, onConfigUpdate, onFilterChange, widgetBackendUrl, onResetReady, datasetId, onApplyFilters, }) {
|
|
39572
|
+
var _a;
|
|
39573
|
+
const getRuntimeUrl = () => {
|
|
39574
|
+
var _a;
|
|
39575
|
+
const baseUrl = widgetBackendUrl || '';
|
|
39576
|
+
const agentName = ((_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentName) || 'default-agent';
|
|
39577
|
+
return `${baseUrl}/api/copilot/${agentName}`;
|
|
39578
|
+
};
|
|
39579
|
+
return (jsxRuntimeExports.jsx(CopilotKit, { runtimeUrl: getRuntimeUrl(), showDevConsole: false, agent: ((_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentName) || "widget_assistant", children: jsxRuntimeExports.jsx(CopilotKitFilters, { widget: widget, showHeader: showHeader, onFilterChange: onFilterChange, onResetReady: onResetReady, widgetBackendUrl: widgetBackendUrl, datasetId: datasetId, onApplyFilters: onApplyFilters }) }));
|
|
39580
|
+
}
|
|
39581
|
+
|
|
39251
39582
|
const CHART_REFRESH_TIMEOUT$3 = 3000;
|
|
39252
39583
|
const DEFAULT_COLORS$2 = ["#E4DCB8", "#DAC46C", "#808080", "#582809", "#A3ADD0", "#398E6F", "#AF123D", "#8C99C4", "#5290AC", "#601B07", "#50649D", "#B4A8A0", "#6F2587"];
|
|
39253
39584
|
const clearChat$3 = async (widgetBackendUrl, widgetId) => {
|
|
@@ -40456,7 +40787,7 @@ function DatagridWidget({ widget, showHeader = true, widgetBackendUrl, onResetRe
|
|
|
40456
40787
|
return (jsxRuntimeExports.jsx(CopilotKit, { runtimeUrl: getRuntimeUrl(), showDevConsole: false, agent: ((_b = widget.config) === null || _b === void 0 ? void 0 : _b.agentName) || "widget_assistant", children: jsxRuntimeExports.jsx(CopilotKitDataGrid, { widget: widget, showHeader: showHeader, styles: styles, onResetReady: onResetReady, widgetBackendUrl: widgetBackendUrl, datasetId: datasetId }) }));
|
|
40457
40788
|
}
|
|
40458
40789
|
|
|
40459
|
-
function WidgetRenderer({ widget, isTemplate = false, onConfigUpdate, widgetBackendUrl, onResetReady, widgetIds, datasetId, }) {
|
|
40790
|
+
function WidgetRenderer({ widget, isTemplate = false, onConfigUpdate, widgetBackendUrl, onResetReady, widgetIds, datasetId, onApplyFilters, }) {
|
|
40460
40791
|
const handleConfigUpdate = (config) => {
|
|
40461
40792
|
if (onConfigUpdate) {
|
|
40462
40793
|
onConfigUpdate(widget.id, config);
|
|
@@ -40481,6 +40812,8 @@ function WidgetRenderer({ widget, isTemplate = false, onConfigUpdate, widgetBack
|
|
|
40481
40812
|
return (jsxRuntimeExports.jsx(FacetWidget, { widget: widget, showHeader: false, onConfigUpdate: handleConfigUpdate }));
|
|
40482
40813
|
case "chatbot":
|
|
40483
40814
|
return jsxRuntimeExports.jsx(ChatbotWidget, { widget: widget, showHeader: false, widgetBackendUrl: widgetBackendUrl, onResetReady: onResetReady, widgetIds: widgetIds, datasetId: datasetId });
|
|
40815
|
+
case "filters":
|
|
40816
|
+
return (jsxRuntimeExports.jsx(FiltersWidget, { widget: widget, showHeader: false, widgetBackendUrl: widgetBackendUrl, onResetReady: onResetReady, datasetId: datasetId, onConfigUpdate: handleConfigUpdate, onApplyFilters: onApplyFilters }));
|
|
40484
40817
|
case "agent":
|
|
40485
40818
|
return widget.config.agentType === "Pie Chart Agent" ? (jsxRuntimeExports.jsx(PieChartWidget, { widget: widget, showHeader: false, widgetBackendUrl: widgetBackendUrl, onResetReady: onResetReady, widgetIds: widgetIds, datasetId: datasetId })) : widget.config.agentType === "Series Bar Chart Agent" ? (jsxRuntimeExports.jsx(SeriesBarChartWidget, { widget: widget, showHeader: false, widgetBackendUrl: widgetBackendUrl, onResetReady: onResetReady, widgetIds: widgetIds, datasetId: datasetId })) : widget.config.agentType === "Series Line Chart Agent" ? (jsxRuntimeExports.jsx(SeriesLineChartWidget, { widget: widget, showHeader: false, widgetBackendUrl: widgetBackendUrl, onResetReady: onResetReady, widgetIds: widgetIds, datasetId: datasetId })) : widget.config.agentType === "Data Grid Agent" ? (jsxRuntimeExports.jsx(DatagridWidget, { widget: widget, showHeader: false, widgetBackendUrl: widgetBackendUrl, onResetReady: onResetReady, widgetIds: widgetIds, datasetId: datasetId })) : (jsxRuntimeExports.jsx(AgentWidget, { widget: widget, showHeader: false, widgetBackendUrl: widgetBackendUrl, onResetReady: onResetReady, widgetIds: widgetIds, datasetId: datasetId }));
|
|
40486
40819
|
default:
|
|
@@ -40704,6 +41037,13 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
40704
41037
|
icon: Bot,
|
|
40705
41038
|
description: 'Add an AI chatbot interface to your dashboard',
|
|
40706
41039
|
configRequired: false
|
|
41040
|
+
},
|
|
41041
|
+
{
|
|
41042
|
+
type: 'filters',
|
|
41043
|
+
title: 'Filters Widget',
|
|
41044
|
+
icon: SlidersHorizontal,
|
|
41045
|
+
description: 'Add filter groups with checkboxes to filter dashboard data',
|
|
41046
|
+
configRequired: true
|
|
40707
41047
|
}
|
|
40708
41048
|
];
|
|
40709
41049
|
const handleWidgetSelect = (widgetType) => {
|
|
@@ -40810,12 +41150,19 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
40810
41150
|
: {})),
|
|
40811
41151
|
};
|
|
40812
41152
|
}
|
|
41153
|
+
else if (selectedWidgetType === 'filters') {
|
|
41154
|
+
config = {
|
|
41155
|
+
query: query,
|
|
41156
|
+
agentName: "adk-filter-agent",
|
|
41157
|
+
agentType: "Filters Agent"
|
|
41158
|
+
};
|
|
41159
|
+
}
|
|
40813
41160
|
else {
|
|
40814
41161
|
config = {
|
|
40815
41162
|
agentName: defaultAgentName
|
|
40816
41163
|
};
|
|
40817
41164
|
}
|
|
40818
|
-
const type = selectedWidgetType === 'text' ? selectedWidgetType : "agent";
|
|
41165
|
+
const type = selectedWidgetType === 'text' || selectedWidgetType === 'filters' ? selectedWidgetType : "agent";
|
|
40819
41166
|
handleAddWidget(type, config);
|
|
40820
41167
|
};
|
|
40821
41168
|
const resetModal = () => {
|
|
@@ -40832,7 +41179,9 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
40832
41179
|
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));
|
|
40833
41180
|
}) })] })) : (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'
|
|
40834
41181
|
? 'Chatbot widget will be configured with the default agent.'
|
|
40835
|
-
: selectedWidgetType === 'text' ? "Customize the widget's appearance"
|
|
41182
|
+
: selectedWidgetType === 'text' ? "Customize the widget's appearance"
|
|
41183
|
+
: selectedWidgetType === 'filters' ? "Configure the filters widget:"
|
|
41184
|
+
: '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 === 'filters') && (jsxRuntimeExports.jsx("div", { className: "mb-6", children: jsxRuntimeExports.jsx(Textarea, { value: query, onChange: (e) => setQuery(e.target.value), placeholder: "e.g., Create filters for products and regions", 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" })] })] })) }) }) }));
|
|
40836
41185
|
}
|
|
40837
41186
|
|
|
40838
41187
|
const RGL = WidthProvider(Responsive);
|
|
@@ -40860,6 +41209,7 @@ const defaultLayouts = {
|
|
|
40860
41209
|
const IconMap = {
|
|
40861
41210
|
search: Search,
|
|
40862
41211
|
filter: Filter,
|
|
41212
|
+
filters: SlidersHorizontal,
|
|
40863
41213
|
results: LayoutGrid,
|
|
40864
41214
|
analytics: BarChart$1,
|
|
40865
41215
|
custom: LayoutGrid,
|
|
@@ -40871,7 +41221,7 @@ const IconMap = {
|
|
|
40871
41221
|
'pie-chart': PieChart$1,
|
|
40872
41222
|
'chatbot': Bot,
|
|
40873
41223
|
};
|
|
40874
|
-
function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSelect, refreshKey, widgetBackendUrl, onSaveLayoutReady, openWidgetPallete = false, onCloseWidgetPallete, defaultAgentName = "adk-construction-project-agent", userId }) {
|
|
41224
|
+
function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSelect, refreshKey, widgetBackendUrl, onSaveLayoutReady, openWidgetPallete = false, onCloseWidgetPallete, defaultAgentName = "adk-construction-project-agent", userId, onApplyFilters }) {
|
|
40875
41225
|
const [widgets, setWidgets] = useState([]);
|
|
40876
41226
|
const [datasetId, setDatasetId] = useState('');
|
|
40877
41227
|
const [availableWidgets, setAvailableWidgets] = useState([]);
|
|
@@ -40919,7 +41269,7 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
40919
41269
|
setEditingWidget(null);
|
|
40920
41270
|
// Trigger the agent by calling its appendMessage function
|
|
40921
41271
|
const widgetResetFn = widgetResetFunctions.get(editingWidget.id);
|
|
40922
|
-
if (widgetResetFn && editingWidget.type === 'agent') {
|
|
41272
|
+
if (widgetResetFn && (editingWidget.type === 'agent' || editingWidget.type === 'filters')) {
|
|
40923
41273
|
// Clear the chat first, then trigger with new query
|
|
40924
41274
|
try {
|
|
40925
41275
|
if (widgetBackendUrl) {
|
|
@@ -41117,6 +41467,8 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
41117
41467
|
return { w: 6, h: 4 };
|
|
41118
41468
|
case "chatbot":
|
|
41119
41469
|
return { w: 6, h: 6 };
|
|
41470
|
+
case "filters":
|
|
41471
|
+
return { w: 3, h: 8 };
|
|
41120
41472
|
default:
|
|
41121
41473
|
return { w: 6, h: 4 };
|
|
41122
41474
|
}
|
|
@@ -41255,7 +41607,8 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
41255
41607
|
'pie-chart': 'Pie Chart Widget',
|
|
41256
41608
|
'chatbot': 'Chatbot Widget',
|
|
41257
41609
|
'text': 'Text Widget',
|
|
41258
|
-
'spacer': 'Spacer Widget'
|
|
41610
|
+
'spacer': 'Spacer Widget',
|
|
41611
|
+
'filters': 'Filters Widget'
|
|
41259
41612
|
};
|
|
41260
41613
|
widgetTypeConfig = {
|
|
41261
41614
|
type: widgetType,
|
|
@@ -41353,16 +41706,10 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
41353
41706
|
var _a, _b;
|
|
41354
41707
|
return (jsxRuntimeExports.jsxs("div", { className: `${(w.type === "text" || w.type === "spacer") ? `${((_b = (_a = w === null || w === void 0 ? void 0 : w.config) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.divider) === "yes" && "border-b border-gray-300"} ${isEditing ? 'shadow-lg rounded-xl border border-primary-300' : 'flex items-center'}` : `shadow-lg rounded-xl border border-primary-300 p-4 ${isEditing ? 'pb-14' : 'pb-5'}`}`, children: [isEditing &&
|
|
41355
41708
|
jsxRuntimeExports.jsxs("div", { className: `flex items-center justify-end mb-4 relative ${(w.type === "text" || w.type === "spacer") ? "pl-4 pr-4 pt-4" : ""}`, children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center drag-icon cursor-grab absolute left-1/2 -translate-x-1/2", children: [jsxRuntimeExports.jsx(GripHorizontal, { className: "" }), jsxRuntimeExports.jsx(GripHorizontal, { className: "-ml-[3px]" }), jsxRuntimeExports.jsx(GripHorizontal, { className: "-ml-[3px]" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 cursor-pointer justify-end", children: [jsxRuntimeExports.jsx(Trash2, { onClick: () => removeWidget(w.id), className: "w-5 h-5 text-red-700" }), (w.type !== "spacer" && w.type !== "chatbot") && jsxRuntimeExports.jsx(Edit, { onClick: () => onClickSettings && onClickSettings(w), className: "w-5 h-5 text-gray-600" })] })] }), jsxRuntimeExports.jsxs("div", { className: `${((w === null || w === void 0 ? void 0 : w.type) === 'text' || (w === null || w === void 0 ? void 0 : w.type) === 'spacer') ? `${isEditing ? 'px-4' : ''}` : "h-full"} w-full relative`, children: [(w === null || w === void 0 ? void 0 : w.type) === "chatbot" &&
|
|
41356
|
-
jsxRuntimeExports.jsxs("div", { className: "relative z-50", children: [jsxRuntimeExports.jsx("div", { onClick: () => handleClearChat(w === null || w === void 0 ? void 0 : w.id), onMouseOver: () => setVisibleClearButton(w === null || w === void 0 ? void 0 : w.id), onMouseLeave: () => setVisibleClearButton(""), className: "absolute top-[12px] right-0 z-40 flex align-middle justify-center gap-2 text-sm px-4 py-2 border-primary-300 rounded-l-sm w-fit bg-primary-700 text-white cursor-pointer shadow-md transition-all", children: jsxRuntimeExports.jsx(MessageCircleX, { className: "w-5 h-5" }) }), jsxRuntimeExports.jsx("span", { className: `absolute top-[56px] right-[16px] z-50 w-max py-1 text-xs px-2 rounded-sm text-white bg-gray-950 ${visibleClearButton === (w === null || w === void 0 ? void 0 : w.id) ? "block" : "hidden"}`, children: "Clear Chat" })] }), jsxRuntimeExports.jsx(WidgetRenderer, { widget: w, widgetBackendUrl: widgetBackendUrl, onResetReady: handleResetReady, widgetIds: widgets.filter(widget => widget.type !== 'chatbot').map(widget => widget.id), datasetId: datasetId })] })] }, w.id));
|
|
41709
|
+
jsxRuntimeExports.jsxs("div", { className: "relative z-50", children: [jsxRuntimeExports.jsx("div", { onClick: () => handleClearChat(w === null || w === void 0 ? void 0 : w.id), onMouseOver: () => setVisibleClearButton(w === null || w === void 0 ? void 0 : w.id), onMouseLeave: () => setVisibleClearButton(""), className: "absolute top-[12px] right-0 z-40 flex align-middle justify-center gap-2 text-sm px-4 py-2 border-primary-300 rounded-l-sm w-fit bg-primary-700 text-white cursor-pointer shadow-md transition-all", children: jsxRuntimeExports.jsx(MessageCircleX, { className: "w-5 h-5" }) }), jsxRuntimeExports.jsx("span", { className: `absolute top-[56px] right-[16px] z-50 w-max py-1 text-xs px-2 rounded-sm text-white bg-gray-950 ${visibleClearButton === (w === null || w === void 0 ? void 0 : w.id) ? "block" : "hidden"}`, children: "Clear Chat" })] }), jsxRuntimeExports.jsx(WidgetRenderer, { widget: w, widgetBackendUrl: widgetBackendUrl, onResetReady: handleResetReady, widgetIds: widgets.filter(widget => widget.type !== 'chatbot').map(widget => widget.id), datasetId: datasetId, onApplyFilters: onApplyFilters })] })] }, w.id));
|
|
41357
41710
|
}) })) })] }));
|
|
41358
41711
|
}
|
|
41359
41712
|
|
|
41360
|
-
const Checkbox = React.forwardRef((_a, ref) => {
|
|
41361
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
41362
|
-
return (jsxRuntimeExports.jsx(CheckboxPrimitive.Root, Object.assign({ ref: ref, className: cn("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground", className) }, props, { children: jsxRuntimeExports.jsx(CheckboxPrimitive.Indicator, { className: cn("flex items-center justify-center text-current"), children: jsxRuntimeExports.jsx(Check, { className: "h-4 w-4" }) }) })));
|
|
41363
|
-
});
|
|
41364
|
-
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
|
|
41365
|
-
|
|
41366
41713
|
const Dialog = DialogPrimitive.Root;
|
|
41367
41714
|
const DialogPortal = DialogPrimitive.Portal;
|
|
41368
41715
|
const DialogOverlay = React.forwardRef((_a, ref) => {
|