@italia/modal 1.0.0-beta.0 → 1.0.0-beta.2

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 CHANGED
@@ -1,59 +1,11 @@
1
- # \<it-modal>
1
+ # <it-modal>
2
2
 
3
- This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
3
+ This package is part of [dev-kit-italia](https://italia.github.io/dev-kit-italia), a Web Components kit for the **.italia** design-system.
4
4
 
5
- ## Installation
5
+ ## Installation and usage
6
6
 
7
- ```bash
8
- npm i @italia/modal
9
- ```
7
+ Most users want to install the full kit by installing [`@italia/dev-kit-italia`](https://npmjs.com/package/@italia/dev-kit-italia), but you have the option of installing this single Web Component separately if needed. Please find detailed installation and usage instructions in the [official documentation](https://italia.github.io/dev-kit-italia/?path=/docs/introduzione--documentazione).
10
8
 
11
- ## Usage
9
+ ## Documentation
12
10
 
13
- ```html
14
- <script type="module">
15
- import '@italia/modal';
16
- </script>
17
- ```
18
-
19
- ## Running locally
20
-
21
- ```bash
22
- npm start
23
- ```
24
-
25
- To run a local development server that serves the basic demo located in `demo/index.html`
26
-
27
- ## Testing
28
-
29
- ```bash
30
- npm run test
31
- ```
32
-
33
- ## Linting and formatting
34
-
35
- To scan the project for linting and formatting errors, run
36
-
37
- ```bash
38
- npm run lint
39
- ```
40
-
41
- To automatically fix linting and formatting errors, run
42
-
43
- ```bash
44
- npm run format
45
- ```
46
-
47
- ## Tooling configs
48
-
49
- For most of the tools, the configuration is in the `package.json` to minimize the amount of files in your project.
50
-
51
- If you customize the configuration a lot, you can consider moving them to individual files.
52
-
53
- ## Local Demo with `web-dev-server`
54
-
55
- ```bash
56
- npm start
57
- ```
58
-
59
- To run a local development server that serves the basic demo located in `demo/index.html`
11
+ Find the usage instructions for this specific component in its [dedicated documentation page](https://italia.github.io/dev-kit-italia/?path=/docs/componenti-modal--documentazione).
@@ -190,6 +190,16 @@
190
190
  "attribute": "footer-shadow",
191
191
  "reflects": true
192
192
  },
193
+ {
194
+ "kind": "field",
195
+ "name": "defaultFocusClose",
196
+ "type": {
197
+ "text": "boolean"
198
+ },
199
+ "default": "false",
200
+ "attribute": "default-focus-close",
201
+ "reflects": true
202
+ },
193
203
  {
194
204
  "kind": "field",
195
205
  "name": "_modalElement",
@@ -238,6 +248,22 @@
238
248
  },
239
249
  "privacy": "private"
240
250
  },
251
+ {
252
+ "kind": "field",
253
+ "name": "_contentElement",
254
+ "type": {
255
+ "text": "HTMLElement"
256
+ },
257
+ "privacy": "private"
258
+ },
259
+ {
260
+ "kind": "field",
261
+ "name": "_closeButton",
262
+ "type": {
263
+ "text": "HTMLElement"
264
+ },
265
+ "privacy": "private"
266
+ },
241
267
  {
242
268
  "kind": "field",
243
269
  "name": "_titleId",
@@ -372,7 +398,7 @@
372
398
  "text": "FocusTrapController"
373
399
  },
374
400
  "privacy": "private",
375
- "default": "new FocusTrapController(this, { getContainer: () => this._modalElement, initialFocus: () => this._modalElement, getTrigger: () => this._triggerElement, onEscape: () => { this._safariMouseInteraction = false; this.hide(); }, })"
401
+ "default": "new FocusTrapController(this, { getContainer: () => this._modalElement, initialFocus: () => this._entryPoint(), getTrigger: () => this._triggerElement, onEscape: () => { this._safariMouseInteraction = false; this.hide(); }, })"
376
402
  },
377
403
  {
378
404
  "kind": "field",
@@ -382,6 +408,17 @@
382
408
  },
383
409
  "readonly": true
384
410
  },
