@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.154 → 2.0.0-next.155

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 (32) hide show
  1. package/bundle/openbridge-webcomponents.bundle.js +129 -6
  2. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  3. package/custom-elements.json +43 -6
  4. package/dist/components/user-button/user-button.css.js +68 -1
  5. package/dist/components/user-button/user-button.css.js.map +1 -1
  6. package/dist/components/user-button/user-button.d.ts +8 -1
  7. package/dist/components/user-button/user-button.d.ts.map +1 -1
  8. package/dist/components/user-button/user-button.js +12 -3
  9. package/dist/components/user-button/user-button.js.map +1 -1
  10. package/dist/components/user-menu/user-menu.css.js +15 -0
  11. package/dist/components/user-menu/user-menu.css.js.map +1 -1
  12. package/dist/components/user-menu/user-menu.d.ts +22 -2
  13. package/dist/components/user-menu/user-menu.d.ts.map +1 -1
  14. package/dist/components/user-menu/user-menu.js +34 -2
  15. package/dist/components/user-menu/user-menu.js.map +1 -1
  16. package/dist/generated/locales/es-419.d.ts +1 -0
  17. package/dist/generated/locales/es-419.d.ts.map +1 -1
  18. package/dist/generated/locales/es-419.js +1 -0
  19. package/dist/generated/locales/es-419.js.map +1 -1
  20. package/dist/generated/locales/fi-FI.d.ts +1 -0
  21. package/dist/generated/locales/fi-FI.d.ts.map +1 -1
  22. package/dist/generated/locales/fi-FI.js +1 -0
  23. package/dist/generated/locales/fi-FI.js.map +1 -1
  24. package/package.json +1 -1
  25. package/src/components/user-button/user-button.css +27 -1
  26. package/src/components/user-button/user-button.stories.ts +29 -0
  27. package/src/components/user-button/user-button.ts +22 -3
  28. package/src/components/user-menu/user-menu.css +8 -0
  29. package/src/components/user-menu/user-menu.stories.ts +53 -0
  30. package/src/components/user-menu/user-menu.ts +55 -4
  31. package/src/generated/locales/es-419.ts +1 -0
  32. package/src/generated/locales/fi-FI.ts +1 -0
@@ -16,6 +16,7 @@ const meta: Meta<ObcUserMenu> = {
16
16
  'sign-out-click',
17
17
  'signed-in-action-click',
18
18
  'recent-user-click',
19
+ 'use-another-account-click',
19
20
  ],
20
21
  },
21
22
  },
