dp-widgets-framework 1.1.5 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { useState, useEffect, useCallback, forwardRef, useRef, useMemo } from 'react';
3
3
  import * as TabsPrimitive from '@radix-ui/react-tabs';
4
- import { clsx } from 'clsx';
4
+ import clsx$1, { clsx } from 'clsx';
5
5
  import { twMerge } from 'tailwind-merge';
6
6
  import * as LabelPrimitive from '@radix-ui/react-label';
7
7
  import { cva } from 'class-variance-authority';
@@ -1457,6 +1457,9 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
1457
1457
  function cn(...inputs) {
1458
1458
  return twMerge(clsx(inputs));
1459
1459
  }
1460
+ const KEYS = {
1461
+ ESCAPE: 'Escape',
1462
+ TAB: 'Tab'};
1460
1463
 
1461
1464
  const Tabs = TabsPrimitive.Root;
1462
1465
  const TabsList = React.forwardRef((_a, ref) => {
@@ -2043,19 +2046,19 @@ const getStyleValues$2 = (styles = {}) => {
2043
2046
  return {
2044
2047
  backgroundColor: styles.backgroundColor || "transparent",
2045
2048
  borderRadius: borderRadiusMap[borderRadius],
2046
- padding: styles.padding || "1rem",
2049
+ // padding: styles.padding || "1rem",
2047
2050
  color: styles.textColor || "#000000",
2048
2051
  fontSize: styles.fontSize || "1rem",
2049
- textAlign: styles.alignment || "left",
2052
+ textAlign: styles.textAlign || "left",
2050
2053
  fontWeight: styles.fontWeight || "normal",
2051
- lineHeight: styles.lineHeight || "1.5",
2054
+ lineHeight: styles.lineHeight || "1.5"
2052
2055
  };
2053
2056
  };
2054
2057
  function TextWidget({ widget }) {
2055
2058
  var _a, _b;
2056
2059
  const styles = getStyleValues$2((_a = widget.config) === null || _a === void 0 ? void 0 : _a.styles);
2057
2060
  const content = ((_b = widget.config) === null || _b === void 0 ? void 0 : _b.content) || {};
2058
- return (jsxRuntimeExports.jsx("div", { className: "w-full", style: styles, children: jsxRuntimeExports.jsx("div", { className: cn("prose max-w-none", content.variant === "title" && "text-2xl font-bold", content.variant === "subtitle" && "text-xl font-semibold", content.variant === "body" && "text-base"), dangerouslySetInnerHTML: { __html: content.text || "Text content" } }) }));
2061
+ return (jsxRuntimeExports.jsx("div", { className: "w-full", style: styles, children: jsxRuntimeExports.jsx("div", { className: cn("prose max-w-none", content.blockType === "heading-1" && "text-[24px] font-bold", content.blockType === "heading-2" && "text-[22px] font-bold", content.blockType === "heading-3" && "text-[18px] font-bold", content.blockType === "paragraph" && "text-base"), dangerouslySetInnerHTML: { __html: content.displayText || "Text content" } }) }));
2059
2062
  }
2060
2063
 
2061
2064
  const getStyleValues$1 = (styles = {}) => {
@@ -36075,15 +36078,13 @@ const createInitialChartState = (agentType, widgetIds, datasetId) => {
36075
36078
  const baseState = { dataset_id: datasetId || "home_generation_dataset" };
36076
36079
  switch (agentType) {
36077
36080
  case "Pie Chart Agent":
36078
- return {
36079
- pie_chart_data: {
36081
+ return Object.assign({ pie_chart_data: {
36080
36082
  title: "",
36081
36083
  type: "pie",
36082
36084
  chart_type: "financial",
36083
36085
  data: { labels: [], values: [], percentages: [], total: 0 },
36084
36086
  metadata: { categories: 0, largest_category: "", largest_value: 0, largest_percentage: 0 }
36085
- }
36086
- };
36087
+ } }, baseState);
36087
36088
  case "Line Chart Agent":
36088
36089
  case "Bar Chart Agent":
36089
36090
  return Object.assign({ bar_chart_data: {
@@ -36124,7 +36125,7 @@ const createInitialChartState = (agentType, widgetIds, datasetId) => {
36124
36125
  metadata: { created_at: "", content_type: "text", is_multiline: false }
36125
36126
  } }, baseState);
36126
36127
  default:
36127
- return { widget_ids: widgetIds };
36128
+ return Object.assign({ widget_ids: widgetIds }, baseState);
36128
36129
  }
36129
36130
  };
36130
36131
  const loadAgentState = async (widgetBackendUrl, threadId, agentName) => {
@@ -36682,7 +36683,7 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
36682
36683
  // Listen for triggerAgent events for this widget
36683
36684
  useEffect(() => {
36684
36685
  const handleTriggerAgent = (event) => {
36685
- const { widgetId, query, agentType: eventAgentType, datesetId } = event.detail;
36686
+ const { widgetId, query, agentType: eventAgentType, datasetId } = event.detail;
36686
36687
  console.log('event.detail==>', event.detail);
36687
36688
  if (widgetId === widget.id) {
36688
36689
  let messageContent = query;
@@ -36787,28 +36788,135 @@ function WidgetRenderer({ widget, isTemplate = false, onConfigUpdate, widgetBack
36787
36788
  return (jsxRuntimeExports.jsxs("div", { className: "text-muted-foreground", children: ["Unknown widget type: ", widget.type] }));
36788
36789
  }
36789
36790
  };
36790
- return (jsxRuntimeExports.jsx("div", { className: "h-full", children: renderWidget() }));
36791
+ return (jsxRuntimeExports.jsx("div", { className: `${(widget === null || widget === void 0 ? void 0 : widget.type) === 'text' ? "" : "h-full"}`, children: renderWidget() }));
36791
36792
  }
36792
36793
 
36793
36794
  const Textarea = React.forwardRef((_a, ref) => {
36794
36795
  var { className } = _a, props = __rest(_a, ["className"]);
36795
- return (jsxRuntimeExports.jsx("textarea", Object.assign({ className: cn("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", className), ref: ref }, props)));
36796
+ return (jsxRuntimeExports.jsx("textarea", Object.assign({ className: cn("flex min-h-[120px] w-full rounded-md border border-gray-300 bg-transparent px-3 py-2 text-base ring-offset-gray-300 placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", className), ref: ref }, props)));
36796
36797
  });
36797
36798
  Textarea.displayName = "Textarea";
36798
36799
 
36799
- function EditWidgetDialog({ initialText, isOpen, onClose, onSubmit }) {
36800
+ function Modal({ isOpen, onClose, title, children, size = 'md', initialFocusRef, noOverflowHidden, }) {
36801
+ const modalRef = useRef(null);
36802
+ useEffect(() => {
36803
+ if (!isOpen || !modalRef.current)
36804
+ return;
36805
+ // Custom focus management
36806
+ const focusableElements = modalRef.current.querySelectorAll('a[href], button, textarea, input[type="text"], input[type="radio"], input[type="checkbox"], select, [tabindex]:not([tabindex="-1"])');
36807
+ const firstFocusableElement = focusableElements[0];
36808
+ const lastFocusableElement = focusableElements[focusableElements.length - 1];
36809
+ // Handle tab key for focus trapping
36810
+ const handleKeyDown = (e) => {
36811
+ if (e.key === KEYS.ESCAPE) {
36812
+ onClose();
36813
+ return;
36814
+ }
36815
+ if (e.key === KEYS.TAB) {
36816
+ if (e.shiftKey) {
36817
+ // Shift + Tab
36818
+ if (document.activeElement === firstFocusableElement) {
36819
+ lastFocusableElement.focus();
36820
+ e.preventDefault();
36821
+ }
36822
+ }
36823
+ else {
36824
+ // Tab
36825
+ if (document.activeElement === lastFocusableElement) {
36826
+ firstFocusableElement.focus();
36827
+ e.preventDefault();
36828
+ }
36829
+ }
36830
+ }
36831
+ };
36832
+ document.addEventListener('keydown', handleKeyDown);
36833
+ // Set initial focus
36834
+ setTimeout(() => {
36835
+ if (initialFocusRef === null || initialFocusRef === void 0 ? void 0 : initialFocusRef.current) {
36836
+ initialFocusRef.current.focus();
36837
+ }
36838
+ else {
36839
+ firstFocusableElement === null || firstFocusableElement === void 0 ? void 0 : firstFocusableElement.focus();
36840
+ }
36841
+ }, 0);
36842
+ // Prevent body scroll
36843
+ document.body.style.overflow = 'hidden';
36844
+ return () => {
36845
+ document.removeEventListener('keydown', handleKeyDown);
36846
+ document.body.style.overflow = '';
36847
+ };
36848
+ }, [isOpen, onClose, initialFocusRef]);
36849
+ if (!isOpen)
36850
+ return null;
36851
+ const sizeClasses = {
36852
+ sm: 'max-w-sm',
36853
+ md: 'max-w-md',
36854
+ lg: 'max-w-lg',
36855
+ xl: 'max-w-xl',
36856
+ };
36857
+ return (jsxRuntimeExports.jsx("div", { className: "fixed inset-0 z-50 overflow-y-auto", "aria-labelledby": "modal-title", role: "dialog", "aria-modal": "true", children: jsxRuntimeExports.jsxs("div", { className: "flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0", children: [jsxRuntimeExports.jsx("div", { className: "fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity", "aria-hidden": "true", onClick: onClose }), jsxRuntimeExports.jsx("div", { ref: modalRef, className: clsx$1(`relative transform ${noOverflowHidden ? "" : "overflow-hidden"} rounded-lg bg-white dark:bg-gray-900 text-left shadow-xl transition-all sm:my-8 sm:w-full`, sizeClasses[size]), children: jsxRuntimeExports.jsxs("div", { className: `bg-white dark:bg-gray-900 px-4 pb-4 pt-5 ${noOverflowHidden ? "rounded-lg" : ""} sm:p-6 sm:pb-4`, children: [jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between mb-4", children: [jsxRuntimeExports.jsx("h3", { id: "modal-title", className: "text-lg font-semibold text-gray-900 dark:text-white", children: title }), jsxRuntimeExports.jsx("button", { onClick: onClose, className: "p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors", "aria-label": "Close modal", children: jsxRuntimeExports.jsx(X, { className: "w-5 h-5" }) })] }), jsxRuntimeExports.jsx("div", { children: children })] }) })] }) }));
36858
+ }
36859
+
36860
+ function EditWidgetDialog({ editingWidget, setWidgets, initialText, isOpen, onClose, onSubmit }) {
36800
36861
  const [query, setQuery] = useState("");
36862
+ const [displayText, setDisplayText] = useState("");
36863
+ const [blockType, setBlockType] = useState("");
36864
+ const [alignment, setAlignment] = useState("");
36865
+ const [divider, setDivider] = useState("no");
36866
+ const [styles, setStyles] = useState("");
36801
36867
  useEffect(() => {
36802
36868
  setQuery(initialText);
36803
36869
  }, [initialText]);
36870
+ useEffect(() => {
36871
+ var _a, _b;
36872
+ const content = (_a = editingWidget === null || editingWidget === void 0 ? void 0 : editingWidget.config) === null || _a === void 0 ? void 0 : _a.content;
36873
+ const cssStyles = (_b = editingWidget === null || editingWidget === void 0 ? void 0 : editingWidget.config) === null || _b === void 0 ? void 0 : _b.styles;
36874
+ const text = content === null || content === void 0 ? void 0 : content.displayText;
36875
+ if (text === null || text === void 0 ? void 0 : text.length) {
36876
+ setDisplayText(text);
36877
+ }
36878
+ const block = content === null || content === void 0 ? void 0 : content.blockType;
36879
+ if (block === null || block === void 0 ? void 0 : block.length) {
36880
+ setBlockType(block);
36881
+ }
36882
+ const textAlign = cssStyles === null || cssStyles === void 0 ? void 0 : cssStyles.textAlign;
36883
+ if (textAlign === null || textAlign === void 0 ? void 0 : textAlign.length) {
36884
+ setAlignment(textAlign);
36885
+ }
36886
+ const hasDivider = content === null || content === void 0 ? void 0 : content.divider;
36887
+ if (hasDivider === null || hasDivider === void 0 ? void 0 : hasDivider.length) {
36888
+ setDivider(hasDivider);
36889
+ }
36890
+ }, [editingWidget]);
36804
36891
  const handleSubmit = () => {
36805
36892
  if (onSubmit && query.trim()) {
36806
36893
  onSubmit(query);
36807
36894
  }
36895
+ if (editingWidget.type === 'text') {
36896
+ const widgetId = editingWidget === null || editingWidget === void 0 ? void 0 : editingWidget.id;
36897
+ setWidgets &&
36898
+ setWidgets((prev) => prev.map((w) => {
36899
+ if (w.id === widgetId) {
36900
+ return Object.assign(Object.assign({}, w), { config: Object.assign(Object.assign({}, w.config), { content: Object.assign(Object.assign({}, w.config.content), { displayText,
36901
+ blockType,
36902
+ divider }), styles: Object.assign(Object.assign({}, w.config.styles), (alignment && alignment.length > 0
36903
+ ? { textAlign: alignment }
36904
+ : {})) }) });
36905
+ }
36906
+ return w;
36907
+ }));
36908
+ onClose && onClose();
36909
+ }
36808
36910
  };
36809
36911
  if (!isOpen)
36810
36912
  return null;
36811
- return (jsxRuntimeExports.jsx("div", { className: "fixed inset-0 bg-black bg-opacity-40 flex items-center justify-center z-50", children: jsxRuntimeExports.jsxs("div", { className: "dark:text-white dark:bg-gray-800 rounded-xl shadow-lg w-[600px] mx-2 text-black bg-white", children: [jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center p-4 border-b", children: [jsxRuntimeExports.jsx("div", { className: "text-lg font-semibold", children: "Edit Widget" }), jsxRuntimeExports.jsx("button", { className: "p-1 hover:bg-[inherit] rounded", onClick: onClose, children: jsxRuntimeExports.jsx(X, { className: "w-5 h-5 text-[inherit]" }) })] }), jsxRuntimeExports.jsxs("div", { className: "p-6 space-y-4", children: [jsxRuntimeExports.jsx("div", { className: "text-xs", children: jsxRuntimeExports.jsx("p", { children: "Please write a prompt to edit a widget." }) }), jsxRuntimeExports.jsx("div", { className: "flex items-center gap-4", children: jsxRuntimeExports.jsx("div", { className: "text-md font-semibold", children: "Query:" }) }), jsxRuntimeExports.jsx("div", { className: "", children: jsxRuntimeExports.jsx(Textarea, { className: "w-full p-2 text-sm dark:bg-gray-800 dark:border-white", 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", 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-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500 px-6 py-2 text-sm flex items-center gap-2", children: "Submit" }) })] })] }) }));
36913
+ console.log(editingWidget, "==> editingWidget");
36914
+ return (jsxRuntimeExports.jsx(Modal, { isOpen: isOpen, onClose: onClose, title: "Edit Widget", size: "lg",
36915
+ // initialFocusRef={inputRef}
36916
+ noOverflowHidden: true, children: jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("p", { className: "text-gray-700 dark:text-gray-300", children: "Customize the widget\u2019s appearance" }), jsxRuntimeExports.jsx("div", { className: "pt-7", children: (editingWidget === null || editingWidget === void 0 ? void 0 : editingWidget.type) === "text" ?
36917
+ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-5", children: [jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Display text:" }), jsxRuntimeExports.jsx(Input, { value: displayText, onChange: (e) => setDisplayText(e.target.value), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Block type:" }), jsxRuntimeExports.jsxs(Select, { value: blockType, onValueChange: (value) => setBlockType(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select block type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "heading-1", children: "Heading 1" }), jsxRuntimeExports.jsx(SelectItem, { value: "heading-2", children: "Heading 2" }), jsxRuntimeExports.jsx(SelectItem, { value: "heading-3", children: "Heading 3" }), jsxRuntimeExports.jsx(SelectItem, { value: "paragraph", children: "Paragraph" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Align:" }), jsxRuntimeExports.jsxs(Select, { value: alignment, onValueChange: (value) => setAlignment(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select block type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "left", children: "Left" }), jsxRuntimeExports.jsx(SelectItem, { value: "center", children: "Center" }), jsxRuntimeExports.jsx(SelectItem, { value: "right", children: "Right" }), jsxRuntimeExports.jsx(SelectItem, { value: "justify", children: "Justify" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Divider:" }), jsxRuntimeExports.jsxs(Select, { value: divider, onValueChange: (value) => setDivider(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "No" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "yes", children: "Yes" }), jsxRuntimeExports.jsx(SelectItem, { value: "no", children: "No" })] })] })] }), jsxRuntimeExports.jsx("div", { className: "flex justify-end", 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" }) })] })
36918
+ :
36919
+ jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Prompt:" }), jsxRuntimeExports.jsx(Textarea, { className: "w-full p-2 dark:bg-gray-800 dark:border-white", 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" }) })] }) })] }) }));
36812
36920
  }
36813
36921
 
36814
36922
  function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk-construction-project-agent" }) {
@@ -36824,6 +36932,13 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
36824
36932
  // description: 'Create interactive bar charts with custom queries',
36825
36933
  // configRequired: true
36826
36934
  // },
36935
+ {
36936
+ type: 'text',
36937
+ title: 'Text Widget',
36938
+ icon: Type,
36939
+ description: 'Add headings or paragraphs to your dashboard',
36940
+ configRequired: false
36941
+ },
36827
36942
  {
36828
36943
  type: 'series-bar-chart',
36829
36944
  title: 'Bar Chart Widget',
@@ -36881,10 +36996,15 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
36881
36996
  setShowConfigStep(true);
36882
36997
  }
36883
36998
  else {
36884
- // For chatbot widget, create the default config
36885
- const config = {
36886
- agentName: defaultAgentName
36887
- };
36999
+ // For chatbot and text widget, create the default config
37000
+ const config = Object.assign({ agentName: defaultAgentName }, (widgetType === "text" && {
37001
+ content: {
37002
+ displayText: "Text goes here...",
37003
+ blockType: "paragraph",
37004
+ divider: "no",
37005
+ },
37006
+ styles: { textAlign: "left" }
37007
+ }));
36888
37008
  handleAddWidget(widgetType, config);
36889
37009
  }
36890
37010
  };
@@ -36958,6 +37078,11 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
36958
37078
  agentName: defaultAgentName
36959
37079
  };
36960
37080
  }
37081
+ else if (selectedWidgetType === 'text') {
37082
+ config = {
37083
+ agentName: defaultAgentName
37084
+ };
37085
+ }
36961
37086
  else {
36962
37087
  config = {
36963
37088
  agentName: defaultAgentName
@@ -36970,15 +37095,13 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
36970
37095
  setQuery('');
36971
37096
  setShowConfigStep(false);
36972
37097
  };
36973
- const handleClose = () => {
36974
- resetModal();
36975
- onClose();
36976
- };
36977
37098
  if (!isOpen)
36978
37099
  return null;
36979
- return (jsxRuntimeExports.jsx("div", { className: "fixed inset-0 bg-black bg-opacity-40 flex items-center justify-center z-50", children: jsxRuntimeExports.jsxs("div", { className: "text-black bg-white rounded-xl shadow-lg w-[600px] mx-2", children: [jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center p-4 border-b", children: [jsxRuntimeExports.jsx("div", { className: "text-lg font-semibold", children: showConfigStep ? `Configure ${(_a = widgetOptions.find(w => w.type === selectedWidgetType)) === null || _a === void 0 ? void 0 : _a.title}` : 'Add Widget' }), jsxRuntimeExports.jsx("button", { className: "p-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded", onClick: handleClose, children: jsxRuntimeExports.jsx(X, { className: "w-5 h-5" }) })] }), jsxRuntimeExports.jsx("div", { className: "p-6", children: !showConfigStep ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: "mb-4", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", 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) => {
37100
+ return (jsxRuntimeExports.jsx(Modal, { isOpen: isOpen, onClose: onClose, title: showConfigStep ? `Configure ${(_a = widgetOptions.find(w => w.type === selectedWidgetType)) === null || _a === void 0 ? void 0 : _a.title}` : 'Add Widget', size: "lg",
37101
+ // initialFocusRef={inputRef}
37102
+ noOverflowHidden: true, children: jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("p", { className: "text-gray-700 dark:text-gray-300", children: "Choose a widget to add to your dashboard:" }), 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-600 dark:text-gray-400" }) }), jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 gap-3 max-h-[400px] overflow-y-auto", children: widgetOptions.map((widget) => {
36980
37103
  const IconComponent = widget.icon;
36981
- return (jsxRuntimeExports.jsxs("button", { onClick: () => handleWidgetSelect(widget.type), className: "flex items-start gap-3 p-4 border rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors text-left", children: [jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 p-2 bg-blue-100 dark:bg-blue-900 rounded-md", children: jsxRuntimeExports.jsx(IconComponent, { className: "w-5 h-5 text-blue-600 dark:text-blue-400" }) }), 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 dark:text-gray-400 mt-1", children: widget.description })] })] }, widget.type));
37104
+ return (jsxRuntimeExports.jsxs("button", { onClick: () => handleWidgetSelect(widget.type), className: "flex items-start gap-3 p-4 border rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors text-left", children: [jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 p-2 bg-primary-100 dark:bg-primary-900 rounded-md", children: jsxRuntimeExports.jsx(IconComponent, { className: "w-5 h-5 text-primary-600 dark:text-primary-400" }) }), 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 dark:text-gray-400 mt-1", children: widget.description })] })] }, widget.type));
36982
37105
  }) })] })) : (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: "mb-4", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: selectedWidgetType === 'chatbot'
36983
37106
  ? 'Chatbot widget will be configured with the default agent.'
36984
37107
  : 'Enter a query for your chart widget:' }) }), (selectedWidgetType === 'bar-chart' || selectedWidgetType === 'series-bar-chart' || selectedWidgetType === 'series-line-chart' || selectedWidgetType === 'line-chart' || selectedWidgetType === 'pie-chart' || selectedWidgetType === 'data-grid' || selectedWidgetType === 'summary') && (jsxRuntimeExports.jsxs("div", { className: "mb-6", children: [jsxRuntimeExports.jsx("label", { className: "block text-sm font-medium mb-2", children: "Query" }), jsxRuntimeExports.jsx(Textarea, { value: query, onChange: (e) => setQuery(e.target.value), placeholder: "e.g., List out the product types by its count and render it on bar chart", className: "w-full h-24 resize-none" })] })), jsxRuntimeExports.jsxs("div", { className: "flex gap-3 justify-end", children: [jsxRuntimeExports.jsx(Button, { variant: "outline", onClick: () => setShowConfigStep(false), children: "Back" }), jsxRuntimeExports.jsx(Button, { onClick: handleConfigSubmit, disabled: (selectedWidgetType === 'bar-chart' || selectedWidgetType === 'series-bar-chart' || selectedWidgetType === 'series-line-chart' || selectedWidgetType === 'line-chart' || selectedWidgetType === 'pie-chart' || selectedWidgetType === 'data-grid' || selectedWidgetType === 'summary') && !query.trim(), children: "Add Widget" })] })] })) })] }) }));
