( any: JsonSchema | JsonSchema[], pred: (obj: JsonSchema) => boolean, rootSchema: JsonSchema )
| 478 | export const isObjectArrayControl = and(uiTypeIs('Control'), isObjectArray); |
| 479 | |
| 480 | const traverse = ( |
| 481 | any: JsonSchema | JsonSchema[], |
| 482 | pred: (obj: JsonSchema) => boolean, |
| 483 | rootSchema: JsonSchema |
| 484 | ): boolean => { |
| 485 | if (Array.isArray(any)) { |
| 486 | return reduce( |
| 487 | any, |
| 488 | (acc, el) => acc || traverse(el, pred, rootSchema), |
| 489 | false |
| 490 | ); |
| 491 | } |
| 492 | |
| 493 | if (pred(any)) { |
| 494 | return true; |
| 495 | } |
| 496 | |
| 497 | if (any.$ref) { |
| 498 | const toTraverse = resolveSchema(rootSchema, any.$ref, rootSchema); |
| 499 | if (toTraverse && !toTraverse.$ref) { |
| 500 | return traverse(toTraverse, pred, rootSchema); |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | if (any.items) { |
| 505 | return traverse(any.items, pred, rootSchema); |
| 506 | } |
| 507 | if (any.properties) { |
| 508 | return reduce( |
| 509 | toPairs(any.properties), |
| 510 | (acc, [_key, val]) => acc || traverse(val, pred, rootSchema), |
| 511 | false |
| 512 | ); |
| 513 | } |
| 514 | |
| 515 | return false; |
| 516 | }; |
| 517 | |
| 518 | export const isObjectArrayWithNesting = ( |
| 519 | uischema: UISchemaElement, |
no test coverage detected
searching dependent graphs…