@oicl/openbridge-webcomponents-full-bundle 2.1.0-next.1 → 2.1.0-next.3
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/.storybook/main.ts +2 -0
- package/bundle/openbridge-webcomponents.bundle.js +390 -301
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +1066 -102
- package/dist/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.d.ts +21 -0
- package/dist/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.d.ts.map +1 -1
- package/dist/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.js +39 -58
- package/dist/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.js.map +1 -1
- package/dist/building-blocks/alert-list/alert-list-base.d.ts +60 -0
- package/dist/building-blocks/alert-list/alert-list-base.d.ts.map +1 -0
- package/dist/building-blocks/alert-list/alert-list-base.js +191 -0
- package/dist/building-blocks/alert-list/alert-list-base.js.map +1 -0
- package/dist/building-blocks/alert-list/alert-list.css.js.map +1 -1
- package/dist/building-blocks/alert-list/alert-list.d.ts +13 -26
- package/dist/building-blocks/alert-list/alert-list.d.ts.map +1 -1
- package/dist/building-blocks/alert-list/alert-list.js +7 -142
- package/dist/building-blocks/alert-list/alert-list.js.map +1 -1
- package/dist/components/alert-icon/alert-icon.d.ts.map +1 -1
- package/dist/components/alert-icon/alert-icon.js +6 -5
- package/dist/components/alert-icon/alert-icon.js.map +1 -1
- package/dist/components/alert-list-details/alert-list-details.css.js +4 -1
- package/dist/components/alert-list-details/alert-list-details.css.js.map +1 -1
- package/dist/components/alert-menu/alert-menu.css.js +3 -42
- package/dist/components/alert-menu/alert-menu.css.js.map +1 -1
- package/dist/components/alert-menu/alert-menu.d.ts +28 -6
- package/dist/components/alert-menu/alert-menu.d.ts.map +1 -1
- package/dist/components/alert-menu/alert-menu.js +81 -60
- package/dist/components/alert-menu/alert-menu.js.map +1 -1
- package/dist/components/alert-menu-item/alert-menu-item.d.ts +16 -6
- package/dist/components/alert-menu-item/alert-menu-item.d.ts.map +1 -1
- package/dist/components/alert-menu-item/alert-menu-item.js +11 -2
- package/dist/components/alert-menu-item/alert-menu-item.js.map +1 -1
- package/dist/components/number-input-field/number-input-field.css.js +8 -2
- package/dist/components/number-input-field/number-input-field.css.js.map +1 -1
- package/dist/components/number-input-field/number-input-field.d.ts +15 -1
- package/dist/components/number-input-field/number-input-field.d.ts.map +1 -1
- package/dist/components/number-input-field/number-input-field.js +38 -44
- package/dist/components/number-input-field/number-input-field.js.map +1 -1
- package/dist/components/textbox/textbox.css.js +3 -9
- package/dist/components/textbox/textbox.css.js.map +1 -1
- package/dist/components/textbox/textbox.d.ts +3 -0
- package/dist/components/textbox/textbox.d.ts.map +1 -1
- package/dist/components/textbox/textbox.js.map +1 -1
- package/dist/generated/locales/es-419.d.ts +1 -1
- package/dist/generated/locales/es-419.js +1 -1
- package/dist/generated/locales/es-419.js.map +1 -1
- package/dist/navigation-instruments/readout-list-item/readout-list-item.css.js +2 -1
- package/dist/navigation-instruments/readout-list-item/readout-list-item.css.js.map +1 -1
- package/dist/pages/alert-detail-page/alert-detail-page.js +1 -1
- package/dist/pages/alert-detail-page/alert-detail-page.js.map +1 -1
- package/dist/pages/alert-list-page-small/alert-list-page-small-base.d.ts +59 -0
- package/dist/pages/alert-list-page-small/alert-list-page-small-base.d.ts.map +1 -0
- package/dist/pages/alert-list-page-small/alert-list-page-small-base.js +126 -0
- package/dist/pages/alert-list-page-small/alert-list-page-small-base.js.map +1 -0
- package/dist/pages/alert-list-page-small/alert-list-page-small.d.ts +12 -15
- package/dist/pages/alert-list-page-small/alert-list-page-small.d.ts.map +1 -1
- package/dist/pages/alert-list-page-small/alert-list-page-small.js +41 -92
- package/dist/pages/alert-list-page-small/alert-list-page-small.js.map +1 -1
- package/docs/GettingStarted.mdx +1 -0
- package/docs/MigrationGuide.mdx +2 -0
- package/package.json +1 -1
- package/src/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.stories.ts +63 -0
- package/src/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.ts +58 -60
- package/src/building-blocks/alert-list/alert-list-base.ts +266 -0
- package/src/building-blocks/alert-list/alert-list.css +1 -23
- package/src/building-blocks/alert-list/alert-list.spec.ts +22 -0
- package/src/building-blocks/alert-list/alert-list.ts +15 -207
- package/src/components/alert-icon/alert-icon.spec.ts +39 -0
- package/src/components/alert-icon/alert-icon.ts +11 -7
- package/src/components/alert-list-details/alert-list-details.css +1 -20
- package/src/components/alert-menu/alert-menu.css +5 -28
- package/src/components/alert-menu/alert-menu.spec.ts +113 -0
- package/src/components/alert-menu/alert-menu.ts +142 -79
- package/src/components/alert-menu-item/alert-menu-item.spec.ts +39 -0
- package/src/components/alert-menu-item/alert-menu-item.stories.ts +22 -0
- package/src/components/alert-menu-item/alert-menu-item.ts +22 -6
- package/src/components/number-input-field/number-input-field.css +8 -2
- package/src/components/number-input-field/number-input-field.spec.ts +260 -2
- package/src/components/number-input-field/number-input-field.stories.ts +74 -0
- package/src/components/number-input-field/number-input-field.ts +45 -74
- package/src/components/textbox/textbox.css +3 -9
- package/src/components/textbox/textbox.stories.ts +24 -0
- package/src/components/textbox/textbox.ts +3 -0
- package/src/generated/locales/es-419.ts +1 -1
- package/src/mixins/alert-list-empty.css +32 -0
- package/src/navigation-instruments/readout-list-item/readout-list-item.css +2 -1
- package/src/pages/alert-detail-page/alert-detail-page.spec.ts +41 -0
- package/src/pages/alert-detail-page/alert-detail-page.ts +1 -1
- package/src/pages/alert-list-page-small/alert-list-page-small-base.ts +152 -0
- package/src/pages/alert-list-page-small/alert-list-page-small.spec.ts +84 -0
- package/src/pages/alert-list-page-small/alert-list-page-small.ts +43 -112
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {PropertyValues} from 'lit';
|
|
2
|
+
import {property} from 'lit/decorators.js';
|
|
3
3
|
import {customElement} from '../../decorator.js';
|
|
4
|
-
import
|
|
5
|
-
import '../../components/scrollbar/scrollbar.js';
|
|
6
|
-
import {ObcScrollbar} from '../../components/scrollbar/scrollbar.js';
|
|
7
|
-
import {ObcAlertMenuItem} from '../../components/alert-menu-item/alert-menu-item.js';
|
|
4
|
+
import {ObcAlertListBase} from './alert-list-base.js';
|
|
8
5
|
|
|
9
6
|
/**
|
|
7
|
+
* `<obc-alert-list>` – Scrolling list of alert items with an empty state.
|
|
8
|
+
*
|
|
9
|
+
* `filter` decides which items count: the empty state shows when none does,
|
|
10
|
+
* and `getVisibleElements()` returns only those. Hiding the other items is
|
|
11
|
+
* left to the consumer's CSS.
|
|
12
|
+
*
|
|
13
|
+
* @property filter - Predicate that picks the items the list counts as shown.
|
|
10
14
|
* @slot - Default slot for the alert list items.
|
|
11
15
|
* @slot empty-icon - Icon shown when the list is empty.
|
|
12
16
|
* @slot empty-title - Title shown when the list is empty.
|
|
@@ -14,213 +18,17 @@ import {ObcAlertMenuItem} from '../../components/alert-menu-item/alert-menu-item
|
|
|
14
18
|
* @stable
|
|
15
19
|
*/
|
|
16
20
|
@customElement('obc-alert-list')
|
|
17
|
-
export class ObcAlertList extends
|
|
21
|
+
export class ObcAlertList extends ObcAlertListBase {
|
|
18
22
|
@property({attribute: false}) filter: (item: HTMLElement) => boolean = () =>
|
|
19
23
|
true;
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
private intersectionObserver: IntersectionObserver | null = null;
|
|
24
|
-
private hasRenderedPanel = false;
|
|
25
|
-
@state() _empty = false;
|
|
26
|
-
|
|
27
|
-
@queryAssignedElements({flatten: true})
|
|
28
|
-
private alertItems!: HTMLElement[];
|
|
29
|
-
|
|
30
|
-
@query('#scrollbar', true)
|
|
31
|
-
private scrollbar!: ObcScrollbar;
|
|
32
|
-
|
|
33
|
-
override firstUpdated() {
|
|
34
|
-
this.updateEmpty();
|
|
35
|
-
this.setupMutationObserver();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
override connectedCallback() {
|
|
39
|
-
super.connectedCallback();
|
|
40
|
-
const intersectionObserver = new IntersectionObserver((entries) => {
|
|
41
|
-
// If intersectionRatio is 0, the target is out of view
|
|
42
|
-
if (entries[0].intersectionRatio === 0) {
|
|
43
|
-
this.hasRenderedPanel = false;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
intersectionObserver.observe(this);
|
|
47
|
-
this.intersectionObserver = intersectionObserver;
|
|
48
|
-
|
|
49
|
-
this.setupMutationObserver();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
override disconnectedCallback() {
|
|
53
|
-
if (this.mutationObserver) {
|
|
54
|
-
this.mutationObserver.disconnect();
|
|
55
|
-
this.mutationObserver = null;
|
|
56
|
-
}
|
|
57
|
-
if (this.intersectionObserver) {
|
|
58
|
-
this.intersectionObserver.disconnect();
|
|
59
|
-
this.intersectionObserver = null;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
protected override willUpdate(_changedProperties: PropertyValues): void {
|
|
64
|
-
if (_changedProperties.has('filter')) {
|
|
65
|
-
this.updateEmpty();
|
|
66
|
-
this.updateOldElementTop();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
private updateEmpty() {
|
|
71
|
-
this._empty = this.getAlertItems().length === 0;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
private getAlertItems() {
|
|
75
|
-
return this.alertItems.filter(this.filter);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private updateOldElementTop() {
|
|
79
|
-
const elements = this.getAlertItems();
|
|
80
|
-
if (elements.length === 0) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Get the top of the element,
|
|
85
|
-
// the element may be in an animation
|
|
86
|
-
// we therefor sum the height of each element
|
|
87
|
-
const firstElement = elements[0];
|
|
88
|
-
const firstElementRect = firstElement.getBoundingClientRect();
|
|
89
|
-
let top = firstElementRect.top;
|
|
90
|
-
this.oldElementTop.clear();
|
|
91
|
-
elements.forEach((element) => {
|
|
92
|
-
const elementRect = element.getBoundingClientRect();
|
|
93
|
-
if (elementRect.height === 0) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
this.oldElementTop.set(element, top);
|
|
97
|
-
top += elementRect.height;
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
private setupMutationObserver() {
|
|
102
|
-
if (this.mutationObserver) {
|
|
103
|
-
// Make a new observer to avoid memory leaks
|
|
104
|
-
this.mutationObserver.disconnect();
|
|
105
|
-
this.mutationObserver = null;
|
|
106
|
-
}
|
|
107
|
-
this.mutationObserver = new MutationObserver(() => {
|
|
108
|
-
this.handleElementsChange();
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
const slotElements = this.alertItems;
|
|
112
|
-
slotElements.forEach((element) => {
|
|
113
|
-
// Earlier observed elements are just updated, and not registered twice.
|
|
114
|
-
this.mutationObserver?.observe(element, {
|
|
115
|
-
attributes: true,
|
|
116
|
-
attributeFilter: ['status', 'shelved'],
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
private handleSlotChange() {
|
|
122
|
-
this.handleElementsChange();
|
|
123
|
-
this.setupMutationObserver();
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
private handleElementsChange() {
|
|
127
|
-
// Take records to ensure the observer is not triggered again
|
|
128
|
-
this.mutationObserver?.takeRecords();
|
|
129
|
-
this.updateEmpty();
|
|
130
|
-
if (!this.checkVisibility()) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const elements = this.getAlertItems();
|
|
135
|
-
// Animate the elements to their new positions
|
|
136
|
-
const oldElementTop: Map<HTMLElement, number> = new Map(this.oldElementTop);
|
|
137
|
-
|
|
138
|
-
requestAnimationFrame(() => {
|
|
139
|
-
this.updateOldElementTop();
|
|
140
|
-
let hasNewElements = false;
|
|
141
|
-
elements.forEach((element) => {
|
|
142
|
-
const elementRect = element.getBoundingClientRect();
|
|
143
|
-
const oldTop = oldElementTop.get(element);
|
|
144
|
-
if (oldTop === undefined) {
|
|
145
|
-
// New element
|
|
146
|
-
(element as ObcAlertMenuItem).animateIntro = this.hasRenderedPanel;
|
|
147
|
-
hasNewElements = true;
|
|
148
|
-
setTimeout(() => {
|
|
149
|
-
(element as ObcAlertMenuItem).animateIntro = false;
|
|
150
|
-
}, 101);
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
const diff = oldTop - elementRect.top;
|
|
154
|
-
if (diff === 0) return;
|
|
155
|
-
element.style.transform = `translateY(${diff}px)`;
|
|
156
|
-
element.style.transition = 'none';
|
|
157
|
-
|
|
158
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- the read forces the reflow that restarts the transition
|
|
159
|
-
element.offsetHeight;
|
|
160
|
-
|
|
161
|
-
// Remove the transition after the animation is complete
|
|
162
|
-
element.style.transition = 'transform 100ms ease-in-out';
|
|
163
|
-
element.style.transform = 'translateY(0px)';
|
|
164
|
-
});
|
|
165
|
-
this.hasRenderedPanel = true;
|
|
166
|
-
if (hasNewElements) {
|
|
167
|
-
setTimeout(() => {
|
|
168
|
-
this.updateOldElementTop();
|
|
169
|
-
}, 101);
|
|
170
|
-
}
|
|
171
|
-
});
|
|
25
|
+
protected override matchesFilter(item: HTMLElement): boolean {
|
|
26
|
+
return this.filter(item);
|
|
172
27
|
}
|
|
173
28
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const scrollbarRect = this.scrollbar.getBoundingClientRect();
|
|
178
|
-
const slottedElements = this.getAlertItems();
|
|
179
|
-
|
|
180
|
-
// Filter for only visible elements that are within the scrollbar viewport
|
|
181
|
-
return slottedElements
|
|
182
|
-
.map((element, index) => ({element, index}))
|
|
183
|
-
.filter(({element}) => {
|
|
184
|
-
const style = window.getComputedStyle(element);
|
|
185
|
-
if (style.display === 'none' || style.visibility === 'hidden') {
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Check if the element is within the scrollbar's viewport
|
|
190
|
-
const elementRect = element.getBoundingClientRect();
|
|
191
|
-
|
|
192
|
-
// Check if element overlaps with scrollbar viewport
|
|
193
|
-
const isVisible = !(
|
|
194
|
-
elementRect.top < scrollbarRect.top ||
|
|
195
|
-
elementRect.bottom > scrollbarRect.bottom
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
return isVisible;
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
override render() {
|
|
203
|
-
return html` <obc-scrollbar class="alert-list" id="scrollbar">
|
|
204
|
-
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
205
|
-
${
|
|
206
|
-
this._empty
|
|
207
|
-
? html` <div class="empty-list">
|
|
208
|
-
<div class="icon">
|
|
209
|
-
<slot name="empty-icon"></slot>
|
|
210
|
-
</div>
|
|
211
|
-
<div class="empty-title">
|
|
212
|
-
<slot name="empty-title"></slot>
|
|
213
|
-
</div>
|
|
214
|
-
<div class="empty-description">
|
|
215
|
-
<slot name="empty-description"></slot>
|
|
216
|
-
</div>
|
|
217
|
-
</div>`
|
|
218
|
-
: nothing
|
|
219
|
-
}
|
|
220
|
-
</obc-scrollbar>`;
|
|
29
|
+
protected override filterChanged(changed: PropertyValues): boolean {
|
|
30
|
+
return changed.has('filter');
|
|
221
31
|
}
|
|
222
|
-
|
|
223
|
-
static override styles = unsafeCSS(compentStyle);
|
|
224
32
|
}
|
|
225
33
|
|
|
226
34
|
declare global {
|
|
@@ -129,3 +129,42 @@ describe('obc-alert-icon flashing lifecycle', () => {
|
|
|
129
129
|
expect(el.getAnimations()).toHaveLength(initial);
|
|
130
130
|
});
|
|
131
131
|
});
|
|
132
|
+
|
|
133
|
+
describe('obc-alert-icon glyphs', () => {
|
|
134
|
+
async function setup(
|
|
135
|
+
props: Partial<
|
|
136
|
+
Pick<ObcAlertIcon, 'alertType' | 'silenced' | 'flashingSpeed'>
|
|
137
|
+
>
|
|
138
|
+
) {
|
|
139
|
+
const screen = render(
|
|
140
|
+
html`<obc-alert-icon
|
|
141
|
+
.alertType=${props.alertType ?? AlertType.Alarm}
|
|
142
|
+
.silenced=${props.silenced}
|
|
143
|
+
.flashingSpeed=${props.flashingSpeed ?? FlashingSpeed.Default}
|
|
144
|
+
></obc-alert-icon>`
|
|
145
|
+
);
|
|
146
|
+
const el = screen.container.querySelector('obc-alert-icon') as ObcAlertIcon;
|
|
147
|
+
await el.updateComplete;
|
|
148
|
+
return el;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** The flashing layer's glyph, or the steady one. */
|
|
152
|
+
const glyph = (el: ObcAlertIcon) =>
|
|
153
|
+
(
|
|
154
|
+
el.shadowRoot!.querySelector('.a > *') ??
|
|
155
|
+
el.shadowRoot!.querySelector('.wrapper > *')
|
|
156
|
+
)?.localName;
|
|
157
|
+
|
|
158
|
+
it('draws a silenced warning with the warning silenced glyph', async () => {
|
|
159
|
+
const el = await setup({alertType: AlertType.Warning, silenced: true});
|
|
160
|
+
expect(glyph(el)).toBe('obi-warning-silenced-iec');
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('draws an unacknowledged alarm held steady by a fixed speed', async () => {
|
|
164
|
+
const el = await setup({flashingSpeed: FlashingSpeed.Fixed});
|
|
165
|
+
expect([durations(el), glyph(el)]).toEqual([
|
|
166
|
+
[],
|
|
167
|
+
'obi-alarm-unacknowledged-iec',
|
|
168
|
+
]);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
@@ -278,12 +278,15 @@ export class ObcAlertIcon extends LitElement {
|
|
|
278
278
|
return null;
|
|
279
279
|
}
|
|
280
280
|
} else if (this.bamType === AlertType.Warning) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
281
|
+
switch (this._effectiveState) {
|
|
282
|
+
case AlertIconState.Rectified:
|
|
283
|
+
return mapping[AlertIconName.WarningRectified];
|
|
284
|
+
case AlertIconState.Silenced:
|
|
285
|
+
return mapping[AlertIconName.WarningSilenced];
|
|
286
|
+
case AlertIconState.Unacknowledged:
|
|
287
|
+
return mapping[AlertIconName.WarningUnack];
|
|
288
|
+
default:
|
|
289
|
+
return null;
|
|
287
290
|
}
|
|
288
291
|
}
|
|
289
292
|
|
|
@@ -339,7 +342,8 @@ export class ObcAlertIcon extends LitElement {
|
|
|
339
342
|
return nothing;
|
|
340
343
|
}
|
|
341
344
|
}
|
|
342
|
-
|
|
345
|
+
// Steady but still owed an ACK, such as with a `fixed` flashing speed.
|
|
346
|
+
return this.icon ? html`${this.icon.a}` : nothing;
|
|
343
347
|
}
|
|
344
348
|
|
|
345
349
|
override render() {
|
|
@@ -43,28 +43,9 @@ obc-table::part(grid) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
.empty-list {
|
|
46
|
-
|
|
47
|
-
flex-direction: column;
|
|
48
|
-
align-items: center;
|
|
49
|
-
justify-content: center;
|
|
50
|
-
height: 100%;
|
|
51
|
-
gap: var(--app-components-alert-menu-button-spacing);
|
|
46
|
+
@mixin alert-list-empty;
|
|
52
47
|
|
|
53
48
|
.icon {
|
|
54
|
-
height: 96px;
|
|
55
|
-
width: 96px;
|
|
56
49
|
color: var(--on-flat-neutral-color);
|
|
57
50
|
}
|
|
58
|
-
|
|
59
|
-
.empty-title {
|
|
60
|
-
color: var(--element-active-color);
|
|
61
|
-
@mixin font-body-active;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.empty-description {
|
|
65
|
-
color: var(--element-neutral-color);
|
|
66
|
-
@mixin font-body;
|
|
67
|
-
max-width: 344px;
|
|
68
|
-
text-align: center;
|
|
69
|
-
}
|
|
70
51
|
}
|
|
@@ -53,38 +53,13 @@
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
.empty-list {
|
|
57
|
-
display: flex;
|
|
58
|
-
flex-direction: column;
|
|
59
|
-
align-items: center;
|
|
60
|
-
justify-content: center;
|
|
61
|
-
height: 100%;
|
|
62
|
-
gap: var(--app-components-alert-menu-button-spacing);
|
|
63
|
-
|
|
64
|
-
.icon {
|
|
65
|
-
height: 96px;
|
|
66
|
-
width: 96px;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.empty-title {
|
|
70
|
-
color: var(--element-active-color);
|
|
71
|
-
@mixin font-body-active;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.empty-description {
|
|
75
|
-
color: var(--element-neutral-color);
|
|
76
|
-
@mixin font-body;
|
|
77
|
-
max-width: 344px;
|
|
78
|
-
text-align: center;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
56
|
::slotted(*) {
|
|
83
57
|
display: block;
|
|
84
58
|
will-change: transform;
|
|
85
59
|
}
|
|
86
60
|
|
|
87
|
-
.alert-list.all ::slotted([shelved])
|
|
61
|
+
.alert-list.all ::slotted([shelved]),
|
|
62
|
+
.alert-list.all ::slotted([status="rectified-unacknowledged"]) {
|
|
88
63
|
display: none;
|
|
89
64
|
}
|
|
90
65
|
|
|
@@ -93,7 +68,9 @@
|
|
|
93
68
|
}
|
|
94
69
|
|
|
95
70
|
.alert-list.unacked {
|
|
96
|
-
::slotted(
|
|
71
|
+
::slotted(
|
|
72
|
+
:not([status="unacknowledged"]):not([status="rectified-unacknowledged"])
|
|
73
|
+
),
|
|
97
74
|
::slotted([shelved]) {
|
|
98
75
|
display: none;
|
|
99
76
|
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {describe, expect, it} from 'vitest';
|
|
2
|
+
import {render} from 'vitest-browser-lit';
|
|
3
|
+
import {html} from 'lit';
|
|
4
|
+
import './alert-menu.js';
|
|
5
|
+
import {ObcAlertMenu, ObcAckAllVisibleClickEvent} from './alert-menu.js';
|
|
6
|
+
import '../alert-menu-item/alert-menu-item.js';
|
|
7
|
+
import {ObcAlertMenuItemStatus} from '../alert-menu-item/alert-menu-item.js';
|
|
8
|
+
import type {ObcTabbedCard} from '../tabbed-card/tabbed-card.js';
|
|
9
|
+
import type {ObcButton} from '../button/button.js';
|
|
10
|
+
|
|
11
|
+
async function setup() {
|
|
12
|
+
const screen = render(
|
|
13
|
+
html`<obc-alert-menu canAckAll>
|
|
14
|
+
<obc-alert-menu-item
|
|
15
|
+
id="active-unacked"
|
|
16
|
+
status=${ObcAlertMenuItemStatus.Unacknowledged}
|
|
17
|
+
></obc-alert-menu-item>
|
|
18
|
+
<obc-alert-menu-item
|
|
19
|
+
id="active-acked"
|
|
20
|
+
status=${ObcAlertMenuItemStatus.Acknowledged}
|
|
21
|
+
></obc-alert-menu-item>
|
|
22
|
+
<obc-alert-menu-item
|
|
23
|
+
id="rectified-unacked"
|
|
24
|
+
status=${ObcAlertMenuItemStatus.RectifiedUnacknowledged}
|
|
25
|
+
></obc-alert-menu-item>
|
|
26
|
+
<obc-alert-menu-item
|
|
27
|
+
id="rectified-acked"
|
|
28
|
+
status=${ObcAlertMenuItemStatus.Rectified}
|
|
29
|
+
></obc-alert-menu-item>
|
|
30
|
+
</obc-alert-menu>`
|
|
31
|
+
);
|
|
32
|
+
const el = screen.container.querySelector('obc-alert-menu') as ObcAlertMenu;
|
|
33
|
+
await el.updateComplete;
|
|
34
|
+
return el;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function clickAckVisible(el: ObcAlertMenu) {
|
|
38
|
+
let detail: ObcAckAllVisibleClickEvent['detail'] | undefined;
|
|
39
|
+
el.addEventListener('ack-all-visible-click', (e) => {
|
|
40
|
+
detail = (e as ObcAckAllVisibleClickEvent).detail;
|
|
41
|
+
});
|
|
42
|
+
const button = el.shadowRoot!.querySelector(
|
|
43
|
+
'[data-testid="ack-all-visible-button"]'
|
|
44
|
+
) as ObcButton;
|
|
45
|
+
button.shadowRoot!.querySelector('button')!.click();
|
|
46
|
+
return {
|
|
47
|
+
tabName: detail?.tabName,
|
|
48
|
+
ids: detail?.visibleElements.map(({element}) => element.id),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
describe('obc-alert-menu', () => {
|
|
53
|
+
it('keeps a rectified-unacknowledged item out of the Active tab', async () => {
|
|
54
|
+
const el = await setup();
|
|
55
|
+
expect(clickAckVisible(el)).toEqual({
|
|
56
|
+
tabName: 'all',
|
|
57
|
+
ids: ['active-unacked', 'active-acked', 'rectified-acked'],
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('falls back to Active, selected and tabbable, when the selected Shelved tab goes', async () => {
|
|
62
|
+
const screen = render(
|
|
63
|
+
html`<obc-alert-menu hasShelved canAckAll>
|
|
64
|
+
<obc-alert-menu-item
|
|
65
|
+
id="active-unacked"
|
|
66
|
+
status=${ObcAlertMenuItemStatus.Unacknowledged}
|
|
67
|
+
></obc-alert-menu-item>
|
|
68
|
+
</obc-alert-menu>`
|
|
69
|
+
);
|
|
70
|
+
const el = screen.container.querySelector('obc-alert-menu') as ObcAlertMenu;
|
|
71
|
+
await el.updateComplete;
|
|
72
|
+
const tabs = el.shadowRoot!.querySelector(
|
|
73
|
+
'obc-tabbed-card'
|
|
74
|
+
) as ObcTabbedCard;
|
|
75
|
+
const headers = () =>
|
|
76
|
+
[...tabs.shadowRoot!.querySelectorAll('[role="tab"]')].map(
|
|
77
|
+
(tab) =>
|
|
78
|
+
`${tab.id} ${tab.getAttribute('aria-selected')} ${tab.getAttribute('tabindex')}`
|
|
79
|
+
);
|
|
80
|
+
(tabs.shadowRoot!.querySelector('#tab-2') as HTMLElement).click();
|
|
81
|
+
await el.updateComplete;
|
|
82
|
+
expect(clickAckVisible(el).tabName).toBe('shelved');
|
|
83
|
+
|
|
84
|
+
el.hasShelved = false;
|
|
85
|
+
await el.updateComplete;
|
|
86
|
+
await tabs.updateComplete;
|
|
87
|
+
expect([clickAckVisible(el).tabName, headers()]).toEqual([
|
|
88
|
+
'all',
|
|
89
|
+
['tab-0 false -1', 'tab-1 true 0'],
|
|
90
|
+
]);
|
|
91
|
+
|
|
92
|
+
el.hasShelved = true;
|
|
93
|
+
await el.updateComplete;
|
|
94
|
+
await tabs.updateComplete;
|
|
95
|
+
expect([clickAckVisible(el).tabName, headers()]).toEqual([
|
|
96
|
+
'all',
|
|
97
|
+
['tab-0 false -1', 'tab-1 true 0', 'tab-2 false -1'],
|
|
98
|
+
]);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('lists a rectified-unacknowledged item in the Unacked tab', async () => {
|
|
102
|
+
const el = await setup();
|
|
103
|
+
const tabs = el.shadowRoot!.querySelector(
|
|
104
|
+
'obc-tabbed-card'
|
|
105
|
+
) as ObcTabbedCard;
|
|
106
|
+
(tabs.shadowRoot!.querySelector('#tab-0') as HTMLElement).click();
|
|
107
|
+
await el.updateComplete;
|
|
108
|
+
expect(clickAckVisible(el)).toEqual({
|
|
109
|
+
tabName: 'unacked',
|
|
110
|
+
ids: ['active-unacked', 'rectified-unacked'],
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
});
|