@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.136 → 2.0.0-next.138

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 (48) hide show
  1. package/bundle/openbridge-webcomponents.bundle.js +11640 -10983
  2. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  3. package/custom-elements.json +921 -0
  4. package/dist/automation/hydraulic-check-valve/hydraulic-check-valve.css.js +12 -0
  5. package/dist/automation/hydraulic-check-valve/hydraulic-check-valve.css.js.map +1 -0
  6. package/dist/automation/hydraulic-check-valve/hydraulic-check-valve.d.ts +33 -0
  7. package/dist/automation/hydraulic-check-valve/hydraulic-check-valve.d.ts.map +1 -0
  8. package/dist/automation/hydraulic-check-valve/hydraulic-check-valve.js +58 -0
  9. package/dist/automation/hydraulic-check-valve/hydraulic-check-valve.js.map +1 -0
  10. package/dist/automation/hydraulic-valve-4-3/hydraulic-valve-4-3.d.ts +77 -0
  11. package/dist/automation/hydraulic-valve-4-3/hydraulic-valve-4-3.d.ts.map +1 -0
  12. package/dist/automation/hydraulic-valve-4-3/hydraulic-valve-4-3.js +74 -0
  13. package/dist/automation/hydraulic-valve-4-3/hydraulic-valve-4-3.js.map +1 -0
  14. package/dist/automation/hydraulic-valve-x-2/hydraulic-valve-x-2.d.ts +74 -0
  15. package/dist/automation/hydraulic-valve-x-2/hydraulic-valve-x-2.d.ts.map +1 -0
  16. package/dist/automation/hydraulic-valve-x-2/hydraulic-valve-x-2.js +60 -0
  17. package/dist/automation/hydraulic-valve-x-2/hydraulic-valve-x-2.js.map +1 -0
  18. package/dist/automation/shuffle-button/shuffle-button-base.d.ts +67 -0
  19. package/dist/automation/shuffle-button/shuffle-button-base.d.ts.map +1 -0
  20. package/dist/automation/shuffle-button/shuffle-button-base.js +126 -0
  21. package/dist/automation/shuffle-button/shuffle-button-base.js.map +1 -0
  22. package/dist/automation/shuffle-button/shuffle-button.css.js +219 -0
  23. package/dist/automation/shuffle-button/shuffle-button.css.js.map +1 -0
  24. package/dist/automation/shuffle-button/shuffle-layout.d.ts +9 -0
  25. package/dist/automation/shuffle-button/shuffle-layout.d.ts.map +1 -0
  26. package/dist/automation/shuffle-button/shuffle-layout.js +16 -0
  27. package/dist/automation/shuffle-button/shuffle-layout.js.map +1 -0
  28. package/dist/components/alert-subsystem-counter/alert-subsystem-counter.css.js +113 -0
  29. package/dist/components/alert-subsystem-counter/alert-subsystem-counter.css.js.map +1 -0
  30. package/dist/components/alert-subsystem-counter/alert-subsystem-counter.d.ts +104 -0
  31. package/dist/components/alert-subsystem-counter/alert-subsystem-counter.d.ts.map +1 -0
  32. package/dist/components/alert-subsystem-counter/alert-subsystem-counter.js +79 -0
  33. package/dist/components/alert-subsystem-counter/alert-subsystem-counter.js.map +1 -0
  34. package/package.json +1 -1
  35. package/src/automation/hydraulic-check-valve/hydraulic-check-valve.css +3 -0
  36. package/src/automation/hydraulic-check-valve/hydraulic-check-valve.stories.ts +18 -0
  37. package/src/automation/hydraulic-check-valve/hydraulic-check-valve.ts +60 -0
  38. package/src/automation/hydraulic-valve-4-3/hydraulic-valve-4-3.stories.ts +72 -0
  39. package/src/automation/hydraulic-valve-4-3/hydraulic-valve-4-3.ts +108 -0
  40. package/src/automation/hydraulic-valve-x-2/hydraulic-valve-x-2.stories.ts +60 -0
  41. package/src/automation/hydraulic-valve-x-2/hydraulic-valve-x-2.ts +101 -0
  42. package/src/automation/shuffle-button/shuffle-button-base.ts +170 -0
  43. package/src/automation/shuffle-button/shuffle-button.css +136 -0
  44. package/src/automation/shuffle-button/shuffle-layout.spec.ts +44 -0
  45. package/src/automation/shuffle-button/shuffle-layout.ts +21 -0
  46. package/src/components/alert-subsystem-counter/alert-subsystem-counter.css +82 -0
  47. package/src/components/alert-subsystem-counter/alert-subsystem-counter.stories.ts +308 -0
  48. package/src/components/alert-subsystem-counter/alert-subsystem-counter.ts +137 -0
