@oicl/openbridge-webcomponents-full-bundle 2.2.0-next.19 → 2.2.0-next.20

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 (29) hide show
  1. package/bundle/openbridge-webcomponents.bundle.js +43 -35
  2. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  3. package/custom-elements.json +108 -7
  4. package/dist/components/button/button.d.ts +8 -0
  5. package/dist/components/button/button.d.ts.map +1 -1
  6. package/dist/components/button/button.js +6 -0
  7. package/dist/components/button/button.js.map +1 -1
  8. package/dist/components/command-menu/command-menu.d.ts +42 -14
  9. package/dist/components/command-menu/command-menu.d.ts.map +1 -1
  10. package/dist/components/command-menu/command-menu.js +25 -6
  11. package/dist/components/command-menu/command-menu.js.map +1 -1
  12. package/dist/components/start-stop-switch/start-stop-switch.css_inline.js +3 -22
  13. package/dist/components/start-stop-switch/start-stop-switch.d.ts +3 -2
  14. package/dist/components/start-stop-switch/start-stop-switch.d.ts.map +1 -1
  15. package/dist/components/start-stop-switch/start-stop-switch.js +9 -7
  16. package/dist/components/start-stop-switch/start-stop-switch.js.map +1 -1
  17. package/docs/MigrationGuide22.mdx +10 -2
  18. package/docs/migration-guide-2-2/renamed-slots.md +7 -0
  19. package/package.json +1 -1
  20. package/src/components/button/button.spec.ts +75 -0
  21. package/src/components/button/button.stories.ts +2 -0
  22. package/src/components/button/button.ts +10 -0
  23. package/src/components/command-menu/command-menu.spec.ts +125 -0
  24. package/src/components/command-menu/command-menu.stories.ts +41 -4
  25. package/src/components/command-menu/command-menu.ts +57 -20
  26. package/src/components/start-stop-switch/start-stop-switch.css +2 -20
  27. package/src/components/start-stop-switch/start-stop-switch.spec.ts +59 -0
  28. package/src/components/start-stop-switch/start-stop-switch.ts +19 -9
  29. package/src/components/tabbed-card/tabbed-card.stories.ts +1 -1
@@ -24,6 +24,8 @@ export type ObcCommandMenuChangeEvent = CustomEvent<{inCommand: boolean}>;
24
24
  * - **Customizable Labels:** All action and state labels for the toggle can be customized via slots.
25
25
  * - **Visual Feedback:** The component visually distinguishes between "in command" and "no command" states, including color and icon changes.
26
26
  * - **Location Support:** Optionally displays the location of the command if `showLocation` is true.
27
+ * - **Action Description:** A caption under the toggle, shown when `hasActionDescription` is true.
28
+ * - **Disabled State:** `disabled` greys out the toggle and stops it from being used, for a menu with nothing to take or release, for example while a request is pending.
27
29
  *
28
30
  * ---
29
31
  *
@@ -41,17 +43,22 @@ export type ObcCommandMenuChangeEvent = CustomEvent<{inCommand: boolean}>;
41
43
  * | `command-status` | Always | Status label (e.g., "Joystick", "NO CMD"). |
42
44
  * | `command-description` | Always | Description of the command state (e.g., "DP", "CMD at DP"). |
43
45
  * | `command-location` | `showLocation` is true | Location label for the command (e.g., "Aft Bridge"). |
