MCPcopy Create free account
hub / github.com/adobe/react-spectrum / groupProps

Function groupProps

packages/dev/s2-docs/src/PropTable.tsx:328–407  ·  view source on GitHub ↗
(
  props: TInterface['properties'],
  propGroups: {[name: string]: (string | RegExp)[]} = GROUPS
)

Source from the content-addressed store, hash-verified

326}
327
328export 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 (

Callers 2

GroupedPropTableFunction · 0.85
PropTable.jsFile · 0.85

Calls 1

filterMethod · 0.65

Tested by

no test coverage detected