### What problem does this PR solve? Feat: Construct a dynamic variable assignment form #10427 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
28 lines
757 B
TypeScript
28 lines
757 B
TypeScript
import { buildOptions } from '@/utils/form';
|
|
import { useCallback } from 'react';
|
|
import {
|
|
JsonSchemaDataType,
|
|
VariableAssignerLogicalArrayOperator,
|
|
VariableAssignerLogicalNumberOperator,
|
|
VariableAssignerLogicalOperator,
|
|
} from '../../constant';
|
|
|
|
export function useBuildLogicalOptions() {
|
|
const buildLogicalOptions = useCallback((type: string) => {
|
|
if (
|
|
type?.toLowerCase().startsWith(JsonSchemaDataType.Array.toLowerCase())
|
|
) {
|
|
return buildOptions(VariableAssignerLogicalArrayOperator);
|
|
}
|
|
|
|
if (type === JsonSchemaDataType.Number) {
|
|
return buildOptions(VariableAssignerLogicalNumberOperator);
|
|
}
|
|
|
|
return buildOptions(VariableAssignerLogicalOperator);
|
|
}, []);
|
|
|
|
return {
|
|
buildLogicalOptions,
|
|
};
|
|
}
|