@@ -37095,7 +37218,7 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
37095
37218
  widgetId: editingWidget.id,
37096
37219
  query: newQuery,
37097
37220
  agentType: (_a = editingWidget.config) === null || _a === void 0 ? void 0 : _a.agentType,
37098
- datesetId: datasetId
37221
+ datasetId: datasetId
37099
37222
  }
37100
37223
  });
37101
37224
  window.dispatchEvent(event);
@@ -37403,7 +37526,8 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
37403
37526
  const widgetNames = {
37404
37527
  'bar-chart': 'Bar Chart Widget',
37405
37528
  'pie-chart': 'Pie Chart Widget',
37406
- 'chatbot': 'Chatbot Widget'
37529
+ 'chatbot': 'Chatbot Widget',
37530
+ 'text': 'Text Widget'
37407
37531
  };
37408
37532
  widgetTypeConfig = {
37409
37533
  type: widgetType,
@@ -37430,6 +37554,8 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
37430
37554
  config: Object.assign(Object.assign({}, config), { isFirstLoad: true }) || { isFirstLoad: true },
37431
37555
  is_draggable: true,
37432
37556
  is_resizable: true,
37557
+ minH: widgetType === "text" ? widgetTypeConfig.defaultSize.h : undefined,
37558
+ maxH: widgetType === "text" ? widgetTypeConfig.defaultSize.h : undefined,
37433
37559
  page_id: pageId,
37434
37560
  };
