dp-widgets-framework 1.5.3 → 1.5.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.
Files changed (4) hide show
  1. package/README.md +477 -477
  2. package/dist/index.esm.js +39 -21
  3. package/dist/index.js +39 -21
  4. package/package.json +138 -138
package/dist/index.esm.js CHANGED
@@ -1841,14 +1841,14 @@ function WidgetSettingsPanel({ pageId, widget, onClose, onWidgetUpdate, widgetBa
1841
1841
  const renderCodeSettings = () => {
1842
1842
  var _a;
1843
1843
  return (jsxRuntimeExports.jsx("div", { className: "space-y-4", children: jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Custom Widget Code" }), jsxRuntimeExports.jsx(CodeEditor, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.customCode) ||
1844
- `// Custom search widget code
1845
- // You can modify the widget behavior here
1846
- function customSearch(query) {
1847
- // Your custom search logic
1848
- console.log('Searching for:', query);
1849
- return {
1850
- // Return your search results
1851
- };
1844
+ `// Custom search widget code
1845
+ // You can modify the widget behavior here
1846
+ function customSearch(query) {
1847
+ // Your custom search logic
1848
+ console.log('Searching for:', query);
1849
+ return {
1850
+ // Return your search results
1851
+ };
1852
1852
  }`, onChange: (value) => updateConfig({
1853
1853
  customCode: value || "",
1854
1854
  }) })] }) }));
@@ -39279,7 +39279,7 @@ const createLoadingComponent$4 = (message = "Loading filter data...") => (jsxRun
39279
39279
  const createInitialFilterState = (datasetId, filterData) => {
39280
39280
  return {
39281
39281
  column_values: filterData || [],
39282
- dataset_id: datasetId || ""
39282
+ dashboard_id: datasetId || ""
39283
39283
  };
39284
39284
  };
39285
39285
  const loadAgentState$4 = async (widgetBackendUrl, threadId, agentName) => {
@@ -39350,7 +39350,7 @@ const convertFilterStateToGroups = (filterState) => {
39350
39350
  })),
39351
39351
  }));
39352
39352
  };
39353
- function FiltersContent({ filterGroups, showHeader, onFilterChange, widget, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout, filterState, onApplyFilters, }) {
39353
+ function FiltersContent({ filterGroups, showHeader, onFilterChange, widget, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout, filterState, onApplyFilters, isEditing = false, }) {
39354
39354
  const hasCalledRef = useRef(false);
39355
39355
  const [expandedGroups, setExpandedGroups] = useState({});
39356
39356
  const [selectedFilters, setSelectedFilters] = useState({});
@@ -39455,9 +39455,22 @@ function FiltersContent({ filterGroups, showHeader, onFilterChange, widget, appe
39455
39455
  if (onFilterChange) {
39456
39456
  onFilterChange({});
39457
39457
  }
39458
- }, className: "py-1.5 text-sm font-medium text-primary-600 hover:text-primary-800 hover:bg-primary-50 rounded-md transition-colors px-2", children: "Clear All Filters" })) : (jsxRuntimeExports.jsx("div", {})), jsxRuntimeExports.jsx(Button, { onClick: () => { onApplyFilters === null || onApplyFilters === void 0 ? void 0 : onApplyFilters(selectedFilters); }, className: "bg-primary-600 hover:bg-primary-700 text-white", children: "Apply Filters" })] }) })] }));
39458
+ }, className: "py-1.5 text-sm font-medium text-primary-600 hover:text-primary-800 hover:bg-primary-50 rounded-md transition-colors px-2", children: "Clear All Filters" })) : (jsxRuntimeExports.jsx("div", {})), jsxRuntimeExports.jsx(Button, { onClick: () => {
39459
+ // Convert option IDs back to original label values
39460
+ const filtersWithLabels = {};
39461
+ Object.entries(selectedFilters).forEach(([groupId, optionIds]) => {
39462
+ const group = filterGroups.find(g => g.id === groupId);
39463
+ if (group) {
39464
+ filtersWithLabels[groupId] = optionIds.map(optionId => {
39465
+ const option = group.options.find(opt => opt.id === optionId);
39466
+ return (option === null || option === void 0 ? void 0 : option.label) || optionId;
39467
+ });
39468
+ }
39469
+ });
39470
+ onApplyFilters === null || onApplyFilters === void 0 ? void 0 : onApplyFilters(filtersWithLabels);
39471
+ }, disabled: isEditing, className: `${isEditing ? 'bg-gray-400 cursor-not-allowed' : 'bg-primary-600 hover:bg-primary-700'} text-white`, title: isEditing ? 'Save the layout first to apply filters' : '', children: "Apply Filters" })] }) })] }));
39459
39472
  }
39460
- function CopilotKitFilters({ widget, showHeader, onFilterChange, onResetReady, widgetBackendUrl, datasetId, onApplyFilters, }) {
39473
+ function CopilotKitFilters({ widget, showHeader, onFilterChange, onResetReady, widgetBackendUrl, datasetId, onApplyFilters, isEditing = false, }) {
39461
39474
  var _a, _b, _c, _d, _e, _f;
39462
39475
  const isFirstLoad = (_a = widget.config) === null || _a === void 0 ? void 0 : _a.isFirstLoad;
39463
39476
  const widget_data = (_b = widget.widget_data) === null || _b === void 0 ? void 0 : _b.column_values;
@@ -39566,9 +39579,9 @@ function CopilotKitFilters({ widget, showHeader, onFilterChange, onResetReady, w
39566
39579
  const filterGroups = convertFilterStateToGroups(filterState);
39567
39580
  return (jsxRuntimeExports.jsx("div", { className: cn("flex flex-col h-full"), children: (filterState === null || filterState === void 0 ? void 0 : filterState.agent_message) &&
39568
39581
  (!((_e = filterState.column_values) === null || _e === void 0 ? void 0 : _e.length))
39569
- ? (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: filterState.agent_message }) }) })) : (jsxRuntimeExports.jsx(FiltersContent, { filterGroups: filterGroups, showHeader: showHeader, onFilterChange: onFilterChange, widget: widget, appendMessage: appendMessage, query: (_f = widget.config) === null || _f === void 0 ? void 0 : _f.query, isFirstLoad: isFirstLoad, widgetBackendUrl: widgetBackendUrl, widgetId: widget.id, startLoadingTimeout: startLoadingTimeout, clearLoadingTimeout: clearLoadingTimeout, filterState: filterState, onApplyFilters: onApplyFilters })) }));
39582
+ ? (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, isEditing: isEditing })) }));
39570
39583
  }
39571
- function FiltersWidget({ widget, showHeader = true, onConfigUpdate, onFilterChange, widgetBackendUrl, onResetReady, datasetId, onApplyFilters, }) {
39584
+ function FiltersWidget({ widget, showHeader = true, onConfigUpdate, onFilterChange, widgetBackendUrl, onResetReady, datasetId, onApplyFilters, isEditing = false, }) {
39572
39585
  var _a;
39573
39586
  const getRuntimeUrl = () => {
39574
39587
  var _a;
@@ -39576,7 +39589,7 @@ function FiltersWidget({ widget, showHeader = true, onConfigUpdate, onFilterChan
39576
39589
  const agentName = ((_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentName) || 'default-agent';
39577
39590
  return `${baseUrl}/api/copilot/${agentName}`;
39578
39591
  };
39579
- return (jsxRuntimeExports.jsx(CopilotKit, { runtimeUrl: getRuntimeUrl(), showDevConsole: false, agent: ((_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentName) || "widget_assistant", children: jsxRuntimeExports.jsx(CopilotKitFilters, { widget: widget, showHeader: showHeader, onFilterChange: onFilterChange, onResetReady: onResetReady, widgetBackendUrl: widgetBackendUrl, datasetId: datasetId, onApplyFilters: onApplyFilters }) }));
39592
+ return (jsxRuntimeExports.jsx(CopilotKit, { runtimeUrl: getRuntimeUrl(), showDevConsole: false, agent: ((_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentName) || "widget_assistant", children: jsxRuntimeExports.jsx(CopilotKitFilters, { widget: widget, showHeader: showHeader, onFilterChange: onFilterChange, onResetReady: onResetReady, widgetBackendUrl: widgetBackendUrl, datasetId: datasetId, onApplyFilters: onApplyFilters, isEditing: isEditing }) }));
39580
39593
  }
39581
39594
 
39582
39595
  const CHART_REFRESH_TIMEOUT$3 = 3000;
@@ -40787,7 +40800,7 @@ function DatagridWidget({ widget, showHeader = true, widgetBackendUrl, onResetRe
40787
40800
  return (jsxRuntimeExports.jsx(CopilotKit, { runtimeUrl: getRuntimeUrl(), showDevConsole: false, agent: ((_b = widget.config) === null || _b === void 0 ? void 0 : _b.agentName) || "widget_assistant", children: jsxRuntimeExports.jsx(CopilotKitDataGrid, { widget: widget, showHeader: showHeader, styles: styles, onResetReady: onResetReady, widgetBackendUrl: widgetBackendUrl, datasetId: datasetId }) }));
40788
40801
  }
40789
40802
 
40790
- function WidgetRenderer({ widget, isTemplate = false, onConfigUpdate, widgetBackendUrl, onResetReady, widgetIds, datasetId, onApplyFilters, }) {
40803
+ function WidgetRenderer({ widget, isTemplate = false, onConfigUpdate, widgetBackendUrl, onResetReady, widgetIds, datasetId, pageId, onApplyFilters, isEditing = false, }) {
40791
40804
  const handleConfigUpdate = (config) => {
40792
40805
  if (onConfigUpdate) {
40793
40806
  onConfigUpdate(widget.id, config);
@@ -40813,7 +40826,7 @@ function WidgetRenderer({ widget, isTemplate = false, onConfigUpdate, widgetBack
40813
40826
  case "chatbot":
40814
40827
  return jsxRuntimeExports.jsx(ChatbotWidget, { widget: widget, showHeader: false, widgetBackendUrl: widgetBackendUrl, onResetReady: onResetReady, widgetIds: widgetIds, datasetId: datasetId });
40815
40828
  case "filters":
40816
- return (jsxRuntimeExports.jsx(FiltersWidget, { widget: widget, showHeader: false, widgetBackendUrl: widgetBackendUrl, onResetReady: onResetReady, datasetId: datasetId, onConfigUpdate: handleConfigUpdate, onApplyFilters: onApplyFilters }));
40829
+ return (jsxRuntimeExports.jsx(FiltersWidget, { widget: widget, showHeader: false, widgetBackendUrl: widgetBackendUrl, onResetReady: onResetReady, datasetId: pageId, onConfigUpdate: handleConfigUpdate, onApplyFilters: onApplyFilters, isEditing: isEditing }));
40817
40830
  case "agent":
40818
40831
  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 }));
40819
40832
  default:
@@ -40957,7 +40970,7 @@ function EditWidgetDialog({ editingWidget, setWidgets, initialText, isOpen, onCl
40957
40970
  jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Query:" }), jsxRuntimeExports.jsx(Textarea, { className: "w-full p-2", value: query, onChange: (e) => { var _a; return setQuery((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.value); } })] }), jsxRuntimeExports.jsx("div", { className: "flex justify-end pt-3", children: jsxRuntimeExports.jsx("button", { onClick: handleSubmit, className: "font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none bg-primary-600 text-white hover:bg-primary-700 focus:ring-primary-500 px-6 py-2 text-sm flex items-center gap-2", children: "Submit" }) })] })] })] }) }));
40958
40971
  }
40959
40972
 
40960
- function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk-construction-project-agent" }) {
40973
+ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk-construction-project-agent", hasFiltersWidget = false }) {
40961
40974
  var _a;
40962
40975
  const [selectedWidgetType, setSelectedWidgetType] = useState(null);
40963
40976
  const [query, setQuery] = useState('');
@@ -41176,7 +41189,12 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
41176
41189
  // initialFocusRef={inputRef}
41177
41190
  noOverflowHidden: true, children: jsxRuntimeExports.jsx("div", { children: jsxRuntimeExports.jsx("div", { className: "pt-4", children: !showConfigStep ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: "mb-4", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: "Choose a widget to add to your dashboard:" }) }), jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 gap-3 max-h-[400px] overflow-y-auto", children: widgetOptions.map((widget) => {
41178
41191
  const IconComponent = widget.icon;
41179
- return (jsxRuntimeExports.jsxs("button", { onClick: () => handleWidgetSelect(widget.type), className: "flex items-start gap-3 p-4 border border-slate-200 rounded-lg hover:bg-gray-50 transition-colors text-left", children: [jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 p-2 bg-primary-100 rounded-md", children: jsxRuntimeExports.jsx(IconComponent, { className: "w-5 h-5 text-primary-600" }) }), jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [jsxRuntimeExports.jsx("h3", { className: "font-medium text-sm", children: widget.title }), jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-500 !mt-1", children: widget.description })] })] }, widget.type));
41192
+ const isFiltersDisabled = widget.type === 'filters' && hasFiltersWidget;
41193
+ return (jsxRuntimeExports.jsxs("button", { onClick: () => !isFiltersDisabled && handleWidgetSelect(widget.type), disabled: isFiltersDisabled, className: `flex items-start gap-3 p-4 border border-slate-200 rounded-lg transition-colors text-left ${isFiltersDisabled
41194
+ ? 'opacity-50 cursor-not-allowed bg-gray-100'
41195
+ : 'hover:bg-gray-50 cursor-pointer'}`, children: [jsxRuntimeExports.jsx("div", { className: `flex-shrink-0 p-2 rounded-md ${isFiltersDisabled ? 'bg-gray-200' : 'bg-primary-100'}`, children: jsxRuntimeExports.jsx(IconComponent, { className: `w-5 h-5 ${isFiltersDisabled ? 'text-gray-400' : 'text-primary-600'}` }) }), jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [jsxRuntimeExports.jsx("h3", { className: `font-medium text-sm ${isFiltersDisabled ? 'text-gray-400' : ''}`, children: widget.title }), jsxRuntimeExports.jsx("p", { className: `text-xs !mt-1 ${isFiltersDisabled ? 'text-gray-400' : 'text-gray-500'}`, children: isFiltersDisabled
41196
+ ? 'Only one Filters Widget is allowed per dashboard'
41197
+ : widget.description })] })] }, widget.type));
41180
41198
  }) })] })) : (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'
41181
41199
  ? 'Chatbot widget will be configured with the default agent.'
41182
41200
  : selectedWidgetType === 'text' ? "Customize the widget's appearance"
@@ -41702,11 +41720,11 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
41702
41720
  return (jsxRuntimeExports.jsxs("div", { className: "w-full max-w-full p-4 bg-accent/5", children: [jsxRuntimeExports.jsx(AddWidgetDialog, { isOpen: openWidgetPallete, onClose: onCloseWidgetPallete || (() => { }), addWidgetFn: (widgetType, config) => {
41703
41721
  addWidget(widgetType, config);
41704
41722
  onCloseWidgetPallete && onCloseWidgetPallete();
41705
- }, 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) => {
41723
+ }, defaultAgentName: defaultAgentName, hasFiltersWidget: widgets.some(w => w.type === 'filters') }), 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) => {
41706
41724
  var _a, _b;
41707
41725
  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 &&
41708
41726
  jsxRuntimeExports.jsxs("div", { className: `flex items-center justify-end mb-4 relative ${(w.type === "text" || w.type === "spacer") ? "pl-4 pr-4 pt-4" : ""}`, children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center drag-icon cursor-grab absolute left-1/2 -translate-x-1/2", children: [jsxRuntimeExports.jsx(GripHorizontal, { className: "" }), jsxRuntimeExports.jsx(GripHorizontal, { className: "-ml-[3px]" }), jsxRuntimeExports.jsx(GripHorizontal, { className: "-ml-[3px]" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 cursor-pointer justify-end", children: [jsxRuntimeExports.jsx(Trash2, { onClick: () => removeWidget(w.id), className: "w-5 h-5 text-red-700" }), (w.type !== "spacer" && w.type !== "chatbot") && jsxRuntimeExports.jsx(Edit, { onClick: () => onClickSettings && onClickSettings(w), className: "w-5 h-5 text-gray-600" })] })] }), jsxRuntimeExports.jsxs("div", { className: `${((w === null || w === void 0 ? void 0 : w.type) === 'text' || (w === null || w === void 0 ? void 0 : w.type) === 'spacer') ? `${isEditing ? 'px-4' : ''}` : "h-full"} w-full relative`, children: [(w === null || w === void 0 ? void 0 : w.type) === "chatbot" &&
41709
- jsxRuntimeExports.jsxs("div", { className: "relative z-50", children: [jsxRuntimeExports.jsx("div", { onClick: () => handleClearChat(w === null || w === void 0 ? void 0 : w.id), onMouseOver: () => setVisibleClearButton(w === null || w === void 0 ? void 0 : w.id), onMouseLeave: () => setVisibleClearButton(""), className: "absolute top-[12px] right-0 z-40 flex align-middle justify-center gap-2 text-sm px-4 py-2 border-primary-300 rounded-l-sm w-fit bg-primary-700 text-white cursor-pointer shadow-md transition-all", children: jsxRuntimeExports.jsx(MessageCircleX, { className: "w-5 h-5" }) }), jsxRuntimeExports.jsx("span", { className: `absolute top-[56px] right-[16px] z-50 w-max py-1 text-xs px-2 rounded-sm text-white bg-gray-950 ${visibleClearButton === (w === null || w === void 0 ? void 0 : w.id) ? "block" : "hidden"}`, children: "Clear Chat" })] }), jsxRuntimeExports.jsx(WidgetRenderer, { widget: w, widgetBackendUrl: widgetBackendUrl, onResetReady: handleResetReady, widgetIds: widgets.filter(widget => widget.type !== 'chatbot').map(widget => widget.id), datasetId: datasetId, onApplyFilters: onApplyFilters })] })] }, w.id));
41727
+ jsxRuntimeExports.jsxs("div", { className: "relative z-50", children: [jsxRuntimeExports.jsx("div", { onClick: () => handleClearChat(w === null || w === void 0 ? void 0 : w.id), onMouseOver: () => setVisibleClearButton(w === null || w === void 0 ? void 0 : w.id), onMouseLeave: () => setVisibleClearButton(""), className: "absolute top-[12px] right-0 z-40 flex align-middle justify-center gap-2 text-sm px-4 py-2 border-primary-300 rounded-l-sm w-fit bg-primary-700 text-white cursor-pointer shadow-md transition-all", children: jsxRuntimeExports.jsx(MessageCircleX, { className: "w-5 h-5" }) }), jsxRuntimeExports.jsx("span", { className: `absolute top-[56px] right-[16px] z-50 w-max py-1 text-xs px-2 rounded-sm text-white bg-gray-950 ${visibleClearButton === (w === null || w === void 0 ? void 0 : w.id) ? "block" : "hidden"}`, children: "Clear Chat" })] }), jsxRuntimeExports.jsx(WidgetRenderer, { widget: w, widgetBackendUrl: widgetBackendUrl, onResetReady: handleResetReady, widgetIds: widgets.filter(widget => widget.type !== 'chatbot').map(widget => widget.id), datasetId: datasetId, pageId: pageId, onApplyFilters: onApplyFilters, isEditing: isEditing })] })] }, w.id));
41710
41728
  }) })) })] }));
41711
41729
  }
41712
41730
 
package/dist/index.js CHANGED
@@ -1868,14 +1868,14 @@ function WidgetSettingsPanel({ pageId, widget, onClose, onWidgetUpdate, widgetBa
1868
1868
  const renderCodeSettings = () => {
1869
1869
  var _a;
1870
1870
  return (jsxRuntimeExports.jsx("div", { className: "space-y-4", children: jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Custom Widget Code" }), jsxRuntimeExports.jsx(CodeEditor, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.customCode) ||
1871
- `// Custom search widget code
1872
- // You can modify the widget behavior here
1873
- function customSearch(query) {
1874
- // Your custom search logic
1875
- console.log('Searching for:', query);
1876
- return {
1877
- // Return your search results
1878
- };
1871
+ `// Custom search widget code
1872
+ // You can modify the widget behavior here
1873
+ function customSearch(query) {
1874
+ // Your custom search logic
1875
+ console.log('Searching for:', query);
1876
+ return {
1877
+ // Return your search results
1878
+ };
1879
1879
  }`, onChange: (value) => updateConfig({
1880
1880
  customCode: value || "",
1881
1881
  }) })] }) }));
