@record-evolution/widget-navbutton 1.0.4 → 1.0.5
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/widget-navbutton.d.ts +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/widget-navbutton.js +12 -3
- package/dist/widget-navbutton.js.map +1 -1
- package/package.json +1 -1
- package/src/definition-schema.d.ts +15 -0
- package/src/definition-schema.json +21 -0
- package/src/widget-navbutton.ts +11 -1
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Webcomponent widget-navbutton following open-wc recommendations",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "widget-navbutton",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.5",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/widget-navbutton.js",
|
|
9
9
|
"types": "dist/src/widget-navbutton.d.ts",
|
|
@@ -6,10 +6,22 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
export type Label = string;
|
|
9
|
+
/**
|
|
10
|
+
* Name of the icon from https://fonts.google.com/icons
|
|
11
|
+
*/
|
|
12
|
+
export type IconName = string;
|
|
9
13
|
/**
|
|
10
14
|
* Navigation to perform on button click. Leave blank to perform automatic back navigation. Example: If you are at route /my/route/asset then 'settings/profile' routes to '/my/route/settings/profile'.
|
|
11
15
|
*/
|
|
12
16
|
export type Navigation = string;
|
|
17
|
+
/**
|
|
18
|
+
* Whether to add a leading slash to the navigation route.
|
|
19
|
+
*/
|
|
20
|
+
export type AddLeadingSlash = boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to add a trailing slash to the navigation route.
|
|
23
|
+
*/
|
|
24
|
+
export type AddTraillingSlash = boolean;
|
|
13
25
|
/**
|
|
14
26
|
* Font size in pixels
|
|
15
27
|
*/
|
|
@@ -17,7 +29,10 @@ export type FontSize = number;
|
|
|
17
29
|
|
|
18
30
|
export interface InputData {
|
|
19
31
|
title?: Label;
|
|
32
|
+
iconName?: IconName;
|
|
20
33
|
route?: Navigation;
|
|
34
|
+
leadingSlash?: AddLeadingSlash;
|
|
35
|
+
trailingSlash?: AddTraillingSlash;
|
|
21
36
|
style?: ButtonStyle;
|
|
22
37
|
[k: string]: unknown;
|
|
23
38
|
}
|
|
@@ -7,12 +7,33 @@
|
|
|
7
7
|
"order": 1,
|
|
8
8
|
"type": "string"
|
|
9
9
|
},
|
|
10
|
+
"iconName": {
|
|
11
|
+
"title": "Icon Name",
|
|
12
|
+
"order": 2,
|
|
13
|
+
"description": "Name of the icon from https://fonts.google.com/icons",
|
|
14
|
+
"dataDrivenDisabled": true,
|
|
15
|
+
"type": "string"
|
|
16
|
+
},
|
|
10
17
|
"route": {
|
|
11
18
|
"title": "Navigation",
|
|
12
19
|
"order": 2,
|
|
13
20
|
"description": "Navigation to perform on button click. Leave blank to perform automatic back navigation. Example: If you are at route /my/route/asset then 'settings/profile' routes to '/my/route/settings/profile'.",
|
|
14
21
|
"type": "string"
|
|
15
22
|
},
|
|
23
|
+
"leadingSlash": {
|
|
24
|
+
"title": "Add Leading Slash",
|
|
25
|
+
"order": 4,
|
|
26
|
+
"description": "Whether to add a leading slash to the navigation route.",
|
|
27
|
+
"dataDrivenDisabled": true,
|
|
28
|
+
"type": "boolean"
|
|
29
|
+
},
|
|
30
|
+
"trailingSlash": {
|
|
31
|
+
"title": "Add Trailling Slash",
|
|
32
|
+
"order": 5,
|
|
33
|
+
"description": "Whether to add a trailing slash to the navigation route.",
|
|
34
|
+
"dataDrivenDisabled": true,
|
|
35
|
+
"type": "boolean"
|
|
36
|
+
},
|
|
16
37
|
"style": {
|
|
17
38
|
"title": "Button Style",
|
|
18
39
|
"order": 3,
|
package/src/widget-navbutton.ts
CHANGED
|
@@ -58,6 +58,16 @@ export class WidgetNavbutton extends LitElement {
|
|
|
58
58
|
this.dispatchEvent(event)
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
addSlashes(item?: any): string | undefined {
|
|
62
|
+
if (!item.route?.endsWith('/') && item.trailingSlash) {
|
|
63
|
+
item.route += '/'
|
|
64
|
+
}
|
|
65
|
+
if (!item.route?.startsWith('/') && item.leadingSlash) {
|
|
66
|
+
item.route = '/' + item.route
|
|
67
|
+
}
|
|
68
|
+
return item.route
|
|
69
|
+
}
|
|
70
|
+
|
|
61
71
|
static styles = css`
|
|
62
72
|
:host {
|
|
63
73
|
display: flex;
|
|
@@ -95,7 +105,7 @@ export class WidgetNavbutton extends LitElement {
|
|
|
95
105
|
--mdif5-filled-button-focus-label-text-color: ${fontColor};
|
|
96
106
|
--mdif5-filled-button-container-color: ${bgColor};
|
|
97
107
|
"
|
|
98
|
-
@click=${() => this.handleNavItemClick(this.inputData
|
|
108
|
+
@click=${() => this.handleNavItemClick(this.addSlashes(this.inputData))}
|
|
99
109
|
>
|
|
100
110
|
${this.inputData?.title}
|
|
101
111
|
<mdif5-ripple></mdif5-ripple>
|