dp-widgets-framework 1.4.2 → 1.4.5

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 CHANGED
@@ -7,7 +7,7 @@ import * as LabelPrimitive from '@radix-ui/react-label';
7
7
  import { cva } from 'class-variance-authority';
8
8
  import * as SwitchPrimitives from '@radix-ui/react-switch';
9
9
  import * as SelectPrimitive from '@radix-ui/react-select';
10
- import { ChevronDown, ChevronUp, Check, AlertCircle, MoveUp, MoveDown, Trash2, Plus, Bot, Type, Layout, LayoutGrid, BarChart as BarChart$1, Filter, Search, ArrowUp, ArrowDown, ChevronRight, RefreshCw, X, AlignVerticalSpaceAround, LineChart as LineChart$1, PieChart as PieChart$1, Table, FileText, Loader2, GripHorizontal, Edit, MessageCircleX, Edit2 } from 'lucide-react';
10
+ import { ChevronDown, ChevronUp, Check, AlertCircle, MoveUp, MoveDown, Trash2, Plus, Bot, Type, Layout, LayoutGrid, BarChart as BarChart$1, Filter, Search, ArrowUp, ArrowDown, ChevronRight, RefreshCw, Send, X, AlignVerticalSpaceAround, LineChart as LineChart$1, PieChart as PieChart$1, Table, FileText, Loader2, GripHorizontal, Edit, MessageCircleX, Edit2 } from 'lucide-react';
11
11
  import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
12
12
  import { Slot } from '@radix-ui/react-slot';
13
13
  import { debounce as debounce$1 } from 'lodash';
@@ -15,7 +15,6 @@ import Editor from '@monaco-editor/react';
15
15
  import { WidthProvider, Responsive } from 'react-grid-layout';
16
16
  import { v4 } from 'uuid';
17
17
  import { CopilotKit, useCopilotContext, useCoAgent, useCopilotChat } from '@copilotkit/react-core';
18
- import { CopilotChat } from '@copilotkit/react-ui';
19
18
  import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
20
19
  import * as DialogPrimitive from '@radix-ui/react-dialog';
21
20
 
