@record-evolution/widget-navbar 1.0.8 → 1.0.10

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/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.8",
6
+ "version": "1.0.10",
7
7
  "type": "module",
8
8
  "main": "dist/widget-navbar.js",
9
9
  "types": "dist/src/widget-navbar.d.ts",
@@ -15,25 +15,24 @@
15
15
  "scripts": {
16
16
  "analyze": "cem analyze --litelement",
17
17
  "start": "node rename-material-package.js && vite",
18
- "build": "node rename-material-package.js && vite build --mode production",
18
+ "build": "node rename-material-package.js && vite build",
19
19
  "watch": "node rename-material-package.js && vite build --watch",
20
- "link": "npm link && cd ../RESWARM/frontend && npm link @record-evolution/widget-navbar",
20
+ "link": "npm run build && npm link && cd ../RESWARM/frontend && npm link @record-evolution/widget-navbar",
21
21
  "unlink": "npm unlink --global && cd ../RESWARM/frontend && npm unlink @record-evolution/widget-navbar && npm i @record-evolution/widget-navbar",
22
- "types": "cat src/definition-schema.json | json2ts > src/definition-schema.d.ts",
22
+ "types": "cat src/definition-schema.json | json2ts --style.tabWidth=4 > src/definition-schema.d.ts",
23
23
  "release": "npm run build && npm run types && npm version patch --tag-version-prefix='' && git push && git push --tag && npm run build"
24
24
  },
25
25
  "dependencies": {
26
- "@material/web": "^2.4.0",
27
- "lit": "^3.3.1"
26
+ "@material/web": "^2.4.1",
27
+ "lit": "^3.3.2",
28
+ "tslib": "^2.8.1"
28
29
  },
29
30
  "devDependencies": {
30
31
  "@custom-elements-manifest/analyzer": "^0.10.5",
31
32
  "@rollup/plugin-replace": "^6.0.2",
32
33
  "json-schema-to-typescript": "^15.0.4",
33
- "rollup-plugin-copy": "^3.5.0",
34
- "tslib": "^2.8.1",
35
34
  "typescript": "^5.9.2",
36
- "vite": "^7.1.6"
35
+ "vite": "^7.3.0"
37
36
  },
