@italia/tabs 0.0.0 → 1.0.0-alpha.10

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.
@@ -0,0 +1,400 @@
1
+ import { r as registerTranslation, _ as __decorate, a as __metadata, b as BaseLocalizedComponent } from '../index-ijsUlb00.js';
2
+ import { css, html } from 'lit';
3
+ import { property, customElement } from 'lit/decorators.js';
4
+ import 'lit/directive.js';
5
+
6
+ const translation$1 = {
7
+ $code: 'it',
8
+ $name: 'Italiano',
9
+ $dir: 'ltr',
10
+ /**
11
+ * Suggerimento a11y annunciato dallo screen reader sul tab attivo e dismissibile.
12
+ * Informa l'utente che può chiudere il tab riattivando l'elemento
13
+ * (doppio tap con VoiceOver/TalkBack, Invio/Spazio con tastiera)
14
+ * oppure premendo Delete/Backspace sulla tastiera fisica.
15
+ */
16
+ closeActiveTabHint: 'Puoi chiudere questo tab premendo Delete o Backspace da tastiera. Su dispositivi touch, doppio tap per chiudere questo tab.',
17
+ };
18
+
19
+ const translation = {
20
+ $code: 'en',
21
+ $name: 'English',
22
+ $dir: 'ltr',
23
+ /**
24
+ * A11y hint announced by screen readers on the active + dismissible tab.
25
+ * Tells the user they can close the tab by re-activating it
26
+ * (double-tap on VoiceOver/TalkBack, Enter/Space on keyboard)
27
+ * or by pressing Delete/Backspace on a physical keyboard.
28
+ */
29
+ closeActiveTabHint: 'You can close this tab by pressing Delete or Backspace on your keyboard. On touch devices, double tap to close this tab.',
30
+ };
31
+
32
+ var styles = css`/***************************** 1 ****************************************/
33
+ /***************************** 2 ****************************************/
34
+ /***************************** 1 ****************************************/
35
+ /***************************** 2 ****************************************/
36
+ /***************************** 1 ****************************************/
37
+ /***************************** 2 ****************************************/
38
+ /***************************** 3 ****************************************/
39
+ /***************************** 1 ****************************************/
40
+ /***************************** 2 ****************************************/
41
+ /***************************** 3 ****************************************/
42
+ /***************************** NEUTRAL 1 ****************************************/
43
+ /***************************** NEUTRAL 2 ****************************************/
44
+ /***************************** NEUTRAL 2 / 3 ****************************************/
45
+ :host {
46
+ display: flex;
47
+ height: var(--it-tab_height, auto);
48
+ flex: 1 0 auto;
49
+ align-items: center;
50
+ justify-content: var(--it-tab_justify, center);
51
+ padding: var(--it-tab_padding-y, var(--bsi-tab-padding-y)) var(--bsi-tab-padding-x);
52
+ border-style: solid;
53
+ border-radius: var(--it-tab_border-radius, 0);
54
+ border-top-width: var(--it-tab_bw-top, 0);
55
+ border-top-color: var(--it-tab_bc-top, transparent);
56
+ border-right-width: var(--it-tab_bw-right, 0);
57
+ border-right-color: var(--it-tab_bc-right, transparent);
58
+ border-bottom: 1px solid var(--bsi-color-border-subtle);
59
+ border-bottom-width: var(--it-tab_bw-bottom, var(--bsi-tab-border-width));
60
+ border-bottom-color: var(--it-tab_bc-bottom, transparent);
61
+ border-left-width: var(--it-tab_bw-left, 0);
62
+ border-left-color: var(--it-tab_bc-left, transparent);
63
+ appearance: none;
64
+ background: var(--it-tab_bg, transparent);
65
+ color: var(--bsi-tab-text-color, var(--bsi-color-text-secondary));
66
+ cursor: pointer;
67
+ font-family: inherit;
68
+ font-size: var(--bsi-tab-font-size);
69
+ font-weight: var(--bsi-tab-font-weight);
70
+ gap: var(--it-tab_gap, 0);
71
+ line-height: 1rem;
72
+ opacity: var(--it-tab_opacity, 1);
73
+ outline: none;
74
+ text-decoration: none;
75
+ white-space: var(--it-tab_white-space, nowrap);
76
+ --bsi-tab-border-width: 3px;
77
+ --bsi-tab-padding-x: var(--bsi-spacing-m, 1rem);
78
+ --bsi-tab-padding-y: var(--bsi-spacing-s, 0.5rem);
79
+ --bsi-tab-font-size: var(--bsi-label-font-size, 0.875rem);
80
+ --bsi-tab-font-weight: 600;
81
+ --bsi-tab-border-radius: var(--bsi-radius-smooth);
82
+ --bsi-tab-shadow: 0 12px 25px -20px rgba(0, 0, 0, 0.5);
83
+ --bsi-tab-background-light: var(--bsi-color-background-primary-lighter);
84
+ --bsi-tab-border-width-cards: 1px;
85
+ --bsi-tab-border-color-cards: var(--bsi-color-border-subtle);
86
+ }
87
+ @media (min-width: 992px) {
88
+ :host {
89
+ --bsi-tab-font-size: var(--bsi-label-font-size-l);
90
+ }
91
+ }
92
+ :host ::slotted(it-icon) {
93
+ --bsi-icon-default: var(--bsi-tab-icon-color, var(--bsi-icon-secondary));
94
+ }
95
+
96
+ :host(:hover) {
97
+ --bsi-tab-text-color: var(--it-tab_hover-text-color, var(--bsi-color-text-secondary-hover));
98
+ --bsi-tab-icon-color: var(--it-tab_hover-icon-color, var(--bsi-icon-secondary-hover));
99
+ --it-tab_opacity: 1;
100
+ }
101
+
102
+ :host([active]) {
103
+ position: relative;
104
+ z-index: var(--it-tab_active-z-index, auto);
105
+ border-top-color: var(--it-tab_active-bc-top, transparent);
106
+ border-right-color: var(--it-tab_active-bc-right, transparent);
107
+ border-bottom-width: var(--it-tab_active-bw-bottom, var(--it-tab_bw-bottom, var(--bsi-tab-border-width)));
108
+ border-bottom-color: var(--it-tab_active-bc-bottom, var(--bsi-color-border-primary));
109
+ border-left-color: var(--it-tab_active-bc-left, transparent);
110
+ margin-bottom: var(--it-tab_active-mb-offset, 0px);
111
+ background-color: var(--it-tab_active-bg, transparent) !important;
112
+ color: var(--it-tab_color-active, var(--bsi-color-text-primary));
113
+ --it-tab_opacity: 1;
114
+ }
115
+ :host([active]) ::slotted(it-icon) {
116
+ --bsi-icon-default: var(--it-tab_icon-color-active, var(--bsi-icon-primary));
117
+ }
118
+
119
+ :host(:focus-visible) {
120
+ box-shadow: inset 0 0 0 2px var(--bsi-color-outline-focus), inset 0 0 0 5px var(--bsi-color-border-inverse);
121
+ outline: 3px solid transparent;
122
+ }
123
+
124
+ :host([disabled]) {
125
+ color: var(--bsi-color-link-disabled);
126
+ cursor: not-allowed;
127
+ pointer-events: none;
128
+ }
129
+ :host([disabled]) ::slotted(it-icon) {
130
+ --bsi-icon-default: var(--bsi-icon-disabled);
131
+ }
132
+ :host([disabled]) .it-tab-close {
133
+ display: none !important;
134
+ }
135
+
136
+ :host([cards]) {
137
+ height: 54px;
138
+ border-radius: 4px 4px 0 0;
139
+ border-top-width: 1px;
140
+ border-top-color: transparent;
141
+ border-right-width: 1px;
142
+ border-right-color: transparent;
143
+ border-bottom-width: 1px;
144
+ border-bottom-color: transparent;
145
+ border-left-width: 1px;
146
+ border-left-color: transparent;
147
+ background: var(--it-tab_cards-bg, var(--bsi-color-background-inverse));
148
+ }
149
+
150
+ :host([cards][dismissible]) {
151
+ padding-right: 8px;
152
+ }
153
+
154
+ :host([cards][active]) {
155
+ position: relative;
156
+ z-index: 1;
157
+ height: 55px;
158
+ border-top-color: var(--it-tab_cards-border-color, var(--bsi-color-border-subtle));
159
+ border-right-color: var(--it-tab_cards-border-color, var(--bsi-color-border-subtle));
160
+ border-bottom-width: 0;
161
+ border-bottom-color: transparent;
162
+ border-left-color: var(--it-tab_cards-border-color, var(--bsi-color-border-subtle));
163
+ margin-bottom: -1px;
164
+ --it-tab_active-bg: var(--it-tab_cards-bg, var(--bsi-color-background-inverse));
165
+ }
166
+
167
+ .it-tab-close {
168
+ display: inline-flex;
169
+ flex-shrink: 0;
170
+ align-items: center;
171
+ justify-content: center;
172
+ padding: 0.125rem;
173
+ border-radius: 50%;
174
+ color: currentColor;
175
+ cursor: pointer;
176
+ line-height: 1;
177
+ text-decoration: none;
178
+ transition: opacity 0.15s ease, background-color 0.15s ease;
179
+ }
180
+ .it-tab-close:focus-visible {
181
+ box-shadow: inset 0 0 0 2px var(--bsi-color-outline-focus), inset 0 0 0 5px var(--bsi-color-border-inverse);
182
+ outline: 3px solid transparent;
183
+ }`;
184
+
185
+ registerTranslation(translation$1, translation);
186
+ /**
187
+ * `it-tab` rappresenta il singolo tab (trigger) all'interno di un componente `it-tabs`.
188
+ *
189
+ * L'host stesso è l'elemento interattivo: porta `role="tab"`, `tabIndex` e tutti
190
+ * gli attributi ARIA direttamente nel light DOM. Lo shadow DOM contiene solo
191
+ * `<slot>` per il contenuto — nessun elemento interattivo annidato (no nested-interactive).
192
+ *
193
+ * ## Accessibilità dismissible
194
+ *
195
+ * Quando `dismissible` è attivo, il componente imposta automaticamente sull'host:
196
+ *
197
+ * - `aria-keyshortcuts="Delete Backspace"` — annuncia le scorciatoie da tastiera
198
+ * agli screen reader desktop (NVDA, JAWS, VoiceOver+Mac).
199
+ * - `aria-description="Attiva di nuovo per chiudere."` (testo localizzato) — presente
200
+ * **solo** quando il tab è anche `active`; informa l'utente di screen reader mobile
201
+ * (VoiceOver+iOS, TalkBack+Android) che può chiudere il tab ri-attivando l'elemento
202
+ * (doppio tap nel DOM virtuale), senza bisogno di shortcut tastiera.
203
+ *
204
+ * Il click sull'host quando `active && dismissible` emette `it-tab-close-request`
205
+ * **solo** se il gesto viene da touch o pen (doppio tap SR mobile).
206
+ * Un click mouse sull'host non chiude il tab: l'utente usa la × esplicita.
207
+ *
208
+ * @slot - Etichetta del tab: testo, icona o icona+testo
209
+ *
210
+ * @fires it-tab-select - Emesso al click (non disabilitato, non già attivo+dismissibile).
211
+ * `detail.panel` contiene il nome del pannello associato.
212
+ * @fires it-tab-close-request - Emesso al doppio-tap touch/pen quando `active && dismissible`
213
+ * (SR mobile), oppure dal pulsante × interno.
214
+ * `detail.panel` e `detail.type` (`'click'`) propagano verso `it-tabs`.
215
+ */
216
+ let ItTab = class ItTab extends BaseLocalizedComponent {
217
+ constructor() {
218
+ super(...arguments);
219
+ /**
220
+ * Nome del pannello `it-tab-panel` associato.
221
+ * Deve corrispondere all'attributo `name` dell'`it-tab-panel` collegato.
222
+ */
223
+ this.panel = '';
224
+ /** Se `true`, il tab è disabilitato e non interagibile. */
225
+ this.disabled = false;
226
+ /**
227
+ * Stato attivo. Gestito dall'`it-tabs` padre.
228
+ * Quando `true` il tab è selezionato e `tabIndex` dell'host è `0`.
229
+ */
230
+ this.active = false;
231
+ /**
232
+ * In variante card: impostato automaticamente dall'`it-tabs` padre quando `cards` è attivo.
233
+ * Porta gli stili card direttamente su :host([cards]) in it-tab.scss.
234
+ */
235
+ this.cards = false;
236
+ /**
237
+ * Mostra il pulsante × per chiudere il tab.
238
+ * Impostato automaticamente dall'`it-tabs` padre (da `dismissible` sul container);
239
+ * non richiede manipolazione del light DOM (il bottone vive nello shadow DOM di `it-tab`).
240
+ * Al click emette `it-tab-close-request` (bubbles + composed) verso `it-tabs`.
241
+ */
242
+ this.dismissible = false;
243
+ /** Tipo di pointer dell'ultimo pointerdown: 'mouse' | 'touch' | 'pen' | '' */
244
+ this._lastPointerType = '';
245
+ this._handlePointerDown = (e) => {
246
+ this._lastPointerType = e.pointerType;
247
+ };
248
+ this._handleClick = () => {
249
+ if (this.disabled)
250
+ return;
251
+ // Tab già attivo + dismissibile: doppio tap touch/pen (SR mobile) → close-request.
252
+ // Mouse click sull'host NON chiude: l'utente usa la × esplicita.
253
+ if (this.dismissible && this.active && (this._lastPointerType === 'touch' || this._lastPointerType === 'pen')) {
254
+ this.dispatchEvent(new CustomEvent('it-tab-close-request', {
255
+ bubbles: true,
256
+ composed: true,
257
+ detail: { panel: this.panel, type: 'click' },
258
+ }));
259
+ return;
260
+ }
261
+ this.dispatchEvent(new CustomEvent('it-tab-select', {
262
+ bubbles: true,
263
+ composed: true,
264
+ detail: { panel: this.panel },
265
+ }));
266
+ };
267
+ this._handleKeydown = (e) => {
268
+ if (e.key === 'Enter' || e.key === ' ') {
269
+ e.preventDefault();
270
+ // Space/Enter attivano il tab, mai la chiusura.
271
+ // La chiusura tramite tastiera è esclusiva di Delete/Backspace,
272
+ // gestiti da it-tabs._onKeyDown.
273
+ if (this.disabled || this.active)
274
+ return;
275
+ this.dispatchEvent(new CustomEvent('it-tab-select', {
276
+ bubbles: true,
277
+ composed: true,
278
+ detail: { panel: this.panel },
279
+ }));
280
+ }
281
+ };
282
+ this._handleCloseClick = (e) => {
283
+ e.stopPropagation(); // non triggerare selezione del tab
284
+ this.dispatchEvent(new CustomEvent('it-tab-close-request', {
285
+ bubbles: true,
286
+ composed: true,
287
+ detail: { panel: this.panel, type: e.type },
288
+ }));
289
+ };
290
+ }
291
+ /**
292
+ * Restituisce l'`id` dell'host, usato dall'`it-tabs` padre per
293
+ * impostare `aria-labelledby` sul pannello associato (tutto in light DOM,
294
+ * nessun cross-shadow ARIA necessario).
295
+ */
296
+ get tabId() {
297
+ return this.id || this._id || '';
298
+ }
299
+ /** Porta il focus sull'host. Chiamato dal `RovingTabindexController`. */
300
+ focusTab() {
301
+ this.focus();
302
+ }
303
+ connectedCallback() {
304
+ super.connectedCallback?.();
305
+ if (!this.hasAttribute('role'))
306
+ this.setAttribute('role', 'tab');
307
+ if (!this.id)
308
+ this.id = this._id ?? '';
309
+ this.setAttribute('aria-selected', String(this.active));
310
+ this.setAttribute('aria-disabled', String(this.disabled));
311
+ this.setAttribute('aria-controls', this.panel);
312
+ // L'host è l'elemento interattivo: porta lui il tabindex del roving pattern.
313
+ this.tabIndex = this.active ? 0 : -1;
314
+ this._updateDismissibleAria();
315
+ this.addEventListener('pointerdown', this._handlePointerDown);
316
+ this.addEventListener('click', this._handleClick);
317
+ this.addEventListener('keydown', this._handleKeydown);
318
+ }
319
+ disconnectedCallback() {
320
+ super.disconnectedCallback?.();
321
+ this.removeEventListener('pointerdown', this._handlePointerDown);
322
+ this.removeEventListener('click', this._handleClick);
323
+ this.removeEventListener('keydown', this._handleKeydown);
324
+ }
325
+ updated(changed) {
326
+ super.updated?.(changed);
327
+ if (changed.has('active')) {
328
+ this.setAttribute('aria-selected', String(this.active));
329
+ this.tabIndex = this.active ? 0 : -1;
330
+ }
331
+ if (changed.has('disabled'))
332
+ this.setAttribute('aria-disabled', String(this.disabled));
333
+ if (changed.has('panel'))
334
+ this.setAttribute('aria-controls', this.panel);
335
+ if (changed.has('active') || changed.has('dismissible'))
336
+ this._updateDismissibleAria();
337
+ }
338
+ /**
339
+ * Aggiorna gli attributi ARIA legati alla funzionalità dismissible:
340
+ *
341
+ * - `aria-keyshortcuts="Delete Backspace"` — presente sempre quando il tab è dismissibile;
342
+ * annuncia la scorciatoia da tastiera agli screen reader (NVDA, JAWS, VoiceOver+Mac).
343
+ *
344
+ * - `aria-description` — presente solo quando il tab è **sia attivo sia dismissibile**;
345
+ * contiene il testo localizzato (es. "Attiva di nuovo per chiudere.") che informa
346
+ * l'utente mobile (VoiceOver/TalkBack) che può chiudere ri-attivando l'elemento
347
+ * (doppio tap), oltre ai tasti Delete/Backspace già coperti da aria-keyshortcuts.
348
+ */
349
+ _updateDismissibleAria() {
350
+ if (this.dismissible) {
351
+ this.setAttribute('aria-keyshortcuts', 'Delete Backspace');
352
+ }
353
+ else {
354
+ this.removeAttribute('aria-keyshortcuts');
355
+ }
356
+ if (this.dismissible && this.active) {
357
+ this.setAttribute('aria-description', this.localize.term('closeActiveTabHint'));
358
+ }
359
+ else {
360
+ this.removeAttribute('aria-description');
361
+ }
362
+ }
363
+ render() {
364
+ return html `
365
+ <slot></slot>
366
+ ${this.dismissible
367
+ ? html `<span class="it-tab-close" aria-hidden="true" @click=${this._handleCloseClick}>
368
+ <it-icon name="it-close"></it-icon>
369
+ </span>`
370
+ : ''}
371
+ `;
372
+ }
373
+ };
374
+ ItTab.styles = styles;
375
+ __decorate([
376
+ property({ type: String, reflect: true }),
377
+ __metadata("design:type", Object)
378
+ ], ItTab.prototype, "panel", void 0);
379
+ __decorate([
380
+ property({ type: Boolean, reflect: true }),
381
+ __metadata("design:type", Object)
382
+ ], ItTab.prototype, "disabled", void 0);
383
+ __decorate([
384
+ property({ type: Boolean, reflect: true }),
385
+ __metadata("design:type", Object)
386
+ ], ItTab.prototype, "active", void 0);
387
+ __decorate([
388
+ property({ type: Boolean, reflect: true }),
389
+ __metadata("design:type", Object)
390
+ ], ItTab.prototype, "cards", void 0);
391
+ __decorate([
392
+ property({ type: Boolean, reflect: true }),
393
+ __metadata("design:type", Object)
394
+ ], ItTab.prototype, "dismissible", void 0);
395
+ ItTab = __decorate([
396
+ customElement('it-tab')
397
+ ], ItTab);
398
+
399
+ export { ItTab };
400
+ //# sourceMappingURL=it-tab.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"it-tab.js","sources":["../../../src/locales/it.ts","../../../src/locales/en.ts","../../../src/it-tab.ts"],"sourcesContent":["import type { DefaultTranslation } from '@italia/i18n';\n\nconst translation: DefaultTranslation = {\n $code: 'it',\n $name: 'Italiano',\n $dir: 'ltr',\n\n /**\n * Suggerimento a11y annunciato dallo screen reader sul tab attivo e dismissibile.\n * Informa l'utente che può chiudere il tab riattivando l'elemento\n * (doppio tap con VoiceOver/TalkBack, Invio/Spazio con tastiera)\n * oppure premendo Delete/Backspace sulla tastiera fisica.\n */\n closeActiveTabHint:\n 'Puoi chiudere questo tab premendo Delete o Backspace da tastiera. Su dispositivi touch, doppio tap per chiudere questo tab.',\n};\n\nexport default translation;\n","import type { DefaultTranslation } from '@italia/i18n';\n\nconst translation: DefaultTranslation = {\n $code: 'en',\n $name: 'English',\n $dir: 'ltr',\n\n /**\n * A11y hint announced by screen readers on the active + dismissible tab.\n * Tells the user they can close the tab by re-activating it\n * (double-tap on VoiceOver/TalkBack, Enter/Space on keyboard)\n * or by pressing Delete/Backspace on a physical keyboard.\n */\n closeActiveTabHint:\n 'You can close this tab by pressing Delete or Backspace on your keyboard. On touch devices, double tap to close this tab.',\n};\n\nexport default translation;\n","import { html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { BaseLocalizedComponent } from '@italia/globals';\nimport { registerTranslation } from '@italia/i18n';\nimport it from './locales/it.js';\nimport en from './locales/en.js';\n\nimport styles from './it-tab.scss';\n\nregisterTranslation(it, en);\n\n/**\n * `it-tab` rappresenta il singolo tab (trigger) all'interno di un componente `it-tabs`.\n *\n * L'host stesso è l'elemento interattivo: porta `role=\"tab\"`, `tabIndex` e tutti\n * gli attributi ARIA direttamente nel light DOM. Lo shadow DOM contiene solo\n * `<slot>` per il contenuto — nessun elemento interattivo annidato (no nested-interactive).\n *\n * ## Accessibilità dismissible\n *\n * Quando `dismissible` è attivo, il componente imposta automaticamente sull'host:\n *\n * - `aria-keyshortcuts=\"Delete Backspace\"` — annuncia le scorciatoie da tastiera\n * agli screen reader desktop (NVDA, JAWS, VoiceOver+Mac).\n * - `aria-description=\"Attiva di nuovo per chiudere.\"` (testo localizzato) — presente\n * **solo** quando il tab è anche `active`; informa l'utente di screen reader mobile\n * (VoiceOver+iOS, TalkBack+Android) che può chiudere il tab ri-attivando l'elemento\n * (doppio tap nel DOM virtuale), senza bisogno di shortcut tastiera.\n *\n * Il click sull'host quando `active && dismissible` emette `it-tab-close-request`\n * **solo** se il gesto viene da touch o pen (doppio tap SR mobile).\n * Un click mouse sull'host non chiude il tab: l'utente usa la × esplicita.\n *\n * @slot - Etichetta del tab: testo, icona o icona+testo\n *\n * @fires it-tab-select - Emesso al click (non disabilitato, non già attivo+dismissibile).\n * `detail.panel` contiene il nome del pannello associato.\n * @fires it-tab-close-request - Emesso al doppio-tap touch/pen quando `active && dismissible`\n * (SR mobile), oppure dal pulsante × interno.\n * `detail.panel` e `detail.type` (`'click'`) propagano verso `it-tabs`.\n */\n@customElement('it-tab')\nexport class ItTab extends BaseLocalizedComponent {\n static styles = styles;\n\n /**\n * Nome del pannello `it-tab-panel` associato.\n * Deve corrispondere all'attributo `name` dell'`it-tab-panel` collegato.\n */\n @property({ type: String, reflect: true })\n panel = '';\n\n /** Se `true`, il tab è disabilitato e non interagibile. */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /**\n * Stato attivo. Gestito dall'`it-tabs` padre.\n * Quando `true` il tab è selezionato e `tabIndex` dell'host è `0`.\n */\n @property({ type: Boolean, reflect: true })\n active = false;\n\n /**\n * In variante card: impostato automaticamente dall'`it-tabs` padre quando `cards` è attivo.\n * Porta gli stili card direttamente su :host([cards]) in it-tab.scss.\n */\n @property({ type: Boolean, reflect: true })\n cards = false;\n\n /**\n * Mostra il pulsante × per chiudere il tab.\n * Impostato automaticamente dall'`it-tabs` padre (da `dismissible` sul container);\n * non richiede manipolazione del light DOM (il bottone vive nello shadow DOM di `it-tab`).\n * Al click emette `it-tab-close-request` (bubbles + composed) verso `it-tabs`.\n */\n @property({ type: Boolean, reflect: true })\n dismissible = false;\n\n /**\n * Restituisce l'`id` dell'host, usato dall'`it-tabs` padre per\n * impostare `aria-labelledby` sul pannello associato (tutto in light DOM,\n * nessun cross-shadow ARIA necessario).\n */\n get tabId(): string {\n return this.id || this._id || '';\n }\n\n /** Tipo di pointer dell'ultimo pointerdown: 'mouse' | 'touch' | 'pen' | '' */\n private _lastPointerType = '';\n\n /** Porta il focus sull'host. Chiamato dal `RovingTabindexController`. */\n focusTab(): void {\n this.focus();\n }\n\n override connectedCallback(): void {\n super.connectedCallback?.();\n\n if (!this.hasAttribute('role')) this.setAttribute('role', 'tab');\n if (!this.id) this.id = this._id ?? '';\n this.setAttribute('aria-selected', String(this.active));\n this.setAttribute('aria-disabled', String(this.disabled));\n this.setAttribute('aria-controls', this.panel);\n // L'host è l'elemento interattivo: porta lui il tabindex del roving pattern.\n this.tabIndex = this.active ? 0 : -1;\n this._updateDismissibleAria();\n this.addEventListener('pointerdown', this._handlePointerDown);\n this.addEventListener('click', this._handleClick);\n this.addEventListener('keydown', this._handleKeydown);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback?.();\n this.removeEventListener('pointerdown', this._handlePointerDown);\n this.removeEventListener('click', this._handleClick);\n this.removeEventListener('keydown', this._handleKeydown);\n }\n\n override updated(changed: Map<string | number | symbol, unknown>): void {\n super.updated?.(changed);\n if (changed.has('active')) {\n this.setAttribute('aria-selected', String(this.active));\n this.tabIndex = this.active ? 0 : -1;\n }\n if (changed.has('disabled')) this.setAttribute('aria-disabled', String(this.disabled));\n if (changed.has('panel')) this.setAttribute('aria-controls', this.panel);\n if (changed.has('active') || changed.has('dismissible')) this._updateDismissibleAria();\n }\n\n /**\n * Aggiorna gli attributi ARIA legati alla funzionalità dismissible:\n *\n * - `aria-keyshortcuts=\"Delete Backspace\"` — presente sempre quando il tab è dismissibile;\n * annuncia la scorciatoia da tastiera agli screen reader (NVDA, JAWS, VoiceOver+Mac).\n *\n * - `aria-description` — presente solo quando il tab è **sia attivo sia dismissibile**;\n * contiene il testo localizzato (es. \"Attiva di nuovo per chiudere.\") che informa\n * l'utente mobile (VoiceOver/TalkBack) che può chiudere ri-attivando l'elemento\n * (doppio tap), oltre ai tasti Delete/Backspace già coperti da aria-keyshortcuts.\n */\n private _updateDismissibleAria(): void {\n if (this.dismissible) {\n this.setAttribute('aria-keyshortcuts', 'Delete Backspace');\n } else {\n this.removeAttribute('aria-keyshortcuts');\n }\n\n if (this.dismissible && this.active) {\n this.setAttribute('aria-description', this.localize.term('closeActiveTabHint'));\n } else {\n this.removeAttribute('aria-description');\n }\n }\n\n private _handlePointerDown = (e: PointerEvent): void => {\n this._lastPointerType = e.pointerType;\n };\n\n private _handleClick = (): void => {\n if (this.disabled) return;\n // Tab già attivo + dismissibile: doppio tap touch/pen (SR mobile) → close-request.\n // Mouse click sull'host NON chiude: l'utente usa la × esplicita.\n if (this.dismissible && this.active && (this._lastPointerType === 'touch' || this._lastPointerType === 'pen')) {\n this.dispatchEvent(\n new CustomEvent('it-tab-close-request', {\n bubbles: true,\n composed: true,\n detail: { panel: this.panel, type: 'click' },\n }),\n );\n return;\n }\n this.dispatchEvent(\n new CustomEvent('it-tab-select', {\n bubbles: true,\n composed: true,\n detail: { panel: this.panel },\n }),\n );\n };\n\n private _handleKeydown = (e: KeyboardEvent): void => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n // Space/Enter attivano il tab, mai la chiusura.\n // La chiusura tramite tastiera è esclusiva di Delete/Backspace,\n // gestiti da it-tabs._onKeyDown.\n if (this.disabled || this.active) return;\n this.dispatchEvent(\n new CustomEvent('it-tab-select', {\n bubbles: true,\n composed: true,\n detail: { panel: this.panel },\n }),\n );\n }\n };\n\n private _handleCloseClick = (e: Event): void => {\n e.stopPropagation(); // non triggerare selezione del tab\n this.dispatchEvent(\n new CustomEvent('it-tab-close-request', {\n bubbles: true,\n composed: true,\n detail: { panel: this.panel, type: e.type },\n }),\n );\n };\n\n render() {\n return html`\n <slot></slot>\n ${this.dismissible\n ? html`<span class=\"it-tab-close\" aria-hidden=\"true\" @click=${this._handleCloseClick}>\n <it-icon name=\"it-close\"></it-icon>\n </span>`\n : ''}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'it-tab': ItTab;\n }\n}\n"],"names":["translation","it","en"],"mappings":";;;;;AAEA,MAAMA,aAAW,GAAuB;AACtC,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,KAAK,EAAE,UAAU;AACjB,IAAA,IAAI,EAAE,KAAK;AAEX;;;;;AAKG;AACH,IAAA,kBAAkB,EAChB,6HAA6H;CAChI;;ACbD,MAAM,WAAW,GAAuB;AACtC,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,IAAI,EAAE,KAAK;AAEX;;;;;AAKG;AACH,IAAA,kBAAkB,EAChB,0HAA0H;CAC7H;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACND,mBAAmB,CAACC,aAAE,EAAEC,WAAE,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;AAEI,IAAM,KAAK,GAAX,MAAM,KAAM,SAAQ,sBAAsB,CAAA;AAA1C,IAAA,WAAA,GAAA;;AAGL;;;AAGG;QAEH,IAAA,CAAA,KAAK,GAAG,EAAE;;QAIV,IAAA,CAAA,QAAQ,GAAG,KAAK;AAEhB;;;AAGG;QAEH,IAAA,CAAA,MAAM,GAAG,KAAK;AAEd;;;AAGG;QAEH,IAAA,CAAA,KAAK,GAAG,KAAK;AAEb;;;;;AAKG;QAEH,IAAA,CAAA,WAAW,GAAG,KAAK;;QAYX,IAAA,CAAA,g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