Feat: Construct a dynamic variable assignment form #10427 (#11316)

### 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)
This commit is contained in:
balibabu
2025-11-17 19:45:58 +08:00
committed by GitHub
parent 7264fb6978
commit d8f413a885
14 changed files with 1275 additions and 313 deletions

View File

@ -1,14 +1,18 @@
import { JSONSchema } from '@/components/jsonjoy-builder';
import { get, isPlainObject } from 'lodash';
import { get, isPlainObject, toLower } from 'lodash';
import { JsonSchemaDataType } from '../constant';
function predicate(types: string[], type: string) {
return types.some((x) => toLower(x) === toLower(type));
}
export function hasSpecificTypeChild(
data: Record<string, any> | Array<any>,
types: string[] = [],
) {
if (Array.isArray(data)) {
for (const value of data) {
if (isPlainObject(value) && types.some((x) => x === value.type)) {
if (isPlainObject(value) && predicate(types, value.type)) {
return true;
}
if (hasSpecificTypeChild(value, types)) {
@ -19,7 +23,7 @@ export function hasSpecificTypeChild(
if (isPlainObject(data)) {
for (const value of Object.values(data)) {
if (isPlainObject(value) && types.some((x) => x === value.type)) {
if (isPlainObject(value) && predicate(types, value.type)) {
return true;
}