dp-widgets-framework 1.5.0 → 1.5.3
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.js
CHANGED
|
@@ -17676,8 +17676,6 @@ function LineChart({ title, data, options, className, units, content }) {
|
|
|
17676
17676
|
function DataGrid({ title, data, className }) {
|
|
17677
17677
|
var _a;
|
|
17678
17678
|
const { columns, rows, units, grouped = false, grouping } = data;
|
|
17679
|
-
console.log('title==>', title);
|
|
17680
|
-
console.log('grouping==>', grouping);
|
|
17681
17679
|
const [expandedGroups, setExpandedGroups] = React.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)) || []));
|
|
17682
17680
|
const toggleGroup = (groupValue) => {
|
|
17683
17681
|
const newExpanded = new Set(expandedGroups);
|
|
@@ -38439,7 +38437,7 @@ function SummaryWidget({ title, data, metadata, className }) {
|
|
|
38439
38437
|
const CHART_REFRESH_TIMEOUT$4 = 3000;
|
|
38440
38438
|
const DEFAULT_COLORS$3 = ["#E4DCB8", "#DAC46C", "#808080", "#582809", "#A3ADD0", "#398E6F", "#AF123D", "#8C99C4", "#5290AC", "#601B07", "#50649D", "#B4A8A0", "#6F2587"];
|
|
38441
38439
|
const LINE_COLORS = ["#243D84", "#69238B", "#4A959F", "#D0A677", "#B31E47", "#396431"];
|
|
38442
|
-
const clearChat$
|
|
38440
|
+
const clearChat$5 = async (widgetBackendUrl, widgetId) => {
|
|
38443
38441
|
if (!widgetBackendUrl || !widgetId)
|
|
38444
38442
|
return;
|
|
38445
38443
|
console.log('clearChat called for widgetId:', widgetId);
|
|
@@ -38461,7 +38459,7 @@ const clearChat$4 = async (widgetBackendUrl, widgetId) => {
|
|
|
38461
38459
|
console.error('Failed to clear chat:', error);
|
|
38462
38460
|
}
|
|
38463
38461
|
};
|
|
38464
|
-
const createLoadingComponent$
|
|
38462
|
+
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(lucideReact.RefreshCw, { className: "h-6 w-6 animate-spin text-gray-800" }), jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500", children: message })] }) }));
|
|
38465
38463
|
const createInitialChartState$4 = (agentType, widgetIds, datasetId) => {
|
|
38466
38464
|
const baseState = { dataset_id: datasetId || "home_generation_dataset" };
|
|
38467
38465
|
switch (agentType) {
|
|
@@ -38519,7 +38517,7 @@ const createInitialChartState$4 = (agentType, widgetIds, datasetId) => {
|
|
|
38519
38517
|
return Object.assign({ widget_ids: widgetIds }, baseState);
|
|
38520
38518
|
}
|
|
38521
38519
|
};
|
|
38522
|
-
const loadAgentState$
|
|
38520
|
+
const loadAgentState$5 = async (widgetBackendUrl, threadId, agentName) => {
|
|
38523
38521
|
try {
|
|
38524
38522
|
const response = await fetch(`${widgetBackendUrl}/api/copilot/${agentName}`, {
|
|
38525
38523
|
method: 'POST',
|
|
@@ -38625,7 +38623,7 @@ function BarChartComponent({ orientation, barChartState, styles, appendMessage,
|
|
|
38625
38623
|
const isEmpty = labels.length === 0 || values.length === 0;
|
|
38626
38624
|
const handleRefresh = async () => {
|
|
38627
38625
|
if (query && widgetBackendUrl && widgetId) {
|
|
38628
|
-
await clearChat$
|
|
38626
|
+
await clearChat$5(widgetBackendUrl, widgetId);
|
|
38629
38627
|
appendMessage(new TextMessage({
|
|
38630
38628
|
content: `${query} and render data on a bar chart`,
|
|
38631
38629
|
role: Role.User,
|
|
@@ -38652,7 +38650,7 @@ function BarChartComponent({ orientation, barChartState, styles, appendMessage,
|
|
|
38652
38650
|
return shuffleColors(DEFAULT_COLORS$3, labels === null || labels === void 0 ? void 0 : labels.length);
|
|
38653
38651
|
}, [labels.length]);
|
|
38654
38652
|
if (isEmpty) {
|
|
38655
|
-
return createLoadingComponent$
|
|
38653
|
+
return createLoadingComponent$5();
|
|
38656
38654
|
}
|
|
38657
38655
|
const transformedData = {
|
|
38658
38656
|
labels: labels,
|
|
@@ -38678,7 +38676,7 @@ function SeriesBarChartComponent$2({ orientation, seriesBarChartState, styles, a
|
|
|
38678
38676
|
const isEmpty = labels.length === 0 || series.length === 0;
|
|
38679
38677
|
const handleRefresh = async () => {
|
|
38680
38678
|
if (query) {
|
|
38681
|
-
await clearChat$
|
|
38679
|
+
await clearChat$5(widgetBackendUrl, widgetId);
|
|
38682
38680
|
// Send trigger event to clear chart state
|
|
38683
38681
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
38684
38682
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -38707,7 +38705,7 @@ function SeriesBarChartComponent$2({ orientation, seriesBarChartState, styles, a
|
|
|
38707
38705
|
return shuffleColors(DEFAULT_COLORS$3, series === null || series === void 0 ? void 0 : series.length);
|
|
38708
38706
|
}, [series.length]);
|
|
38709
38707
|
if (isEmpty) {
|
|
38710
|
-
return createLoadingComponent$
|
|
38708
|
+
return createLoadingComponent$5();
|
|
38711
38709
|
}
|
|
38712
38710
|
const transformedData = {
|
|
38713
38711
|
labels: labels,
|
|
@@ -38731,7 +38729,7 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
|
|
|
38731
38729
|
const isEmpty = labels.length === 0 || series.length === 0;
|
|
38732
38730
|
const handleRefresh = async () => {
|
|
38733
38731
|
if (query) {
|
|
38734
|
-
await clearChat$
|
|
38732
|
+
await clearChat$5(widgetBackendUrl, widgetId);
|
|
38735
38733
|
// Send trigger event to clear chart state
|
|
38736
38734
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
38737
38735
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -38760,7 +38758,7 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
|
|
|
38760
38758
|
return shuffleColors([...LINE_COLORS, ...DEFAULT_COLORS$3], series === null || series === void 0 ? void 0 : series.length);
|
|
38761
38759
|
}, [series.length]);
|
|
38762
38760
|
if (isEmpty) {
|
|
38763
|
-
return createLoadingComponent$
|
|
38761
|
+
return createLoadingComponent$5();
|
|
38764
38762
|
}
|
|
38765
38763
|
const transformedData = {
|
|
38766
38764
|
labels: labels,
|
|
@@ -38790,7 +38788,7 @@ function PieChartComponent$1({ pieChartState, styles, appendMessage, query, isFi
|
|
|
38790
38788
|
const isEmpty = labels.length === 0 || values.length === 0;
|
|
38791
38789
|
const handleRefresh = async () => {
|
|
38792
38790
|
if (query) {
|
|
38793
|
-
await clearChat$
|
|
38791
|
+
await clearChat$5(widgetBackendUrl, widgetId);
|
|
38794
38792
|
// Send trigger event to clear chart state
|
|
38795
38793
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
38796
38794
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -38819,7 +38817,7 @@ function PieChartComponent$1({ pieChartState, styles, appendMessage, query, isFi
|
|
|
38819
38817
|
return shuffleColors(DEFAULT_COLORS$3, labels.length);
|
|
38820
38818
|
}, [labels.length]);
|
|
38821
38819
|
if (isEmpty) {
|
|
38822
|
-
return createLoadingComponent$
|
|
38820
|
+
return createLoadingComponent$5();
|
|
38823
38821
|
}
|
|
38824
38822
|
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]);
|
|
38825
38823
|
const transformedData = {
|
|
@@ -38846,7 +38844,7 @@ function LineChartComponent({ lineChartState, styles, appendMessage, query, isFi
|
|
|
38846
38844
|
const isEmpty = labels.length === 0 || values.length === 0;
|
|
38847
38845
|
const handleRefresh = async () => {
|
|
38848
38846
|
if (query && widgetBackendUrl && widgetId) {
|
|
38849
|
-
await clearChat$
|
|
38847
|
+
await clearChat$5(widgetBackendUrl, widgetId);
|
|
38850
38848
|
appendMessage(new TextMessage({
|
|
38851
38849
|
content: `${query} and render data on a bar chart`,
|
|
38852
38850
|
role: Role.User,
|
|
@@ -38872,7 +38870,7 @@ function LineChartComponent({ lineChartState, styles, appendMessage, query, isFi
|
|
|
38872
38870
|
return LINE_COLORS[Math.floor(Math.random() * LINE_COLORS.length)];
|
|
38873
38871
|
}, [labels.length]);
|
|
38874
38872
|
if (isEmpty) {
|
|
38875
|
-
return createLoadingComponent$
|
|
38873
|
+
return createLoadingComponent$5();
|
|
38876
38874
|
}
|
|
38877
38875
|
const transformedData = {
|
|
38878
38876
|
labels: labels,
|
|
@@ -38902,7 +38900,7 @@ function DataGridComponent$1({ dataGridState, styles, appendMessage, query, isFi
|
|
|
38902
38900
|
const isEmpty = columns.length === 0 || rows.length === 0;
|
|
38903
38901
|
const handleRefresh = async () => {
|
|
38904
38902
|
if (query) {
|
|
38905
|
-
await clearChat$
|
|
38903
|
+
await clearChat$5(widgetBackendUrl, widgetId);
|
|
38906
38904
|
// Send trigger event to clear chart state
|
|
38907
38905
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
38908
38906
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -38928,7 +38926,7 @@ function DataGridComponent$1({ dataGridState, styles, appendMessage, query, isFi
|
|
|
38928
38926
|
}
|
|
38929
38927
|
}, [isEmpty, startLoadingTimeout, clearLoadingTimeout]);
|
|
38930
38928
|
if (isEmpty) {
|
|
38931
|
-
return createLoadingComponent$
|
|
38929
|
+
return createLoadingComponent$5("Loading table data...");
|
|
38932
38930
|
}
|
|
38933
38931
|
const transformedData = {
|
|
38934
38932
|
columns: columns,
|
|
@@ -38949,7 +38947,7 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
38949
38947
|
const isEmpty = !content || content.trim() === "";
|
|
38950
38948
|
const handleRefresh = async () => {
|
|
38951
38949
|
if (query) {
|
|
38952
|
-
await clearChat$
|
|
38950
|
+
await clearChat$5(widgetBackendUrl, widgetId);
|
|
38953
38951
|
// Send trigger event to clear chart state
|
|
38954
38952
|
console.log('Dispatching clearChartState event for widgetId:', widgetId);
|
|
38955
38953
|
window.dispatchEvent(new CustomEvent('clearChartState', { detail: { widgetId } }));
|
|
@@ -38978,7 +38976,7 @@ function SummaryComponent({ summaryState, styles, appendMessage, query, isFirstL
|
|
|
38978
38976
|
}
|
|
38979
38977
|
}, [isEmpty, startLoadingTimeout, clearLoadingTimeout]);
|
|
38980
38978
|
if (isEmpty) {
|
|
38981
|
-
return createLoadingComponent$
|
|
38979
|
+
return createLoadingComponent$5("Loading summary...");
|
|
38982
38980
|
}
|
|
38983
38981
|
return (jsxRuntimeExports.jsx(SummaryWidget, { title: title, data: data, metadata: metadata, className: "" }));
|
|
38984
38982
|
}
|
|
@@ -39017,7 +39015,7 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
|
|
|
39017
39015
|
// Increment the API call counter
|
|
39018
39016
|
setApiCallCount(prev => prev + 1);
|
|
39019
39017
|
const agentName = ((_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentName) || "adk-construction-project-agent";
|
|
39020
|
-
const apiResponse = await loadAgentState$
|
|
39018
|
+
const apiResponse = await loadAgentState$5(widgetBackendUrl, widget.id, agentName);
|
|
39021
39019
|
if (apiResponse && !(chartState === null || chartState === void 0 ? void 0 : chartState.agent_message)) {
|
|
39022
39020
|
parseAndUpdateChartState$4(apiResponse, setChartState);
|
|
39023
39021
|
}
|
|
@@ -39275,6 +39273,339 @@ function ChatbotWidget({ widget, showHeader = true, widgetBackendUrl, onResetRea
|
|
|
39275
39273
|
return (jsxRuntimeExports.jsx(reactCore.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 }) }));
|
|
39276
39274
|
}
|
|
39277
39275
|
|
|
39276
|
+
const Checkbox = React__namespace.forwardRef((_a, ref) => {
|
|
39277
|
+
var { className } = _a, props = __rest(_a, ["className"]);
|
|
39278
|
+
return (jsxRuntimeExports.jsx(CheckboxPrimitive__namespace.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__namespace.Indicator, { className: cn("flex items-center justify-center text-current"), children: jsxRuntimeExports.jsx(lucideReact.Check, { className: "h-4 w-4" }) }) })));
|
|
39279
|
+
});
|
|
39280
|
+
Checkbox.displayName = CheckboxPrimitive__namespace.Root.displayName;
|
|
39281
|
+
|
|
39282
|
+
const FILTER_REFRESH_TIMEOUT = 3000;
|
|
39283
|
+
const clearChat$4 = async (widgetBackendUrl, widgetId) => {
|
|
39284
|
+
if (!widgetBackendUrl || !widgetId)
|
|
39285
|
+
return;
|
|
39286
|
+
console.log('clearChat called for widgetId:', widgetId);
|
|
39287
|
+
try {
|
|
39288
|
+
await fetch(`${widgetBackendUrl}/api/clear-chat`, {
|
|
39289
|
+
method: 'POST',
|
|
39290
|
+
headers: {
|
|
39291
|
+
'Content-Type': 'application/json',
|
|
39292
|
+
},
|
|
39293
|
+
body: JSON.stringify({
|
|
39294
|
+
session_id: widgetId,
|
|
39295
|
+
delete_state: true
|
|
39296
|
+
}),
|
|
39297
|
+
});
|
|
39298
|
+
console.log('Dispatching clearFilterState event from clearChat for widgetId:', widgetId);
|
|
39299
|
+
window.dispatchEvent(new CustomEvent('clearFilterState', { detail: { widgetId } }));
|
|
39300
|
+
}
|
|
39301
|
+
catch (error) {
|
|
39302
|
+
console.error('Failed to clear chat:', error);
|
|
39303
|
+
}
|
|
39304
|
+
};
|
|
39305
|
+
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(lucideReact.RefreshCw, { className: "h-6 w-6 animate-spin text-gray-800" }), jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500", children: message })] }) }));
|
|
39306
|
+
const createInitialFilterState = (datasetId, filterData) => {
|
|
39307
|
+
return {
|
|
39308
|
+
column_values: filterData || [],
|
|
39309
|
+
dataset_id: datasetId || ""
|
|
39310
|
+
};
|
|
39311
|
+
};
|
|
39312
|
+
const loadAgentState$4 = async (widgetBackendUrl, threadId, agentName) => {
|
|
39313
|
+
try {
|
|
39314
|
+
const response = await fetch(`${widgetBackendUrl}/api/copilot/${agentName}`, {
|
|
39315
|
+
method: 'POST',
|
|
39316
|
+
headers: {
|
|
39317
|
+
'Content-Type': 'application/json',
|
|
39318
|
+
},
|
|
39319
|
+
body: JSON.stringify({
|
|
39320
|
+
"operationName": "loadAgentState",
|
|
39321
|
+
"query": "query loadAgentState($data: LoadAgentStateInput!) {\n loadAgentState(data: $data) {\n threadId\n threadExists\n state\n messages\n __typename\n }\n}",
|
|
39322
|
+
"variables": {
|
|
39323
|
+
"data": {
|
|
39324
|
+
"agentName": agentName,
|
|
39325
|
+
"threadId": threadId
|
|
39326
|
+
}
|
|
39327
|
+
}
|
|
39328
|
+
}),
|
|
39329
|
+
});
|
|
39330
|
+
if (!response.ok) {
|
|
39331
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
39332
|
+
}
|
|
39333
|
+
const result = await response.json();
|
|
39334
|
+
return result;
|
|
39335
|
+
}
|
|
39336
|
+
catch (error) {
|
|
39337
|
+
console.error('Failed to load agent state:', error);
|
|
39338
|
+
return null;
|
|
39339
|
+
}
|
|
39340
|
+
};
|
|
39341
|
+
const parseAndUpdateFilterState = (apiResponse, setFilterState) => {
|
|
39342
|
+
var _a, _b;
|
|
39343
|
+
try {
|
|
39344
|
+
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) {
|
|
39345
|
+
const stateString = apiResponse.data.loadAgentState.state;
|
|
39346
|
+
const parsedState = JSON.parse(stateString);
|
|
39347
|
+
if (parsedState.state) {
|
|
39348
|
+
const filterData = parsedState.state;
|
|
39349
|
+
setFilterState((prevState) => {
|
|
39350
|
+
const newFilterState = Object.assign({}, prevState);
|
|
39351
|
+
if (filterData.column_values) {
|
|
39352
|
+
newFilterState.column_values = filterData.column_values;
|
|
39353
|
+
}
|
|
39354
|
+
if (filterData.agent_message) {
|
|
39355
|
+
newFilterState.agent_message = filterData.agent_message;
|
|
39356
|
+
}
|
|
39357
|
+
return newFilterState;
|
|
39358
|
+
});
|
|
39359
|
+
}
|
|
39360
|
+
}
|
|
39361
|
+
}
|
|
39362
|
+
catch (error) {
|
|
39363
|
+
console.error('Failed to parse and update filter state:', error);
|
|
39364
|
+
}
|
|
39365
|
+
};
|
|
39366
|
+
// Helper function to convert FilterState to FilterGroup array
|
|
39367
|
+
const convertFilterStateToGroups = (filterState) => {
|
|
39368
|
+
if (!filterState.column_values || filterState.column_values.length === 0) {
|
|
39369
|
+
return [];
|
|
39370
|
+
}
|
|
39371
|
+
return filterState.column_values.map((filter) => ({
|
|
39372
|
+
id: `${filter.column}`,
|
|
39373
|
+
name: filter.column.replace(/_/g, ' ').replace(/\b\w/g, (l) => l.toUpperCase()),
|
|
39374
|
+
options: filter.values.map((value) => ({
|
|
39375
|
+
id: value.toLowerCase().replace(/\s+/g, '-'),
|
|
39376
|
+
label: value,
|
|
39377
|
+
})),
|
|
39378
|
+
}));
|
|
39379
|
+
};
|
|
39380
|
+
function FiltersContent({ filterGroups, showHeader, onFilterChange, widget, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout, filterState, onApplyFilters, }) {
|
|
39381
|
+
const hasCalledRef = React.useRef(false);
|
|
39382
|
+
const [expandedGroups, setExpandedGroups] = React.useState({});
|
|
39383
|
+
const [selectedFilters, setSelectedFilters] = React.useState({});
|
|
39384
|
+
const [searchQueries, setSearchQueries] = React.useState({});
|
|
39385
|
+
const isEmpty = filterGroups.length === 0;
|
|
39386
|
+
const handleRefresh = async () => {
|
|
39387
|
+
if (query) {
|
|
39388
|
+
await clearChat$4(widgetBackendUrl, widgetId);
|
|
39389
|
+
console.log('Dispatching clearFilterState event for widgetId:', widgetId);
|
|
39390
|
+
window.dispatchEvent(new CustomEvent('clearFilterState', { detail: { widgetId } }));
|
|
39391
|
+
appendMessage(new TextMessage({
|
|
39392
|
+
content: `${query}`,
|
|
39393
|
+
role: Role.User,
|
|
39394
|
+
}));
|
|
39395
|
+
}
|
|
39396
|
+
};
|
|
39397
|
+
React.useEffect(() => {
|
|
39398
|
+
if (isEmpty && query && isFirstLoad && !(filterState === null || filterState === void 0 ? void 0 : filterState.agent_message) && !hasCalledRef.current) {
|
|
39399
|
+
hasCalledRef.current = true;
|
|
39400
|
+
handleRefresh();
|
|
39401
|
+
}
|
|
39402
|
+
}, [isEmpty, query, isFirstLoad, filterState]);
|
|
39403
|
+
React.useEffect(() => {
|
|
39404
|
+
console.log('FiltersContent useEffect - isEmpty:', isEmpty, 'hasMessage:', !!(filterState === null || filterState === void 0 ? void 0 : filterState.agent_message), 'isFirstLoad:', isFirstLoad);
|
|
39405
|
+
if (isEmpty && startLoadingTimeout && !(filterState === null || filterState === void 0 ? void 0 : filterState.agent_message)) {
|
|
39406
|
+
console.log('Starting loading timeout from FiltersContent useEffect');
|
|
39407
|
+
startLoadingTimeout();
|
|
39408
|
+
}
|
|
39409
|
+
else if (!isEmpty && clearLoadingTimeout) {
|
|
39410
|
+
clearLoadingTimeout();
|
|
39411
|
+
}
|
|
39412
|
+
}, [isEmpty, startLoadingTimeout, clearLoadingTimeout, filterState]);
|
|
39413
|
+
// Initialize expanded state for all groups
|
|
39414
|
+
React.useEffect(() => {
|
|
39415
|
+
const initialExpanded = {};
|
|
39416
|
+
filterGroups.forEach((group) => {
|
|
39417
|
+
var _a;
|
|
39418
|
+
initialExpanded[group.id] = ((_a = widget.config) === null || _a === void 0 ? void 0 : _a.defaultExpanded) !== false;
|
|
39419
|
+
});
|
|
39420
|
+
setExpandedGroups(initialExpanded);
|
|
39421
|
+
}, [filterGroups]);
|
|
39422
|
+
const toggleGroup = (groupId) => {
|
|
39423
|
+
setExpandedGroups((prev) => (Object.assign(Object.assign({}, prev), { [groupId]: !prev[groupId] })));
|
|
39424
|
+
};
|
|
39425
|
+
const handleCheckboxChange = (groupId, optionId, checked) => {
|
|
39426
|
+
setSelectedFilters((prev) => {
|
|
39427
|
+
const groupFilters = prev[groupId] || [];
|
|
39428
|
+
let newGroupFilters;
|
|
39429
|
+
if (checked) {
|
|
39430
|
+
newGroupFilters = [...groupFilters, optionId];
|
|
39431
|
+
}
|
|
39432
|
+
else {
|
|
39433
|
+
newGroupFilters = groupFilters.filter((id) => id !== optionId);
|
|
39434
|
+
}
|
|
39435
|
+
const newFilters = Object.assign(Object.assign({}, prev), { [groupId]: newGroupFilters });
|
|
39436
|
+
if (onFilterChange) {
|
|
39437
|
+
onFilterChange(newFilters);
|
|
39438
|
+
}
|
|
39439
|
+
return newFilters;
|
|
39440
|
+
});
|
|
39441
|
+
};
|
|
39442
|
+
const handleSearchChange = (groupId, query) => {
|
|
39443
|
+
setSearchQueries((prev) => (Object.assign(Object.assign({}, prev), { [groupId]: query })));
|
|
39444
|
+
};
|
|
39445
|
+
const getFilteredOptions = (group) => {
|
|
39446
|
+
var _a;
|
|
39447
|
+
const query = ((_a = searchQueries[group.id]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || "";
|
|
39448
|
+
if (!query)
|
|
39449
|
+
return group.options;
|
|
39450
|
+
return group.options.filter((option) => option.label.toLowerCase().includes(query));
|
|
39451
|
+
};
|
|
39452
|
+
const getSelectedCount = (groupId) => {
|
|
39453
|
+
var _a;
|
|
39454
|
+
return ((_a = selectedFilters[groupId]) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
39455
|
+
};
|
|
39456
|
+
const clearGroupFilters = (groupId) => {
|
|
39457
|
+
setSelectedFilters((prev) => {
|
|
39458
|
+
const newFilters = Object.assign(Object.assign({}, prev), { [groupId]: [] });
|
|
39459
|
+
if (onFilterChange) {
|
|
39460
|
+
onFilterChange(newFilters);
|
|
39461
|
+
}
|
|
39462
|
+
return newFilters;
|
|
39463
|
+
});
|
|
39464
|
+
};
|
|
39465
|
+
if (isEmpty) {
|
|
39466
|
+
return createLoadingComponent$4();
|
|
39467
|
+
}
|
|
39468
|
+
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(lucideReact.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) => {
|
|
39469
|
+
const isExpanded = expandedGroups[group.id];
|
|
39470
|
+
const selectedCount = getSelectedCount(group.id);
|
|
39471
|
+
const filteredOptions = getFilteredOptions(group);
|
|
39472
|
+
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(lucideReact.ChevronDown, { className: "w-4 h-4 text-primary-600" })) : (jsxRuntimeExports.jsx(lucideReact.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) => {
|
|
39473
|
+
e.stopPropagation();
|
|
39474
|
+
clearGroupFilters(group.id);
|
|
39475
|
+
}, 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(lucideReact.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) => {
|
|
39476
|
+
var _a;
|
|
39477
|
+
const isChecked = ((_a = selectedFilters[group.id]) === null || _a === void 0 ? void 0 : _a.includes(option.id)) || false;
|
|
39478
|
+
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));
|
|
39479
|
+
})) })] }) })] }, group.id));
|
|
39480
|
+
}) }) }), 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: () => {
|
|
39481
|
+
setSelectedFilters({});
|
|
39482
|
+
if (onFilterChange) {
|
|
39483
|
+
onFilterChange({});
|
|
39484
|
+
}
|
|
39485
|
+
}, 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" })] }) })] }));
|
|
39486
|
+
}
|
|
39487
|
+
function CopilotKitFilters({ widget, showHeader, onFilterChange, onResetReady, widgetBackendUrl, datasetId, onApplyFilters, }) {
|
|
39488
|
+
var _a, _b, _c, _d, _e, _f;
|
|
39489
|
+
const isFirstLoad = (_a = widget.config) === null || _a === void 0 ? void 0 : _a.isFirstLoad;
|
|
39490
|
+
const widget_data = (_b = widget.widget_data) === null || _b === void 0 ? void 0 : _b.column_values;
|
|
39491
|
+
const { setThreadId } = reactCore.useCopilotContext();
|
|
39492
|
+
const timeoutRef = React.useRef(null);
|
|
39493
|
+
const [apiCallCount, setApiCallCount] = React.useState(0);
|
|
39494
|
+
const [hasTimeoutError, setHasTimeoutError] = React.useState(false);
|
|
39495
|
+
React.useEffect(() => {
|
|
39496
|
+
setThreadId(widget.id);
|
|
39497
|
+
}, [widget.id, setThreadId]);
|
|
39498
|
+
const { state: agentState, setState: setAgentState } = reactCore.useCoAgent({
|
|
39499
|
+
name: (_c = widget.config) === null || _c === void 0 ? void 0 : _c.agentName,
|
|
39500
|
+
initialState: createInitialFilterState(datasetId, widget_data),
|
|
39501
|
+
});
|
|
39502
|
+
const [filterState, setFilterState] = React.useState(createInitialFilterState(datasetId, widget_data));
|
|
39503
|
+
const handleLoadingTimeout = React.useCallback(async () => {
|
|
39504
|
+
var _a;
|
|
39505
|
+
if (!widgetBackendUrl || !widget.id || (filterState === null || filterState === void 0 ? void 0 : filterState.agent_message) || hasTimeoutError) {
|
|
39506
|
+
console.log('Skipping API call - conditions not met');
|
|
39507
|
+
return;
|
|
39508
|
+
}
|
|
39509
|
+
console.log('Loading timeout triggered for widget:', widget.id, 'API call count:', apiCallCount);
|
|
39510
|
+
if (apiCallCount >= 30) {
|
|
39511
|
+
console.log('API call limit reached for widget:', widget.id);
|
|
39512
|
+
setHasTimeoutError(true);
|
|
39513
|
+
setFilterState(prevState => (Object.assign(Object.assign({}, prevState), { agent_message: "Timeout: Unable to load filter data after multiple attempts. Please try refreshing the widget." })));
|
|
39514
|
+
return;
|
|
39515
|
+
}
|
|
39516
|
+
setApiCallCount(prev => prev + 1);
|
|
39517
|
+
const agentName = ((_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentName) || "adk-construction-project-agent";
|
|
39518
|
+
console.log('Calling loadAgentState API for widget:', widget.id);
|
|
39519
|
+
const apiResponse = await loadAgentState$4(widgetBackendUrl, widget.id, agentName);
|
|
39520
|
+
console.log('API response received:', apiResponse);
|
|
39521
|
+
if (apiResponse && !(filterState === null || filterState === void 0 ? void 0 : filterState.agent_message)) {
|
|
39522
|
+
parseAndUpdateFilterState(apiResponse, setFilterState);
|
|
39523
|
+
}
|
|
39524
|
+
}, [widgetBackendUrl, widget.id, setFilterState, (_d = widget.config) === null || _d === void 0 ? void 0 : _d.agentName, filterState, apiCallCount, hasTimeoutError]);
|
|
39525
|
+
const startLoadingTimeout = React.useCallback(() => {
|
|
39526
|
+
if (timeoutRef.current) {
|
|
39527
|
+
clearTimeout(timeoutRef.current);
|
|
39528
|
+
}
|
|
39529
|
+
console.log('Scheduling next API call in 3 seconds');
|
|
39530
|
+
timeoutRef.current = setTimeout(() => {
|
|
39531
|
+
handleLoadingTimeout();
|
|
39532
|
+
}, FILTER_REFRESH_TIMEOUT);
|
|
39533
|
+
}, [handleLoadingTimeout]);
|
|
39534
|
+
const clearLoadingTimeout = React.useCallback(() => {
|
|
39535
|
+
if (timeoutRef.current) {
|
|
39536
|
+
clearTimeout(timeoutRef.current);
|
|
39537
|
+
timeoutRef.current = null;
|
|
39538
|
+
}
|
|
39539
|
+
}, []);
|
|
39540
|
+
React.useEffect(() => {
|
|
39541
|
+
return () => {
|
|
39542
|
+
if (timeoutRef.current) {
|
|
39543
|
+
clearTimeout(timeoutRef.current);
|
|
39544
|
+
}
|
|
39545
|
+
};
|
|
39546
|
+
}, []);
|
|
39547
|
+
const { appendMessage, reset } = reactCore.useCopilotChat();
|
|
39548
|
+
React.useEffect(() => {
|
|
39549
|
+
if (onResetReady && reset && widget.id) {
|
|
39550
|
+
const wrappedReset = () => {
|
|
39551
|
+
reset();
|
|
39552
|
+
window.dispatchEvent(new CustomEvent('clearFilterState', { detail: { widgetId: widget.id } }));
|
|
39553
|
+
};
|
|
39554
|
+
onResetReady(widget.id, wrappedReset);
|
|
39555
|
+
}
|
|
39556
|
+
}, [reset, widget.id, onResetReady]);
|
|
39557
|
+
React.useEffect(() => {
|
|
39558
|
+
const handleTriggerAgent = (event) => {
|
|
39559
|
+
const { widgetId, query, datasetId } = event.detail;
|
|
39560
|
+
reset();
|
|
39561
|
+
if (widgetId === widget.id) {
|
|
39562
|
+
let messageContent = `${query}`;
|
|
39563
|
+
console.log('triggering to datasetId==>', datasetId);
|
|
39564
|
+
setFilterState(createInitialFilterState(datasetId));
|
|
39565
|
+
setAgentState(createInitialFilterState(datasetId));
|
|
39566
|
+
setApiCallCount(0);
|
|
39567
|
+
setHasTimeoutError(false);
|
|
39568
|
+
appendMessage(new TextMessage({
|
|
39569
|
+
content: messageContent,
|
|
39570
|
+
role: Role.User,
|
|
39571
|
+
}));
|
|
39572
|
+
// Start polling for filter data
|
|
39573
|
+
startLoadingTimeout();
|
|
39574
|
+
}
|
|
39575
|
+
};
|
|
39576
|
+
const handleClearFilterState = (event) => {
|
|
39577
|
+
const { widgetId } = event.detail;
|
|
39578
|
+
if (widgetId === widget.id) {
|
|
39579
|
+
setFilterState(createInitialFilterState(datasetId));
|
|
39580
|
+
setAgentState(createInitialFilterState(datasetId));
|
|
39581
|
+
setApiCallCount(0);
|
|
39582
|
+
setHasTimeoutError(false);
|
|
39583
|
+
}
|
|
39584
|
+
};
|
|
39585
|
+
window.addEventListener('triggerAgent', handleTriggerAgent);
|
|
39586
|
+
window.addEventListener('clearFilterState', handleClearFilterState);
|
|
39587
|
+
return () => {
|
|
39588
|
+
window.removeEventListener('triggerAgent', handleTriggerAgent);
|
|
39589
|
+
window.removeEventListener('clearFilterState', handleClearFilterState);
|
|
39590
|
+
};
|
|
39591
|
+
}, [widget.id, appendMessage, setFilterState, startLoadingTimeout]);
|
|
39592
|
+
// Convert filter state to filter groups
|
|
39593
|
+
const filterGroups = convertFilterStateToGroups(filterState);
|
|
39594
|
+
return (jsxRuntimeExports.jsx("div", { className: cn("flex flex-col h-full"), children: (filterState === null || filterState === void 0 ? void 0 : filterState.agent_message) &&
|
|
39595
|
+
(!((_e = filterState.column_values) === null || _e === void 0 ? void 0 : _e.length))
|
|
39596
|
+
? (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 })) }));
|
|
39597
|
+
}
|
|
39598
|
+
function FiltersWidget({ widget, showHeader = true, onConfigUpdate, onFilterChange, widgetBackendUrl, onResetReady, datasetId, onApplyFilters, }) {
|
|
39599
|
+
var _a;
|
|
39600
|
+
const getRuntimeUrl = () => {
|
|
39601
|
+
var _a;
|
|
39602
|
+
const baseUrl = widgetBackendUrl || '';
|
|
39603
|
+
const agentName = ((_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentName) || 'default-agent';
|
|
39604
|
+
return `${baseUrl}/api/copilot/${agentName}`;
|
|
39605
|
+
};
|
|
39606
|
+
return (jsxRuntimeExports.jsx(reactCore.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 }) }));
|
|
39607
|
+
}
|
|
39608
|
+
|
|
39278
39609
|
const CHART_REFRESH_TIMEOUT$3 = 3000;
|
|
39279
39610
|
const DEFAULT_COLORS$2 = ["#E4DCB8", "#DAC46C", "#808080", "#582809", "#A3ADD0", "#398E6F", "#AF123D", "#8C99C4", "#5290AC", "#601B07", "#50649D", "#B4A8A0", "#6F2587"];
|
|
39280
39611
|
const clearChat$3 = async (widgetBackendUrl, widgetId) => {
|
|
@@ -40483,7 +40814,7 @@ function DatagridWidget({ widget, showHeader = true, widgetBackendUrl, onResetRe
|
|
|
40483
40814
|
return (jsxRuntimeExports.jsx(reactCore.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 }) }));
|
|
40484
40815
|
}
|
|
40485
40816
|
|
|
40486
|
-
function WidgetRenderer({ widget, isTemplate = false, onConfigUpdate, widgetBackendUrl, onResetReady, widgetIds, datasetId, }) {
|
|
40817
|
+
function WidgetRenderer({ widget, isTemplate = false, onConfigUpdate, widgetBackendUrl, onResetReady, widgetIds, datasetId, onApplyFilters, }) {
|
|
40487
40818
|
const handleConfigUpdate = (config) => {
|
|
40488
40819
|
if (onConfigUpdate) {
|
|
40489
40820
|
onConfigUpdate(widget.id, config);
|
|
@@ -40508,6 +40839,8 @@ function WidgetRenderer({ widget, isTemplate = false, onConfigUpdate, widgetBack
|
|
|
40508
40839
|
return (jsxRuntimeExports.jsx(FacetWidget, { widget: widget, showHeader: false, onConfigUpdate: handleConfigUpdate }));
|
|
40509
40840
|
case "chatbot":
|
|
40510
40841
|
return jsxRuntimeExports.jsx(ChatbotWidget, { widget: widget, showHeader: false, widgetBackendUrl: widgetBackendUrl, onResetReady: onResetReady, widgetIds: widgetIds, datasetId: datasetId });
|
|
40842
|
+
case "filters":
|
|
40843
|
+
return (jsxRuntimeExports.jsx(FiltersWidget, { widget: widget, showHeader: false, widgetBackendUrl: widgetBackendUrl, onResetReady: onResetReady, datasetId: datasetId, onConfigUpdate: handleConfigUpdate, onApplyFilters: onApplyFilters }));
|
|
40511
40844
|
case "agent":
|
|
40512
40845
|
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 }));
|
|
40513
40846
|
default:
|
|
@@ -40731,6 +41064,13 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
40731
41064
|
icon: lucideReact.Bot,
|
|
40732
41065
|
description: 'Add an AI chatbot interface to your dashboard',
|
|
40733
41066
|
configRequired: false
|
|
41067
|
+
},
|
|
41068
|
+
{
|
|
41069
|
+
type: 'filters',
|
|
41070
|
+
title: 'Filters Widget',
|
|
41071
|
+
icon: lucideReact.SlidersHorizontal,
|
|
41072
|
+
description: 'Add filter groups with checkboxes to filter dashboard data',
|
|
41073
|
+
configRequired: true
|
|
40734
41074
|
}
|
|
40735
41075
|
];
|
|
40736
41076
|
const handleWidgetSelect = (widgetType) => {
|
|
@@ -40837,12 +41177,19 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
40837
41177
|
: {})),
|
|
40838
41178
|
};
|
|
40839
41179
|
}
|
|
41180
|
+
else if (selectedWidgetType === 'filters') {
|
|
41181
|
+
config = {
|
|
41182
|
+
query: query,
|
|
41183
|
+
agentName: "adk-filter-agent",
|
|
41184
|
+
agentType: "Filters Agent"
|
|
41185
|
+
};
|
|
41186
|
+
}
|
|
40840
41187
|
else {
|
|
40841
41188
|
config = {
|
|
40842
41189
|
agentName: defaultAgentName
|
|
40843
41190
|
};
|
|
40844
41191
|
}
|
|
40845
|
-
const type = selectedWidgetType === 'text' ? selectedWidgetType : "agent";
|
|
41192
|
+
const type = selectedWidgetType === 'text' || selectedWidgetType === 'filters' ? selectedWidgetType : "agent";
|
|
40846
41193
|
handleAddWidget(type, config);
|
|
40847
41194
|
};
|
|
40848
41195
|
const resetModal = () => {
|
|
@@ -40859,7 +41206,9 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
40859
41206
|
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));
|
|
40860
41207
|
}) })] })) : (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'
|
|
40861
41208
|
? 'Chatbot widget will be configured with the default agent.'
|
|
40862
|
-
: selectedWidgetType === 'text' ? "Customize the widget's appearance"
|
|
41209
|
+
: selectedWidgetType === 'text' ? "Customize the widget's appearance"
|
|
41210
|
+
: selectedWidgetType === 'filters' ? "Configure the filters widget:"
|
|
41211
|
+
: '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" })] })] })) }) }) }));
|
|
40863
41212
|
}
|
|
40864
41213
|
|
|
40865
41214
|
const RGL = reactGridLayout.WidthProvider(reactGridLayout.Responsive);
|
|
@@ -40887,6 +41236,7 @@ const defaultLayouts = {
|
|
|
40887
41236
|
const IconMap = {
|
|
40888
41237
|
search: lucideReact.Search,
|
|
40889
41238
|
filter: lucideReact.Filter,
|
|
41239
|
+
filters: lucideReact.SlidersHorizontal,
|
|
40890
41240
|
results: lucideReact.LayoutGrid,
|
|
40891
41241
|
analytics: lucideReact.BarChart,
|
|
40892
41242
|
custom: lucideReact.LayoutGrid,
|
|
@@ -40898,7 +41248,7 @@ const IconMap = {
|
|
|
40898
41248
|
'pie-chart': lucideReact.PieChart,
|
|
40899
41249
|
'chatbot': lucideReact.Bot,
|
|
40900
41250
|
};
|
|
40901
|
-
function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSelect, refreshKey, widgetBackendUrl, onSaveLayoutReady, openWidgetPallete = false, onCloseWidgetPallete, defaultAgentName = "adk-construction-project-agent", userId }) {
|
|
41251
|
+
function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSelect, refreshKey, widgetBackendUrl, onSaveLayoutReady, openWidgetPallete = false, onCloseWidgetPallete, defaultAgentName = "adk-construction-project-agent", userId, onApplyFilters }) {
|
|
40902
41252
|
const [widgets, setWidgets] = React.useState([]);
|
|
40903
41253
|
const [datasetId, setDatasetId] = React.useState('');
|
|
40904
41254
|
const [availableWidgets, setAvailableWidgets] = React.useState([]);
|
|
@@ -40946,7 +41296,7 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
40946
41296
|
setEditingWidget(null);
|
|
40947
41297
|
// Trigger the agent by calling its appendMessage function
|
|
40948
41298
|
const widgetResetFn = widgetResetFunctions.get(editingWidget.id);
|
|
40949
|
-
if (widgetResetFn && editingWidget.type === 'agent') {
|
|
41299
|
+
if (widgetResetFn && (editingWidget.type === 'agent' || editingWidget.type === 'filters')) {
|
|
40950
41300
|
// Clear the chat first, then trigger with new query
|
|
40951
41301
|
try {
|
|
40952
41302
|
if (widgetBackendUrl) {
|
|
@@ -41144,6 +41494,8 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
41144
41494
|
return { w: 6, h: 4 };
|
|
41145
41495
|
case "chatbot":
|
|
41146
41496
|
return { w: 6, h: 6 };
|
|
41497
|
+
case "filters":
|
|
41498
|
+
return { w: 3, h: 8 };
|
|
41147
41499
|
default:
|
|
41148
41500
|
return { w: 6, h: 4 };
|
|
41149
41501
|
}
|
|
@@ -41282,7 +41634,8 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
41282
41634
|
'pie-chart': 'Pie Chart Widget',
|
|
41283
41635
|
'chatbot': 'Chatbot Widget',
|
|
41284
41636
|
'text': 'Text Widget',
|
|
41285
|
-
'spacer': 'Spacer Widget'
|
|
41637
|
+
'spacer': 'Spacer Widget',
|
|
41638
|
+
'filters': 'Filters Widget'
|
|
41286
41639
|
};
|
|
41287
41640
|
widgetTypeConfig = {
|
|
41288
41641
|
type: widgetType,
|
|
@@ -41380,16 +41733,10 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
41380
41733
|
var _a, _b;
|
|
41381
41734
|
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 &&
|
|
41382
41735
|
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(lucideReact.GripHorizontal, { className: "" }), jsxRuntimeExports.jsx(lucideReact.GripHorizontal, { className: "-ml-[3px]" }), jsxRuntimeExports.jsx(lucideReact.GripHorizontal, { className: "-ml-[3px]" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 cursor-pointer justify-end", children: [jsxRuntimeExports.jsx(lucideReact.Trash2, { onClick: () => removeWidget(w.id), className: "w-5 h-5 text-red-700" }), (w.type !== "spacer" && w.type !== "chatbot") && jsxRuntimeExports.jsx(lucideReact.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" &&
|
|
41383
|
-
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(lucideReact.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));
|
|
41736
|
+
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(lucideReact.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));
|
|
41384
41737
|
}) })) })] }));
|
|
41385
41738
|
}
|
|
41386
41739
|
|
|
41387
|
-
const Checkbox = React__namespace.forwardRef((_a, ref) => {
|
|
41388
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
41389
|
-
return (jsxRuntimeExports.jsx(CheckboxPrimitive__namespace.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__namespace.Indicator, { className: cn("flex items-center justify-center text-current"), children: jsxRuntimeExports.jsx(lucideReact.Check, { className: "h-4 w-4" }) }) })));
|
|
41390
|
-
});
|
|
41391
|
-
Checkbox.displayName = CheckboxPrimitive__namespace.Root.displayName;
|
|
41392
|
-
|
|
41393
41740
|
const Dialog = DialogPrimitive__namespace.Root;
|
|
41394
41741
|
const DialogPortal = DialogPrimitive__namespace.Portal;
|
|
41395
41742
|
const DialogOverlay = React__namespace.forwardRef((_a, ref) => {
|