import { FlowNodeRegistry, ValidateTrigger } from '@flowgram.ai/fixed-layout-editor';
/**
* Custom node registration
*/
export const nodeRegistries: FlowNodeRegistry[] = [
{
/**
* Custom node type
*/
type: 'condition',
/**
* Custom node extension:
* - loop: Extend as loop node
* - start: Extend as start node
* - dynamicSplit: Extend as branch node
* - end: Extend as end node
* - tryCatch: Extend as tryCatch node
* - default: Extend as normal node (default)
*/
extend: 'dynamicSplit',
/**
* Node configuration information
*/
meta: {
// isStart: false, // Whether it's a start node
// isNodeEnd: false, // Whether it's an end node, no nodes can be added after end node
// draggable: false, // Whether draggable, start and end nodes cannot be dragged
// selectable: false, // Triggers and start nodes cannot be box-selected
// deleteDisable: true, // Disable deletion
// copyDisable: true, // Disable copying
// addDisable: true, // Disable adding
},
/**
* Configure node form validation and rendering,
* Note: validate uses data and rendering separation to ensure nodes can validate data even without rendering
*/
formMeta: {
validateTrigger: ValidateTrigger.onChange,
validate: {
title: ({ value }) => (value ? undefined : 'Title is required'),
},
/**
* Render form
*/
render: () => (
<>
<Field name="title">
{({ field }) => <div className="demo-free-node-title">{field.value}</div>}
</Field>
<Field name="content">
{({ field }) => <input onChange={field.onChange} value={field.value}/>}
</Field>
</>
)
},
},
];