node-registry.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
  3. * SPDX-License-Identifier: MIT
  4. */
  5. import {
  6. Field,
  7. FieldRenderProps,
  8. FormMeta,
  9. WorkflowNodeRegistry,
  10. FormRenderProps,
  11. } from '@flowgram.ai/free-layout-editor';
  12. import { FieldWrapper } from '@flowgram.ai/demo-node-form';
  13. import { Input } from '@douyinfe/semi-ui';
  14. import '../index.css';
  15. interface FormData {
  16. country: string;
  17. city: string;
  18. }
  19. const render = ({ form }: FormRenderProps<FormData>) => (
  20. <div className="demo-node-content">
  21. <div className="demo-node-title">Visibility Examples</div>
  22. <Field name="country">
  23. {({ field }: FieldRenderProps<string>) => (
  24. <FieldWrapper title="Country">
  25. <Input size={'small'} {...field} />
  26. </FieldWrapper>
  27. )}
  28. </Field>
  29. <Field name="city" deps={['country']}>
  30. {({ field }: FieldRenderProps<string>) =>
  31. form.getValueIn('country') ? (
  32. <FieldWrapper title="City">
  33. <Input size={'small'} {...field} />
  34. </FieldWrapper>
  35. ) : (
  36. <></>
  37. )
  38. }
  39. </Field>
  40. </div>
  41. );
  42. const formMeta: FormMeta<FormData> = {
  43. render,
  44. };
  45. export const nodeRegistry: WorkflowNodeRegistry = {
  46. type: 'custom',
  47. meta: {},
  48. defaultPorts: [{ type: 'output' }, { type: 'input' }],
  49. formMeta,
  50. };