@@ -39306,7 +39306,7 @@ const createLoadingComponent$4 = (message = "Loading filter data...") => (jsxRun
39306
39306
  const createInitialFilterState = (datasetId, filterData) => {
39307
39307
  return {
39308
39308
  column_values: filterData || [],
39309
- dataset_id: datasetId || ""
39309
+ dashboard_id: datasetId || ""
39310
39310
  };
39311
39311
  };
39312
39312
  const loadAgentState$4 = async (widgetBackendUrl, threadId, agentName) => {
@@ -39377,7 +39377,7 @@ const convertFilterStateToGroups = (filterState) => {
39377
39377
  })),
39378
39378
  }));
39379
39379
  };
39380
- function FiltersContent({ filterGroups, showHeader, onFilterChange, widget, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout, filterState, onApplyFilters, }) {
39380
+ function FiltersContent({ filterGroups, showHeader, onFilterChange, widget, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout, filterState, onApplyFilters, isEditing = false, }) {
39381
39381
  const hasCalledRef = React.useRef(false);
39382
39382
  const [expandedGroups, setExpandedGroups] = React.useState({});
39383
39383
  const [selectedFilters, setSelectedFilters] = React.useState({});
@@ -39482,9 +39482,22 @@ function FiltersContent({ filterGroups, showHeader, onFilterChange, widget, appe
39482
39482
  if (onFilterChange) {
39483
39483
  onFilterChange({});
39484
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" })] }) })] }));
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: () => {
39486
+ // Convert option IDs back to original label values
39487
+ const filtersWithLabels = {};
39488
+ Object.entries(selectedFilters).forEach(([groupId, optionIds]) => {
39489
+ const group = filterGroups.find(g => g.id === groupId);
39490
+ if (group) {
39491
+ filtersWithLabels[groupId] = optionIds.map(optionId => {
39492
+ const option = group.options.find(opt => opt.id === optionId);
39493
+ return (option === null || option === void 0 ? void 0 : option.label) || optionId;
39494
+ });
39495
+ }
39496
+ });
39497
+ onApplyFilters === null || onApplyFilters === void 0 ? void 0 : onApplyFilters(filtersWithLabels);
39498
+ }, disabled: isEditing, className: `${isEditing ? 'bg-gray-400 cursor-not-allowed' : 'bg-primary-600 hover:bg-primary-700'} text-white`, title: isEditing ? 'Save the layout first to apply filters' : '', children: "Apply Filters" })] }) })] }));
39486
39499
  }
