Skip to content

Commit bf2a697

Browse files
committed
feat(hub): allow per-group and hub-wide dock category order overrides
- DevframeViewGroup.categoryOrder overrides the default category order for its members' in-group sub-categories, scoped to that group only. - DevframeClientHostOptions.categoryOrder overrides the top-level dock-bar category order hub-wide. Both mirror DEFAULT_CATEGORIES_ORDER's shape and merge-over-defaults semantics.
1 parent e7db71c commit bf2a697

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

packages/hub/src/client/host.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,28 @@ export interface DevframeClientHostOptions {
6363
* `@devframes/json-render-ui`). The hub ships none by default.
6464
*/
6565
renderers?: Record<string, DockRenderer>
66+
/**
67+
* Hub-wide override of the top-level dock-bar category ordering — a map of
68+
* category id → ordering weight (lower sorts earlier), mirroring the shape
69+
* of {@link import('../constants').DEFAULT_CATEGORIES_ORDER}.
70+
*
71+
* This is the OUTER bucket ordering: it governs every ungrouped entry's own
72+
* `category` and every group's `category` (see
73+
* {@link import('../types/docks').DevframeDockEntryBase.category}). It is
74+
* distinct from {@link import('../types/docks').DevframeViewGroup.categoryOrder},
75+
* which only reorders the IN-GROUP sub-categories of one specific group.
76+
*
77+
* Keys are merged over `DEFAULT_CATEGORIES_ORDER`, so the host app only
78+
* lists the categories it wants to move; any category absent from the map
79+
* keeps its default weight (falling back to `0`).
80+
*
81+
* @example
82+
* ```ts
83+
* // Surface `data` tools ahead of `app` tools, hub-wide.
84+
* createDevframeClientHost({ categoryOrder: { data: 50 } })
85+
* ```
86+
*/
87+
categoryOrder?: Record<string, number>
6688
}
6789

6890
export interface DevframeClientHost {

packages/hub/src/types/docks.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,29 @@ export interface DevframeViewGroup extends DevframeDockEntryBase {
375375
* opens until a member is chosen.
376376
*/
377377
defaultChildId?: string
378+
/**
379+
* Per-group override of the in-group sub-category ordering — a map of
380+
* sub-category id → ordering weight (lower sorts earlier), mirroring the
381+
* shape of {@link import('../constants').DEFAULT_CATEGORIES_ORDER}.
382+
*
383+
* A member's own {@link DevframeDockEntryBase.category} is reinterpreted as
384+
* its IN-GROUP sub-category, and members are sub-divided and sorted by those
385+
* sub-categories. By default that sort follows the hub-wide
386+
* `DEFAULT_CATEGORIES_ORDER`; set this to reorder the sub-categories **inside
387+
* this group only**, leaving the outer dock-bar ordering (and every other
388+
* group) untouched.
389+
*
390+
* Keys are merged over the defaults, so you only list the sub-categories you
391+
* want to move; any sub-category absent from the map keeps its default weight
392+
* (falling back to `0`).
393+
*
394+
* @example
395+
* ```ts
396+
* // In the "nuxt" group, surface `app` tools before `framework` internals.
397+
* { type: 'group', id: 'nuxt', categoryOrder: { app: -200 } }
398+
* ```
399+
*/
400+
categoryOrder?: Record<string, number>
378401
}
379402

380403
/**

tests/__snapshots__/tsnapi/@devframes/hub/client.snapshot.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface DevframeClientHostOptions {
2121
clientType?: DockClientType;
2222
loadClientScripts?: boolean;
2323
renderers?: Record<string, DockRenderer>;
24+
categoryOrder?: Record<string, number>;
2425
}
2526
export interface DockClientScriptContext extends DocksContext {
2627
current: DockEntryState;

0 commit comments

Comments
 (0)