@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.84 → 2.0.0-next.85
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/bundle/openbridge-webcomponents.bundle.js +76 -33
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +64 -16
- package/dist/components/tab-item/tab-item.css.js +8 -1
- package/dist/components/tab-item/tab-item.css.js.map +1 -1
- package/dist/components/tab-item/tab-item.d.ts +44 -0
- package/dist/components/tab-item/tab-item.d.ts.map +1 -1
- package/dist/components/tab-item/tab-item.js +44 -25
- package/dist/components/tab-item/tab-item.js.map +1 -1
- package/dist/components/tab-row/tab-row.d.ts +23 -9
- package/dist/components/tab-row/tab-row.d.ts.map +1 -1
- package/dist/components/tab-row/tab-row.js +24 -7
- package/dist/components/tab-row/tab-row.js.map +1 -1
- package/package.json +1 -1
- package/src/components/tab-item/tab-item.css +8 -1
- package/src/components/tab-item/tab-item.stories.ts +30 -0
- package/src/components/tab-item/tab-item.ts +89 -31
- package/src/components/tab-row/tab-row.stories.ts +20 -10
- package/src/components/tab-row/tab-row.ts +54 -19
|
@@ -3,6 +3,7 @@ import {property} from 'lit/decorators.js';
|
|
|
3
3
|
import {repeat} from 'lit/directives/repeat.js';
|
|
4
4
|
import compentStyle from './tab-row.css?inline';
|
|
5
5
|
import '../tab-item/tab-item.js';
|
|
6
|
+
import type {TabItemBadge} from '../tab-item/tab-item.js';
|
|
6
7
|
import '../icon-button/icon-button.js';
|
|
7
8
|
import '../../icons/icon-placeholder.js';
|
|
8
9
|
import {customElement} from '../../decorator.js';
|
|
@@ -15,11 +16,22 @@ export interface TabData {
|
|
|
15
16
|
subtitle?: string;
|
|
16
17
|
showSubtitle?: boolean;
|
|
17
18
|
hasLeadingIcon?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* One or more badges to display on the tab. When non-empty this takes
|
|
21
|
+
* precedence over the deprecated single-badge fields below.
|
|
22
|
+
*/
|
|
23
|
+
badges?: TabItemBadge[];
|
|
24
|
+
/** @deprecated Use `badges` instead. */
|
|
18
25
|
hasBadge?: boolean;
|
|
26
|
+
/** @deprecated Use `badges` instead. */
|
|
19
27
|
badgeCount?: number;
|
|
28
|
+
/** @deprecated Use `badges` instead. */
|
|
20
29
|
badgeType?: BadgeType;
|
|
30
|
+
/** @deprecated Use `badges` instead. */
|
|
21
31
|
badgeSize?: BadgeSize;
|
|
32
|
+
/** @deprecated Use `badges` instead. */
|
|
22
33
|
badgeShowNumber?: boolean;
|
|
34
|
+
/** @deprecated Use `badges` instead. */
|
|
23
35
|
showLeadingBadgeIcon?: boolean;
|
|
24
36
|
disabled?: boolean;
|
|
25
37
|
}
|
|
@@ -80,8 +92,8 @@ export interface TabData {
|
|
|
80
92
|
*
|
|
81
93
|
* | Slot Name | Renders When... | Purpose |
|
|
82
94
|
* |--------------------------|------------------------------------|------------------------------------------------------|
|
|
83
|
-
* | `tab-<id>-icon`
|
|
84
|
-
* | `tab-<id
|
|
95
|
+
* | `tab-<id>-icon` | If `hasLeadingIcon` is true | Leading icon for a specific tab (replaceable) |
|
|
96
|
+
* | `tab-<id>-<iconSlotName>` | For each badge that declares an `iconSlotName` | Custom icon for a specific tab's badge (replaceable). The deprecated single-badge path uses `tab-<id>-badge-icon`. |
|
|
85
97
|
*
|
|
86
98
|
* ---
|
|
87
99
|
*
|
|
@@ -100,7 +112,7 @@ export interface TabData {
|
|
|
100
112
|
* - If using custom icons, provide them via the appropriate named slot for each tab.
|
|
101
113
|
*
|
|
102
114
|
* @slot tab-<id>-icon - Leading icon slot for each tab (shown when `hasLeadingIcon` is true for that tab)
|
|
103
|
-
* @slot tab-<id
|
|
115
|
+
* @slot tab-<id>-<iconSlotName> - Custom badge icon slot for each tab, one per badge that declares an `iconSlotName`. The deprecated single-badge path uses `tab-<id>-badge-icon`.
|
|
104
116
|
* @fires tab-selected {CustomEvent<{tab: TabData, id: string, index: number}>} Fired when a tab is selected.
|
|
105
117
|
* @fires tab-closed {CustomEvent<{tab: TabData, id: string, index: number}>} Fired when a tab's close button is clicked.
|
|
106
118
|
* @fires add-new-tab {CustomEvent<void>} Fired when the "add new tab" button is clicked.
|
|
@@ -115,12 +127,13 @@ export class ObcTabRow extends LitElement {
|
|
|
115
127
|
* - `subtitle` (string): Contextual text shown below the title when subtitle display is enabled.
|
|
116
128
|
* - `showSubtitle` (boolean): Optional per-tab override for displaying the subtitle.
|
|
117
129
|
* - `hasLeadingIcon` (boolean): Whether to show a leading icon (default: true).
|
|
118
|
-
* - `
|
|
119
|
-
* - `
|
|
120
|
-
* - `
|
|
121
|
-
* - `
|
|
122
|
-
* - `
|
|
123
|
-
* - `
|
|
130
|
+
* - `badges` (TabItemBadge[]): One or more badges to display on the tab. Takes precedence over the deprecated single-badge fields below.
|
|
131
|
+
* - `hasBadge` (boolean, deprecated): Whether to show a badge on the tab.
|
|
132
|
+
* - `badgeCount` (number, deprecated): Number to display in the badge.
|
|
133
|
+
* - `badgeType` (BadgeType, deprecated): Visual style of the badge (e.g., notification, alarm, enhance).
|
|
134
|
+
* - `badgeSize` (BadgeSize, deprecated): Size of the badge (e.g., regular, large).
|
|
135
|
+
* - `badgeShowNumber` (boolean, deprecated): If true, shows the badge number.
|
|
136
|
+
* - `showLeadingBadgeIcon` (boolean, deprecated): If true, shows a badge icon.
|
|
124
137
|
* - `disabled` (boolean): If true, disables the tab.
|
|
125
138
|
*/
|
|
126
139
|
@property({type: Array}) tabs: TabData[] = [];
|
|
@@ -139,6 +152,8 @@ export class ObcTabRow extends LitElement {
|
|
|
139
152
|
*/
|
|
140
153
|
@property({type: Boolean, attribute: 'has-close'}) hasClose = false;
|
|
141
154
|
|
|
155
|
+
@property({type: Boolean}) centerContent = false;
|
|
156
|
+
|
|
142
157
|
/**
|
|
143
158
|
* Enables "hug" mode for a more compact tab layout with reduced padding.
|
|
144
159
|
*
|
|
@@ -203,8 +218,27 @@ export class ObcTabRow extends LitElement {
|
|
|
203
218
|
|
|
204
219
|
private renderTab(tab: TabData, index: number) {
|
|
205
220
|
const isFirst = index === 0;
|
|
221
|
+
const previousTabSelected = this.selectedTabId === this.tabs[index - 1]?.id;
|
|
206
222
|
const isChecked = tab.id === this.selectedTabId;
|
|
207
223
|
const showSubtitle = tab.showSubtitle ?? this.showSubtitle;
|
|
224
|
+
// Forward a light-DOM slot for every distinct `iconSlotName` declared by the
|
|
225
|
+
// tab's badges (new `badges` array), plus the deprecated single badge-icon
|
|
226
|
+
// slot. obc-tab-item renders `<slot name=${iconSlotName} slot="badge-icon">`
|
|
227
|
+
// inside each badge, so obc-tab-row must project matching content into that
|
|
228
|
+
// slot. Slots are namespaced by tab id to stay unique across the row.
|
|
229
|
+
const badgeIconSlots = [
|
|
230
|
+
...new Set(
|
|
231
|
+
(tab.badges ?? [])
|
|
232
|
+
.map((badge) => badge.iconSlotName)
|
|
233
|
+
.filter((slotName): slotName is string => slotName !== undefined)
|
|
234
|
+
),
|
|
235
|
+
];
|
|
236
|
+
if (
|
|
237
|
+
(tab.showLeadingBadgeIcon ?? false) &&
|
|
238
|
+
!badgeIconSlots.includes('badge-icon')
|
|
239
|
+
) {
|
|
240
|
+
badgeIconSlots.push('badge-icon');
|
|
241
|
+
}
|
|
208
242
|
return html`
|
|
209
243
|
<obc-tab-item
|
|
210
244
|
.title=${tab.title}
|
|
@@ -214,11 +248,12 @@ export class ObcTabRow extends LitElement {
|
|
|
214
248
|
.hasClose=${this.hasClose}
|
|
215
249
|
.hasLeadingIcon=${tab.hasLeadingIcon ?? true}
|
|
216
250
|
.hasTitle=${true}
|
|
217
|
-
.hasDivider=${!isFirst}
|
|
251
|
+
.hasDivider=${!isFirst && !previousTabSelected}
|
|
218
252
|
.hug=${this.hug}
|
|
253
|
+
.centerContent=${this.centerContent}
|
|
219
254
|
.disabled=${tab.disabled || false}
|
|
220
|
-
.
|
|
221
|
-
|
|
255
|
+
.badges=${tab.badges ?? []}
|
|
256
|
+
.hasBadge=${tab.hasBadge || false}
|
|
222
257
|
.badgeCount=${tab.badgeCount || 0}
|
|
223
258
|
.badgeType=${tab.badgeType ?? BadgeType.regular}
|
|
224
259
|
.badgeSize=${tab.badgeSize ?? BadgeSize.regular}
|
|
@@ -235,13 +270,13 @@ export class ObcTabRow extends LitElement {
|
|
|
235
270
|
`
|
|
236
271
|
: ''}
|
|
237
272
|
<span slot="title">${tab.title}</span>
|
|
238
|
-
${
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
273
|
+
${badgeIconSlots.map(
|
|
274
|
+
(slotName) => html`
|
|
275
|
+
<slot name="tab-${tab.id}-${slotName}" slot=${slotName}>
|
|
276
|
+
<obi-placeholder></obi-placeholder>
|
|
277
|
+
</slot>
|
|
278
|
+
`
|
|
279
|
+
)}
|
|
245
280
|
</obc-tab-item>
|
|
246
281
|
`;
|
|
247
282
|
}
|