37435
37561
  setWidgets((prev) => {
@@ -37461,15 +37587,25 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
37461
37587
  processedIds.add(widget.id);
37462
37588
  return true;
37463
37589
  })
37464
- .map((widget) => ({
37465
- i: widget.id, // must match RGL item key
37466
- x: widget.position_x, // grid X position
37467
- y: widget.position_y, // grid Y position
37468
- w: widget.width, // width in grid cols
37469
- h: widget.height, // height in grid rows
37470
- minW: 0,
37471
- minH: 0,
37472
- }));
37590
+ .map((widget) => {
37591
+ const isText = widget.type === "text";
37592
+ return {
37593
+ i: widget.id,
37594
+ x: widget.position_x,
37595
+ y: widget.position_y,
37596
+ w: widget.width,
37597
+ h: isText
37598
+ ? (isEditing ? widget.height : Math.max(widget.height - 1, 1))
37599
+ : widget.height,
37600
+ minW: 0,
37601
+ minH: isText ? widget.height : 0,
37602
+ maxH: isText ? widget.height : undefined,
37603
+ isResizable: isEditing,
37604
+ resizeHandles: isText
37605
+ ? ["w", "e"] // only horizontal
37606
+ : ["sw", "nw", "se", "ne"],
37607
+ };
37608
+ });
37473
37609
  };
