@oicl/openbridge-webcomponents-full-bundle 2.2.0-next.4 → 2.2.0-next.6

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.
Files changed (77) hide show
  1. package/bundle/openbridge-webcomponents.bundle.js +548 -6
  2. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  3. package/custom-elements.json +543 -7
  4. package/dist/components/alert-button-item/alert-button-item.css.js +65 -1
  5. package/dist/components/alert-button-item/alert-button-item.css.js.map +1 -1
  6. package/dist/components/alert-button-item/alert-button-item.d.ts +14 -1
  7. package/dist/components/alert-button-item/alert-button-item.d.ts.map +1 -1
  8. package/dist/components/alert-button-item/alert-button-item.js +19 -2
  9. package/dist/components/alert-button-item/alert-button-item.js.map +1 -1
  10. package/dist/components/alert-subsystem-button/alert-subsystem-button.css.js +120 -0
  11. package/dist/components/alert-subsystem-button/alert-subsystem-button.css.js.map +1 -0
  12. package/dist/components/alert-subsystem-button/alert-subsystem-button.d.ts +101 -0
  13. package/dist/components/alert-subsystem-button/alert-subsystem-button.d.ts.map +1 -0
  14. package/dist/components/alert-subsystem-button/alert-subsystem-button.js +107 -0
  15. package/dist/components/alert-subsystem-button/alert-subsystem-button.js.map +1 -0
  16. package/dist/components/alert-subsystem-counter/alert-subsystem-counter.css.js +4 -0
  17. package/dist/components/alert-subsystem-counter/alert-subsystem-counter.css.js.map +1 -1
  18. package/dist/components/alert-subsystem-counter/alert-subsystem-counter.d.ts +3 -1
  19. package/dist/components/alert-subsystem-counter/alert-subsystem-counter.d.ts.map +1 -1
  20. package/dist/components/alert-subsystem-counter/alert-subsystem-counter.js +7 -1
  21. package/dist/components/alert-subsystem-counter/alert-subsystem-counter.js.map +1 -1
  22. package/dist/components/diagnostic-button/diagnostic-button.css.js +18 -0
  23. package/dist/components/diagnostic-button/diagnostic-button.css.js.map +1 -0
  24. package/dist/components/diagnostic-button/diagnostic-button.d.ts +71 -0
  25. package/dist/components/diagnostic-button/diagnostic-button.d.ts.map +1 -0
  26. package/dist/components/diagnostic-button/diagnostic-button.js +52 -0
  27. package/dist/components/diagnostic-button/diagnostic-button.js.map +1 -0
  28. package/dist/components/diagnostic-menu/diagnostic-menu.css.js +109 -0
  29. package/dist/components/diagnostic-menu/diagnostic-menu.css.js.map +1 -0
  30. package/dist/components/diagnostic-menu/diagnostic-menu.d.ts +103 -0
  31. package/dist/components/diagnostic-menu/diagnostic-menu.d.ts.map +1 -0
  32. package/dist/components/diagnostic-menu/diagnostic-menu.js +90 -0
  33. package/dist/components/diagnostic-menu/diagnostic-menu.js.map +1 -0
  34. package/dist/components/icon-button/icon-button.js +2 -2
  35. package/dist/components/icon-button/icon-button.js.map +1 -1
  36. package/dist/components/top-bar/top-bar.css.js +6 -0
  37. package/dist/components/top-bar/top-bar.css.js.map +1 -1
  38. package/dist/components/top-bar/top-bar.d.ts +9 -1
  39. package/dist/components/top-bar/top-bar.d.ts.map +1 -1
  40. package/dist/components/top-bar/top-bar.js +2 -0
  41. package/dist/components/top-bar/top-bar.js.map +1 -1
  42. package/dist/generated/locales/es-419.d.ts +6 -0
  43. package/dist/generated/locales/es-419.d.ts.map +1 -1
  44. package/dist/generated/locales/es-419.js +6 -0
  45. package/dist/generated/locales/es-419.js.map +1 -1
  46. package/dist/generated/locales/fi-FI.d.ts +6 -0
  47. package/dist/generated/locales/fi-FI.d.ts.map +1 -1
  48. package/dist/generated/locales/fi-FI.js +6 -0
  49. package/dist/generated/locales/fi-FI.js.map +1 -1
  50. package/package.json +1 -1
  51. package/src/components/alert-button-item/alert-button-item.css +13 -1
  52. package/src/components/alert-button-item/alert-button-item.spec.ts +69 -0
  53. package/src/components/alert-button-item/alert-button-item.stories.ts +13 -0
  54. package/src/components/alert-button-item/alert-button-item.ts +32 -2
  55. package/src/components/alert-subsystem-button/alert-subsystem-button.css +42 -0
  56. package/src/components/alert-subsystem-button/alert-subsystem-button.spec.ts +142 -0
  57. package/src/components/alert-subsystem-button/alert-subsystem-button.stories.ts +69 -0
  58. package/src/components/alert-subsystem-button/alert-subsystem-button.ts +168 -0
  59. package/src/components/alert-subsystem-counter/alert-subsystem-counter.css +4 -0
  60. package/src/components/alert-subsystem-counter/alert-subsystem-counter.ts +10 -2
  61. package/src/components/diagnostic-button/diagnostic-button.css +7 -0
  62. package/src/components/diagnostic-button/diagnostic-button.spec.ts +80 -0
  63. package/src/components/diagnostic-button/diagnostic-button.stories.ts +30 -0
  64. package/src/components/diagnostic-button/diagnostic-button.ts +100 -0
  65. package/src/components/diagnostic-menu/diagnostic-menu.css +69 -0
  66. package/src/components/diagnostic-menu/diagnostic-menu.spec.ts +114 -0
  67. package/src/components/diagnostic-menu/diagnostic-menu.stories.ts +135 -0
  68. package/src/components/diagnostic-menu/diagnostic-menu.ts +171 -0
  69. package/src/components/icon-button/icon-button.stories.ts +51 -1
  70. package/src/components/icon-button/icon-button.ts +2 -2
  71. package/src/components/top-bar/top-bar-asset-picker.spec.ts +54 -0
  72. package/src/components/top-bar/top-bar-diagnostics.spec.ts +59 -0
  73. package/src/components/top-bar/top-bar.css +6 -0
  74. package/src/components/top-bar/top-bar.stories.ts +188 -78
  75. package/src/components/top-bar/top-bar.ts +11 -1
  76. package/src/generated/locales/es-419.ts +6 -0
  77. package/src/generated/locales/fi-FI.ts +6 -0
