@openremote/or-mwc-components 1.8.0 → 1.9.0-snapshot.20250826113849
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 +7 -7
- package/build.gradle +0 -36
- package/playwright.config.ts +0 -3
- package/rspack.config.js +0 -7
- package/src/or-mwc-dialog.ts +0 -374
- package/src/or-mwc-drawer.ts +0 -100
- package/src/or-mwc-input.ts +0 -1876
- package/src/or-mwc-list.ts +0 -335
- package/src/or-mwc-menu.ts +0 -279
- package/src/or-mwc-snackbar.ts +0 -157
- package/src/or-mwc-table.ts +0 -712
- package/src/or-mwc-tabs.ts +0 -175
- package/src/style.ts +0 -125
- package/test/or-mwc-input.test.ts +0 -46
- package/tsconfig.json +0 -15
- package/tsconfig.tsbuildinfo +0 -1
package/src/or-mwc-tabs.ts
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { MDCTabBar } from "@material/tab-bar";
|
|
2
|
-
import {css, CSSResult, html, LitElement, TemplateResult, unsafeCSS } from "lit";
|
|
3
|
-
import { customElement, property, state } from "lit/decorators.js";
|
|
4
|
-
import {DefaultColor4, DefaultColor8} from "@openremote/core";
|
|
5
|
-
import {unsafeHTML} from 'lit/directives/unsafe-html.js';
|
|
6
|
-
|
|
7
|
-
// Material Styling import
|
|
8
|
-
const tabStyle = require("@material/tab/dist/mdc.tab.css");
|
|
9
|
-
const tabBarStyle = require("@material/tab-bar/dist/mdc.tab-bar.css");
|
|
10
|
-
const tabIndicatorStyle = require("@material/tab-indicator/dist/mdc.tab-indicator.css");
|
|
11
|
-
const tabScrollerStyle = require("@material/tab-scroller/dist/mdc.tab-scroller.css");
|
|
12
|
-
|
|
13
|
-
export interface OrMwcTabItem {
|
|
14
|
-
name?: string,
|
|
15
|
-
icon?: string,
|
|
16
|
-
content?: TemplateResult | string
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
//language=css
|
|
20
|
-
const tabStyling = css`
|
|
21
|
-
.mdc-tab {
|
|
22
|
-
background: var(--or-app-color4, ${unsafeCSS(DefaultColor4)});
|
|
23
|
-
}
|
|
24
|
-
.mdc-tab .mdc-tab__text-label {
|
|
25
|
-
color: var(--or-app-color8, ${unsafeCSS(DefaultColor8)});
|
|
26
|
-
}
|
|
27
|
-
.mdc-tab .mdc-tab__icon {
|
|
28
|
-
color: var(--or-app-color8, ${unsafeCSS(DefaultColor8)})
|
|
29
|
-
}
|
|
30
|
-
.mdc-tab-indicator .mdc-tab-indicator__content--underline {
|
|
31
|
-
border-color: var(--or-app-color8, ${unsafeCSS(DefaultColor8)})
|
|
32
|
-
}
|
|
33
|
-
.mdc-tab__ripple::before, .mdc-tab__ripple::after {
|
|
34
|
-
background-color: var(--ripplecolor, ${unsafeCSS(DefaultColor8)});
|
|
35
|
-
}
|
|
36
|
-
.mdc-tab-vertical {
|
|
37
|
-
height: 72px !important; /* 72px is original Material spec */
|
|
38
|
-
}
|
|
39
|
-
.mdc-tab-vertical__content {
|
|
40
|
-
flex-direction: column;
|
|
41
|
-
gap: 6px; /* 6px is original Material spec */
|
|
42
|
-
}
|
|
43
|
-
.mdc-tab-vertical__text-label {
|
|
44
|
-
padding-left: 0 !important;
|
|
45
|
-
}
|
|
46
|
-
`
|
|
47
|
-
|
|
48
|
-
/* ----------------- */
|
|
49
|
-
|
|
50
|
-
@customElement("or-mwc-tabs")
|
|
51
|
-
export class OrMwcTabs extends LitElement {
|
|
52
|
-
|
|
53
|
-
static get styles() {
|
|
54
|
-
return [unsafeCSS(tabStyle), unsafeCSS(tabBarStyle), unsafeCSS(tabIndicatorStyle), unsafeCSS(tabScrollerStyle), tabStyling];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
@property({type: Number}) // Selected tab index from the items array
|
|
58
|
-
protected index?: number;
|
|
59
|
-
|
|
60
|
-
@property({type: Array})
|
|
61
|
-
protected items?: OrMwcTabItem[];
|
|
62
|
-
|
|
63
|
-
@property({type: String})
|
|
64
|
-
protected iconPosition?: "left" | "top";
|
|
65
|
-
|
|
66
|
-
@property({type: Boolean})
|
|
67
|
-
protected noScroll?: boolean;
|
|
68
|
-
|
|
69
|
-
@property({type: String})
|
|
70
|
-
protected bgColor?: string;
|
|
71
|
-
|
|
72
|
-
@property({type: String})
|
|
73
|
-
protected color?: string;
|
|
74
|
-
|
|
75
|
-
@property() // Custom styling that gets injected in render()
|
|
76
|
-
protected styles?: CSSResult | string;
|
|
77
|
-
|
|
78
|
-
@state()
|
|
79
|
-
private mdcTabBar: MDCTabBar | undefined;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
constructor() {
|
|
83
|
-
super();
|
|
84
|
-
|
|
85
|
-
// default values
|
|
86
|
-
if (this.index == null) { this.index = 0; }
|
|
87
|
-
if (this.items == null) { this.items = []; }
|
|
88
|
-
if (this.iconPosition == null) { this.iconPosition = "left"; }
|
|
89
|
-
if (this.noScroll == null) { this.noScroll = false; }
|
|
90
|
-
|
|
91
|
-
this.updateComplete.then(() => {
|
|
92
|
-
const tabBarElement = this.shadowRoot?.querySelector('.mdc-tab-bar');
|
|
93
|
-
if(tabBarElement != null) {
|
|
94
|
-
this.mdcTabBar = new MDCTabBar(tabBarElement); // init of material component
|
|
95
|
-
this.mdcTabBar.listen("MDCTabBar:activated", (event: CustomEvent) => {
|
|
96
|
-
this.index = event.detail.index;
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if(tabBarElement != null) {
|
|
101
|
-
|
|
102
|
-
// Adding classes for Icon top position or not.
|
|
103
|
-
if(this.iconPosition === "top") {
|
|
104
|
-
if(this.items?.find((item) => { return (item.name != null && item.icon != null); }) != undefined) {
|
|
105
|
-
tabBarElement.querySelectorAll('.mdc-tab').forEach((value: Element) => { value.classList.add('mdc-tab-vertical'); });
|
|
106
|
-
tabBarElement.querySelectorAll('.mdc-tab__content').forEach((value: Element) => { value.classList.add('mdc-tab-vertical__content')});
|
|
107
|
-
tabBarElement.querySelectorAll('.mdc-tab__text-label').forEach((value: Element) => { value.classList.add('mdc-tab-vertical__text-label')});
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Apply colors if set differently
|
|
112
|
-
if(this.bgColor != null) {
|
|
113
|
-
tabBarElement.querySelectorAll('.mdc-tab').forEach((value: Element) => {
|
|
114
|
-
(value as HTMLElement).style.background = this.bgColor as string;
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
if(this.color != null) {
|
|
118
|
-
tabBarElement.querySelectorAll('.mdc-tab__text-label').forEach((value: Element) => { (value as HTMLElement).style.color = this.color as string; });
|
|
119
|
-
tabBarElement.querySelectorAll('.mdc-tab__icon').forEach((value: Element) => { (value as HTMLElement).style.color = this.color as string; })
|
|
120
|
-
tabBarElement.querySelectorAll('.mdc-tab-indicator__content--underline').forEach((value: Element) => { (value as HTMLElement).style.borderColor = this.color as string; });
|
|
121
|
-
tabBarElement.querySelectorAll('.mdc-tab__ripple').forEach((value: Element) => { (value as HTMLElement).style.setProperty('--ripplecolor', this.color as string); })
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
})
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// If an update happens on either the Index or mdcTabBar object.
|
|
128
|
-
protected updated(changedProperties: Map<string, any>) {
|
|
129
|
-
if(changedProperties.has('index') || changedProperties.has('mdcTabBar')) {
|
|
130
|
-
if(this.mdcTabBar != null && this.index != null) {
|
|
131
|
-
this.mdcTabBar.activateTab(this.index);
|
|
132
|
-
this.dispatchEvent(new CustomEvent("activated", { detail: { index: this.index }}))
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
protected render() {
|
|
139
|
-
let selectedItem: OrMwcTabItem | undefined;
|
|
140
|
-
if(this.items != null && this.index != null) {
|
|
141
|
-
selectedItem = this.items[this.index];
|
|
142
|
-
}
|
|
143
|
-
return html`
|
|
144
|
-
${typeof(this.styles) === "string" ? html`<style>${this.styles}</style>` : this.styles || ``}
|
|
145
|
-
<div>
|
|
146
|
-
<div class="mdc-tab-bar" role="tablist" id="tab-bar">
|
|
147
|
-
<div class="mdc-tab-scroller">
|
|
148
|
-
<div class="mdc-tab-scroller__scroll-area" style="overflow-x: ${this.noScroll ? 'hidden' : undefined}">
|
|
149
|
-
<div class="mdc-tab-scroller__scroll-content">
|
|
150
|
-
${this.items?.map((menuItem => { return html`
|
|
151
|
-
<button class="mdc-tab" role="tab" aria-selected="false" tabindex="${this.items?.indexOf(menuItem)}">
|
|
152
|
-
<span class="mdc-tab__content">
|
|
153
|
-
${menuItem.icon != null ? html`<or-icon icon="${menuItem.icon}" class="mdc-tab__icon"></or-icon>` : null}
|
|
154
|
-
${menuItem.name != null ? html`<span class="mdc-tab__text-label">${menuItem.name}</span>` : null}
|
|
155
|
-
</span>
|
|
156
|
-
<span class="mdc-tab-indicator">
|
|
157
|
-
<span class="mdc-tab-indicator__content mdc-tab-indicator__content--underline"></span>
|
|
158
|
-
</span>
|
|
159
|
-
<span class="mdc-tab__ripple"></span>
|
|
160
|
-
</button>
|
|
161
|
-
`}))}
|
|
162
|
-
</div>
|
|
163
|
-
</div>
|
|
164
|
-
</div>
|
|
165
|
-
</div>
|
|
166
|
-
<div>
|
|
167
|
-
<div>
|
|
168
|
-
<!-- Content of menu Item. Using either unsafeHTML or HTML depending on input type -->
|
|
169
|
-
${(selectedItem != null && selectedItem.content != null) ? (typeof selectedItem.content == "string" ? unsafeHTML(selectedItem.content as string) : html`${selectedItem.content}`) : undefined}
|
|
170
|
-
</div>
|
|
171
|
-
</div>
|
|
172
|
-
</div>
|
|
173
|
-
`
|
|
174
|
-
}
|
|
175
|
-
}
|
package/src/style.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import {css, unsafeCSS} from "lit";
|
|
2
|
-
import {DefaultColor4} from "@openremote/core";
|
|
3
|
-
|
|
4
|
-
// language=CSS
|
|
5
|
-
export const progressCircular = css`
|
|
6
|
-
|
|
7
|
-
/* https://codepen.io/finnhvman/pen/bmNdNr */
|
|
8
|
-
.pure-material-progress-circular {
|
|
9
|
-
-webkit-appearance: none;
|
|
10
|
-
-moz-appearance: none;
|
|
11
|
-
appearance: none;
|
|
12
|
-
box-sizing: border-box;
|
|
13
|
-
border: none;
|
|
14
|
-
border-radius: 50%;
|
|
15
|
-
padding: 0.25em;
|
|
16
|
-
width: 3em;
|
|
17
|
-
height: 3em;
|
|
18
|
-
color: var(--or-app-color4, ${unsafeCSS(DefaultColor4)});
|
|
19
|
-
background-color: transparent;
|
|
20
|
-
font-size: 16px;
|
|
21
|
-
overflow: hidden;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.pure-material-progress-circular::-webkit-progress-bar {
|
|
25
|
-
background-color: transparent;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/* Indeterminate */
|
|
29
|
-
.pure-material-progress-circular:indeterminate {
|
|
30
|
-
-webkit-mask-image: linear-gradient(transparent 50%, black 50%), linear-gradient(to right, transparent 50%, black 50%);
|
|
31
|
-
mask-image: linear-gradient(transparent 50%, black 50%), linear-gradient(to right, transparent 50%, black 50%);
|
|
32
|
-
animation: pure-material-progress-circular 6s infinite cubic-bezier(0.3, 0.6, 1, 1);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
:-ms-lang(x), .pure-material-progress-circular:indeterminate {
|
|
36
|
-
animation: none;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.pure-material-progress-circular:indeterminate::before,
|
|
40
|
-
.pure-material-progress-circular:indeterminate::-webkit-progress-value {
|
|
41
|
-
content: "";
|
|
42
|
-
display: block;
|
|
43
|
-
box-sizing: border-box;
|
|
44
|
-
margin-bottom: 0.25em;
|
|
45
|
-
border: solid 0.25em transparent;
|
|
46
|
-
border-top-color: currentColor;
|
|
47
|
-
border-radius: 50%;
|
|
48
|
-
width: 100% !important;
|
|
49
|
-
height: 100%;
|
|
50
|
-
background-color: transparent;
|
|
51
|
-
animation: pure-material-progress-circular-pseudo 0.75s infinite linear alternate;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.pure-material-progress-circular:indeterminate::-moz-progress-bar {
|
|
55
|
-
box-sizing: border-box;
|
|
56
|
-
border: solid 0.25em transparent;
|
|
57
|
-
border-top-color: currentColor;
|
|
58
|
-
border-radius: 50%;
|
|
59
|
-
width: 100%;
|
|
60
|
-
height: 100%;
|
|
61
|
-
background-color: transparent;
|
|
62
|
-
animation: pure-material-progress-circular-pseudo 0.75s infinite linear alternate;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.pure-material-progress-circular:indeterminate::-ms-fill {
|
|
66
|
-
animation-name: -ms-ring;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
@keyframes pure-material-progress-circular {
|
|
70
|
-
0% {
|
|
71
|
-
transform: rotate(0deg);
|
|
72
|
-
}
|
|
73
|
-
12.5% {
|
|
74
|
-
transform: rotate(180deg);
|
|
75
|
-
animation-timing-function: linear;
|
|
76
|
-
}
|
|
77
|
-
25% {
|
|
78
|
-
transform: rotate(630deg);
|
|
79
|
-
}
|
|
80
|
-
37.5% {
|
|
81
|
-
transform: rotate(810deg);
|
|
82
|
-
animation-timing-function: linear;
|
|
83
|
-
}
|
|
84
|
-
50% {
|
|
85
|
-
transform: rotate(1260deg);
|
|
86
|
-
}
|
|
87
|
-
62.5% {
|
|
88
|
-
transform: rotate(1440deg);
|
|
89
|
-
animation-timing-function: linear;
|
|
90
|
-
}
|
|
91
|
-
75% {
|
|
92
|
-
transform: rotate(1890deg);
|
|
93
|
-
}
|
|
94
|
-
87.5% {
|
|
95
|
-
transform: rotate(2070deg);
|
|
96
|
-
animation-timing-function: linear;
|
|
97
|
-
}
|
|
98
|
-
100% {
|
|
99
|
-
transform: rotate(2520deg);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
@keyframes pure-material-progress-circular-pseudo {
|
|
104
|
-
0% {
|
|
105
|
-
transform: rotate(-30deg);
|
|
106
|
-
}
|
|
107
|
-
29.4% {
|
|
108
|
-
border-left-color: transparent;
|
|
109
|
-
}
|
|
110
|
-
29.41% {
|
|
111
|
-
border-left-color: currentColor;
|
|
112
|
-
}
|
|
113
|
-
64.7% {
|
|
114
|
-
border-bottom-color: transparent;
|
|
115
|
-
}
|
|
116
|
-
64.71% {
|
|
117
|
-
border-bottom-color: currentColor;
|
|
118
|
-
}
|
|
119
|
-
100% {
|
|
120
|
-
border-left-color: currentColor;
|
|
121
|
-
border-bottom-color: currentColor;
|
|
122
|
-
transform: rotate(225deg);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
`;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { ct, expect } from "@openremote/test";
|
|
2
|
-
|
|
3
|
-
import { OrMwcInput, InputType } from "@openremote/or-mwc-components/or-mwc-input";
|
|
4
|
-
|
|
5
|
-
ct("Button should trigger or-mwc-input-changed event", async ({ mount }) => {
|
|
6
|
-
let clicked = false;
|
|
7
|
-
const component = await mount(OrMwcInput, {
|
|
8
|
-
props: {
|
|
9
|
-
type: InputType.BUTTON,
|
|
10
|
-
raised: true,
|
|
11
|
-
label: "button",
|
|
12
|
-
},
|
|
13
|
-
on: {
|
|
14
|
-
"or-mwc-input-changed": () => (clicked = true),
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
expect(clicked).toBeFalsy();
|
|
18
|
-
await component.click();
|
|
19
|
-
expect(clicked).toBeTruthy();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
ct("Switch should switch", async ({ mount }) => {
|
|
23
|
-
const component = await mount(OrMwcInput, {
|
|
24
|
-
props: {
|
|
25
|
-
type: InputType.SWITCH,
|
|
26
|
-
label: "switch",
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
const locator = component.getByRole("switch", { name: "switch" });
|
|
30
|
-
await expect(locator).not.toBeChecked();
|
|
31
|
-
await component.click();
|
|
32
|
-
await expect(locator).toBeChecked();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
ct("Input should have text value", async ({ mount }) => {
|
|
36
|
-
const component = await mount(OrMwcInput, {
|
|
37
|
-
props: {
|
|
38
|
-
type: InputType.TEXT,
|
|
39
|
-
label: "text",
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
const locator = component.getByRole("textbox", { name: "text" });
|
|
43
|
-
await expect(locator).toHaveValue("");
|
|
44
|
-
await locator.fill("input");
|
|
45
|
-
await expect(locator).toHaveValue("input");
|
|
46
|
-
});
|
package/tsconfig.json
DELETED