This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
navigation.ts
59 lines (55 loc) · 1.63 KB
/
navigation.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { ViewNavigationGroup, MenuItem, ViewNavigationCategory, ViewNavigationItem } from '@tesler-ui/schema'
export { ViewNavigationGroup, MenuItem, ViewNavigationCategory, ViewNavigationItem } from '@tesler-ui/schema'
/**
* Returns MenuItem if it is ViewNavigationItem
*
* @param item to be identified as view
* @category Type Guards
*/
export function isViewNavigationItem(item: MenuItem): item is ViewNavigationItem {
return !!item && 'viewName' in item
}
/**
* @param item
* @deprecated ViewNavigationCategory will be deleted in 2.0.0
* @category Type Guards
*/
export function isViewNavigationCategory(item: any): item is ViewNavigationCategory {
return !!item && 'categoryName' in item
}
/**
* Returns MenuItem if it is ViewNavigationGroup
*
* @param item to be identified as group
* @category Type Guards
*/
export function isViewNavigationGroup(item: MenuItem): item is ViewNavigationGroup {
// TODO: remove 'categoryName' check in 2.0.0
return !!item && 'child' in item && !('categoryName' in item)
}
/**
* 1 - for static, top level navigation
* 2 - `SecondLevelMenu` tab widgets
* 2 - `ThirdLevelMenu` tab widgets
* 2 - `FourthLevelMenu` tab widgets
*/
export type NavigationLevel = 1 | 2 | 3 | 4
/**
* Model for displayed tab item
*/
export interface NavigationTab {
/**
* View name where navigation tab will redirect the user
*/
viewName: string
/**
* Displayed title: either view name or a group name
*/
title?: string
/**
* When true, menu item will not be visible
*
* It's still will be accessible through direct link though
*/
hidden?: boolean
}