39487
- function CopilotKitFilters({ widget, showHeader, onFilterChange, onResetReady, widgetBackendUrl, datasetId, onApplyFilters, }) {
39500
+ function CopilotKitFilters({ widget, showHeader, onFilterChange, onResetReady, widgetBackendUrl, datasetId, onApplyFilters, isEditing = false, }) {
39488
39501
  var _a, _b, _c, _d, _e, _f;
39489
39502
  const isFirstLoad = (_a = widget.config) === null || _a === void 0 ? void 0 : _a.isFirstLoad;
39490
39503
  const widget_data = (_b = widget.widget_data) === null || _b === void 0 ? void 0 : _b.column_values;
@@ -39593,9 +39606,9 @@ function CopilotKitFilters({ widget, showHeader, onFilterChange, onResetReady, w
39593
39606
  const filterGroups = convertFilterStateToGroups(filterState);
39594
39607
  return (jsxRuntimeExports.jsx("div", { className: cn("flex flex-col h-full"), children: (filterState === null || filterState === void 0 ? void 0 : filterState.agent_message) &&
39595
39608
  (!((_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 })) }));
39609
+ ? (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, isEditing: isEditing })) }));
39597
39610
  }
39598
- function FiltersWidget({ widget, showHeader = true, onConfigUpdate, onFilterChange, widgetBackendUrl, onResetReady, datasetId, onApplyFilters, }) {
39611
+ function FiltersWidget({ widget, showHeader = true, onConfigUpdate, onFilterChange, widgetBackendUrl, onResetReady, datasetId, onApplyFilters, isEditing = false, }) {
39599
39612
  var _a;
39600
39613
  const getRuntimeUrl = () => {
39601
39614
  var _a;
@@ -39603,7 +39616,7 @@ function FiltersWidget({ widget, showHeader = true, onConfigUpdate, onFilterChan
39603
39616
  const agentName = ((_a = widget.config) === null || _a === void 0 ? void 0 : _a.agentName) || 'default-agent';
39604
39617
  return `${baseUrl}/api/copilot/${agentName}`;
39605
39618
  };
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 }) }));
39619
+ 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, isEditing: isEditing }) }));
39607
39620
  }
