feat: free-layout-props delete onNodeActivated, getNodeForm.onFormValueChangeIn return disposable

This commit is contained in:
xiamidaxia 2025-03-24 15:29:42 +08:00
parent 5f1a1cfa1c
commit 3397925e4a
3 changed files with 14 additions and 16 deletions

View File

@ -64,11 +64,6 @@ export interface FreeLayoutProps extends EditorProps<FreeLayoutPluginContext, Wo
* *
*/ */
onContentChange?: (ctx: FreeLayoutPluginContext, event: WorkflowContentChangeEvent) => void; onContentChange?: (ctx: FreeLayoutPluginContext, event: WorkflowContentChangeEvent) => void;
/**
*
* @param node
*/
onNodeActivated?: (ctx: FreeLayoutPluginContext, node: WorkflowNodeEntity | undefined) => void;
/** /**
* 线 * 线
* @param ctx * @param ctx

View File

@ -428,14 +428,15 @@ export class FormModelV2 extends FormModel implements Disposable {
onFormValueChangeIn<TValue = FieldValue, TFormValue = FieldValue>( onFormValueChangeIn<TValue = FieldValue, TFormValue = FieldValue>(
name: FieldName, name: FieldName,
callback: (payload: onFormValueChangeInPayload<TValue, TFormValue>) => void callback: (payload: onFormValueChangeInPayload<TValue, TFormValue>) => void
) { ): Disposable {
if (!this._initialized) { if (!this._initialized) {
throw new Error( throw new Error(
`[NodeEngine] FormModel Error: onFormValueChangeIn can not be called before initialized` `[NodeEngine] FormModel Error: onFormValueChangeIn can not be called before initialized`
); );
} }
this.formControl!._formModel.onFormValuesChange(({ name: changedName, values, prevValues }) => { return this.formControl!._formModel.onFormValuesChange(
({ name: changedName, values, prevValues }) => {
if (changedName === name) { if (changedName === name) {
callback({ callback({
value: get(values, name), value: get(values, name),
@ -444,7 +445,8 @@ export class FormModelV2 extends FormModel implements Disposable {
prevFormValues: prevValues, prevFormValues: prevValues,
}); });
} }
}); }
);
} }
/** /**

View File

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import { Disposable } from '@flowgram.ai/utils/src';
import { Event } from '@flowgram.ai/utils'; import { Event } from '@flowgram.ai/utils';
import { FlowNodeFormData, NodeRender, OnFormValuesChangePayload } from '@flowgram.ai/form-core'; import { FlowNodeFormData, NodeRender, OnFormValuesChangePayload } from '@flowgram.ai/form-core';
import { FieldName, FieldValue, FormState } from '@flowgram.ai/form'; import { FieldName, FieldValue, FormState } from '@flowgram.ai/form';
@ -55,7 +56,7 @@ export interface NodeFormProps<TValues> {
onFormValueChangeIn<TValue = FieldValue, TFormValue = FieldValue>( onFormValueChangeIn<TValue = FieldValue, TFormValue = FieldValue>(
name: FieldName, name: FieldName,
callback: (payload: onFormValueChangeInPayload<TValue, TFormValue>) => void callback: (payload: onFormValueChangeInPayload<TValue, TFormValue>) => void
): void; ): Disposable;
} }
/** /**