37474
37610
  const removeWidget = (widgetId) => {
37475
37611
  setWidgets((prev) => {
@@ -37490,9 +37626,12 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
37490
37626
  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) => {
37491
37627
  addWidget(widgetType, config);
37492
37628
  onCloseWidgetPallete === null || onCloseWidgetPallete === void 0 ? void 0 : onCloseWidgetPallete();
37493
- }, 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", { className: `border border-primary-300 rounded-xl p-4 shadow-lg overflow-hidden ${isEditing ? 'pb-20' : 'pb-14'}`, children: [isEditing &&
37494
- 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" &&
37495
- 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), datasetId: datasetId })] })] }, w.id))) })) })] }));
37629
+ }, 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", 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], children: widgets.map((w) => {
37630
+ var _a, _b;
37631
+ return (jsxRuntimeExports.jsxs("div", { className: `${w.type === "text" ? `${((_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 &&
37632
+ jsxRuntimeExports.jsxs("div", { className: `flex items-center justify-end mb-4 relative ${w.type === "text" ? "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" }), 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' ? `${isEditing ? 'px-4' : ''}` : "h-full"} w-full relative`, children: [(w === null || w === void 0 ? void 0 : w.type) === "chatbot" &&
37633
+ 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), datasetId: datasetId })] })] }, w.id));
37634
+ }) })) })] }));
37496
37635
  }
37497
37636
 
