@record-evolution/widget-navbar 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/definition-schema.d.ts +20 -0
- package/dist/src/definition-schema.json +28 -0
- package/dist/src/widget-navbar.ts +13 -3
- package/dist/widget-navbar.js +241 -238
- package/dist/widget-navbar.js.map +1 -1
- package/package.json +1 -1
- package/src/definition-schema.d.ts +20 -0
- package/src/definition-schema.json +28 -0
- package/src/widget-navbar.ts +13 -3
|
@@ -10,6 +10,14 @@ export type TitleSettings = string;
|
|
|
10
10
|
* Navigation to perform on title click. Example: If you are at route /my/route/asset then 'settings/profile' routes to '/my/route/settings/profile'.
|
|
11
11
|
*/
|
|
12
12
|
export type TitleNavigation = string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether to add a leading slash to the navigation route.
|
|
15
|
+
*/
|
|
16
|
+
export type AddLeadingSlash = boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether to add a trailing slash to the navigation route.
|
|
19
|
+
*/
|
|
20
|
+
export type AddTraillingSlash = boolean;
|
|
13
21
|
export type FontSize = number;
|
|
14
22
|
export type FontWeight = number;
|
|
15
23
|
export type Label = string;
|
|
@@ -21,16 +29,28 @@ export type IconName = string;
|
|
|
21
29
|
* Navigation to perform on click. Example: If you are at route /my/route/asset then 'settings/profile' routes to '/my/route/settings/profile'.
|
|
22
30
|
*/
|
|
23
31
|
export type NavigationRoute = string;
|
|
32
|
+
/**
|
|
33
|
+
* Whether to add a leading slash to the navigation route.
|
|
34
|
+
*/
|
|
35
|
+
export type AddLeadingSlash1 = boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Whether to add a trailing slash to the navigation route.
|
|
38
|
+
*/
|
|
39
|
+
export type AddTraillingSlash1 = boolean;
|
|
24
40
|
export type NavigationItems = {
|
|
25
41
|
label?: Label;
|
|
26
42
|
iconName?: IconName;
|
|
27
43
|
route?: NavigationRoute;
|
|
44
|
+
leadingSlash?: AddLeadingSlash1;
|
|
45
|
+
trailingSlash?: AddTraillingSlash1;
|
|
28
46
|
[k: string]: unknown;
|
|
29
47
|
}[];
|
|
30
48
|
|
|
31
49
|
export interface InputData {
|
|
32
50
|
title?: TitleSettings;
|
|
33
51
|
route?: TitleNavigation;
|
|
52
|
+
leadingSlash?: AddLeadingSlash;
|
|
53
|
+
trailingSlash?: AddTraillingSlash;
|
|
34
54
|
style?: ItemStyle;
|
|
35
55
|
navItems?: NavigationItems;
|
|
36
56
|
[k: string]: unknown;
|
|
@@ -13,6 +13,20 @@
|
|
|
13
13
|
"description": "Navigation to perform on title click. Example: If you are at route /my/route/asset then 'settings/profile' routes to '/my/route/settings/profile'.",
|
|
14
14
|
"type": "string"
|
|
15
15
|
},
|
|
16
|
+
"leadingSlash": {
|
|
17
|
+
"title": "Add Leading Slash",
|
|
18
|
+
"order": 4,
|
|
19
|
+
"description": "Whether to add a leading slash to the navigation route.",
|
|
20
|
+
"dataDrivenDisabled": true,
|
|
21
|
+
"type": "boolean"
|
|
22
|
+
},
|
|
23
|
+
"trailingSlash": {
|
|
24
|
+
"title": "Add Trailling Slash",
|
|
25
|
+
"order": 5,
|
|
26
|
+
"description": "Whether to add a trailing slash to the navigation route.",
|
|
27
|
+
"dataDrivenDisabled": true,
|
|
28
|
+
"type": "boolean"
|
|
29
|
+
},
|
|
16
30
|
"style": {
|
|
17
31
|
"title": "Item Style",
|
|
18
32
|
"order": 3,
|
|
@@ -68,6 +82,20 @@
|
|
|
68
82
|
"order": 3,
|
|
69
83
|
"description": "Navigation to perform on click. Example: If you are at route /my/route/asset then 'settings/profile' routes to '/my/route/settings/profile'.",
|
|
70
84
|
"type": "string"
|
|
85
|
+
},
|
|
86
|
+
"leadingSlash": {
|
|
87
|
+
"title": "Add Leading Slash",
|
|
88
|
+
"order": 4,
|
|
89
|
+
"description": "Whether to add a leading slash to the navigation route.",
|
|
90
|
+
"dataDrivenDisabled": true,
|
|
91
|
+
"type": "boolean"
|
|
92
|
+
},
|
|
93
|
+
"trailingSlash": {
|
|
94
|
+
"title": "Add Trailling Slash",
|
|
95
|
+
"order": 5,
|
|
96
|
+
"description": "Whether to add a trailing slash to the navigation route.",
|
|
97
|
+
"dataDrivenDisabled": true,
|
|
98
|
+
"type": "boolean"
|
|
71
99
|
}
|
|
72
100
|
}
|
|
73
101
|
}
|
|
@@ -97,6 +97,16 @@ export class WidgetNavbar extends LitElement {
|
|
|
97
97
|
return '/' + route.split('/').filter(Boolean).join('/')
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
addSlashes(item?: any): string | undefined {
|
|
101
|
+
if (!item.route?.endsWith('/') && item.trailingSlash) {
|
|
102
|
+
item.route += '/'
|
|
103
|
+
}
|
|
104
|
+
if (!item.route?.startsWith('/') && item.leadingSlash) {
|
|
105
|
+
item.route = '/' + item.route
|
|
106
|
+
}
|
|
107
|
+
return item.route
|
|
108
|
+
}
|
|
109
|
+
|
|
100
110
|
matchesRoute(itemRoute?: string) {
|
|
101
111
|
if (itemRoute === undefined) return false
|
|
102
112
|
const route = this.trimRoute(decodeURIComponent(this.route || '/'))
|
|
@@ -124,7 +134,7 @@ export class WidgetNavbar extends LitElement {
|
|
|
124
134
|
class="paging"
|
|
125
135
|
style=${this.inputData?.route ? 'cursor: pointer' : ''}
|
|
126
136
|
?active=${this.inputData?.title}
|
|
127
|
-
@click=${() => this.handleNavItemClick(this.inputData?.route)}
|
|
137
|
+
@click=${() => this.handleNavItemClick(this.addSlashes(this.inputData?.route))}
|
|
128
138
|
>
|
|
129
139
|
${this.inputData?.title}
|
|
130
140
|
</h2>
|
|
@@ -134,11 +144,11 @@ export class WidgetNavbar extends LitElement {
|
|
|
134
144
|
(item) => item.label,
|
|
135
145
|
(item) => html`
|
|
136
146
|
<mdif4-secondary-tab
|
|
137
|
-
?active=${this.matchesRoute(item
|
|
147
|
+
?active=${this.matchesRoute(this.addSlashes(item))}
|
|
138
148
|
style="font-size: ${fontSize}px;
|
|
139
149
|
--mdif4-secondary-tab-container-color: ${bgColor};
|
|
140
150
|
color: ${fontColor};"
|
|
141
|
-
@click=${() => this.handleNavItemClick(item
|
|
151
|
+
@click=${() => this.handleNavItemClick(this.addSlashes(item))}
|
|
142
152
|
>
|
|
143
153
|
${item.iconName
|
|
144
154
|
? html`
|