38
37
  "repository": {
39
38
  "type": "git",
@@ -38,33 +38,33 @@ export type AddLeadingSlash1 = boolean;
38
38
  */
39
39
  export type AddTraillingSlash1 = boolean;
40
40
  export type NavigationItems = {
41
- label?: Label;
42
- iconName?: IconName;
43
- route?: NavigationRoute;
44
- leadingSlash?: AddLeadingSlash1;
45
- trailingSlash?: AddTraillingSlash1;
46
- [k: string]: unknown;
41
+ label?: Label;
42
+ iconName?: IconName;
43
+ route?: NavigationRoute;
44
+ leadingSlash?: AddLeadingSlash1;
45
+ trailingSlash?: AddTraillingSlash1;
46
+ [k: string]: unknown;
47
47
  }[];
48
48
 
49
49
  export interface InputData {
50
- title?: TitleSettings;
51
- route?: TitleNavigation;
52
- leadingSlash?: AddLeadingSlash;
53
- trailingSlash?: AddTraillingSlash;
54
- style?: ItemStyle;
55
- navItems?: NavigationItems;
56
- [k: string]: unknown;
50
+ title?: TitleSettings;
51
+ route?: TitleNavigation;
52
+ leadingSlash?: AddLeadingSlash;
53
+ trailingSlash?: AddTraillingSlash;
54
+ style?: ItemStyle;
55
+ navItems?: NavigationItems;
56
+ [k: string]: unknown;
57
57
  }
58
58
  export interface ItemStyle {
59
- fontSize?: FontSize;
60
- fontWeight?: FontWeight;
61
- color?: FontColor;
62
- backgroundColor?: BackgroundColor;
63
- [k: string]: unknown;
59
+ fontSize?: FontSize;
60
+ fontWeight?: FontWeight;
61
+ color?: FontColor;
62
+ backgroundColor?: BackgroundColor;
63
+ [k: string]: unknown;
64
64
  }
65
65
  export interface FontColor {
66
- [k: string]: unknown;
66
+ [k: string]: unknown;
67
67
  }
68
68
  export interface BackgroundColor {
69
- [k: string]: unknown;
69
+ [k: string]: unknown;
70
70
  }
@@ -89,6 +89,8 @@ export class WidgetNavbar extends LitElement {
89
89
  margin: 0;
90
90
  padding: 0px;
91
91
  font-size: 1.2em;
92
+ line-height: 2.5;
93
+ height: 48px;
92
94
  }
93
95
  `
94
96
 
@@ -134,7 +136,7 @@ export class WidgetNavbar extends LitElement {
134
136
  class="paging"
135
137
  style=${this.inputData?.route ? 'cursor: pointer' : ''}
136
138
  ?active=${this.inputData?.title}
137
- @click=${() => this.handleNavItemClick(this.addSlashes(this.inputData?.route))}
139
+ @click=${() => this.handleNavItemClick(this.addSlashes(this.inputData))}
138
140
  >
139
141
  ${this.inputData?.title}
140
142
  </h2>
@@ -1,70 +0,0 @@
1
- /* eslint-disable */
2
- /**
3
- * This file was automatically generated by json-schema-to-typescript.
4
- * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
- * and run json-schema-to-typescript to regenerate this file.
6
- */
7
-
8
- export type TitleSettings = string;
9
- /**
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
- */
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;
21
- export type FontSize = number;
22
- export type FontWeight = number;
23
- export type Label = string;
24
- /**
25
- * Name of the icon from https://fonts.google.com/icons
26
- */
27
- export type IconName = string;
28
- /**
29
- * Navigation to perform on click. Example: If you are at route /my/route/asset then 'settings/profile' routes to '/my/route/settings/profile'.
30
- */
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;
40
- export type NavigationItems = {
41
- label?: Label;
42
- iconName?: IconName;
43
- route?: NavigationRoute;
44
- leadingSlash?: AddLeadingSlash1;
45
- trailingSlash?: AddTraillingSlash1;
46
- [k: string]: unknown;
47
- }[];
48
-
49
- export interface InputData {
50
- title?: TitleSettings;
51
- route?: TitleNavigation;
52
- leadingSlash?: AddLeadingSlash;
53
- trailingSlash?: AddTraillingSlash;
54
- style?: ItemStyle;
55
- navItems?: NavigationItems;
56
- [k: string]: unknown;
57
- }
58
- export interface ItemStyle {
59
- fontSize?: FontSize;
60
- fontWeight?: FontWeight;
61
- color?: FontColor;
62
- backgroundColor?: BackgroundColor;
63
- [k: string]: unknown;
64
- }
65
- export interface FontColor {
66
- [k: string]: unknown;
67
- }
68
- export interface BackgroundColor {
69
- [k: string]: unknown;
70
- }
@@ -1,104 +0,0 @@
1
- {
2
- "title": "Input Data",
3
- "type": "object",
4
- "properties": {
5
- "title": {
6
- "title": "Title Settings",
7
- "order": 1,
8
- "type": "string"
9
- },
10
- "route": {
11
- "title": "Title Navigation",
12
- "order": 3,
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
- "type": "string"
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
- },
30
- "style": {
31
- "title": "Item Style",
32
- "order": 6,
33
- "type": "object",
34
- "properties": {
35
- "fontSize": {
36
- "title": "Font Size",
37
- "order": 1,
38
- "dataDrivenDisabled": true,
39
- "type": "number"
40
- },
41
- "fontWeight": {
42
- "title": "Font Weight",
43
- "order": 3,
44
- "dataDrivenDisabled": true,
45
- "type": "number"
46
- },
47
- "color": {
48
- "title": "Font Color",
49
- "order": 4,
50
- "type": "color",
51
- "dataDrivenDisabled": true
52
- },
53
- "backgroundColor": {
54
- "title": "Background Color",
55
- "order": 4,
56
- "type": "color",
57
- "dataDrivenDisabled": true
58
- }
59
- }
60
- },
61
- "navItems": {
62
- "title": "Navigation Items",
63
- "order": 7,
64
- "type": "array",
65
- "items": {
66
- "type": "object",
67
- "properties": {
68
- "label": {
69
- "title": "Label",
70
- "order": 1,
71
- "type": "string"
72
- },
73
- "iconName": {
74
- "title": "Icon Name",
75
- "order": 2,
76
- "description": "Name of the icon from https://fonts.google.com/icons",
77
- "dataDrivenDisabled": true,
78
- "type": "string"
79
- },
80
- "route": {
81
- "title": "Navigation Route",
82
- "order": 3,
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'.",
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"
99
- }
100
- }
101
- }
102
- }
103
- }
104
- }
@@ -1,172 +0,0 @@
1
- import { html, css, LitElement, PropertyValues, nothing } from 'lit'
2
- import { property, state } from 'lit/decorators.js'
3
- import { repeat } from 'lit/directives/repeat.js'
4
- import { InputData } from './definition-schema'
5
-
6
- import '@material/web/icon/icon'
7
- import '@material/web/tabs/tabs'
8
- import '@material/web/tabs/primary-tab'
9
- import '@material/web/tabs/secondary-tab'
10
-
11
- type Theme = {
12
- theme_name: string
13
- theme_object: any
14
- }
15
- export class WidgetNavbar extends LitElement {
16
- @property({ type: Object }) inputData?: InputData
17
- @property({ type: Object }) theme?: Theme
18
- @property({ type: String }) route?: string
19
-
20
- @state() private themeBgColor?: string
21
- @state() private themeTitleColor?: string
22
-
23
- version: string = 'versionplaceholder'
24
-
25
- update(changedProperties: Map<string, any>) {
26
- if (changedProperties.has('theme')) {
27
- this.registerTheme(this.theme)
28
- }
29
-
30
- super.update(changedProperties)
31
- }
32
-
33
- protected firstUpdated(_changedProperties: PropertyValues): void {
34
- this.registerTheme(this.theme)
35
- }
36
-
37
- registerTheme(theme?: Theme) {
38
- const cssTextColor = getComputedStyle(this).getPropertyValue('--re-text-color').trim()
39
- const cssBgColor = getComputedStyle(this).getPropertyValue('--re-tile-background-color').trim()
40
- this.themeBgColor = cssBgColor || this.theme?.theme_object?.backgroundColor
41
- this.themeTitleColor = cssTextColor || this.theme?.theme_object?.title?.textStyle?.color
42
- }
43
-
44
- handleNavItemClick(route?: string) {
45
- // console.log('Navigating to:', item.route)
46
- const event = new CustomEvent('nav-submit', {
47
- detail: { path: route },
48
- bubbles: true,
49
- composed: true
50
- })
51
- this.dispatchEvent(event)
52
- }
53
-
54
- normalizeRoute(route?: string) {
55
- if (!route) return '/'
56
- return route
57
- }
58
-
59
- static styles = css`
60
- :host {
61
- display: block;
62
- font-family: sans-serif;
63
- box-sizing: border-box;
64
- margin: auto;
65
- }
66
-
67
- .paging:not([active]) {
68
- display: none !important;
69
- }
70
-
71
- .wrapper {
72
- display: flex;
73
- align-items: end;
74
- height: 100%;
75
- width: 100%;
76
- box-sizing: border-box;
77
- }
78
-
79
- mdif4-icon {
80
- font-family: 'Material Symbols Outlined';
81
- }
82
-
83
- .selected {
84
- font-weight: bold;
85
- background-color: rgba(0, 0, 0, 0.1);
86
- }
87
-
88
- h2 {
89
- margin: 0;
90
- padding: 0px;
91
- font-size: 1.2em;
92
- }
93
- `
94
-
95
- trimRoute(route?: string) {
96
- if (!route) return ''
97
- return '/' + route.split('/').filter(Boolean).join('/')
98
- }
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
-
110
- matchesRoute(itemRoute?: string) {
111
- if (itemRoute === undefined) return false
112
- const route = this.trimRoute(decodeURIComponent(this.route || '/'))
113
- const subRoute = this.trimRoute(itemRoute)
114
- if (itemRoute.startsWith('/')) {
115
- return route.startsWith(subRoute)
116
- } else {
117
- return route.endsWith(subRoute) || route === subRoute
118
- }
119
- }
120
-
121
- render() {
122
- const fontSize = this.inputData?.style?.fontSize ?? 16
123
- const iconFontSize = (this.inputData?.style?.fontSize ?? 16) * 1.5
124
- const fontColor = this.inputData?.style?.color || this.themeTitleColor || 'black'
125
- const bgColor = this.inputData?.style?.backgroundColor || this.themeBgColor || 'white'
126
- return html`
127
- <div
128
- class="wrapper"
129
- style="background-color: ${bgColor}; color: ${fontColor};
130
- font-weight: ${this.inputData?.style?.fontWeight};
131
- font-size: ${fontSize}px;"
132
- >
133
- <h2
134
- class="paging"
135
- style=${this.inputData?.route ? 'cursor: pointer' : ''}
136
- ?active=${this.inputData?.title}
137
- @click=${() => this.handleNavItemClick(this.addSlashes(this.inputData?.route))}
138
- >
139
- ${this.inputData?.title}
140
- </h2>
141
- <mdif4-tab class="xnav-list">
142
- ${repeat(
143
- this.inputData?.navItems || [],
144
- (item) => item.label,
145
- (item) => html`
146
- <mdif4-secondary-tab
147
- ?active=${this.matchesRoute(this.addSlashes(item))}
148
- style="font-size: ${fontSize}px;
149
- --mdif4-secondary-tab-container-color: ${bgColor};
150
- color: ${fontColor};"
151
- @click=${() => this.handleNavItemClick(this.addSlashes(item))}
152
- >
153
- ${item.iconName
154
- ? html`
155
- <mdif4-icon
156
- slot="icon"
157
- style="font-size: ${iconFontSize}px;width: ${iconFontSize}px;color: ${fontColor}"
158
- >
159
- ${item.iconName}
160
- </mdif4-icon>
161
- `
162
- : nothing}
163
- ${item.label}
164
- </mdif4-secondary-tab>
165
- `
166
- )}
167
- </mdif4-tab>
168
- </div>
169
- `
170
- }
171
- }
172
- window.customElements.define('widget-navbar-versionplaceholder', WidgetNavbar)