37498
37637
  const Checkbox = React.forwardRef((_a, ref) => {
package/dist/index.js CHANGED
@@ -1484,6 +1484,9 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
1484
1484
  function cn(...inputs) {
1485
1485
  return tailwindMerge.twMerge(clsx.clsx(inputs));
1486
1486
  }
1487
+ const KEYS = {
1488
+ ESCAPE: 'Escape',
1489
+ TAB: 'Tab'};
1487
1490
 
1488
1491
  const Tabs = TabsPrimitive__namespace.Root;
1489
1492
  const TabsList = React__namespace.forwardRef((_a, ref) => {
@@ -2070,19 +2073,19 @@ const getStyleValues$2 = (styles = {}) => {
2070
2073
  return {
2071
2074
  backgroundColor: styles.backgroundColor || "transparent",
2072
2075
  borderRadius: borderRadiusMap[borderRadius],
2073
- padding: styles.padding || "1rem",
2076
+ // padding: styles.padding || "1rem",
2074
2077
  color: styles.textColor || "#000000",
2075
2078
  fontSize: styles.fontSize || "1rem",
2076
- textAlign: styles.alignment || "left",
2079
+ textAlign: styles.textAlign || "left",
2077
2080
  fontWeight: styles.fontWeight || "normal",
2078
- lineHeight: styles.lineHeight || "1.5",
2081
+ lineHeight: styles.lineHeight || "1.5"
2079
2082
  };
2080
2083
  };
2081
2084
  function TextWidget({ widget }) {
2082
2085
  var _a, _b;
2083
2086
  const styles = getStyleValues$2((_a = widget.config) === null || _a === void 0 ? void 0 : _a.styles);
2084
2087
  const content = ((_b = widget.config) === null || _b === void 0 ? void 0 : _b.content) || {};
2085
- return (jsxRuntimeExports.jsx("div", { className: "w-full", style: styles, children: jsxRuntimeExports.jsx("div", { className: cn("prose max-w-none", content.variant === "title" && "text-2xl font-bold", content.variant === "subtitle" && "text-xl font-semibold", content.variant === "body" && "text-base"), dangerouslySetInnerHTML: { __html: content.text || "Text content" } }) }));
2088
+ return (jsxRuntimeExports.jsx("div", { className: "w-full", style: styles, children: jsxRuntimeExports.jsx("div", { className: cn("prose max-w-none", content.blockType === "heading-1" && "text-[24px] font-bold", content.blockType === "heading-2" && "text-[22px] font-bold", content.blockType === "heading-3" && "text-[18px] font-bold", content.blockType === "paragraph" && "text-base"), dangerouslySetInnerHTML: { __html: content.displayText || "Text content" } }) }));
2086
2089
  }
2087
2090
 
2088
2091
  const getStyleValues$1 = (styles = {}) => {
@@ -36102,15 +36105,13 @@ const createInitialChartState = (agentType, widgetIds, datasetId) => {
36102
36105
  const baseState = { dataset_id: datasetId || "home_generation_dataset" };
36103
36106
  switch (agentType) {
36104
36107
  case "Pie Chart Agent":
36105
- return {
36106
- pie_chart_data: {
36108
+ return Object.assign({ pie_chart_data: {
36107
36109
  title: "",
36108
36110
  type: "pie",
36109
36111
  chart_type: "financial",
36110
36112
  data: { labels: [], values: [], percentages: [], total: 0 },
36111
36113
  metadata: { categories: 0, largest_category: "", largest_value: 0, largest_percentage: 0 }
36112
- }
36113
- };
36114
+ } }, baseState);
36114
36115
  case "Line Chart Agent":
36115
36116
  case "Bar Chart Agent":
36116
36117
  return Object.assign({ bar_chart_data: {
@@ -36151,7 +36152,7 @@ const createInitialChartState = (agentType, widgetIds, datasetId) => {
36151
36152
  metadata: { created_at: "", content_type: "text", is_multiline: false }
36152
36153
  } }, baseState);
36153
36154
  default:
36154
- return { widget_ids: widgetIds };
36155
+ return Object.assign({ widget_ids: widgetIds }, baseState);
36155
36156
  }
36156
36157
  };
36157
36158
  const loadAgentState = async (widgetBackendUrl, threadId, agentName) => {
@@ -36709,7 +36710,7 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
36709
36710
  // Listen for triggerAgent events for this widget
36710
36711
  React.useEffect(() => {
36711
36712
  const handleTriggerAgent = (event) => {
36712
- const { widgetId, query, agentType: eventAgentType, datesetId } = event.detail;
36713
+ const { widgetId, query, agentType: eventAgentType, datasetId } = event.detail;
36713
36714
  console.log('event.detail==>', event.detail);
36714
36715
  if (widgetId === widget.id) {
36715
36716
  let messageContent = query;
@@ -36814,28 +36815,135 @@ function WidgetRenderer({ widget, isTemplate = false, onConfigUpdate, widgetBack
36814
36815
  return (jsxRuntimeExports.jsxs("div", { className: "text-muted-foreground", children: ["Unknown widget type: ", widget.type] }));
36815
36816
  }
36816
36817
  };
36817
- return (jsxRuntimeExports.jsx("div", { className: "h-full", children: renderWidget() }));
36818
+ return (jsxRuntimeExports.jsx("div", { className: `${(widget === null || widget === void 0 ? void 0 : widget.type) === 'text' ? "" : "h-full"}`, children: renderWidget() }));
36818
36819
  }
36819
36820
 
36820
36821
  const Textarea = React__namespace.forwardRef((_a, ref) => {
36821
36822
  var { className } = _a, props = __rest(_a, ["className"]);
36822
- return (jsxRuntimeExports.jsx("textarea", Object.assign({ className: cn("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", className), ref: ref }, props)));
36823
+ return (jsxRuntimeExports.jsx("textarea", Object.assign({ className: cn("flex min-h-[120px] w-full rounded-md border border-gray-300 bg-transparent px-3 py-2 text-base ring-offset-gray-300 placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", className), ref: ref }, props)));
36823
36824
  });
36824
36825
  Textarea.displayName = "Textarea";
36825
36826
 
36826
- function EditWidgetDialog({ initialText, isOpen, onClose, onSubmit }) {
36827
+ function Modal({ isOpen, onClose, title, children, size = 'md', initialFocusRef, noOverflowHidden, }) {
36828
+ const modalRef = React.useRef(null);
36829
+ React.useEffect(() => {
36830
+ if (!isOpen || !modalRef.current)
36831
+ return;
36832
+ // Custom focus management
36833
+ const focusableElements = modalRef.current.querySelectorAll('a[href], button, textarea, input[type="text"], input[type="radio"], input[type="checkbox"], select, [tabindex]:not([tabindex="-1"])');
36834
+ const firstFocusableElement = focusableElements[0];
36835
+ const lastFocusableElement = focusableElements[focusableElements.length - 1];
36836
+ // Handle tab key for focus trapping
36837
+ const handleKeyDown = (e) => {
36838
+ if (e.key === KEYS.ESCAPE) {
36839
+ onClose();
36840
+ return;
36841
+ }
36842
+ if (e.key === KEYS.TAB) {
36843
+ if (e.shiftKey) {
36844
+ // Shift + Tab
36845
+ if (document.activeElement === firstFocusableElement) {
36846
+ lastFocusableElement.focus();
36847
+ e.preventDefault();
36848
+ }
36849
+ }
36850
+ else {
36851
+ // Tab
36852
+ if (document.activeElement === lastFocusableElement) {
36853
+ firstFocusableElement.focus();
36854
+ e.preventDefault();
36855
+ }
36856
+ }
36857
+ }
36858
+ };
36859
+ document.addEventListener('keydown', handleKeyDown);
36860
+ // Set initial focus
36861
+ setTimeout(() => {
36862
+ if (initialFocusRef === null || initialFocusRef === void 0 ? void 0 : initialFocusRef.current) {
36863
+ initialFocusRef.current.focus();
36864
+ }
36865
+ else {
36866
+ firstFocusableElement === null || firstFocusableElement === void 0 ? void 0 : firstFocusableElement.focus();
36867
+ }
36868
+ }, 0);
36869
+ // Prevent body scroll
36870
+ document.body.style.overflow = 'hidden';
36871
+ return () => {
36872
+ document.removeEventListener('keydown', handleKeyDown);
36873
+ document.body.style.overflow = '';
36874
+ };
36875
+ }, [isOpen, onClose, initialFocusRef]);
36876
+ if (!isOpen)
36877
+ return null;
36878
+ const sizeClasses = {
36879
+ sm: 'max-w-sm',
36880
+ md: 'max-w-md',
36881
+ lg: 'max-w-lg',
36882
+ xl: 'max-w-xl',
36883
+ };
36884
+ return (jsxRuntimeExports.jsx("div", { className: "fixed inset-0 z-50 overflow-y-auto", "aria-labelledby": "modal-title", role: "dialog", "aria-modal": "true", children: jsxRuntimeExports.jsxs("div", { className: "flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0", children: [jsxRuntimeExports.jsx("div", { className: "fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity", "aria-hidden": "true", onClick: onClose }), jsxRuntimeExports.jsx("div", { ref: modalRef, className: clsx(`relative transform ${noOverflowHidden ? "" : "overflow-hidden"} rounded-lg bg-white dark:bg-gray-900 text-left shadow-xl transition-all sm:my-8 sm:w-full`, sizeClasses[size]), children: jsxRuntimeExports.jsxs("div", { className: `bg-white dark:bg-gray-900 px-4 pb-4 pt-5 ${noOverflowHidden ? "rounded-lg" : ""} sm:p-6 sm:pb-4`, children: [jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between mb-4", children: [jsxRuntimeExports.jsx("h3", { id: "modal-title", className: "text-lg font-semibold text-gray-900 dark:text-white", children: title }), jsxRuntimeExports.jsx("button", { onClick: onClose, className: "p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors", "aria-label": "Close modal", children: jsxRuntimeExports.jsx(lucideReact.X, { className: "w-5 h-5" }) })] }), jsxRuntimeExports.jsx("div", { children: children })] }) })] }) }));
36885
+ }
36886
+
36887
+ function EditWidgetDialog({ editingWidget, setWidgets, initialText, isOpen, onClose, onSubmit }) {
36827
36888
  const [query, setQuery] = React.useState("");
36889
+ const [displayText, setDisplayText] = React.useState("");
36890
+ const [blockType, setBlockType] = React.useState("");
36891
+ const [alignment, setAlignment] = React.useState("");
36892
+ const [divider, setDivider] = React.useState("no");
36893
+ const [styles, setStyles] = React.useState("");
36828
36894
  React.useEffect(() => {
36829
36895
  setQuery(initialText);
36830
36896
  }, [initialText]);
36897
+ React.useEffect(() => {
36898
+ var _a, _b;
36899
+ const content = (_a = editingWidget === null || editingWidget === void 0 ? void 0 : editingWidget.config) === null || _a === void 0 ? void 0 : _a.content;
36900
+ const cssStyles = (_b = editingWidget === null || editingWidget === void 0 ? void 0 : editingWidget.config) === null || _b === void 0 ? void 0 : _b.styles;
36901
+ const text = content === null || content === void 0 ? void 0 : content.displayText;
36902
+ if (text === null || text === void 0 ? void 0 : text.length) {
36903
+ setDisplayText(text);
36904
+ }
36905
+ const block = content === null || content === void 0 ? void 0 : content.blockType;
36906
+ if (block === null || block === void 0 ? void 0 : block.length) {
36907
+ setBlockType(block);
36908
+ }
36909
+ const textAlign = cssStyles === null || cssStyles === void 0 ? void 0 : cssStyles.textAlign;
36910
+ if (textAlign === null || textAlign === void 0 ? void 0 : textAlign.length) {
36911
+ setAlignment(textAlign);
36912
+ }
36913
+ const hasDivider = content === null || content === void 0 ? void 0 : content.divider;
36914
+ if (hasDivider === null || hasDivider === void 0 ? void 0 : hasDivider.length) {
36915
+ setDivider(hasDivider);
36916
+ }
36917
+ }, [editingWidget]);
36831
36918
  const handleSubmit = () => {
36832
36919
  if (onSubmit && query.trim()) {
36833
36920
  onSubmit(query);
36834
36921
  }
36922
+ if (editingWidget.type === 'text') {
36923
+ const widgetId = editingWidget === null || editingWidget === void 0 ? void 0 : editingWidget.id;
36924
+ setWidgets &&
36925
+ setWidgets((prev) => prev.map((w) => {
36926
+ if (w.id === widgetId) {
36927
+ return Object.assign(Object.assign({}, w), { config: Object.assign(Object.assign({}, w.config), { content: Object.assign(Object.assign({}, w.config.content), { displayText,
36928
+ blockType,
36929
+ divider }), styles: Object.assign(Object.assign({}, w.config.styles), (alignment && alignment.length > 0
36930
+ ? { textAlign: alignment }
36931
+ : {})) }) });
36932
+ }
36933
+ return w;
36934
+ }));
36935
+ onClose && onClose();
36936
+ }
36835
36937
  };
36836
36938
  if (!isOpen)
36837
36939
  return null;
36838
- return (jsxRuntimeExports.jsx("div", { className: "fixed inset-0 bg-black bg-opacity-40 flex items-center justify-center z-50", children: jsxRuntimeExports.jsxs("div", { className: "dark:text-white dark:bg-gray-800 rounded-xl shadow-lg w-[600px] mx-2 text-black bg-white", children: [jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center p-4 border-b", children: [jsxRuntimeExports.jsx("div", { className: "text-lg font-semibold", children: "Edit Widget" }), jsxRuntimeExports.jsx("button", { className: "p-1 hover:bg-[inherit] rounded", onClick: onClose, children: jsxRuntimeExports.jsx(lucideReact.X, { className: "w-5 h-5 text-[inherit]" }) })] }), jsxRuntimeExports.jsxs("div", { className: "p-6 space-y-4", children: [jsxRuntimeExports.jsx("div", { className: "text-xs", children: jsxRuntimeExports.jsx("p", { children: "Please write a prompt to edit a widget." }) }), jsxRuntimeExports.jsx("div", { className: "flex items-center gap-4", children: jsxRuntimeExports.jsx("div", { className: "text-md font-semibold", children: "Query:" }) }), jsxRuntimeExports.jsx("div", { className: "", children: jsxRuntimeExports.jsx(Textarea, { className: "w-full p-2 text-sm dark:bg-gray-800 dark:border-white", 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", 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-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500 px-6 py-2 text-sm flex items-center gap-2", children: "Submit" }) })] })] }) }));
36940
+ console.log(editingWidget, "==> editingWidget");
36941
+ return (jsxRuntimeExports.jsx(Modal, { isOpen: isOpen, onClose: onClose, title: "Edit Widget", size: "lg",
36942
+ // initialFocusRef={inputRef}
36943
+ noOverflowHidden: true, children: jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("p", { className: "text-gray-700 dark:text-gray-300", children: "Customize the widget\u2019s appearance" }), jsxRuntimeExports.jsx("div", { className: "pt-7", children: (editingWidget === null || editingWidget === void 0 ? void 0 : editingWidget.type) === "text" ?
36944
+ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-5", children: [jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Display text:" }), jsxRuntimeExports.jsx(Input, { value: displayText, onChange: (e) => setDisplayText(e.target.value), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Block type:" }), jsxRuntimeExports.jsxs(Select, { value: blockType, onValueChange: (value) => setBlockType(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select block type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "heading-1", children: "Heading 1" }), jsxRuntimeExports.jsx(SelectItem, { value: "heading-2", children: "Heading 2" }), jsxRuntimeExports.jsx(SelectItem, { value: "heading-3", children: "Heading 3" }), jsxRuntimeExports.jsx(SelectItem, { value: "paragraph", children: "Paragraph" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Align:" }), jsxRuntimeExports.jsxs(Select, { value: alignment, onValueChange: (value) => setAlignment(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select block type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "left", children: "Left" }), jsxRuntimeExports.jsx(SelectItem, { value: "center", children: "Center" }), jsxRuntimeExports.jsx(SelectItem, { value: "right", children: "Right" }), jsxRuntimeExports.jsx(SelectItem, { value: "justify", children: "Justify" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Divider:" }), jsxRuntimeExports.jsxs(Select, { value: divider, onValueChange: (value) => setDivider(value), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "No" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "yes", children: "Yes" }), jsxRuntimeExports.jsx(SelectItem, { value: "no", children: "No" })] })] })] }), jsxRuntimeExports.jsx("div", { className: "flex justify-end", 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" }) })] })
36945
+ :
36946
+ jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2", children: [jsxRuntimeExports.jsx("div", { className: "font-semibold", children: "Prompt:" }), jsxRuntimeExports.jsx(Textarea, { className: "w-full p-2 dark:bg-gray-800 dark:border-white", 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" }) })] }) })] }) }));
36839
36947
  }
36840
36948
 
36841
36949
  function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk-construction-project-agent" }) {
@@ -36851,6 +36959,13 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
36851
36959
  // description: 'Create interactive bar charts with custom queries',
36852
36960
  // configRequired: true
36853
36961
  // },
36962
+ {
36963
+ type: 'text',
36964
+ title: 'Text Widget',
36965
+ icon: lucideReact.Type,
36966
+ description: 'Add headings or paragraphs to your dashboard',
36967
+ configRequired: false
36968
+ },
36854
36969
  {
36855
36970
  type: 'series-bar-chart',
36856
36971
  title: 'Bar Chart Widget',
@@ -36908,10 +37023,15 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
36908
37023
  setShowConfigStep(true);
36909
37024
  }
36910
37025
  else {
36911
- // For chatbot widget, create the default config
36912
- const config = {
36913
- agentName: defaultAgentName
36914
- };
37026
+ // For chatbot and text widget, create the default config
37027
+ const config = Object.assign({ agentName: defaultAgentName }, (widgetType === "text" && {
37028
+ content: {
37029
+ displayText: "Text goes here...",
37030
+ blockType: "paragraph",
37031
+ divider: "no",
37032
+ },
37033
+ styles: { textAlign: "left" }
37034
+ }));
36915
37035
  handleAddWidget(widgetType, config);
36916
37036
  }
36917
37037
  };
@@ -36985,6 +37105,11 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
36985
37105
  agentName: defaultAgentName
36986
37106
  };
36987
37107
  }
37108
+ else if (selectedWidgetType === 'text') {
37109
+ config = {
37110
+ agentName: defaultAgentName
37111
+ };
37112
+ }
36988
37113
  else {
36989
37114
  config = {
36990
37115
  agentName: defaultAgentName
@@ -36997,15 +37122,13 @@ function AddWidgetDialog({ isOpen, onClose, addWidgetFn, defaultAgentName = "adk
36997
37122
  setQuery('');
36998
37123
  setShowConfigStep(false);
36999
37124
  };
37000
- const handleClose = () => {
37001
- resetModal();
37002
- onClose();
37003
- };
37004
37125
  if (!isOpen)
37005
37126
  return null;
37006
- return (jsxRuntimeExports.jsx("div", { className: "fixed inset-0 bg-black bg-opacity-40 flex items-center justify-center z-50", children: jsxRuntimeExports.jsxs("div", { className: "text-black bg-white rounded-xl shadow-lg w-[600px] mx-2", children: [jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center p-4 border-b", children: [jsxRuntimeExports.jsx("div", { className: "text-lg font-semibold", children: showConfigStep ? `Configure ${(_a = widgetOptions.find(w => w.type === selectedWidgetType)) === null || _a === void 0 ? void 0 : _a.title}` : 'Add Widget' }), jsxRuntimeExports.jsx("button", { className: "p-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded", onClick: handleClose, children: jsxRuntimeExports.jsx(lucideReact.X, { className: "w-5 h-5" }) })] }), jsxRuntimeExports.jsx("div", { className: "p-6", children: !showConfigStep ? (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: "mb-4", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", 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) => {
37127
+ return (jsxRuntimeExports.jsx(Modal, { isOpen: isOpen, onClose: onClose, title: showConfigStep ? `Configure ${(_a = widgetOptions.find(w => w.type === selectedWidgetType)) === null || _a === void 0 ? void 0 : _a.title}` : 'Add Widget', size: "lg",
37128
+ // initialFocusRef={inputRef}
37129
+ noOverflowHidden: true, children: jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("p", { className: "text-gray-700 dark:text-gray-300", children: "Choose a widget to add to your dashboard:" }), 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-600 dark:text-gray-400" }) }), jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 gap-3 max-h-[400px] overflow-y-auto", children: widgetOptions.map((widget) => {
37007
37130
  const IconComponent = widget.icon;
37008
- return (jsxRuntimeExports.jsxs("button", { onClick: () => handleWidgetSelect(widget.type), className: "flex items-start gap-3 p-4 border rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors text-left", children: [jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 p-2 bg-blue-100 dark:bg-blue-900 rounded-md", children: jsxRuntimeExports.jsx(IconComponent, { className: "w-5 h-5 text-blue-600 dark:text-blue-400" }) }), 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 dark:text-gray-400 mt-1", children: widget.description })] })] }, widget.type));
37131
+ return (jsxRuntimeExports.jsxs("button", { onClick: () => handleWidgetSelect(widget.type), className: "flex items-start gap-3 p-4 border rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors text-left", children: [jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 p-2 bg-primary-100 dark:bg-primary-900 rounded-md", children: jsxRuntimeExports.jsx(IconComponent, { className: "w-5 h-5 text-primary-600 dark:text-primary-400" }) }), 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 dark:text-gray-400 mt-1", children: widget.description })] })] }, widget.type));
37009
37132
  }) })] })) : (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: "mb-4", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: selectedWidgetType === 'chatbot'
37010
37133
  ? 'Chatbot widget will be configured with the default agent.'
37011
37134
  : 'Enter a query for your chart widget:' }) }), (selectedWidgetType === 'bar-chart' || selectedWidgetType === 'series-bar-chart' || selectedWidgetType === 'series-line-chart' || selectedWidgetType === 'line-chart' || selectedWidgetType === 'pie-chart' || selectedWidgetType === 'data-grid' || selectedWidgetType === 'summary') && (jsxRuntimeExports.jsxs("div", { className: "mb-6", children: [jsxRuntimeExports.jsx("label", { className: "block text-sm font-medium mb-2", children: "Query" }), jsxRuntimeExports.jsx(Textarea, { value: query, onChange: (e) => setQuery(e.target.value), placeholder: "e.g., List out the product types by its count and render it on bar chart", className: "w-full h-24 resize-none" })] })), jsxRuntimeExports.jsxs("div", { className: "flex gap-3 justify-end", children: [jsxRuntimeExports.jsx(Button, { variant: "outline", onClick: () => setShowConfigStep(false), children: "Back" }), jsxRuntimeExports.jsx(Button, { onClick: handleConfigSubmit, disabled: (selectedWidgetType === 'bar-chart' || selectedWidgetType === 'series-bar-chart' || selectedWidgetType === 'series-line-chart' || selectedWidgetType === 'line-chart' || selectedWidgetType === 'pie-chart' || selectedWidgetType === 'data-grid' || selectedWidgetType === 'summary') && !query.trim(), children: "Add Widget" })] })] })) })] }) }));