411
+ {
412
+ "kind": "method",
413
+ "name": "_entryPoint",
414
+ "privacy": "private",
415
+ "return": {
416
+ "type": {
417
+ "text": "HTMLElement | null"
418
+ }
419
+ },
420
+ "description": "Element the focus enters on when the modal opens.\n\nDeliberately not the `[role=\"dialog\"]` element: NVDA doesn't announce the role when focus\nlands on the dialog element itself (nvaccess/nvda#8620), so the user is told the name of the\nmodal but never that it is a dialog — unlike VoiceOver, JAWS and Narrator, which announce it.\nEntering on a descendant instead has the dialog announced as its ancestor, role included.\n`.modal-content` is a container and not a control, so its content is still read out after the\nannouncement, exactly as it was when focus landed on the dialog."
421
+ },
385
422
  {
386
423
  "kind": "method",
387
424
  "name": "show",
@@ -648,6 +685,14 @@
648
685
  },
649
686
  "default": "false",
650
687
  "fieldName": "footerShadow"
688
+ },
689
+ {
690
+ "name": "default-focus-close",
691
+ "type": {
692
+ "text": "boolean"
693
+ },
694
+ "default": "false",
695
+ "fieldName": "defaultFocusClose"
651
696
  }
652
697
  ],
653
698
  "superclass": {
@@ -740,7 +785,7 @@
740
785
  {
741
786
  "kind": "variable",
742
787
  "name": "meta",
743
- "default": "{ title: 'Componenti/Modal', component: 'it-modal', tags: ['alpha', 'a11y-ok', 'web-component'], parameters: { layout: 'fullscreen', docs: { story: { inline: false, iframeHeight: 420, }, }, }, args: { 'modal-title': 'Titolo modale', 'modal-description': 'Descrizione della modale', 'custom-header': false, size: '', position: undefined, scrollable: false, 'static-backdrop': false, 'hide-close-button': false, 'close-button-placement': 'header', variant: '', 'close-label': 'Chiudi finestra modale', 'disable-animation': false, 'footer-shadow': false, triggerLabel: 'Apri modale', bodyContent: 'Contenuto della modale. Può includere testo, form, o qualsiasi altro elemento.', }, argTypes: { 'modal-title': { control: 'text', description: 'Titolo della modale (usa slot `header` per contenuto custom)', }, 'modal-description': { control: 'text', description: 'Descrizione della modale (usa slot `description` per contenuto custom), verrrà inserita in un elemento visivamente nascosto per i lettori di schermo.', }, 'custom-header': { control: 'boolean', description: \"Abilita header custom. In questo modo è possibile inserire un header personalizzato tramite slot, altrimenti lo slot header verrà inserito all'interno di un `h2` con classi predefinite per garantire la corretta semantica e accessibilità.\", table: { defaultValue: { summary: 'false' } }, }, size: { control: 'select', options: MODAL_SIZES, description: 'Dimensione della modale', table: { defaultValue: { summary: undefined } }, }, position: { control: 'select', options: MODAL_POSITIONS, description: 'Posizionamento della modale', table: { defaultValue: { summary: undefined } }, }, scrollable: { control: 'boolean', description: 'Abilita scroll interno al body', table: { defaultValue: { summary: 'false' } }, }, 'static-backdrop': { control: 'boolean', description: 'Disabilita chiusura su click backdrop', table: { defaultValue: { summary: 'false' } }, }, 'hide-close-button': { control: 'boolean', description: 'Nasconde il pulsante di chiusura', }, 'close-button-placement': { control: 'select', options: ['header', 'backdrop'], description: 'Posizione del pulsante di chiusura: `header` (default) o `backdrop`', table: { defaultValue: { summary: 'header' } }, }, variant: { control: 'select', options: MODAL_VARIANTS, description: 'Variante della modale', table: { defaultValue: { summary: undefined } }, }, 'close-label': { control: 'text', description: 'Etichetta accessibile per il pulsante di chiusura', table: { defaultValue: { summary: 'Chiudi finestra modale' } }, }, 'disable-animation': { control: 'boolean', description: 'Disabilita animazione fade', }, 'footer-shadow': { control: 'boolean', description: 'Ombra sul footer per contenuti lunghi', table: { defaultValue: { summary: 'false' } }, }, triggerLabel: { table: { disable: true }, }, bodyContent: { table: { disable: true }, }, }, } satisfies Meta<ModalProps>"
788
+ "default": "{ title: 'Componenti/Modal', component: 'it-modal', tags: ['a11y-ok', 'web-component'], parameters: { layout: 'fullscreen', docs: { story: { inline: false, iframeHeight: 420, }, }, }, args: { 'modal-title': 'Titolo modale', 'modal-description': 'Descrizione della modale', 'custom-header': false, size: '', position: undefined, scrollable: false, 'static-backdrop': false, 'hide-close-button': false, 'close-button-placement': 'header', variant: '', 'close-label': 'Chiudi finestra modale', 'default-focus-close': false, 'disable-animation': false, 'footer-shadow': false, triggerLabel: 'Apri modale', bodyContent: 'Contenuto della modale. Può includere testo, form, o qualsiasi altro elemento.', }, argTypes: { 'modal-title': { control: 'text', description: 'Titolo della modale (usa slot `header` per contenuto custom)', }, 'modal-description': { control: 'text', description: 'Descrizione della modale (usa slot `description` per contenuto custom), verrrà inserita in un elemento visivamente nascosto per i lettori di schermo.', }, 'custom-header': { control: 'boolean', description: \"Abilita header custom. In questo modo è possibile inserire un header personalizzato tramite slot, altrimenti lo slot header verrà inserito all'interno di un `h2` con classi predefinite per garantire la corretta semantica e accessibilità.\", table: { defaultValue: { summary: 'false' } }, }, size: { control: 'select', options: MODAL_SIZES, description: 'Dimensione della modale', table: { defaultValue: { summary: undefined } }, }, position: { control: 'select', options: MODAL_POSITIONS, description: 'Posizionamento della modale', table: { defaultValue: { summary: undefined } }, }, scrollable: { control: 'boolean', description: 'Abilita scroll interno al body', table: { defaultValue: { summary: 'false' } }, }, 'static-backdrop': { control: 'boolean', description: 'Disabilita chiusura su click backdrop', table: { defaultValue: { summary: 'false' } }, }, 'hide-close-button': { control: 'boolean', description: 'Nasconde il pulsante di chiusura', }, 'close-button-placement': { control: 'select', options: ['header', 'backdrop'], description: 'Posizione del pulsante di chiusura: `header` (default) o `backdrop`', table: { defaultValue: { summary: 'header' } }, }, variant: { control: 'select', options: MODAL_VARIANTS, description: 'Variante della modale', table: { defaultValue: { summary: undefined } }, }, 'close-label': { control: 'text', description: 'Etichetta accessibile per il pulsante di chiusura', table: { defaultValue: { summary: 'Chiudi finestra modale' } }, }, 'default-focus-close': { control: 'boolean', description: \"Forza il focus sul pulsante di chiusura all'apertura della modale\", table: { defaultValue: { summary: 'false' } }, }, 'disable-animation': { control: 'boolean', description: 'Disabilita animazione fade', }, 'footer-shadow': { control: 'boolean', description: 'Ombra sul footer per contenuti lunghi', table: { defaultValue: { summary: 'false' } }, }, triggerLabel: { table: { disable: true }, }, bodyContent: { table: { disable: true }, }, }, } satisfies Meta<ModalProps>"
744
789
  },
745
790
  {
746
791
  "kind": "variable",
@@ -26,12 +26,15 @@ export declare class ItModal extends BaseComponent {
26
26
  closeLabel: string;
27
27
  disableAnimation: boolean;
28
28
  footerShadow: boolean;
29
+ defaultFocusClose: boolean;
29
30
  private _modalElement;
30
31
  private _triggerSlot;
31
32
  private _headerSlot;
32
33
  private _descriptionSlot;
33
34
  private _backdropElement;
34
35
  private _dialogElement;
36
+ private _contentElement;
37
+ private _closeButton;
35
38
  private _titleId;
36
39
  private _triggerId;
37
40
  private _descriptionId;
@@ -52,6 +55,17 @@ export declare class ItModal extends BaseComponent {
52
55
  get _triggerElement(): HTMLElement | null;
53
56
  constructor();
54
57
  connectedCallback(): void;
58
+ /**
59
+ * Element the focus enters on when the modal opens.
60
+ *
61
+ * Deliberately not the `[role="dialog"]` element: NVDA doesn't announce the role when focus
62
+ * lands on the dialog element itself (nvaccess/nvda#8620), so the user is told the name of the
63
+ * modal but never that it is a dialog — unlike VoiceOver, JAWS and Narrator, which announce it.
64
+ * Entering on a descendant instead has the dialog announced as its ancestor, role included.
65
+ * `.modal-content` is a container and not a control, so its content is still read out after the
66
+ * announcement, exactly as it was when focus landed on the dialog.
67
+ */
68
+ private _entryPoint;
55
69
  disconnectedCallback(): void;
56
70
  show(): void;
57
71
  hide(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"it-modal.d.ts","sourceRoot":"","sources":["../../src/it-modal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAA0D,MAAM,iBAAiB,CAAC;AACxG,OAAO,EAAQ,cAAc,EAAE,MAAM,KAAK,CAAC;AAI3C,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAyB,MAAM,YAAY,CAAC;AAqB1G,qBACa,OAAQ,SAAQ,aAAa;IACxC,MAAM,CAAC,MAAM,+BAAU;IAEvB,OAAgB,iBAAiB;;;;;;;MAAgE;IAErD,IAAI,EAAE,OAAO,GAAG,SAAS,CAAa;IAEb,UAAU,SAAM;IAEV,gBAAgB,SAAM;IAEzB,YAAY,UAAS;IAElD,IAAI,EAAE,SAAS,CAAM;IAErB,QAAQ,CAAC,EAAE,aAAa,CAAC;IAExB,UAAU,UAAS;IAEW,cAAc,UAAS;IAErB,eAAe,UAAS;IAEpB,oBAAoB,EAChG,QAAQ,GACR,UAAU,CAAY;IAEiB,OAAO,CAAC,EAAE,YAAY,CAAC;IAEV,WAAW,SAAM;IAEJ,UAAU,SAAM;IAET,gBAAgB,UAAS;IAE7B,YAAY,UAAS;IAEnE,OAAO,CAAC,aAAa,CAAe;IAE/B,OAAO,CAAC,YAAY,CAAmB;IAExC,OAAO,CAAC,WAAW,CAAmB;IAE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1B,MAAM;CAgEP"}
@@ -1795,7 +1795,7 @@ if (typeof window !== 'undefined') {
1795
1795
  window._itAnalytics = window._itAnalytics || {};
1796
1796
  window._itAnalytics = {
1797
1797
  ...window._itAnalytics,
1798
- version: '1.0.0-beta.0',
1798
+ version: '1.0.0-beta.2',
1799
1799
  };
1800
1800
  }
1801
1801
 
@@ -1837,6 +1837,7 @@ var styles = css`@charset "UTF-8";
1837
1837
  }
1838
1838
 
1839
1839
  .modal-dialog-scrollable {
1840
+ --bsi-modal-margin: 0;
1840
1841
  height: calc(100% - var(--bsi-modal-margin) * 2);
1841
1842
  }
1842
1843
  .modal-dialog-scrollable .modal-content {
@@ -1848,6 +1849,7 @@ var styles = css`@charset "UTF-8";
1848
1849
  }
1849
1850
 
1850
1851
  .modal-dialog-centered {
1852
+ --bsi-modal-margin: 0;
1851
1853
  display: flex;
1852
1854
  align-items: center;
1853
1855
  min-height: calc(100% - var(--bsi-modal-margin) * 2);
@@ -1931,6 +1933,10 @@ var styles = css`@charset "UTF-8";
1931
1933
  --bsi-modal-margin: 1.5rem;
1932
1934
  --bsi-modal-box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
1933
1935
  }
1936
+ .modal-dialog-scrollable,
1937
+ .modal-dialog-centered {
1938
+ --bsi-modal-margin: 1.5rem;
1939
+ }
1934
1940
  .modal-dialog {
1935
1941
  max-width: var(--bsi-modal-width);
1936
1942
  }
@@ -2111,10 +2117,17 @@ var styles = css`@charset "UTF-8";
2111
2117
  .modal.popconfirm-modal .modal-dialog .modal-footer {
2112
2118
  justify-content: flex-start;
2113
2119
  }
2120
+ .modal.it-dialog-scrollable .modal-dialog {
2121
+ --bsi-modal-margin: 0.5rem;
2122
+ height: calc(100% - var(--bsi-modal-margin) * 2);
2123
+ margin: var(--bsi-modal-margin) auto;
2124
+ }
2114
2125
  .modal.it-dialog-scrollable .modal-dialog .modal-content {
2115
2126
  display: flex;
2116
2127
  flex-direction: column;
2117
- height: calc(100vh - 208px);
2128
+ height: 100%;
2129
+ max-height: 100%;
2130
+ overflow: hidden;
2118
2131
  border-radius: 0;
2119
2132
  }
2120
2133
  .modal.it-dialog-scrollable .modal-dialog .modal-content .modal-header {
@@ -2130,19 +2143,19 @@ var styles = css`@charset "UTF-8";
2130
2143
  flex-shrink: 0;
2131
2144
  }
2132
2145
  .modal.it-dialog-scrollable .modal-dialog.modal-dialog-left {
2133
- height: 100vh;
2146
+ height: 100%;
2134
2147
  margin: 0 var(--bsi-spacing-m) 0 0;
2135
2148
  }
2136
2149
  .modal.it-dialog-scrollable .modal-dialog.modal-dialog-left .modal-content {
2137
- height: 100vh;
2150
+ height: 100%;
2138
2151
  }
2139
2152
  .modal.it-dialog-scrollable .modal-dialog.modal-dialog-right {
2140
- height: 100vh;
2153
+ height: 100%;
2141
2154
  margin: 0 0 0 var(--bsi-spacing-m);
2142
2155
  float: right;
2143
2156
  }
2144
2157
  .modal.it-dialog-scrollable .modal-dialog.modal-dialog-right .modal-content {
2145
- height: 100vh;
2158
+ height: 100%;
2146
2159
  }
2147
2160
  .modal.fade .modal-dialog {
2148
2161
  transition: var(--bsi-modal-transition);
@@ -2182,20 +2195,17 @@ var styles = css`@charset "UTF-8";
2182
2195
  margin: 0;
2183
2196
  }
2184
2197
  .modal .modal-dialog.modal-dialog-left .modal-content {
2185
- height: 100vh;
2198
+ height: 100%;
2186
2199
  }
2187
2200
  .modal .modal-dialog.modal-dialog-right {
2188
2201
  margin: 0;
2189
2202
  float: right;
2190
2203
  }
2191
2204
  .modal .modal-dialog.modal-dialog-right .modal-content {
2192
- height: 100vh;
2205
+ height: 100%;
2193
2206
  }
2194
2207
  .modal.it-dialog-scrollable .modal-dialog {
2195
- margin: 64px auto;
2196
- }
2197
- .modal.it-dialog-scrollable .modal-dialog .modal-content {
2198
- height: calc(100vh - 128px);
2208
+ --bsi-modal-margin: min(64px, 10vh);
2199
2209
  }
2200
2210
  }
2201
2211
  *,
@@ -3018,6 +3028,7 @@ let ItModal = class ItModal extends BaseComponent {
3018
3028
  this.closeLabel = '';
3019
3029
  this.disableAnimation = false;
3020
3030
  this.footerShadow = false;
3031
+ this.defaultFocusClose = false;
3021
3032
  this._titleId = '';
3022
3033
  this._triggerId = '';
3023
3034
  this._descriptionId = '';
@@ -3083,7 +3094,7 @@ let ItModal = class ItModal extends BaseComponent {
3083
3094
  this._descriptionId = this.generateId('modal-description');
3084
3095
  this._focusTrap = new FocusTrapController(this, {
3085
3096
  getContainer: () => this._modalElement,
3086
- initialFocus: () => this._modalElement,
3097
+ initialFocus: () => this._entryPoint(),
3087
3098
  getTrigger: () => this._triggerElement,
3088
3099
  onEscape: () => {
3089
3100
  this._safariMouseInteraction = false;
@@ -3094,6 +3105,19 @@ let ItModal = class ItModal extends BaseComponent {
3094
3105
  connectedCallback() {
3095
3106
  super.connectedCallback?.();
3096
3107
  }
3108
+ /**
3109
+ * Element the focus enters on when the modal opens.
3110
+ *
3111
+ * Deliberately not the `[role="dialog"]` element: NVDA doesn't announce the role when focus
3112
+ * lands on the dialog element itself (nvaccess/nvda#8620), so the user is told the name of the
3113
+ * modal but never that it is a dialog — unlike VoiceOver, JAWS and Narrator, which announce it.
3114
+ * Entering on a descendant instead has the dialog announced as its ancestor, role included.
3115
+ * `.modal-content` is a container and not a control, so its content is still read out after the
3116
+ * announcement, exactly as it was when focus landed on the dialog.
3117
+ */
3118
+ _entryPoint() {
3119
+ return this.defaultFocusClose ? this._closeButton : (this._contentElement ?? this._modalElement);
3120
+ }
3097
3121
  disconnectedCallback() {
3098
3122
  super.disconnectedCallback?.();
3099
3123
  this._removeTriggerListeners();
@@ -3434,16 +3458,8 @@ let ItModal = class ItModal extends BaseComponent {
3434
3458
  @click="${this._handleBackdropClick}"
3435
3459
  part="modal"
3436
3460
  >
3437
- <!-- TRICK SAFARI ENGINE -->
3438
- <div
3439
- id="safari-focus-anchor"
3440
- tabindex="-1"
3441
- aria-hidden="true"
3442
- style="position: absolute; width: 0; height: 0; outline: none;"
3443
- ></div>
3444
3461
  <div
3445
3462
  class="${classMap(this._modalBodyClasses)}"
3446
- role="document"
3447
3463
  @click="${this._handleDialogClick}"
3448
3464
  part="modal-content-wrapper"
3449
3465
  >
@@ -3451,7 +3467,7 @@ let ItModal = class ItModal extends BaseComponent {
3451
3467
  <div class="visually-hidden" id="${this._descriptionId}">
3452
3468
  <slot name="description" @slotchange="${this._onHeaderSlotChange}">${this.modalDescription}</slot>
3453
3469
  </div>
3454
- <div class="modal-content" part="modal-content">
3470
+ <div class="modal-content" tabindex="-1" part="modal-content">
3455
3471
  <div
3456
3472
  class="${hasHeader || (this.variant !== 'popconfirm' && !this.hideCloseButton) ? 'modal-header' : ''}"
3457
3473
  part="modal-header"
@@ -3544,6 +3560,10 @@ __decorate([
3544
3560
  property({ type: Boolean, attribute: 'footer-shadow', reflect: true }),
3545
3561
  __metadata("design:type", Object)
3546
3562
  ], ItModal.prototype, "footerShadow", void 0);
3563
+ __decorate([
3564
+ property({ type: Boolean, attribute: 'default-focus-close', reflect: true }),
3565
+ __metadata("design:type", Object)
3566
+ ], ItModal.prototype, "defaultFocusClose", void 0);
3547
3567
  __decorate([
3548
3568
  query('[role="dialog"]'),
3549
3569
  __metadata("design:type", HTMLElement)
@@ -3568,6 +3588,14 @@ __decorate([
3568
3588
  query('.modal-dialog'),
3569
3589
  __metadata("design:type", HTMLElement)
3570
3590
  ], ItModal.prototype, "_dialogElement", void 0);
3591
+ __decorate([
3592
+ query('.modal-content'),
3593
+ __metadata("design:type", HTMLElement)
3594
+ ], ItModal.prototype, "_contentElement", void 0);
3595
+ __decorate([
3596
+ query('[part="close-button"]'),
3597
+ __metadata("design:type", HTMLElement)
3598
+ ], ItModal.prototype, "_closeButton", void 0);
3571
3599
  __decorate([
3572
3600
  state(),
3573
3601
  __metadata("design:type", Object)