@record-evolution/widget-navbutton 1.0.10 → 1.0.12
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-navbutton.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { css as d, LitElement as
|
|
1
|
+
import { css as d, LitElement as f, html as h } from "lit";
|
|
2
2
|
import { property as c, state as u, customElement as p } from "lit/decorators.js";
|
|
3
3
|
import "@material/web/icon/icon.js";
|
|
4
4
|
import "@material/web/button/filled-button.js";
|
|
5
|
-
var
|
|
6
|
-
for (var
|
|
7
|
-
(a = t[s]) && (
|
|
8
|
-
return
|
|
5
|
+
var m = Object.defineProperty, b = Object.getOwnPropertyDescriptor, n = (t, e, o, l) => {
|
|
6
|
+
for (var r = l > 1 ? void 0 : l ? b(e, o) : e, s = t.length - 1, a; s >= 0; s--)
|
|
7
|
+
(a = t[s]) && (r = (l ? a(e, o, r) : a(r)) || r);
|
|
8
|
+
return l && r && m(e, o, r), r;
|
|
9
9
|
};
|
|
10
10
|
const g = (t) => {
|
|
11
11
|
if (!t) return !0;
|
|
@@ -14,9 +14,9 @@ const g = (t) => {
|
|
|
14
14
|
const o = e.match(/^(?:rgba|hsla)\([^)]*[,/]\s*([\d.]+%?)\s*\)$/);
|
|
15
15
|
return o ? parseFloat(o[1]) === 0 : /^#[0-9a-f]{8}$/.test(e) ? e.slice(7) === "00" : /^#[0-9a-f]{4}$/.test(e) ? e[4] === "0" : !1;
|
|
16
16
|
};
|
|
17
|
-
let i = class extends
|
|
17
|
+
let i = class extends f {
|
|
18
18
|
constructor() {
|
|
19
|
-
super(...arguments), this.version = "1.0.
|
|
19
|
+
super(...arguments), this.version = "1.0.12";
|
|
20
20
|
}
|
|
21
21
|
update(t) {
|
|
22
22
|
t.has("theme") && this.registerTheme(this.theme), super.update(t);
|
|
@@ -25,8 +25,8 @@ let i = class extends h {
|
|
|
25
25
|
this.registerTheme(this.theme);
|
|
26
26
|
}
|
|
27
27
|
registerTheme(t) {
|
|
28
|
-
const e =
|
|
29
|
-
this.themeBgColor =
|
|
28
|
+
const e = t?.theme_object?.backgroundColor;
|
|
29
|
+
this.themeBgColor = `var(--re-tile-background-color, ${(g(e) ? void 0 : e) || "transparent"})`, this.themeTitleColor = `var(--re-text-color, ${t?.theme_object?.title?.textStyle?.color || "inherit"})`;
|
|
30
30
|
}
|
|
31
31
|
handleNavItemClick() {
|
|
32
32
|
let t;
|
|
@@ -47,21 +47,21 @@ let i = class extends h {
|
|
|
47
47
|
for (const o of t.variables)
|
|
48
48
|
o.label && (e = e.split(`{{${o.label}}}`).join(encodeURIComponent(String(o.value ?? ""))));
|
|
49
49
|
if (e.includes("*")) {
|
|
50
|
-
const o = (this.route || "").split("/").filter(Boolean),
|
|
51
|
-
for (let
|
|
52
|
-
r
|
|
53
|
-
e = (e.startsWith("/") ? "/" : "") +
|
|
50
|
+
const o = (this.route || "").split("/").filter(Boolean), l = e.split("/").filter(Boolean);
|
|
51
|
+
for (let r = 0; r < l.length; r++)
|
|
52
|
+
l[r] === "*" && (l[r] = o[r] ?? "");
|
|
53
|
+
e = (e.startsWith("/") ? "/" : "") + l.filter(Boolean).join("/");
|
|
54
54
|
}
|
|
55
55
|
return e;
|
|
56
56
|
}
|
|
57
57
|
render() {
|
|
58
|
-
const t = this.inputData?.style?.fontSize ?? 16, e = t * 1.5, o = this.inputData?.style?.color || this.themeTitleColor || "black",
|
|
59
|
-
return
|
|
58
|
+
const t = this.inputData?.style?.fontSize ?? 16, e = t * 1.5, o = this.inputData?.style?.color || this.themeTitleColor || "black", l = this.inputData?.style?.backgroundColor || this.themeBgColor || "white", r = Math.max(40, Math.round(t * 2.5));
|
|
59
|
+
return h`
|
|
60
60
|
<md-filled-button
|
|
61
61
|
style="--btn-fg: ${o};
|
|
62
62
|
font-size: ${t}px;
|
|
63
63
|
--md-filled-button-label-text-size: ${t}px;
|
|
64
|
-
--md-filled-button-container-height: ${
|
|
64
|
+
--md-filled-button-container-height: ${r}px;
|
|
65
65
|
--md-filled-button-icon-size: ${e}px;
|
|
66
66
|
--md-filled-button-label-text-color: ${o};
|
|
67
67
|
--md-filled-button-hover-label-text-color: ${o};
|
|
@@ -71,7 +71,7 @@ let i = class extends h {
|
|
|
71
71
|
--md-filled-button-hover-icon-color: ${o};
|
|
72
72
|
--md-filled-button-pressed-icon-color: ${o};
|
|
73
73
|
--md-filled-button-focus-icon-color: ${o};
|
|
74
|
-
--md-filled-button-container-color: ${
|
|
74
|
+
--md-filled-button-container-color: ${l};
|
|
75
75
|
"
|
|
76
76
|
@click=${() => this.handleNavItemClick()}
|
|
77
77
|
>
|
|
@@ -127,7 +127,7 @@ n([
|
|
|
127
127
|
u()
|
|
128
128
|
], i.prototype, "themeTitleColor", 2);
|
|
129
129
|
i = n([
|
|
130
|
-
p("widget-navbutton-1.0.
|
|
130
|
+
p("widget-navbutton-1.0.12")
|
|
131
131
|
], i);
|
|
132
132
|
export {
|
|
133
133
|
i as WidgetNavbutton
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget-navbutton.js","sources":["../src/widget-navbutton.ts"],"sourcesContent":["import { html, css, LitElement, PropertyValues } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { InputData } from './definition-schema'\n\nimport '@material/web/icon/icon.js'\nimport '@material/web/button/filled-button.js'\n\ntype Theme = {\n theme_name: string\n theme_object: any\n}\n\n/**\n * ECharts themes describe a *chart canvas*, and most of them set\n * `backgroundColor` to a fully transparent colour (the light theme uses\n * `rgba(0, 0, 0, 0)`). That is a valid, truthy colour string, so using it\n * verbatim as the button background paints nothing at all. Treat any\n * fully transparent theme colour as \"no colour\" so the fallback kicks in.\n */\nconst isTransparent = (color?: string) => {\n if (!color) return true\n const value = color.trim().toLowerCase()\n if (value === 'transparent') return true\n const functional = value.match(/^(?:rgba|hsla)\\([^)]*[,/]\\s*([\\d.]+%?)\\s*\\)$/)\n if (functional) return parseFloat(functional[1]) === 0\n // #rrggbbaa / #rgba\n if (/^#[0-9a-f]{8}$/.test(value)) return value.slice(7) === '00'\n if (/^#[0-9a-f]{4}$/.test(value)) return value[4] === '0'\n return false\n}\n\n@customElement('widget-navbutton-versionplaceholder')\nexport class WidgetNavbutton 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 const themeBgColor = theme?.theme_object?.backgroundColor\n this.themeBgColor = cssBgColor || (isTransparent(themeBgColor) ? undefined : themeBgColor)\n this.themeTitleColor = cssTextColor || theme?.theme_object?.title?.textStyle?.color\n }\n\n handleNavItemClick() {\n let goto: string\n if (this.inputData?.route === '') {\n goto = '/' + this.route?.split('/').filter(Boolean).slice(0, -1).join('/') + '/' || '/'\n goto = goto === '//' ? '/' : goto\n } else {\n goto =\n this.resolveRoute({\n route: this.inputData?.route,\n variables: this.inputData?.variables\n }) || '/'\n }\n const event = new CustomEvent('nav-submit', {\n detail: { path: goto },\n bubbles: true,\n composed: true\n })\n this.dispatchEvent(event)\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 static styles = css`\n :host {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n font-family: sans-serif;\n box-sizing: border-box;\n margin: auto;\n padding: 2cqh 2cqw;\n }\n\n md-icon {\n font-family: 'Material Symbols Outlined';\n }\n md-filled-button {\n flex: 1;\n --md-filled-button-container-shape: 4px;\n --md-filled-button-container-shadow-color: none;\n /* State layers follow the configured label color; a hard-coded\n accent stays teal no matter how the button is styled. */\n --md-ripple-hover-color: var(--btn-fg);\n --md-ripple-pressed-color: var(--btn-fg);\n --md-filled-button-hover-state-layer-color: var(--btn-fg);\n --md-filled-button-pressed-state-layer-color: var(--btn-fg);\n }\n `\n\n render() {\n const fontSize = this.inputData?.style?.fontSize ?? 16\n const iconFontSize = fontSize * 1.5\n const fontColor = this.inputData?.style?.color || this.themeTitleColor || 'black'\n const bgColor = this.inputData?.style?.backgroundColor || this.themeBgColor || 'white'\n // The container height is a fixed 40px token, so it has to grow with the\n // label or larger font sizes overflow the button.\n const buttonHeight = Math.max(40, Math.round(fontSize * 2.5))\n return html`\n <md-filled-button\n style=\"--btn-fg: ${fontColor};\n font-size: ${fontSize}px;\n --md-filled-button-label-text-size: ${fontSize}px;\n --md-filled-button-container-height: ${buttonHeight}px;\n --md-filled-button-icon-size: ${iconFontSize}px;\n --md-filled-button-label-text-color: ${fontColor};\n --md-filled-button-hover-label-text-color: ${fontColor};\n --md-filled-button-pressed-label-text-color: ${fontColor};\n --md-filled-button-focus-label-text-color: ${fontColor};\n --md-filled-button-icon-color: ${fontColor};\n --md-filled-button-hover-icon-color: ${fontColor};\n --md-filled-button-pressed-icon-color: ${fontColor};\n --md-filled-button-focus-icon-color: ${fontColor};\n --md-filled-button-container-color: ${bgColor};\n \"\n @click=${() => this.handleNavItemClick()}\n >\n ${this.inputData?.title}\n <md-icon slot=\"icon\" style=\"--md-icon-size: ${iconFontSize}px;\"\n >${this.inputData?.iconName}</md-icon\n >\n </md-filled-button>\n `\n }\n}\n"],"names":["isTransparent","color","value","functional","WidgetNavbutton","LitElement","changedProperties","_changedProperties","theme","cssTextColor","cssBgColor","themeBgColor","goto","event","item","route","variable","currentSegments","routeSegments","i","fontSize","iconFontSize","fontColor","bgColor","buttonHeight","html","css","__decorateClass","property","state","customElement"],"mappings":";;;;;;;;;AAmBA,MAAMA,IAAgB,CAACC,MAAmB;AACtC,MAAI,CAACA,EAAO,QAAO;AACnB,QAAMC,IAAQD,EAAM,KAAA,EAAO,YAAA;AAC3B,MAAIC,MAAU,cAAe,QAAO;AACpC,QAAMC,IAAaD,EAAM,MAAM,8CAA8C;AAC7E,SAAIC,IAAmB,WAAWA,EAAW,CAAC,CAAC,MAAM,IAEjD,iBAAiB,KAAKD,CAAK,IAAUA,EAAM,MAAM,CAAC,MAAM,OACxD,iBAAiB,KAAKA,CAAK,IAAUA,EAAM,CAAC,MAAM,MAC/C;AACX;AAGO,IAAME,IAAN,cAA8BC,EAAW;AAAA,EAAzC,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,GACnFC,IAAeH,GAAO,cAAc;AAC1C,SAAK,eAAeE,MAAeV,EAAcW,CAAY,IAAI,SAAYA,IAC7E,KAAK,kBAAkBF,KAAgBD,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AA;AACAuB,EAAA;AAAA,EAAhBE,EAAA;AAAM,GANEzB,EAMQ,WAAA,mBAAA,CAAA;AANRA,IAANuB,EAAA;AAAA,EADNG,EAAc,yBAAqC;AAAA,GACvC1B,CAAA;"}
|
|
1
|
+
{"version":3,"file":"widget-navbutton.js","sources":["../src/widget-navbutton.ts"],"sourcesContent":["import { html, css, LitElement, PropertyValues } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { NavigationButtonConfiguration } from './definition-schema'\n\nimport '@material/web/icon/icon.js'\nimport '@material/web/button/filled-button.js'\n\ntype Theme = {\n theme_name: string\n theme_object: any\n}\n\n/**\n * ECharts themes describe a *chart canvas*, and most of them set\n * `backgroundColor` to a fully transparent colour (the light theme uses\n * `rgba(0, 0, 0, 0)`). That is a valid, truthy colour string, so using it\n * verbatim as the button background paints nothing at all. Treat any\n * fully transparent theme colour as \"no colour\" so the fallback kicks in.\n */\nconst isTransparent = (color?: string) => {\n if (!color) return true\n const value = color.trim().toLowerCase()\n if (value === 'transparent') return true\n const functional = value.match(/^(?:rgba|hsla)\\([^)]*[,/]\\s*([\\d.]+%?)\\s*\\)$/)\n if (functional) return parseFloat(functional[1]) === 0\n // #rrggbbaa / #rgba\n if (/^#[0-9a-f]{8}$/.test(value)) return value.slice(7) === '00'\n if (/^#[0-9a-f]{4}$/.test(value)) return value[4] === '0'\n return false\n}\n\n@customElement('widget-navbutton-versionplaceholder')\nexport class WidgetNavbutton extends LitElement {\n @property({ type: Object }) inputData?: NavigationButtonConfiguration\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 themeBgColor = theme?.theme_object?.backgroundColor\n this.themeBgColor = `var(--re-tile-background-color, ${(isTransparent(themeBgColor) ? undefined : themeBgColor) || 'transparent'})`\n this.themeTitleColor = `var(--re-text-color, ${theme?.theme_object?.title?.textStyle?.color || 'inherit'})`\n }\n\n handleNavItemClick() {\n let goto: string\n if (this.inputData?.route === '') {\n goto = '/' + this.route?.split('/').filter(Boolean).slice(0, -1).join('/') + '/' || '/'\n goto = goto === '//' ? '/' : goto\n } else {\n goto =\n this.resolveRoute({\n route: this.inputData?.route,\n variables: this.inputData?.variables\n }) || '/'\n }\n const event = new CustomEvent('nav-submit', {\n detail: { path: goto },\n bubbles: true,\n composed: true\n })\n this.dispatchEvent(event)\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 static styles = css`\n :host {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n font-family: sans-serif;\n box-sizing: border-box;\n margin: auto;\n padding: 2cqh 2cqw;\n }\n\n md-icon {\n font-family: 'Material Symbols Outlined';\n }\n md-filled-button {\n flex: 1;\n --md-filled-button-container-shape: 4px;\n --md-filled-button-container-shadow-color: none;\n /* State layers follow the configured label color; a hard-coded\n accent stays teal no matter how the button is styled. */\n --md-ripple-hover-color: var(--btn-fg);\n --md-ripple-pressed-color: var(--btn-fg);\n --md-filled-button-hover-state-layer-color: var(--btn-fg);\n --md-filled-button-pressed-state-layer-color: var(--btn-fg);\n }\n `\n\n render() {\n const fontSize = this.inputData?.style?.fontSize ?? 16\n const iconFontSize = fontSize * 1.5\n const fontColor = this.inputData?.style?.color || this.themeTitleColor || 'black'\n const bgColor = this.inputData?.style?.backgroundColor || this.themeBgColor || 'white'\n // The container height is a fixed 40px token, so it has to grow with the\n // label or larger font sizes overflow the button.\n const buttonHeight = Math.max(40, Math.round(fontSize * 2.5))\n return html`\n <md-filled-button\n style=\"--btn-fg: ${fontColor};\n font-size: ${fontSize}px;\n --md-filled-button-label-text-size: ${fontSize}px;\n --md-filled-button-container-height: ${buttonHeight}px;\n --md-filled-button-icon-size: ${iconFontSize}px;\n --md-filled-button-label-text-color: ${fontColor};\n --md-filled-button-hover-label-text-color: ${fontColor};\n --md-filled-button-pressed-label-text-color: ${fontColor};\n --md-filled-button-focus-label-text-color: ${fontColor};\n --md-filled-button-icon-color: ${fontColor};\n --md-filled-button-hover-icon-color: ${fontColor};\n --md-filled-button-pressed-icon-color: ${fontColor};\n --md-filled-button-focus-icon-color: ${fontColor};\n --md-filled-button-container-color: ${bgColor};\n \"\n @click=${() => this.handleNavItemClick()}\n >\n ${this.inputData?.title}\n <md-icon slot=\"icon\" style=\"--md-icon-size: ${iconFontSize}px;\"\n >${this.inputData?.iconName}</md-icon\n >\n </md-filled-button>\n `\n }\n}\n"],"names":["isTransparent","color","value","functional","WidgetNavbutton","LitElement","changedProperties","_changedProperties","theme","themeBgColor","goto","event","item","route","variable","currentSegments","routeSegments","i","fontSize","iconFontSize","fontColor","bgColor","buttonHeight","html","css","__decorateClass","property","state","customElement"],"mappings":";;;;;;;;;AAmBA,MAAMA,IAAgB,CAACC,MAAmB;AACtC,MAAI,CAACA,EAAO,QAAO;AACnB,QAAMC,IAAQD,EAAM,KAAA,EAAO,YAAA;AAC3B,MAAIC,MAAU,cAAe,QAAO;AACpC,QAAMC,IAAaD,EAAM,MAAM,8CAA8C;AAC7E,SAAIC,IAAmB,WAAWA,EAAW,CAAC,CAAC,MAAM,IAEjD,iBAAiB,KAAKD,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AAAA;AAAA,EAI3C;AACJ;AAvIaf,EAwEF,SAASoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAvEYC,EAAA;AAAA,EAA3BC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GADjBtB,EACmB,WAAA,aAAA,CAAA;AACAqB,EAAA;AAAA,EAA3BC,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,yBAAqC;AAAA,GACvCxB,CAAA;"}
|
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.12",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=24.9.0",
|
|
9
9
|
"npm": ">=10.0.2"
|
|
@@ -25,7 +25,11 @@
|
|
|
25
25
|
"link": "npm run build && npm link && cd ../RESWARM/frontend && npm link @record-evolution/widget-navbutton",
|
|
26
26
|
"unlink": "npm unlink --global && cd ../RESWARM/frontend && npm unlink @record-evolution/widget-navbutton && npm i @record-evolution/widget-navbutton",
|
|
27
27
|
"types": "cat src/definition-schema.json | json2ts --style.tabWidth=4 > src/definition-schema.d.ts",
|
|
28
|
-
"
|
|
28
|
+
"preversion": "sh scripts/release-preflight.sh",
|
|
29
|
+
"postversion": "git push --follow-tags && sh scripts/release-verify.sh",
|
|
30
|
+
"release": "npm version patch",
|
|
31
|
+
"release:minor": "npm version minor",
|
|
32
|
+
"release:major": "npm version major"
|
|
29
33
|
},
|
|
30
34
|
"dependencies": {
|
|
31
35
|
"lit": "^3.3.3",
|
package/src/default-data.json
CHANGED
|
@@ -41,7 +41,7 @@ export type FontSize = number;
|
|
|
41
41
|
/**
|
|
42
42
|
* A navigation button widget for in-dashboard navigation between pages or sections. Use this widget to create clickable buttons that navigate users to different dashboard views, external pages, or perform back navigation. Supports Material Design icons and customizable styling. Ideal for creating navigation flows, back buttons, call-to-action links, or any clickable element that should route users to another location.
|
|
43
43
|
*/
|
|
44
|
-
export interface
|
|
44
|
+
export interface NavigationButtonConfiguration {
|
|
45
45
|
title?: Label;
|
|
46
46
|
iconName?: IconName;
|
|
47
47
|
route?: Navigation;
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
"title": "
|
|
2
|
+
"title": "Navigation Button Configuration",
|
|
3
3
|
"description": "A navigation button widget for in-dashboard navigation between pages or sections. Use this widget to create clickable buttons that navigate users to different dashboard views, external pages, or perform back navigation. Supports Material Design icons and customizable styling. Ideal for creating navigation flows, back buttons, call-to-action links, or any clickable element that should route users to another location.",
|
|
4
|
+
"aiSelection": {
|
|
5
|
+
"dataShape": "A single destination: a label, an icon and a route, plus optional route variables. No data input.",
|
|
6
|
+
"useWhen": [
|
|
7
|
+
"One clickable element should take the user somewhere — a detail page, an external site, or back.",
|
|
8
|
+
"A call to action belongs next to specific content rather than in a navigation menu."
|
|
9
|
+
],
|
|
10
|
+
"notFor": [
|
|
11
|
+
"Several destinations that belong together as a menu — use widget-navbar or widget-sidenav.",
|
|
12
|
+
"A button that writes or submits data — use widget-form.",
|
|
13
|
+
"A button that commands a device — use widget-switch, or widget-scada for an industrial symbol.",
|
|
14
|
+
"Per-row links inside a list of records — use widget-table with a column of type 'button'."
|
|
15
|
+
]
|
|
16
|
+
},
|
|
4
17
|
"type": "object",
|
|
5
18
|
"properties": {
|
|
6
19
|
"title": {
|
package/src/widget-navbutton.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { html, css, LitElement, PropertyValues } from 'lit'
|
|
2
2
|
import { customElement, property, state } from 'lit/decorators.js'
|
|
3
|
-
import {
|
|
3
|
+
import { NavigationButtonConfiguration } from './definition-schema'
|
|
4
4
|
|
|
5
5
|
import '@material/web/icon/icon.js'
|
|
6
6
|
import '@material/web/button/filled-button.js'
|
|
@@ -31,7 +31,7 @@ const isTransparent = (color?: string) => {
|
|
|
31
31
|
|
|
32
32
|
@customElement('widget-navbutton-versionplaceholder')
|
|
33
33
|
export class WidgetNavbutton extends LitElement {
|
|
34
|
-
@property({ type: Object }) inputData?:
|
|
34
|
+
@property({ type: Object }) inputData?: NavigationButtonConfiguration
|
|
35
35
|
@property({ type: Object }) theme?: Theme
|
|
36
36
|
@property({ type: String }) route?: string
|
|
37
37
|
|
|
@@ -53,11 +53,9 @@ export class WidgetNavbutton extends LitElement {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
registerTheme(theme?: Theme) {
|
|
56
|
-
const cssTextColor = getComputedStyle(this).getPropertyValue('--re-text-color').trim()
|
|
57
|
-
const cssBgColor = getComputedStyle(this).getPropertyValue('--re-tile-background-color').trim()
|
|
58
56
|
const themeBgColor = theme?.theme_object?.backgroundColor
|
|
59
|
-
this.themeBgColor =
|
|
60
|
-
this.themeTitleColor =
|
|
57
|
+
this.themeBgColor = `var(--re-tile-background-color, ${(isTransparent(themeBgColor) ? undefined : themeBgColor) || 'transparent'})`
|
|
58
|
+
this.themeTitleColor = `var(--re-text-color, ${theme?.theme_object?.title?.textStyle?.color || 'inherit'})`
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
handleNavItemClick() {
|