@@ -37122,7 +37245,7 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
37122
37245
  widgetId: editingWidget.id,
37123
37246
  query: newQuery,
37124
37247
  agentType: (_a = editingWidget.config) === null || _a === void 0 ? void 0 : _a.agentType,
37125
- datesetId: datasetId
37248
+ datasetId: datasetId
37126
37249
  }
37127
37250
  });
37128
37251
  window.dispatchEvent(event);
@@ -37430,7 +37553,8 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
37430
37553
  const widgetNames = {
37431
37554
  'bar-chart': 'Bar Chart Widget',
37432
37555
  'pie-chart': 'Pie Chart Widget',
37433
- 'chatbot': 'Chatbot Widget'
37556
+ 'chatbot': 'Chatbot Widget',
37557
+ 'text': 'Text Widget'
37434
37558
  };
37435
37559
  widgetTypeConfig = {
37436
37560
  type: widgetType,
@@ -37457,6 +37581,8 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
37457
37581
  config: Object.assign(Object.assign({}, config), { isFirstLoad: true }) || { isFirstLoad: true },
37458
37582
  is_draggable: true,
37459
37583
  is_resizable: true,
37584
+ minH: widgetType === "text" ? widgetTypeConfig.defaultSize.h : undefined,
37585
+ maxH: widgetType === "text" ? widgetTypeConfig.defaultSize.h : undefined,
37460
37586
  page_id: pageId,
37461
37587
  };
