(
props: TInterface['properties'],
propGroups: {[name: string]: (string | RegExp)[]} = GROUPS
)
| 326 | } |
| 327 | |
| 328 | export function groupProps( |
| 329 | props: TInterface['properties'], |
| 330 | propGroups: {[name: string]: (string | RegExp)[]} = GROUPS |
| 331 | ): [TInterface['properties'], {[name: string]: TInterface['properties']}] { |
| 332 | props = Object.fromEntries( |
| 333 | Object.entries(props).filter( |
| 334 | ([, prop]) => |
| 335 | prop.type === 'property' && prop.access !== 'private' && prop.access !== 'protected' |
| 336 | ) |
| 337 | ); |
| 338 | let groups = {}; |
| 339 | |
| 340 | // Default groups |
| 341 | for (let group in propGroups) { |
| 342 | let groupProps = {}; |
| 343 | for (let propName of propGroups[group]) { |
| 344 | if (propName instanceof RegExp) { |
| 345 | for (let key in props) { |
| 346 | // eslint-disable-next-line max-depth |
| 347 | if (propName.test(key)) { |
| 348 | groupProps[key] = props[key]; |
| 349 | delete props[key]; |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | continue; |
| 354 | } |
| 355 | |
| 356 | if (props[propName]) { |
| 357 | if (propName === 'id' && props[propName].value.type !== 'string') { |
| 358 | continue; |
| 359 | } |
| 360 | |
| 361 | if ( |
| 362 | propName === 'value' && |
| 363 | ((group === 'Value' && !props.defaultValue) || |
| 364 | (group === 'Forms' && props[propName].value.type !== 'string')) |
| 365 | ) { |
| 366 | continue; |
| 367 | } |
| 368 | |
| 369 | if ( |
| 370 | propName === 'type' && |
| 371 | group === 'Forms' && |
| 372 | !props[propName].description?.includes('form') |
| 373 | ) { |
| 374 | continue; |
| 375 | } |
| 376 | |
| 377 | if (propName === 'children' && group === 'Content' && !props.items && !props.columns) { |
| 378 | continue; |
| 379 | } |
| 380 | |
| 381 | if (propName === 'target' && props[propName].value.type !== 'identifier') { |
| 382 | continue; |
| 383 | } |
| 384 | |
| 385 | if ( |
no test coverage detected