dp-widgets-framework 1.0.4 → 1.0.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
@@ -37376,7 +37376,7 @@ const IconMap = {
37376
37376
  'pie-chart': PieChart$1,
37377
37377
  'chatbot': Bot,
37378
37378
  };
37379
- function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSelect, refreshKey, widgetBackendUrl, onSaveLayoutReady, openWidgetPallete = false, onCloseWidgetPallete, defaultAgentName = "adk-construction-project-agent" }) {
37379
+ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSelect, refreshKey, widgetBackendUrl, onSaveLayoutReady, openWidgetPallete = false, onCloseWidgetPallete, defaultAgentName = "adk-construction-project-agent", userId }) {
37380
37380
  const [widgets, setWidgets] = useState([]);
37381
37381
  const [availableWidgets, setAvailableWidgets] = useState([]);
37382
37382
  const [isLoading, setIsLoading] = useState(true);
@@ -37497,7 +37497,13 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
37497
37497
  }
37498
37498
  setIsLoading(true);
37499
37499
  try {
37500
- const response = await fetch(getApiUrl(`/api/pages/${pageId}`));
37500
+ const response = await fetch(getApiUrl(`/api/pages/${pageId}`), {
37501
+ method: "GET",
37502
+ headers: {
37503
+ "Content-Type": "application/json",
37504
+ "x-owner-id": userId || "",
37505
+ },
37506
+ });
37501
37507
  if (!response.ok) {
37502
37508
  throw new Error("Failed to load page data");
37503
37509
  }
@@ -37833,62 +37839,7 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
37833
37839
  onCloseWidgetPallete === null || onCloseWidgetPallete === void 0 ? void 0 : onCloseWidgetPallete();
37834
37840
  }, defaultAgentName: defaultAgentName }), jsxRuntimeExports.jsx(EditWidgetDialog, { 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", layouts: { lg: getLayoutFromWidgets() }, breakpoints: { lg: 1200, md: 996, sm: 768, xs: 480 }, cols: { lg: 12, md: 8, sm: 6, xs: 2 }, rowHeight: 100, isDraggable: isEditing, isResizable: isEditing, draggableHandle: ".drag-icon", onLayoutChange: handleLayoutChange, compactType: "vertical", containerPadding: [0, 0], resizeHandles: ["sw", "nw", "se", "ne"], children: widgets.map((w) => (jsxRuntimeExports.jsxs("div", { style: { borderColor: "rgb(147 197 253 / 1)" }, className: `border border-blue-300 rounded-xl p-4 shadow-lg overflow-hidden ${isEditing ? 'pb-20' : 'pb-14'}`, children: [isEditing &&
37835
37841
  jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-end mb-4 relative", 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" }), jsxRuntimeExports.jsx(Edit, { onClick: () => onClickSettings && onClickSettings(w), className: "w-5 h-5 text-gray-600" })] })] }), jsxRuntimeExports.jsxs("div", { className: "w-full h-full relative", children: [(w === null || w === void 0 ? void 0 : w.type) === "chatbot" &&
37836
- jsxRuntimeExports.jsxs("div", { className: "relative z-50", children: [jsxRuntimeExports.jsx("div", { onClick: () => handleClearChat(w.id), onMouseOver: () => setVisibleClearButton(true), onMouseLeave: () => setVisibleClearButton(false), className: "absolute z-40 flex align-middle justify-center gap-2 text-sm px-4 py-2 border-blue-300 rounded-sm dark:bg-white w-fit bg-gray-900 text-white dark:text-gray-900 cursor-pointer shadow-md transition-all", style: { top: "12px", right: "0", borderTopLeftRadius: "4px", borderBottomLeftRadius: "4px" }, children: jsxRuntimeExports.jsx(MessageCircleX, { className: "w-5 h-5" }) }), jsxRuntimeExports.jsx("span", { className: `absolute z-50 w-max py-1 text-xs px-2 rounded-sm dark:text-gray-900 dark:bg-white text-white bg-gray-900 ${visibleClearButton ? "block" : "hidden"}`, style: { top: "56px", right: "16px", borderRadius: "3px" }, children: "Clear Chat" })] }), jsxRuntimeExports.jsx(WidgetRenderer, { widget: w, widgetBackendUrl: widgetBackendUrl, onResetReady: handleResetReady, widgetIds: widgets.filter(widget => widget.type !== 'chatbot').map(widget => widget.id) })] })] }, w.id))) })
37837
- // <ReactGridLayout
37838
- // className="layout"
37839
- // layout={getLayoutFromWidgets()}
37840
- // cols={12}
37841
- // rowHeight={50}
37842
- // onLayoutChange={handleLayoutChange}
37843
- // onDragStart={() => setIsDragging(true)}
37844
- // onDragStop={() => setIsDragging(false)}
37845
- // isDraggable={isEditing}
37846
- // isResizable={isEditing}
37847
- // useCSSTransforms
37848
- // compactType={null}
37849
- // margin={[8, 8]}
37850
- // preventCollision={true}
37851
- // >
37852
- // {widgets.map((widget) => (
37853
- // <div
37854
- // key={widget.id}
37855
- // className={cn(
37856
- // "bg-background rounded-lg shadow-sm border overflow-hidden transition-all",
37857
- // currentSelectedWidget?.id === widget.id &&
37858
- // "ring-2 ring-primary ring-offset-2"
37859
- // )}
37860
- // onClick={(e) => handleWidgetClick(widget, e)}
37861
- // onDoubleClick={(e) => handleWidgetDoubleClick(widget, e)}
37862
- // >
37863
- // {widget.config?.showHeader !== false && (
37864
- // <div className="p-2 border-b flex items-center justify-between">
37865
- // <span className="font-medium text-sm">
37866
- // {widget.title}
37867
- // </span>
37868
- // {isEditing && (
37869
- // <Button
37870
- // variant="ghost"
37871
- // size="sm"
37872
- // onClick={() => removeWidget(widget.id)}
37873
- // >
37874
- // <Trash2 className="h-4 w-4" />
37875
- // </Button>
37876
- // )}
37877
- // </div>
37878
- // )}
37879
- // <div
37880
- // className={cn(
37881
- // "h-full",
37882
- // widget.config?.showHeader !== false &&
37883
- // "h-[calc(100%-40px)]"
37884
- // )}
37885
- // >
37886
- // <WidgetRenderer widget={widget} widgetBackendUrl={widgetBackendUrl} />
37887
- // </div>
37888
- // </div>
37889
- // ))}
37890
- // </ReactGridLayout>
37891
- ) })] }));
37842
+ jsxRuntimeExports.jsxs("div", { className: "relative z-50", children: [jsxRuntimeExports.jsx("div", { onClick: () => handleClearChat(w.id), onMouseOver: () => setVisibleClearButton(true), onMouseLeave: () => setVisibleClearButton(false), className: "absolute z-40 flex align-middle justify-center gap-2 text-sm px-4 py-2 border-blue-300 rounded-sm dark:bg-white w-fit bg-gray-900 text-white dark:text-gray-900 cursor-pointer shadow-md transition-all", style: { top: "12px", right: "0", borderTopLeftRadius: "4px", borderBottomLeftRadius: "4px" }, children: jsxRuntimeExports.jsx(MessageCircleX, { className: "w-5 h-5" }) }), jsxRuntimeExports.jsx("span", { className: `absolute z-50 w-max py-1 text-xs px-2 rounded-sm dark:text-gray-900 dark:bg-white text-white bg-gray-900 ${visibleClearButton ? "block" : "hidden"}`, style: { top: "56px", right: "16px", borderRadius: "3px" }, children: "Clear Chat" })] }), jsxRuntimeExports.jsx(WidgetRenderer, { widget: w, widgetBackendUrl: widgetBackendUrl, onResetReady: handleResetReady, widgetIds: widgets.filter(widget => widget.type !== 'chatbot').map(widget => widget.id) })] })] }, w.id))) })) })] }));
37892
37843
  }