37462
37588
  setWidgets((prev) => {
@@ -37488,15 +37614,25 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
37488
37614
  processedIds.add(widget.id);
37489
37615
  return true;
37490
37616
  })
37491
- .map((widget) => ({
37492
- i: widget.id, // must match RGL item key
37493
- x: widget.position_x, // grid X position
37494
- y: widget.position_y, // grid Y position
37495
- w: widget.width, // width in grid cols
37496
- h: widget.height, // height in grid rows
37497
- minW: 0,
37498
- minH: 0,
37499
- }));
37617
+ .map((widget) => {
37618
+ const isText = widget.type === "text";
37619
+ return {
37620
+ i: widget.id,
37621
+ x: widget.position_x,
37622
+ y: widget.position_y,
37623
+ w: widget.width,
37624
+ h: isText
37625
+ ? (isEditing ? widget.height : Math.max(widget.height - 1, 1))
37626
+ : widget.height,
37627
+ minW: 0,
37628
+ minH: isText ? widget.height : 0,
37629
+ maxH: isText ? widget.height : undefined,
37630
+ isResizable: isEditing,
37631
+ resizeHandles: isText
37632
+ ? ["w", "e"] // only horizontal
37633
+ : ["sw", "nw", "se", "ne"],
37634
+ };
37635
+ });
37500
37636
  };