39608
39621
 
39609
39622
  const CHART_REFRESH_TIMEOUT$3 = 3000;
@@ -40814,7 +40827,7 @@ function DatagridWidget({ widget, showHeader = true, widgetBackendUrl, onResetRe
40814
40827
  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 }) }));
40815
40828
  }
40816
40829
 
40817
- function WidgetRenderer({ widget, isTemplate = false, onConfigUpdate, widgetBackendUrl, onResetReady, widgetIds, datasetId, onApplyFilters, }) {
40830
+ function WidgetRenderer({ widget, isTemplate = false, onConfigUpdate, widgetBackendUrl, onResetReady, widgetIds, datasetId, pageId, onApplyFilters, isEditing = false, }) {
40818
40831
  const handleConfigUpdate = (config) => {
40819
40832
  if (onConfigUpdate) {
40820
40833
  onConfigUpdate(widget.id, config);
@@ -40840,7 +40853,7 @@ function WidgetRenderer({ widget, isTemplate = false, onConfigUpdate, widgetBack
40840
40853
  case "chatbot":
40841
40854
  return jsxRuntimeExports.jsx(ChatbotWidget, { widget: widget, showHeader: false, widgetBackendUrl: widgetBackendUrl, onResetReady: onResetReady, widgetIds: widgetIds, datasetId: datasetId });
40842
40855
  case "filters":
40843
- return (jsxRuntimeExports.jsx(FiltersWidget, { widget: widget, showHeader: false, widgetBackendUrl: widgetBackendUrl, onResetReady: onResetReady, datasetId: datasetId, onConfigUpdate: handleConfigUpdate, onApplyFilters: onApplyFilters }));
40856
+ return (jsxRuntimeExports.jsx(FiltersWidget, { widget: widget, showHeader: false, widgetBackendUrl: widgetBackendUrl, onResetReady: onResetReady, datasetId: pageId, onConfigUpdate: handleConfigUpdate, onApplyFilters: onApplyFilters, isEditing: isEditing }));
40844
40857
  case "agent":
40845
40858
  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 }));
40846
40859
  default:
@@ -40984,7 +40997,7 @@ function EditWidgetDialog({ editingWidget, setWidgets, initialText, isOpen, onCl
40984
40997
  jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Query:" }), jsxRuntimeExports.jsx(Textarea, { className: "w-full p-2", value: query, onChange: (e) => { var _a; return setQuery((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.value); } })] }), jsxRuntimeExports.jsx("div", { className: "flex justify-end pt-3", children: jsxRuntimeExports.jsx("button", { onClick: handleSubmit, className: "font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none bg-primary-600 text-white hover:bg-primary-700 focus:ring-primary-500 px-6 py-2 text-sm flex items-center gap-2", children: "Submit" }) })] })] })] }) }));
40985
40998
  }
40986
40999
 
40987
- function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk-construction-project-agent" }) {
41000
+ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk-construction-project-agent", hasFiltersWidget = false }) {
40988
41001
  var _a;
40989
41002
  const [selectedWidgetType, setSelectedWidgetType] = React.useState(null);
40990
41003
  const [query, setQuery] = React.useState('');
@@ -41203,7 +41216,12 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
41203
41216
  // initialFocusRef={inputRef}
41204
41217
  noOverflowHidden: true, children: jsxRuntimeExports.jsx("div", { children: jsxRuntimeExports.jsx("div", { className: "pt-4", children: !showConfigStep ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: "mb-4", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: "Choose a widget to add to your dashboard:" }) }), jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 gap-3 max-h-[400px] overflow-y-auto", children: widgetOptions.map((widget) => {
41205
41218
  const IconComponent = widget.icon;
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));
41219
+ const isFiltersDisabled = widget.type === 'filters' && hasFiltersWidget;
41220
+ return (jsxRuntimeExports.jsxs("button", { onClick: () => !isFiltersDisabled && handleWidgetSelect(widget.type), disabled: isFiltersDisabled, className: `flex items-start gap-3 p-4 border border-slate-200 rounded-lg transition-colors text-left ${isFiltersDisabled
41221
+ ? 'opacity-50 cursor-not-allowed bg-gray-100'
41222
+ : 'hover:bg-gray-50 cursor-pointer'}`, children: [jsxRuntimeExports.jsx("div", { className: `flex-shrink-0 p-2 rounded-md ${isFiltersDisabled ? 'bg-gray-200' : 'bg-primary-100'}`, children: jsxRuntimeExports.jsx(IconComponent, { className: `w-5 h-5 ${isFiltersDisabled ? 'text-gray-400' : 'text-primary-600'}` }) }), jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [jsxRuntimeExports.jsx("h3", { className: `font-medium text-sm ${isFiltersDisabled ? 'text-gray-400' : ''}`, children: widget.title }), jsxRuntimeExports.jsx("p", { className: `text-xs !mt-1 ${isFiltersDisabled ? 'text-gray-400' : 'text-gray-500'}`, children: isFiltersDisabled
41223
+ ? 'Only one Filters Widget is allowed per dashboard'
41224
+ : widget.description })] })] }, widget.type));
41207
41225
  }) })] })) : (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'
41208
41226
  ? 'Chatbot widget will be configured with the default agent.'
41209
41227
  : selectedWidgetType === 'text' ? "Customize the widget's appearance"
@@ -41729,11 +41747,11 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
41729
41747
  return (jsxRuntimeExports.jsxs("div", { className: "w-full max-w-full p-4 bg-accent/5", children: [jsxRuntimeExports.jsx(AddWidgetDialog, { isOpen: openWidgetPallete, onClose: onCloseWidgetPallete || (() => { }), addWidgetFn: (widgetType, config) => {
41730
41748
  addWidget(widgetType, config);
41731
41749
  onCloseWidgetPallete && onCloseWidgetPallete();
41732
- }, 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) => {
41750
+ }, defaultAgentName: defaultAgentName, hasFiltersWidget: widgets.some(w => w.type === 'filters') }), 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) => {
41733
41751
  var _a, _b;
41734
41752
  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 &&
41735
41753
  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" &&
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));
41754
+ 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, pageId: pageId, onApplyFilters: onApplyFilters, isEditing: isEditing })] })] }, w.id));
41737
41755
  }) })) })] }));