44
- * | `toogle-action-to-in-command-label` | Always | Label for the action to take command (toggle to "in command"). |
45
- * | `toogle-action-to-no-command-label` | Always | Label for the action to release command (toggle to "no command").|
46
- * | `toogle-state-in-command-label` | Always | Status label when in "in command" state. |
47
- * | `toogle-state-no-command-label` | Always | Status label when in "no command" state. |
48
- * | `toogle-state-in-command-icon` | Always | Icon for the "in command" state (defaults to `<obi-command-in>`).|
46
+ * | `toggle-action-to-in-command-label` | Always | Label for the action to take command (toggle to "in command"). |
47
+ * | `toggle-action-to-no-command-label` | Always | Label for the action to release command (toggle to "no command").|
48
+ * | `toggle-state-in-command-label` | Always | Status label when in "in command" state. |
49
+ * | `toggle-state-no-command-label` | Always | Status label when in "no command" state. |
50
+ * | `toggle-state-in-command-icon` | Always | Icon for the "in command" state (defaults to `<obi-command-in>`).|
51
+ *
52
+ * The misspelled `toogle-…` names of these five slots are deprecated aliases: each is read only while its `toggle-…` slot is empty, and goes in the next major release (#1370).
49
53
  *
50
54
  * ---
51
55
  *
52
56
  * ### Properties and Attributes
53
57
  * - **`inCommand`** (`boolean`): Whether the menu is in the "in command" state. Controls the toggle and visual state. (Default: `false`)
54
58
  * - **`showLocation`** (`boolean`): Whether to display the location slot. If `false`, the location is omitted. (Default: `true`)
59
+ * - **`disabled`** (`boolean`): Disables the toggle. (Default: `false`)
60
+ * - **`hasActionDescription`** (`boolean`): Shows `actionDescription` under the toggle. (Default: `false`)
61
+ * - **`actionDescription`** (`string`): Caption under the toggle. (Default: `'Action description'`)
55
62
  *
56
63
  * ---
57
64
  *
@@ -76,10 +83,10 @@ export type ObcCommandMenuChangeEvent = CustomEvent<{inCommand: boolean}>;
76
83
  * <div slot="command-status">Joystick</div>
77
84
  * <div slot="command-description">DP</div>
78
85
  * <div slot="command-location">Aft Bridge</div>
79
- * <div slot="toogle-action-to-in-command-label">Take</div>
80
- * <div slot="toogle-action-to-no-command-label">Release</div>
81
- * <div slot="toogle-state-in-command-label">In CMD</div>
82
- * <div slot="toogle-state-no-command-label">DP Aft Bridge</div>
86
+ * <div slot="toggle-action-to-in-command-label">Take</div>
87
+ * <div slot="toggle-action-to-no-command-label">Release</div>
88
+ * <div slot="toggle-state-in-command-label">In CMD</div>
89
+ * <div slot="toggle-state-no-command-label">DP Aft Bridge</div>
83
90
  * </obc-command-menu>
84
91
  * ```
85
92
  *
@@ -90,15 +97,26 @@ export type ObcCommandMenuChangeEvent = CustomEvent<{inCommand: boolean}>;
90
97
  * @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, or from the button event of `obc-top-bar` or `obc-integration-bar`. The user menu's *Soft Dismiss From A Bar Button* story shows that wiring, the brilliance menu's *Soft Dismiss* story the one for a button you hold yourself (`bindPopoverTrigger`), and the vue demo runs its top bar this way. Leave it off to show and hide the menu yourself.
91
98
  * @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`.
92
99
  * @availableWhen open softDismiss==true
100
+ * @property disabled - Disables the toggle, for a menu with nothing to offer: no user signed in, a request
101
+ * already pending, or a user who holds the command and may not release it. The toggle then hides its
102
+ * thumb and shows only the current side's state label.
103
+ * @property hasActionDescription - Shows `actionDescription` as a caption under the toggle.
104
+ * @property actionDescription - Caption under the toggle that says what taking or releasing the command does.
105
+ * @availableWhen actionDescription hasActionDescription==true
93
106
  * @slot command-icon - Main icon representing the current command state.
94
107
  * @slot command-status - Status label (e.g., "Joystick", "NO CMD").
95
108
  * @slot command-description - Description of the command state.
96
109
  * @slot command-location - Location label for the command (shown if `showLocation` is true).
97
- * @slot toogle-action-to-in-command-label - Label for the action to take command.
98
- * @slot toogle-action-to-no-command-label - Label for the action to release command.
99
- * @slot toogle-state-in-command-label - Status label when in "in command" state.
100
- * @slot toogle-state-no-command-label - Status label when in "no command" state.
101
- * @slot toogle-state-in-command-icon - Icon for the "in command" state (defaults to `<obi-command-in>`).
110
+ * @slot toggle-action-to-in-command-label - Label for the action to take command.
111
+ * @slot toggle-action-to-no-command-label - Label for the action to release command.
112
+ * @slot toggle-state-in-command-label - Status label when in "in command" state.
113
+ * @slot toggle-state-no-command-label - Status label when in "no command" state.
114
+ * @slot toggle-state-in-command-icon - Icon for the "in command" state (defaults to `<obi-command-in>`).
115
+ * @slot toogle-action-to-in-command-label - Deprecated: use `toggle-action-to-in-command-label`. Read only while that slot is empty.
116
+ * @slot toogle-action-to-no-command-label - Deprecated: use `toggle-action-to-no-command-label`. Read only while that slot is empty.
117
+ * @slot toogle-state-in-command-label - Deprecated: use `toggle-state-in-command-label`. Read only while that slot is empty.
118
+ * @slot toogle-state-no-command-label - Deprecated: use `toggle-state-no-command-label`. Read only while that slot is empty.
119
+ * @slot toogle-state-in-command-icon - Deprecated: use `toggle-state-in-command-icon`. Read only while that slot is empty.
102
120
  * @fires {CustomEvent<{inCommand: boolean}>} change - Fired when the command state is toggled.
103
121
  * @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.
104
122
  * @beta
@@ -115,6 +133,12 @@ export class ObcCommandMenu extends LitElement {
115
133
 
116
134
  @property({type: Boolean, attribute: false}) showLocation: boolean = true;
117
135
 
136
+ @property({type: Boolean}) disabled = false;
137
+
138
+ @property({type: Boolean}) hasActionDescription = false;
139
+
140
+ @property({type: String}) actionDescription = 'Action description';
141
+
118
142
  override render() {
119
143
  return html`
120
144
  <div
@@ -155,23 +179,36 @@ export class ObcCommandMenu extends LitElement {
155
179
  @change=${this.onChange}
156
180
  .checked=${this.inCommand}
157
181
  .size=${'large'}
182
+ .disabled=${this.disabled}
183
+ .hasDescription=${this.hasActionDescription}
184
+ .description=${this.actionDescription}
158
185
  >
159
186
  <div slot="to-checked-action-label">
160
- <slot name="toogle-action-to-in-command-label"></slot>
187
+ <slot name="toggle-action-to-in-command-label">
188
+ <slot name="toogle-action-to-in-command-label"></slot>
189
+ </slot>
161
190
  </div>
162
191
  <div slot="to-unchecked-action-label">
163
- <slot name="toogle-action-to-no-command-label"></slot>
192
+ <slot name="toggle-action-to-no-command-label">
193
+ <slot name="toogle-action-to-no-command-label"></slot>
194
+ </slot>
164
195
  </div>
165
196
  <div slot="checked-state-label">
166
- <slot name="toogle-state-in-command-label"></slot>
197
+ <slot name="toggle-state-in-command-label">
198
+ <slot name="toogle-state-in-command-label"></slot>
199
+ </slot>
167
200
  </div>
168
201
  <div slot="checked-state-icon">
169
- <slot name="toogle-state-in-command-icon">
170
- <obi-command-in></obi-command-in>
202
+ <slot name="toggle-state-in-command-icon">
203
+ <slot name="toogle-state-in-command-icon">
204
+ <obi-command-in></obi-command-in>
205
+ </slot>
171
206
  </slot>
172
207
  </div>
173
208
  <div slot="unchecked-state-label">
174
- <slot name="toogle-state-no-command-label"></slot>
209
+ <slot name="toggle-state-no-command-label">
210
+ <slot name="toogle-state-no-command-label"></slot>
211
+ </slot>
175
212
  </div>
176
213
  </obc-start-stop-switch>
177
214
  </div>
@@ -138,10 +138,6 @@
138
138
  width: fit-content;
139
139
  justify-content: center;
140
140
  align-items: center;
141
-
142
- padding: 0;
143
- background: transparent;
144
- border: none;
145
141
  min-width: var(--ui-components-start-stop-switch-touch-target-size);
146
142
  cursor: grab;
147
143
 
@@ -150,12 +146,6 @@
150
146
  right 0.1s ease-in-out,
151
147
  width 0.2s ease-in-out;
152
148
 
153
- /* Remove focus styling from button - focus is shown on wrapper instead */
154
- &:focus-visible {
155
- outline: none;
156
- box-shadow: none;
157
- }
158
-
159
149
  /* Prevent any visual changes on active/pressed state */
160
150
  &:active {
161
151
  cursor: grabbing;
@@ -218,17 +208,9 @@
218
208
  border-color: var(--indent-disabled-border-color);
219
209
  }
220
210
 
221
- /* Hide the button visually when disabled, but keep it in DOM for accessibility */
211
+ /* A disabled switch has nothing to drag: the state label stands alone */
222
212
  .wrapper.disabled .button {
223
- position: absolute;
224
- width: 1px;
225
- height: 1px;
226
- padding: 0;
227
- margin: -1px;
228
- overflow: hidden;
229
- clip: rect(0, 0, 0, 0);
230
- white-space: nowrap;
231
- border: 0;
213
+ display: none;
232
214
  }
233
215
 
234
216
  .wrapper.disabled .state {
@@ -96,3 +96,62 @@ describe('obc-start-stop-switch drag under CSS zoom (#1371)', () => {
96
96
  });
97
97
  }
98
98
  });
99
+
100
+ describe('obc-start-stop-switch disabled mid-drag', () => {
101
+ it('ends the drag without a change when disabled before release', async () => {
102
+ const {toggle, thumb, track, changes} = await mount(1, false);
103
+ const x = await press(toggle, thumb);
104
+ await moveTo(toggle, x + track.getBoundingClientRect().width);
105
+
106
+ toggle.disabled = true;
107
+ await toggle.updateComplete;
108
+ await release(toggle);
109
+
110
+ expect(toggle.checked).toBe(false);
111
+ expect(changes).toEqual([]);
112
+ });
113
+ });
114
+
115
+ describe('obc-start-stop-switch semantics', () => {
116
+ async function mountSwitch(props: Partial<ObcStartStopSwitch>) {
117
+ const toggle = document.createElement(
118
+ 'obc-start-stop-switch'
119
+ ) as ObcStartStopSwitch;
120
+ Object.assign(toggle, props);
121
+ document.body.append(toggle);
122
+ cleanup.push(() => toggle.remove());
123
+ await toggle.updateComplete;
124
+ return toggle;
125
+ }
126
+
127
+ function switchRole(toggle: ObcStartStopSwitch) {
128
+ return toggle.shadowRoot!.querySelector<HTMLElement>('[role="switch"]')!;
129
+ }
130
+
131
+ for (const disabled of [false, true]) {
132
+ it(`holds no control inside the switch${disabled ? ' while disabled' : ''}`, async () => {
133
+ const toggle = await mountSwitch({disabled});
134
+
135
+ const inner = switchRole(toggle).querySelectorAll(
136
+ 'button, a[href], input, select, textarea, [tabindex]'
137
+ );
138
+ expect(inner).toHaveLength(0);
139
+ });
140
+ }
141
+
142
+ it('describes the switch with its description', async () => {
143
+ const toggle = await mountSwitch({
144
+ hasDescription: true,
145
+ description: 'Take command',
146
+ });
147
+
148
+ const id = switchRole(toggle).getAttribute('aria-describedby')!;
149
+ expect(toggle.shadowRoot!.getElementById(id)?.textContent?.trim()).toBe(
150
+ 'Take command'
151
+ );
152
+
153
+ toggle.hasDescription = false;
154
+ await toggle.updateComplete;
155
+ expect(switchRole(toggle).hasAttribute('aria-describedby')).toBe(false);
156
+ });
157
+ });
@@ -101,8 +101,9 @@ const DRAG_COMPLETE_THRESHOLD = 0.9;
101
101
  *
102
102
  * ### Keyboard
103
103
  * [APG Switch](https://www.w3.org/WAI/ARIA/apg/patterns/switch/): `Space` and
104
- * `Enter` toggle it. The knob inside is a drag handle for pointers and stays
105
- * out of the tab sequence.
104
+ * `Enter` toggle it. The knob inside is a drag handle for pointers, not a
105
+ * control of its own: a switch announces its content as one name, so nothing
106
+ * inside it may take focus. The description, when shown, describes the switch.
106
107
  *
107
108
  * Left out: nothing.
108
109
  *
@@ -221,10 +222,16 @@ export class ObcStartStopSwitch extends LitElement {
221
222
  const newPosition = startPosition + this.dragOffset;
222
223
  const percent = newPosition / maxOffset;
223
224
 
224
- if (!this.checked && percent > DRAG_COMPLETE_THRESHOLD) {
225
+ // A switch disabled mid-drag ends the drag without a change, as a key press would.
226
+ const canCommit = !this.disabled;
227
+ if (canCommit && !this.checked && percent > DRAG_COMPLETE_THRESHOLD) {
225
228
  this.checked = true;
226
229
  this.dispatchChangeEvent();
227
- } else if (this.checked && percent < 1 - DRAG_COMPLETE_THRESHOLD) {
230
+ } else if (
231
+ canCommit &&
232
+ this.checked &&
233
+ percent < 1 - DRAG_COMPLETE_THRESHOLD
234
+ ) {
228
235
  this.checked = false;
229
236
  this.dispatchChangeEvent();
230
237
  }
@@ -352,18 +359,19 @@ export class ObcStartStopSwitch extends LitElement {
352
359
  aria-checked=${isChecked ? 'true' : 'false'}
353
360
  aria-disabled=${this.disabled ? 'true' : 'false'}
354
361
  aria-label=${ifDefined(forwardedAriaLabel)}
362
+ aria-describedby=${ifDefined(
363
+ this.hasDescription ? 'description' : undefined
364
+ )}
355
365
  @keydown=${this.handleKeydown}
356
366
  >
357
367
  <div class="button-track">
358
- <button
368
+ <div
359
369
  class="button"
360
370
  style=${this.getButtonStyle()}
361
371
  @mousedown=${this.disabled ? undefined : this.onDragStart}
362
372
  @touchstart=${
363
373
  this.disabled ? undefined : this.onDragStart
364
374
  }
365
- ?disabled=${this.disabled}
366
- tabindex="-1"
367
375
  >
368
376
  ${
369
377
  !this.disabled
@@ -386,7 +394,7 @@ export class ObcStartStopSwitch extends LitElement {
386
394
  `
387
395
  : ''
388
396
  }
389
- </button>
397
+ </div>
390
398
  ${
391
399
  !this.disabled
392
400
  ? html`<div class="button-track-checked"></div>`
@@ -409,7 +417,9 @@ export class ObcStartStopSwitch extends LitElement {
409
417
  </div>
410
418
  ${
411
419
  this.hasDescription
412
- ? html`<div class="description">${this.description}</div>`
420
+ ? html`<div class="description" id="description">
421
+ ${this.description}
422
+ </div>`
413
423
  : ''
414
424
  }
415
425
  </div>
@@ -85,7 +85,7 @@ export const DefaultSlotOnly: Story = {
85
85
  <div class="content-box">
86
86
  <h3>Overview Content</h3>
87
87
  <p>
88
- This is the only tab content. The consumer should then toogle
88
+ This is the only tab content. The consumer should then toggle
89
89
  content based on the selected tab.
90
90
  </p>
91
91
  </div>