37501
37637
  const removeWidget = (widgetId) => {
37502
37638
  setWidgets((prev) => {
@@ -37517,9 +37653,12 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
37517
37653
  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) => {
37518
37654
  addWidget(widgetType, config);
37519
37655
  onCloseWidgetPallete === null || onCloseWidgetPallete === void 0 ? void 0 : onCloseWidgetPallete();
37520
- }, 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", { className: `border border-primary-300 rounded-xl p-4 shadow-lg overflow-hidden ${isEditing ? 'pb-20' : 'pb-14'}`, children: [isEditing &&
37521
- 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" &&
37522
- 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), datasetId: datasetId })] })] }, w.id))) })) })] }));
37656
+ }, 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", 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], children: widgets.map((w) => {
37657
+ var _a, _b;
37658
+ return (jsxRuntimeExports.jsxs("div", { className: `${w.type === "text" ? `${((_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 &&
37659
+ jsxRuntimeExports.jsxs("div", { className: `flex items-center justify-end mb-4 relative ${w.type === "text" ? "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" }), 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' ? `${isEditing ? 'px-4' : ''}` : "h-full"} w-full relative`, children: [(w === null || w === void 0 ? void 0 : w.type) === "chatbot" &&
37660
+ 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), datasetId: datasetId })] })] }, w.id));
37661
+ }) })) })] }));
37523
37662
  }
37524
37663
 
37525
37664
  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.1.5",
3
+ "version": "1.1.7",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org"