|
@@ -4,7 +4,7 @@
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
import { Field } from '@flowgram.ai/free-layout-editor';
|
|
import { Field } from '@flowgram.ai/free-layout-editor';
|
|
|
-import { DynamicValueInput } from '@flowgram.ai/form-materials';
|
|
|
|
|
|
|
+import { DynamicValueInput, PromptEditorWithVariables } from '@flowgram.ai/form-materials';
|
|
|
|
|
|
|
|
import { FormItem } from '../form-item';
|
|
import { FormItem } from '../form-item';
|
|
|
import { Feedback } from '../feedback';
|
|
import { Feedback } from '../feedback';
|
|
@@ -13,6 +13,7 @@ import { useNodeRenderContext } from '../../hooks';
|
|
|
|
|
|
|
|
export function FormInputs() {
|
|
export function FormInputs() {
|
|
|
const { readonly } = useNodeRenderContext();
|
|
const { readonly } = useNodeRenderContext();
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<Field<JsonSchema> name="inputs">
|
|
<Field<JsonSchema> name="inputs">
|
|
|
{({ field: inputsField }) => {
|
|
{({ field: inputsField }) => {
|
|
@@ -23,23 +24,39 @@ export function FormInputs() {
|
|
|
}
|
|
}
|
|
|
const content = Object.keys(properties).map((key) => {
|
|
const content = Object.keys(properties).map((key) => {
|
|
|
const property = properties[key];
|
|
const property = properties[key];
|
|
|
|
|
+
|
|
|
|
|
+ const formComponent = property.extra?.formComponent;
|
|
|
|
|
+
|
|
|
|
|
+ const vertical = ['prompt-editor'].includes(formComponent || '');
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<Field key={key} name={`inputsValues.${key}`} defaultValue={property.default}>
|
|
<Field key={key} name={`inputsValues.${key}`} defaultValue={property.default}>
|
|
|
{({ field, fieldState }) => (
|
|
{({ field, fieldState }) => (
|
|
|
<FormItem
|
|
<FormItem
|
|
|
name={key}
|
|
name={key}
|
|
|
|
|
+ vertical={vertical}
|
|
|
type={property.type as string}
|
|
type={property.type as string}
|
|
|
required={required.includes(key)}
|
|
required={required.includes(key)}
|
|
|
>
|
|
>
|
|
|
- <DynamicValueInput
|
|
|
|
|
- value={field.value}
|
|
|
|
|
- onChange={field.onChange}
|
|
|
|
|
- readonly={readonly}
|
|
|
|
|
- hasError={Object.keys(fieldState?.errors || {}).length > 0}
|
|
|
|
|
- constantProps={{
|
|
|
|
|
- schema: property,
|
|
|
|
|
- }}
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ {formComponent === 'prompt-editor' && (
|
|
|
|
|
+ <PromptEditorWithVariables
|
|
|
|
|
+ value={field.value}
|
|
|
|
|
+ onChange={field.onChange}
|
|
|
|
|
+ readonly={readonly}
|
|
|
|
|
+ hasError={Object.keys(fieldState?.errors || {}).length > 0}
|
|
|
|
|
+ />
|
|
|
|
|
+ )}
|
|
|
|
|
+ {!formComponent && (
|
|
|
|
|
+ <DynamicValueInput
|
|
|
|
|
+ value={field.value}
|
|
|
|
|
+ onChange={field.onChange}
|
|
|
|
|
+ readonly={readonly}
|
|
|
|
|
+ hasError={Object.keys(fieldState?.errors || {}).length > 0}
|
|
|
|
|
+ constantProps={{
|
|
|
|
|
+ schema: property,
|
|
|
|
|
+ }}
|
|
|
|
|
+ />
|
|
|
|
|
+ )}
|
|
|
<Feedback errors={fieldState?.errors} warnings={fieldState?.warnings} />
|
|
<Feedback errors={fieldState?.errors} warnings={fieldState?.warnings} />
|
|
|
</FormItem>
|
|
</FormItem>
|
|
|
)}
|
|
)}
|