41738
41756
  }
41739
41757
 
package/package.json CHANGED
@@ -1,139 +1,139 @@
1
- {
2
- "name": "dp-widgets-framework",
3
- "version": "1.5.3",
4
- "private": false,
5
- "publishConfig": {
6
- "registry": "https://registry.npmjs.org"
7
- },
8
- "description": "A React framework for creating customizable widget dashboards with drag-and-drop functionality",
9
- "keywords": [
10
- "react",
11
- "widgets",
12
- "dashboard",
13
- "framework",
14
- "drag-and-drop",
15
- "customizable"
16
- ],
17
- "homepage": "https://github.com/aretec-inc/di-widgets-framework",
18
- "repository": {
19
- "type": "git",
20
- "url": "https://github.com/aretec-inc/di-widgets-framework.git"
21
- },
22
- "author": "Syed Fakher Uddin",
23
- "files": [
24
- "dist/*.esm.js",
25
- "dist/*.js",
26
- "dist/*.d.ts",
27
- "dist/*.css",
28
- "README.md"
29
- ],
30
- "main": "dist/index.js",
31
- "module": "dist/index.esm.js",
32
- "types": "dist/index.d.ts",
33
- "exports": {
34
- ".": {
35
- "import": "./dist/index.esm.js",
36
- "require": "./dist/index.js",
37
- "default": "./dist/index.js"
38
- }
39
- },
40
- "scripts": {
41
- "dev": "next dev",
42
- "build": "next build",
43
- "start": "next start",
44
- "lint": "next lint",
45
- "format-all-files": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,md}\"",
46
- "build:rollup": "rollup -c --bundleConfigAsCjs",
47
- "prepare": "npm run build:rollup",
48
- "prepublishOnly": "npm run build:rollup",
49
- "init:db": "node scripts/init-db.js",
50
- "test:db": "node scripts/test-db-init.js",
51
- "postbuild": "echo 'Build completed. Run npm run init:db if database initialization is needed.'"
52
- },
53
- "dependencies": {
54
- "@ag-ui/client": "0.0.35",
55
- "@ag-ui/core": "0.0.35",
56
- "@copilotkit/react-core": "1.9.3",
57
- "@copilotkit/react-ui": "1.9.3",
58
- "@copilotkit/runtime": "1.9.3",
59
- "@energiency/chartjs-plugin-piechart-outlabels": "^1.3.5",
60
- "@hello-pangea/dnd": "^17.0.0",
61
- "@monaco-editor/react": "^4.6.0",
62
- "@radix-ui/react-accordion": "^1.2.2",
63
- "@radix-ui/react-avatar": "^1.1.2",
64
- "@radix-ui/react-checkbox": "^1.1.3",
65
- "@radix-ui/react-collapsible": "^1.1.2",
66
- "@radix-ui/react-dialog": "^1.1.5",
67
- "@radix-ui/react-dropdown-menu": "^2.1.5",
68
- "@radix-ui/react-label": "^2.1.1",
69
- "@radix-ui/react-radio-group": "^1.2.2",
70
- "@radix-ui/react-scroll-area": "^1.2.2",
71
- "@radix-ui/react-select": "^2.1.5",
72
- "@radix-ui/react-slider": "^1.2.2",
73
- "@radix-ui/react-slot": "^1.1.1",
74
- "@radix-ui/react-switch": "^1.1.2",
75
- "@radix-ui/react-tabs": "^1.1.2",
76
- "@types/cors": "^2.8.17",
77
- "@types/express": "^5.0.0",
78
- "@types/pg": "^8.11.11",
79
- "@types/react-beautiful-dnd": "^13.1.8",
80
- "@types/react-datepicker": "^7.0.0",
81
- "@types/react-grid-layout": "^1.3.5",
82
- "chart.js": "^4.5.0",
83
- "chartjs-plugin-datalabels": "^2.2.0",
84
- "class-variance-authority": "^0.7.1",
85
- "clsx": "^2.1.1",
86
- "cors": "^2.8.5",
87
- "dotenv": "^16.4.7",
88
- "express": "^4.21.2",
89
- "express-validator": "^7.2.1",
90
- "framer-motion": "^12.0.6",
91
- "lodash": "^4.17.21",
92
- "lucide-react": "^0.474.0",
93
- "next": "14.0.4",
94
- "next-themes": "^0.4.4",
95
- "pg": "^8.13.1",
96
- "react": "^18",
97
- "react-beautiful-dnd": "^13.1.1",
98
- "react-chartjs-2": "^5.3.0",
99
- "react-datepicker": "^7.6.0",
100
- "react-dom": "^18",
101
- "react-error-boundary": "^5.0.0",
102
- "react-grid-layout": "^1.5.0",
103
- "react-markdown": "^9.0.3",
104
- "tailwind-merge": "^3.0.1",
105
- "tailwindcss-animate": "^1.0.7",
106
- "uuid": "^11.0.5",
107
- "zod": "^3.24.1"
108
- },
109
- "devDependencies": {
110
- "@eslint/eslintrc": "^3",
111
- "@rollup/plugin-babel": "^6.0.4",
112
- "@rollup/plugin-commonjs": "^28.0.1",
113
- "@rollup/plugin-json": "^6.1.0",
114
- "@rollup/plugin-node-resolve": "^15.3.0",
115
- "@rollup/plugin-terser": "^0.4.4",
116
- "@rollup/plugin-typescript": "^12.1.1",
117
- "@types/lodash": "^4.17.15",
118
- "@types/node": "^20",
119
- "@types/react": "^18",
120
- "@types/react-dom": "^18",
121
- "autoprefixer": "^10.0.1",
122
- "eslint": "^8.43.0",
123
- "eslint-config-next": "15.1.6",
124
- "eslint-config-node": "^4.1.0",
125
- "eslint-config-prettier": "^8.10.0",
126
- "eslint-plugin-next": "^0.0.0",
127
- "eslint-plugin-node": "^11.1.0",
128
- "eslint-plugin-prettier": "^4.2.1",
129
- "eslint-plugin-react": "^7.32.2",
130
- "postcss": "^8",
131
- "prettier": "^2.8.8",
132
- "rollup": "^4.27.3",
133
- "rollup-plugin-peer-deps-external": "^2.2.4",
134
- "rollup-plugin-postcss": "^4.0.2",
135
- "rollup-plugin-visualizer": "^5.12.0",
136
- "tailwindcss": "^3.3.0",
137
- "typescript": "^5"
138
- }
1
+ {
2
+ "name": "dp-widgets-framework",
3
+ "version": "1.5.5",
4
+ "private": false,
5
+ "publishConfig": {
6
+ "registry": "https://registry.npmjs.org"
7
+ },
8
+ "description": "A React framework for creating customizable widget dashboards with drag-and-drop functionality",
9
+ "keywords": [
10
+ "react",
11
+ "widgets",
12
+ "dashboard",
13
+ "framework",
14
+ "drag-and-drop",
15
+ "customizable"
16
+ ],
17
+ "homepage": "https://github.com/aretec-inc/di-widgets-framework",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/aretec-inc/di-widgets-framework.git"
21
+ },
22
+ "author": "Syed Fakher Uddin",
23
+ "files": [
24
+ "dist/*.esm.js",
25
+ "dist/*.js",
26
+ "dist/*.d.ts",
27
+ "dist/*.css",
28
+ "README.md"
29
+ ],
30
+ "main": "dist/index.js",
31
+ "module": "dist/index.esm.js",
32
+ "types": "dist/index.d.ts",
33
+ "exports": {
34
+ ".": {
35
+ "import": "./dist/index.esm.js",
36
+ "require": "./dist/index.js",
37
+ "default": "./dist/index.js"
38
+ }
39
+ },
40
+ "scripts": {
41
+ "dev": "next dev",
42
+ "build": "next build",
43
+ "start": "next start",
44
+ "lint": "next lint",
45
+ "format-all-files": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,md}\"",
46
+ "build:rollup": "rollup -c --bundleConfigAsCjs",
47
+ "prepare": "npm run build:rollup",
48
+ "prepublishOnly": "npm run build:rollup",
49
+ "init:db": "node scripts/init-db.js",
50
+ "test:db": "node scripts/test-db-init.js",
51
+ "postbuild": "echo 'Build completed. Run npm run init:db if database initialization is needed.'"
52
+ },
53
+ "dependencies": {
54
+ "@ag-ui/client": "0.0.35",
55
+ "@ag-ui/core": "0.0.35",
56
+ "@copilotkit/react-core": "1.9.3",
57
+ "@copilotkit/react-ui": "1.9.3",
58
+ "@copilotkit/runtime": "1.9.3",
59
+ "@energiency/chartjs-plugin-piechart-outlabels": "^1.3.5",
60
+ "@hello-pangea/dnd": "^17.0.0",
61
+ "@monaco-editor/react": "^4.6.0",
62
+ "@radix-ui/react-accordion": "^1.2.2",
63
+ "@radix-ui/react-avatar": "^1.1.2",
64
+ "@radix-ui/react-checkbox": "^1.1.3",
65
+ "@radix-ui/react-collapsible": "^1.1.2",
66
+ "@radix-ui/react-dialog": "^1.1.5",
67
+ "@radix-ui/react-dropdown-menu": "^2.1.5",
68
+ "@radix-ui/react-label": "^2.1.1",
69
+ "@radix-ui/react-radio-group": "^1.2.2",
70
+ "@radix-ui/react-scroll-area": "^1.2.2",
71
+ "@radix-ui/react-select": "^2.1.5",
72
+ "@radix-ui/react-slider": "^1.2.2",
73
+ "@radix-ui/react-slot": "^1.1.1",
74
+ "@radix-ui/react-switch": "^1.1.2",
75
+ "@radix-ui/react-tabs": "^1.1.2",
76
+ "@types/cors": "^2.8.17",
77
+ "@types/express": "^5.0.0",
78
+ "@types/pg": "^8.11.11",
79
+ "@types/react-beautiful-dnd": "^13.1.8",
80
+ "@types/react-datepicker": "^7.0.0",
81
+ "@types/react-grid-layout": "^1.3.5",
82
+ "chart.js": "^4.5.0",
83
+ "chartjs-plugin-datalabels": "^2.2.0",
84
+ "class-variance-authority": "^0.7.1",
85
+ "clsx": "^2.1.1",
86
+ "cors": "^2.8.5",
87
+ "dotenv": "^16.4.7",
88
+ "express": "^4.21.2",
89
+ "express-validator": "^7.2.1",
90
+ "framer-motion": "^12.0.6",
91
+ "lodash": "^4.17.21",
92
+ "lucide-react": "^0.474.0",
93
+ "next": "14.0.4",
94
+ "next-themes": "^0.4.4",
95
+ "pg": "^8.13.1",
96
+ "react": "^18",
97
+ "react-beautiful-dnd": "^13.1.1",
98
+ "react-chartjs-2": "^5.3.0",
99
+ "react-datepicker": "^7.6.0",
100
+ "react-dom": "^18",
101
+ "react-error-boundary": "^5.0.0",
102
+ "react-grid-layout": "^1.5.0",
103
+ "react-markdown": "^9.0.3",
104
+ "tailwind-merge": "^3.0.1",
105
+ "tailwindcss-animate": "^1.0.7",
106
+ "uuid": "^11.0.5",
107
+ "zod": "^3.24.1"
108
+ },
109
+ "devDependencies": {
110
+ "@eslint/eslintrc": "^3",
111
+ "@rollup/plugin-babel": "^6.0.4",
112
+ "@rollup/plugin-commonjs": "^28.0.1",
113
+ "@rollup/plugin-json": "^6.1.0",
114
+ "@rollup/plugin-node-resolve": "^15.3.0",
115
+ "@rollup/plugin-terser": "^0.4.4",
116
+ "@rollup/plugin-typescript": "^12.1.1",
117
+ "@types/lodash": "^4.17.15",
118
+ "@types/node": "^20",
119
+ "@types/react": "^18",
120
+ "@types/react-dom": "^18",
121
+ "autoprefixer": "^10.0.1",
122
+ "eslint": "^8.43.0",
123
+ "eslint-config-next": "15.1.6",
124
+ "eslint-config-node": "^4.1.0",
125
+ "eslint-config-prettier": "^8.10.0",
126
+ "eslint-plugin-next": "^0.0.0",
127
+ "eslint-plugin-node": "^11.1.0",
128
+ "eslint-plugin-prettier": "^4.2.1",
129
+ "eslint-plugin-react": "^7.32.2",
130
+ "postcss": "^8",
131
+ "prettier": "^2.8.8",
132
+ "rollup": "^4.27.3",
133
+ "rollup-plugin-peer-deps-external": "^2.2.4",
134
+ "rollup-plugin-postcss": "^4.0.2",
135
+ "rollup-plugin-visualizer": "^5.12.0",
136
+ "tailwindcss": "^3.3.0",
137
+ "typescript": "^5"
138
+ }
139
139
  }