import React, { useCallback } from "react"; import { FormLayout, Label, type LayoutType } from "../../index"; import { DialPanel } from "../DialPanel"; import { DialProvider, useDialSchema } from "../DialProvider"; import { IconRenderer } from "../IconRenderer"; import { LabelPositionT } from "../types"; interface DialInterfaceInputProps { name: string; label?: string; labelPosition?: LabelPositionT; icon?: string; } export const DialInterfaceInput: React.FC = ({ name, label, labelPosition = "top", icon, }) => { const { getValue, setValue, schemas } = useDialSchema(); const values: Record = getValue(name) as Record; const handlePropertyChange = useCallback( (propName: string, value: unknown) => { const newValues = { ...values }; newValues[propName] = value; setValue(name, newValues); }, [name, setValue, values], ); const schema = schemas.find((s) => s.name === name); if (!schema || !schema.typeDefinition?.schemas) { return null; } const interfaceContent = (
); if (!label) { return interfaceContent; } return (
{schema.helpText && ( ⓘ {schema.helpText} )} {interfaceContent}
); };