@@ -0,0 +1,171 @@
1
+ import {LitElement, html, nothing, unsafeCSS} from 'lit';
2
+ import {property, query} from 'lit/decorators.js';
3
+ import {localized, msg} from '@lit/localize';
4
+ import componentStyle from './diagnostic-menu.css?inline';
5
+ import {customElement} from '../../decorator.js';
6
+ import '../button/button.js';
7
+ import '../../icons/icon-chevron-right-google.js';
8
+ import '../alert-frame/diagnostic-badge.js';
9
+ import '../../building-blocks/alert-list/alert-list.js';
10
+ import type {ObcAlertList} from '../../building-blocks/alert-list/alert-list.js';
11
+ import {PopoverController} from '../../internal/popover-controller.js';
12
+
13
+ export type ObcDiagnosticMenuAckAllVisibleClickEvent = CustomEvent<{
14
+ visibleElements: {element: HTMLElement; index: number}[];
15
+ }>;
16
+
17
+ /**
18
+ * `<obc-diagnostic-menu>` – The panel the diagnostic button opens: a titled
19
+ * list of diagnostics with an acknowledge-all and a list button.
20
+ *
21
+ * The diagnostic counterpart of `obc-alert-menu`, without its tabs and its
22
+ * silence button: a title row, the slotted `obc-message-menu-item` rows in a
23
+ * scrolling list with an empty state, and a footer with "ACK all visible" and
24
+ * "Diagnostics list".
25
+ *
26
+ * ---
27
+ *
28
+ * ### Features
29
+ * - **Title row:** `menuTitle`, "Diagnostics" when left empty.
30
+ * - **Rows:** any number of `obc-message-menu-item` children; the list
31
+ * scrolls, slides new rows into place and shows an empty state the
32
+ * `empty-*` slots replace.
33
+ * - **ACK all visible:** enabled by `canAckAll`; fires
34
+ * `ack-all-visible-click` with the rows in view, as the alert menu does.
35
+ * - **Diagnostics list:** `showDiagnosticListButton` shows the button that
36
+ * fires `go-to-diagnostic-list-click` for the full list page.
37
+ * - **Soft dismiss:** `softDismiss` and `open` close the menu on a click
38
+ * outside or `Escape`, as every menu does.
39
+ *
40
+ * ---
41
+ *
42
+ * ### Usage Guidelines
43
+ * - Open it from `obc-diagnostic-button`'s `click` with a flag of your own,
44
+ * bound to `open` and to the button's `activated`, and reset on `close`.
45
+ * - A row is acknowledged through its own `primary-action-click`; the footer
46
+ * button reports every row in view at once.
47
+ * - Position it yourself, under the top bar's diagnostic button.
48
+ * - **TODO(designer):** the design draws an open-in-new glyph after
49
+ * "Diagnostics list" and a 696 px card that hugs its rows; neither the
50
+ * glyph nor a width token is in the library, so the button draws the
51
+ * chevron of the alert menu's "Alerts" button and the card keeps the alert
52
+ * menu's width and height (#1396).
53
+ *
54
+ * ---
55
+ *
56
+ * ### Example
57
+ *
58
+ * ```html
59
+ * <obc-diagnostic-menu canAckAll>
60
+ * <obc-message-menu-item title="Simulate" description="Value is simulated" day="Yesterday" time="09:12:34" primaryActionLabel="Action" hasPrimaryIcon>
61
+ * <obi-placeholder slot="primary-icon"></obi-placeholder>
62
+ * </obc-message-menu-item>
63
+ * </obc-diagnostic-menu>
64
+ * ```
65
+ *
66
+ * @property menuTitle - Title of the menu; "Diagnostics" when left empty.
67
+ * @property canAckAll - Enables the "ACK all visible" button; set it while a row in view can be acknowledged.
68
+ * @availableWhen canAckAll showAckAllButton==true
69
+ * @property showAckAllButton - Shows the "ACK all visible" button in the footer.
70
+ * @property showDiagnosticListButton - Shows the "Diagnostics list" button in the footer.
71
+ * @property softDismiss - Lets the menu close itself on a click outside it, on `Escape`, or when another menu opens. The page is covered while the menu is open, so the closing click reaches nothing there; only the top bar's strip stays clickable, which is how its buttons switch or close menus in one click. Wire it with three bindings: set `softDismiss`, bind `open` to a flag you keep, and reset that flag on `close`. The button that opens the menu needs no wiring of its own: flip the flag from its click. Leave it off to show and hide the menu yourself.
72
+ * @property open - Whether the menu is showing. Bind it to a flag you keep rather than toggling it from the menu's own value: when the menu closes itself, `open` is written back to `false` before the button's click reaches your handler, so `menu.open = !menu.open` gets out of step. Reset the flag on `close`.
73
+ * @availableWhen open softDismiss==true
74
+ * @slot - The diagnostics as `obc-message-menu-item` rows.
75
+ * @slot empty-title - Title of the empty state, "No diagnostics" when left unfilled.
76
+ * @slot empty-description - Description of the empty state.
77
+ * @slot empty-icon - Icon of the empty state, the diagnostic asterisk when left unfilled.
78
+ * @fires {ObcDiagnosticMenuAckAllVisibleClickEvent} ack-all-visible-click - Fired when the "ACK all visible" button is clicked, with the rows in view.
79
+ * @fires {CustomEvent<void>} go-to-diagnostic-list-click - Fired when the "Diagnostics list" button is clicked.
80
+ * @fires {CustomEvent<void>} close - Fired when the menu closed on its own, from a click outside, `Escape`, or another menu opening. `open` is already `false` by the time it arrives; reset the flag you bind to `open` here, or the next click on the button finds it still set and asks a closed menu to close.
81
+ * @experimental
82
+ */
83
+ @customElement('obc-diagnostic-menu')
84
+ @localized()
85
+ export class ObcDiagnosticMenu extends LitElement {
86
+ @property({type: Boolean}) softDismiss = false;
87
+
88
+ @property({type: Boolean}) open = false;
89
+
90
+ protected readonly softDismissController = new PopoverController(this);
91
+
92
+ @property({type: String}) menuTitle = '';
93
+
94
+ @property({type: Boolean}) canAckAll = false;
95
+
96
+ @property({type: Boolean, attribute: false}) showAckAllButton = true;
97
+
98
+ @property({type: Boolean, attribute: false}) showDiagnosticListButton = true;
99
+
100
+ @query('.list') private list!: ObcAlertList;
101
+
102
+ private handleAckAllVisibleClick() {
103
+ this.dispatchEvent(
104
+ new CustomEvent('ack-all-visible-click', {
105
+ detail: {visibleElements: this.list.getVisibleElements()},
106
+ })
107
+ );
108
+ }
109
+
110
+ override render() {
111
+ return html`
112
+ <div class="wrapper" part="wrapper">
113
+ <div class="title-container">
114
+ <h3 class="title">${this.menuTitle || msg('Diagnostics')}</h3>
115
+ </div>
116
+ <obc-alert-list class="list">
117
+ <slot></slot>
118
+ <slot name="empty-title" slot="empty-title"
119
+ >${msg('No diagnostics')}</slot
120
+ >
121
+ <slot name="empty-description" slot="empty-description"
122
+ >${msg("Go to the 'Diagnostics list' for more details.")}</slot
123
+ >
124
+ <slot name="empty-icon" slot="empty-icon"
125
+ ><obi-diagnostic-badge class="empty-badge"></obi-diagnostic-badge
126
+ ></slot>
127
+ </obc-alert-list>
128
+ <div class="action">
129
+ ${
130
+ this.showAckAllButton
131
+ ? html`<obc-button
132
+ variant="normal"
133
+ .disabled=${!this.canAckAll}
134
+ data-testid="ack-all-visible-button"
135
+ @click=${this.handleAckAllVisibleClick}
136
+ >
137
+ ${msg('ACK all visible')}
138
+ </obc-button>`
139
+ : nothing
140
+ }
141
+ ${
142
+ this.showDiagnosticListButton
143
+ ? html`<obc-button
144
+ variant="normal"
145
+ showTrailingIcon
146
+ data-testid="diagnostic-list-button"
147
+ @click=${() =>
148
+ this.dispatchEvent(
149
+ new CustomEvent('go-to-diagnostic-list-click')
150
+ )}
151
+ >
152
+ ${msg('Diagnostics list')}
153
+ <obi-chevron-right-google
154
+ slot="trailing-icon"
155
+ ></obi-chevron-right-google>
156
+ </obc-button>`
157
+ : nothing
158
+ }
159
+ </div>
160
+ </div>
161
+ `;
162
+ }
163
+
164
+ static override styles = unsafeCSS(componentStyle);
165
+ }
166
+
167
+ declare global {
168
+ interface HTMLElementTagNameMap {
169
+ 'obc-diagnostic-menu': ObcDiagnosticMenu;
170
+ }
171
+ }
@@ -1,5 +1,6 @@
1
1
  import type {Meta, StoryObj} from '@storybook/web-components-vite';