@@ -50,6 +51,8 @@ const meta: Meta<ObcUserMenu> = {
50
51
  passwordError: '',
51
52
  userInitials: 'AB',
52
53
  userLabel: 'Username',
54
+ userRole: '',
55
+ showUseAnotherAccount: true,
53
56
  recentUsers: [
54
57
  {initials: 'AB', label: 'Username'},
55
58
  {initials: 'CD', label: 'Username'},
@@ -77,6 +80,8 @@ const meta: Meta<ObcUserMenu> = {
77
80
  passwordError=${args.passwordError}
78
81
  .userInitials=${args.userInitials}
79
82
  .userLabel=${args.userLabel}
83
+ .userRole=${args.userRole}
84
+ .showUseAnotherAccount=${args.showUseAnotherAccount}
80
85
  .recentUsers=${args.recentUsers}
81
86
  .signedInActions=${args.signedInActions}
82
87
  .primaryActionId=${args.primaryActionId}
@@ -185,6 +190,54 @@ export const SignedInWithoutActions: Story = {
185
190
  },
186
191
  };
187
192
 
193
+ export const UserSignInWithRoles: Story = {
194
+ args: {
195
+ type: ObcUserMenuType.userSignIn,
196
+ size: ObcUserMenuSize.regular,
197
+ hasRecentlySignedIn: true,
198
+ userRole: 'Role',
199
+ recentUsers: [
200
+ {initials: 'AB', label: 'Username', role: 'Role'},
201
+ {initials: 'CD', label: 'Username', role: 'Role'},
202
+ {initials: 'EF', label: 'Username', role: 'Role'},
203
+ ],
204
+ },
205
+ };
206
+
207
+ export const SignedInWithRole: Story = {
208
+ args: {
209
+ type: ObcUserMenuType.signedIn,
210
+ size: ObcUserMenuSize.regular,
211
+ userRole: 'Role',
212
+ },
213
+ };
214
+
215
+ export const UserSignInWithoutUseAnotherAccount: Story = {
216
+ args: {
217
+ type: ObcUserMenuType.userSignIn,
218
+ size: ObcUserMenuSize.regular,
219
+ showUseAnotherAccount: false,
220
+ },
221
+ };
222
+
223
+ export const UserSignInSmallWithoutUseAnotherAccount: Story = {
224
+ args: {
225
+ type: ObcUserMenuType.userSignIn,
226
+ size: ObcUserMenuSize.small,
227
+ showUseAnotherAccount: false,
228
+ },
229
+ };
230
+
231
+ export const UserSignInSmallIgnoresRole: Story = {
232
+ args: {
233
+ type: ObcUserMenuType.userSignIn,
234
+ size: ObcUserMenuSize.small,
235
+ hasRecentlySignedIn: true,
236
+ userRole: 'Role',
237
+ recentUsers: [{initials: 'AB', label: 'Username', role: 'Role'}],
238
+ },
239
+ };
240
+
188
241
  export const SignInWithoutRecentUsers: Story = {
189
242
  args: {
190
243
  type: ObcUserMenuType.signIn,
@@ -39,8 +39,11 @@ export enum ObcUserMenuSize {
39
39
  export type ObcUserMenuUser = {
40
40
  initials: string;
41
41
  label: string;
42
+ role?: string;
42
43
  };
43
44
 
45
+ export type ObcUserMenuRecentUserClickEvent = CustomEvent<ObcUserMenuUser>;
46
+
44
47
  export type ObcUserMenuSignedInAction = {
45
48
  id: string;
46
49
  label: string;
@@ -80,8 +83,13 @@ export type ObcUserMenuSignedInAction = {
80
83
  * - `passwordError` (`string`): Error message for the password field.
81
84
  * - `userInitials` (`string`): Initials for the primary user profile.
82
85
  * - `userLabel` (`string`): Label for the primary user profile.
86
+ * - `userRole` (`string`): Role shown under the primary user's label. Omit it
87
+ * to show no role; only the regular size draws one.
83
88
  * - `recentUsers` (`ObcUserMenuUser[]`): List of recent users shown in the
84
- * "Recently signed in" section. Empty renders no section.
89
+ * "Recently signed in" section. Empty renders no section. Each user may
90
+ * carry its own `role`.
91
+ * - `showUseAnotherAccount` (`boolean`): Toggles the "Use another account"
92
+ * button in the `user-sign-in` layouts, both sizes. Defaults to `true`.
85
93
  * - `signedInActions` (`ObcUserMenuSignedInAction[]`): Actions shown in the
86
94
  * signed-in navigation list. Empty renders no actions.
87
95
  * - `primaryActionId` (`string`): Id of the action promoted to a button in the
@@ -90,6 +98,9 @@ export type ObcUserMenuSignedInAction = {
90
98
  * ### Events
91
99
  * - `sign-in-click` – Fired when a sign-in button is clicked.
92
100
  * - `sign-out-click` – Fired when the sign-out button is clicked.
101
+ * - `use-another-account-click` – Fired when the "Use another account" button
102
+ * is clicked. The menu does not change its own type; set it to `sign-in` in
103
+ * the handler to show the full form.
93
104
  * - `signed-in-action-click` – Fired when a signed-in action is clicked.
94
105
  * - `recent-user-click` – Fired when a recent user button is clicked.
95
106
  *
@@ -124,6 +135,8 @@ export type ObcUserMenuSignedInAction = {
124
135
  * @availableWhen userInitials type!=signIn
125
136
  * @property userLabel - Label for the primary user profile.
126
137
  * @availableWhen userLabel type!=signIn
138
+ * @property userRole - Role shown under the primary user's label; omit it to show no role.
139
+ * @availableWhen userRole type!=signIn && size==regular
127
140
  * @property recentUsers - Recent users for the "Recently signed in" section.
128
141
  * @property signedInActions - Actions shown in the signed-in navigation list.
129
142
  * @availableWhen signedInActions type==signedIn
@@ -133,11 +146,14 @@ export type ObcUserMenuSignedInAction = {
133
146
  * @availableWhen showPassword type in [signIn, userSignIn]
134
147
  * @property primaryActionId - Id of the action promoted to a button in the small signed-in layout.
135
148
  * @availableWhen primaryActionId type==signedIn && size==small
149
+ * @property showUseAnotherAccount - Controls the visibility of the "Use another account" button.
150
+ * @availableWhen showUseAnotherAccount type==userSignIn
136
151
  * @slot signed-in-action-icon-<id> - Optional icon for a signed-in action, one per action; `<id>` is the normalized action id (shown in the `signed-in` type).
137
152
  * @fires {CustomEvent<{username?: string, password?: string}>} sign-in-click - Fired when a sign-in button is clicked.
138
153
  * @fires {CustomEvent<void>} sign-out-click - Fired when the sign-out button is clicked.
154
+ * @fires {CustomEvent<void>} use-another-account-click - Fired when the "Use another account" button is clicked.
139
155
  * @fires {CustomEvent<{id: string, label: string}>} signed-in-action-click - Fired when a signed-in action is clicked.
140
- * @fires {CustomEvent<{initials: string, label: string}>} recent-user-click - Fired when a recent user button is clicked.
156
+ * @fires {ObcUserMenuRecentUserClickEvent} recent-user-click - Fired when a recent user button is clicked, carrying that user's entry.
141
157
  * @stable
142
158
  */
143
159
  @customElement('obc-user-menu')
@@ -168,6 +184,8 @@ export class ObcUserMenu extends LitElement {
168
184
 
169
185
  @property({type: String}) userLabel?: string;
170
186
 
187
+ @property({type: String}) userRole?: string;
188
+
171
189
  @property({type: Array, attribute: false})
172
190
  recentUsers: ObcUserMenuUser[] = [];
173
191
 
@@ -176,6 +194,9 @@ export class ObcUserMenu extends LitElement {
176
194
 
177
195
  @property({type: String}) primaryActionId?: string;
178
196
 
197
+ @property({type: Boolean, attribute: false})
198
+ showUseAnotherAccount = true;
199
+
179
200
  private get showRecentUsers() {
180
201
  return this.hasRecentlySignedIn && this.recentUsers.length > 0;
181
202
  }
@@ -223,6 +244,7 @@ export class ObcUserMenu extends LitElement {
223
244
  .size=${size}
224
245
  .initials=${user.initials}
225
246
  .label=${user.label}
247
+ .sublabel=${isLarge ? user.role : undefined}
226
248
  @click=${() => this.handleRecentUserClick(user)}
227
249
  ></obc-user-button>
228
250
  `
@@ -239,6 +261,7 @@ export class ObcUserMenu extends LitElement {
239
261
  return nothing;
240
262
  }
241
263
  const userButtonSize = size === 'large' ? Size.large : Size.regular;
264
+ const role = size === 'large' ? this.userRole : undefined;
242
265
  return html`
243
266
  <div
244
267
  class=${classMap({
@@ -250,12 +273,14 @@ export class ObcUserMenu extends LitElement {
250
273
  class=${classMap({
251
274
  'user-avatar': true,
252
275
  [`size-${size}`]: true,
276
+ 'has-role': Boolean(role),
253
277
  })}
254
278
  .variant=${Variant.initials}
255
279
  .styleType=${StyleType.normal}
256
280
  .size=${userButtonSize}
257
281
  .initials=${this.userInitials ?? ''}
258
282
  .label=${this.userLabel ?? ''}
283
+ .sublabel=${role}
259
284
  ></obc-user-button>
260
285
  </div>
261
286
  `;
@@ -293,8 +318,8 @@ export class ObcUserMenu extends LitElement {
293
318
 
294
319
  private handleRecentUserClick(user: ObcUserMenuUser) {
295
320
  this.dispatchEvent(
296
- new CustomEvent('recent-user-click', {
297
- detail: {initials: user.initials, label: user.label},
321
+ new CustomEvent<ObcUserMenuUser>('recent-user-click', {
322
+ detail: {...user},
298
323
  })
299
324
  );
300
325
  }
@@ -352,6 +377,10 @@ export class ObcUserMenu extends LitElement {
352
377
  this.dispatchEvent(new CustomEvent('sign-out-click'));
353
378
  }
354
379
 
380
+ private handleUseAnotherAccountClick() {
381
+ this.dispatchEvent(new CustomEvent('use-another-account-click'));
382
+ }
383
+
355
384
  private renderSignIn() {
356
385
  return html`
357
386
  <div class="title-container">
@@ -488,6 +517,17 @@ export class ObcUserMenu extends LitElement {
488
517
  >
489
518
  ${msg('Sign in')}
490
519
  </obc-button>
520
+ ${this.showUseAnotherAccount
521
+ ? html`
522
+ <obc-button
523
+ variant=${ButtonVariant.normal}
524
+ fullWidth
525
+ @click=${this.handleUseAnotherAccountClick}
526
+ >
527
+ ${msg('Use another account')}
528
+ </obc-button>
529
+ `
530
+ : nothing}
491
531
  </div>
492
532
  </div>
493
533
  ${this.showRecentUsers
@@ -535,6 +575,17 @@ export class ObcUserMenu extends LitElement {
535
575
  >
536
576
  ${msg('Sign in')}
537
577
  </obc-button>
578
+ ${this.showUseAnotherAccount
579
+ ? html`
580
+ <obc-button
581
+ variant=${ButtonVariant.normal}
582
+ fullWidth
583
+ @click=${this.handleUseAnotherAccountClick}
584
+ >
585
+ ${msg('Use another account')}
586
+ </obc-button>
587
+ `
588
+ : nothing}
538
589
  </div>
539
590
  ${this.showRecentUsers
540
591
  ? html`
@@ -77,6 +77,7 @@
77
77
  'sf6e1665c7022a1f8': `Password`,
78
78
  's981f6febad4df84a': `Recently signed in`,
79
79
  'sbce70cbdb856635e': `Recent`,
80
+ 's8506875a9d95f22c': `Use another account`,
80
81
  's7cfe12cd14df9950': `Sign out`,
81
82
  's5be3c6d61cd9182f': `Notifications`,
82
83
  's744d993d03f29851': `Screen`,
@@ -87,6 +87,7 @@
87
87
  'sf6e1665c7022a1f8': `Password`,
88
88
  's981f6febad4df84a': `Recently signed in`,
89
89
  'sbce70cbdb856635e': `Recent`,
90
+ 's8506875a9d95f22c': `Use another account`,
90
91
  's7cfe12cd14df9950': `Sign out`,
91
92
  's5be3c6d61cd9182f': `Notifications`,
92
93
  's744d993d03f29851': `Screen`,