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

Function getItemsForSection

packages/dev/s2-docs/src/searchUtils.tsx:240–265  ·  view source on GitHub ↗
(
  sections: Section[],
  sectionId: string,
  searchValue: string,
  resourceTagIds: string[] = []
)

Source from the content-addressed store, hash-verified

238 * Gets items for a given section selection (handles 'all' and specific sections).
239 */
240export function getItemsForSection(
241 sections: Section[],
242 sectionId: string,
243 searchValue: string,
244 resourceTagIds: string[] = []
245): ComponentItem[] {
246 // Check if this is a resource tag (e.g., icons) - return empty, handled separately
247 if (resourceTagIds.includes(sectionId)) {
248 return [];
249 }
250
251 let items: ComponentItem[];
252 if (sectionId === 'all') {
253 items = sections.flatMap(s => s.children);
254 if (searchValue.trim().length > 0) {
255 items = sortSearchItems(items, searchValue, createSearchOptions<ComponentItem>());
256 } else {
257 items = sortItemsForDisplay(items, searchValue);
258 }
259 } else {
260 items = sections.find(s => s.id === sectionId)?.children || [];
261 items = sortItemsForDisplay(items, searchValue);
262 }
263
264 return items;
265}
266
267/**
268 * Filters sections based on search value.

Callers 1

useSearchMenuStateFunction · 0.85

Calls 3

sortSearchItemsFunction · 0.85
createSearchOptionsFunction · 0.85
sortItemsForDisplayFunction · 0.85

Tested by

no test coverage detected