dp-widgets-framework 1.2.5 → 1.2.7
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 +55 -23
- package/dist/index.js +55 -23
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -15391,7 +15391,28 @@ function DataGrid({ title, data, className }) {
|
|
|
15391
15391
|
return null;
|
|
15392
15392
|
return (jsxRuntimeExports.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsxs("tr", { className: "border-b border-gray-200", children: [jsxRuntimeExports.jsx("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50 w-8" }), columns.map((column, index) => (jsxRuntimeExports.jsx("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50", children: column }, index)))] }) }), jsxRuntimeExports.jsx("tbody", { children: grouping.sections.map((section, sectionIndex) => {
|
|
15393
15393
|
const isExpanded = expandedGroups.has(section.group_value);
|
|
15394
|
-
return (jsxRuntimeExports.jsxs(React__default.Fragment, { children: [jsxRuntimeExports.jsxs("tr", { className: "bg-blue-50 border-b border-gray-200", children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3", children: section.collapsible && (jsxRuntimeExports.jsx("button", { onClick: () => toggleGroup(section.group_value), className: "flex items-center justify-center w-6 h-6 hover:bg-blue-100 rounded transition-colors", "aria-label": isExpanded ? "Collapse group" : "Expand group", children: isExpanded ? (jsxRuntimeExports.jsx(ChevronDown, { className: "w-4 h-4 text-blue-600" })) : (jsxRuntimeExports.jsx(ChevronRight, { className: "w-4 h-4 text-blue-600" })) })) }), jsxRuntimeExports.jsx("td", {
|
|
15394
|
+
return (jsxRuntimeExports.jsxs(React__default.Fragment, { children: [jsxRuntimeExports.jsxs("tr", { className: "bg-blue-50 border-b border-gray-200", children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3", children: section.collapsible && (jsxRuntimeExports.jsx("button", { onClick: () => toggleGroup(section.group_value), className: "flex items-center justify-center w-6 h-6 hover:bg-blue-100 rounded transition-colors", "aria-label": isExpanded ? "Collapse group" : "Expand group", children: isExpanded ? (jsxRuntimeExports.jsx(ChevronDown, { className: "w-4 h-4 text-blue-600" })) : (jsxRuntimeExports.jsx(ChevronRight, { className: "w-4 h-4 text-blue-600" })) })) }), columns.map((column, columnIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm font-medium text-blue-700", children: columnIndex === 0 ? (jsxRuntimeExports.jsxs("span", { className: "font-semibold text-blue-900", children: [section.title, ": ", section.group_value] })) : (jsxRuntimeExports.jsx("div", { className: "text-left", children: (() => {
|
|
15395
|
+
var _a;
|
|
15396
|
+
// Find the statistic for this column
|
|
15397
|
+
const sectionStats = (_a = grouping.section_statistics) === null || _a === void 0 ? void 0 : _a[section.group_value];
|
|
15398
|
+
if (!sectionStats)
|
|
15399
|
+
return jsxRuntimeExports.jsx("span", { className: "text-gray-400", children: "\u2014" });
|
|
15400
|
+
// Look for exact column name match first
|
|
15401
|
+
if (sectionStats[column] &&
|
|
15402
|
+
typeof sectionStats[column].total === 'number' &&
|
|
15403
|
+
!isNaN(sectionStats[column].total)) {
|
|
15404
|
+
return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: sectionStats[column].total.toLocaleString() }));
|
|
15405
|
+
}
|
|
15406
|
+
// If exact match fails, try to find by partial match
|
|
15407
|
+
const matchingKey = Object.keys(sectionStats).find(key => key.toLowerCase().includes(column.toLowerCase()) ||
|
|
15408
|
+
column.toLowerCase().includes(key.toLowerCase()));
|
|
15409
|
+
if (matchingKey && sectionStats[matchingKey] &&
|
|
15410
|
+
typeof sectionStats[matchingKey].total === 'number' &&
|
|
15411
|
+
!isNaN(sectionStats[matchingKey].total)) {
|
|
15412
|
+
return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: sectionStats[matchingKey].total.toLocaleString() }));
|
|
15413
|
+
}
|
|
15414
|
+
return jsxRuntimeExports.jsx("span", { className: "text-gray-400", children: "\u2014" });
|
|
15415
|
+
})() })) }, columnIndex)))] }), (!section.collapsible || isExpanded) && section.rows.map((row, rowIndex) => (jsxRuntimeExports.jsxs("tr", { className: `border-b border-gray-200 ${rowIndex % 2 === 0
|
|
15395
15416
|
? "bg-white"
|
|
15396
15417
|
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3" }), row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: cell !== null && cell !== undefined ? String(cell) : "—" }, cellIndex)))] }, `${sectionIndex}-${rowIndex}`)))] }, `section-${sectionIndex}`));
|
|
15397
15418
|
}) })] }));
|
|
@@ -15399,15 +15420,19 @@ function DataGrid({ title, data, className }) {
|
|
|
15399
15420
|
const renderRegularTable = () => (jsxRuntimeExports.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsx("tr", { className: "border-b border-gray-200", children: columns.map((column, index) => (jsxRuntimeExports.jsx("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50", children: column }, index))) }) }), jsxRuntimeExports.jsx("tbody", { children: rows.map((row, rowIndex) => (jsxRuntimeExports.jsx("tr", { className: `border-b border-gray-200 ${rowIndex % 2 === 0
|
|
15400
15421
|
? "bg-white"
|
|
15401
15422
|
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: cell !== null && cell !== undefined ? String(cell) : "—" }, cellIndex))) }, rowIndex))) })] }));
|
|
15402
|
-
const getTotalRowCount = () => {
|
|
15403
|
-
if (grouped && (grouping === null || grouping === void 0 ? void 0 : grouping.sections)) {
|
|
15404
|
-
return grouping.sections.reduce((total, section) => total + section.row_count, 0);
|
|
15405
|
-
}
|
|
15406
|
-
return rows.length;
|
|
15407
|
-
};
|
|
15408
15423
|
return (jsxRuntimeExports.jsxs("div", { className: `h-full flex flex-col ${className || ""}`, children: [title && (jsxRuntimeExports.jsx("div", { className: "pb-4", children: jsxRuntimeExports.jsx("h3", { className: "text-lg font-bold", style: {
|
|
15409
15424
|
color: "#0F172A"
|
|
15410
|
-
}, children: title }) })), jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-auto", children: jsxRuntimeExports.jsx("div", { className: "min-w-full", children: grouped && grouping ? renderGroupedTable() : renderRegularTable() }) }), jsxRuntimeExports.jsx("div", { className: "pt-2 text-xs text-gray-500", children: grouped && grouping ? (jsxRuntimeExports.jsxs("
|
|
15425
|
+
}, children: title }) })), jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-auto", children: jsxRuntimeExports.jsx("div", { className: "min-w-full", children: grouped && grouping ? renderGroupedTable() : renderRegularTable() }) }), jsxRuntimeExports.jsx("div", { className: "pt-2 text-xs text-gray-500", children: grouped && grouping && grouping.section_statistics ? (jsxRuntimeExports.jsxs("div", { className: "flex gap-6", children: [jsxRuntimeExports.jsxs("span", { children: [grouping.total_groups, " group", grouping.total_groups !== 1 ? "s" : "", " \u00D7 ", columns.length, " column", columns.length !== 1 ? "s" : ""] }), jsxRuntimeExports.jsx("div", { className: "flex gap-4", children: (() => {
|
|
15426
|
+
const totals = {};
|
|
15427
|
+
Object.values(grouping.section_statistics).forEach(groupStats => {
|
|
15428
|
+
Object.entries(groupStats).forEach(([column, stats]) => {
|
|
15429
|
+
if (typeof stats.total === 'number' && !isNaN(stats.total)) {
|
|
15430
|
+
totals[column] = (totals[column] || 0) + stats.total;
|
|
15431
|
+
}
|
|
15432
|
+
});
|
|
15433
|
+
});
|
|
15434
|
+
return Object.entries(totals).map(([column, total], index) => (jsxRuntimeExports.jsxs("span", { className: "font-medium", children: ["Total ", column, ": ", total.toLocaleString()] }, index)));
|
|
15435
|
+
})() })] })) : (jsxRuntimeExports.jsxs("span", { children: ["Showing ", rows.length, " row", rows.length !== 1 ? "s" : "", " \u00D7 ", columns.length, " column", columns.length !== 1 ? "s" : ""] })) })] }));
|
|
15411
15436
|
}
|
|
15412
15437
|
|
|
15413
15438
|
function ok$1() {}
|
|
@@ -36093,7 +36118,7 @@ const clearChat = async (widgetBackendUrl, widgetId) => {
|
|
|
36093
36118
|
console.error('Failed to clear chat:', error);
|
|
36094
36119
|
}
|
|
36095
36120
|
};
|
|
36096
|
-
const createLoadingComponent = (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-
|
|
36121
|
+
const createLoadingComponent = (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 })] }) }));
|
|
36097
36122
|
const createInitialChartState = (agentType, widgetIds, datasetId) => {
|
|
36098
36123
|
const baseState = { dataset_id: datasetId || "home_generation_dataset" };
|
|
36099
36124
|
switch (agentType) {
|
|
@@ -36949,7 +36974,6 @@ function EditWidgetDialog({ editingWidget, setWidgets, initialText, isOpen, onCl
|
|
|
36949
36974
|
};
|
|
36950
36975
|
if (!isOpen)
|
|
36951
36976
|
return null;
|
|
36952
|
-
console.log(editingWidget, "==> editingWidget");
|
|
36953
36977
|
return (jsxRuntimeExports.jsx(Modal, { isOpen: isOpen, onClose: onClose, title: "Edit Widget", size: "lg",
|
|
36954
36978
|
// initialFocusRef={inputRef}
|
|
36955
36979
|
noOverflowHidden: true, children: jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("p", { className: "text-gray-700", children: "Customize the widget\u2019s appearance" }), jsxRuntimeExports.jsx("div", { className: "pt-7", children: (editingWidget === null || editingWidget === void 0 ? void 0 : editingWidget.type) === "text" ?
|
|
@@ -36963,6 +36987,10 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
36963
36987
|
const [selectedWidgetType, setSelectedWidgetType] = useState(null);
|
|
36964
36988
|
const [query, setQuery] = useState('');
|
|
36965
36989
|
const [showConfigStep, setShowConfigStep] = useState(false);
|
|
36990
|
+
const [displayText, setDisplayText] = useState("Text goes here...");
|
|
36991
|
+
const [blockType, setBlockType] = useState("paragraph");
|
|
36992
|
+
const [alignment, setAlignment] = useState("left");
|
|
36993
|
+
const [divider, setDivider] = useState("no");
|
|
36966
36994
|
const widgetOptions = [
|
|
36967
36995
|
// {
|
|
36968
36996
|
// type: 'bar-chart',
|
|
@@ -36976,7 +37004,7 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
36976
37004
|
title: 'Text Widget',
|
|
36977
37005
|
icon: Type,
|
|
36978
37006
|
description: 'Add headings or paragraphs to your dashboard',
|
|
36979
|
-
configRequired:
|
|
37007
|
+
configRequired: true
|
|
36980
37008
|
},
|
|
36981
37009
|
{
|
|
36982
37010
|
type: 'spacer',
|
|
@@ -37043,14 +37071,9 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
37043
37071
|
}
|
|
37044
37072
|
else {
|
|
37045
37073
|
// For chatbot and text widget, create the default config
|
|
37046
|
-
const config =
|
|
37047
|
-
|
|
37048
|
-
|
|
37049
|
-
blockType: "paragraph",
|
|
37050
|
-
divider: "no",
|
|
37051
|
-
},
|
|
37052
|
-
styles: { textAlign: "left" }
|
|
37053
|
-
}));
|
|
37074
|
+
const config = {
|
|
37075
|
+
agentName: defaultAgentName,
|
|
37076
|
+
};
|
|
37054
37077
|
handleAddWidget(widgetType, config);
|
|
37055
37078
|
}
|
|
37056
37079
|
};
|
|
@@ -37126,7 +37149,16 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
37126
37149
|
}
|
|
37127
37150
|
else if (selectedWidgetType === 'text') {
|
|
37128
37151
|
config = {
|
|
37129
|
-
agentName: defaultAgentName
|
|
37152
|
+
agentName: defaultAgentName,
|
|
37153
|
+
agentType: "Text Agent",
|
|
37154
|
+
content: {
|
|
37155
|
+
displayText,
|
|
37156
|
+
blockType,
|
|
37157
|
+
divider
|
|
37158
|
+
},
|
|
37159
|
+
styles: Object.assign({}, (alignment && alignment.length > 0
|
|
37160
|
+
? { textAlign: alignment }
|
|
37161
|
+
: {})),
|
|
37130
37162
|
};
|
|
37131
37163
|
}
|
|
37132
37164
|
else {
|
|
@@ -37134,7 +37166,8 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
37134
37166
|
agentName: defaultAgentName
|
|
37135
37167
|
};
|
|
37136
37168
|
}
|
|
37137
|
-
|
|
37169
|
+
const type = selectedWidgetType === 'text' ? selectedWidgetType : "agent";
|
|
37170
|
+
handleAddWidget(type, config);
|
|
37138
37171
|
};
|
|
37139
37172
|
const resetModal = () => {
|
|
37140
37173
|
setSelectedWidgetType(null);
|
|
@@ -37150,7 +37183,7 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
37150
37183
|
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));
|
|
37151
37184
|
}) })] })) : (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: "mb-2", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: selectedWidgetType === 'chatbot'
|
|
37152
37185
|
? 'Chatbot widget will be configured with the default agent.'
|
|
37153
|
-
: '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" }) })), 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" })] })] })) }) }) }));
|
|
37186
|
+
: selectedWidgetType === 'text' ? "Customize the widget's appearance" : 'Enter a query for your chart widget:' }) }), (selectedWidgetType === 'bar-chart' || selectedWidgetType === 'series-bar-chart' || selectedWidgetType === 'series-line-chart' || selectedWidgetType === 'line-chart' || selectedWidgetType === 'pie-chart' || selectedWidgetType === 'data-grid' || selectedWidgetType === 'summary') && (jsxRuntimeExports.jsx("div", { className: "mb-6", children: jsxRuntimeExports.jsx(Textarea, { value: query, onChange: (e) => setQuery(e.target.value), placeholder: "e.g., List out the product types by its count and render it on bar chart", className: "w-full h-24 resize-none" }) })), selectedWidgetType === 'text' && (jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-5 pb-5 pt-2", children: [jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Display text:" }), jsxRuntimeExports.jsx(Input, { value: displayText, onChange: (e) => setDisplayText(e.target.value), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Block type:" }), jsxRuntimeExports.jsxs(Select, { value: blockType, onValueChange: (value) => setBlockType(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select block type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "heading-1", children: "Heading 1" }), jsxRuntimeExports.jsx(SelectItem, { value: "heading-2", children: "Heading 2" }), jsxRuntimeExports.jsx(SelectItem, { value: "heading-3", children: "Heading 3" }), jsxRuntimeExports.jsx(SelectItem, { value: "paragraph", children: "Paragraph" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Align:" }), jsxRuntimeExports.jsxs(Select, { value: alignment, onValueChange: (value) => setAlignment(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select block type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "left", children: "Left" }), jsxRuntimeExports.jsx(SelectItem, { value: "center", children: "Center" }), jsxRuntimeExports.jsx(SelectItem, { value: "right", children: "Right" }), jsxRuntimeExports.jsx(SelectItem, { value: "justify", children: "Justify" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Divider:" }), jsxRuntimeExports.jsxs(Select, { value: divider, onValueChange: (value) => setDivider(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "No" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "yes", children: "Yes" }), jsxRuntimeExports.jsx(SelectItem, { value: "no", children: "No" })] })] })] })] })), jsxRuntimeExports.jsxs("div", { className: "flex gap-3 justify-end", children: [jsxRuntimeExports.jsx(Button, { variant: "outline", onClick: () => setShowConfigStep(false), children: "Back" }), jsxRuntimeExports.jsx(Button, { onClick: handleConfigSubmit, disabled: (selectedWidgetType === 'bar-chart' || selectedWidgetType === 'series-bar-chart' || selectedWidgetType === 'series-line-chart' || selectedWidgetType === 'line-chart' || selectedWidgetType === 'pie-chart' || selectedWidgetType === 'data-grid' || selectedWidgetType === 'summary') && !query.trim(), children: "Add Widget" })] })] })) }) }) }));
|
|
37154
37187
|
}
|
|
37155
37188
|
|
|
37156
37189
|
const RGL = WidthProvider(Responsive);
|
|
@@ -37323,7 +37356,6 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
37323
37356
|
throw new Error("Failed to load page data");
|
|
37324
37357
|
}
|
|
37325
37358
|
const data = await response.json();
|
|
37326
|
-
console.log(data);
|
|
37327
37359
|
setPageData(data);
|
|
37328
37360
|
setWidgets(data.widgets || []);
|
|
37329
37361
|
setDatasetId(data === null || data === void 0 ? void 0 : data.dataset_id);
|
package/dist/index.js
CHANGED
|
@@ -15418,7 +15418,28 @@ function DataGrid({ title, data, className }) {
|
|
|
15418
15418
|
return null;
|
|
15419
15419
|
return (jsxRuntimeExports.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsxs("tr", { className: "border-b border-gray-200", children: [jsxRuntimeExports.jsx("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50 w-8" }), columns.map((column, index) => (jsxRuntimeExports.jsx("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50", children: column }, index)))] }) }), jsxRuntimeExports.jsx("tbody", { children: grouping.sections.map((section, sectionIndex) => {
|
|
15420
15420
|
const isExpanded = expandedGroups.has(section.group_value);
|
|
15421
|
-
return (jsxRuntimeExports.jsxs(React.Fragment, { children: [jsxRuntimeExports.jsxs("tr", { className: "bg-blue-50 border-b border-gray-200", children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3", children: section.collapsible && (jsxRuntimeExports.jsx("button", { onClick: () => toggleGroup(section.group_value), className: "flex items-center justify-center w-6 h-6 hover:bg-blue-100 rounded transition-colors", "aria-label": isExpanded ? "Collapse group" : "Expand group", children: isExpanded ? (jsxRuntimeExports.jsx(lucideReact.ChevronDown, { className: "w-4 h-4 text-blue-600" })) : (jsxRuntimeExports.jsx(lucideReact.ChevronRight, { className: "w-4 h-4 text-blue-600" })) })) }), jsxRuntimeExports.jsx("td", {
|
|
15421
|
+
return (jsxRuntimeExports.jsxs(React.Fragment, { children: [jsxRuntimeExports.jsxs("tr", { className: "bg-blue-50 border-b border-gray-200", children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3", children: section.collapsible && (jsxRuntimeExports.jsx("button", { onClick: () => toggleGroup(section.group_value), className: "flex items-center justify-center w-6 h-6 hover:bg-blue-100 rounded transition-colors", "aria-label": isExpanded ? "Collapse group" : "Expand group", children: isExpanded ? (jsxRuntimeExports.jsx(lucideReact.ChevronDown, { className: "w-4 h-4 text-blue-600" })) : (jsxRuntimeExports.jsx(lucideReact.ChevronRight, { className: "w-4 h-4 text-blue-600" })) })) }), columns.map((column, columnIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm font-medium text-blue-700", children: columnIndex === 0 ? (jsxRuntimeExports.jsxs("span", { className: "font-semibold text-blue-900", children: [section.title, ": ", section.group_value] })) : (jsxRuntimeExports.jsx("div", { className: "text-left", children: (() => {
|
|
15422
|
+
var _a;
|
|
15423
|
+
// Find the statistic for this column
|
|
15424
|
+
const sectionStats = (_a = grouping.section_statistics) === null || _a === void 0 ? void 0 : _a[section.group_value];
|
|
15425
|
+
if (!sectionStats)
|
|
15426
|
+
return jsxRuntimeExports.jsx("span", { className: "text-gray-400", children: "\u2014" });
|
|
15427
|
+
// Look for exact column name match first
|
|
15428
|
+
if (sectionStats[column] &&
|
|
15429
|
+
typeof sectionStats[column].total === 'number' &&
|
|
15430
|
+
!isNaN(sectionStats[column].total)) {
|
|
15431
|
+
return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: sectionStats[column].total.toLocaleString() }));
|
|
15432
|
+
}
|
|
15433
|
+
// If exact match fails, try to find by partial match
|
|
15434
|
+
const matchingKey = Object.keys(sectionStats).find(key => key.toLowerCase().includes(column.toLowerCase()) ||
|
|
15435
|
+
column.toLowerCase().includes(key.toLowerCase()));
|
|
15436
|
+
if (matchingKey && sectionStats[matchingKey] &&
|
|
15437
|
+
typeof sectionStats[matchingKey].total === 'number' &&
|
|
15438
|
+
!isNaN(sectionStats[matchingKey].total)) {
|
|
15439
|
+
return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: sectionStats[matchingKey].total.toLocaleString() }));
|
|
15440
|
+
}
|
|
15441
|
+
return jsxRuntimeExports.jsx("span", { className: "text-gray-400", children: "\u2014" });
|
|
15442
|
+
})() })) }, columnIndex)))] }), (!section.collapsible || isExpanded) && section.rows.map((row, rowIndex) => (jsxRuntimeExports.jsxs("tr", { className: `border-b border-gray-200 ${rowIndex % 2 === 0
|
|
15422
15443
|
? "bg-white"
|
|
15423
15444
|
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3" }), row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: cell !== null && cell !== undefined ? String(cell) : "—" }, cellIndex)))] }, `${sectionIndex}-${rowIndex}`)))] }, `section-${sectionIndex}`));
|
|
15424
15445
|
}) })] }));
|
|
@@ -15426,15 +15447,19 @@ function DataGrid({ title, data, className }) {
|
|
|
15426
15447
|
const renderRegularTable = () => (jsxRuntimeExports.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsx("tr", { className: "border-b border-gray-200", children: columns.map((column, index) => (jsxRuntimeExports.jsx("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50", children: column }, index))) }) }), jsxRuntimeExports.jsx("tbody", { children: rows.map((row, rowIndex) => (jsxRuntimeExports.jsx("tr", { className: `border-b border-gray-200 ${rowIndex % 2 === 0
|
|
15427
15448
|
? "bg-white"
|
|
15428
15449
|
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: cell !== null && cell !== undefined ? String(cell) : "—" }, cellIndex))) }, rowIndex))) })] }));
|
|
15429
|
-
const getTotalRowCount = () => {
|
|
15430
|
-
if (grouped && (grouping === null || grouping === void 0 ? void 0 : grouping.sections)) {
|
|
15431
|
-
return grouping.sections.reduce((total, section) => total + section.row_count, 0);
|
|
15432
|
-
}
|
|
15433
|
-
return rows.length;
|
|
15434
|
-
};
|
|
15435
15450
|
return (jsxRuntimeExports.jsxs("div", { className: `h-full flex flex-col ${className || ""}`, children: [title && (jsxRuntimeExports.jsx("div", { className: "pb-4", children: jsxRuntimeExports.jsx("h3", { className: "text-lg font-bold", style: {
|
|
15436
15451
|
color: "#0F172A"
|
|
15437
|
-
}, children: title }) })), jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-auto", children: jsxRuntimeExports.jsx("div", { className: "min-w-full", children: grouped && grouping ? renderGroupedTable() : renderRegularTable() }) }), jsxRuntimeExports.jsx("div", { className: "pt-2 text-xs text-gray-500", children: grouped && grouping ? (jsxRuntimeExports.jsxs("
|
|
15452
|
+
}, children: title }) })), jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-auto", children: jsxRuntimeExports.jsx("div", { className: "min-w-full", children: grouped && grouping ? renderGroupedTable() : renderRegularTable() }) }), jsxRuntimeExports.jsx("div", { className: "pt-2 text-xs text-gray-500", children: grouped && grouping && grouping.section_statistics ? (jsxRuntimeExports.jsxs("div", { className: "flex gap-6", children: [jsxRuntimeExports.jsxs("span", { children: [grouping.total_groups, " group", grouping.total_groups !== 1 ? "s" : "", " \u00D7 ", columns.length, " column", columns.length !== 1 ? "s" : ""] }), jsxRuntimeExports.jsx("div", { className: "flex gap-4", children: (() => {
|
|
15453
|
+
const totals = {};
|
|
15454
|
+
Object.values(grouping.section_statistics).forEach(groupStats => {
|
|
15455
|
+
Object.entries(groupStats).forEach(([column, stats]) => {
|
|
15456
|
+
if (typeof stats.total === 'number' && !isNaN(stats.total)) {
|
|
15457
|
+
totals[column] = (totals[column] || 0) + stats.total;
|
|
15458
|
+
}
|
|
15459
|
+
});
|
|
15460
|
+
});
|
|
15461
|
+
return Object.entries(totals).map(([column, total], index) => (jsxRuntimeExports.jsxs("span", { className: "font-medium", children: ["Total ", column, ": ", total.toLocaleString()] }, index)));
|
|
15462
|
+
})() })] })) : (jsxRuntimeExports.jsxs("span", { children: ["Showing ", rows.length, " row", rows.length !== 1 ? "s" : "", " \u00D7 ", columns.length, " column", columns.length !== 1 ? "s" : ""] })) })] }));
|
|
15438
15463
|
}
|
|
15439
15464
|
|
|
15440
15465
|
function ok$1() {}
|
|
@@ -36120,7 +36145,7 @@ const clearChat = async (widgetBackendUrl, widgetId) => {
|
|
|
36120
36145
|
console.error('Failed to clear chat:', error);
|
|
36121
36146
|
}
|
|
36122
36147
|
};
|
|
36123
|
-
const createLoadingComponent = (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-
|
|
36148
|
+
const createLoadingComponent = (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 })] }) }));
|
|
36124
36149
|
const createInitialChartState = (agentType, widgetIds, datasetId) => {
|
|
36125
36150
|
const baseState = { dataset_id: datasetId || "home_generation_dataset" };
|
|
36126
36151
|
switch (agentType) {
|
|
@@ -36976,7 +37001,6 @@ function EditWidgetDialog({ editingWidget, setWidgets, initialText, isOpen, onCl
|
|
|
36976
37001
|
};
|
|
36977
37002
|
if (!isOpen)
|
|
36978
37003
|
return null;
|
|
36979
|
-
console.log(editingWidget, "==> editingWidget");
|
|
36980
37004
|
return (jsxRuntimeExports.jsx(Modal, { isOpen: isOpen, onClose: onClose, title: "Edit Widget", size: "lg",
|
|
36981
37005
|
// initialFocusRef={inputRef}
|
|
36982
37006
|
noOverflowHidden: true, children: jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("p", { className: "text-gray-700", children: "Customize the widget\u2019s appearance" }), jsxRuntimeExports.jsx("div", { className: "pt-7", children: (editingWidget === null || editingWidget === void 0 ? void 0 : editingWidget.type) === "text" ?
|
|
@@ -36990,6 +37014,10 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
36990
37014
|
const [selectedWidgetType, setSelectedWidgetType] = React.useState(null);
|
|
36991
37015
|
const [query, setQuery] = React.useState('');
|
|
36992
37016
|
const [showConfigStep, setShowConfigStep] = React.useState(false);
|
|
37017
|
+
const [displayText, setDisplayText] = React.useState("Text goes here...");
|
|
37018
|
+
const [blockType, setBlockType] = React.useState("paragraph");
|
|
37019
|
+
const [alignment, setAlignment] = React.useState("left");
|
|
37020
|
+
const [divider, setDivider] = React.useState("no");
|
|
36993
37021
|
const widgetOptions = [
|
|
36994
37022
|
// {
|
|
36995
37023
|
// type: 'bar-chart',
|
|
@@ -37003,7 +37031,7 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
37003
37031
|
title: 'Text Widget',
|
|
37004
37032
|
icon: lucideReact.Type,
|
|
37005
37033
|
description: 'Add headings or paragraphs to your dashboard',
|
|
37006
|
-
configRequired:
|
|
37034
|
+
configRequired: true
|
|
37007
37035
|
},
|
|
37008
37036
|
{
|
|
37009
37037
|
type: 'spacer',
|
|
@@ -37070,14 +37098,9 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
37070
37098
|
}
|
|
37071
37099
|
else {
|
|
37072
37100
|
// For chatbot and text widget, create the default config
|
|
37073
|
-
const config =
|
|
37074
|
-
|
|
37075
|
-
|
|
37076
|
-
blockType: "paragraph",
|
|
37077
|
-
divider: "no",
|
|
37078
|
-
},
|
|
37079
|
-
styles: { textAlign: "left" }
|
|
37080
|
-
}));
|
|
37101
|
+
const config = {
|
|
37102
|
+
agentName: defaultAgentName,
|
|
37103
|
+
};
|
|
37081
37104
|
handleAddWidget(widgetType, config);
|
|
37082
37105
|
}
|
|
37083
37106
|
};
|
|
@@ -37153,7 +37176,16 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
37153
37176
|
}
|
|
37154
37177
|
else if (selectedWidgetType === 'text') {
|
|
37155
37178
|
config = {
|
|
37156
|
-
agentName: defaultAgentName
|
|
37179
|
+
agentName: defaultAgentName,
|
|
37180
|
+
agentType: "Text Agent",
|
|
37181
|
+
content: {
|
|
37182
|
+
displayText,
|
|
37183
|
+
blockType,
|
|
37184
|
+
divider
|
|
37185
|
+
},
|
|
37186
|
+
styles: Object.assign({}, (alignment && alignment.length > 0
|
|
37187
|
+
? { textAlign: alignment }
|
|
37188
|
+
: {})),
|
|
37157
37189
|
};
|
|
37158
37190
|
}
|
|
37159
37191
|
else {
|
|
@@ -37161,7 +37193,8 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
37161
37193
|
agentName: defaultAgentName
|
|
37162
37194
|
};
|
|
37163
37195
|
}
|
|
37164
|
-
|
|
37196
|
+
const type = selectedWidgetType === 'text' ? selectedWidgetType : "agent";
|
|
37197
|
+
handleAddWidget(type, config);
|
|
37165
37198
|
};
|
|
37166
37199
|
const resetModal = () => {
|
|
37167
37200
|
setSelectedWidgetType(null);
|
|
@@ -37177,7 +37210,7 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
|
|
|
37177
37210
|
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));
|
|
37178
37211
|
}) })] })) : (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: "mb-2", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: selectedWidgetType === 'chatbot'
|
|
37179
37212
|
? 'Chatbot widget will be configured with the default agent.'
|
|
37180
|
-
: '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" }) })), 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" })] })] })) }) }) }));
|
|
37213
|
+
: selectedWidgetType === 'text' ? "Customize the widget's appearance" : 'Enter a query for your chart widget:' }) }), (selectedWidgetType === 'bar-chart' || selectedWidgetType === 'series-bar-chart' || selectedWidgetType === 'series-line-chart' || selectedWidgetType === 'line-chart' || selectedWidgetType === 'pie-chart' || selectedWidgetType === 'data-grid' || selectedWidgetType === 'summary') && (jsxRuntimeExports.jsx("div", { className: "mb-6", children: jsxRuntimeExports.jsx(Textarea, { value: query, onChange: (e) => setQuery(e.target.value), placeholder: "e.g., List out the product types by its count and render it on bar chart", className: "w-full h-24 resize-none" }) })), selectedWidgetType === 'text' && (jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-5 pb-5 pt-2", children: [jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Display text:" }), jsxRuntimeExports.jsx(Input, { value: displayText, onChange: (e) => setDisplayText(e.target.value), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Block type:" }), jsxRuntimeExports.jsxs(Select, { value: blockType, onValueChange: (value) => setBlockType(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select block type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "heading-1", children: "Heading 1" }), jsxRuntimeExports.jsx(SelectItem, { value: "heading-2", children: "Heading 2" }), jsxRuntimeExports.jsx(SelectItem, { value: "heading-3", children: "Heading 3" }), jsxRuntimeExports.jsx(SelectItem, { value: "paragraph", children: "Paragraph" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Align:" }), jsxRuntimeExports.jsxs(Select, { value: alignment, onValueChange: (value) => setAlignment(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select block type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "left", children: "Left" }), jsxRuntimeExports.jsx(SelectItem, { value: "center", children: "Center" }), jsxRuntimeExports.jsx(SelectItem, { value: "right", children: "Right" }), jsxRuntimeExports.jsx(SelectItem, { value: "justify", children: "Justify" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Divider:" }), jsxRuntimeExports.jsxs(Select, { value: divider, onValueChange: (value) => setDivider(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "No" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "yes", children: "Yes" }), jsxRuntimeExports.jsx(SelectItem, { value: "no", children: "No" })] })] })] })] })), jsxRuntimeExports.jsxs("div", { className: "flex gap-3 justify-end", children: [jsxRuntimeExports.jsx(Button, { variant: "outline", onClick: () => setShowConfigStep(false), children: "Back" }), jsxRuntimeExports.jsx(Button, { onClick: handleConfigSubmit, disabled: (selectedWidgetType === 'bar-chart' || selectedWidgetType === 'series-bar-chart' || selectedWidgetType === 'series-line-chart' || selectedWidgetType === 'line-chart' || selectedWidgetType === 'pie-chart' || selectedWidgetType === 'data-grid' || selectedWidgetType === 'summary') && !query.trim(), children: "Add Widget" })] })] })) }) }) }));
|
|
37181
37214
|
}
|
|
37182
37215
|
|
|
37183
37216
|
const RGL = reactGridLayout.WidthProvider(reactGridLayout.Responsive);
|
|
@@ -37350,7 +37383,6 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
37350
37383
|
throw new Error("Failed to load page data");
|
|
37351
37384
|
}
|
|
37352
37385
|
const data = await response.json();
|
|
37353
|
-
console.log(data);
|
|
37354
37386
|
setPageData(data);
|
|
37355
37387
|
setWidgets(data.widgets || []);
|
|
37356
37388
|
setDatasetId(data === null || data === void 0 ? void 0 : data.dataset_id);
|