@record-evolution/widget-sidenav 1.0.15 → 1.0.16
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/widget-sidenav.js +58 -35
- package/dist/widget-sidenav.js.map +1 -1
- package/package.json +2 -2
- package/src/widget-sidenav.ts +23 -0
package/dist/widget-sidenav.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { css as u, LitElement as d, html as
|
|
2
|
-
import { property as
|
|
3
|
-
import { repeat as
|
|
1
|
+
import { css as u, LitElement as d, html as c } from "lit";
|
|
2
|
+
import { property as p, state as h, customElement as m } from "lit/decorators.js";
|
|
3
|
+
import { repeat as b } from "lit/directives/repeat.js";
|
|
4
4
|
import "@material/web/icon/icon.js";
|
|
5
|
-
var
|
|
6
|
-
for (var
|
|
7
|
-
(a = t[
|
|
8
|
-
return o &&
|
|
5
|
+
var g = Object.defineProperty, f = Object.getOwnPropertyDescriptor, l = (t, e, r, o) => {
|
|
6
|
+
for (var i = o > 1 ? void 0 : o ? f(e, r) : e, n = t.length - 1, a; n >= 0; n--)
|
|
7
|
+
(a = t[n]) && (i = (o ? a(e, r, i) : a(i)) || i);
|
|
8
|
+
return o && i && g(e, r, i), i;
|
|
9
9
|
};
|
|
10
10
|
let s = class extends d {
|
|
11
11
|
constructor() {
|
|
12
|
-
super(...arguments), this.version = "1.0.
|
|
12
|
+
super(...arguments), this.version = "1.0.16";
|
|
13
13
|
}
|
|
14
14
|
update(t) {
|
|
15
15
|
t.has("theme") && this.registerTheme(this.theme), super.update(t);
|
|
@@ -18,8 +18,8 @@ let s = class extends d {
|
|
|
18
18
|
this.registerTheme(this.theme);
|
|
19
19
|
}
|
|
20
20
|
registerTheme(t) {
|
|
21
|
-
const e = getComputedStyle(this).getPropertyValue("--re-text-color").trim(),
|
|
22
|
-
this.themeBgColor =
|
|
21
|
+
const e = getComputedStyle(this).getPropertyValue("--re-text-color").trim(), r = getComputedStyle(this).getPropertyValue("--re-tile-background-color").trim();
|
|
22
|
+
this.themeBgColor = r || this.theme?.theme_object?.backgroundColor, this.themeTitleColor = e || this.theme?.theme_object?.title?.textStyle?.color;
|
|
23
23
|
}
|
|
24
24
|
handleNavItemClick(t) {
|
|
25
25
|
const e = new CustomEvent("nav-submit", {
|
|
@@ -35,12 +35,12 @@ let s = class extends d {
|
|
|
35
35
|
resolveRoute(t) {
|
|
36
36
|
let e = String(t?.route ?? "");
|
|
37
37
|
if (t?.variables)
|
|
38
|
-
for (const
|
|
39
|
-
|
|
38
|
+
for (const r of t.variables)
|
|
39
|
+
r.label && (e = e.split(`{{${r.label}}}`).join(encodeURIComponent(String(r.value ?? ""))));
|
|
40
40
|
if (e.includes("*")) {
|
|
41
|
-
const
|
|
42
|
-
for (let
|
|
43
|
-
o[
|
|
41
|
+
const r = (this.route || "").split("/").filter(Boolean), o = e.split("/").filter(Boolean);
|
|
42
|
+
for (let i = 0; i < o.length; i++)
|
|
43
|
+
o[i] === "*" && (o[i] = r[i] ?? "");
|
|
44
44
|
e = (e.startsWith("/") ? "/" : "") + o.filter(Boolean).join("/");
|
|
45
45
|
}
|
|
46
46
|
return e;
|
|
@@ -48,12 +48,12 @@ let s = class extends d {
|
|
|
48
48
|
matchesRoute(t) {
|
|
49
49
|
if (t === void 0) return !1;
|
|
50
50
|
t = String(t);
|
|
51
|
-
const e = this.trimRoute(decodeURIComponent(this.route || "/")),
|
|
52
|
-
return t.startsWith("/") ? e.startsWith(
|
|
51
|
+
const e = this.trimRoute(decodeURIComponent(this.route || "/")), r = this.trimRoute(t);
|
|
52
|
+
return t.startsWith("/") ? e.startsWith(r) : e.endsWith(r) || e === r;
|
|
53
53
|
}
|
|
54
54
|
render() {
|
|
55
|
-
const t = this.inputData?.style?.fontSize ?? 16, e = (this.inputData?.style?.fontSize ?? 16) * 1.5,
|
|
56
|
-
return
|
|
55
|
+
const t = this.inputData?.style?.fontSize ?? 16, e = (this.inputData?.style?.fontSize ?? 16) * 1.5, r = t * 0.4;
|
|
56
|
+
return c`
|
|
57
57
|
<div
|
|
58
58
|
class="wrapper"
|
|
59
59
|
style="background-color: ${this.inputData?.style?.backgroundColor || this.themeBgColor}; color: ${this.inputData?.style?.color || this.themeTitleColor};
|
|
@@ -74,16 +74,16 @@ let s = class extends d {
|
|
|
74
74
|
${this.inputData?.title}
|
|
75
75
|
</h2>
|
|
76
76
|
<div class="nav-list">
|
|
77
|
-
${
|
|
77
|
+
${b(
|
|
78
78
|
this.inputData?.navItems || [],
|
|
79
79
|
(o) => o.label,
|
|
80
|
-
(o) =>
|
|
80
|
+
(o) => c`
|
|
81
81
|
<div
|
|
82
82
|
class="nav-item ${this.matchesRoute(this.resolveRoute(o)) ? "selected" : ""}"
|
|
83
|
-
style="gap: ${
|
|
83
|
+
style="gap: ${r}px;"
|
|
84
84
|
@click=${() => this.handleNavItemClick(this.resolveRoute(o))}
|
|
85
85
|
>
|
|
86
|
-
${o.iconName ?
|
|
86
|
+
${o.iconName ? c`
|
|
87
87
|
<md-icon
|
|
88
88
|
style="font-size: ${e}px;width: ${e}px;"
|
|
89
89
|
>${o.iconName}
|
|
@@ -126,6 +126,29 @@ s.styles = u`
|
|
|
126
126
|
margin-top: 12px;
|
|
127
127
|
overflow-y: auto;
|
|
128
128
|
flex-grow: 1;
|
|
129
|
+
/* Derive scrollbar colors from the (inherited) text color so they
|
|
130
|
+
follow custom styles and themes — e.g. light thumb on dark nav. */
|
|
131
|
+
scrollbar-width: thin;
|
|
132
|
+
scrollbar-color: color-mix(in srgb, currentColor 35%, transparent) transparent;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* WebKit/Blink fallback for browsers without scrollbar-color support. */
|
|
136
|
+
.nav-list::-webkit-scrollbar {
|
|
137
|
+
width: 8px;
|
|
138
|
+
height: 8px;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.nav-list::-webkit-scrollbar-track {
|
|
142
|
+
background: transparent;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.nav-list::-webkit-scrollbar-thumb {
|
|
146
|
+
background-color: color-mix(in srgb, currentColor 35%, transparent);
|
|
147
|
+
border-radius: 4px;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.nav-list::-webkit-scrollbar-thumb:hover {
|
|
151
|
+
background-color: color-mix(in srgb, currentColor 55%, transparent);
|
|
129
152
|
}
|
|
130
153
|
|
|
131
154
|
.nav-item {
|
|
@@ -151,23 +174,23 @@ s.styles = u`
|
|
|
151
174
|
font-size: 1.2em;
|
|
152
175
|
}
|
|
153
176
|
`;
|
|
154
|
-
|
|
155
|
-
|
|
177
|
+
l([
|
|
178
|
+
p({ type: Object })
|
|
156
179
|
], s.prototype, "inputData", 2);
|
|
157
|
-
|
|
158
|
-
|
|
180
|
+
l([
|
|
181
|
+
p({ type: Object })
|
|
159
182
|
], s.prototype, "theme", 2);
|
|
160
|
-
|
|
161
|
-
|
|
183
|
+
l([
|
|
184
|
+
p({ type: String })
|
|
162
185
|
], s.prototype, "route", 2);
|
|
163
|
-
|
|
164
|
-
|
|
186
|
+
l([
|
|
187
|
+
h()
|
|
165
188
|
], s.prototype, "themeBgColor", 2);
|
|
166
|
-
|
|
167
|
-
|
|
189
|
+
l([
|
|
190
|
+
h()
|
|
168
191
|
], s.prototype, "themeTitleColor", 2);
|
|
169
|
-
s =
|
|
170
|
-
m("widget-sidenav-1.0.
|
|
192
|
+
s = l([
|
|
193
|
+
m("widget-sidenav-1.0.16")
|
|
171
194
|
], s);
|
|
172
195
|
export {
|
|
173
196
|
s as WidgetSidenav
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget-sidenav.js","sources":["../src/widget-sidenav.ts"],"sourcesContent":["import { html, css, LitElement, PropertyValues } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { repeat } from 'lit/directives/repeat.js'\nimport { InputData } from './definition-schema'\n\nimport '@material/web/icon/icon.js'\n\ntype Theme = {\n theme_name: string\n theme_object: any\n}\n@customElement('widget-sidenav-versionplaceholder')\nexport class WidgetSidenav extends LitElement {\n @property({ type: Object }) inputData?: InputData\n @property({ type: Object }) theme?: Theme\n @property({ type: String }) route?: string\n\n @state() private themeBgColor?: string\n @state() private themeTitleColor?: string\n\n version: string = 'versionplaceholder'\n\n update(changedProperties: Map<string, any>) {\n if (changedProperties.has('theme')) {\n this.registerTheme(this.theme)\n }\n\n super.update(changedProperties)\n }\n\n protected firstUpdated(_changedProperties: PropertyValues): void {\n this.registerTheme(this.theme)\n }\n\n registerTheme(theme?: Theme) {\n const cssTextColor = getComputedStyle(this).getPropertyValue('--re-text-color').trim()\n const cssBgColor = getComputedStyle(this).getPropertyValue('--re-tile-background-color').trim()\n this.themeBgColor = cssBgColor || this.theme?.theme_object?.backgroundColor\n this.themeTitleColor = cssTextColor || this.theme?.theme_object?.title?.textStyle?.color\n }\n\n handleNavItemClick(route?: string) {\n // console.log('Navigating to:', item.route)\n const event = new CustomEvent('nav-submit', {\n detail: { path: String(route) },\n bubbles: true,\n composed: true\n })\n this.dispatchEvent(event)\n }\n\n trimRoute(route?: string) {\n route = String(route)\n if (!route) return ''\n return '/' + route.split('/').filter(Boolean).join('/')\n }\n\n resolveRoute(item?: any): string | undefined {\n let route = String(item?.route ?? '')\n if (item?.variables) {\n for (const variable of item.variables) {\n if (variable.label) {\n route = route\n .split(`{{${variable.label}}}`)\n .join(encodeURIComponent(String(variable.value ?? '')))\n }\n }\n }\n if (route.includes('*')) {\n const currentSegments = (this.route || '').split('/').filter(Boolean)\n const routeSegments = route.split('/').filter(Boolean)\n for (let i = 0; i < routeSegments.length; i++) {\n if (routeSegments[i] === '*') {\n routeSegments[i] = currentSegments[i] ?? ''\n }\n }\n route = (route.startsWith('/') ? '/' : '') + routeSegments.filter(Boolean).join('/')\n }\n return route\n }\n\n matchesRoute(itemRoute?: string) {\n if (itemRoute === undefined) return false\n itemRoute = String(itemRoute)\n const route = this.trimRoute(decodeURIComponent(this.route || '/'))\n const subRoute = this.trimRoute(itemRoute)\n if (itemRoute.startsWith('/')) {\n return route.startsWith(subRoute)\n } else {\n return route.endsWith(subRoute) || route === subRoute\n }\n }\n\n static styles = css`\n :host {\n display: block;\n font-family: sans-serif;\n box-sizing: border-box;\n margin: auto;\n }\n\n .paging:not([active]) {\n display: none !important;\n }\n\n .wrapper {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n padding: 12px;\n box-sizing: border-box;\n }\n\n .nav-list {\n display: flex;\n flex-direction: column;\n gap: 2px;\n margin-top: 12px;\n overflow-y: auto;\n flex-grow: 1;\n }\n\n .nav-item {\n cursor: pointer;\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 8px;\n border-radius: 4px;\n }\n\n md-icon {\n font-family: 'Material Symbols Outlined';\n }\n\n .selected {\n background-color: rgba(0, 0, 0, 0.1);\n }\n\n h2 {\n margin: 0;\n padding: 0px;\n font-size: 1.2em;\n }\n `\n\n render() {\n const fontSize = this.inputData?.style?.fontSize ?? 16\n const iconFontSize = (this.inputData?.style?.fontSize ?? 16) * 1.5\n const gap = fontSize * 0.4\n return html`\n <div\n class=\"wrapper\"\n style=\"background-color: ${this.inputData?.style?.backgroundColor ||\n this.themeBgColor}; color: ${this.inputData?.style?.color || this.themeTitleColor};\n font-weight: ${this.inputData?.style?.fontWeight};\n font-size: ${fontSize}px;\"\n >\n <h2\n class=\"paging\"\n style=${this.inputData?.route ? 'cursor: pointer' : ''}\n ?active=${this.inputData?.title}\n @click=${() =>\n this.handleNavItemClick(\n this.resolveRoute({\n route: this.inputData?.route,\n variables: this.inputData?.variables\n })\n )}\n >\n ${this.inputData?.title}\n </h2>\n <div class=\"nav-list\">\n ${repeat(\n this.inputData?.navItems || [],\n (item) => item.label,\n (item) => html`\n <div\n class=\"nav-item ${this.matchesRoute(this.resolveRoute(item))\n ? 'selected'\n : ''}\"\n style=\"gap: ${gap}px;\"\n @click=${() => this.handleNavItemClick(this.resolveRoute(item))}\n >\n ${item.iconName\n ? html`\n <md-icon\n style=\"font-size: ${iconFontSize}px;width: ${iconFontSize}px;\"\n >${item.iconName}\n </md-icon>\n `\n : ''}\n ${item.label}\n </div>\n `\n )}\n </div>\n </div>\n `\n }\n}\n"],"names":["WidgetSidenav","LitElement","changedProperties","_changedProperties","theme","cssTextColor","cssBgColor","route","event","item","variable","currentSegments","routeSegments","i","itemRoute","subRoute","fontSize","iconFontSize","gap","html","repeat","css","__decorateClass","property","state","customElement"],"mappings":";;;;;;;;;AAYO,IAAMA,IAAN,cAA4BC,EAAW;AAAA,EAAvC,cAAA;AAAA,UAAA,GAAA,SAAA,GAQH,KAAA,UAAkB;AAAA,EAAA;AAAA,EAElB,OAAOC,GAAqC;AACxC,IAAIA,EAAkB,IAAI,OAAO,KAC7B,KAAK,cAAc,KAAK,KAAK,GAGjC,MAAM,OAAOA,CAAiB;AAAA,EAClC;AAAA,EAEU,aAAaC,GAA0C;AAC7D,SAAK,cAAc,KAAK,KAAK;AAAA,EACjC;AAAA,EAEA,cAAcC,GAAe;AACzB,UAAMC,IAAe,iBAAiB,IAAI,EAAE,iBAAiB,iBAAiB,EAAE,KAAA,GAC1EC,IAAa,iBAAiB,IAAI,EAAE,iBAAiB,4BAA4B,EAAE,KAAA;AACzF,SAAK,eAAeA,KAAc,KAAK,OAAO,cAAc,iBAC5D,KAAK,kBAAkBD,KAAgB,KAAK,OAAO,cAAc,OAAO,WAAW;AAAA,EACvF;AAAA,EAEA,mBAAmBE,GAAgB;AAE/B,UAAMC,IAAQ,IAAI,YAAY,cAAc;AAAA,MACxC,QAAQ,EAAE,MAAM,OAAOD,CAAK,EAAA;AAAA,MAC5B,SAAS;AAAA,MACT,UAAU;AAAA,IAAA,CACb;AACD,SAAK,cAAcC,CAAK;AAAA,EAC5B;AAAA,EAEA,UAAUD,GAAgB;AAEtB,WADAA,IAAQ,OAAOA,CAAK,GACfA,IACE,MAAMA,EAAM,MAAM,GAAG,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,IADnC;AAAA,EAEvB;AAAA,E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AA,CAAA;AACAsB,EAAA;AAAA,EAA3BC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAFjBvB,EAEmB,WAAA,SAAA,CAAA;AACAsB,EAAA;AAAA,EAA3BC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAHjBvB,EAGmB,WAAA,SAAA,CAAA;AAEXsB,EAAA;AAAA,EAAhBE,EAAA;AAAM,GALExB,EAKQ,WAAA,gBAAA,CAAA;AACAsB,EAAA;AAAA,EAAhBE,EAAA;AAAM,GANExB,EAMQ,WAAA,mBAAA,CAAA;AANRA,IAANsB,EAAA;AAAA,EADNG,EAAc,uBAAmC;AAAA,GACrCzB,CAAA;"}
|
|
1
|
+
{"version":3,"file":"widget-sidenav.js","sources":["../src/widget-sidenav.ts"],"sourcesContent":["import { html, css, LitElement, PropertyValues } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { repeat } from 'lit/directives/repeat.js'\nimport { InputData } from './definition-schema'\n\nimport '@material/web/icon/icon.js'\n\ntype Theme = {\n theme_name: string\n theme_object: any\n}\n@customElement('widget-sidenav-versionplaceholder')\nexport class WidgetSidenav extends LitElement {\n @property({ type: Object }) inputData?: InputData\n @property({ type: Object }) theme?: Theme\n @property({ type: String }) route?: string\n\n @state() private themeBgColor?: string\n @state() private themeTitleColor?: string\n\n version: string = 'versionplaceholder'\n\n update(changedProperties: Map<string, any>) {\n if (changedProperties.has('theme')) {\n this.registerTheme(this.theme)\n }\n\n super.update(changedProperties)\n }\n\n protected firstUpdated(_changedProperties: PropertyValues): void {\n this.registerTheme(this.theme)\n }\n\n registerTheme(theme?: Theme) {\n const cssTextColor = getComputedStyle(this).getPropertyValue('--re-text-color').trim()\n const cssBgColor = getComputedStyle(this).getPropertyValue('--re-tile-background-color').trim()\n this.themeBgColor = cssBgColor || this.theme?.theme_object?.backgroundColor\n this.themeTitleColor = cssTextColor || this.theme?.theme_object?.title?.textStyle?.color\n }\n\n handleNavItemClick(route?: string) {\n // console.log('Navigating to:', item.route)\n const event = new CustomEvent('nav-submit', {\n detail: { path: String(route) },\n bubbles: true,\n composed: true\n })\n this.dispatchEvent(event)\n }\n\n trimRoute(route?: string) {\n route = String(route)\n if (!route) return ''\n return '/' + route.split('/').filter(Boolean).join('/')\n }\n\n resolveRoute(item?: any): string | undefined {\n let route = String(item?.route ?? '')\n if (item?.variables) {\n for (const variable of item.variables) {\n if (variable.label) {\n route = route\n .split(`{{${variable.label}}}`)\n .join(encodeURIComponent(String(variable.value ?? '')))\n }\n }\n }\n if (route.includes('*')) {\n const currentSegments = (this.route || '').split('/').filter(Boolean)\n const routeSegments = route.split('/').filter(Boolean)\n for (let i = 0; i < routeSegments.length; i++) {\n if (routeSegments[i] === '*') {\n routeSegments[i] = currentSegments[i] ?? ''\n }\n }\n route = (route.startsWith('/') ? '/' : '') + routeSegments.filter(Boolean).join('/')\n }\n return route\n }\n\n matchesRoute(itemRoute?: string) {\n if (itemRoute === undefined) return false\n itemRoute = String(itemRoute)\n const route = this.trimRoute(decodeURIComponent(this.route || '/'))\n const subRoute = this.trimRoute(itemRoute)\n if (itemRoute.startsWith('/')) {\n return route.startsWith(subRoute)\n } else {\n return route.endsWith(subRoute) || route === subRoute\n }\n }\n\n static styles = css`\n :host {\n display: block;\n font-family: sans-serif;\n box-sizing: border-box;\n margin: auto;\n }\n\n .paging:not([active]) {\n display: none !important;\n }\n\n .wrapper {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n padding: 12px;\n box-sizing: border-box;\n }\n\n .nav-list {\n display: flex;\n flex-direction: column;\n gap: 2px;\n margin-top: 12px;\n overflow-y: auto;\n flex-grow: 1;\n /* Derive scrollbar colors from the (inherited) text color so they\n follow custom styles and themes — e.g. light thumb on dark nav. */\n scrollbar-width: thin;\n scrollbar-color: color-mix(in srgb, currentColor 35%, transparent) transparent;\n }\n\n /* WebKit/Blink fallback for browsers without scrollbar-color support. */\n .nav-list::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n }\n\n .nav-list::-webkit-scrollbar-track {\n background: transparent;\n }\n\n .nav-list::-webkit-scrollbar-thumb {\n background-color: color-mix(in srgb, currentColor 35%, transparent);\n border-radius: 4px;\n }\n\n .nav-list::-webkit-scrollbar-thumb:hover {\n background-color: color-mix(in srgb, currentColor 55%, transparent);\n }\n\n .nav-item {\n cursor: pointer;\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 8px;\n border-radius: 4px;\n }\n\n md-icon {\n font-family: 'Material Symbols Outlined';\n }\n\n .selected {\n background-color: rgba(0, 0, 0, 0.1);\n }\n\n h2 {\n margin: 0;\n padding: 0px;\n font-size: 1.2em;\n }\n `\n\n render() {\n const fontSize = this.inputData?.style?.fontSize ?? 16\n const iconFontSize = (this.inputData?.style?.fontSize ?? 16) * 1.5\n const gap = fontSize * 0.4\n return html`\n <div\n class=\"wrapper\"\n style=\"background-color: ${this.inputData?.style?.backgroundColor ||\n this.themeBgColor}; color: ${this.inputData?.style?.color || this.themeTitleColor};\n font-weight: ${this.inputData?.style?.fontWeight};\n font-size: ${fontSize}px;\"\n >\n <h2\n class=\"paging\"\n style=${this.inputData?.route ? 'cursor: pointer' : ''}\n ?active=${this.inputData?.title}\n @click=${() =>\n this.handleNavItemClick(\n this.resolveRoute({\n route: this.inputData?.route,\n variables: this.inputData?.variables\n })\n )}\n >\n ${this.inputData?.title}\n </h2>\n <div class=\"nav-list\">\n ${repeat(\n this.inputData?.navItems || [],\n (item) => item.label,\n (item) => html`\n <div\n class=\"nav-item ${this.matchesRoute(this.resolveRoute(item))\n ? 'selected'\n : ''}\"\n style=\"gap: ${gap}px;\"\n @click=${() => this.handleNavItemClick(this.resolveRoute(item))}\n >\n ${item.iconName\n ? html`\n <md-icon\n style=\"font-size: ${iconFontSize}px;width: ${iconFontSize}px;\"\n >${item.iconName}\n </md-icon>\n `\n : ''}\n ${item.label}\n </div>\n `\n )}\n </div>\n </div>\n `\n }\n}\n"],"names":["WidgetSidenav","LitElement","changedProperties","_changedProperties","theme","cssTextColor","cssBgColor","route","event","item","variable","currentSegments","routeSegments","itemRoute","subRoute","fontSize","iconFontSize","gap","html","repeat","css","__decorateClass","property","state","customElement"],"mappings":";;;;;;;;;AAYO,IAAMA,IAAN,cAA4BC,EAAW;AAAA,EAAvC,cAAA;AAAA,UAAA,GAAA,SAAA,GAQH,KAAA,UAAkB;AAAA,EAAA;AAAA,EAElB,OAAOC,GAAqC;AACxC,IAAIA,EAAkB,IAAI,OAAO,KAC7B,KAAK,cAAc,KAAK,KAAK,GAGjC,MAAM,OAAOA,CAAiB;AAAA,EAClC;AAAA,EAEU,aAAaC,GAA0C;AAC7D,SAAK,cAAc,KAAK,KAAK;AAAA,EACjC;AAAA,EAEA,cAAcC,GAAe;AACzB,UAAMC,IAAe,iBAAiB,IAAI,EAAE,iBAAiB,iBAAiB,EAAE,KAAA,GAC1EC,IAAa,iBAAiB,IAAI,EAAE,iBAAiB,4BAA4B,EAAE,KAAA;AACzF,SAAK,eAAeA,KAAc,KAAK,OAAO,cAAc,iBAC5D,KAAK,kBAAkBD,KAAgB,KAAK,OAAO,cAAc,OAAO,WAAW;AAAA,EACvF;AAAA,EAEA,mBAAmBE,GAAgB;AAE/B,UAAMC,IAAQ,IAAI,YAAY,cAAc;AAAA,MACxC,QAAQ,EAAE,MAAM,OAAOD,CAAK,EAAA;AAAA,MAC5B,SAAS;AAAA,MACT,UAAU;AAAA,IAAA,CACb;AACD,SAAK,cAAcC,CAAK;AAAA,EAC5B;AAAA,EAEA,UAAUD,GAAgB;AAEtB,WADAA,IAAQ,OAAOA,CAAK,GACfA,IACE,MAAMA,EAAM,MAAM,GAAG,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,IADnC;AAAA,EAEvB;AAAA,EAEA,aAAaE,GAAgC;AACzC,QAAIF,IAAQ,OAAOE,GAAM,SAAS,EAAE;AACpC,QAAIA,GAAM;AACN,iBAAWC,KAAYD,EAAK;AACxB,QAAIC,EAAS,UACTH,IAAQA,EACH,MAAM,KAAKG,EAAS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C,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAFjBtB,EAEmB,WAAA,SAAA,CAAA;AACAqB,EAAA;AAAA,EAA3BC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAHjBtB,EAGmB,WAAA,SAAA,CAAA;AAEXqB,EAAA;AAAA,EAAhBE,EAAA;AAAM,GALEvB,EAKQ,WAAA,gBAAA,CAAA;AACAqB,EAAA;AAAA,EAAhBE,EAAA;AAAM,GANEvB,EAMQ,WAAA,mBAAA,CAAA;AANRA,IAANqB,EAAA;AAAA,EADNG,EAAc,uBAAmC;AAAA,GACrCxB,CAAA;"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Webcomponent widget-sidenav following open-wc recommendations",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "widget-sidenav",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.16",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=24.9.0",
|
|
9
9
|
"npm": ">=10.0.2"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"release": "npm run build && npm run types && npm version patch --tag-version-prefix='' && git push && git push --tag && npm run build"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"lit": "^3.3.
|
|
31
|
+
"lit": "^3.3.3",
|
|
32
32
|
"tslib": "^2.8.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
package/src/widget-sidenav.ts
CHANGED
|
@@ -119,6 +119,29 @@ export class WidgetSidenav extends LitElement {
|
|
|
119
119
|
margin-top: 12px;
|
|
120
120
|
overflow-y: auto;
|
|
121
121
|
flex-grow: 1;
|
|
122
|
+
/* Derive scrollbar colors from the (inherited) text color so they
|
|
123
|
+
follow custom styles and themes — e.g. light thumb on dark nav. */
|
|
124
|
+
scrollbar-width: thin;
|
|
125
|
+
scrollbar-color: color-mix(in srgb, currentColor 35%, transparent) transparent;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* WebKit/Blink fallback for browsers without scrollbar-color support. */
|
|
129
|
+
.nav-list::-webkit-scrollbar {
|
|
130
|
+
width: 8px;
|
|
131
|
+
height: 8px;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.nav-list::-webkit-scrollbar-track {
|
|
135
|
+
background: transparent;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.nav-list::-webkit-scrollbar-thumb {
|
|
139
|
+
background-color: color-mix(in srgb, currentColor 35%, transparent);
|
|
140
|
+
border-radius: 4px;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.nav-list::-webkit-scrollbar-thumb:hover {
|
|
144
|
+
background-color: color-mix(in srgb, currentColor 55%, transparent);
|
|
122
145
|
}
|
|
123
146
|
|
|
124
147
|
.nav-item {
|