@record-evolution/widget-navbar 1.0.9 → 1.0.11

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.
@@ -76,7 +76,7 @@ export class WidgetNavbar extends LitElement {
76
76
  box-sizing: border-box;
77
77
  }
78
78
 
79
- mdif4-icon {
79
+ md-icon {
80
80
  font-family: 'Material Symbols Outlined';
81
81
  }
82
82
 
@@ -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
 
@@ -138,33 +140,33 @@ export class WidgetNavbar extends LitElement {
138
140
  >
139
141
  ${this.inputData?.title}
140
142
  </h2>
141
- <mdif4-tab class="xnav-list">
143
+ <md-tab class="xnav-list">
142
144
  ${repeat(
143
145
  this.inputData?.navItems || [],
144
146
  (item) => item.label,
145
147
  (item) => html`
146
- <mdif4-secondary-tab
148
+ <md-secondary-tab
147
149
  ?active=${this.matchesRoute(this.addSlashes(item))}
148
150
  style="font-size: ${fontSize}px;
149
- --mdif4-secondary-tab-container-color: ${bgColor};
151
+ --md-secondary-tab-container-color: ${bgColor};
150
152
  color: ${fontColor};"
151
153
  @click=${() => this.handleNavItemClick(this.addSlashes(item))}
152
154
  >
153
155
  ${item.iconName
154
156
  ? html`
155
- <mdif4-icon
157
+ <md-icon
156
158
  slot="icon"
157
159
  style="font-size: ${iconFontSize}px;width: ${iconFontSize}px;color: ${fontColor}"
158
160
  >
159
161
  ${item.iconName}
160
- </mdif4-icon>
162
+ </md-icon>
161
163
  `
162
164
  : nothing}
163
165
  ${item.label}
164
- </mdif4-secondary-tab>
166
+ </md-secondary-tab>
165
167
  `
166
168
  )}
167
- </mdif4-tab>
169
+ </md-tab>
168
170
  </div>
169
171
  `
170
172
  }
@@ -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))}
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)