Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

Add size configuration to ContentDialogSettings and update modal dialog to apply size styles

Muhammad Hamza Khan8f689deea46c
diff --git a/packages/app/src/builder-ui/ui/form/fields.ts b/packages/app/src/builder-ui/ui/form/fields.ts
index 4a26c5f5..df31295d 100644
--- a/packages/app/src/builder-ui/ui/form/fields.ts
+++ b/packages/app/src/builder-ui/ui/form/fields.ts
@@ -453,13 +453,11 @@ async function handleExpandTextarea(
const hasCodeEditor = !!code;
// Create modal content container
- const modalContent = document.createElement('div');
- modalContent.style.cssText = 'padding: 16px;';
// Create modal textarea
const modalTextarea = document.createElement('textarea') as TextAreaWithEditor;
modalTextarea.value = originalTextarea.value;
- modalTextarea.classList.add('form-control');
+ modalTextarea.classList.add('form-control', 'h-full');
// Apply styles based on editor type
applyTextareaStyles(modalTextarea, hasCodeEditor);
@@ -474,12 +472,17 @@ async function handleExpandTextarea(
});
}
- modalContent.appendChild(modalTextarea);
// Open modal dialog (content must be HTML string, not element)
await twModalDialog({
title: label || 'Edit',
- content: modalContent.outerHTML,
+ content: modalTextarea.outerHTML,
+ size: {
+ width: '80vw',
+ height: '80vh',
+ maxWidth: '1200px',
+ maxHeight: '800px',
+ },
actions: [
{
label: 'Done',
diff --git a/packages/app/src/builder-ui/ui/tw-dialogs.ts b/packages/app/src/builder-ui/ui/tw-dialogs.ts
index 548af035..3660aaa8 100644
--- a/packages/app/src/builder-ui/ui/tw-dialogs.ts
+++ b/packages/app/src/builder-ui/ui/tw-dialogs.ts
@@ -34,6 +34,12 @@ interface ContentDialogSettings {
onDOMReady?: (dialog: HTMLElement) => void; //callback when dialog is ready but not yet displayed
onLoad?: (dialog: HTMLElement) => void; //callback when dialog is loaded
onCloseClick?: (data?: any, dialog?: HTMLElement) => void; //callback when default dialog close buttons [X] is clicked, if this function is not defined, the dialog will not have a corner close button
+ size?: {
+ width?: string; // e.g., '80vw', '80%'
+ height?: string; // e.g., '80vh', '80%'
+ maxWidth?: string; // e.g., '1200px', '90vw'
+ maxHeight?: string; // e.g., '800px', '90vh'
+ };
}
export function editValuesDialog({
@@ -271,6 +277,7 @@ export async function twModalDialog({
onDOMReady,
onLoad,
onCloseClick,
+ size,
}: ContentDialogSettings) {
const dialoTpl = document.querySelector('#editValuesDialogTpl');
if (!dialoTpl) return;
@@ -291,6 +298,28 @@ export async function twModalDialog({
dialogContent.innerHTML = content;
+ // Apply size styles if provided
+ if (size) {
+ const dialogElement = dialogDialog as HTMLElement;
+ dialogElement.classList.add('flex', 'flex-col');
+ dialogContent.classList.add('h-full', 'p-4');
+
+ if (size.width) {
+ dialogElement.style.width = size.width;
+ }
+ if (size.height) {
+ dialogElement.style.height = size.height;
+ }
+ if (size.maxWidth) {
+ dialogElement.style.maxWidth = size.maxWidth;
+ dialogElement.classList.remove('max-w-2xl');
+ }
+ if (size.maxHeight) {
+ dialogElement.style.maxHeight = size.maxHeight;
+ dialogElement.classList.remove('max-h-screen');
+ }
+ }
+
const buttons = [];
if (actions.length === 0) {