2
- import {html} from 'lit-html';
2
+ import {html} from 'lit';
3
+ import {ref} from 'lit/directives/ref.js';
3
4
  import {IconButtonVariant, ObcIconButton} from './icon-button.js';
4
5
  import './icon-button.js';
5
6
  import {iconIds, iconIdToIconHtml} from '../../storybook-util.js';
@@ -160,3 +161,52 @@ export const Progress: Story = {
160
161
  progress: 50,
161
162
  },
162
163
  };
164
+
165
+ const PROGRESS_DURATION_MS = 5000;
166
+
167
+ /**
168
+ * Drives `progress` from 0 to 100 over five seconds, then stops at 100.
169
+ * One run, so nothing on the page keeps moving (WCAG 2.2.2).
170
+ */
171
+ function animateProgress(element: Element | undefined) {
172
+ if (!(element instanceof ObcIconButton)) return;
173
+ const button = element;
174
+ let start: number | undefined;
175
+ const tick = (now: number) => {
176
+ if (!button.isConnected) return;
177
+ start ??= now;
178
+ const elapsed = now - start;
179
+ button.progress = Math.min(
180
+ 100,
181
+ Math.round((elapsed / PROGRESS_DURATION_MS) * 100)
182
+ );
183
+ if (elapsed < PROGRESS_DURATION_MS) requestAnimationFrame(tick);
184
+ };
185
+ requestAnimationFrame(tick);
186
+ }
187
+
188
+ export const ProgressAnimated: Story = {
189
+ tags: ['skip-test'],
190
+ args: {
191
+ variant: IconButtonVariant.flat,
192
+ },
193
+ argTypes: {
194
+ progress: {table: {disable: true}},
195
+ },
196
+ render: (args) => html`
197
+ <obc-icon-button
198
+ ${ref(animateProgress)}
199
+ aria-label=${args.ariaLabel}
200
+ variant=${args.variant}
201
+ ?cornerleft=${args.cornerLeft}
202
+ ?cornerright=${args.cornerRight}
203
+ ?activecolor=${args.activeColor}
204
+ ?activated=${args.activated}
205
+ ?wide=${args.wide}
206
+ ?disabled=${args.disabled}
207
+ .progress=${0}
208
+ >
209
+ ${iconIdToIconHtml(args.icon)}
210
+ </obc-icon-button>
211
+ `,
212
+ };
@@ -158,7 +158,7 @@ export class ObcIconButton extends LitElement {
158
158
  cx="20"
159
159
  cy="20"
160
160
  r="18"
161
- stroke="#325B9A"
161
+ stroke="var(--instrument-enhanced-secondary-color)"
162
162
  stroke-width="4"
163
163
  fill="none"
164
164
  />
@@ -186,7 +186,7 @@ export class ObcIconButton extends LitElement {
186
186
  fill="none"
187
187
  />
188
188
  <path
189
- d="M18 2 A18 18 0 ${largeArcFlag} 1 ${x} ${y}"
189
+ d="M20 2 A18 18 0 ${largeArcFlag} 1 ${x} ${y}"
190
190
  stroke="var(--instrument-enhanced-secondary-color)"
191
191
  stroke-width="4"
192
192
  stroke-linecap="round"
@@ -0,0 +1,54 @@
1
+ import {describe, expect, it} from 'vitest';
2
+ import {render} from 'vitest-browser-lit';
3
+ import {html} from 'lit';
4
+ import '../../main.css';
5
+ import './top-bar.js';
6
+ import type {ObcTopBar} from './top-bar.js';
7
+ import {tabStops} from '../../internal/_test-utils.js';
8
+
9
+ /**
10
+ * The picker is consumer content, so the bar only has to place it: after the
11
+ * page name, before the command button, and not at all in settings mode.
12
+ */
13
+ async function setup(settings = false) {
14
+ const screen = render(
15
+ html`<button id="before">before</button>
16
+ <obc-top-bar appTitle="App" pageName="Page" ?settings=${settings}>
17
+ <button slot="asset-picker" id="picker">Merd B</button>
18
+ <button slot="command-button" id="command">command</button>
19
+ </obc-top-bar>`
20
+ );
21
+ const el = screen.container.querySelector('obc-top-bar') as ObcTopBar;
22
+ await el.updateComplete;
23
+ const slot = el.shadowRoot!.querySelector<HTMLSlotElement>(
24
+ 'slot[name="asset-picker"]'
25
+ );
26
+ return {el, slot};
27
+ }
28
+
29
+ describe('obc-top-bar asset-picker slot', () => {
30
+ it('sits between the page name and the command button', async () => {
31
+ const {slot} = await setup();
32
+
33
+ expect(slot!.assignedElements().map((e) => e.id)).toEqual(['picker']);
34
+ expect(slot!.previousElementSibling!.className).toBe('page-name');
35
+ expect((slot!.nextElementSibling as HTMLSlotElement).name).toBe(
36
+ 'command-button'
37
+ );
38
+ });
39
+
40
+ it('is the tab stop after the menu button', async () => {
41
+ await setup();
42
+ (document.getElementById('before') as HTMLElement).focus();
43
+
44
+ const stops = await tabStops(3);
45
+
46
+ expect(stops.map((e) => e?.id)).toEqual(['', 'picker', 'command']);
47
+ });
48
+
49
+ it('is not rendered in settings mode', async () => {
50
+ const {slot} = await setup(true);
51
+
52
+ expect(slot).toBeNull();
53
+ });
54
+ });
@@ -0,0 +1,59 @@
1
+ import {describe, expect, it} from 'vitest';
2
+ import {render} from 'vitest-browser-lit';
3
+ import {html} from 'lit';
4
+ import '../../main.css';
5
+ import './top-bar.js';
6
+ import type {ObcTopBar} from './top-bar.js';
7
+ import {tabStops} from '../../internal/_test-utils.js';
8
+
9
+ /**
10
+ * The diagnostic button is consumer content, so the bar only has to place
11
+ * it: after the alert area, before the dimming button, in every mode.
12
+ */
13
+ async function setup(attrs: {settings?: boolean; inactive?: boolean} = {}) {
14
+ const screen = render(
15
+ html`<button id="before">before</button>
16
+ <obc-top-bar
17
+ appTitle="App"
18
+ pageName="Page"
19
+ showDimmingButton
20
+ ?settings=${attrs.settings ?? false}
21
+ ?inactive=${attrs.inactive ?? false}
22
+ >
23
+ <button slot="alerts" id="alert">alerts</button>
24
+ <button slot="diagnostics" id="diagnostics">diagnostics</button>
25
+ </obc-top-bar>`
26
+ );
27
+ const el = screen.container.querySelector('obc-top-bar') as ObcTopBar;
28
+ await el.updateComplete;
29
+ const slot = el.shadowRoot!.querySelector<HTMLSlotElement>(
30
+ 'slot[name="diagnostics"]'
31
+ );
32
+ return {el, slot};
33
+ }
34
+
35
+ describe('obc-top-bar diagnostics slot', () => {
36
+ it('sits after the alert area and before the dimming button', async () => {
37
+ const {slot} = await setup();
38
+
39
+ expect(slot!.assignedElements().map((e) => e.id)).toEqual(['diagnostics']);
40
+ expect(slot!.previousElementSibling!.className).toBe('alert-container');
41
+ expect(slot!.nextElementSibling!.classList.contains('dimming-button')).toBe(
42
+ true
43
+ );
44
+ });
45
+
46
+ it('is the tab stop after the alert area', async () => {
47
+ await setup();
48
+ (document.getElementById('alert') as HTMLElement).focus();
49
+
50
+ const stops = await tabStops(1);
51
+
52
+ expect(stops.map((e) => e?.id)).toEqual(['diagnostics']);
53
+ });
54
+
55
+ it('is rendered in settings and inactive modes', async () => {
56
+ expect((await setup({settings: true})).slot).not.toBeNull();
57
+ expect((await setup({inactive: true})).slot).not.toBeNull();
58
+ });
59
+ });
@@ -71,11 +71,17 @@
71
71
  .dimming-button,
72
72
  .user-button,
73
73
  .apps-button,
74
+ ::slotted([slot="asset-picker"]),
74
75
  ::slotted([slot="command-button"]),
76
+ ::slotted([slot="diagnostics"]),
75
77
  ::slotted([slot="clock"]) {
76
78
  flex-shrink: 0;
77
79
  }
78
80
 
81
+ ::slotted([slot="asset-picker"]) {
82
+ margin: 0 var(--app-components-topbar-label-spacing); /* Figma pads the picker 8 px each side; a dropdown button brings no gutter of its own */
83
+ }
84
+
79
85
  .alert-container {
80
86
  display: flex;
81
87
  flex: 1 1 0; /* zero basis: fills what the texts leave, holds its min-content in a squeeze */