@@ -16603,7 +16602,6 @@ var plugin$1 = {
16603
16602
  Chart$1.register(CategoryScale, LinearScale, PointElement, LineElement, plugin_title, plugin_tooltip, plugin_legend);
16604
16603
  function SeriesLineChart({ orientation, title, data, options, className, units, content, x_axis_title, y_axis_title }) {
16605
16604
  var _a, _b;
16606
- console.log('x_axis_title==>', x_axis_title);
16607
16605
  const formatValue = (value) => {
16608
16606
  const numValue = typeof value === 'string' ? parseFloat(value) : value;
16609
16607
  if (!isNaN(numValue)) {
@@ -17651,6 +17649,8 @@ function LineChart({ title, data, options, className, units, content }) {
17651
17649
  function DataGrid({ title, data, className }) {
17652
17650
  var _a;
17653
17651
  const { columns, rows, units, grouped = false, grouping } = data;
17652
+ console.log('title==>', title);
17653
+ console.log('grouping==>', grouping);
17654
17654
  const [expandedGroups, setExpandedGroups] = useState(new Set(((_a = grouping === null || grouping === void 0 ? void 0 : grouping.sections) === null || _a === void 0 ? void 0 : _a.filter(s => s.expanded).map(s => s.group_value)) || []));
17655
17655
  const toggleGroup = (groupValue) => {
17656
17656
  const newExpanded = new Set(expandedGroups);
@@ -39154,7 +39154,25 @@ function CopilotKitChatbot({ widget, showHeader, styles, onResetReady, widgetIds
39154
39154
  dataset_id: datasetId
39155
39155
  },
39156
39156
  });
39157
- const { reset } = useCopilotChat();
39157
+ const { reset, visibleMessages, appendMessage, isLoading } = useCopilotChat();
39158
+ const [inputValue, setInputValue] = useState("");
39159
+ const [chatMessages, setChatMessages] = useState([]);
39160
+ const messagesEndRef = React__default.useRef(null);
39161
+ const scrollToBottom = () => {
39162
+ var _a;
39163
+ (_a = messagesEndRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ behavior: "smooth" });
39164
+ };
39165
+ useEffect(() => {
39166
+ console.log('visibleMessages==>', visibleMessages);
39167
+ if (visibleMessages.length) {
39168
+ const nonEmptyMessages = visibleMessages.filter((msg) => (msg === null || msg === void 0 ? void 0 : msg.content) && (msg === null || msg === void 0 ? void 0 : msg.content.trim()) !== "");
39169
+ setChatMessages(nonEmptyMessages);
39170
+ }
39171
+ }, [visibleMessages]);
39172
+ // Auto-scroll when messages change or loading state changes
39173
+ useEffect(() => {
39174
+ scrollToBottom();
39175
+ }, [chatMessages, isLoading]);
39158
39176
  // Register the reset function with the parent component
39159
39177
  useEffect(() => {
39160
39178
  if (onResetReady && reset && widget.id) {
@@ -39182,12 +39200,25 @@ function CopilotKitChatbot({ widget, showHeader, styles, onResetReady, widgetIds
39182
39200
  window.removeEventListener('clearChartState', handleClearChartState);
39183
39201
  };
39184
39202
  }, [widget.id, widgetIds, datasetId, setChatbotState]);
39185
- return (jsxRuntimeExports.jsxs("div", { className: cn("flex flex-col h-full"), children: [showHeader && (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-between pb-2 border-b", children: jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }), jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })] }) })), jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: jsxRuntimeExports.jsx(CopilotChat, { className: "h-full text-xs [&_.copilot-chat-message]:text-xs [&_.copilot-chat-input]:text-xs", labels: {
39186
- title: ((_b = widget.config) === null || _b === void 0 ? void 0 : _b.copilotTitle) || widget.title,
39187
- initial: ((_c = widget.config) === null || _c === void 0 ? void 0 : _c.copilotInitialMessage) || ((_d = widget.config) === null || _d === void 0 ? void 0 : _d.placeholder) || "How can I help you today?"
39188
- }, onSubmitMessage: () => {
39189
- setChatbotState(prevState => (Object.assign(Object.assign({}, prevState), { widget_ids: widgetIds, dataset_id: datasetId })));
39190
- } }) })] }));
39203
+ const handleSubmit = (e) => {
39204
+ e.preventDefault();
39205
+ if (!inputValue.trim())
39206
+ return;
39207
+ // Update chatbot state before sending message
39208
+ setChatbotState(prevState => (Object.assign(Object.assign({}, prevState), { widget_ids: widgetIds, dataset_id: datasetId })));
39209
+ // Append the user message
39210
+ appendMessage(new TextMessage({
39211
+ content: inputValue,
39212
+ role: Role.User,
39213
+ }));
39214
+ // Clear input
39215
+ setInputValue("");
39216
+ };
39217
+ return (jsxRuntimeExports.jsxs("div", { className: cn("flex flex-col h-full"), children: [showHeader && (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-between pb-2 border-b", children: jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }), jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })] }) })), jsxRuntimeExports.jsxs("div", { className: "flex-1 h-full flex flex-col", children: [jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-y-auto p-4 space-y-4", children: chatMessages.length === 0 ? (jsxRuntimeExports.jsx("div", { className: "text-center text-gray-500 text-xs mt-8", children: ((_b = widget.config) === null || _b === void 0 ? void 0 : _b.copilotInitialMessage) || ((_c = widget.config) === null || _c === void 0 ? void 0 : _c.placeholder) || "How can I help you today?" })) : (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [chatMessages.map((message) => (jsxRuntimeExports.jsx("div", { className: cn("flex", message.role === "user" ? "justify-end" : "justify-start"), children: jsxRuntimeExports.jsxs("div", { className: cn("max-w-[80%] rounded-lg px-4 py-2 text-xs", message.role === "user"
39218
+ ? "bg-blue-500 text-white"
39219
+ : "bg-gray-100 text-gray-900"), children: [jsxRuntimeExports.jsx("div", { className: "whitespace-pre-wrap", children: jsxRuntimeExports.jsx(Markdown, { children: message.content }) }), message.createdAt && (jsxRuntimeExports.jsx("div", { className: cn("text-[10px] mt-1", message.role === "user" ? "text-blue-100" : "text-gray-500"), children: new Date(message.createdAt).toLocaleTimeString() }))] }) }, message.id))), isLoading && (jsxRuntimeExports.jsx("div", { className: "flex justify-start", children: jsxRuntimeExports.jsx("div", { className: "bg-gray-100 rounded-lg px-4 py-2 text-xs", children: jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntimeExports.jsxs("div", { className: "flex space-x-1", children: [jsxRuntimeExports.jsx("div", { className: "w-2 h-2 bg-gray-400 rounded-full animate-bounce", style: { animationDelay: '0ms' } }), jsxRuntimeExports.jsx("div", { className: "w-2 h-2 bg-gray-400 rounded-full animate-bounce", style: { animationDelay: '150ms' } }), jsxRuntimeExports.jsx("div", { className: "w-2 h-2 bg-gray-400 rounded-full animate-bounce", style: { animationDelay: '300ms' } })] }), jsxRuntimeExports.jsx("span", { className: "text-gray-500", children: "Thinking..." })] }) }) })), jsxRuntimeExports.jsx("div", { ref: messagesEndRef })] })) }), jsxRuntimeExports.jsx("form", { onSubmit: handleSubmit, className: "border-t p-4", children: jsxRuntimeExports.jsxs("div", { className: "flex gap-2 relative", children: [jsxRuntimeExports.jsx("textarea", { value: inputValue, onChange: (e) => setInputValue(e.target.value), placeholder: ((_d = widget.config) === null || _d === void 0 ? void 0 : _d.placeholder) || "Type a message...", className: "resize-none h-20 overflow-y-auto flex-1 px-3 py-2 text-xs border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500" }), jsxRuntimeExports.jsx("button", { type: "submit", disabled: !inputValue.trim(), className: cn("absolute bottom-0 right-0 p-2 rounded-lg text-white flex items-center justify-center bg-transparent"), children: jsxRuntimeExports.jsx(Send, { className: cn("h-4 w-4", inputValue.trim()
39220
+ ? "text-primary-600"
39221
+ : "text-gray-600 cursor-not-allowed") }) })] }) })] })] }));
39191
39222
  }
