( sections: Section[], sectionId: string, searchValue: string, resourceTagIds: string[] = [] )
| 238 | * Gets items for a given section selection (handles 'all' and specific sections). |
| 239 | */ |
| 240 | export 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. |
no test coverage detected