Files
Jordi Enric 6f1cfef213 clean circular deps (#34262)
* clean circular deps in telemetry

* clean circular deps in command

* fix commandmenu circular deps

* rm deps.json

* fix consent circular dep

* fix TOC circular deps

* fix wrong import path

* fix test types

* fix missing fn

* undo let change

* fix consent component

* empty
2025-03-20 11:11:11 +01:00

22 lines
813 B
TypeScript

import type { ICommandSection } from 'ui-patterns/CommandMenu/internal/types'
const DEFAULT_PRIORITY = 10
/**
* Order sections in the command menu by a numbered priority. The lower the
* number, the higher the priority.
*
* Specify the priority when creating or updating the section by passing the
* option `{ sectionMeta: { priority: number } }`.
*
* The priority rankings are roughly as follows:
* 1. Super important, stick to top. Reserved for special cases.
* 2. We want to highlight this and encourage people to use it.
* 3. Easy access for most important features/commands.
*/
export function orderCommandSectionsByPriority(sections: Array<ICommandSection>) {
return sections
.slice()
.sort((a, b) => (a.meta?.priority ?? DEFAULT_PRIORITY) - (b.meta?.priority ?? DEFAULT_PRIORITY))
}