39192
39223
  function ChatbotWidget({ widget, showHeader = true, widgetBackendUrl, onResetReady, widgetIds, datasetId, }) {
39193
39224
  var _a, _b;
@@ -39377,7 +39408,6 @@ function CopilotKitPieChart({ widget, showHeader, styles, onResetReady, widgetBa
39377
39408
  const isFirstLoad = (_a = widget.config) === null || _a === void 0 ? void 0 : _a.isFirstLoad;
39378
39409
  const content = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.content;
39379
39410
  const widget_data = (_c = widget.widget_data) === null || _c === void 0 ? void 0 : _c.pie_chart_data;
39380
- console.log('widget_data===>', widget_data);
39381
39411
  const { threadId, setThreadId } = useCopilotContext();
39382
39412
  const timeoutRef = useRef(null);
39383
39413
  const [apiCallCount, setApiCallCount] = useState(0);
@@ -39689,7 +39719,6 @@ function CopilotKitSeriesBarChart$1({ widget, showHeader, styles, onResetReady,
39689
39719
  const isFirstLoad = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.isFirstLoad;
39690
39720
  const content = (_c = widget.config) === null || _c === void 0 ? void 0 : _c.content;
39691
39721
  const widget_data = (_d = widget.widget_data) === null || _d === void 0 ? void 0 : _d.series_bar_chart_data;
39692
- console.log('widget_data===>', widget_data);
39693
39722
  const { threadId, setThreadId } = useCopilotContext();
39694
39723
  const timeoutRef = useRef(null);
39695
39724
  const [apiCallCount, setApiCallCount] = useState(0);
@@ -40001,7 +40030,6 @@ function CopilotKitSeriesBarChart({ widget, showHeader, styles, onResetReady, wi
40001
40030
  const isFirstLoad = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.isFirstLoad;
40002
40031
  const content = (_c = widget.config) === null || _c === void 0 ? void 0 : _c.content;
40003
40032
  const widget_data = (_d = widget.widget_data) === null || _d === void 0 ? void 0 : _d.series_bar_chart_data;
40004
- console.log('widget_data===>', widget_data);
40005
40033
  const { threadId, setThreadId } = useCopilotContext();
40006
40034
  const timeoutRef = useRef(null);
40007
40035
  const [apiCallCount, setApiCallCount] = useState(0);
@@ -40161,7 +40189,8 @@ const createInitialChartState = (datasetId, dataGridState) => {
40161
40189
  total_rows: (dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.metadata.total_rows) || 0,
40162
40190
  total_columns: (dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.metadata.total_columns) || 0,
40163
40191
  numeric_columns: (dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.metadata.numeric_columns) || []
40164
- }
40192
+ },
40193
+ grouping: (dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.grouping) || undefined
40165
40194
  },
40166
40195
  dataset_id: datasetId || "home_generation_dataset"
40167
40196
  };
@@ -40295,7 +40324,6 @@ function CopilotKitDataGrid({ widget, showHeader, styles, onResetReady, widgetBa
40295
40324
  const isFirstLoad = (_a = widget.config) === null || _a === void 0 ? void 0 : _a.isFirstLoad;
40296
40325
  const content = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.content;
40297
40326
  const widget_data = (_c = widget.widget_data) === null || _c === void 0 ? void 0 : _c.matrix_grid_data;
40298
- console.log('widget_data===>', widget_data);
40299
40327
  const { threadId, setThreadId } = useCopilotContext();
40300
40328
  const timeoutRef = useRef(null);
40301
40329
  const [apiCallCount, setApiCallCount] = useState(0);
@@ -41308,7 +41336,7 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
41308
41336
  onCloseWidgetPallete && onCloseWidgetPallete();
41309
41337
  }, defaultAgentName: defaultAgentName }), jsxRuntimeExports.jsx(EditWidgetDialog, { editingWidget: editingWidget, setWidgets: setWidgets, initialText: editInitialQuery, isOpen: showEditModal, onClose: () => setShowEditModal(false), onSubmit: handleEditSubmit }), jsxRuntimeExports.jsx("div", { className: "min-h-full", onDragOver: (e) => e.preventDefault(), onDrop: handleDrop, onClick: () => setSelectedWidget(null), children: isLoading ? (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: jsxRuntimeExports.jsx(Loader2, { className: "h-8 w-8 animate-spin" }) })) : (jsxRuntimeExports.jsx(RGL, { className: "layout m-0 p-0 gap-2", layouts: { lg: getLayoutFromWidgets() }, breakpoints: { lg: 1200, md: 996, sm: 768, xs: 480 }, cols: { lg: 12, md: 8, sm: 6, xs: 2 }, rowHeight: 60, isDraggable: isEditing, isResizable: isEditing, draggableHandle: ".drag-icon", onLayoutChange: handleLayoutChange, compactType: "vertical", containerPadding: [0, 0], margin: [16, 16], children: widgets.map((w) => {
41310
41338
  var _a, _b;
41311
- 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-20' : 'pb-14'}`} overflow-hidden`, children: [isEditing &&
41339
+ 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 &&
41312
41340
  jsxRuntimeExports.jsxs("div", { className: `flex items-center justify-end mb-4 relative ${(w.type === "text" || w.type === "spacer") ? "pl-4 pr-4 pt-4" : ""}`, children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center drag-icon cursor-grab absolute left-1/2 -translate-x-1/2", children: [jsxRuntimeExports.jsx(GripHorizontal, { className: "" }), jsxRuntimeExports.jsx(GripHorizontal, { className: "-ml-[3px]" }), jsxRuntimeExports.jsx(GripHorizontal, { className: "-ml-[3px]" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 cursor-pointer justify-end", children: [jsxRuntimeExports.jsx(Trash2, { onClick: () => removeWidget(w.id), className: "w-5 h-5 text-red-700" }), w.type !== "spacer" && jsxRuntimeExports.jsx(Edit, { onClick: () => onClickSettings && onClickSettings(w), className: "w-5 h-5 text-gray-600" })] })] }), jsxRuntimeExports.jsxs("div", { className: `${((w === null || w === void 0 ? void 0 : w.type) === 'text' || (w === null || w === void 0 ? void 0 : w.type) === 'spacer') ? `${isEditing ? 'px-4' : ''}` : "h-full"} w-full relative`, children: [(w === null || w === void 0 ? void 0 : w.type) === "chatbot" &&
41313
41341
  jsxRuntimeExports.jsxs("div", { className: "relative z-50", children: [jsxRuntimeExports.jsx("div", { onClick: () => handleClearChat(w.id), onMouseOver: () => setVisibleClearButton(true), onMouseLeave: () => setVisibleClearButton(false), className: "absolute top-[12px] right-0 z-40 flex align-middle justify-center gap-2 text-sm px-4 py-2 border-primary-300 rounded-l-sm w-fit bg-primary-700 text-white cursor-pointer shadow-md transition-all", children: jsxRuntimeExports.jsx(MessageCircleX, { className: "w-5 h-5" }) }), jsxRuntimeExports.jsx("span", { className: `absolute top-[56px] right-[16px] z-50 w-max py-1 text-xs px-2 rounded-sm text-white bg-gray-950 ${visibleClearButton ? "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));
41314
41342
  }) })) })] }));
package/dist/index.js CHANGED
@@ -16,7 +16,6 @@ var Editor = require('@monaco-editor/react');
16
16
  var reactGridLayout = require('react-grid-layout');
17
17
  var uuid = require('uuid');
18
18
  var reactCore = require('@copilotkit/react-core');
19
- var reactUi = require('@copilotkit/react-ui');
20
19
  var CheckboxPrimitive = require('@radix-ui/react-checkbox');
21
20
  var DialogPrimitive = require('@radix-ui/react-dialog');
22
21
 
@@ -16630,7 +16629,6 @@ var plugin$1 = {
16630
16629
  Chart$1.register(CategoryScale, LinearScale, PointElement, LineElement, plugin_title, plugin_tooltip, plugin_legend);
16631
16630
  function SeriesLineChart({ orientation, title, data, options, className, units, content, x_axis_title, y_axis_title }) {
16632
16631
  var _a, _b;
16633
- console.log('x_axis_title==>', x_axis_title);
16634
16632
  const formatValue = (value) => {
16635
16633
  const numValue = typeof value === 'string' ? parseFloat(value) : value;
16636
16634
  if (!isNaN(numValue)) {
@@ -17678,6 +17676,8 @@ function LineChart({ title, data, options, className, units, content }) {
17678
17676
  function DataGrid({ title, data, className }) {
17679
17677
  var _a;
17680
17678
  const { columns, rows, units, grouped = false, grouping } = data;
17679
+ console.log('title==>', title);
17680
+ console.log('grouping==>', grouping);
17681
17681
  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
17682
  const toggleGroup = (groupValue) => {
17683
17683
  const newExpanded = new Set(expandedGroups);
@@ -39181,7 +39181,25 @@ function CopilotKitChatbot({ widget, showHeader, styles, onResetReady, widgetIds
39181
39181
  dataset_id: datasetId
39182
39182
  },
39183
39183
  });
39184
- const { reset } = reactCore.useCopilotChat();
39184
+ const { reset, visibleMessages, appendMessage, isLoading } = reactCore.useCopilotChat();
39185
+ const [inputValue, setInputValue] = React.useState("");
39186
+ const [chatMessages, setChatMessages] = React.useState([]);
39187
+ const messagesEndRef = React.useRef(null);
39188
+ const scrollToBottom = () => {
39189
+ var _a;
39190
+ (_a = messagesEndRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ behavior: "smooth" });
39191
+ };
39192
+ React.useEffect(() => {
39193
+ console.log('visibleMessages==>', visibleMessages);
39194
+ if (visibleMessages.length) {
39195
+ const nonEmptyMessages = visibleMessages.filter((msg) => (msg === null || msg === void 0 ? void 0 : msg.content) && (msg === null || msg === void 0 ? void 0 : msg.content.trim()) !== "");
39196
+ setChatMessages(nonEmptyMessages);
39197
+ }
39198
+ }, [visibleMessages]);
39199
+ // Auto-scroll when messages change or loading state changes
39200
+ React.useEffect(() => {
39201
+ scrollToBottom();
39202
+ }, [chatMessages, isLoading]);
39185
39203
  // Register the reset function with the parent component
39186
39204
  React.useEffect(() => {
39187
39205
  if (onResetReady && reset && widget.id) {
@@ -39209,12 +39227,25 @@ function CopilotKitChatbot({ widget, showHeader, styles, onResetReady, widgetIds
39209
39227
  window.removeEventListener('clearChartState', handleClearChartState);
39210
39228
  };
39211
39229
  }, [widget.id, widgetIds, datasetId, setChatbotState]);
39212
- return (jsxRuntimeExports.jsxs("div", { className: cn("flex flex-col h-full"), children: [showHeader && (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-between pb-2 border-b", children: jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntimeExports.jsx(lucideReact.Bot, { className: "h-4 w-4" }), jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })] }) })), jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: jsxRuntimeExports.jsx(reactUi.CopilotChat, { className: "h-full text-xs [&_.copilot-chat-message]:text-xs [&_.copilot-chat-input]:text-xs", labels: {
39213
- title: ((_b = widget.config) === null || _b === void 0 ? void 0 : _b.copilotTitle) || widget.title,
39214
- initial: ((_c = widget.config) === null || _c === void 0 ? void 0 : _c.copilotInitialMessage) || ((_d = widget.config) === null || _d === void 0 ? void 0 : _d.placeholder) || "How can I help you today?"
39215
- }, onSubmitMessage: () => {
39216
- setChatbotState(prevState => (Object.assign(Object.assign({}, prevState), { widget_ids: widgetIds, dataset_id: datasetId })));
39217
- } }) })] }));
39230
+ const handleSubmit = (e) => {
39231
+ e.preventDefault();
39232
+ if (!inputValue.trim())
39233
+ return;
39234
+ // Update chatbot state before sending message
39235
+ setChatbotState(prevState => (Object.assign(Object.assign({}, prevState), { widget_ids: widgetIds, dataset_id: datasetId })));
39236
+ // Append the user message
39237
+ appendMessage(new TextMessage({
39238
+ content: inputValue,
39239
+ role: Role.User,
39240
+ }));
39241
+ // Clear input
39242
+ setInputValue("");
39243
+ };
39244
+ return (jsxRuntimeExports.jsxs("div", { className: cn("flex flex-col h-full"), children: [showHeader && (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-between pb-2 border-b", children: jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntimeExports.jsx(lucideReact.Bot, { className: "h-4 w-4" }), jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })] }) })), jsxRuntimeExports.jsxs("div", { className: "flex-1 h-full flex flex-col", children: [jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-y-auto p-4 space-y-4", children: chatMessages.length === 0 ? (jsxRuntimeExports.jsx("div", { className: "text-center text-gray-500 text-xs mt-8", children: ((_b = widget.config) === null || _b === void 0 ? void 0 : _b.copilotInitialMessage) || ((_c = widget.config) === null || _c === void 0 ? void 0 : _c.placeholder) || "How can I help you today?" })) : (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [chatMessages.map((message) => (jsxRuntimeExports.jsx("div", { className: cn("flex", message.role === "user" ? "justify-end" : "justify-start"), children: jsxRuntimeExports.jsxs("div", { className: cn("max-w-[80%] rounded-lg px-4 py-2 text-xs", message.role === "user"
39245
+ ? "bg-blue-500 text-white"
39246
+ : "bg-gray-100 text-gray-900"), children: [jsxRuntimeExports.jsx("div", { className: "whitespace-pre-wrap", children: jsxRuntimeExports.jsx(Markdown, { children: message.content }) }), message.createdAt && (jsxRuntimeExports.jsx("div", { className: cn("text-[10px] mt-1", message.role === "user" ? "text-blue-100" : "text-gray-500"), children: new Date(message.createdAt).toLocaleTimeString() }))] }) }, message.id))), isLoading && (jsxRuntimeExports.jsx("div", { className: "flex justify-start", children: jsxRuntimeExports.jsx("div", { className: "bg-gray-100 rounded-lg px-4 py-2 text-xs", children: jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntimeExports.jsxs("div", { className: "flex space-x-1", children: [jsxRuntimeExports.jsx("div", { className: "w-2 h-2 bg-gray-400 rounded-full animate-bounce", style: { animationDelay: '0ms' } }), jsxRuntimeExports.jsx("div", { className: "w-2 h-2 bg-gray-400 rounded-full animate-bounce", style: { animationDelay: '150ms' } }), jsxRuntimeExports.jsx("div", { className: "w-2 h-2 bg-gray-400 rounded-full animate-bounce", style: { animationDelay: '300ms' } })] }), jsxRuntimeExports.jsx("span", { className: "text-gray-500", children: "Thinking..." })] }) }) })), jsxRuntimeExports.jsx("div", { ref: messagesEndRef })] })) }), jsxRuntimeExports.jsx("form", { onSubmit: handleSubmit, className: "border-t p-4", children: jsxRuntimeExports.jsxs("div", { className: "flex gap-2 relative", children: [jsxRuntimeExports.jsx("textarea", { value: inputValue, onChange: (e) => setInputValue(e.target.value), placeholder: ((_d = widget.config) === null || _d === void 0 ? void 0 : _d.placeholder) || "Type a message...", className: "resize-none h-20 overflow-y-auto flex-1 px-3 py-2 text-xs border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500" }), jsxRuntimeExports.jsx("button", { type: "submit", disabled: !inputValue.trim(), className: cn("absolute bottom-0 right-0 p-2 rounded-lg text-white flex items-center justify-center bg-transparent"), children: jsxRuntimeExports.jsx(lucideReact.Send, { className: cn("h-4 w-4", inputValue.trim()
39247
+ ? "text-primary-600"
39248
+ : "text-gray-600 cursor-not-allowed") }) })] }) })] })] }));
39218
39249
  }
39219
39250
  function ChatbotWidget({ widget, showHeader = true, widgetBackendUrl, onResetReady, widgetIds, datasetId, }) {
39220
39251
  var _a, _b;
@@ -39404,7 +39435,6 @@ function CopilotKitPieChart({ widget, showHeader, styles, onResetReady, widgetBa
39404
39435
  const isFirstLoad = (_a = widget.config) === null || _a === void 0 ? void 0 : _a.isFirstLoad;
39405
39436
  const content = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.content;
39406
39437
  const widget_data = (_c = widget.widget_data) === null || _c === void 0 ? void 0 : _c.pie_chart_data;
39407
- console.log('widget_data===>', widget_data);
39408
39438
  const { threadId, setThreadId } = reactCore.useCopilotContext();
39409
39439
  const timeoutRef = React.useRef(null);
39410
39440
  const [apiCallCount, setApiCallCount] = React.useState(0);
@@ -39716,7 +39746,6 @@ function CopilotKitSeriesBarChart$1({ widget, showHeader, styles, onResetReady,
39716
39746
  const isFirstLoad = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.isFirstLoad;
39717
39747
  const content = (_c = widget.config) === null || _c === void 0 ? void 0 : _c.content;
39718
39748
  const widget_data = (_d = widget.widget_data) === null || _d === void 0 ? void 0 : _d.series_bar_chart_data;
39719
- console.log('widget_data===>', widget_data);
39720
39749
  const { threadId, setThreadId } = reactCore.useCopilotContext();
39721
39750
  const timeoutRef = React.useRef(null);
39722
39751
  const [apiCallCount, setApiCallCount] = React.useState(0);
@@ -40028,7 +40057,6 @@ function CopilotKitSeriesBarChart({ widget, showHeader, styles, onResetReady, wi
40028
40057
  const isFirstLoad = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.isFirstLoad;
40029
40058
  const content = (_c = widget.config) === null || _c === void 0 ? void 0 : _c.content;
40030
40059
  const widget_data = (_d = widget.widget_data) === null || _d === void 0 ? void 0 : _d.series_bar_chart_data;
40031
- console.log('widget_data===>', widget_data);
40032
40060
  const { threadId, setThreadId } = reactCore.useCopilotContext();
40033
40061
  const timeoutRef = React.useRef(null);
40034
40062
  const [apiCallCount, setApiCallCount] = React.useState(0);
@@ -40188,7 +40216,8 @@ const createInitialChartState = (datasetId, dataGridState) => {
40188
40216
  total_rows: (dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.metadata.total_rows) || 0,
40189
40217
  total_columns: (dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.metadata.total_columns) || 0,
40190
40218
  numeric_columns: (dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.metadata.numeric_columns) || []
40191
- }
40219
+ },
40220
+ grouping: (dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.grouping) || undefined
40192
40221
  },
40193
40222
  dataset_id: datasetId || "home_generation_dataset"
40194
40223
  };
@@ -40322,7 +40351,6 @@ function CopilotKitDataGrid({ widget, showHeader, styles, onResetReady, widgetBa
40322
40351
  const isFirstLoad = (_a = widget.config) === null || _a === void 0 ? void 0 : _a.isFirstLoad;
40323
40352
  const content = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.content;
40324
40353
  const widget_data = (_c = widget.widget_data) === null || _c === void 0 ? void 0 : _c.matrix_grid_data;
40325
- console.log('widget_data===>', widget_data);
40326
40354
  const { threadId, setThreadId } = reactCore.useCopilotContext();
40327
40355
  const timeoutRef = React.useRef(null);
40328
40356
  const [apiCallCount, setApiCallCount] = React.useState(0);
@@ -41335,7 +41363,7 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
41335
41363
  onCloseWidgetPallete && onCloseWidgetPallete();
41336
41364
  }, defaultAgentName: defaultAgentName }), jsxRuntimeExports.jsx(EditWidgetDialog, { editingWidget: editingWidget, setWidgets: setWidgets, initialText: editInitialQuery, isOpen: showEditModal, onClose: () => setShowEditModal(false), onSubmit: handleEditSubmit }), jsxRuntimeExports.jsx("div", { className: "min-h-full", onDragOver: (e) => e.preventDefault(), onDrop: handleDrop, onClick: () => setSelectedWidget(null), children: isLoading ? (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: jsxRuntimeExports.jsx(lucideReact.Loader2, { className: "h-8 w-8 animate-spin" }) })) : (jsxRuntimeExports.jsx(RGL, { className: "layout m-0 p-0 gap-2", layouts: { lg: getLayoutFromWidgets() }, breakpoints: { lg: 1200, md: 996, sm: 768, xs: 480 }, cols: { lg: 12, md: 8, sm: 6, xs: 2 }, rowHeight: 60, isDraggable: isEditing, isResizable: isEditing, draggableHandle: ".drag-icon", onLayoutChange: handleLayoutChange, compactType: "vertical", containerPadding: [0, 0], margin: [16, 16], children: widgets.map((w) => {
41337
41365
  var _a, _b;
41338
- 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-20' : 'pb-14'}`} overflow-hidden`, children: [isEditing &&
41366
+ 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 &&
41339
41367
  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" && 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" &&
41340
41368
  jsxRuntimeExports.jsxs("div", { className: "relative z-50", children: [jsxRuntimeExports.jsx("div", { onClick: () => handleClearChat(w.id), onMouseOver: () => setVisibleClearButton(true), onMouseLeave: () => setVisibleClearButton(false), 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 ? "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));
41341
41369
  }) })) })] }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dp-widgets-framework",
3
- "version": "1.4.2",
3
+ "version": "1.4.5",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org"