@italia/tabs 0.0.0 → 1.0.0-alpha.9
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/README.md +2 -2
- package/custom-elements.json +1188 -27
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/it-tab-panel.d.ts +44 -0
- package/dist/src/it-tab-panel.d.ts.map +1 -0
- package/dist/src/it-tab-panel.js +149 -0
- package/dist/src/it-tab-panel.js.map +1 -0
- package/dist/src/it-tab.d.ts +94 -0
- package/dist/src/it-tab.d.ts.map +1 -0
- package/dist/src/it-tab.js +400 -0
- package/dist/src/it-tab.js.map +1 -0
- package/dist/src/it-tabs.d.ts +241 -5
- package/dist/src/it-tabs.d.ts.map +1 -1
- package/dist/src/it-tabs.js +1323 -51
- package/dist/src/it-tabs.js.map +1 -1
- package/dist/src/locales/en.d.ts +4 -0
- package/dist/src/locales/en.d.ts.map +1 -0
- package/dist/src/locales/it.d.ts +4 -0
- package/dist/src/locales/it.d.ts.map +1 -0
- package/dist/src/types.d.ts +30 -0
- package/dist/src/types.d.ts.map +1 -0
- package/package.json +18 -9
package/dist/src/it-tabs.js
CHANGED
|
@@ -1,72 +1,1344 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
import { B as BaseComponent, _ as __decorate, a as __metadata } from '../index-MXvCu6vX.js';
|
|
2
|
+
import { css, html } from 'lit';
|
|
3
|
+
import { property, state, queryAssignedElements, customElement } from 'lit/decorators.js';
|
|
4
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
5
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
6
|
+
import 'lit/directive.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Roving Tabindex Controller
|
|
10
|
+
*
|
|
11
|
+
* Implements the ARIA roving tabindex pattern for keyboard navigation.
|
|
12
|
+
* See: https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_roving_tabindex
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* ```ts
|
|
16
|
+
* private rovingTabindex = new RovingTabindexController(this, {
|
|
17
|
+
* getItems: () => Array.from(this.querySelectorAll('my-item')),
|
|
18
|
+
* onSelect: (item) => this.selectItem(item),
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
class RovingTabindexController {
|
|
23
|
+
constructor(host, config) {
|
|
24
|
+
this.host = host;
|
|
25
|
+
this.config = {
|
|
26
|
+
wrap: true,
|
|
27
|
+
direction: 'both',
|
|
28
|
+
selectOnFocus: false,
|
|
29
|
+
selectOnHomeEnd: false,
|
|
30
|
+
skipItem: (item) => item.hasAttribute('disabled') || item.disabled === true,
|
|
31
|
+
...config,
|
|
32
|
+
};
|
|
33
|
+
host.addController(this);
|
|
34
|
+
}
|
|
35
|
+
// eslint-disable-next-line class-methods-use-this
|
|
36
|
+
hostConnected() {
|
|
37
|
+
// Controller is ready when host connects
|
|
38
|
+
}
|
|
39
|
+
// eslint-disable-next-line class-methods-use-this
|
|
40
|
+
hostDisconnected() {
|
|
41
|
+
// Cleanup if needed
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Update tabindex values for all items
|
|
45
|
+
* @param activeIndex - Index of the item that should be tabbable (default: 0 or first non-disabled)
|
|
46
|
+
*/
|
|
47
|
+
updateTabindices(activeIndex) {
|
|
48
|
+
const items = this.config.getItems();
|
|
49
|
+
if (!items || items.length === 0) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
// Find the active index
|
|
53
|
+
let targetIndex = activeIndex ?? 0;
|
|
54
|
+
// If no active index specified, use first non-disabled item
|
|
55
|
+
if (activeIndex === undefined) {
|
|
56
|
+
targetIndex = items.findIndex((item) => !this.config.skipItem(item));
|
|
57
|
+
if (targetIndex === -1) {
|
|
58
|
+
targetIndex = 0; // Fallback to first item if all disabled
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Set tabindex for all items
|
|
62
|
+
items.forEach((item, index) => {
|
|
63
|
+
const itemElement = item;
|
|
64
|
+
if (this.config.skipItem(itemElement)) {
|
|
65
|
+
// eslint-disable-next-line no-param-reassign
|
|
66
|
+
itemElement.tabIndex = -1;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// eslint-disable-next-line no-param-reassign
|
|
70
|
+
itemElement.tabIndex = index === targetIndex ? 0 : -1;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Handle keyboard navigation
|
|
76
|
+
* @param currentItem - The currently focused item
|
|
77
|
+
* @param event - The keyboard event
|
|
78
|
+
* @returns true if the event was handled, false otherwise
|
|
79
|
+
*/
|
|
80
|
+
handleKeydown(currentItem, event) {
|
|
81
|
+
const direction = typeof this.config.direction === 'function' ? this.config.direction() : this.config.direction;
|
|
82
|
+
const { key } = event;
|
|
83
|
+
// Determine if this key should be handled based on direction
|
|
84
|
+
const isVertical = key === 'ArrowUp' || key === 'ArrowDown';
|
|
85
|
+
const isHorizontal = key === 'ArrowLeft' || key === 'ArrowRight';
|
|
86
|
+
const isHome = key === 'Home';
|
|
87
|
+
const isEnd = key === 'End';
|
|
88
|
+
const shouldHandle = isHome ||
|
|
89
|
+
isEnd ||
|
|
90
|
+
(direction === 'both' && (isVertical || isHorizontal)) ||
|
|
91
|
+
(direction === 'vertical' && isVertical) ||
|
|
92
|
+
(direction === 'horizontal' && isHorizontal);
|
|
93
|
+
if (!shouldHandle) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
// Prevent default behavior (page scrolling)
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
const items = this.config.getItems();
|
|
99
|
+
const currentIndex = items.indexOf(currentItem);
|
|
100
|
+
if (currentIndex === -1) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
let nextIndex = currentIndex;
|
|
104
|
+
// Handle Home/End keys
|
|
105
|
+
if (isHome) {
|
|
106
|
+
nextIndex = 0;
|
|
107
|
+
}
|
|
108
|
+
else if (isEnd) {
|
|
109
|
+
nextIndex = items.length - 1;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
// Handle arrow keys
|
|
113
|
+
const isNext = key === 'ArrowDown' || key === 'ArrowRight';
|
|
114
|
+
const isPrev = key === 'ArrowUp' || key === 'ArrowLeft';
|
|
115
|
+
if (isNext) {
|
|
116
|
+
nextIndex = this.getNextIndex(items, currentIndex, 1);
|
|
117
|
+
}
|
|
118
|
+
else if (isPrev) {
|
|
119
|
+
nextIndex = this.getNextIndex(items, currentIndex, -1);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// Skip disabled items — Home always searches forward, End always searches backward
|
|
123
|
+
// eslint-disable-next-line no-nested-ternary
|
|
124
|
+
const searchDirection = isHome ? 1 : isEnd ? -1 : nextIndex > currentIndex ? 1 : -1;
|
|
125
|
+
nextIndex = this.findNextValidIndex(items, nextIndex, searchDirection);
|
|
126
|
+
if (nextIndex !== -1 && nextIndex !== currentIndex) {
|
|
127
|
+
const nextItem = items[nextIndex];
|
|
128
|
+
// Update tabindices
|
|
129
|
+
this.updateTabindices(nextIndex);
|
|
130
|
+
// Focus the next item
|
|
131
|
+
nextItem.focus();
|
|
132
|
+
// Optionally select/activate the item.
|
|
133
|
+
// Select when `selectOnFocus` is enabled, or when Home/End keys
|
|
134
|
+
// were used and the consumer explicitly opted in via `selectOnHomeEnd`.
|
|
135
|
+
const shouldSelect = this.config.selectOnFocus === true || ((isHome || isEnd) && this.config.selectOnHomeEnd === true);
|
|
136
|
+
if (shouldSelect && this.config.onSelect) {
|
|
137
|
+
this.config.onSelect(nextItem, event);
|
|
138
|
+
}
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get the next index based on direction
|
|
145
|
+
*/
|
|
146
|
+
getNextIndex(items, currentIndex, direction) {
|
|
147
|
+
const { wrap } = this.config;
|
|
148
|
+
let nextIndex = currentIndex + direction;
|
|
149
|
+
if (wrap) {
|
|
150
|
+
// Wrap around
|
|
151
|
+
if (nextIndex < 0) {
|
|
152
|
+
nextIndex = items.length - 1;
|
|
153
|
+
}
|
|
154
|
+
else if (nextIndex >= items.length) {
|
|
155
|
+
nextIndex = 0;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
// Clamp to bounds
|
|
160
|
+
nextIndex = Math.max(0, Math.min(items.length - 1, nextIndex));
|
|
161
|
+
}
|
|
162
|
+
return nextIndex;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Find the next valid (non-disabled) index
|
|
166
|
+
*/
|
|
167
|
+
findNextValidIndex(items, startIndex, direction) {
|
|
168
|
+
const maxAttempts = items.length;
|
|
169
|
+
let attempts = 0;
|
|
170
|
+
let index = startIndex;
|
|
171
|
+
while (attempts < maxAttempts) {
|
|
172
|
+
if (!this.config.skipItem(items[index])) {
|
|
173
|
+
return index;
|
|
174
|
+
}
|
|
175
|
+
index = this.getNextIndex(items, index, direction);
|
|
176
|
+
attempts += 1;
|
|
177
|
+
}
|
|
178
|
+
// All items are disabled
|
|
179
|
+
return -1;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Set focus to a specific item
|
|
183
|
+
*/
|
|
184
|
+
focusItem(item) {
|
|
185
|
+
const items = this.config.getItems();
|
|
186
|
+
const index = items.indexOf(item);
|
|
187
|
+
if (index !== -1) {
|
|
188
|
+
this.updateTabindices(index);
|
|
189
|
+
item.focus();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Set focus to the first non-disabled item
|
|
194
|
+
*/
|
|
195
|
+
focusFirst() {
|
|
196
|
+
const items = this.config.getItems();
|
|
197
|
+
const firstValidIndex = this.findNextValidIndex(items, 0, 1);
|
|
198
|
+
if (firstValidIndex !== -1) {
|
|
199
|
+
this.focusItem(items[firstValidIndex]);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Set focus to the last non-disabled item
|
|
204
|
+
*/
|
|
205
|
+
focusLast() {
|
|
206
|
+
const items = this.config.getItems();
|
|
207
|
+
const lastValidIndex = this.findNextValidIndex(items, items.length - 1, -1);
|
|
208
|
+
if (lastValidIndex !== -1) {
|
|
209
|
+
this.focusItem(items[lastValidIndex]);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
var styles = css`/***************************** 1 ****************************************/
|
|
215
|
+
/***************************** 2 ****************************************/
|
|
216
|
+
/***************************** 1 ****************************************/
|
|
217
|
+
/***************************** 2 ****************************************/
|
|
218
|
+
/***************************** 1 ****************************************/
|
|
219
|
+
/***************************** 2 ****************************************/
|
|
220
|
+
/***************************** 3 ****************************************/
|
|
221
|
+
/***************************** 1 ****************************************/
|
|
222
|
+
/***************************** 2 ****************************************/
|
|
223
|
+
/***************************** 3 ****************************************/
|
|
224
|
+
/***************************** NEUTRAL 1 ****************************************/
|
|
225
|
+
/***************************** NEUTRAL 2 ****************************************/
|
|
226
|
+
/***************************** NEUTRAL 2 / 3 ****************************************/
|
|
227
|
+
.nav {
|
|
228
|
+
--bsi-nav-link-disabled-color: var(--bsi-color-text-disabled);
|
|
229
|
+
--bsi-nav-link-padding-x: var(--bsi-spacing-s);
|
|
230
|
+
--bsi-nav-link-padding-y: var(--bsi-spacing-s);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* stylelint-disable-next-line no-duplicate-selectors */
|
|
234
|
+
.nav {
|
|
235
|
+
display: flex;
|
|
236
|
+
flex-wrap: wrap;
|
|
237
|
+
margin-bottom: 0;
|
|
238
|
+
padding-left: 0;
|
|
239
|
+
list-style: none;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.nav-link {
|
|
243
|
+
display: block;
|
|
244
|
+
color: var(--bsi-navbar-link-color);
|
|
245
|
+
font-size: var(--bsi-navbar-link-font-size);
|
|
246
|
+
font-weight: var(--bsi-navbar-link-font-weight);
|
|
247
|
+
line-height: var(--bsi-navbar-link-line-height);
|
|
248
|
+
text-decoration: none;
|
|
249
|
+
}
|
|
250
|
+
.nav-link:hover {
|
|
251
|
+
color: var(--bsi-navbar-link-color);
|
|
252
|
+
text-decoration: underline;
|
|
253
|
+
text-underline-offset: 2px;
|
|
254
|
+
}
|
|
255
|
+
.nav-link.disabled {
|
|
256
|
+
opacity: var(--bsi-navbar-disable-item-opacity);
|
|
257
|
+
cursor: not-allowed;
|
|
258
|
+
pointer-events: none;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.nav-pills {
|
|
262
|
+
--bsi-nav-pills-border-radius: 4px;
|
|
263
|
+
--bsi-nav-pills-link-active-bg: hsl(210, 100%, 40%);
|
|
264
|
+
--bsi-nav-pills-link-active-color: hsl(0, 0%, 100%);
|
|
265
|
+
}
|
|
266
|
+
.nav-pills .nav-link {
|
|
267
|
+
border: 0;
|
|
268
|
+
background: none;
|
|
269
|
+
border-radius: var(--bsi-nav-pills-border-radius);
|
|
270
|
+
}
|
|
271
|
+
.nav-pills .nav-link:disabled {
|
|
272
|
+
border-color: transparent;
|
|
273
|
+
background-color: transparent;
|
|
274
|
+
color: var(--bsi-nav-link-disabled-color);
|
|
275
|
+
}
|
|
276
|
+
.nav-pills .nav-link.active,
|
|
277
|
+
.nav-pills .show > .nav-link {
|
|
278
|
+
color: var(--bsi-nav-pills-link-active-color);
|
|
279
|
+
background-color: var(--bsi-nav-pills-link-active-bg);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.nav-fill > .nav-link,
|
|
283
|
+
.nav-fill .nav-item {
|
|
284
|
+
flex: 1 1 auto;
|
|
285
|
+
text-align: center;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.nav-justified > .nav-link,
|
|
289
|
+
.nav-justified .nav-item {
|
|
290
|
+
flex-basis: 0;
|
|
291
|
+
flex-grow: 1;
|
|
292
|
+
text-align: center;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.nav-fill .nav-item .nav-link,
|
|
296
|
+
.nav-justified .nav-item .nav-link {
|
|
297
|
+
width: 100%;
|
|
298
|
+
}
|
|
36
299
|
|
|
37
|
-
|
|
300
|
+
.tab-content > .tab-pane {
|
|
301
|
+
display: none;
|
|
302
|
+
}
|
|
303
|
+
.tab-content > .active {
|
|
38
304
|
display: block;
|
|
39
|
-
|
|
40
|
-
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.nav-tabs {
|
|
308
|
+
--bsi-tabs-background-color: var(--bsi-color-background-inverse);
|
|
309
|
+
--bsi-tabs-border-color: var(--bsi-color-border-subtle);
|
|
310
|
+
--bsi-tab-text-color: var(--bsi-color-text-secondary);
|
|
311
|
+
--bsi-tab-icon-color: var(--bsi-icon-secondary);
|
|
312
|
+
--bsi-tab-border-radius: var(--bsi-radius-smooth);
|
|
313
|
+
--bsi-tab-border-width: 3px;
|
|
314
|
+
--bsi-tab-padding-x: var(--bsi-spacing-m);
|
|
315
|
+
--bsi-tab-padding-y: var(--bsi-spacing-s);
|
|
316
|
+
--bsi-tab-font-size: var(--bsi-label-font-size);
|
|
317
|
+
--bsi-tab-font-weight: 600;
|
|
318
|
+
--bsi-tab-shadow: 0 12px 25px -20px rgba(0, 0, 0, 0.5);
|
|
319
|
+
--bsi-tab-background-light: var(--bsi-color-background-primary-lighter);
|
|
320
|
+
--bsi-tab-border-color: transparent;
|
|
321
|
+
--bsi-tab-border-width-cards: 2px;
|
|
322
|
+
--bsi-tab-border-color-cards: var(--bsi-color-border-subtle);
|
|
323
|
+
--bsi-tab-add-btn-border: var(--bsi-color-border-primary);
|
|
324
|
+
--bsi-tab-add-btn-color: var(--bsi-color-background-primary);
|
|
325
|
+
--bsi-tab-close-btn-color: var(--bsi-color-text-secondary);
|
|
326
|
+
--bsi-tab-close-btn-color-hover: color-mix(
|
|
327
|
+
in srgb,
|
|
328
|
+
var(--bsi-primary) 90%,
|
|
329
|
+
black 10%
|
|
330
|
+
);
|
|
331
|
+
--bsi-tab-close-btn-color-disabled: var(--bsi-color-text-disabled);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/* stylelint-disable-next-line no-duplicate-selectors */
|
|
335
|
+
.nav-tabs {
|
|
336
|
+
position: relative;
|
|
337
|
+
display: flex;
|
|
338
|
+
flex-wrap: nowrap;
|
|
339
|
+
overflow-x: auto;
|
|
340
|
+
overflow-y: hidden;
|
|
341
|
+
border-bottom-color: var(--bsi-tabs-border-color);
|
|
342
|
+
background-color: var(--bsi-tabs-background-color);
|
|
343
|
+
-webkit-overflow-scrolling: touch;
|
|
344
|
+
}
|
|
345
|
+
.nav-tabs .it-ico:before,
|
|
346
|
+
.nav-tabs .it-ico-lg:before {
|
|
347
|
+
margin-right: 0;
|
|
348
|
+
}
|
|
349
|
+
.nav-tabs.auto .nav-link {
|
|
350
|
+
flex: 1;
|
|
351
|
+
}
|
|
352
|
+
.nav-tabs.auto .nav-item {
|
|
353
|
+
flex: 1;
|
|
354
|
+
text-align: center;
|
|
355
|
+
}
|
|
356
|
+
.nav-tabs.no-border {
|
|
357
|
+
border: none !important;
|
|
358
|
+
}
|
|
359
|
+
.nav-tabs.no-background {
|
|
360
|
+
background-color: transparent;
|
|
361
|
+
}
|
|
362
|
+
.nav-tabs.no-background .nav-item .nav-link.active {
|
|
363
|
+
background-color: transparent;
|
|
364
|
+
}
|
|
365
|
+
.nav-tabs.nav-tabs-icon-text .icon {
|
|
366
|
+
margin-right: 0.5rem;
|
|
367
|
+
}
|
|
368
|
+
.nav-tabs .nav-link {
|
|
369
|
+
display: flex;
|
|
370
|
+
flex: 1 0 auto;
|
|
371
|
+
align-items: center;
|
|
372
|
+
justify-content: center;
|
|
373
|
+
padding: var(--bsi-tab-padding-y) var(--bsi-tab-padding-x);
|
|
374
|
+
background-color: var(--bsi-tab-background-color, transparent);
|
|
375
|
+
border-width: var(--bsi-tab-border-width);
|
|
376
|
+
border-style: solid;
|
|
377
|
+
border-left-width: 0;
|
|
378
|
+
border-top-width: 0;
|
|
379
|
+
border-right-width: 0;
|
|
380
|
+
border-color: transparent;
|
|
381
|
+
border-bottom-width: var(--bsi-tab-border-width);
|
|
382
|
+
border-radius: 0;
|
|
383
|
+
color: var(--bsi-tab-text-color);
|
|
384
|
+
font-size: var(--bsi-tab-font-size);
|
|
385
|
+
font-weight: var(--bsi-tab-font-weight);
|
|
386
|
+
line-height: 1rem;
|
|
387
|
+
text-decoration: none;
|
|
388
|
+
white-space: nowrap;
|
|
389
|
+
}
|
|
390
|
+
@media (min-width: 992px) {
|
|
391
|
+
.nav-tabs .nav-link {
|
|
392
|
+
--bsi-tab-font-size: var(--bsi-label-font-size-l);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
.nav-tabs .nav-link:hover {
|
|
396
|
+
--bsi-tab-text-color: var(--bsi-color-text-secondary-hover);
|
|
397
|
+
}
|
|
398
|
+
.nav-tabs .nav-link.disabled {
|
|
399
|
+
--bsi-tab-text-color: var(--bsi-color-link-disabled);
|
|
400
|
+
cursor: not-allowed;
|
|
401
|
+
}
|
|
402
|
+
.nav-tabs .nav-link[data-focus-mouse=true]:not(.active) {
|
|
403
|
+
border-color: var(--bsi-tab-border-color) !important;
|
|
404
|
+
--bsi-tab-border-color: var(--bsi-color-border-subtle);
|
|
405
|
+
}
|
|
406
|
+
.nav-tabs .nav-link.active, .nav-tabs .nav-link[data-focus-mouse=true]:has(.active), .nav-tabs .nav-link[data-focus-mouse=true]:not(:focus) {
|
|
407
|
+
--bsi-tab-border-color: var(--bsi-color-border-primary);
|
|
408
|
+
--bsi-tab-text-color: var(--bsi-color-text-primary);
|
|
409
|
+
border-color: var(--bsi-tab-border-color) !important;
|
|
410
|
+
}
|
|
411
|
+
.nav-tabs .nav-link.active .icon, .nav-tabs .nav-link[data-focus-mouse=true]:has(.active) .icon, .nav-tabs .nav-link[data-focus-mouse=true]:not(:focus) .icon {
|
|
412
|
+
--bsi-tab-icon-color: var(--bsi-icon-primary);
|
|
413
|
+
}
|
|
414
|
+
.nav-tabs .nav-link:focus:not([data-focus-mouse=true]) {
|
|
415
|
+
box-shadow: inset 0 0 0 2px var(--bsi-color-outline-focus) !important;
|
|
416
|
+
}
|
|
417
|
+
.nav-tabs .nav-link .icon {
|
|
418
|
+
fill: var(--bsi-tab-icon-color);
|
|
419
|
+
}
|
|
420
|
+
.nav-tabs .nav-link .icon:hover {
|
|
421
|
+
--bsi-tab-icon-color: var(--bsi-icon-secondary-hover);
|
|
422
|
+
}
|
|
423
|
+
.disabled .nav-tabs .nav-link .icon {
|
|
424
|
+
fill: var(--bsi-icon-disabled);
|
|
425
|
+
}
|
|
426
|
+
.nav-tabs .nav-item {
|
|
427
|
+
display: flex;
|
|
428
|
+
margin-bottom: 0;
|
|
429
|
+
}
|
|
430
|
+
.nav-tabs.nav-tabs-vertical {
|
|
431
|
+
flex-direction: column;
|
|
432
|
+
border-color: var(--bsi-tabs-border-color);
|
|
433
|
+
border-right-width: 1px;
|
|
434
|
+
border-style: solid;
|
|
435
|
+
border-bottom-width: 0;
|
|
436
|
+
border-left-width: 0;
|
|
437
|
+
border-top-width: 0;
|
|
438
|
+
}
|
|
439
|
+
.nav-tabs.nav-tabs-vertical .nav-link {
|
|
440
|
+
position: relative;
|
|
441
|
+
justify-content: space-between;
|
|
442
|
+
border-right-width: var(--bsi-tab-border-width);
|
|
443
|
+
border-bottom-width: 0;
|
|
444
|
+
white-space: normal;
|
|
445
|
+
}
|
|
446
|
+
.nav-tabs.nav-tabs-vertical .nav-link.justify-content-end .it-ico:before,
|
|
447
|
+
.nav-tabs.nav-tabs-vertical .nav-link.justify-content-end .it-ico-lg:before {
|
|
448
|
+
margin-right: 0;
|
|
449
|
+
}
|
|
450
|
+
.nav-tabs.nav-tabs-vertical.nav-tabs-vertical-background .nav-link.active,
|
|
451
|
+
.nav-tabs.nav-tabs-vertical.nav-tabs-vertical-background .nav-item.show .nav-link {
|
|
452
|
+
--bsi-tab-background-color: var(--bsi-color-background-primary-lighter);
|
|
453
|
+
}
|
|
454
|
+
.nav-tabs.nav-dark {
|
|
455
|
+
--bsi-tabs-border-color: var(--bsi-color-border-subtle);
|
|
456
|
+
--bsi-tabs-background-color: var(--bsi-color-background-secondary-deep);
|
|
457
|
+
}
|
|
458
|
+
.nav-tabs.nav-dark .nav-link {
|
|
459
|
+
--bsi-tab-text-color: var(--bsi-color-text-inverse);
|
|
460
|
+
opacity: 0.75;
|
|
461
|
+
}
|
|
462
|
+
.nav-tabs.nav-dark .nav-link:hover {
|
|
463
|
+
opacity: 1;
|
|
464
|
+
}
|
|
465
|
+
.nav-tabs.nav-dark .nav-link.disabled {
|
|
466
|
+
opacity: 0.5;
|
|
467
|
+
}
|
|
468
|
+
.nav-tabs.nav-dark .nav-link .icon {
|
|
469
|
+
--bsi-tab-icon-color: var(--bsi-color-text-inverse);
|
|
470
|
+
}
|
|
471
|
+
.nav-tabs.nav-dark .nav-link.active,
|
|
472
|
+
.nav-tabs.nav-dark .nav-item.show .nav-link {
|
|
473
|
+
opacity: 1;
|
|
474
|
+
--bsi-tab-border-color: var(--bsi-color-border-inverse);
|
|
475
|
+
}
|
|
476
|
+
.nav-tabs.nav-dark.nav-tabs-vertical .nav-link.active,
|
|
477
|
+
.nav-tabs.nav-dark.nav-tabs-vertical .nav-item.show .nav-link {
|
|
478
|
+
border-bottom: none;
|
|
479
|
+
border-right-color: var(--bsi-color-border-inverse);
|
|
480
|
+
}
|
|
481
|
+
.nav-tabs.nav-tabs-cards::after {
|
|
482
|
+
content: "";
|
|
483
|
+
flex-grow: 1;
|
|
484
|
+
border-bottom: 1px solid var(--bsi-color-border-subtle);
|
|
485
|
+
}
|
|
486
|
+
.nav-tabs.nav-tabs-cards .nav-link {
|
|
487
|
+
--bsi-tab-border-width: 1px;
|
|
488
|
+
border-bottom: var(--bsi-tab-border-width) solid var(--bsi-color-border-subtle);
|
|
489
|
+
position: relative;
|
|
490
|
+
}
|
|
491
|
+
.nav-tabs.nav-tabs-cards .nav-link[data-focus-mouse=true]:not(.active) {
|
|
492
|
+
border-color: transparent;
|
|
493
|
+
}
|
|
494
|
+
.nav-tabs.nav-tabs-cards .nav-link.active, .nav-tabs.nav-tabs-cards .nav-link[data-focus-mouse=true]:not(:focus) {
|
|
495
|
+
--bsi-tab-border-color: var(--bsi-color-border-subtle);
|
|
496
|
+
border-color: var(--bsi-tab-border-color);
|
|
497
|
+
border-top-width: var(--bsi-tab-border-width);
|
|
498
|
+
border-right-width: var(--bsi-tab-border-width);
|
|
499
|
+
border-left-width: var(--bsi-tab-border-width);
|
|
500
|
+
border-bottom-color: transparent !important;
|
|
501
|
+
border-top-left-radius: var(--bsi-tab-border-radius);
|
|
502
|
+
border-top-right-radius: var(--bsi-tab-border-radius);
|
|
503
|
+
}
|
|
504
|
+
.nav-tabs.nav-tabs-editable .nav-item {
|
|
505
|
+
position: relative;
|
|
506
|
+
border-bottom: 0;
|
|
507
|
+
}
|
|
508
|
+
.nav-tabs.nav-tabs-editable .nav-item:last-of-type {
|
|
509
|
+
padding: var(--bsi-tab-padding-y) calc(var(--bsi-tab-padding-x) / 2);
|
|
510
|
+
border-bottom: 1px solid var(--bsi-color-border-subtle);
|
|
511
|
+
}
|
|
512
|
+
.nav-tabs.nav-tabs-editable .nav-tab-add {
|
|
513
|
+
position: relative;
|
|
514
|
+
width: 1.5rem;
|
|
515
|
+
height: 1.5rem;
|
|
516
|
+
margin: -0.2em 1em 0;
|
|
517
|
+
border: 1px solid var(--bsi-color-border-primary);
|
|
518
|
+
border-radius: 50%;
|
|
519
|
+
}
|
|
520
|
+
.nav-tabs.nav-tabs-editable .nav-tab-add:after {
|
|
521
|
+
position: absolute;
|
|
522
|
+
top: 0.278rem;
|
|
523
|
+
left: 0.611rem;
|
|
524
|
+
content: "";
|
|
525
|
+
width: 2px;
|
|
526
|
+
height: 0.778rem;
|
|
527
|
+
background-color: var(--bsi-color-background-primary);
|
|
528
|
+
}
|
|
529
|
+
.nav-tabs.nav-tabs-editable .nav-tab-add:before {
|
|
530
|
+
position: absolute;
|
|
531
|
+
top: 0.611rem;
|
|
532
|
+
left: 0.278rem;
|
|
533
|
+
content: "";
|
|
534
|
+
width: 0.778rem;
|
|
535
|
+
height: 2px;
|
|
536
|
+
background-color: var(--bsi-color-background-primary);
|
|
537
|
+
}
|
|
538
|
+
.nav-tabs.nav-tabs-editable .nav-link {
|
|
539
|
+
padding-right: 3rem;
|
|
540
|
+
}
|
|
541
|
+
.nav-tabs.nav-tabs-editable .nav-link-close {
|
|
542
|
+
position: absolute;
|
|
543
|
+
top: calc(50% - 1rem);
|
|
544
|
+
right: 0.889rem;
|
|
545
|
+
color: var(--bsi-color-text-secondary);
|
|
546
|
+
transition: color 0.2s;
|
|
547
|
+
cursor: pointer;
|
|
548
|
+
}
|
|
549
|
+
.nav-tabs.nav-tabs-editable .nav-link-close .icon {
|
|
550
|
+
fill: var(--bsi-icon-secondary);
|
|
551
|
+
}
|
|
552
|
+
.nav-tabs.nav-tabs-editable .nav-link-close.disabled {
|
|
553
|
+
color: var(--bsi-color-text-disabled);
|
|
554
|
+
cursor: pointer;
|
|
555
|
+
}
|
|
556
|
+
.nav-tabs.nav-tabs-editable .nav-link-close.disabled .icon {
|
|
557
|
+
fill: var(--bsi-icon-disabled);
|
|
558
|
+
}
|
|
559
|
+
.nav-tabs.nav-tabs-editable .nav-link-close:hover {
|
|
560
|
+
color: rgb(0, 91.8, 183.6);
|
|
561
|
+
}
|
|
562
|
+
.nav-tabs.nav-tabs-editable .nav-link-close:hover .icon {
|
|
563
|
+
fill: rgb(0, 91.8, 183.6);
|
|
564
|
+
}
|
|
565
|
+
.nav-tabs.nav-tabs-editable .nav-link-close .it-ico {
|
|
566
|
+
font-size: 0.625rem;
|
|
567
|
+
}
|
|
568
|
+
.nav-tabs.nav-tabs-editable .nav-link-close .it-ico:before {
|
|
569
|
+
margin-right: 0;
|
|
570
|
+
}
|
|
571
|
+
.nav-tabs.nav-tabs-editable .nav-link.active .nav-link-close,
|
|
572
|
+
.nav-tabs.nav-tabs-editable .nav-item.show .nav-link .nav-link-close {
|
|
573
|
+
color: var(--bsi-color-text-primary);
|
|
574
|
+
}
|
|
575
|
+
.nav-tabs.nav-tabs-editable .nav-link.active .nav-link-close .icon,
|
|
576
|
+
.nav-tabs.nav-tabs-editable .nav-item.show .nav-link .nav-link-close .icon {
|
|
577
|
+
fill: var(--bsi-icon-primary);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
.flex-column-reverse .nav-tabs {
|
|
581
|
+
border-top-width: 1px;
|
|
582
|
+
border-bottom-width: 0;
|
|
583
|
+
}
|
|
584
|
+
.flex-column-reverse .nav-tabs .nav-link {
|
|
585
|
+
border-top-width: var(--bsi-tab-border-width);
|
|
586
|
+
border-bottom-width: 0;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
.flex-row-reverse .nav-tabs.nav-tabs-vertical {
|
|
590
|
+
border-right-width: 0;
|
|
591
|
+
border-left-width: 1px;
|
|
592
|
+
}
|
|
593
|
+
.flex-row-reverse .nav-tabs.nav-tabs-vertical .nav-link {
|
|
594
|
+
justify-content: flex-start;
|
|
595
|
+
border-right-width: 0;
|
|
596
|
+
border-bottom-width: 0;
|
|
597
|
+
border-left-width: var(--bsi-tab-border-width);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
.nav-tabs-hidescroll {
|
|
601
|
+
height: 2.667rem;
|
|
602
|
+
overflow: hidden;
|
|
603
|
+
}
|
|
604
|
+
.nav-tabs-hidescroll.hidescroll-ico {
|
|
605
|
+
height: 2.944rem;
|
|
606
|
+
}
|
|
607
|
+
.nav-tabs-hidescroll.hidescroll-ico-lg {
|
|
608
|
+
height: 3.444rem;
|
|
609
|
+
}
|
|
610
|
+
.nav-tabs-hidescroll .nav-tabs {
|
|
611
|
+
padding-bottom: 20px;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
@media (max-width: 767.98px) {
|
|
615
|
+
.nav-tabs {
|
|
616
|
+
box-shadow: 0 12px 25px -20px rgba(0, 0, 0, 0.5);
|
|
617
|
+
}
|
|
618
|
+
.nav-tabs.nav-tabs-vertical, .nav-tabs.nav-tabs-cards {
|
|
619
|
+
box-shadow: none;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
@media (min-width: 1200px) {
|
|
623
|
+
.nav-tabs {
|
|
624
|
+
flex-wrap: wrap;
|
|
625
|
+
overflow-x: hidden;
|
|
626
|
+
}
|
|
627
|
+
.nav-tabs.auto {
|
|
628
|
+
flex-wrap: nowrap;
|
|
629
|
+
}
|
|
630
|
+
.nav-tabs-hidescroll {
|
|
631
|
+
height: auto;
|
|
632
|
+
overflow: initial;
|
|
633
|
+
}
|
|
634
|
+
.nav-tabs-hidescroll.hidescroll-ico, .nav-tabs-hidescroll.hidescroll-ico-lg {
|
|
635
|
+
height: auto;
|
|
636
|
+
}
|
|
637
|
+
.nav-tabs-hidescroll .nav-tabs {
|
|
638
|
+
padding-bottom: 0;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
:host {
|
|
642
|
+
display: flex;
|
|
643
|
+
width: 100%;
|
|
644
|
+
height: 100%;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
::slotted([slot=after-tablist]) {
|
|
648
|
+
flex-shrink: 0;
|
|
649
|
+
align-self: center;
|
|
650
|
+
margin-inline-start: 0.25rem;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
.tabs-wrapper {
|
|
654
|
+
display: flex;
|
|
655
|
+
max-width: 100%;
|
|
656
|
+
flex: 1;
|
|
657
|
+
flex-direction: var(--it-tab_wrapper-flex-dir);
|
|
658
|
+
align-items: var(--it-tab_wrapper-align);
|
|
659
|
+
margin-block: 0.75rem;
|
|
660
|
+
--it-tab_wrapper-flex-dir: column;
|
|
661
|
+
--it-tab_wrapper-align: stretch;
|
|
662
|
+
--it-tab_wrapper-content-flex: initial;
|
|
663
|
+
}
|
|
664
|
+
.tabs-wrapper--vertical {
|
|
665
|
+
--it-tab_wrapper-flex-dir: row;
|
|
666
|
+
--it-tab_wrapper-content-flex: 1;
|
|
667
|
+
}
|
|
668
|
+
.tabs-wrapper--start {
|
|
669
|
+
gap: 24px;
|
|
670
|
+
--it-tab_wrapper-flex-dir: row;
|
|
671
|
+
--it-tab_wrapper-content-flex: 1;
|
|
672
|
+
}
|
|
673
|
+
.tabs-wrapper--end {
|
|
674
|
+
gap: 24px;
|
|
675
|
+
--it-tab_wrapper-flex-dir: row-reverse;
|
|
676
|
+
--it-tab_wrapper-content-flex: 1;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
.nav-row {
|
|
680
|
+
display: flex;
|
|
681
|
+
align-items: center;
|
|
682
|
+
overflow-y: visible;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
.tabs-wrapper--vertical .nav-row,
|
|
686
|
+
.tabs-wrapper--start .nav-row,
|
|
687
|
+
.tabs-wrapper--end .nav-row {
|
|
688
|
+
flex: 0 0 var(--it-tabs-nav-size, 30%);
|
|
689
|
+
flex-direction: column;
|
|
690
|
+
align-items: stretch;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
.tab-content {
|
|
694
|
+
min-width: 0;
|
|
695
|
+
flex: var(--it-tab_wrapper-content-flex, initial);
|
|
696
|
+
margin-top: var(--it-tab_content-mt, 0.5rem);
|
|
697
|
+
}
|
|
698
|
+
.tab-content ::slotted(:not(it-tab-panel)) {
|
|
699
|
+
display: none;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
.tabs-wrapper--vertical .tab-content,
|
|
703
|
+
.tabs-wrapper--start .tab-content,
|
|
704
|
+
.tabs-wrapper--end .tab-content {
|
|
705
|
+
--it-tab_content-mt: 0;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
.tabs-wrapper--bottom {
|
|
709
|
+
flex-direction: column-reverse;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
.tabs-wrapper--bottom .nav-tabs {
|
|
713
|
+
order: 1;
|
|
714
|
+
border-top-width: 1px;
|
|
715
|
+
border-bottom-width: 0;
|
|
716
|
+
margin-top: 0.75rem;
|
|
717
|
+
--it-tab_bw-top: var(--bsi-tab-border-width);
|
|
718
|
+
--it-tab_bw-bottom: 0;
|
|
719
|
+
--it-tab_active-bc-top: var(--bsi-color-border-primary);
|
|
720
|
+
--it-tab_active-bc-bottom: transparent;
|
|
721
|
+
background-color: var(--it-tab_active-bg, var(--bsi-tabs-background-color));
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
.tabs-wrapper--vertical,
|
|
725
|
+
.tabs-wrapper--start,
|
|
726
|
+
.tabs-wrapper--end {
|
|
727
|
+
--it-tab-panel_margin-block: -0.75rem;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
.nav-tabs-vertical {
|
|
731
|
+
height: 100%;
|
|
732
|
+
flex: 1;
|
|
733
|
+
--it-tab_bw-right: var(--bsi-tab-border-width);
|
|
734
|
+
--it-tab_bw-bottom: 0;
|
|
735
|
+
--it-tab_active-bc-right: var(--bsi-color-border-primary);
|
|
736
|
+
--it-tab_active-bc-bottom: transparent;
|
|
737
|
+
--it-tab_justify: flex-start;
|
|
738
|
+
--it-tab_white-space: normal;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
.tabs-wrapper--end .nav-tabs-vertical {
|
|
742
|
+
border-right-width: 0;
|
|
743
|
+
border-left-width: 1px;
|
|
744
|
+
--it-tab_bw-right: 0;
|
|
745
|
+
--it-tab_bw-left: var(--bsi-tab-border-width);
|
|
746
|
+
--it-tab_active-bc-right: transparent;
|
|
747
|
+
--it-tab_active-bc-left: var(--bsi-color-border-primary);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
.nav-tabs-vertical-background {
|
|
751
|
+
--it-tab_active-bg: var(--bsi-tab-background-light);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
.nav-dark {
|
|
755
|
+
--bsi-tab-text-color: var(--bsi-color-text-inverse);
|
|
756
|
+
--bsi-tab-icon-color: var(--bsi-color-text-inverse);
|
|
757
|
+
--it-tab_opacity: 0.75;
|
|
758
|
+
--it-tab_hover-text-color: var(--bsi-color-text-inverse);
|
|
759
|
+
--it-tab_hover-icon-color: var(--bsi-color-text-inverse);
|
|
760
|
+
--it-tab_color-active: var(--bsi-color-text-inverse);
|
|
761
|
+
--it-tab_icon-color-active: var(--bsi-color-text-inverse);
|
|
762
|
+
--it-tab_active-bc-top: var(--bsi-color-border-inverse);
|
|
763
|
+
--it-tab_active-bc-right: var(--bsi-color-border-inverse);
|
|
764
|
+
--it-tab_active-bc-bottom: var(--bsi-color-border-inverse);
|
|
765
|
+
--it-tab_active-bc-left: var(--bsi-color-border-inverse);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
.nav-tabs-cards {
|
|
769
|
+
overflow: visible;
|
|
770
|
+
align-items: flex-end;
|
|
771
|
+
border-bottom: 1px solid var(--bsi-color-border-subtle);
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
.nav-tabs-icon-text {
|
|
775
|
+
--it-tab_gap: var(--bsi-spacing-xs, 0.25rem);
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
.nav-tabs {
|
|
779
|
+
overflow-x: visible !important;
|
|
780
|
+
overflow-y: unset !important;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
.nav-tabs.nav-tabs-cards::after {
|
|
784
|
+
content: none;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
.nav-row.auto {
|
|
788
|
+
flex-wrap: nowrap;
|
|
789
|
+
justify-content: space-between;
|
|
790
|
+
}
|
|
791
|
+
.nav-row.auto > .nav-tabs {
|
|
792
|
+
flex: 1;
|
|
793
|
+
overflow-x: auto !important;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
@media (max-width: 767.98px) {
|
|
797
|
+
.nav-row.auto {
|
|
798
|
+
box-shadow: 0 12px 25px -20px rgba(0, 0, 0, 0.5);
|
|
799
|
+
}
|
|
800
|
+
.nav-row.auto > .nav-tabs {
|
|
801
|
+
box-shadow: none !important;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
.nav-row.nav-tabs-hidescroll > .nav-tabs {
|
|
805
|
+
-ms-overflow-style: none; /* IE / Edge */
|
|
806
|
+
overflow-x: auto !important;
|
|
807
|
+
scrollbar-width: none; /* Firefox */
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
.nav-row.nav-tabs-hidescroll > .nav-tabs::-webkit-scrollbar {
|
|
811
|
+
display: none; /* Chrome, Safari, WebKit */
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
.nav-tabs-hidescroll {
|
|
815
|
+
overflow: hidden;
|
|
816
|
+
height: unset !important;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
.nav-tabs-hidescroll .nav-tabs {
|
|
820
|
+
padding-bottom: 0 !important;
|
|
41
821
|
}`;
|
|
42
822
|
|
|
43
|
-
|
|
823
|
+
/**
|
|
824
|
+
* `it-tabs` è il componente contenitore per un'interfaccia a schede (tab).
|
|
825
|
+
*
|
|
826
|
+
* Gestisce la selezione, la navigazione da tastiera (roving tabindex, frecce, Home, End)
|
|
827
|
+
* e i collegamenti ARIA tra trigger e pannelli.
|
|
828
|
+
*
|
|
829
|
+
* ## Struttura attesa
|
|
830
|
+
*
|
|
831
|
+
* ```html
|
|
832
|
+
* <it-tabs label="Navigazione">
|
|
833
|
+
* <it-tab slot="tab" panel="p1">Tab 1</it-tab>
|
|
834
|
+
* <it-tab slot="tab" panel="p2">Tab 2</it-tab>
|
|
835
|
+
*
|
|
836
|
+
* <it-tab-panel name="p1">Contenuto del primo pannello</it-tab-panel>
|
|
837
|
+
* <it-tab-panel name="p2">Contenuto del secondo pannello</it-tab-panel>
|
|
838
|
+
* </it-tabs>
|
|
839
|
+
* ```
|
|
840
|
+
*
|
|
841
|
+
* @slot tab - Slot nominato per gli elementi `it-tab` (trigger della lista)
|
|
842
|
+
* @slot after-tablist - Slot opzionale per elementi aggiuntivi dopo la lista di tab
|
|
843
|
+
* (es. pulsante "aggiungi"). Appare alla fine della tablist visivamente allineato ai tab.
|
|
844
|
+
* @slot - Slot di default per gli elementi `it-tab-panel` (contenuto)
|
|
845
|
+
*
|
|
846
|
+
* @cssprop [--it-tabs-nav-size=auto] - Larghezza (flex-basis) della tablist in modalità
|
|
847
|
+
* verticale (`placement=start|end`). Accetta qualsiasi valore CSS valido
|
|
848
|
+
* per `flex-basis` (es. `200px`, `25%`, `12rem`). Non ha effetto in modalità orizzontale.
|
|
849
|
+
*
|
|
850
|
+
* @fires it-tabs-change - Emesso quando cambia il pannello attivo.
|
|
851
|
+
* `detail.panel` contiene il nome del pannello attivato.
|
|
852
|
+
* @fires it-tab-close - Emesso (quando `dismissible` è attivo) quando si clicca il pulsante ×,
|
|
853
|
+
* si preme Delete/Backspace, o si ri-attiva il tab già selezionato (doppio tap mobile SR).
|
|
854
|
+
* Il `detail` è tipizzato come {@link ItTabCloseEventDetail}: `detail.panel` e `detail.type`.
|
|
855
|
+
*
|
|
856
|
+
* L'evento è **cancelable**: chiamare `e.preventDefault()` blocca la rimozione automatica.
|
|
857
|
+
* Per eseguire la chiusura standard in un momento a scelta (es. dopo conferma asincrona)
|
|
858
|
+
* richiamare il metodo pubblico `itTabs.close(e.detail.panel)`.
|
|
859
|
+
*/
|
|
860
|
+
let ItTabs = class ItTabs extends BaseComponent {
|
|
44
861
|
constructor() {
|
|
45
862
|
super(...arguments);
|
|
46
|
-
|
|
47
|
-
|
|
863
|
+
/**
|
|
864
|
+
* Testo dell'`aria-label` per la tablist.
|
|
865
|
+
* Obbligatorio quando non è presente un'intestazione visiva adiacente.
|
|
866
|
+
*/
|
|
867
|
+
this.label = '';
|
|
868
|
+
/**
|
|
869
|
+
* Tab a tutta larghezza: i tab occupano l'intera larghezza disponibile.
|
|
870
|
+
* Corrisponde alla classe Bootstrap Italia `.auto` sulla tablist.
|
|
871
|
+
*/
|
|
872
|
+
this.auto = false;
|
|
873
|
+
/**
|
|
874
|
+
* Nasconde visivamente la scrollbar orizzontale della tablist su viewport intermedi
|
|
875
|
+
* (≥ 768px e < 1200px), dove Bootstrap Italia mostra normalmente il tab overflow con scrollbar.
|
|
876
|
+
* Su mobile (< 768px) e su desktop wide (≥ 1200px) il meccanismo viene disattivato automaticamente.
|
|
877
|
+
*
|
|
878
|
+
* Il meccanismo BSI: il wrapper `.nav-row` riceve `overflow: hidden` + altezza fissa che
|
|
879
|
+
* stoppa la scrollbar; `.nav-tabs` riceve `padding-bottom: 20px` che spinge il
|
|
880
|
+
* track della scrollbar sotto il bordo di clip, rendendola invisibile ma preservando lo scroll.
|
|
881
|
+
*
|
|
882
|
+
* Corrisponde alla classe Bootstrap Italia `.nav-tabs-hidescroll` sul wrapper.
|
|
883
|
+
* Ignorato nei layout verticali (`placement="start"` / `placement="end"`) e con `cards`.
|
|
884
|
+
* Usato tipicamente insieme ad `auto`.
|
|
885
|
+
*/
|
|
886
|
+
this.hideScrollbar = false;
|
|
887
|
+
/**
|
|
888
|
+
* Sfondo primario chiaro sul tab selezionato (solo in layout verticale: `placement="start"` o `placement="end"`).
|
|
889
|
+
* Corrisponde alla classe Bootstrap Italia `.nav-tabs-vertical-background`.
|
|
890
|
+
*/
|
|
891
|
+
this.verticalBackground = false;
|
|
892
|
+
/**
|
|
893
|
+
* Variante con sfondo scuro per la tablist.
|
|
894
|
+
* Corrisponde alla classe Bootstrap Italia `.nav-dark`.
|
|
895
|
+
* Ignorato quando `cards` è attivo: le due varianti non sono compatibili.
|
|
896
|
+
*/
|
|
897
|
+
this.dark = false;
|
|
898
|
+
/**
|
|
899
|
+
* Stile "card" per i tab.
|
|
900
|
+
* Corrisponde alla classe Bootstrap Italia `.nav-tabs-cards`.
|
|
901
|
+
*/
|
|
902
|
+
this.cards = false;
|
|
903
|
+
/**
|
|
904
|
+
* Abilita la chiusura dei tab tramite il pulsante × e i tasti Delete/Backspace.
|
|
905
|
+
* Indipendente da `cards`: può essere usato con qualsiasi variante di tab.
|
|
906
|
+
* Quando attivo, ogni `it-tab` mostra il pulsante × e risponde
|
|
907
|
+
* ai tasti Delete/Backspace con l'evento cancelable `it-tab-close`.
|
|
908
|
+
*/
|
|
909
|
+
this.dismissible = false;
|
|
910
|
+
/**
|
|
911
|
+
* Attiva l'animazione "a comparsa" (fade in/out) sui pannelli.
|
|
912
|
+
* Equivale alla classe `.fade` di Bootstrap Italia su ogni `.tab-pane`.
|
|
913
|
+
*/
|
|
914
|
+
this.fade = false;
|
|
915
|
+
/**
|
|
916
|
+
* Posizione della tablist rispetto ai pannelli.
|
|
917
|
+
* - `top` (default): tablist sopra il contenuto
|
|
918
|
+
* - `bottom`: tablist sotto il contenuto
|
|
919
|
+
* - `start`: tablist a sinistra (layout verticale)
|
|
920
|
+
* - `end`: tablist a destra (layout verticale)
|
|
921
|
+
*/
|
|
922
|
+
this.placement = 'top';
|
|
923
|
+
// ─── Internal state ───────────────────────────────────────────────────────
|
|
924
|
+
/**
|
|
925
|
+
* Traccia se almeno uno dei tab contiene un elemento `it-icon`.
|
|
926
|
+
* Determina se applicare la classe `.nav-tabs-icon-text` per ottimizzare
|
|
927
|
+
* lo spazio tra icona e testo.
|
|
928
|
+
*/
|
|
929
|
+
this._hasIcons = false;
|
|
930
|
+
/**
|
|
931
|
+
* Roving tabindex controller: gestisce tabindex e navigazione da tastiera
|
|
932
|
+
* tra gli elementi `it-tab` secondo il pattern WAI-ARIA.
|
|
933
|
+
*
|
|
934
|
+
* La direzione è dinamica: `'horizontal'` per layout orizzontali,
|
|
935
|
+
* `'vertical'` per layout verticali (placement start/end).
|
|
936
|
+
*/
|
|
937
|
+
this.rovingTabindex = new RovingTabindexController(this, {
|
|
938
|
+
getItems: () => this._tabs,
|
|
939
|
+
onSelect: (tab) => this._selectTab(tab),
|
|
940
|
+
selectOnFocus: true,
|
|
941
|
+
// Home/End should activate tabs per WAI-ARIA for this component.
|
|
942
|
+
selectOnHomeEnd: true,
|
|
943
|
+
direction: 'both',
|
|
944
|
+
skipItem: (tab) => tab.disabled,
|
|
945
|
+
});
|
|
946
|
+
/**
|
|
947
|
+
* Intercetta `it-tab-close-request` emesso dal bottone × nello shadow DOM di `it-tab`.
|
|
948
|
+
* Prima di dispatchiare `it-tab-close` all'esterno, sposta il focus su un tab adiacente
|
|
949
|
+
* in modo che l'utente da tastiera non perda il punto di navigazione.
|
|
950
|
+
*/
|
|
951
|
+
this._onTabCloseRequest = (e) => {
|
|
952
|
+
const tab = this._tabs.find((t) => t.panel === e.detail.panel);
|
|
953
|
+
if (tab)
|
|
954
|
+
this._closeTabWithFocusShift(tab, e.detail.type !== 'click');
|
|
955
|
+
};
|
|
956
|
+
// ─── Event handlers ──────────────────────────────────────────────────────
|
|
957
|
+
this._onTabSelect = (e) => {
|
|
958
|
+
const target = e.target;
|
|
959
|
+
if (target.tagName.toLowerCase() === 'it-tab') {
|
|
960
|
+
this._selectTab(target);
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
/**
|
|
964
|
+
* Navigazione da tastiera nella tablist (WAI-ARIA tabs pattern).
|
|
965
|
+
*
|
|
966
|
+
* Orizzontale: ArrowLeft / ArrowRight / Home / End
|
|
967
|
+
* Verticale: ArrowUp / ArrowDown / Home / End
|
|
968
|
+
*
|
|
969
|
+
* La logica di navigazione viene delegata al `RovingTabindexController`
|
|
970
|
+
* che gestisce wrap-around, skip dei disabilitati e aggiornamento dei tabindex.
|
|
971
|
+
*/
|
|
972
|
+
this._onKeyDown = (e) => {
|
|
973
|
+
// Risale il composedPath per trovare l'it-tab che ha originato l'evento
|
|
974
|
+
// (attraversa i confini dello shadow DOM).
|
|
975
|
+
const path = e.composedPath();
|
|
976
|
+
const currentTab = path.find((el) => el instanceof HTMLElement && el.tagName.toLowerCase() === 'it-tab');
|
|
977
|
+
if (!currentTab || currentTab.disabled)
|
|
978
|
+
return;
|
|
979
|
+
// Delete/Backspace quando dismissible è attivo: sposta il focus su un tab adiacente,
|
|
980
|
+
// poi notifica l'esterno di chiudere il tab corrente.
|
|
981
|
+
if ((e.key === 'Delete' || e.key === 'Backspace') && this.dismissible) {
|
|
982
|
+
e.preventDefault();
|
|
983
|
+
this._closeTabWithFocusShift(currentTab, true);
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
// direction='both': tutte e 4 le frecce sono valide in ogni orientamento
|
|
987
|
+
const validKeys = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Home', 'End'];
|
|
988
|
+
if (!validKeys.includes(e.key))
|
|
989
|
+
return;
|
|
990
|
+
// Delega navigazione + aggiornamento tabindex + selezione (via onSelect) al controller.
|
|
991
|
+
this.rovingTabindex.handleKeydown(currentTab, e);
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
// ─── Keyboard navigation ──────────────────────────────────────────────────
|
|
995
|
+
/**
|
|
996
|
+
* Determina se la tablist è in orientamento verticale.
|
|
997
|
+
* Usato sia per il layout che per la direzione della navigazione da tastiera.
|
|
998
|
+
*/
|
|
999
|
+
get _isVertical() {
|
|
1000
|
+
return this.placement === 'start' || this.placement === 'end';
|
|
1001
|
+
}
|
|
1002
|
+
// ─── Lifecycle ───────────────────────────────────────────────────────────
|
|
1003
|
+
connectedCallback() {
|
|
1004
|
+
super.connectedCallback?.();
|
|
1005
|
+
this.addEventListener('keydown', this._onKeyDown);
|
|
1006
|
+
this.addEventListener('it-tab-select', this._onTabSelect);
|
|
1007
|
+
this.addEventListener('it-tab-close-request', this._onTabCloseRequest);
|
|
1008
|
+
}
|
|
1009
|
+
disconnectedCallback() {
|
|
1010
|
+
this.removeEventListener('keydown', this._onKeyDown);
|
|
1011
|
+
this.removeEventListener('it-tab-select', this._onTabSelect);
|
|
1012
|
+
this.removeEventListener('it-tab-close-request', this._onTabCloseRequest);
|
|
1013
|
+
super.disconnectedCallback?.();
|
|
1014
|
+
}
|
|
1015
|
+
firstUpdated(changedProperties) {
|
|
1016
|
+
super.firstUpdated?.(changedProperties);
|
|
1017
|
+
this._initTabs();
|
|
1018
|
+
}
|
|
1019
|
+
updated(changedProperties) {
|
|
1020
|
+
super.updated?.(changedProperties);
|
|
1021
|
+
// Re-sync tab state when dismissible (or cards/fade) change at runtime.
|
|
1022
|
+
if (changedProperties.has('dismissible') || changedProperties.has('cards') || changedProperties.has('fade')) {
|
|
1023
|
+
this._initTabs();
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
// ─── Internal state management ───────────────────────────────────────────
|
|
1027
|
+
/**
|
|
1028
|
+
* Inizializza i tab: attiva il primo tab non disabilitato se nessuno è già attivo,
|
|
1029
|
+
* collega i tab ai pannelli via ARIA e allinea il roving tabindex controller.
|
|
1030
|
+
*/
|
|
1031
|
+
_initTabs() {
|
|
1032
|
+
const tabs = this._tabs;
|
|
1033
|
+
const panels = this._panels;
|
|
1034
|
+
if (!tabs.length)
|
|
1035
|
+
return;
|
|
1036
|
+
// Rileva se almeno un tab contiene un elemento it-icon per applicare la classe icon-text
|
|
1037
|
+
this._hasIcons = tabs.some((tab) => tab.querySelector('it-icon') !== null);
|
|
1038
|
+
const alreadyActive = tabs.find((t) => t.active && !t.disabled);
|
|
1039
|
+
const toActivate = alreadyActive ?? tabs.find((t) => !t.disabled) ?? null;
|
|
1040
|
+
tabs.forEach((tab) => {
|
|
1041
|
+
const isActive = tab === toActivate;
|
|
1042
|
+
// eslint-disable-next-line no-param-reassign
|
|
1043
|
+
tab.active = isActive;
|
|
1044
|
+
const panel = panels.find((p) => p.name === tab.panel);
|
|
1045
|
+
if (panel) {
|
|
1046
|
+
if (!panel.id)
|
|
1047
|
+
panel.id = panel.name;
|
|
1048
|
+
// Imposta aria-labelledby puntando al bottone interno del tab.
|
|
1049
|
+
// Cross-shadow ARIA id reference: funziona nei browser moderni (Chrome 90+, FF 100+, Safari 16+).
|
|
1050
|
+
panel.setAttribute('aria-labelledby', tab.tabId);
|
|
1051
|
+
// Il fade può essere impostato sull'it-tabs (propagato a tutti i pannelli)
|
|
1052
|
+
// o direttamente su singoli it-tab-panel. Non sovrascrivere il valore
|
|
1053
|
+
// già presente sul pannello se l'it-tabs non ha fade.
|
|
1054
|
+
// eslint-disable-next-line no-param-reassign
|
|
1055
|
+
panel.fade = panel.fade || this.fade;
|
|
1056
|
+
// eslint-disable-next-line no-param-reassign
|
|
1057
|
+
panel.active = isActive;
|
|
1058
|
+
}
|
|
1059
|
+
// Propaga la variante cards su ogni it-tab — CSS :host([cards]) può stilare direttamente.
|
|
1060
|
+
// eslint-disable-next-line no-param-reassign
|
|
1061
|
+
tab.cards = this.cards;
|
|
1062
|
+
// Abilita il pulsante × nello shadow DOM di it-tab quando dismissible è attivo.
|
|
1063
|
+
// Nessuna manipolazione del light DOM: sicuro per SSR e framework re-render.
|
|
1064
|
+
// eslint-disable-next-line no-param-reassign
|
|
1065
|
+
tab.dismissible = this.dismissible;
|
|
1066
|
+
// ARIA: shortcut keyboard Delete + Backspace se la chiusura è abilitata.
|
|
1067
|
+
// aria-keyshortcuts è supportato dai browser come attributo; l'annuncio
|
|
1068
|
+
// da parte degli screen reader è best-effort (varia per SR/versione).
|
|
1069
|
+
if (this.dismissible && !tab.disabled) {
|
|
1070
|
+
tab.setAttribute('aria-keyshortcuts', 'Delete Backspace');
|
|
1071
|
+
}
|
|
1072
|
+
else {
|
|
1073
|
+
tab.removeAttribute('aria-keyshortcuts');
|
|
1074
|
+
}
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* Sposta il focus sul tab adiacente (successivo, altrimenti precedente) e
|
|
1079
|
+
* dispatcha `it-tab-close` verso l'esterno.
|
|
1080
|
+
*
|
|
1081
|
+
* Perché NON usiamo `_selectTab` né `rovingTabindex.focusItem`:
|
|
1082
|
+
* - `_selectTab` dispatcha `it-tabs-change`, che può far reagire il consumer
|
|
1083
|
+
* in modo inaspettato (re-render, rimozione sync, ecc.) prima che il focus
|
|
1084
|
+
* sia spostato — causa il "salto" di un tab.
|
|
1085
|
+
* - `rovingTabindex.focusItem` chiama `getItems()` che potrebbe leggere
|
|
1086
|
+
* una lista di tab parzialmente aggiornata se il DOM è cambiato tra
|
|
1087
|
+
* `_selectTab` e la chiamata a `focusItem`.
|
|
1088
|
+
*
|
|
1089
|
+
* Approccio diretto:
|
|
1090
|
+
* 1. Se il tab da chiudere era attivo, aggiorniamo active + pannelli
|
|
1091
|
+
* direttamente (senza eventi intermedi) — così `_initTabs` post-rimozione
|
|
1092
|
+
* trova `alreadyActive = target` e non sceglie il primo della lista.
|
|
1093
|
+
* 2. `target.tabIndex = 0` + `target.focus()` — atomici, nessun `getItems()`
|
|
1094
|
+
* intermedio che potrebbe restituire una lista stale.
|
|
1095
|
+
* 3. Dispatch `it-tab-close` — il consumer rimuove il tab.
|
|
1096
|
+
*
|
|
1097
|
+
* Pattern: WAI-ARIA APG tabs § keyboard Delete.
|
|
1098
|
+
*/
|
|
1099
|
+
/**
|
|
1100
|
+
* Esegue la chiusura fisica senza emettere eventi:
|
|
1101
|
+
* trasferisce lo stato `active` al tab adiacente,
|
|
1102
|
+
* sposta il focus (solo se `moveFocus`) e rimuove dal DOM.
|
|
1103
|
+
*
|
|
1104
|
+
* Chiamato sia come default action di `_closeTabWithFocusShift`
|
|
1105
|
+
* sia direttamente dal metodo pubblico `close()`.
|
|
1106
|
+
*/
|
|
1107
|
+
_executeClose(closingTab, moveFocus) {
|
|
1108
|
+
const tabs = this._tabs;
|
|
1109
|
+
const idx = tabs.indexOf(closingTab);
|
|
1110
|
+
const after = tabs.slice(idx + 1).find((t) => !t.disabled);
|
|
1111
|
+
const before = tabs
|
|
1112
|
+
.slice(0, idx)
|
|
1113
|
+
.reverse()
|
|
1114
|
+
.find((t) => !t.disabled);
|
|
1115
|
+
const target = after ?? before ?? null;
|
|
1116
|
+
if (target) {
|
|
1117
|
+
if (closingTab.active) {
|
|
1118
|
+
// Trasferisce lo stato active al target in modo sincrono,
|
|
1119
|
+
// così _initTabs (dopo lo slotchange) lo trova già attivo.
|
|
1120
|
+
tabs.forEach((t) => {
|
|
1121
|
+
// eslint-disable-next-line no-param-reassign
|
|
1122
|
+
t.active = t === target;
|
|
1123
|
+
});
|
|
1124
|
+
this._panels.forEach((p) => {
|
|
1125
|
+
// eslint-disable-next-line no-param-reassign
|
|
1126
|
+
p.active = p.name === target.panel;
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
// Focus sincrono: tabIndex=0 garantisce che focus() funzioni anche se Lit
|
|
1130
|
+
// non ha ancora aggiornato il DOM (active → tabIndex avviene async in updated).
|
|
1131
|
+
// Avviene solo da tastiera (Delete/Backspace), non da click × o chiamata pubblica.
|
|
1132
|
+
if (moveFocus) {
|
|
1133
|
+
target.tabIndex = 0;
|
|
1134
|
+
target.focus();
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
const panelEl = this._panels.find((p) => p.name === closingTab.panel);
|
|
1138
|
+
closingTab.remove();
|
|
1139
|
+
panelEl?.remove();
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Dispatcha `it-tab-close` (cancelable) e — se non viene chiamato `preventDefault()` —
|
|
1143
|
+
* esegue la chiusura standard tramite `_executeClose`.
|
|
1144
|
+
*
|
|
1145
|
+
* Il consumer che chiama `e.preventDefault()` può poi invocare
|
|
1146
|
+
* `itTabs.close(e.detail.panel)` per eseguire la chiusura standard.
|
|
1147
|
+
*/
|
|
1148
|
+
_closeTabWithFocusShift(closingTab, moveFocus) {
|
|
1149
|
+
const event = new CustomEvent('it-tab-close', {
|
|
1150
|
+
bubbles: true,
|
|
1151
|
+
composed: true,
|
|
1152
|
+
cancelable: true,
|
|
1153
|
+
detail: { panel: closingTab.panel, type: moveFocus ? 'keydown' : 'click' },
|
|
1154
|
+
});
|
|
1155
|
+
this.dispatchEvent(event);
|
|
1156
|
+
if (!event.defaultPrevented) {
|
|
1157
|
+
this._executeClose(closingTab, moveFocus);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Chiude il tab associato al pannello `panel`, trasferendo lo stato `active`
|
|
1162
|
+
* al tab adiacente e rimuovendo `it-tab` + `it-tab-panel` dal DOM.
|
|
1163
|
+
*
|
|
1164
|
+
* Metodo pubblico pensato per essere chiamato dopo aver intercettato
|
|
1165
|
+
* `it-tab-close` con `e.preventDefault()` — ad esempio al termine di
|
|
1166
|
+
* una conferma asincrona:
|
|
1167
|
+
*
|
|
1168
|
+
* ```js
|
|
1169
|
+
* itTabs.addEventListener('it-tab-close', async (e) => {
|
|
1170
|
+
* e.preventDefault();
|
|
1171
|
+
* if (await myModal.confirm('Chiudere?')) itTabs.close(e.detail.panel);
|
|
1172
|
+
* });
|
|
1173
|
+
* ```
|
|
1174
|
+
*
|
|
1175
|
+
* Noop se `dismissible` non è attivo o il pannello non esiste.
|
|
1176
|
+
* Non ri-emette `it-tab-close`.
|
|
1177
|
+
*/
|
|
1178
|
+
close(panel) {
|
|
1179
|
+
if (!this.dismissible)
|
|
1180
|
+
return;
|
|
1181
|
+
const tab = this._tabs.find((t) => t.panel === panel);
|
|
1182
|
+
if (tab)
|
|
1183
|
+
this._executeClose(tab, false);
|
|
1184
|
+
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Aggiunge un `it-tab` e il relativo `it-tab-panel` al componente.
|
|
1187
|
+
*
|
|
1188
|
+
* Il tab viene inserito prima dell'elemento `slot="after-tablist"` se presente
|
|
1189
|
+
* (in modo da restare all'interno della tablist prima del pulsante aggiungi),
|
|
1190
|
+
* altrimenti in fondo alla lista. Il pannello è sempre appeso in fondo.
|
|
1191
|
+
*
|
|
1192
|
+
* ```js
|
|
1193
|
+
* const tab = document.createElement('it-tab');
|
|
1194
|
+
* tab.setAttribute('slot', 'tab');
|
|
1195
|
+
* tab.setAttribute('panel', 'p5');
|
|
1196
|
+
* tab.textContent = 'Tab 5';
|
|
1197
|
+
* const panel = document.createElement('it-tab-panel');
|
|
1198
|
+
* panel.setAttribute('name', 'p5');
|
|
1199
|
+
* panel.textContent = 'Contenuto 5';
|
|
1200
|
+
* itTabs.addTab(tab, panel);
|
|
1201
|
+
* ```
|
|
1202
|
+
*/
|
|
1203
|
+
addTab(tab, panel) {
|
|
1204
|
+
const afterTablist = this.querySelector('[slot="after-tablist"]');
|
|
1205
|
+
if (afterTablist) {
|
|
1206
|
+
this.insertBefore(tab, afterTablist);
|
|
1207
|
+
}
|
|
1208
|
+
else {
|
|
1209
|
+
this.appendChild(tab);
|
|
1210
|
+
}
|
|
1211
|
+
this.appendChild(panel);
|
|
48
1212
|
}
|
|
49
|
-
|
|
50
|
-
|
|
1213
|
+
/**
|
|
1214
|
+
* Seleziona il tab indicato e aggiorna tutti gli stati (tab attivo, pannello visibile,
|
|
1215
|
+
* tabindex sul roving controller).
|
|
1216
|
+
*/
|
|
1217
|
+
_selectTab(targetTab) {
|
|
1218
|
+
if (targetTab.disabled)
|
|
1219
|
+
return;
|
|
1220
|
+
const tabs = this._tabs;
|
|
1221
|
+
const panels = this._panels;
|
|
1222
|
+
tabs.forEach((tab) => {
|
|
1223
|
+
const isTarget = tab === targetTab;
|
|
1224
|
+
// eslint-disable-next-line no-param-reassign
|
|
1225
|
+
tab.active = isTarget;
|
|
1226
|
+
const panel = panels.find((p) => p.name === tab.panel);
|
|
1227
|
+
if (panel) {
|
|
1228
|
+
// eslint-disable-next-line no-param-reassign
|
|
1229
|
+
panel.active = isTarget;
|
|
1230
|
+
}
|
|
1231
|
+
});
|
|
1232
|
+
this.dispatchEvent(new CustomEvent('it-tabs-change', {
|
|
1233
|
+
bubbles: true,
|
|
1234
|
+
composed: true,
|
|
1235
|
+
detail: { panel: targetTab.panel },
|
|
1236
|
+
}));
|
|
51
1237
|
}
|
|
1238
|
+
// ─── Slot change handlers ────────────────────────────────────────────────
|
|
1239
|
+
_onTabSlotChange() {
|
|
1240
|
+
this._initTabs();
|
|
1241
|
+
}
|
|
1242
|
+
_onPanelSlotChange() {
|
|
1243
|
+
this._initTabs();
|
|
1244
|
+
}
|
|
1245
|
+
// ─── Render ──────────────────────────────────────────────────────────────
|
|
52
1246
|
render() {
|
|
1247
|
+
const isVertical = this._isVertical;
|
|
1248
|
+
const tablistClasses = classMap({
|
|
1249
|
+
nav: true,
|
|
1250
|
+
'nav-tabs': true,
|
|
1251
|
+
auto: this.auto && !isVertical,
|
|
1252
|
+
'nav-dark': this.dark && !this.cards,
|
|
1253
|
+
'nav-tabs-vertical': isVertical,
|
|
1254
|
+
'nav-tabs-vertical-background': isVertical && this.verticalBackground,
|
|
1255
|
+
'nav-tabs-icon-text': this._hasIcons,
|
|
1256
|
+
'nav-tabs-cards': this.cards,
|
|
1257
|
+
});
|
|
1258
|
+
const rowClasses = classMap({
|
|
1259
|
+
'nav-row': true,
|
|
1260
|
+
auto: this.auto && !isVertical,
|
|
1261
|
+
'nav-tabs-hidescroll': this.hideScrollbar && !isVertical && !this.cards,
|
|
1262
|
+
// 'hidescroll-ico': this.hideScrollbar && this.iconText && !isVertical && !this.cards,
|
|
1263
|
+
});
|
|
1264
|
+
const wrapperClasses = classMap({
|
|
1265
|
+
'tabs-wrapper': true,
|
|
1266
|
+
'tabs-wrapper--bottom': this.placement === 'bottom',
|
|
1267
|
+
'tabs-wrapper--start': this.placement === 'start',
|
|
1268
|
+
'tabs-wrapper--end': this.placement === 'end',
|
|
1269
|
+
'tabs-wrapper--vertical': isVertical,
|
|
1270
|
+
});
|
|
53
1271
|
return html `
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
1272
|
+
<div class=${wrapperClasses}>
|
|
1273
|
+
<div class=${rowClasses}>
|
|
1274
|
+
<div
|
|
1275
|
+
class=${tablistClasses}
|
|
1276
|
+
role="tablist"
|
|
1277
|
+
part="tablist"
|
|
1278
|
+
aria-label=${ifDefined(this.label || undefined)}
|
|
1279
|
+
aria-orientation=${isVertical ? 'vertical' : 'horizontal'}
|
|
1280
|
+
>
|
|
1281
|
+
<slot name="tab" @slotchange=${this._onTabSlotChange}></slot>
|
|
1282
|
+
</div>
|
|
1283
|
+
<slot name="after-tablist"></slot>
|
|
1284
|
+
</div>
|
|
1285
|
+
<div class="tab-content" part="tab-content">
|
|
1286
|
+
<slot @slotchange=${this._onPanelSlotChange}></slot>
|
|
1287
|
+
</div>
|
|
1288
|
+
</div>
|
|
58
1289
|
`;
|
|
59
1290
|
}
|
|
60
1291
|
};
|
|
61
1292
|
ItTabs.styles = styles;
|
|
1293
|
+
ItTabs.shadowRootOptions = { ...BaseComponent.shadowRootOptions, delegatesFocus: true };
|
|
1294
|
+
__decorate([
|
|
1295
|
+
property({ type: String, reflect: true }),
|
|
1296
|
+
__metadata("design:type", Object)
|
|
1297
|
+
], ItTabs.prototype, "label", void 0);
|
|
1298
|
+
__decorate([
|
|
1299
|
+
property({ type: Boolean, reflect: true }),
|
|
1300
|
+
__metadata("design:type", Object)
|
|
1301
|
+
], ItTabs.prototype, "auto", void 0);
|
|
1302
|
+
__decorate([
|
|
1303
|
+
property({ type: Boolean, attribute: 'hide-scrollbar', reflect: true }),
|
|
1304
|
+
__metadata("design:type", Object)
|
|
1305
|
+
], ItTabs.prototype, "hideScrollbar", void 0);
|
|
1306
|
+
__decorate([
|
|
1307
|
+
property({ type: Boolean, attribute: 'vertical-background', reflect: true }),
|
|
1308
|
+
__metadata("design:type", Object)
|
|
1309
|
+
], ItTabs.prototype, "verticalBackground", void 0);
|
|
62
1310
|
__decorate([
|
|
63
|
-
property({ type:
|
|
1311
|
+
property({ type: Boolean, reflect: true }),
|
|
64
1312
|
__metadata("design:type", Object)
|
|
65
|
-
], ItTabs.prototype, "
|
|
1313
|
+
], ItTabs.prototype, "dark", void 0);
|
|
66
1314
|
__decorate([
|
|
67
|
-
property({ type:
|
|
1315
|
+
property({ type: Boolean, reflect: true }),
|
|
68
1316
|
__metadata("design:type", Object)
|
|
69
|
-
], ItTabs.prototype, "
|
|
1317
|
+
], ItTabs.prototype, "cards", void 0);
|
|
1318
|
+
__decorate([
|
|
1319
|
+
property({ type: Boolean, reflect: true }),
|
|
1320
|
+
__metadata("design:type", Object)
|
|
1321
|
+
], ItTabs.prototype, "dismissible", void 0);
|
|
1322
|
+
__decorate([
|
|
1323
|
+
property({ type: Boolean, reflect: true }),
|
|
1324
|
+
__metadata("design:type", Object)
|
|
1325
|
+
], ItTabs.prototype, "fade", void 0);
|
|
1326
|
+
__decorate([
|
|
1327
|
+
property({ type: String, reflect: true }),
|
|
1328
|
+
__metadata("design:type", String)
|
|
1329
|
+
], ItTabs.prototype, "placement", void 0);
|
|
1330
|
+
__decorate([
|
|
1331
|
+
state(),
|
|
1332
|
+
__metadata("design:type", Object)
|
|
1333
|
+
], ItTabs.prototype, "_hasIcons", void 0);
|
|
1334
|
+
__decorate([
|
|
1335
|
+
queryAssignedElements({ slot: 'tab', selector: 'it-tab' }),
|
|
1336
|
+
__metadata("design:type", Array)
|
|
1337
|
+
], ItTabs.prototype, "_tabs", void 0);
|
|
1338
|
+
__decorate([
|
|
1339
|
+
queryAssignedElements({ selector: 'it-tab-panel' }),
|
|
1340
|
+
__metadata("design:type", Array)
|
|
1341
|
+
], ItTabs.prototype, "_panels", void 0);
|
|
70
1342
|
ItTabs = __decorate([
|
|
71
1343
|
customElement('it-tabs')
|
|
72
1344
|
], ItTabs);
|