@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.71 → 2.0.0-next.72

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.
@@ -3,7 +3,11 @@ import {html, nothing} from 'lit';
3
3
  import './alert-menu-item.js';
4
4
  import '../../icons/icon-engine.js';
5
5
  import '../alert-icon/alert-icon.js';
6
- import {ObcAlertMenuItem, ObcAlertMenuItemStatus} from './alert-menu-item.js';
6
+ import {
7
+ ObcAlertMenuItem,
8
+ ObcAlertMenuItemActionState,
9
+ ObcAlertMenuItemStatus,
10
+ } from './alert-menu-item.js';
7
11
 
8
12
  const meta: Meta<ObcAlertMenuItem> = {
9
13
  title: 'Application Components/Alerts/Alert Menu Item',
@@ -17,6 +21,9 @@ const meta: Meta<ObcAlertMenuItem> = {
17
21
  status: ObcAlertMenuItemStatus.Unacknowledged,
18
22
  hasIcon: false,
19
23
  shelved: false,
24
+ secondaryActionLabel: '',
25
+ primaryActionState: ObcAlertMenuItemActionState.Enabled,
26
+ secondaryActionState: ObcAlertMenuItemActionState.Enabled,
20
27
  },
21
28
  render: (args) => html`
22
29
  <obc-alert-menu-item
@@ -27,6 +34,9 @@ const meta: Meta<ObcAlertMenuItem> = {
27
34
  .shelved=${args.shelved}
28
35
  .hasIcon=${args.hasIcon}
29
36
  .status=${args.status}
37
+ .secondaryActionLabel=${args.secondaryActionLabel}
38
+ .primaryActionState=${args.primaryActionState}
39
+ .secondaryActionState=${args.secondaryActionState}
30
40
  >
31
41
  <obc-alert-icon slot="alert-icon" type="alarm" active></obc-alert-icon>
32
42
  ${args.hasIcon ? html`<obi-engine slot="icon"></obi-engine>` : nothing}
@@ -43,6 +53,15 @@ const meta: Meta<ObcAlertMenuItem> = {
43
53
  },
44
54
  hasIcon: {control: 'boolean'},
45
55
  shelved: {control: 'boolean'},
56
+ secondaryActionLabel: {control: 'text'},
57
+ primaryActionState: {
58
+ control: 'select',
59
+ options: Object.values(ObcAlertMenuItemActionState),
60
+ },
61
+ secondaryActionState: {
62
+ control: 'select',
63
+ options: Object.values(ObcAlertMenuItemActionState),
64
+ },
46
65
  },
47
66
  };
48
67
 
@@ -83,3 +102,23 @@ export const NoAckWarning: Story = {
83
102
  status: ObcAlertMenuItemStatus.NoAckWarning,
84
103
  },
85
104
  };
105
+
106
+ export const WithSecondaryAction: Story = {
107
+ args: {
108
+ secondaryActionLabel: 'Mute',
109
+ },
110
+ };
111
+
112
+ export const SecondaryActionDisabled: Story = {
113
+ args: {
114
+ secondaryActionLabel: 'Mute',
115
+ secondaryActionState: ObcAlertMenuItemActionState.Disabled,
116
+ },
117
+ };
118
+
119
+ export const PrimaryActionNone: Story = {
120
+ args: {
121
+ secondaryActionLabel: 'Mute',
122
+ primaryActionState: ObcAlertMenuItemActionState.None,
123
+ },
124
+ };
@@ -20,6 +20,18 @@ export enum ObcAlertMenuItemStatus {
20
20
  Rectified = 'rectified',
21
21
  }
22
22
 
23
+ /**
24
+ * Appearance of an alert menu item action.
25
+ * - `enabled`: Action is shown and interactive (default).
26
+ * - `disabled`: Action is shown but cannot be triggered.
27
+ * - `none`: Action is removed and takes no space.
28
+ */
29
+ export enum ObcAlertMenuItemActionState {
30
+ Enabled = 'enabled',
31
+ Disabled = 'disabled',
32
+ None = 'none',
33
+ }
34
+
23
35
  /**
24
36
  * `<obc-alert-menu-item>` – A list item component for displaying alert or notification entries with status, icons, and action controls.
25
37
  *
@@ -33,7 +45,8 @@ export enum ObcAlertMenuItemStatus {
33
45
  * - **Icon Support:** Optional secondary icon (e.g., system or source) and a primary alert icon. Tertiary "shelved" icon appears if the alert is shelved.
34
46
  * - **Time and Day Display:** Optionally shows day and/or time for the alert occurrence.
35
47
  * - **Expandable:** Can be toggled open/closed for additional details (via click).
36
- * - **Action Button:** Displays an "ACK" button for unacknowledged alerts; triggers an event when clicked.
48
+ * - **Action Buttons:** Displays an "ACK" button for unacknowledged alerts and an optional secondary action (label set via `secondaryActionLabel`); each triggers an event when clicked.
49
+ * - Each action's appearance is controlled independently via `primaryActionState` / `secondaryActionState` (`enabled`, `disabled`, or `none`).
37
50
  * - **Animated Intro:** Optional animation when the item appears.
38
51
  * - **Size Options:** Supports single-line or multi-line layouts (see `size` property).
39
52
  *
@@ -44,6 +57,8 @@ export enum ObcAlertMenuItemStatus {
44
57
  * - Provide a relevant icon in the `alert-icon` slot to visually indicate the alert type.
45
58
  * - Use the `icon` slot for a source/system icon if needed.
46
59
  * - Only show the "ACK" action for alerts that require acknowledgment.
60
+ * - Provide `secondaryActionLabel` to add a second action alongside ACK.
61
+ * - Use `primaryActionState` / `secondaryActionState` to temporarily disable an action (`disabled`) or remove it without leaving a gap (`none`).
47
62
  * - Use the `shelved` property to indicate alerts that are temporarily deferred.
48
63
  *
49
64
  * ### Slots
@@ -54,6 +69,7 @@ export enum ObcAlertMenuItemStatus {
54
69
  *
55
70
  * ### Events
56
71
  * - **ack-click** – Fired when the ACK action button is clicked.
72
+ * - **ack-secondary-click** – Fired when the secondary action button is clicked.
57
73
  * - **item-click** – Fired when the alert menu item is clicked (toggles open/closed).
58
74
  *
59
75
  * ### Best Practices
@@ -81,6 +97,7 @@ export enum ObcAlertMenuItemStatus {
81
97
  * @slot icon - Optional secondary icon (e.g., source/system).
82
98
  *
83
99
  * @fires ack-click {CustomEvent<void>} Fired when the ACK action button is clicked.
100
+ * @fires ack-secondary-click {CustomEvent<void>} Fired when the secondary action button is clicked.
84
101
  * @fires item-click {CustomEvent<void>} Fired when the alert menu item is clicked.
85
102
  */
86
103
  @customElement('obc-alert-menu-item')
@@ -146,10 +163,51 @@ export class ObcAlertMenuItem extends LitElement {
146
163
  */
147
164
  @property({type: Boolean}) animateIntro = false;
148
165
 
166
+ /**
167
+ * The label for the secondary action button.
168
+ * Unlike the primary (ACK) action, the secondary label is not derived from
169
+ * `status`; it must be provided explicitly. The secondary action is only
170
+ * shown when a non-empty label is set and `secondaryActionState` is not
171
+ * `none`.
172
+ */
173
+ @property({type: String}) secondaryActionLabel = '';
174
+
175
+ /**
176
+ * Controls the appearance of the primary (ACK) action.
177
+ * See {@link ObcAlertMenuItemActionState} for the available states.
178
+ */
179
+ @property({type: String}) primaryActionState: ObcAlertMenuItemActionState =
180
+ ObcAlertMenuItemActionState.Enabled;
181
+
182
+ /**
183
+ * Controls the appearance of the secondary action.
184
+ * See {@link ObcAlertMenuItemActionState} for the available states.
185
+ */
186
+ @property({type: String}) secondaryActionState: ObcAlertMenuItemActionState =
187
+ ObcAlertMenuItemActionState.None;
188
+
149
189
  private get primaryActionLabel() {
190
+ if (this.primaryActionState === ObcAlertMenuItemActionState.None) {
191
+ return '';
192
+ }
150
193
  return this.status === ObcAlertMenuItemStatus.Unacknowledged ? 'ACK' : '';
151
194
  }
152
195
 
196
+ private get secondaryActionLabelToShow() {
197
+ if (this.secondaryActionState === ObcAlertMenuItemActionState.None) {
198
+ return '';
199
+ }
200
+ return this.secondaryActionLabel;
201
+ }
202
+
203
+ private get primaryActionDisabled() {
204
+ return this.primaryActionState === ObcAlertMenuItemActionState.Disabled;
205
+ }
206
+
207
+ private get secondaryActionDisabled() {
208
+ return this.secondaryActionState === ObcAlertMenuItemActionState.Disabled;
209
+ }
210
+
153
211
  private get hasTrailingIcon() {
154
212
  // True when we need the action container but don't have an ACK button
155
213
  return this.status !== ObcAlertMenuItemStatus.Unacknowledged;
@@ -164,6 +222,10 @@ export class ObcAlertMenuItem extends LitElement {
164
222
  this.dispatchEvent(new CustomEvent('ack-click'));
165
223
  }
166
224
 
225
+ private handleSecondaryActionClick() {
226
+ this.dispatchEvent(new CustomEvent('ack-secondary-click'));
227
+ }
228
+
167
229
  override render() {
168
230
  return html`
169
231
  <obc-message-menu-item
@@ -172,6 +234,9 @@ export class ObcAlertMenuItem extends LitElement {
172
234
  .day=${this.day}
173
235
  .time=${this.time}
174
236
  .primaryActionLabel=${this.primaryActionLabel}
237
+ .secondaryActionLabel=${this.secondaryActionLabelToShow}
238
+ .enablePrimaryAction=${!this.primaryActionDisabled}
239
+ .enableSecondaryAction=${!this.secondaryActionDisabled}
175
240
  .size=${this.size}
176
241
  .open=${this.open}
177
242
  .hasSecondaryIcon=${this.hasIcon}
@@ -181,6 +246,7 @@ export class ObcAlertMenuItem extends LitElement {
181
246
  hasPrimaryIcon
182
247
  @message-click=${this.handleMessageClick}
183
248
  @primary-action-click=${this.handleActionClick}
249
+ @secondary-action-click=${this.handleSecondaryActionClick}
184
250
  >
185
251
  <slot name="alert-icon" slot="primary-icon"></slot>
186
252
  <slot name="title" slot="title">${this.title}</slot>
@@ -36,6 +36,8 @@ const meta: Meta<ObcMessageMenuItem> = {
36
36
  time: {control: 'text'},
37
37
  primaryActionLabel: {control: 'text'},
38
38
  secondaryActionLabel: {control: 'text'},
39
+ enablePrimaryAction: {control: 'boolean'},
40
+ enableSecondaryAction: {control: 'boolean'},
39
41
  // Icon slots
40
42
  hasPrimaryIcon: {control: 'boolean'},
41
43
  hasSecondaryIcon: {control: 'boolean'},
@@ -57,6 +59,8 @@ const meta: Meta<ObcMessageMenuItem> = {
57
59
  time: '',
58
60
  primaryActionLabel: '',
59
61
  secondaryActionLabel: '',
62
+ enablePrimaryAction: true,
63
+ enableSecondaryAction: true,
60
64
  hasPrimaryIcon: false,
61
65
  hasSecondaryIcon: false,
62
66
  hasTrailingIcon: false,
@@ -75,6 +79,8 @@ const meta: Meta<ObcMessageMenuItem> = {
75
79
  .time=${args.time}
76
80
  .primaryActionLabel=${args.primaryActionLabel}
77
81
  .secondaryActionLabel=${args.secondaryActionLabel}
82
+ .enablePrimaryAction=${args.enablePrimaryAction}
83
+ .enableSecondaryAction=${args.enableSecondaryAction}
78
84
  .hasPrimaryIcon=${args.hasPrimaryIcon}
79
85
  .hasSecondaryIcon=${args.hasSecondaryIcon}
80
86
  .hasTrailingIcon=${args.hasTrailingIcon}
@@ -259,6 +265,18 @@ export const HorizontalWithTwoActions: Story = {
259
265
  },
260
266
  };
261
267
 
268
+ export const HorizontalWithOneDisabledAction: Story = {
269
+ args: {
270
+ size: ObcMessageMenuItemSize.DoubleLine,
271
+ hasPrimaryIcon: true,
272
+ day: 'Yesterday',
273
+ time: '09:12:34',
274
+ primaryActionLabel: 'Action',
275
+ secondaryActionLabel: 'Action 2',
276
+ enableSecondaryAction: false,
277
+ },
278
+ };
279
+
262
280
  export const HorizontalWithTrailingIcon: Story = {
263
281
  args: {
264
282
  size: ObcMessageMenuItemSize.DoubleLine,
@@ -37,6 +37,7 @@ export enum ObcMessageMenuItemSize {
37
37
  *
38
38
  * - **Actions:**
39
39
  * - Supports up to two action buttons via `primaryActionLabel` and `secondaryActionLabel`.
40
+ * - Each action can be independently disabled by setting `enablePrimaryAction` or `enableSecondaryAction` to `false`.
40
41
  * - In vertical layout, action buttons expand to full width.
41
42
  *
42
43
  * - **Timestamp:**
@@ -52,6 +53,7 @@ export enum ObcMessageMenuItemSize {
52
53
  * - Use `stackVertical=true` when actions need more prominence or when space is narrow.
53
54
  * - Enable `enhancedIcon` to highlight important or priority messages.
54
55
  * - Use `isShelved` to indicate messages that have been temporarily set aside.
56
+ * - Set `enablePrimaryAction` / `enableSecondaryAction` to `false` when an action is temporarily unavailable (e.g. awaiting a precondition) rather than removing the button.
55
57
  *
56
58
  * ## Slots
57
59
  *
@@ -134,6 +136,8 @@ export class ObcMessageMenuItem extends LitElement {
134
136
  @property({type: String}) time = '';
135
137
  @property({type: String}) primaryActionLabel = '';
136
138
  @property({type: String}) secondaryActionLabel = '';
139
+ @property({type: Boolean, attribute: false}) enablePrimaryAction = true;
140
+ @property({type: Boolean, attribute: false}) enableSecondaryAction = true;
137
141
 
138
142
  // Visibility properties for icons (slots)
139
143
  @property({type: Boolean}) hasPrimaryIcon = false;
@@ -281,6 +285,7 @@ export class ObcMessageMenuItem extends LitElement {
281
285
  variant="normal"
282
286
  .fullWidth=${this.isVertical}
283
287
  @click=${this.handleSecondaryActionClick}
288
+ ?disabled=${!this.enableSecondaryAction}
284
289
  >
285
290
  ${this.secondaryActionLabel}
286
291
  </obc-button>`
@@ -290,6 +295,7 @@ export class ObcMessageMenuItem extends LitElement {
290
295
  variant="normal"
291
296
  .fullWidth=${this.isVertical}
292
297
  @click=${this.handlePrimaryActionClick}
298
+ ?disabled=${!this.enablePrimaryAction}
293
299
  >
294
300
  ${this.hasActionLabelSlot
295
301
  ? html`<slot name="action-label"></slot>`