37893
37844
 
37894
37845
  const Checkbox = React.forwardRef((_a, ref) => {
package/dist/index.js CHANGED
@@ -37403,7 +37403,7 @@ const IconMap = {
37403
37403
  'pie-chart': lucideReact.PieChart,
37404
37404
  'chatbot': lucideReact.Bot,
37405
37405
  };
37406
- function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSelect, refreshKey, widgetBackendUrl, onSaveLayoutReady, openWidgetPallete = false, onCloseWidgetPallete, defaultAgentName = "adk-construction-project-agent" }) {
37406
+ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSelect, refreshKey, widgetBackendUrl, onSaveLayoutReady, openWidgetPallete = false, onCloseWidgetPallete, defaultAgentName = "adk-construction-project-agent", userId }) {
37407
37407
  const [widgets, setWidgets] = React.useState([]);
37408
37408
  const [availableWidgets, setAvailableWidgets] = React.useState([]);
37409
37409
  const [isLoading, setIsLoading] = React.useState(true);
@@ -37524,7 +37524,13 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
37524
37524
  }
37525
37525
  setIsLoading(true);
37526
37526
  try {
37527
- const response = await fetch(getApiUrl(`/api/pages/${pageId}`));
37527
+ const response = await fetch(getApiUrl(`/api/pages/${pageId}`), {
37528
+ method: "GET",
37529
+ headers: {
37530
+ "Content-Type": "application/json",
37531
+ "x-owner-id": userId || "",
37532
+ },
37533
+ });
37528
37534
  if (!response.ok) {
37529
37535
  throw new Error("Failed to load page data");
37530
37536
  }
@@ -37860,62 +37866,7 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
37860
37866
  onCloseWidgetPallete === null || onCloseWidgetPallete === void 0 ? void 0 : onCloseWidgetPallete();
37861
37867
  }, defaultAgentName: defaultAgentName }), jsxRuntimeExports.jsx(EditWidgetDialog, { 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", layouts: { lg: getLayoutFromWidgets() }, breakpoints: { lg: 1200, md: 996, sm: 768, xs: 480 }, cols: { lg: 12, md: 8, sm: 6, xs: 2 }, rowHeight: 100, isDraggable: isEditing, isResizable: isEditing, draggableHandle: ".drag-icon", onLayoutChange: handleLayoutChange, compactType: "vertical", containerPadding: [0, 0], resizeHandles: ["sw", "nw", "se", "ne"], children: widgets.map((w) => (jsxRuntimeExports.jsxs("div", { style: { borderColor: "rgb(147 197 253 / 1)" }, className: `border border-blue-300 rounded-xl p-4 shadow-lg overflow-hidden ${isEditing ? 'pb-20' : 'pb-14'}`, children: [isEditing &&
37862
37868
  jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-end mb-4 relative", 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" }), jsxRuntimeExports.jsx(lucideReact.Edit, { onClick: () => onClickSettings && onClickSettings(w), className: "w-5 h-5 text-gray-600" })] })] }), jsxRuntimeExports.jsxs("div", { className: "w-full h-full relative", children: [(w === null || w === void 0 ? void 0 : w.type) === "chatbot" &&
37863
- jsxRuntimeExports.jsxs("div", { className: "relative z-50", children: [jsxRuntimeExports.jsx("div", { onClick: () => handleClearChat(w.id), onMouseOver: () => setVisibleClearButton(true), onMouseLeave: () => setVisibleClearButton(false), className: "absolute z-40 flex align-middle justify-center gap-2 text-sm px-4 py-2 border-blue-300 rounded-sm dark:bg-white w-fit bg-gray-900 text-white dark:text-gray-900 cursor-pointer shadow-md transition-all", style: { top: "12px", right: "0", borderTopLeftRadius: "4px", borderBottomLeftRadius: "4px" }, children: jsxRuntimeExports.jsx(lucideReact.MessageCircleX, { className: "w-5 h-5" }) }), jsxRuntimeExports.jsx("span", { className: `absolute z-50 w-max py-1 text-xs px-2 rounded-sm dark:text-gray-900 dark:bg-white text-white bg-gray-900 ${visibleClearButton ? "block" : "hidden"}`, style: { top: "56px", right: "16px", borderRadius: "3px" }, children: "Clear Chat" })] }), jsxRuntimeExports.jsx(WidgetRenderer, { widget: w, widgetBackendUrl: widgetBackendUrl, onResetReady: handleResetReady, widgetIds: widgets.filter(widget => widget.type !== 'chatbot').map(widget => widget.id) })] })] }, w.id))) })
37864
- // <ReactGridLayout
37865
- // className="layout"
37866
- // layout={getLayoutFromWidgets()}
37867
- // cols={12}
37868
- // rowHeight={50}
37869
- // onLayoutChange={handleLayoutChange}
37870
- // onDragStart={() => setIsDragging(true)}
37871
- // onDragStop={() => setIsDragging(false)}
37872
- // isDraggable={isEditing}
37873
- // isResizable={isEditing}
37874
- // useCSSTransforms
37875
- // compactType={null}
37876
- // margin={[8, 8]}
37877
- // preventCollision={true}
37878
- // >
37879
- // {widgets.map((widget) => (
37880
- // <div
37881
- // key={widget.id}
37882
- // className={cn(
37883
- // "bg-background rounded-lg shadow-sm border overflow-hidden transition-all",
37884
- // currentSelectedWidget?.id === widget.id &&
37885
- // "ring-2 ring-primary ring-offset-2"
37886
- // )}
37887
- // onClick={(e) => handleWidgetClick(widget, e)}
37888
- // onDoubleClick={(e) => handleWidgetDoubleClick(widget, e)}
37889
- // >
37890
- // {widget.config?.showHeader !== false && (
37891
- // <div className="p-2 border-b flex items-center justify-between">
37892
- // <span className="font-medium text-sm">
37893
- // {widget.title}
37894
- // </span>
37895
- // {isEditing && (
37896
- // <Button
37897
- // variant="ghost"
37898
- // size="sm"
37899
- // onClick={() => removeWidget(widget.id)}
37900
- // >
37901
- // <Trash2 className="h-4 w-4" />
37902
- // </Button>
37903
- // )}
37904
- // </div>
37905
- // )}
37906
- // <div
37907
- // className={cn(
37908
- // "h-full",
37909
- // widget.config?.showHeader !== false &&
37910
- // "h-[calc(100%-40px)]"
37911
- // )}
37912
- // >
37913
- // <WidgetRenderer widget={widget} widgetBackendUrl={widgetBackendUrl} />
37914
- // </div>
37915
- // </div>
37916
- // ))}
37917
- // </ReactGridLayout>
37918
- ) })] }));
37869
+ jsxRuntimeExports.jsxs("div", { className: "relative z-50", children: [jsxRuntimeExports.jsx("div", { onClick: () => handleClearChat(w.id), onMouseOver: () => setVisibleClearButton(true), onMouseLeave: () => setVisibleClearButton(false), className: "absolute z-40 flex align-middle justify-center gap-2 text-sm px-4 py-2 border-blue-300 rounded-sm dark:bg-white w-fit bg-gray-900 text-white dark:text-gray-900 cursor-pointer shadow-md transition-all", style: { top: "12px", right: "0", borderTopLeftRadius: "4px", borderBottomLeftRadius: "4px" }, children: jsxRuntimeExports.jsx(lucideReact.MessageCircleX, { className: "w-5 h-5" }) }), jsxRuntimeExports.jsx("span", { className: `absolute z-50 w-max py-1 text-xs px-2 rounded-sm dark:text-gray-900 dark:bg-white text-white bg-gray-900 ${visibleClearButton ? "block" : "hidden"}`, style: { top: "56px", right: "16px", borderRadius: "3px" }, children: "Clear Chat" })] }), jsxRuntimeExports.jsx(WidgetRenderer, { widget: w, widgetBackendUrl: widgetBackendUrl, onResetReady: handleResetReady, widgetIds: widgets.filter(widget => widget.type !== 'chatbot').map(widget => widget.id) })] })] }, w.id))) })) })] }));
37919
37870
  }
37920
37871
 
37921
37872
  const Checkbox = React__namespace.forwardRef((_a, ref) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dp-widgets-framework",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org"