@oicl/openbridge-webcomponents 2.0.0-next.154 → 2.0.0-next.156
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.
- package/LICENSE-AGPL.txt +661 -0
- package/LICENSE-APACHE.txt +177 -0
- package/LICENSE.txt +35 -0
- package/bundle/openbridge-webcomponents.bundle.js +3629 -3281
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +303 -43
- package/dist/automation/transmitter/transmitter-shared.d.ts +11 -0
- package/dist/automation/transmitter/transmitter-shared.d.ts.map +1 -0
- package/dist/automation/transmitter/transmitter-shared.js +16 -0
- package/dist/automation/transmitter/transmitter-shared.js.map +1 -0
- package/dist/automation/transmitter/transmitter.css.js +12 -1
- package/dist/automation/transmitter/transmitter.css.js.map +1 -1
- package/dist/automation/transmitter/transmitter.d.ts +9 -10
- package/dist/automation/transmitter/transmitter.d.ts.map +1 -1
- package/dist/automation/transmitter/transmitter.js +12 -15
- package/dist/automation/transmitter/transmitter.js.map +1 -1
- package/dist/automation/transmitter-button/transmitter-button.css.js +18 -42
- package/dist/automation/transmitter-button/transmitter-button.css.js.map +1 -1
- package/dist/automation/transmitter-button/transmitter-button.d.ts +31 -21
- package/dist/automation/transmitter-button/transmitter-button.d.ts.map +1 -1
- package/dist/automation/transmitter-button/transmitter-button.js +37 -39
- package/dist/automation/transmitter-button/transmitter-button.js.map +1 -1
- package/dist/automation/transmitter-stack/transmitter-stack.css.js +144 -0
- package/dist/automation/transmitter-stack/transmitter-stack.css.js.map +1 -0
- package/dist/automation/transmitter-stack/transmitter-stack.d.ts +93 -0
- package/dist/automation/transmitter-stack/transmitter-stack.d.ts.map +1 -0
- package/dist/automation/transmitter-stack/transmitter-stack.js +97 -0
- package/dist/automation/transmitter-stack/transmitter-stack.js.map +1 -0
- package/dist/building-blocks/readout-block/readout-block.d.ts +1 -1
- package/dist/building-blocks/readout-block/readout-block.js.map +1 -1
- package/dist/components/textarea-field/textarea-field.css.js +0 -2
- package/dist/components/textarea-field/textarea-field.css.js.map +1 -1
- package/dist/components/textbox/textbox.d.ts +1 -1
- package/dist/components/textbox/textbox.js.map +1 -1
- package/dist/components/user-button/user-button.css.js +68 -1
- package/dist/components/user-button/user-button.css.js.map +1 -1
- package/dist/components/user-button/user-button.d.ts +12 -1
- package/dist/components/user-button/user-button.d.ts.map +1 -1
- package/dist/components/user-button/user-button.js +12 -3
- package/dist/components/user-button/user-button.js.map +1 -1
- package/dist/components/user-menu/user-menu.css.js +15 -0
- package/dist/components/user-menu/user-menu.css.js.map +1 -1
- package/dist/components/user-menu/user-menu.d.ts +30 -2
- package/dist/components/user-menu/user-menu.d.ts.map +1 -1
- package/dist/components/user-menu/user-menu.js +34 -2
- package/dist/components/user-menu/user-menu.js.map +1 -1
- package/dist/generated/locales/es-419.d.ts +1 -0
- package/dist/generated/locales/es-419.d.ts.map +1 -1
- package/dist/generated/locales/es-419.js +1 -0
- package/dist/generated/locales/es-419.js.map +1 -1
- package/dist/generated/locales/fi-FI.d.ts +1 -0
- package/dist/generated/locales/fi-FI.d.ts.map +1 -1
- package/dist/generated/locales/fi-FI.js +1 -0
- package/dist/generated/locales/fi-FI.js.map +1 -1
- package/dist/navigation-instruments/readout/readout.d.ts +1 -1
- package/dist/navigation-instruments/readout/readout.js.map +1 -1
- package/dist/navigation-instruments/readout-list-item/readout-list-item.css.js +1 -0
- package/dist/navigation-instruments/readout-list-item/readout-list-item.css.js.map +1 -1
- package/dist/navigation-instruments/readout-list-item/readout-list-item.d.ts +1 -1
- package/dist/navigation-instruments/readout-list-item/readout-list-item.d.ts.map +1 -1
- package/dist/navigation-instruments/readout-list-item/readout-list-item.js +3 -0
- package/dist/navigation-instruments/readout-list-item/readout-list-item.js.map +1 -1
- package/package.json +6 -3
|
@@ -58,6 +58,39 @@ const compentStyle = css`* {
|
|
|
58
58
|
"ss04" on;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
.wrapper.size-large .user-label {
|
|
62
|
+
font-family: var(--global-typography-font-family);
|
|
63
|
+
font-weight: var(--global-typography-ui-body-font-weight);
|
|
64
|
+
font-size: var(--global-typography-ui-body-font-size);
|
|
65
|
+
line-height: var(--global-typography-ui-body-line-height);
|
|
66
|
+
font-feature-settings:
|
|
67
|
+
"liga" off,
|
|
68
|
+
"clig" off,
|
|
69
|
+
"ss04" on;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.wrapper.size-large .user-sublabel {
|
|
73
|
+
font-family: var(--global-typography-font-family);
|
|
74
|
+
font-weight: var(--global-typography-ui-body-font-weight);
|
|
75
|
+
font-size: var(--global-typography-ui-body-font-size);
|
|
76
|
+
line-height: var(--global-typography-ui-body-line-height);
|
|
77
|
+
font-feature-settings:
|
|
78
|
+
"liga" off,
|
|
79
|
+
"clig" off,
|
|
80
|
+
"ss04" on;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.wrapper.size-large.has-sublabel .user-label {
|
|
84
|
+
font-family: var(--global-typography-font-family);
|
|
85
|
+
font-weight: var(--global-typography-ui-body-active-font-weight);
|
|
86
|
+
font-size: var(--global-typography-ui-body-active-font-size);
|
|
87
|
+
line-height: var(--global-typography-ui-body-active-line-height);
|
|
88
|
+
font-feature-settings:
|
|
89
|
+
"liga" off,
|
|
90
|
+
"clig" off,
|
|
91
|
+
"ss04" on;
|
|
92
|
+
}
|
|
93
|
+
|
|
61
94
|
.wrapper.size-large.style-selected .user-initials {
|
|
62
95
|
font-family: var(--global-typography-font-family);
|
|
63
96
|
font-weight: var(--font-weight-bold);
|
|
@@ -70,6 +103,17 @@ const compentStyle = css`* {
|
|
|
70
103
|
"ss04" on;
|
|
71
104
|
}
|
|
72
105
|
|
|
106
|
+
.wrapper.size-large.style-selected .user-label {
|
|
107
|
+
font-family: var(--global-typography-font-family);
|
|
108
|
+
font-weight: var(--global-typography-ui-body-active-font-weight);
|
|
109
|
+
font-size: var(--global-typography-ui-body-active-font-size);
|
|
110
|
+
line-height: var(--global-typography-ui-body-active-line-height);
|
|
111
|
+
font-feature-settings:
|
|
112
|
+
"liga" off,
|
|
113
|
+
"clig" off,
|
|
114
|
+
"ss04" on;
|
|
115
|
+
}
|
|
116
|
+
|
|
73
117
|
.wrapper.size-large.state-static {
|
|
74
118
|
width: var(--ui-components-user-button-visual-size-enhanced);
|
|
75
119
|
height: var(--ui-components-user-button-visual-size-enhanced);
|
|
@@ -91,7 +135,30 @@ const compentStyle = css`* {
|
|
|
91
135
|
color: var(--element-active-color);
|
|
92
136
|
}
|
|
93
137
|
|
|
94
|
-
.wrapper
|
|
138
|
+
.wrapper .user-sublabel {
|
|
139
|
+
font-family: var(--global-typography-font-family);
|
|
140
|
+
font-weight: var(--global-typography-ui-label-font-weight);
|
|
141
|
+
font-size: var(--global-typography-ui-label-font-size);
|
|
142
|
+
line-height: var(--global-typography-ui-label-line-height);
|
|
143
|
+
font-feature-settings:
|
|
144
|
+
"liga" off,
|
|
145
|
+
"clig" off,
|
|
146
|
+
"ss04" on;
|
|
147
|
+
color: var(--element-active-color);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.wrapper.has-sublabel .user-label {
|
|
151
|
+
font-family: var(--global-typography-font-family);
|
|
152
|
+
font-weight: var(--global-typography-ui-label-active-font-weight);
|
|
153
|
+
font-size: var(--global-typography-ui-label-active-font-size);
|
|
154
|
+
line-height: var(--global-typography-ui-label-active-line-height);
|
|
155
|
+
font-feature-settings:
|
|
156
|
+
"liga" off,
|
|
157
|
+
"clig" off,
|
|
158
|
+
"ss04" on;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.wrapper:disabled .user-label,.wrapper:disabled .user-sublabel {
|
|
95
162
|
color: var(--element-disabled-color);
|
|
96
163
|
}
|
|
97
164
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-button.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-button.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -41,6 +41,8 @@ export declare enum Variant {
|
|
|
41
41
|
* - Provide a custom icon via the `icon` slot when using the `icon` variant.
|
|
42
42
|
* - **Label Support:**
|
|
43
43
|
* - Optional `label` property displays text next to the button (not shown in static mode).
|
|
44
|
+
* - Optional `sublabel` adds a second, lighter line under the label, for a
|
|
45
|
+
* secondary detail such as the user's role.
|
|
44
46
|
*
|
|
45
47
|
* ## Usage Guidelines
|
|
46
48
|
* Use `obc-user-button` to represent a user in navigation bars, toolbars, or menus where a compact, recognizable user indicator is needed. Ideal for profile menus, account switching, or user-related quick actions.
|
|
@@ -62,7 +64,8 @@ export declare enum Variant {
|
|
|
62
64
|
* - Initials longer than two characters are truncated and a warning is logged.
|
|
63
65
|
* - If `initials` is empty or invalid, the button falls back to the user icon.
|
|
64
66
|
* - The `label` is only visible when the button is interactive (not static).
|
|
65
|
-
* - For accessibility, the button
|
|
67
|
+
* - For accessibility, the button is named after its visible text — `label` and
|
|
68
|
+
* `sublabel` — falling back to the initials when it shows no text.
|
|
66
69
|
* - Only use the `static` property for non-interactive contexts; otherwise, the button is clickable.
|
|
67
70
|
*
|
|
68
71
|
* ## Example:
|
|
@@ -79,6 +82,8 @@ export declare enum Variant {
|
|
|
79
82
|
* @availableWhen disabled static==false
|
|
80
83
|
* @property label - Optional label text to display next to the button (not shown in static mode).
|
|
81
84
|
* @availableWhen label static==false
|
|
85
|
+
* @property sublabel - Optional second line under the label, for a secondary detail such as a role (not shown in static mode).
|
|
86
|
+
* @availableWhen sublabel static==false
|
|
82
87
|
* @slot icon - Custom icon for the user button (used only in `icon` variant; defaults to <obi-user> if not provided)
|
|
83
88
|
* @stable
|
|
84
89
|
*/
|
|
@@ -117,6 +122,12 @@ export declare class ObcUserButton extends LitElement {
|
|
|
117
122
|
* Available when `static==false`.
|
|
118
123
|
*/
|
|
119
124
|
label?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Optional second line under the label, for a secondary detail such as a role (not shown in static mode).
|
|
127
|
+
*
|
|
128
|
+
* Available when `static==false`.
|
|
129
|
+
*/
|
|
130
|
+
sublabel?: string;
|
|
120
131
|
private get formattedInitials();
|
|
121
132
|
private get shouldShowIcon();
|
|
122
133
|
render(): import('lit-html').TemplateResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-button.d.ts","sourceRoot":"","sources":["../../../src/components/user-button/user-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAqB,MAAM,KAAK,CAAC;AAInD,OAAO,0BAA0B,CAAC;AAIlC,oBAAY,SAAS;IACnB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,QAAQ,aAAa;CACtB;AAED,oBAAY,IAAI;IACd,OAAO,YAAY;IACnB,KAAK,UAAU;CAChB;AAED;;;;GAIG;AACH,oBAAY,OAAO;IACjB,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAED
|
|
1
|
+
{"version":3,"file":"user-button.d.ts","sourceRoot":"","sources":["../../../src/components/user-button/user-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAqB,MAAM,KAAK,CAAC;AAInD,OAAO,0BAA0B,CAAC;AAIlC,oBAAY,SAAS;IACnB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,QAAQ,aAAa;CACtB;AAED,oBAAY,IAAI;IACd,OAAO,YAAY;IACnB,KAAK,UAAU;CAChB;AAED;;;;GAIG;AACH,oBAAY,OAAO;IACjB,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBACa,aAAc,SAAQ,UAAU;IAC3C;;;;OAIG;IACuB,OAAO,EAAE,OAAO,CAAgB;IAChC,IAAI,EAAE,IAAI,CAAgB;IAEpD;;;;;OAKG;IACuB,SAAS,EAAE,SAAS,CAAkB;IAErC,MAAM,EAAE,OAAO,CAAS;IAExB,QAAQ,EAAE,OAAO,CAAS;IAErD;;;;OAIG;IACuB,QAAQ,EAAE,MAAM,CAAM;IAEtB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAE5C,OAAO,KAAK,iBAAiB,GAgB5B;IAED,OAAO,KAAK,cAAc,GAEzB;IAEQ,MAAM;IAkEf,OAAgB,MAAM,0BAA2B;CAClD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,aAAa,CAAC;KAClC;CACF"}
|
|
@@ -65,15 +65,21 @@ let ObcUserButton = class extends LitElement {
|
|
|
65
65
|
"mode-icon": this.shouldShowIcon,
|
|
66
66
|
"mode-initials": !this.shouldShowIcon,
|
|
67
67
|
"state-static": this.static,
|
|
68
|
-
[`size-${this.size}`]: true
|
|
68
|
+
[`size-${this.size}`]: true,
|
|
69
|
+
"has-sublabel": Boolean(this.sublabel) && !this.static
|
|
69
70
|
};
|
|
70
71
|
const tag = this.static ? literal`div` : literal`button`;
|
|
72
|
+
const visibleText = [this.label, this.sublabel].filter(Boolean).join(", ");
|
|
73
|
+
const accessibleName = !this.static && visibleText || this.initials || "User button";
|
|
71
74
|
const label = this.label && !this.static ? html`<span class="user-label" part="label">${this.label}</span>` : nothing;
|
|
75
|
+
const sublabel = this.sublabel && !this.static ? html`<span class="user-sublabel" part="sublabel">
|
|
76
|
+
${this.sublabel}
|
|
77
|
+
</span>` : nothing;
|
|
72
78
|
return html`
|
|
73
79
|
<${tag}
|
|
74
80
|
class=${classMap(wrapperClasses)}
|
|
75
81
|
?disabled=${this.disabled}
|
|
76
|
-
aria-label=${
|
|
82
|
+
aria-label=${accessibleName}
|
|
77
83
|
>
|
|
78
84
|
<div class="content-container" part="content-container">
|
|
79
85
|
<div class="user-button-circle">
|
|
@@ -90,7 +96,7 @@ let ObcUserButton = class extends LitElement {
|
|
|
90
96
|
</span>
|
|
91
97
|
`}
|
|
92
98
|
</div>
|
|
93
|
-
${label}
|
|
99
|
+
${label} ${sublabel}
|
|
94
100
|
</div>
|
|
95
101
|
</${tag}>
|
|
96
102
|
`;
|
|
@@ -118,6 +124,9 @@ __decorateClass([
|
|
|
118
124
|
__decorateClass([
|
|
119
125
|
property({ type: String })
|
|
120
126
|
], ObcUserButton.prototype, "label", 2);
|
|
127
|
+
__decorateClass([
|
|
128
|
+
property({ type: String })
|
|
129
|
+
], ObcUserButton.prototype, "sublabel", 2);
|
|
121
130
|
ObcUserButton = __decorateClass([
|
|
122
131
|
customElement("obc-user-button")
|
|
123
132
|
], ObcUserButton);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-button.js","sources":["../../../src/components/user-button/user-button.ts"],"sourcesContent":["import {LitElement, nothing, unsafeCSS} from 'lit';\nimport {property} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\nimport compentStyle from './user-button.css?inline';\nimport '../../icons/icon-user.js';\nimport {html, literal} from 'lit/static-html.js';\nimport {customElement} from '../../decorator.js';\n\nexport enum StyleType {\n flat = 'flat',\n normal = 'normal',\n selected = 'selected',\n}\n\nexport enum Size {\n regular = 'regular',\n large = 'large',\n}\n\n/**\n * Defines the visual content of the user button.\n * - `icon`: Shows a user icon (default).\n * - `initials`: Shows up to two uppercase initials.\n */\nexport enum Variant {\n icon = 'icon',\n initials = 'initials',\n}\n\n/**\n * `obc-user-button` – A compact, circular button for representing a user via icon or initials.\n *\n * Displays either a user icon or user initials inside a circular button, with optional label text. Commonly used for user profile access, account switching, or avatar actions in toolbars and navigation. The button supports multiple visual styles and can be rendered as a static (non-interactive) element.\n *\n * Appears as a button by default, but switches to a non-interactive div when the `static` property is set.\n *\n * ## Features\n * - **Variants:**\n * - `icon`: Shows a user icon (default, fallback if initials are invalid or missing).\n * - `initials`: Shows up to two uppercase initials (falls back to icon if input is empty or longer than two characters).\n * - **Style Types:**\n * - `flat`: Minimal, flat appearance (default).\n * - `normal`: Outlined with background and border.\n * - `selected`: Highlighted to indicate selection or active state.\n * - **Static Mode:**\n * - Set `static` to render as a non-interactive element for use in read-only or decorative contexts.\n * - **Disabled State:**\n * - Set `disabled` to visually and functionally disable the button.\n * - **Custom Icon Slot:**\n * - Provide a custom icon via the `icon` slot when using the `icon` variant.\n * - **Label Support:**\n * - Optional `label` property displays text next to the button (not shown in static mode).\n *\n * ## Usage Guidelines\n * Use `obc-user-button` to represent a user in navigation bars, toolbars, or menus where a compact, recognizable user indicator is needed. Ideal for profile menus, account switching, or user-related quick actions.\n * - Use the `icon` variant for generic user representation, or when no initials are available.\n * - Use the `initials` variant to personalize the button with user initials (max two characters).\n * - Use `styleType=\"selected\"` to indicate the current user or active selection.\n * - Use `static` for non-interactive displays, such as in lists or summaries.\n * - Avoid using for critical actions or as a replacement for full user profile cards.\n *\n * **TODO(designer):** Confirm if there are recommended scenarios for when to use `flat`, `normal`, or `selected` style types, and if there are accessibility guidelines for initials fallback.\n *\n * ## Slots\n *\n * | Slot Name | Renders When... | Purpose |\n * |-----------|-----------------|---------|\n * | `icon` | `variant=\"icon\"` | Custom icon to display instead of the default user icon. |\n *\n * ## Best Practices & Constraints\n * - Initials longer than two characters are truncated and a warning is logged.\n * - If `initials` is empty or invalid, the button falls back to the user icon.\n * - The `label` is only visible when the button is interactive (not static).\n * - For accessibility, the button uses `aria-label` based on initials or a default.\n * - Only use the `static` property for non-interactive contexts; otherwise, the button is clickable.\n *\n * ## Example:\n * ```html\n * <obc-user-button variant=\"initials\" initials=\"JD\" styleType=\"normal\" label=\"John Doe\"></obc-user-button>\n * <obc-user-button variant=\"icon\" styleType=\"flat\">\n * <obi-placeholder slot=\"icon\"></obi-placeholder>\n * </obc-user-button>\n * ```\n *\n * @property static - If true, renders the button as a static (non-interactive) element using a `<div>`.\n * Use for decorative or read-only contexts where user interaction is not required.\n * @property disabled - Disables the button, preventing user interaction and applying a disabled style.\n * @availableWhen disabled static==false\n * @property label - Optional label text to display next to the button (not shown in static mode).\n * @availableWhen label static==false\n * @slot icon - Custom icon for the user button (used only in `icon` variant; defaults to <obi-user> if not provided)\n * @stable\n */\n@customElement('obc-user-button')\nexport class ObcUserButton extends LitElement {\n /**\n * Controls whether the button displays a user icon (`icon`) or user initials (`initials`).\n * - `icon`: Shows a user icon (default, or if initials are invalid).\n * - `initials`: Shows up to two uppercase initials (falls back to icon if empty or longer than two characters).\n */\n @property({type: String}) variant: Variant = Variant.icon;\n @property({type: String}) size: Size = Size.regular;\n\n /**\n * Sets the visual style of the button.\n * - `flat`: Minimal, flat appearance (default).\n * - `normal`: Outlined with background and border.\n * - `selected`: Highlighted to indicate selection or active state.\n */\n @property({type: String}) styleType: StyleType = StyleType.flat;\n\n @property({type: Boolean}) static: boolean = false;\n\n @property({type: Boolean}) disabled: boolean = false;\n\n /**\n * The initials to display when `variant=\"initials\"`.\n * - Only the first two non-whitespace characters are used and converted to uppercase.\n * - If empty or longer than two characters, falls back to the user icon.\n */\n @property({type: String}) initials: string = '';\n\n @property({type: String}) label?: string;\n\n private get formattedInitials() {\n if (!this.initials) return '';\n\n // Remove whitespace and convert to uppercase\n const clean = this.initials.replace(/\\s+/g, '').toUpperCase();\n\n // If longer than 2 characters, truncate to first 2\n const maxInitialsLength = this.size === Size.large ? 3 : 2;\n if (clean.length > maxInitialsLength) {\n console.warn(\n `Initials \"${this.initials}\" are longer than ${maxInitialsLength} characters.`\n );\n return clean.slice(0, maxInitialsLength);\n }\n\n return clean;\n }\n\n private get shouldShowIcon() {\n return this.variant === Variant.icon;\n }\n\n override render() {\n const styleType =\n this.size === Size.large && this.styleType === StyleType.flat\n ? StyleType.normal\n : this.styleType;\n const wrapperClasses = {\n wrapper: true,\n 'wrapper-static': this.static,\n [`style-${styleType}`]: true,\n 'mode-icon': this.shouldShowIcon,\n 'mode-initials': !this.shouldShowIcon,\n 'state-static': this.static,\n [`size-${this.size}`]: true,\n };\n\n // Use button element when clickable, div when static\n const tag = this.static ? literal`div` : literal`button`;\n\n const label =\n this.label && !this.static\n ? html`<span class=\"user-label\" part=\"label\">${this.label}</span>`\n : nothing;\n\n return html`\n <${tag}\n class=${classMap(wrapperClasses)}\n ?disabled=${this.disabled}\n aria-label=${this.initials || 'User button'}\n >\n <div class=\"content-container\" part=\"content-container\">\n <div class=\"user-button-circle\">\n ${\n this.shouldShowIcon\n ? html`\n <div class=\"icon-container\">\n <slot name=\"icon\">\n <!-- Fallback to default icon if no slot content -->\n <obi-user></obi-user>\n </slot>\n </div>\n `\n : html`\n <span class=\"user-initials\">\n ${this.formattedInitials}\n </span>\n `\n }\n </div>\n ${label}\n </div>\n </${tag}>\n `;\n }\n\n static override styles = unsafeCSS(compentStyle);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-user-button': ObcUserButton;\n }\n}\n"],"names":["StyleType","Size","Variant"],"mappings":";;;;;;;;;;;;;;;;;AAQO,IAAK,8BAAAA,eAAL;AACLA,aAAA,MAAA,IAAO;AACPA,aAAA,QAAA,IAAS;AACTA,aAAA,UAAA,IAAW;AAHD,SAAAA;AAAA,GAAA,aAAA,CAAA,CAAA;AAML,IAAK,yBAAAC,UAAL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othing, unsafeCSS} from 'lit';\nimport {property} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\nimport compentStyle from './user-button.css?inline';\nimport '../../icons/icon-user.js';\nimport {html, literal} from 'lit/static-html.js';\nimport {customElement} from '../../decorator.js';\n\nexport enum StyleType {\n flat = 'flat',\n normal = 'normal',\n selected = 'selected',\n}\n\nexport enum Size {\n regular = 'regular',\n large = 'large',\n}\n\n/**\n * Defines the visual content of the user button.\n * - `icon`: Shows a user icon (default).\n * - `initials`: Shows up to two uppercase initials.\n */\nexport enum Variant {\n icon = 'icon',\n initials = 'initials',\n}\n\n/**\n * `obc-user-button` – A compact, circular button for representing a user via icon or initials.\n *\n * Displays either a user icon or user initials inside a circular button, with optional label text. Commonly used for user profile access, account switching, or avatar actions in toolbars and navigation. The button supports multiple visual styles and can be rendered as a static (non-interactive) element.\n *\n * Appears as a button by default, but switches to a non-interactive div when the `static` property is set.\n *\n * ## Features\n * - **Variants:**\n * - `icon`: Shows a user icon (default, fallback if initials are invalid or missing).\n * - `initials`: Shows up to two uppercase initials (falls back to icon if input is empty or longer than two characters).\n * - **Style Types:**\n * - `flat`: Minimal, flat appearance (default).\n * - `normal`: Outlined with background and border.\n * - `selected`: Highlighted to indicate selection or active state.\n * - **Static Mode:**\n * - Set `static` to render as a non-interactive element for use in read-only or decorative contexts.\n * - **Disabled State:**\n * - Set `disabled` to visually and functionally disable the button.\n * - **Custom Icon Slot:**\n * - Provide a custom icon via the `icon` slot when using the `icon` variant.\n * - **Label Support:**\n * - Optional `label` property displays text next to the button (not shown in static mode).\n * - Optional `sublabel` adds a second, lighter line under the label, for a\n * secondary detail such as the user's role.\n *\n * ## Usage Guidelines\n * Use `obc-user-button` to represent a user in navigation bars, toolbars, or menus where a compact, recognizable user indicator is needed. Ideal for profile menus, account switching, or user-related quick actions.\n * - Use the `icon` variant for generic user representation, or when no initials are available.\n * - Use the `initials` variant to personalize the button with user initials (max two characters).\n * - Use `styleType=\"selected\"` to indicate the current user or active selection.\n * - Use `static` for non-interactive displays, such as in lists or summaries.\n * - Avoid using for critical actions or as a replacement for full user profile cards.\n *\n * **TODO(designer):** Confirm if there are recommended scenarios for when to use `flat`, `normal`, or `selected` style types, and if there are accessibility guidelines for initials fallback.\n *\n * ## Slots\n *\n * | Slot Name | Renders When... | Purpose |\n * |-----------|-----------------|---------|\n * | `icon` | `variant=\"icon\"` | Custom icon to display instead of the default user icon. |\n *\n * ## Best Practices & Constraints\n * - Initials longer than two characters are truncated and a warning is logged.\n * - If `initials` is empty or invalid, the button falls back to the user icon.\n * - The `label` is only visible when the button is interactive (not static).\n * - For accessibility, the button is named after its visible text — `label` and\n * `sublabel` — falling back to the initials when it shows no text.\n * - Only use the `static` property for non-interactive contexts; otherwise, the button is clickable.\n *\n * ## Example:\n * ```html\n * <obc-user-button variant=\"initials\" initials=\"JD\" styleType=\"normal\" label=\"John Doe\"></obc-user-button>\n * <obc-user-button variant=\"icon\" styleType=\"flat\">\n * <obi-placeholder slot=\"icon\"></obi-placeholder>\n * </obc-user-button>\n * ```\n *\n * @property static - If true, renders the button as a static (non-interactive) element using a `<div>`.\n * Use for decorative or read-only contexts where user interaction is not required.\n * @property disabled - Disables the button, preventing user interaction and applying a disabled style.\n * @availableWhen disabled static==false\n * @property label - Optional label text to display next to the button (not shown in static mode).\n * @availableWhen label static==false\n * @property sublabel - Optional second line under the label, for a secondary detail such as a role (not shown in static mode).\n * @availableWhen sublabel static==false\n * @slot icon - Custom icon for the user button (used only in `icon` variant; defaults to <obi-user> if not provided)\n * @stable\n */\n@customElement('obc-user-button')\nexport class ObcUserButton extends LitElement {\n /**\n * Controls whether the button displays a user icon (`icon`) or user initials (`initials`).\n * - `icon`: Shows a user icon (default, or if initials are invalid).\n * - `initials`: Shows up to two uppercase initials (falls back to icon if empty or longer than two characters).\n */\n @property({type: String}) variant: Variant = Variant.icon;\n @property({type: String}) size: Size = Size.regular;\n\n /**\n * Sets the visual style of the button.\n * - `flat`: Minimal, flat appearance (default).\n * - `normal`: Outlined with background and border.\n * - `selected`: Highlighted to indicate selection or active state.\n */\n @property({type: String}) styleType: StyleType = StyleType.flat;\n\n @property({type: Boolean}) static: boolean = false;\n\n @property({type: Boolean}) disabled: boolean = false;\n\n /**\n * The initials to display when `variant=\"initials\"`.\n * - Only the first two non-whitespace characters are used and converted to uppercase.\n * - If empty or longer than two characters, falls back to the user icon.\n */\n @property({type: String}) initials: string = '';\n\n @property({type: String}) label?: string;\n\n @property({type: String}) sublabel?: string;\n\n private get formattedInitials() {\n if (!this.initials) return '';\n\n // Remove whitespace and convert to uppercase\n const clean = this.initials.replace(/\\s+/g, '').toUpperCase();\n\n // If longer than 2 characters, truncate to first 2\n const maxInitialsLength = this.size === Size.large ? 3 : 2;\n if (clean.length > maxInitialsLength) {\n console.warn(\n `Initials \"${this.initials}\" are longer than ${maxInitialsLength} characters.`\n );\n return clean.slice(0, maxInitialsLength);\n }\n\n return clean;\n }\n\n private get shouldShowIcon() {\n return this.variant === Variant.icon;\n }\n\n override render() {\n const styleType =\n this.size === Size.large && this.styleType === StyleType.flat\n ? StyleType.normal\n : this.styleType;\n const wrapperClasses = {\n wrapper: true,\n 'wrapper-static': this.static,\n [`style-${styleType}`]: true,\n 'mode-icon': this.shouldShowIcon,\n 'mode-initials': !this.shouldShowIcon,\n 'state-static': this.static,\n [`size-${this.size}`]: true,\n 'has-sublabel': Boolean(this.sublabel) && !this.static,\n };\n\n // Use button element when clickable, div when static\n const tag = this.static ? literal`div` : literal`button`;\n\n const visibleText = [this.label, this.sublabel].filter(Boolean).join(', ');\n const accessibleName =\n (!this.static && visibleText) || this.initials || 'User button';\n\n const label =\n this.label && !this.static\n ? html`<span class=\"user-label\" part=\"label\">${this.label}</span>`\n : nothing;\n\n const sublabel =\n this.sublabel && !this.static\n ? html`<span class=\"user-sublabel\" part=\"sublabel\">\n ${this.sublabel}\n </span>`\n : nothing;\n\n return html`\n <${tag}\n class=${classMap(wrapperClasses)}\n ?disabled=${this.disabled}\n aria-label=${accessibleName}\n >\n <div class=\"content-container\" part=\"content-container\">\n <div class=\"user-button-circle\">\n ${\n this.shouldShowIcon\n ? html`\n <div class=\"icon-container\">\n <slot name=\"icon\">\n <!-- Fallback to default icon if no slot content -->\n <obi-user></obi-user>\n </slot>\n </div>\n `\n : html`\n <span class=\"user-initials\">\n ${this.formattedInitials}\n </span>\n `\n }\n </div>\n ${label} ${sublabel}\n </div>\n </${tag}>\n `;\n }\n\n static override styles = unsafeCSS(compentStyle);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-user-button': ObcUserButton;\n }\n}\n"],"names":["StyleType","Size","Variant"],"mappings":";;;;;;;;;;;;;;;;;AAQO,IAAK,8BAAAA,eAAL;AACLA,aAAA,MAAA,IAAO;AACPA,aAAA,QAAA,IAAS;AACTA,aAAA,UAAA,IAAW;AAHD,SAAAA;AAAA,GAAA,aAAA,CAAA,CAAA;AAML,IAAK,yBAAAC,UAAL;AACLA,QAAA,SAAA,IAAU;AACVA,QAAA,OAAA,IAAQ;AAFE,SAAAA;AAAA,GAAA,QAAA,CAAA,CAAA;AAUL,IAAK,4BAAAC,aAAL;AACLA,WAAA,MAAA,IAAO;AACPA,WAAA,UAAA,IAAW;AAFD,SAAAA;AAAA,GAAA,WAAA,CAAA,CAAA;AA2EL,IAAM,gBAAN,cAA4B,WAAW;AAAA,EAAvC,cAAA;AAAA,UAAA,GAAA,SAAA;AAMqB,SAAA,UAAmB;AACnB,SAAA,OAAa;AAQb,SAAA,YAAuB;AAEtB,SAAA,SAAkB;AAElB,SAAA,WAAoB;AAOrB,SAAA,WAAmB;AAAA,EAAA;AAAA,EAM7C,IAAY,oBAAoB;AAC9B,QAAI,CAAC,KAAK,SAAU,QAAO;AAG3B,UAAM,QAAQ,KAAK,SAAS,QAAQ,QAAQ,EAAE,EAAE,YAAA;AAGhD,UAAM,oBAAoB,KAAK,SAAS,UAAa,IAAI;AACzD,QAAI,MAAM,SAAS,mBAAmB;AACpC,cAAQ;AAAA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,GAAG;AAAA;AAAA,EAEb;AAGF;AAzHa,cAwHK,SAAS,UAAU,YAAY;AAlHrB,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,OAAA,CAAO;AAAA,GANb,cAMe,WAAA,WAAA,CAAA;AACA,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,OAAA,CAAO;AAAA,GAPb,cAOe,WAAA,QAAA,CAAA;AAQA,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,OAAA,CAAO;AAAA,GAfb,cAee,WAAA,aAAA,CAAA;AAEC,gBAAA;AAAA,EAA1B,SAAS,EAAC,MAAM,QAAA,CAAQ;AAAA,GAjBd,cAiBgB,WAAA,UAAA,CAAA;AAEA,gBAAA;AAAA,EAA1B,SAAS,EAAC,MAAM,QAAA,CAAQ;AAAA,GAnBd,cAmBgB,WAAA,YAAA,CAAA;AAOD,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,OAAA,CAAO;AAAA,GA1Bb,cA0Be,WAAA,YAAA,CAAA;AAEA,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,OAAA,CAAO;AAAA,GA5Bb,cA4Be,WAAA,SAAA,CAAA;AAEA,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,OAAA,CAAO;AAAA,GA9Bb,cA8Be,WAAA,YAAA,CAAA;AA9Bf,gBAAN,gBAAA;AAAA,EADN,cAAc,iBAAiB;AAAA,GACnB,aAAA;"}
|
|
@@ -167,6 +167,21 @@ const componentStyle = css`* {
|
|
|
167
167
|
color: var(--element-neutral-color);
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
:is(.card .user-profile) obc-user-button:not(.has-role)::part(label) {
|
|
171
|
+
font-weight: var(--font-weight-regular);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
:is(.card .user-profile) obc-user-button::part(sublabel) {
|
|
175
|
+
font-family: var(--global-typography-font-family);
|
|
176
|
+
font-weight: var(--global-typography-ui-body-font-weight);
|
|
177
|
+
font-size: var(--global-typography-ui-body-font-size);
|
|
178
|
+
line-height: var(--global-typography-ui-body-line-height);
|
|
179
|
+
font-feature-settings:
|
|
180
|
+
"liga" off,
|
|
181
|
+
"clig" off,
|
|
182
|
+
"ss04" on;
|
|
183
|
+
}
|
|
184
|
+
|
|
170
185
|
.card .user-primary {
|
|
171
186
|
padding: 0;
|
|
172
187
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-menu.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-menu.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -21,7 +21,9 @@ export declare enum ObcUserMenuSize {
|
|
|
21
21
|
export type ObcUserMenuUser = {
|
|
22
22
|
initials: string;
|
|
23
23
|
label: string;
|
|
24
|
+
role?: string;
|
|
24
25
|
};
|
|
26
|
+
export type ObcUserMenuRecentUserClickEvent = CustomEvent<ObcUserMenuUser>;
|
|
25
27
|
export type ObcUserMenuSignedInAction = {
|
|
26
28
|
id: string;
|
|
27
29
|
label: string;
|
|
@@ -60,8 +62,13 @@ export type ObcUserMenuSignedInAction = {
|
|
|
60
62
|
* - `passwordError` (`string`): Error message for the password field.
|
|
61
63
|
* - `userInitials` (`string`): Initials for the primary user profile.
|
|
62
64
|
* - `userLabel` (`string`): Label for the primary user profile.
|
|
65
|
+
* - `userRole` (`string`): Role shown under the primary user's label. Omit it
|
|
66
|
+
* to show no role; only the regular size draws one.
|
|
63
67
|
* - `recentUsers` (`ObcUserMenuUser[]`): List of recent users shown in the
|
|
64
|
-
* "Recently signed in" section. Empty renders no section.
|
|
68
|
+
* "Recently signed in" section. Empty renders no section. Each user may
|
|
69
|
+
* carry its own `role`.
|
|
70
|
+
* - `showUseAnotherAccount` (`boolean`): Toggles the "Use another account"
|
|
71
|
+
* button in the `user-sign-in` layouts, both sizes. Defaults to `true`.
|
|
65
72
|
* - `signedInActions` (`ObcUserMenuSignedInAction[]`): Actions shown in the
|
|
66
73
|
* signed-in navigation list. Empty renders no actions.
|
|
67
74
|
* - `primaryActionId` (`string`): Id of the action promoted to a button in the
|
|
@@ -70,6 +77,9 @@ export type ObcUserMenuSignedInAction = {
|
|
|
70
77
|
* ### Events
|
|
71
78
|
* - `sign-in-click` – Fired when a sign-in button is clicked.
|
|
72
79
|
* - `sign-out-click` – Fired when the sign-out button is clicked.
|
|
80
|
+
* - `use-another-account-click` – Fired when the "Use another account" button
|
|
81
|
+
* is clicked. The menu does not change its own type; set it to `sign-in` in
|
|
82
|
+
* the handler to show the full form.
|
|
73
83
|
* - `signed-in-action-click` – Fired when a signed-in action is clicked.
|
|
74
84
|
* - `recent-user-click` – Fired when a recent user button is clicked.
|
|
75
85
|
*
|
|
@@ -104,6 +114,8 @@ export type ObcUserMenuSignedInAction = {
|
|
|
104
114
|
* @availableWhen userInitials type!=signIn
|
|
105
115
|
* @property userLabel - Label for the primary user profile.
|
|
106
116
|
* @availableWhen userLabel type!=signIn
|
|
117
|
+
* @property userRole - Role shown under the primary user's label; omit it to show no role.
|
|
118
|
+
* @availableWhen userRole type!=signIn && size==regular
|
|
107
119
|
* @property recentUsers - Recent users for the "Recently signed in" section.
|
|
108
120
|
* @property signedInActions - Actions shown in the signed-in navigation list.
|
|
109
121
|
* @availableWhen signedInActions type==signedIn
|
|
@@ -113,11 +125,14 @@ export type ObcUserMenuSignedInAction = {
|
|
|
113
125
|
* @availableWhen showPassword type in [signIn, userSignIn]
|
|
114
126
|
* @property primaryActionId - Id of the action promoted to a button in the small signed-in layout.
|
|
115
127
|
* @availableWhen primaryActionId type==signedIn && size==small
|
|
128
|
+
* @property showUseAnotherAccount - Controls the visibility of the "Use another account" button.
|
|
129
|
+
* @availableWhen showUseAnotherAccount type==userSignIn
|
|
116
130
|
* @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).
|
|
117
131
|
* @fires {CustomEvent<{username?: string, password?: string}>} sign-in-click - Fired when a sign-in button is clicked.
|
|
118
132
|
* @fires {CustomEvent<void>} sign-out-click - Fired when the sign-out button is clicked.
|
|
133
|
+
* @fires {CustomEvent<void>} use-another-account-click - Fired when the "Use another account" button is clicked.
|
|
119
134
|
* @fires {CustomEvent<{id: string, label: string}>} signed-in-action-click - Fired when a signed-in action is clicked.
|
|
120
|
-
* @fires {
|
|
135
|
+
* @fires {ObcUserMenuRecentUserClickEvent} recent-user-click - Fired when a recent user button is clicked, carrying that user's entry.
|
|
121
136
|
* @stable
|
|
122
137
|
*/
|
|
123
138
|
export declare class ObcUserMenu extends LitElement {
|
|
@@ -179,6 +194,12 @@ export declare class ObcUserMenu extends LitElement {
|
|
|
179
194
|
* Available when `type!=signIn`.
|
|
180
195
|
*/
|
|
181
196
|
userLabel?: string;
|
|
197
|
+
/**
|
|
198
|
+
* Role shown under the primary user's label; omit it to show no role.
|
|
199
|
+
*
|
|
200
|
+
* Available when `type!=signIn && size==regular`.
|
|
201
|
+
*/
|
|
202
|
+
userRole?: string;
|
|
182
203
|
/** Recent users for the "Recently signed in" section. */
|
|
183
204
|
recentUsers: ObcUserMenuUser[];
|
|
184
205
|
/**
|
|
@@ -193,6 +214,12 @@ export declare class ObcUserMenu extends LitElement {
|
|
|
193
214
|
* Available when `type==signedIn && size==small`.
|
|
194
215
|
*/
|
|
195
216
|
primaryActionId?: string;
|
|
217
|
+
/**
|
|
218
|
+
* Controls the visibility of the "Use another account" button.
|
|
219
|
+
*
|
|
220
|
+
* Available when `type==userSignIn`.
|
|
221
|
+
*/
|
|
222
|
+
showUseAnotherAccount: boolean;
|
|
196
223
|
private get showRecentUsers();
|
|
197
224
|
private renderTextInput;
|
|
198
225
|
private renderUserButtons;
|
|
@@ -206,6 +233,7 @@ export declare class ObcUserMenu extends LitElement {
|
|
|
206
233
|
private validateSignIn;
|
|
207
234
|
private handleSignInClick;
|
|
208
235
|
private handleSignOutClick;
|
|
236
|
+
private handleUseAnotherAccountClick;
|
|
209
237
|
private renderSignIn;
|
|
210
238
|
private renderSignInSmall;
|
|
211
239
|
private renderUserSignIn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-menu.d.ts","sourceRoot":"","sources":["../../../src/components/user-menu/user-menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,cAAc,EAA2B,MAAM,KAAK,CAAC;AAKzE,OAAO,yCAAyC,CAAC;AACjD,OAAO,qBAAqB,CAAC;AAC7B,OAAO,+BAA+B,CAAC;AACvC,OAAO,iCAAiC,CAAC;AACzC,OAAO,uCAAuC,CAAC;AAC/C,OAAO,qCAAqC,CAAC;AAC7C,OAAO,qCAAqC,CAAC;AAC7C,OAAO,kCAAkC,CAAC;AAC1C,OAAO,0BAA0B,CAAC;AAalC,oBAAY,eAAe;IACzB,MAAM,YAAY;IAClB,UAAU,iBAAiB;IAC3B,aAAa,oBAAoB;IACjC,QAAQ,cAAc;CACvB;AAED,oBAAY,eAAe;IACzB,OAAO,YAAY;IACnB,KAAK,UAAU;CAChB;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"user-menu.d.ts","sourceRoot":"","sources":["../../../src/components/user-menu/user-menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,cAAc,EAA2B,MAAM,KA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,EAAE,CAAM;IAGpC,eAAe,EAAE,yBAAyB,EAAE,CAAM;IAExB,eAAe,CAAC,EAAE,MAAM,CAAC;IAGnD,qBAAqB,UAAQ;IAE7B,OAAO,KAAK,eAAe,GAE1B;IAED,OAAO,CAAC,eAAe;IAwBvB,OAAO,CAAC,iBAAiB;IA4BzB,OAAO,CAAC,iBAAiB;IAiCzB,OAAO,CAAC,qBAAqB;IAe7B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,yBAAyB;IAQjC,OAAO,CAAC,qBAAqB;IAQ7B,OAAO,CAAC,mBAAmB;IAQ3B,OAAO,CAAC,mBAAmB;IAQ3B,OAAO,CAAC,cAAc;IAmBtB,OAAO,CAAC,iBAAiB;IAczB,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,4BAA4B;IAIpC,OAAO,CAAC,YAAY;IAoDpB,OAAO,CAAC,iBAAiB;IAqDzB,OAAO,CAAC,gBAAgB;IA2DxB,OAAO,CAAC,qBAAqB;IA0D7B,OAAO,CAAC,mBAAmB;IAiB3B,OAAO,CAAC,wBAAwB;IAiBhC,OAAO,CAAC,cAAc;IA2CtB,OAAO,CAAC,mBAAmB;IAkClB,MAAM;IAwCf,OAAgB,MAAM,0BAA6B;CACpD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,eAAe,EAAE,WAAW,CAAC;KAC9B;CACF"}
|
|
@@ -49,6 +49,7 @@ let ObcUserMenu = class extends LitElement {
|
|
|
49
49
|
this.passwordError = "";
|
|
50
50
|
this.recentUsers = [];
|
|
51
51
|
this.signedInActions = [];
|
|
52
|
+
this.showUseAnotherAccount = true;
|
|
52
53
|
}
|
|
53
54
|
get showRecentUsers() {
|
|
54
55
|
return this.hasRecentlySignedIn && this.recentUsers.length > 0;
|
|
@@ -89,6 +90,7 @@ let ObcUserMenu = class extends LitElement {
|
|
|
89
90
|
.size=${size}
|
|
90
91
|
.initials=${user.initials}
|
|
91
92
|
.label=${user.label}
|
|
93
|
+
.sublabel=${isLarge ? user.role : void 0}
|
|
92
94
|
@click=${() => this.handleRecentUserClick(user)}
|
|
93
95
|
></obc-user-button>
|
|
94
96
|
`
|
|
@@ -101,6 +103,7 @@ let ObcUserMenu = class extends LitElement {
|
|
|
101
103
|
return nothing;
|
|
102
104
|
}
|
|
103
105
|
const userButtonSize = size === "large" ? Size.large : Size.regular;
|
|
106
|
+
const role = size === "large" ? this.userRole : void 0;
|
|
104
107
|
return html`
|
|
105
108
|
<div
|
|
106
109
|
class=${classMap({
|
|
@@ -111,13 +114,15 @@ let ObcUserMenu = class extends LitElement {
|
|
|
111
114
|
<obc-user-button
|
|
112
115
|
class=${classMap({
|
|
113
116
|
"user-avatar": true,
|
|
114
|
-
[`size-${size}`]: true
|
|
117
|
+
[`size-${size}`]: true,
|
|
118
|
+
"has-role": Boolean(role)
|
|
115
119
|
})}
|
|
116
120
|
.variant=${Variant.initials}
|
|
117
121
|
.styleType=${StyleType.normal}
|
|
118
122
|
.size=${userButtonSize}
|
|
119
123
|
.initials=${this.userInitials ?? ""}
|
|
120
124
|
.label=${this.userLabel ?? ""}
|
|
125
|
+
.sublabel=${role}
|
|
121
126
|
></obc-user-button>
|
|
122
127
|
</div>
|
|
123
128
|
`;
|
|
@@ -149,7 +154,7 @@ let ObcUserMenu = class extends LitElement {
|
|
|
149
154
|
handleRecentUserClick(user) {
|
|
150
155
|
this.dispatchEvent(
|
|
151
156
|
new CustomEvent("recent-user-click", {
|
|
152
|
-
detail: {
|
|
157
|
+
detail: { ...user }
|
|
153
158
|
})
|
|
154
159
|
);
|
|
155
160
|
}
|
|
@@ -197,6 +202,9 @@ let ObcUserMenu = class extends LitElement {
|
|
|
197
202
|
handleSignOutClick() {
|
|
198
203
|
this.dispatchEvent(new CustomEvent("sign-out-click"));
|
|
199
204
|
}
|
|
205
|
+
handleUseAnotherAccountClick() {
|
|
206
|
+
this.dispatchEvent(new CustomEvent("use-another-account-click"));
|
|
207
|
+
}
|
|
200
208
|
renderSignIn() {
|
|
201
209
|
return html`
|
|
202
210
|
<div class="title-container">
|
|
@@ -317,6 +325,15 @@ let ObcUserMenu = class extends LitElement {
|
|
|
317
325
|
>
|
|
318
326
|
${msg("Sign in")}
|
|
319
327
|
</obc-button>
|
|
328
|
+
${this.showUseAnotherAccount ? html`
|
|
329
|
+
<obc-button
|
|
330
|
+
variant=${ButtonVariant.normal}
|
|
331
|
+
fullWidth
|
|
332
|
+
@click=${this.handleUseAnotherAccountClick}
|
|
333
|
+
>
|
|
334
|
+
${msg("Use another account")}
|
|
335
|
+
</obc-button>
|
|
336
|
+
` : nothing}
|
|
320
337
|
</div>
|
|
321
338
|
</div>
|
|
322
339
|
${this.showRecentUsers ? html`
|
|
@@ -359,6 +376,15 @@ let ObcUserMenu = class extends LitElement {
|
|
|
359
376
|
>
|
|
360
377
|
${msg("Sign in")}
|
|
361
378
|
</obc-button>
|
|
379
|
+
${this.showUseAnotherAccount ? html`
|
|
380
|
+
<obc-button
|
|
381
|
+
variant=${ButtonVariant.normal}
|
|
382
|
+
fullWidth
|
|
383
|
+
@click=${this.handleUseAnotherAccountClick}
|
|
384
|
+
>
|
|
385
|
+
${msg("Use another account")}
|
|
386
|
+
</obc-button>
|
|
387
|
+
` : nothing}
|
|
362
388
|
</div>
|
|
363
389
|
${this.showRecentUsers ? html`
|
|
364
390
|
<div class="divider" aria-hidden="true"></div>
|
|
@@ -537,6 +563,9 @@ __decorateClass([
|
|
|
537
563
|
__decorateClass([
|
|
538
564
|
property({ type: String })
|
|
539
565
|
], ObcUserMenu.prototype, "userLabel", 2);
|
|
566
|
+
__decorateClass([
|
|
567
|
+
property({ type: String })
|
|
568
|
+
], ObcUserMenu.prototype, "userRole", 2);
|
|
540
569
|
__decorateClass([
|
|
541
570
|
property({ type: Array, attribute: false })
|
|
542
571
|
], ObcUserMenu.prototype, "recentUsers", 2);
|
|
@@ -546,6 +575,9 @@ __decorateClass([
|
|
|
546
575
|
__decorateClass([
|
|
547
576
|
property({ type: String })
|
|
548
577
|
], ObcUserMenu.prototype, "primaryActionId", 2);
|
|
578
|
+
__decorateClass([
|
|
579
|
+
property({ type: Boolean, attribute: false })
|
|
580
|
+
], ObcUserMenu.prototype, "showUseAnotherAccount", 2);
|
|
549
581
|
ObcUserMenu = __decorateClass([
|
|
550
582
|
customElement("obc-user-menu"),
|
|
551
583
|
localized()
|