"use client"; import React, { useState, useEffect, useCallback } from 'react'; import { useEditorStore } from '@/stores/editor-store'; import { XIcon } from 'lucide-react'; import useFlowStore, { useFlowStoreActions } from '@/stores/flow-store'; import { Node } from '@xyflow/react'; import Form from '@rjsf/core'; import { RJSFSchema, UiSchema, getTemplate, TemplatesType, FieldHelpProps } from '@rjsf/utils'; import validator from '@rjsf/validator-ajv8'; import { ObjectFieldTemplateProps, FieldTemplateProps, WidgetProps } from '@rjsf/utils'; import { FormProps } from '@rjsf/core'; import { useNodesStore } from '@/stores/nodes-store'; // Types & Interfaces interface ServiceFormData { version: string; name: string; summary: string; description: string; } interface NodeData extends ServiceFormData { [key: string]: any; } type ServiceNode = Node; const FORM_UI_SCHEMA: UiSchema = { name: { 'ui:description': 'The name of the service', 'ui:help': 'Enter the name of your service' }, version: { 'ui:description': 'The version number (e.g., 1.0.0)', 'ui:help': 'Format: MAJOR.MINOR.PATCH (e.g., 2.1.0)', 'ui:errormessage': { pattern: 'Please enter a valid version number like 1.0.0' } }, summary: { 'ui:widget': 'textarea', 'ui:description': 'A brief summary of the service', 'ui:help': 'Provide a short summary that describes your service' }, 'ui:submitButtonOptions': { norender: true } }; const BaseInputTemplate = (props: WidgetProps) => { const { id, value, onChange, disabled, placeholder, label, required } = props; // const nodeConfiguration = getNodeConfiguration(props.schema.type); return ( onChange(e.target.value)} disabled={disabled} required={required} placeholder={placeholder || `Enter ${label?.toLowerCase()}`} className=" w-full px-3 py-2 bg-white border-2 border-gray-200 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 disabled:bg-gray-50 disabled:cursor-not-allowed placeholder:text-gray-400 text-gray-900 transition-colors duration-200 " /> ); }; const BaseTextareaWidget = (props: WidgetProps) => { const { id, value, onChange, disabled, placeholder, label, required } = props; return (