@record-evolution/widget-navbar 1.0.5 → 1.0.6
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 +10 -0
- package/dist/src/definition-schema.json +14 -0
- package/dist/src/widget-navbar.ts +12 -2
- package/dist/widget-navbar.js +240 -237
- package/dist/widget-navbar.js.map +1 -1
- package/package.json +1 -1
- package/src/definition-schema.d.ts +10 -0
- package/src/definition-schema.json +14 -0
- package/src/widget-navbar.ts +12 -2
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Webcomponent widget-navbar following open-wc recommendations",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "widget-navbar",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.6",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/widget-navbar.js",
|
|
9
9
|
"types": "dist/src/widget-navbar.d.ts",
|
|
@@ -21,10 +21,20 @@ export type IconName = string;
|
|
|
21
21
|
* Navigation to perform on click. Example: If you are at route /my/route/asset then 'settings/profile' routes to '/my/route/settings/profile'.
|
|
22
22
|
*/
|
|
23
23
|
export type NavigationRoute = string;
|
|
24
|
+
/**
|
|
25
|
+
* Whether to add a leading slash to the navigation route.
|
|
26
|
+
*/
|
|
27
|
+
export type AddLeadingSlash = boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether to add a trailing slash to the navigation route.
|
|
30
|
+
*/
|
|
31
|
+
export type AddTraillingSlash = boolean;
|
|
24
32
|
export type NavigationItems = {
|
|
25
33
|
label?: Label;
|
|
26
34
|
iconName?: IconName;
|
|
27
35
|
route?: NavigationRoute;
|
|
36
|
+
leadingSlash?: AddLeadingSlash;
|
|
37
|
+
trailingSlash?: AddTraillingSlash;
|
|
28
38
|
[k: string]: unknown;
|
|
29
39
|
}[];
|
|
30
40
|
|
|
@@ -68,6 +68,20 @@
|
|
|
68
68
|
"order": 3,
|
|
69
69
|
"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
70
|
"type": "string"
|
|
71
|
+
},
|
|
72
|
+
"leadingSlash": {
|
|
73
|
+
"title": "Add Leading Slash",
|
|
74
|
+
"order": 4,
|
|
75
|
+
"description": "Whether to add a leading slash to the navigation route.",
|
|
76
|
+
"dataDrivenDisabled": true,
|
|
77
|
+
"type": "boolean"
|
|
78
|
+
},
|
|
79
|
+
"trailingSlash": {
|
|
80
|
+
"title": "Add Trailling Slash",
|
|
81
|
+
"order": 5,
|
|
82
|
+
"description": "Whether to add a trailing slash to the navigation route.",
|
|
83
|
+
"dataDrivenDisabled": true,
|
|
84
|
+
"type": "boolean"
|
|
71
85
|
}
|
|
72
86
|
}
|
|
73
87
|
}
|
package/src/widget-navbar.ts
CHANGED
|
@@ -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 || '/'))
|
|
@@ -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`
|