@@ -0,0 +1,60 @@
1
+ import {LitElement, html, unsafeCSS} from 'lit';
2
+ import {property} from 'lit/decorators.js';
3
+ import {classMap} from 'lit/directives/class-map.js';
4
+ import {customElement} from '../../decorator.js';
5
+ import sharedStyle from '../shuffle-button/shuffle-button.css?inline';
6
+ import componentStyle from './hydraulic-check-valve.css?inline';
7
+ import '../../icons/icon-hydraulic-13.js';
8
+
9
+ /**
10
+ * `<obc-hydraulic-check-valve>` – Static check valve symbol.
11
+ *
12
+ * Renders the check valve symbol in the same thumb-on-track visual style as
13
+ * the position-selector valve components, sized to a single slot (48px at
14
+ * regular size). A check valve has no selectable positions, so the component
15
+ * is display-only and not focusable.
16
+ *
17
+ * ## Usage Guidelines
18
+ * Use alongside `<obc-hydraulic-valve-4-3>` and `<obc-hydraulic-valve-x-2>`
19
+ * for consistent styling of valves without switchable positions.
20
+ *
21
+ * @experimental
22
+ *
23
+ * @property ariaLabel - Accessible name for the symbol.
24
+ * @property vertical - Rotates the symbol 90° counter-clockwise to match a vertical flow path.
25
+ */
26
+ @customElement('obc-hydraulic-check-valve')
27
+ export class ObcHydraulicCheckValve extends LitElement {
28
+ @property({type: String}) override ariaLabel = 'Check valve';
29
+
30
+ @property({type: Boolean}) vertical = false;
31
+
32
+ override render() {
33
+ return html`
34
+ <div
35
+ class=${classMap({shuffle: true, vertical: this.vertical})}
36
+ role="img"
37
+ aria-label=${this.ariaLabel}
38
+ >
39
+ <div class="window">
40
+ <div class="track"></div>
41
+ <div class="thumb selected">
42
+ <div class="visible-wrapper">
43
+ <div class="icon-container">
44
+ <obi-hydraulic-13></obi-hydraulic-13>
45
+ </div>
46
+ </div>
47
+ </div>
48
+ </div>
49
+ </div>
50
+ `;
51
+ }
52
+
53
+ static override styles = [unsafeCSS(sharedStyle), unsafeCSS(componentStyle)];
54
+ }
55
+
56
+ declare global {
57
+ interface HTMLElementTagNameMap {
58
+ 'obc-hydraulic-check-valve': ObcHydraulicCheckValve;
59
+ }
60
+ }
@@ -0,0 +1,72 @@
1
+ import type {Meta, StoryObj} from '@storybook/web-components-vite';
2
+ import {html} from 'lit';
3
+ import {
4
+ HydraulicValve43Type,
5
+ ObcHydraulicValve43,
6
+ } from './hydraulic-valve-4-3.js';
7
+ import './hydraulic-valve-4-3.js';
8
+ import type {PositionSelectedEvent} from '../shuffle-button/shuffle-button-base.js';
9
+
10
+ const meta: Meta<typeof ObcHydraulicValve43> = {
11
+ title: 'Automation/Hydraulic Valves/Valve 4-3',
12
+ tags: ['autodocs', '6.1', 'experimental'],
13
+ component: 'obc-hydraulic-valve-4-3',
14
+ args: {
15
+ type: HydraulicValve43Type.One,
16
+ selectedPosition: 1,
17
+ vertical: false,
18
+ },
19
+ argTypes: {
20
+ type: {
21
+ control: {type: 'select'},
22
+ options: Object.values(HydraulicValve43Type),
23
+ },
24
+ selectedPosition: {
25
+ control: {type: 'number', min: 0, max: 2, step: 1},
26
+ },
27
+ },
28
+ render: (args) => html`
29
+ <obc-hydraulic-valve-4-3
30
+ type=${args.type}
31
+ .selectedPosition=${args.selectedPosition}
32
+ ?vertical=${args.vertical}
33
+ @position-selected=${(event: PositionSelectedEvent) => {
34
+ (event.target as ObcHydraulicValve43).selectedPosition =
35
+ event.detail.position;
36
+ }}
37
+ ></obc-hydraulic-valve-4-3>
38
+ `,
39
+ } satisfies Meta<ObcHydraulicValve43>;
40
+
41
+ export default meta;
42
+ type Story = StoryObj<ObcHydraulicValve43>;
43
+
44
+ export const Default: Story = {};
45
+
46
+ export const Type2: Story = {
47
+ args: {type: HydraulicValve43Type.Two},
48
+ };
49
+
50
+ export const Type3: Story = {
51
+ args: {type: HydraulicValve43Type.Three},
52
+ };
53
+
54
+ export const Type4: Story = {
55
+ args: {type: HydraulicValve43Type.Four},
56
+ };
57
+
58
+ export const Type5: Story = {
59
+ args: {type: HydraulicValve43Type.Five},
60
+ };
61
+
62
+ export const PositionLeft: Story = {
63
+ args: {selectedPosition: 0},
64
+ };
65
+
66
+ export const PositionRight: Story = {
67
+ args: {selectedPosition: 2},
68
+ };
69
+
70
+ export const Vertical: Story = {
71
+ args: {vertical: true},
72
+ };
@@ -0,0 +1,108 @@
1
+ import {html} from 'lit';
2
+ import type {TemplateResult} from 'lit';
3
+ import {property} from 'lit/decorators.js';
4
+ import {customElement} from '../../decorator.js';
5
+ import {ObcShuffleButtonBase} from '../shuffle-button/shuffle-button-base.js';
6
+ import '../../icons/icon-hydraulic-01.js';
7
+ import '../../icons/icon-hydraulic-02.js';
8
+ import '../../icons/icon-hydraulic-05.js';
9
+ import '../../icons/icon-hydraulic-06.js';
10
+ import '../../icons/icon-hydraulic-07.js';
11
+ import '../../icons/icon-hydraulic-08.js';
12
+ import '../../icons/icon-hydraulic-16.js';
13
+
14
+ /**
15
+ * Detail payload for the `position-selected` event: the zero-based position
16
+ * the user requested (0 = left, 1 = center, 2 = right).
17
+ *
18
+ * Declared here rather than imported from the base: the wrapper generators
19
+ * resolve event types in the component's own module only.
20
+ */
21
+ export interface PositionSelectedDetail {
22
+ position: number;
23
+ }
24
+
25
+ /**
26
+ * Center-position symbol variant of `<obc-hydraulic-valve-4-3>`.
27
+ * Each value maps to a different center (neutral) position symbol.
28
+ */
29
+ export enum HydraulicValve43Type {
30
+ One = '1',
31
+ Two = '2',
32
+ Three = '3',
33
+ Four = '4',
34
+ Five = '5',
35
+ }
36
+
37
+ /**
38
+ * `<obc-hydraulic-valve-4-3>` – Position selector symbol for a 4/3 directional valve.
39
+ *
40
+ * Shows the valve's three positions as icon thumbs on a shared track. The
41
+ * selected position always occupies the fixed center slot; the other position
42
+ * thumbs keep their logical order and shift to either side, so the component's
43
+ * total width never changes (five 48px slots at regular size).
44
+ *
45
+ * ## Features / Variants
46
+ * - `type` selects the center-position symbol (five variants).
47
+ * - `vertical` stacks the positions top to bottom and rotates the symbols to
48
+ * match a vertical flow path.
49
+ * - Controlled selection: clicking an option or pressing arrow keys fires
50
+ * `position-selected` with the requested position; the application updates
51
+ * `selectedPosition` once the change is confirmed.
52
+ * - Scales with the component size classes (`obc-component-size-*`).
53
+ *
54
+ * ## Usage Guidelines
55
+ * Use to display and command the position of a 4/3 directional valve. For
56
+ * two-position valves use `<obc-hydraulic-valve-x-2>`; for a static check
57
+ * valve symbol use `<obc-hydraulic-check-valve>`. Bind `selectedPosition` to
58
+ * the position the device reports, not to the last request, so the symbol
59
+ * never shows a position the valve has not reached.
60
+ *
61
+ * ## Events
62
+ * - `position-selected` – Fired when the user requests a position (click or
63
+ * arrow key). Detail: `{position: number}` (0 = left, 1 = center, 2 = right).
64
+ *
65
+ * @property type - Center-position symbol variant.
66
+ * @property ariaLabel - Accessible name for the control.
67
+ * @fires {CustomEvent<PositionSelectedDetail>} position-selected - Fired when the user requests a position (click or arrow key).
68
+ * @experimental
69
+ */
70
+ @customElement('obc-hydraulic-valve-4-3')
71
+ export class ObcHydraulicValve43 extends ObcShuffleButtonBase {
72
+ @property({type: String}) type: HydraulicValve43Type =
73
+ HydraulicValve43Type.One;
74
+
75
+ @property({type: String}) override ariaLabel = 'Hydraulic 4/3 valve';
76
+
77
+ protected override get positionCount(): number {
78
+ return 3;
79
+ }
80
+
81
+ protected override renderPositionIcon(position: number): TemplateResult {
82
+ if (position === 0) {
83
+ return html`<obi-hydraulic-02></obi-hydraulic-02>`;
84
+ }
85
+ if (position === 2) {
86
+ return html`<obi-hydraulic-07></obi-hydraulic-07>`;
87
+ }
88
+ switch (this.type) {
89
+ case HydraulicValve43Type.Two:
90
+ return html`<obi-hydraulic-16></obi-hydraulic-16>`;
91
+ case HydraulicValve43Type.Three:
92
+ return html`<obi-hydraulic-08></obi-hydraulic-08>`;
93
+ case HydraulicValve43Type.Four:
94
+ return html`<obi-hydraulic-05></obi-hydraulic-05>`;
95
+ case HydraulicValve43Type.Five:
96
+ return html`<obi-hydraulic-06></obi-hydraulic-06>`;
97
+ case HydraulicValve43Type.One:
98
+ default:
99
+ return html`<obi-hydraulic-01></obi-hydraulic-01>`;
100
+ }
101
+ }
102
+ }
103
+
104
+ declare global {
105
+ interface HTMLElementTagNameMap {
106
+ 'obc-hydraulic-valve-4-3': ObcHydraulicValve43;
107
+ }
108
+ }
@@ -0,0 +1,60 @@
1
+ import type {Meta, StoryObj} from '@storybook/web-components-vite';
2
+ import {html} from 'lit';
3
+ import {
4
+ HydraulicValveX2Type,
5
+ ObcHydraulicValveX2,
6
+ } from './hydraulic-valve-x-2.js';
7
+ import './hydraulic-valve-x-2.js';
8
+ import type {PositionSelectedEvent} from '../shuffle-button/shuffle-button-base.js';
9
+
10
+ const meta: Meta<typeof ObcHydraulicValveX2> = {
11
+ title: 'Automation/Hydraulic Valves/Valve X-2',
12
+ tags: ['autodocs', '6.1', 'experimental'],
13
+ component: 'obc-hydraulic-valve-x-2',
14
+ args: {
15
+ type: HydraulicValveX2Type.TwoTwo,
16
+ selectedPosition: 1,
17
+ vertical: false,
18
+ },
19
+ argTypes: {
20
+ type: {
21
+ control: {type: 'select'},
22
+ options: Object.values(HydraulicValveX2Type),
23
+ },
24
+ selectedPosition: {
25
+ control: {type: 'number', min: 0, max: 1, step: 1},
26
+ },
27
+ },
28
+ render: (args) => html`
29
+ <obc-hydraulic-valve-x-2
30
+ type=${args.type}
31
+ .selectedPosition=${args.selectedPosition}
32
+ ?vertical=${args.vertical}
33
+ @position-selected=${(event: PositionSelectedEvent) => {
34
+ (event.target as ObcHydraulicValveX2).selectedPosition =
35
+ event.detail.position;
36
+ }}
37
+ ></obc-hydraulic-valve-x-2>
38
+ `,
39
+ } satisfies Meta<ObcHydraulicValveX2>;
40
+
41
+ export default meta;
42
+ type Story = StoryObj<ObcHydraulicValveX2>;
43
+
44
+ export const Default: Story = {};
45
+
46
+ export const TypeThreeTwo: Story = {
47
+ args: {type: HydraulicValveX2Type.ThreeTwo},
48
+ };
49
+
50
+ export const TypeFourTwo: Story = {
51
+ args: {type: HydraulicValveX2Type.FourTwo},
52
+ };
53
+
54
+ export const PositionFirst: Story = {
55
+ args: {selectedPosition: 0},
56
+ };
57
+
58
+ export const Vertical: Story = {
59
+ args: {vertical: true},
60
+ };
@@ -0,0 +1,101 @@
1
+ import {html} from 'lit';
2
+ import type {TemplateResult} from 'lit';
3
+ import {property} from 'lit/decorators.js';
4
+ import {customElement} from '../../decorator.js';
5
+ import {ObcShuffleButtonBase} from '../shuffle-button/shuffle-button-base.js';
6
+ import '../../icons/icon-hydraulic-01.js';
7
+ import '../../icons/icon-hydraulic-02.js';
8
+ import '../../icons/icon-hydraulic-07.js';
9
+ import '../../icons/icon-hydraulic-10.js';
10
+ import '../../icons/icon-hydraulic-11.js';
11
+
12
+ /**
13
+ * Detail payload for the `position-selected` event: the zero-based position
14
+ * the user requested (0 = first, 1 = second).
15
+ *
16
+ * Declared here rather than imported from the base: the wrapper generators
17
+ * resolve event types in the component's own module only.
18
+ */
19
+ export interface PositionSelectedDetail {
20
+ position: number;
21
+ }
22
+
23
+ /**
24
+ * Port/position configuration of `<obc-hydraulic-valve-x-2>`:
25
+ * `2/2`, `3/2` or `4/2` (ports/positions). Each value maps to its own pair of
26
+ * position symbols.
27
+ */
28
+ export enum HydraulicValveX2Type {
29
+ TwoTwo = '2/2',
30
+ ThreeTwo = '3/2',
31
+ FourTwo = '4/2',
32
+ }
33
+
34
+ /**
35
+ * `<obc-hydraulic-valve-x-2>` – Position selector symbol for a two-position valve.
36
+ *
37
+ * Shows the valve's two positions as icon thumbs on a shared track. The
38
+ * selected position always occupies the fixed center slot; the option thumb
39
+ * sits to its left or right depending on logical order, and an empty spacer
40
+ * slot keeps the total width constant (three 48px slots at regular size).
41
+ *
42
+ * ## Features / Variants
43
+ * - `type` selects the port/position configuration: `2/2`, `3/2` or `4/2`.
44
+ * - `vertical` stacks the positions top to bottom and rotates the symbols to
45
+ * match a vertical flow path.
46
+ * - Controlled selection: clicking the option or pressing arrow keys fires
47
+ * `position-selected`; the application updates `selectedPosition` once the
48
+ * change is confirmed.
49
+ * - Scales with the component size classes (`obc-component-size-*`).
50
+ *
51
+ * ## Usage Guidelines
52
+ * Use to display and command the position of a two-position valve. For 4/3
53
+ * directional valves use `<obc-hydraulic-valve-4-3>`; for a static check
54
+ * valve symbol use `<obc-hydraulic-check-valve>`. Bind `selectedPosition` to
55
+ * the position the device reports, not to the last request, so the symbol
56
+ * never shows a position the valve has not reached.
57
+ *
58
+ * ## Events
59
+ * - `position-selected` – Fired when the user requests a position (click or
60
+ * arrow key). Detail: `{position: number}` (0 = first, 1 = second).
61
+ *
62
+ * @property type - Port/position configuration.
63
+ * @property ariaLabel - Accessible name for the control.
64
+ * @fires {CustomEvent<PositionSelectedDetail>} position-selected - Fired when the user requests a position (click or arrow key).
65
+ * @experimental
66
+ */
67
+ @customElement('obc-hydraulic-valve-x-2')
68
+ export class ObcHydraulicValveX2 extends ObcShuffleButtonBase {
69
+ @property({type: String}) type: HydraulicValveX2Type =
70
+ HydraulicValveX2Type.TwoTwo;
71
+
72
+ @property({type: String}) override ariaLabel = 'Hydraulic valve';
73
+
74
+ protected override get positionCount(): number {
75
+ return 2;
76
+ }
77
+
78
+ protected override renderPositionIcon(position: number): TemplateResult {
79
+ switch (this.type) {
80
+ case HydraulicValveX2Type.ThreeTwo:
81
+ return position === 0
82
+ ? html`<obi-hydraulic-11></obi-hydraulic-11>`
83
+ : html`<obi-hydraulic-10></obi-hydraulic-10>`;
84
+ case HydraulicValveX2Type.FourTwo:
85
+ return position === 0
86
+ ? html`<obi-hydraulic-02></obi-hydraulic-02>`
87
+ : html`<obi-hydraulic-07></obi-hydraulic-07>`;
88
+ case HydraulicValveX2Type.TwoTwo:
89
+ default:
90
+ return position === 0
91
+ ? html`<obi-hydraulic-02></obi-hydraulic-02>`
92
+ : html`<obi-hydraulic-01></obi-hydraulic-01>`;
93
+ }
94
+ }
95
+ }
96
+
97
+ declare global {
98
+ interface HTMLElementTagNameMap {
99
+ 'obc-hydraulic-valve-x-2': ObcHydraulicValveX2;
100
+ }
101
+ }
@@ -0,0 +1,170 @@
1
+ import {LitElement, html, unsafeCSS} from 'lit';
2
+ import type {PropertyValues, TemplateResult} from 'lit';
3
+ import {property, state} from 'lit/decorators.js';
4
+ import {classMap} from 'lit/directives/class-map.js';
5
+ import componentStyle from './shuffle-button.css?inline';
6
+ import {
7
+ clampPosition,
8
+ shuffleSlotCount,
9
+ shuffleWindowOffset,
10
+ } from './shuffle-layout.js';
11
+
12
+ /**
13
+ * Detail payload for the `position-selected` event dispatched by
14
+ * shuffle-button components. `position` is the zero-based position the user
15
+ * requested.
16
+ */
17
+ export interface PositionSelectedDetail {
18
+ position: number;
19
+ }
20
+
21
+ /**
22
+ * The `position-selected` event dispatched by shuffle-button components.
23
+ */
24
+ export type PositionSelectedEvent = CustomEvent<PositionSelectedDetail>;
25
+
26
+ /**
27
+ * Base class for shuffle-button selectors: a control whose selected thumb
28
+ * always occupies the fixed center slot of a (2·n−1)-slot row (or column when
29
+ * `vertical`). Option thumbs keep their logical order and redistribute to
30
+ * either side of the selected thumb; empty spacer slots absorb the remaining
31
+ * length so the total size never changes.
32
+ *
33
+ * ## Controlled selection
34
+ * Clicking an option or pressing an arrow key only fires `position-selected`.
35
+ * The host application sets `selectedPosition` once the device confirms the
36
+ * change, so the control never shows a position the device has not reached.
37
+ *
38
+ * ## Keyboard
39
+ * Follows the WAI-ARIA radio group pattern
40
+ * (https://www.w3.org/WAI/ARIA/apg/patterns/radio/): `role="radiogroup"` with
41
+ * one `role="radio"` thumb per position, a single tab stop on the selected
42
+ * thumb, and Left/Up and Right/Down moving to the previous/next position with
43
+ * wrap-around. Departures: arrow keys request the position rather than moving
44
+ * the checked state (controlled selection above), and focus follows the thumb
45
+ * only once the host confirms it. Space/Enter on a focused thumb request it
46
+ * through the native button click. Home/End are out of scope.
47
+ *
48
+ * Subclasses define `positionCount` and `renderPositionIcon()` and carry the
49
+ * `@fires position-selected` tag: the manifest and the framework wrappers read
50
+ * events from the registered element, not from this base.
51
+ *
52
+ * Not declared `abstract`: the wrapper generators wrap every `LitElement`
53
+ * subclass and pass its constructor as a concrete `Constructor<T>`, so the
54
+ * default implementations below stand in for abstract members (same as
55
+ * `ObcAbstractAutomationButton`).
56
+ *
57
+ * @property selectedPosition - Zero-based index of the currently selected position. Out-of-range values are clamped.
58
+ * @property vertical - Lays the control out vertically: positions stack top to bottom and the position symbols rotate 90° counter-clockwise to match a vertical flow path.
59
+ * @property ariaLabel - Accessible name for the radio group (the control is icon-only). Concrete components override the default with a device-specific name.
60
+ */
61
+ export class ObcShuffleButtonBase extends LitElement {
62
+ @property({type: Number}) selectedPosition = 1;
63
+
64
+ @property({type: Boolean}) vertical = false;
65
+
66
+ @property({type: String}) override ariaLabel = 'Position selector';
67
+
68
+ @state() private suppressHover = false;
69
+
70
+ protected get positionCount(): number {
71
+ return 1;
72
+ }
73
+
74
+ protected renderPositionIcon(_position: number): TemplateResult {
75
+ return html``;
76
+ }
77
+
78
+ override render() {
79
+ const count = this.positionCount;
80
+ const selected = clampPosition(count, this.selectedPosition);
81
+ return html`
82
+ <div
83
+ class=${classMap({shuffle: true, vertical: this.vertical})}
84
+ role="radiogroup"
85
+ aria-label=${this.ariaLabel}
86
+ aria-orientation=${this.vertical ? 'vertical' : 'horizontal'}
87
+ style="--_shuffle-slot-count: ${shuffleSlotCount(
88
+ count
89
+ )}; --_shuffle-window-offset: ${shuffleWindowOffset(
90
+ count,
91
+ selected
92
+ )};${this.suppressHover ? ' --obc-can-hover: 0;' : ''}"
93
+ @keydown=${this.handleKeydown}
94
+ @pointermove=${this.restoreHover}
95
+ >
96
+ <div class="window">
97
+ <div class="track"></div>
98
+ ${Array.from({length: count}, (_, position) =>
99
+ this.renderThumb(position, selected)
100
+ )}
101
+ </div>
102
+ </div>
103
+ `;
104
+ }
105
+
106
+ private renderThumb(position: number, selected: number) {
107
+ const isSelected = position === selected;
108
+ return html`
109
+ <button
110
+ class=${classMap({thumb: true, selected: isSelected})}
111
+ type="button"
112
+ role="radio"
113
+ aria-checked=${isSelected}
114
+ tabindex=${isSelected ? 0 : -1}
115
+ @click=${() => this.requestPosition(position)}
116
+ >
117
+ <div class="visible-wrapper">
118
+ <div class="icon-container">${this.renderPositionIcon(position)}</div>
119
+ </div>
120
+ </button>
121
+ `;
122
+ }
123
+
124
+ private requestPosition(position: number) {
125
+ if (position === clampPosition(this.positionCount, this.selectedPosition)) {
126
+ return;
127
+ }
128
+ // Browsers keep :hover on the thumb that shuffles away from under a
129
+ // stationary pointer; mute hover feedback until the pointer really moves.
130
+ this.suppressHover = true;
131
+ const event: PositionSelectedEvent = new CustomEvent('position-selected', {
132
+ detail: {position},
133
+ bubbles: true,
134
+ composed: true,
135
+ });
136
+ this.dispatchEvent(event);
137
+ }
138
+
139
+ private restoreHover() {
140
+ this.suppressHover = false;
141
+ }
142
+
143
+ private handleKeydown(event: KeyboardEvent) {
144
+ let delta: number;
145
+ if (event.key === 'ArrowRight' || event.key === 'ArrowDown') {
146
+ delta = 1;
147
+ } else if (event.key === 'ArrowLeft' || event.key === 'ArrowUp') {
148
+ delta = -1;
149
+ } else {
150
+ return;
151
+ }
152
+ event.preventDefault();
153
+ const count = this.positionCount;
154
+ const selected = clampPosition(count, this.selectedPosition);
155
+ this.requestPosition((selected + delta + count) % count);
156
+ }
157
+
158
+ protected override updated(changed: PropertyValues) {
159
+ if (
160
+ changed.has('selectedPosition') &&
161
+ this.shadowRoot?.activeElement instanceof HTMLElement
162
+ ) {
163
+ this.shadowRoot
164
+ .querySelector<HTMLButtonElement>('button.thumb.selected')
165
+ ?.focus();
166
+ }
167
+ }
168
+
169
+ static override styles = unsafeCSS(componentStyle);
170
+ }