@oicl/openbridge-webcomponents-full-bundle 2.2.0-next.15 → 2.2.0-next.17
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/bundle/openbridge-webcomponents.bundle.js +320 -64
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +1752 -15
- package/dist/automation/analog-threeway-valve/analog-threeway-valve.d.ts +4 -4
- package/dist/automation/analog-threeway-valve/analog-threeway-valve.js.map +1 -1
- package/dist/automation/automation-badge/automation-badge.css_inline.js +6 -0
- package/dist/automation/automation-badge/automation-badge.d.ts +61 -1
- package/dist/automation/automation-badge/automation-badge.d.ts.map +1 -1
- package/dist/automation/automation-badge/automation-badge.js +83 -1
- package/dist/automation/automation-badge/automation-badge.js.map +1 -1
- package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.d.ts +20 -0
- package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.d.ts.map +1 -1
- package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.js +1 -0
- package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.js.map +1 -1
- package/dist/automation/automation-button/abstract-automation-button.d.ts +16 -4
- package/dist/automation/automation-button/abstract-automation-button.d.ts.map +1 -1
- package/dist/automation/automation-button/abstract-automation-button.js +46 -20
- package/dist/automation/automation-button/abstract-automation-button.js.map +1 -1
- package/dist/automation/automation-button/badge-layout.d.ts +34 -0
- package/dist/automation/automation-button/badge-layout.d.ts.map +1 -0
- package/dist/automation/automation-button/badge-layout.js +64 -0
- package/dist/automation/automation-button/badge-layout.js.map +1 -0
- package/dist/automation/automation-tank/automation-tank.d.ts.map +1 -1
- package/dist/automation/automation-tank/automation-tank.js +7 -2
- package/dist/automation/automation-tank/automation-tank.js.map +1 -1
- package/dist/automation/digital-threeway-valve/digital-threeway-valve.d.ts +4 -4
- package/dist/automation/digital-threeway-valve/digital-threeway-valve.js.map +1 -1
- package/dist/automation/electricity-battery/electricity-battery.d.ts +4 -4
- package/dist/automation/electricity-battery/electricity-battery.js.map +1 -1
- package/dist/automation/specialty-tank/abstract-specialty-tank.d.ts.map +1 -1
- package/dist/automation/specialty-tank/abstract-specialty-tank.js +7 -2
- package/dist/automation/specialty-tank/abstract-specialty-tank.js.map +1 -1
- package/dist/internal/global-setting.d.ts +55 -0
- package/dist/internal/global-setting.d.ts.map +1 -0
- package/dist/internal/global-setting.js +86 -0
- package/dist/internal/global-setting.js.map +1 -0
- package/package.json +3 -2
- package/script/check-typography-ramp.ts +144 -0
- package/script/typography/ramp.ts +237 -0
- package/script/typography-ramp.test.ts +267 -0
- package/src/automation/analog-threeway-valve/analog-threeway-valve.ts +4 -4
- package/src/automation/analog-valve/analog-valve.stories.ts +8 -0
- package/src/automation/automation-badge/automation-badge.css +6 -0
- package/src/automation/automation-badge/automation-badge.stories.ts +47 -3
- package/src/automation/automation-badge/automation-badge.ts +124 -1
- package/src/automation/automation-button/abstract-automation-button-storybook-helpers.ts +3 -0
- package/src/automation/automation-button/abstract-automation-button.ts +70 -23
- package/src/automation/automation-button/badge-layout.spec.ts +138 -0
- package/src/automation/automation-button/badge-layout.ts +120 -0
- package/src/automation/automation-tank/automation-tank.ts +11 -6
- package/src/automation/digital-threeway-valve/digital-threeway-valve.ts +4 -4
- package/src/automation/electricity-battery/electricity-battery.ts +4 -4
- package/src/automation/pump/pump.stories.ts +59 -0
- package/src/automation/specialty-tank/abstract-specialty-tank.ts +11 -6
- package/src/internal/global-setting.spec.ts +119 -0
- package/src/internal/global-setting.ts +105 -0
|
@@ -36,10 +36,16 @@ import {AlertType} from '../../types.js';
|
|
|
36
36
|
import '../automation-badge/automation-badge.js';
|
|
37
37
|
import {ObcAutomationBadgeType} from '../automation-badge/automation-badge.js';
|
|
38
38
|
import {CircularProgressMode} from '../../building-blocks/circular-progress/circular-progress.js';
|
|
39
|
+
import {
|
|
40
|
+
AutomationButtonBadgeKind,
|
|
41
|
+
AutomationButtonBadgeLayout,
|
|
42
|
+
BadgeLayoutController,
|
|
43
|
+
} from './badge-layout.js';
|
|
39
44
|
|
|
40
45
|
export enum AutomationButtonBadgeAlert {
|
|
41
46
|
None = 'none',
|
|
42
47
|
Silence = 'silence',
|
|
48
|
+
Shelved = 'shelved',
|
|
43
49
|
Caution = 'caution',
|
|
44
50
|
Warning = 'warning',
|
|
45
51
|
Alarm = 'alarm',
|
|
@@ -54,6 +60,7 @@ export enum AutomationButtonBadgeInterlock {
|
|
|
54
60
|
None = 'none',
|
|
55
61
|
Interlock = 'interlock',
|
|
56
62
|
InterlockInhibit = 'interlock-inhibit',
|
|
63
|
+
Simulation = 'simulation',
|
|
57
64
|
}
|
|
58
65
|
|
|
59
66
|
export enum AutomationButtonBadgeControl {
|
|
@@ -68,15 +75,21 @@ export enum AutomationButtonBadgeControl {
|
|
|
68
75
|
export enum AutomationButtonBadgeCommandLocked {
|
|
69
76
|
None = 'none',
|
|
70
77
|
CommandLocked = 'command-locked',
|
|
78
|
+
Simulation = 'simulation',
|
|
71
79
|
}
|
|
72
80
|
|
|
81
|
+
type BadgeCorner = keyof AutomationButtonBadgeLayout;
|
|
82
|
+
|
|
73
83
|
/**
|
|
74
84
|
* Base class for the automation device buttons.
|
|
75
85
|
*
|
|
76
86
|
* Renders an `<obc-automation-button>` with the shared surface every device
|
|
77
87
|
* button needs: the readout stack and its status row, the alert frame, the
|
|
78
|
-
* circular progress indicator, and the four badge corners
|
|
79
|
-
*
|
|
88
|
+
* circular progress indicator, and the four badge corners with their slots and
|
|
89
|
+
* enum-driven fallbacks. Which badge goes in which corner follows the badge
|
|
90
|
+
* layout (`badge-layout.ts`): control top-left, alert top-right, interlock
|
|
91
|
+
* bottom-left and command-locked bottom-right unless the app or `badgeLayout`
|
|
92
|
+
* moves them.
|
|
80
93
|
*
|
|
81
94
|
* ## Usage Guidelines
|
|
82
95
|
*
|
|
@@ -98,6 +111,7 @@ export enum AutomationButtonBadgeCommandLocked {
|
|
|
98
111
|
* @availableWhen alertFrameMode alert==true
|
|
99
112
|
* @availableWhen showAlertCategoryIcon alert==true && alertFrameType in [SmallSideFlip, LargeSideFlip, BottomFlip, TopFlip]
|
|
100
113
|
* @availableWhen showAlertIcon alert==true && alertFrameType in [LargeSideFlip, BottomFlip, TopFlip]
|
|
114
|
+
* @property badgeLayout - Which badge kind each corner shows, on top of the app-wide layout set with `setAutomationBadgeLayout()`. A corner left out keeps the app-wide badge, `null` leaves it empty, and a badge moved here leaves the corner it came from.
|
|
101
115
|
* @property progress - Shows a progress indicator, used to indicate that an user action is in progress
|
|
102
116
|
* @availableWhen progressMode progress==true
|
|
103
117
|
* @availableWhen progressValue progress==true && progressMode in [determinate, progressiveIndeterminate]
|
|
@@ -141,6 +155,10 @@ export class ObcAbstractAutomationButton extends LitElement {
|
|
|
141
155
|
AutomationButtonBadgeInterlock.None;
|
|
142
156
|
@property({type: String}) badgeAlert: AutomationButtonBadgeAlert =
|
|
143
157
|
AutomationButtonBadgeAlert.None;
|
|
158
|
+
@property({attribute: false}) badgeLayout:
|
|
159
|
+
AutomationButtonBadgeLayout | undefined = undefined;
|
|
160
|
+
|
|
161
|
+
private readonly _badgeLayout = new BadgeLayoutController(this);
|
|
144
162
|
|
|
145
163
|
get icon(): TemplateResult {
|
|
146
164
|
throw new Error('Method "icon" must be implemented in subclass');
|
|
@@ -233,20 +251,19 @@ export class ObcAbstractAutomationButton extends LitElement {
|
|
|
233
251
|
);
|
|
234
252
|
}
|
|
235
253
|
|
|
236
|
-
private getBadgeSpacer(
|
|
254
|
+
private getBadgeSpacer(
|
|
255
|
+
badges: Record<BadgeCorner, ObcAutomationBadgeType | null>
|
|
256
|
+
): boolean {
|
|
237
257
|
if (!this.showReadoutStack) {
|
|
238
258
|
return false;
|
|
239
259
|
}
|
|
240
260
|
|
|
241
|
-
const topLeft =
|
|
242
|
-
|
|
243
|
-
const topRight =
|
|
244
|
-
this.badgeTopRight.length > 0 || this.getBadgeAlertType() !== null;
|
|
261
|
+
const topLeft = this.badgeTopLeft.length > 0 || badges.topLeft !== null;
|
|
262
|
+
const topRight = this.badgeTopRight.length > 0 || badges.topRight !== null;
|
|
245
263
|
const bottomLeft =
|
|
246
|
-
this.badgeBottomLeft.length > 0 ||
|
|
264
|
+
this.badgeBottomLeft.length > 0 || badges.bottomLeft !== null;
|
|
247
265
|
const bottomRight =
|
|
248
|
-
this.badgeBottomRight.length > 0 ||
|
|
249
|
-
this.getBadgeCommandLockedType() !== null;
|
|
266
|
+
this.badgeBottomRight.length > 0 || badges.bottomRight !== null;
|
|
250
267
|
if (this._readoutPosition === AutomationButtonReadoutPosition.top) {
|
|
251
268
|
return topRight || topLeft;
|
|
252
269
|
} else if (
|
|
@@ -267,9 +284,28 @@ export class ObcAbstractAutomationButton extends LitElement {
|
|
|
267
284
|
this.requestUpdate();
|
|
268
285
|
}
|
|
269
286
|
|
|
287
|
+
private getBadgeType(
|
|
288
|
+
kind: AutomationButtonBadgeKind | null
|
|
289
|
+
): ObcAutomationBadgeType | null {
|
|
290
|
+
switch (kind) {
|
|
291
|
+
case AutomationButtonBadgeKind.Control:
|
|
292
|
+
return this.getBadgeControlType();
|
|
293
|
+
case AutomationButtonBadgeKind.Alert:
|
|
294
|
+
return this.getBadgeAlertType();
|
|
295
|
+
case AutomationButtonBadgeKind.Interlock:
|
|
296
|
+
return this.getBadgeInterlockType();
|
|
297
|
+
case AutomationButtonBadgeKind.CommandLocked:
|
|
298
|
+
return this.getBadgeCommandLockedType();
|
|
299
|
+
default:
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
270
304
|
private getBadgeAlertType(): ObcAutomationBadgeType | null {
|
|
271
305
|
if (this.badgeAlert === AutomationButtonBadgeAlert.Silence) {
|
|
272
306
|
return ObcAutomationBadgeType.AlertSilenced;
|
|
307
|
+
} else if (this.badgeAlert === AutomationButtonBadgeAlert.Shelved) {
|
|
308
|
+
return ObcAutomationBadgeType.AlertShelved;
|
|
273
309
|
} else if (this.badgeAlert === AutomationButtonBadgeAlert.Caution) {
|
|
274
310
|
return ObcAutomationBadgeType.Caution;
|
|
275
311
|
} else if (this.badgeAlert === AutomationButtonBadgeAlert.Warning) {
|
|
@@ -312,6 +348,10 @@ export class ObcAbstractAutomationButton extends LitElement {
|
|
|
312
348
|
this.badgeInterlock === AutomationButtonBadgeInterlock.InterlockInhibit
|
|
313
349
|
) {
|
|
314
350
|
return ObcAutomationBadgeType.InterlockInhibit;
|
|
351
|
+
} else if (
|
|
352
|
+
this.badgeInterlock === AutomationButtonBadgeInterlock.Simulation
|
|
353
|
+
) {
|
|
354
|
+
return ObcAutomationBadgeType.Simulation;
|
|
315
355
|
}
|
|
316
356
|
return null;
|
|
317
357
|
}
|
|
@@ -322,16 +362,23 @@ export class ObcAbstractAutomationButton extends LitElement {
|
|
|
322
362
|
AutomationButtonBadgeCommandLocked.CommandLocked
|
|
323
363
|
) {
|
|
324
364
|
return ObcAutomationBadgeType.CommandLocked;
|
|
365
|
+
} else if (
|
|
366
|
+
this.badgeCommandLocked === AutomationButtonBadgeCommandLocked.Simulation
|
|
367
|
+
) {
|
|
368
|
+
return ObcAutomationBadgeType.Simulation;
|
|
325
369
|
}
|
|
326
370
|
return null;
|
|
327
371
|
}
|
|
328
372
|
|
|
329
373
|
override render() {
|
|
330
374
|
const readouts: AutomationButtonReadoutStack[] = [...this.extraReadouts];
|
|
331
|
-
const
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
375
|
+
const layout = this._badgeLayout.resolve(this.badgeLayout);
|
|
376
|
+
const badges = {
|
|
377
|
+
topLeft: this.getBadgeType(layout.topLeft),
|
|
378
|
+
topRight: this.getBadgeType(layout.topRight),
|
|
379
|
+
bottomLeft: this.getBadgeType(layout.bottomLeft),
|
|
380
|
+
bottomRight: this.getBadgeType(layout.bottomRight),
|
|
381
|
+
};
|
|
335
382
|
|
|
336
383
|
return html`<obc-automation-button
|
|
337
384
|
.state=${
|
|
@@ -356,7 +403,7 @@ export class ObcAbstractAutomationButton extends LitElement {
|
|
|
356
403
|
.variant=${this._variant}
|
|
357
404
|
.direction=${this._direction}
|
|
358
405
|
.orientation=${this._orientation}
|
|
359
|
-
.hasBadgeSpacer=${this.getBadgeSpacer()}
|
|
406
|
+
.hasBadgeSpacer=${this.getBadgeSpacer(badges)}
|
|
360
407
|
.handlePosition=${this._handlePosition}
|
|
361
408
|
.static=${this.static}
|
|
362
409
|
.handleSize=${this._handleSize}
|
|
@@ -371,9 +418,9 @@ export class ObcAbstractAutomationButton extends LitElement {
|
|
|
371
418
|
@slotchange=${this.handleBadgeSlotChange}
|
|
372
419
|
>
|
|
373
420
|
${
|
|
374
|
-
|
|
421
|
+
badges.topRight
|
|
375
422
|
? html`<obc-automation-badge
|
|
376
|
-
.type=${
|
|
423
|
+
.type=${badges.topRight}
|
|
377
424
|
></obc-automation-badge>`
|
|
378
425
|
: nothing
|
|
379
426
|
}
|
|
@@ -384,9 +431,9 @@ export class ObcAbstractAutomationButton extends LitElement {
|
|
|
384
431
|
@slotchange=${this.handleBadgeSlotChange}
|
|
385
432
|
>
|
|
386
433
|
${
|
|
387
|
-
|
|
434
|
+
badges.topLeft
|
|
388
435
|
? html`<obc-automation-badge
|
|
389
|
-
.type=${
|
|
436
|
+
.type=${badges.topLeft}
|
|
390
437
|
></obc-automation-badge>`
|
|
391
438
|
: nothing
|
|
392
439
|
}
|
|
@@ -397,9 +444,9 @@ export class ObcAbstractAutomationButton extends LitElement {
|
|
|
397
444
|
@slotchange=${this.handleBadgeSlotChange}
|
|
398
445
|
>
|
|
399
446
|
${
|
|
400
|
-
|
|
447
|
+
badges.bottomLeft
|
|
401
448
|
? html`<obc-automation-badge
|
|
402
|
-
.type=${
|
|
449
|
+
.type=${badges.bottomLeft}
|
|
403
450
|
></obc-automation-badge>`
|
|
404
451
|
: nothing
|
|
405
452
|
}
|
|
@@ -410,9 +457,9 @@ export class ObcAbstractAutomationButton extends LitElement {
|
|
|
410
457
|
@slotchange=${this.handleBadgeSlotChange}
|
|
411
458
|
>
|
|
412
459
|
${
|
|
413
|
-
|
|
460
|
+
badges.bottomRight
|
|
414
461
|
? html`<obc-automation-badge
|
|
415
|
-
.type=${
|
|
462
|
+
.type=${badges.bottomRight}
|
|
416
463
|
></obc-automation-badge>`
|
|
417
464
|
: nothing
|
|
418
465
|
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import {describe, it, expect, afterEach} from 'vitest';
|
|
2
|
+
import '../pump/pump.js';
|
|
3
|
+
import type {ObcPump} from '../pump/pump.js';
|
|
4
|
+
import {
|
|
5
|
+
AutomationButtonBadgeAlert,
|
|
6
|
+
AutomationButtonBadgeCommandLocked,
|
|
7
|
+
AutomationButtonBadgeControl,
|
|
8
|
+
AutomationButtonBadgeInterlock,
|
|
9
|
+
} from './abstract-automation-button.js';
|
|
10
|
+
import {ObcAutomationBadgeType} from '../automation-badge/automation-badge.js';
|
|
11
|
+
import {
|
|
12
|
+
AutomationButtonBadgeKind as Kind,
|
|
13
|
+
defaultAutomationButtonBadgeLayout,
|
|
14
|
+
getAutomationBadgeLayout,
|
|
15
|
+
resolveBadgeLayout,
|
|
16
|
+
setAutomationBadgeLayout,
|
|
17
|
+
} from './badge-layout.js';
|
|
18
|
+
|
|
19
|
+
describe('resolveBadgeLayout', () => {
|
|
20
|
+
const base = defaultAutomationButtonBadgeLayout;
|
|
21
|
+
|
|
22
|
+
it('keeps the base when nothing overrides it', () => {
|
|
23
|
+
expect(resolveBadgeLayout(base, undefined)).toEqual(base);
|
|
24
|
+
expect(resolveBadgeLayout(base, {})).toEqual(base);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('empties a corner set to null', () => {
|
|
28
|
+
expect(resolveBadgeLayout(base, {bottomRight: null})).toEqual({
|
|
29
|
+
...base,
|
|
30
|
+
bottomRight: null,
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('moves a kind out of the corner it came from', () => {
|
|
35
|
+
expect(resolveBadgeLayout(base, {topLeft: Kind.Alert})).toEqual({
|
|
36
|
+
topLeft: Kind.Alert,
|
|
37
|
+
topRight: null,
|
|
38
|
+
bottomLeft: Kind.Interlock,
|
|
39
|
+
bottomRight: Kind.CommandLocked,
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('keeps a kind named twice in the first corner only', () => {
|
|
44
|
+
expect(
|
|
45
|
+
resolveBadgeLayout(base, {topRight: Kind.Alert, bottomLeft: Kind.Alert})
|
|
46
|
+
).toEqual({...base, bottomLeft: null});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('swaps two kinds when both corners are named', () => {
|
|
50
|
+
expect(
|
|
51
|
+
resolveBadgeLayout(base, {topLeft: Kind.Alert, topRight: Kind.Control})
|
|
52
|
+
).toEqual({...base, topLeft: Kind.Alert, topRight: Kind.Control});
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const mounted: HTMLElement[] = [];
|
|
57
|
+
afterEach(() => {
|
|
58
|
+
mounted.splice(0).forEach((el) => el.remove());
|
|
59
|
+
setAutomationBadgeLayout(undefined);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
async function mountPump() {
|
|
63
|
+
const el = document.createElement('obc-pump') as ObcPump;
|
|
64
|
+
el.badgeControl = AutomationButtonBadgeControl.Auto;
|
|
65
|
+
el.badgeAlert = AutomationButtonBadgeAlert.Alarm;
|
|
66
|
+
el.badgeInterlock = AutomationButtonBadgeInterlock.Interlock;
|
|
67
|
+
el.badgeCommandLocked = AutomationButtonBadgeCommandLocked.CommandLocked;
|
|
68
|
+
document.body.appendChild(el);
|
|
69
|
+
mounted.push(el);
|
|
70
|
+
await el.updateComplete;
|
|
71
|
+
return el;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function badgeIn(el: ObcPump, corner: string): string | null {
|
|
75
|
+
const badge = el.shadowRoot!.querySelector(
|
|
76
|
+
`slot[name="${corner}"] obc-automation-badge`
|
|
77
|
+
) as unknown as {type: ObcAutomationBadgeType} | null;
|
|
78
|
+
return badge?.type ?? null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
describe('badge layout on a device', () => {
|
|
82
|
+
it('renders the default layout', async () => {
|
|
83
|
+
const el = await mountPump();
|
|
84
|
+
expect(badgeIn(el, 'badge-top-left')).toBe(ObcAutomationBadgeType.Auto);
|
|
85
|
+
expect(badgeIn(el, 'badge-top-right')).toBe(ObcAutomationBadgeType.Alarm);
|
|
86
|
+
expect(badgeIn(el, 'badge-bottom-left')).toBe(
|
|
87
|
+
ObcAutomationBadgeType.Interlock
|
|
88
|
+
);
|
|
89
|
+
expect(badgeIn(el, 'badge-bottom-right')).toBe(
|
|
90
|
+
ObcAutomationBadgeType.CommandLocked
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('re-renders a connected device when the global layout changes', async () => {
|
|
95
|
+
const el = await mountPump();
|
|
96
|
+
setAutomationBadgeLayout({topLeft: Kind.Alert, topRight: Kind.Control});
|
|
97
|
+
await el.updateComplete;
|
|
98
|
+
expect(badgeIn(el, 'badge-top-left')).toBe(ObcAutomationBadgeType.Alarm);
|
|
99
|
+
expect(badgeIn(el, 'badge-top-right')).toBe(ObcAutomationBadgeType.Auto);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('lets the local layout override corners of the global one', async () => {
|
|
103
|
+
setAutomationBadgeLayout({bottomLeft: Kind.CommandLocked});
|
|
104
|
+
expect(getAutomationBadgeLayout().bottomRight).toBeNull();
|
|
105
|
+
const el = await mountPump();
|
|
106
|
+
el.badgeLayout = {bottomRight: Kind.Interlock};
|
|
107
|
+
await el.updateComplete;
|
|
108
|
+
expect(badgeIn(el, 'badge-bottom-left')).toBe(
|
|
109
|
+
ObcAutomationBadgeType.CommandLocked
|
|
110
|
+
);
|
|
111
|
+
expect(badgeIn(el, 'badge-bottom-right')).toBe(
|
|
112
|
+
ObcAutomationBadgeType.Interlock
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('stops updating a disconnected device', async () => {
|
|
117
|
+
const el = await mountPump();
|
|
118
|
+
el.remove();
|
|
119
|
+
setAutomationBadgeLayout({topLeft: null});
|
|
120
|
+
expect(el.isUpdatePending).toBe(false);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('picks up a layout set while it was detached', async () => {
|
|
124
|
+
const el = await mountPump();
|
|
125
|
+
el.remove();
|
|
126
|
+
setAutomationBadgeLayout({topLeft: null});
|
|
127
|
+
document.body.appendChild(el);
|
|
128
|
+
await el.updateComplete;
|
|
129
|
+
expect(badgeIn(el, 'badge-top-left')).toBeNull();
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('does not re-render on reconnect when nothing changed', async () => {
|
|
133
|
+
const el = await mountPump();
|
|
134
|
+
el.remove();
|
|
135
|
+
document.body.appendChild(el);
|
|
136
|
+
expect(el.isUpdatePending).toBe(false);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Badge layout of the automation buttons.
|
|
3
|
+
*
|
|
4
|
+
* Says which badge kind each corner of an automation button shows. The app
|
|
5
|
+
* sets one layout for every button with `setAutomationBadgeLayout()`; a
|
|
6
|
+
* button's own `badgeLayout` property changes single corners on top of it.
|
|
7
|
+
*
|
|
8
|
+
* Merge rules, for both the global and the local layout:
|
|
9
|
+
* - a corner left out keeps the layout underneath it,
|
|
10
|
+
* - `null` leaves the corner empty,
|
|
11
|
+
* - a kind moved to a new corner leaves the corner it came from, so it is
|
|
12
|
+
* never shown twice.
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* setAutomationBadgeLayout({
|
|
16
|
+
* topLeft: AutomationButtonBadgeKind.Alert,
|
|
17
|
+
* topRight: AutomationButtonBadgeKind.Control,
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @module
|
|
22
|
+
*/
|
|
23
|
+
import type {ReactiveControllerHost} from 'lit';
|
|
24
|
+
import {
|
|
25
|
+
GlobalSetting,
|
|
26
|
+
GlobalSettingController,
|
|
27
|
+
} from '../../internal/global-setting.js';
|
|
28
|
+
|
|
29
|
+
export enum AutomationButtonBadgeKind {
|
|
30
|
+
Control = 'control',
|
|
31
|
+
Alert = 'alert',
|
|
32
|
+
Interlock = 'interlock',
|
|
33
|
+
CommandLocked = 'command-locked',
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Which badge kind each corner shows. `null` leaves the corner empty. */
|
|
37
|
+
export interface AutomationButtonBadgeLayout {
|
|
38
|
+
topLeft?: AutomationButtonBadgeKind | null;
|
|
39
|
+
topRight?: AutomationButtonBadgeKind | null;
|
|
40
|
+
bottomLeft?: AutomationButtonBadgeKind | null;
|
|
41
|
+
bottomRight?: AutomationButtonBadgeKind | null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type ResolvedAutomationButtonBadgeLayout =
|
|
45
|
+
Required<AutomationButtonBadgeLayout>;
|
|
46
|
+
|
|
47
|
+
const corners = ['topLeft', 'topRight', 'bottomLeft', 'bottomRight'] as const;
|
|
48
|
+
|
|
49
|
+
export const defaultAutomationButtonBadgeLayout: Readonly<ResolvedAutomationButtonBadgeLayout> =
|
|
50
|
+
Object.freeze({
|
|
51
|
+
topLeft: AutomationButtonBadgeKind.Control,
|
|
52
|
+
topRight: AutomationButtonBadgeKind.Alert,
|
|
53
|
+
bottomLeft: AutomationButtonBadgeKind.Interlock,
|
|
54
|
+
bottomRight: AutomationButtonBadgeKind.CommandLocked,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The `base` layout with the corners `override` names put on top of it.
|
|
59
|
+
* A kind `override` names twice stays in the first corner, in reading order.
|
|
60
|
+
*/
|
|
61
|
+
export function resolveBadgeLayout(
|
|
62
|
+
base: ResolvedAutomationButtonBadgeLayout,
|
|
63
|
+
override: AutomationButtonBadgeLayout | undefined
|
|
64
|
+
): ResolvedAutomationButtonBadgeLayout {
|
|
65
|
+
const result = {...base};
|
|
66
|
+
if (!override) {
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
const placed = new Set<AutomationButtonBadgeKind>();
|
|
70
|
+
for (const corner of corners) {
|
|
71
|
+
const kind = override[corner];
|
|
72
|
+
if (kind === undefined) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
result[corner] = kind !== null && placed.has(kind) ? null : kind;
|
|
76
|
+
if (kind !== null) {
|
|
77
|
+
placed.add(kind);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
for (const corner of corners) {
|
|
81
|
+
const kind = result[corner];
|
|
82
|
+
if (override[corner] === undefined && kind !== null && placed.has(kind)) {
|
|
83
|
+
result[corner] = null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const globalLayout = new GlobalSetting<ResolvedAutomationButtonBadgeLayout>({
|
|
90
|
+
...defaultAutomationButtonBadgeLayout,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Sets the badge layout of every automation button on the page, and
|
|
95
|
+
* re-renders the ones already connected. `undefined` restores the default.
|
|
96
|
+
*/
|
|
97
|
+
export function setAutomationBadgeLayout(
|
|
98
|
+
layout: AutomationButtonBadgeLayout | undefined
|
|
99
|
+
): void {
|
|
100
|
+
globalLayout.set(
|
|
101
|
+
resolveBadgeLayout(defaultAutomationButtonBadgeLayout, layout)
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function getAutomationBadgeLayout(): ResolvedAutomationButtonBadgeLayout {
|
|
106
|
+
return {...globalLayout.get()};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Re-renders its host when the global badge layout changes, and puts the host's own corners on top of it. */
|
|
110
|
+
export class BadgeLayoutController extends GlobalSettingController<ResolvedAutomationButtonBadgeLayout> {
|
|
111
|
+
constructor(host: ReactiveControllerHost) {
|
|
112
|
+
super(host, globalLayout);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
resolve(
|
|
116
|
+
local: AutomationButtonBadgeLayout | undefined
|
|
117
|
+
): ResolvedAutomationButtonBadgeLayout {
|
|
118
|
+
return resolveBadgeLayout(this.value, local);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -274,6 +274,8 @@ export class ObcAutomationTank extends AdviceMixin(SetpointMixin(LitElement)) {
|
|
|
274
274
|
switch (this.badgeAlert) {
|
|
275
275
|
case AutomationButtonBadgeAlert.Silence:
|
|
276
276
|
return ObcAutomationBadgeType.AlertSilenced;
|
|
277
|
+
case AutomationButtonBadgeAlert.Shelved:
|
|
278
|
+
return ObcAutomationBadgeType.AlertShelved;
|
|
277
279
|
case AutomationButtonBadgeAlert.Caution:
|
|
278
280
|
return ObcAutomationBadgeType.Caution;
|
|
279
281
|
case AutomationButtonBadgeAlert.Warning:
|
|
@@ -318,19 +320,22 @@ export class ObcAutomationTank extends AdviceMixin(SetpointMixin(LitElement)) {
|
|
|
318
320
|
return ObcAutomationBadgeType.Interlock;
|
|
319
321
|
case AutomationButtonBadgeInterlock.InterlockInhibit:
|
|
320
322
|
return ObcAutomationBadgeType.InterlockInhibit;
|
|
323
|
+
case AutomationButtonBadgeInterlock.Simulation:
|
|
324
|
+
return ObcAutomationBadgeType.Simulation;
|
|
321
325
|
default:
|
|
322
326
|
return null;
|
|
323
327
|
}
|
|
324
328
|
}
|
|
325
329
|
|
|
326
330
|
private _badgeCommandLockedType(): ObcAutomationBadgeType | null {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
331
|
+
switch (this.badgeCommandLocked) {
|
|
332
|
+
case AutomationButtonBadgeCommandLocked.CommandLocked:
|
|
333
|
+
return ObcAutomationBadgeType.CommandLocked;
|
|
334
|
+
case AutomationButtonBadgeCommandLocked.Simulation:
|
|
335
|
+
return ObcAutomationBadgeType.Simulation;
|
|
336
|
+
default:
|
|
337
|
+
return null;
|
|
332
338
|
}
|
|
333
|
-
return null;
|
|
334
339
|
}
|
|
335
340
|
|
|
336
341
|
private get _usesGaugeTrend(): boolean {
|
|
@@ -60,10 +60,10 @@ export enum DigitalThreewayValveVariant {
|
|
|
60
60
|
* @property orientation - Side the stem points to.
|
|
61
61
|
* @property flows - Readout rows, one per flow: an optional arrow direction with either a value and optional unit (default `%`) or `open` for an `Open`/`Closed` state.
|
|
62
62
|
* @property variant - Visual style of the button surround.
|
|
63
|
-
* @slot badge-top-right - Content projected into the top-right badge position; overrides `
|
|
64
|
-
* @slot badge-top-left - Content projected into the top-left badge position; overrides `
|
|
65
|
-
* @slot badge-bottom-left - Content projected into the bottom-left badge position; overrides `
|
|
66
|
-
* @slot badge-bottom-right - Content projected into the bottom-right badge position; overrides `
|
|
63
|
+
* @slot badge-top-right - Content projected into the top-right badge position; overrides the badge `badgeLayout` puts in that corner.
|
|
64
|
+
* @slot badge-top-left - Content projected into the top-left badge position; overrides the badge `badgeLayout` puts in that corner.
|
|
65
|
+
* @slot badge-bottom-left - Content projected into the bottom-left badge position; overrides the badge `badgeLayout` puts in that corner.
|
|
66
|
+
* @slot badge-bottom-right - Content projected into the bottom-right badge position; overrides the badge `badgeLayout` puts in that corner.
|
|
67
67
|
* @fires click - Fired when the valve is clicked.
|
|
68
68
|
* @experimental
|
|
69
69
|
*/
|
|
@@ -21,10 +21,10 @@ import {ObcAbstractAutomationButtonSquared} from '../automation-button/abstract-
|
|
|
21
21
|
* Without a visible tag the button is named `Battery`, followed by the state
|
|
22
22
|
* (`Battery On`) when the state row is shown.
|
|
23
23
|
*
|
|
24
|
-
* @slot badge-top-right - Content projected into the top-right badge position; overrides `
|
|
25
|
-
* @slot badge-top-left - Content projected into the top-left badge position; overrides `
|
|
26
|
-
* @slot badge-bottom-left - Content projected into the bottom-left badge position; overrides `
|
|
27
|
-
* @slot badge-bottom-right - Content projected into the bottom-right badge position; overrides `
|
|
24
|
+
* @slot badge-top-right - Content projected into the top-right badge position; overrides the badge `badgeLayout` puts in that corner.
|
|
25
|
+
* @slot badge-top-left - Content projected into the top-left badge position; overrides the badge `badgeLayout` puts in that corner.
|
|
26
|
+
* @slot badge-bottom-left - Content projected into the bottom-left badge position; overrides the badge `badgeLayout` puts in that corner.
|
|
27
|
+
* @slot badge-bottom-right - Content projected into the bottom-right badge position; overrides the badge `badgeLayout` puts in that corner.
|
|
28
28
|
* @fires click - Fired when the battery is clicked.
|
|
29
29
|
* @experimental
|
|
30
30
|
*/
|
|
@@ -10,6 +10,16 @@ import {
|
|
|
10
10
|
} from '../automation-button/automation-button.js';
|
|
11
11
|
import {AutomationButtonReadoutStackSize} from '../../components/automation-button-readout-stack/automation-button-readout-stack.js';
|
|
12
12
|
import {argTypesAbstractAutomationButtonMotorized} from '../automation-button/abstract-automation-button-storybook-helpers.js';
|
|
13
|
+
import {
|
|
14
|
+
AutomationButtonBadgeAlert,
|
|
15
|
+
AutomationButtonBadgeCommandLocked,
|
|
16
|
+
AutomationButtonBadgeControl,
|
|
17
|
+
AutomationButtonBadgeInterlock,
|
|
18
|
+
} from '../automation-button/abstract-automation-button.js';
|
|
19
|
+
import {
|
|
20
|
+
AutomationButtonBadgeKind,
|
|
21
|
+
setAutomationBadgeLayout,
|
|
22
|
+
} from '../automation-button/badge-layout.js';
|
|
13
23
|
|
|
14
24
|
const meta: Meta<typeof ObcPump> = {
|
|
15
25
|
title: 'Automation/Automation Devices/Pump',
|
|
@@ -79,3 +89,52 @@ export const VariantDoubleSizeLarge: Story = {
|
|
|
79
89
|
componentSize: 'obc-component-size-large',
|
|
80
90
|
},
|
|
81
91
|
};
|
|
92
|
+
|
|
93
|
+
const allBadges = {
|
|
94
|
+
turnedOn: true,
|
|
95
|
+
vertical: false,
|
|
96
|
+
direction: AutomationButtonDirection.forward,
|
|
97
|
+
labelDirection: AutomationButtonLabelDirection.left,
|
|
98
|
+
badgeControl: AutomationButtonBadgeControl.Auto,
|
|
99
|
+
badgeAlert: AutomationButtonBadgeAlert.Alarm,
|
|
100
|
+
badgeInterlock: AutomationButtonBadgeInterlock.Interlock,
|
|
101
|
+
badgeCommandLocked: AutomationButtonBadgeCommandLocked.CommandLocked,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const BadgeLayoutLocal: Story = {
|
|
105
|
+
args: {
|
|
106
|
+
...allBadges,
|
|
107
|
+
badgeLayout: {
|
|
108
|
+
topLeft: AutomationButtonBadgeKind.Alert,
|
|
109
|
+
topRight: AutomationButtonBadgeKind.Control,
|
|
110
|
+
bottomRight: null,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
parameters: {
|
|
114
|
+
docs: {
|
|
115
|
+
description: {
|
|
116
|
+
story:
|
|
117
|
+
'Alert and control swap corners on this pump only, and command-locked is hidden.',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const BadgeLayoutGlobal: Story = {
|
|
124
|
+
args: allBadges,
|
|
125
|
+
beforeEach: () => {
|
|
126
|
+
setAutomationBadgeLayout({
|
|
127
|
+
topLeft: AutomationButtonBadgeKind.Interlock,
|
|
128
|
+
bottomLeft: AutomationButtonBadgeKind.Control,
|
|
129
|
+
});
|
|
130
|
+
return () => setAutomationBadgeLayout(undefined);
|
|
131
|
+
},
|
|
132
|
+
parameters: {
|
|
133
|
+
docs: {
|
|
134
|
+
description: {
|
|
135
|
+
story:
|
|
136
|
+
'The app-wide layout from `setAutomationBadgeLayout()` puts interlock top-left and control bottom-left on every device.',
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
};
|
|
@@ -177,6 +177,8 @@ export class ObcAbstractSpecialtyTank extends LitElement {
|
|
|
177
177
|
switch (this.badgeAlert) {
|
|
178
178
|
case AutomationButtonBadgeAlert.Silence:
|
|
179
179
|
return ObcAutomationBadgeType.AlertSilenced;
|
|
180
|
+
case AutomationButtonBadgeAlert.Shelved:
|
|
181
|
+
return ObcAutomationBadgeType.AlertShelved;
|
|
180
182
|
case AutomationButtonBadgeAlert.Caution:
|
|
181
183
|
return ObcAutomationBadgeType.Caution;
|
|
182
184
|
case AutomationButtonBadgeAlert.Warning:
|
|
@@ -204,19 +206,22 @@ export class ObcAbstractSpecialtyTank extends LitElement {
|
|
|
204
206
|
return ObcAutomationBadgeType.Interlock;
|
|
205
207
|
case AutomationButtonBadgeInterlock.InterlockInhibit:
|
|
206
208
|
return ObcAutomationBadgeType.InterlockInhibit;
|
|
209
|
+
case AutomationButtonBadgeInterlock.Simulation:
|
|
210
|
+
return ObcAutomationBadgeType.Simulation;
|
|
207
211
|
default:
|
|
208
212
|
return null;
|
|
209
213
|
}
|
|
210
214
|
}
|
|
211
215
|
|
|
212
216
|
private _badgeCommandLockedType(): ObcAutomationBadgeType | null {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
217
|
+
switch (this.badgeCommandLocked) {
|
|
218
|
+
case AutomationButtonBadgeCommandLocked.CommandLocked:
|
|
219
|
+
return ObcAutomationBadgeType.CommandLocked;
|
|
220
|
+
case AutomationButtonBadgeCommandLocked.Simulation:
|
|
221
|
+
return ObcAutomationBadgeType.Simulation;
|
|
222
|
+
default:
|
|
223
|
+
return null;
|
|
218
224
|
}
|
|
219
|
-
return null;
|
|
220
225
|
}
|
|
221
226
|
|
|
222
227
|
private _slotHasContent(e: Event): boolean {
|