@italia/modal 1.0.0-alpha.8 → 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.
@@ -31,26 +31,8 @@
31
31
  "declarations": [
32
32
  {
33
33
  "kind": "class",
34
- "description": "Componente Modal per finestre di dialogo modali.",
34
+ "description": "",
35
35
  "name": "ItModal",
36
- "slots": [
37
- {
38
- "description": "Elemento che apre la modale (es. it-button)",
39
- "name": "trigger"
40
- },
41
- {
42
- "description": "Contenuto principale della modale (body)",
43
- "name": "content"
44
- },
45
- {
46
- "description": "Icona opzionale nell'header",
47
- "name": "header-icon"
48
- },
49
- {
50
- "description": "Azioni del footer (pulsanti)",
51
- "name": "footer"
52
- }
53
- ],
54
36
  "members": [
55
37
  {
56
38
  "kind": "field",
@@ -59,15 +41,15 @@
59
41
  "text": "object"
60
42
  },
61
43
  "static": true,
62
- "default": "{ ...BaseComponent.shadowRootOptions, delegatesFocus: true, }"
44
+ "default": "{ ...BaseComponent.shadowRootOptions, delegatesFocus: true }"
63
45
  },
64
46
  {
65
47
  "kind": "field",
66
48
  "name": "open",
67
49
  "type": {
68
- "text": "boolean"
50
+ "text": "boolean | undefined"
69
51
  },
70
- "default": "false",
52
+ "default": "undefined",
71
53
  "attribute": "open",
72
54
  "reflects": true
73
55
  },
@@ -105,7 +87,7 @@
105
87
  "kind": "field",
106
88
  "name": "position",
107
89
  "type": {
108
- "text": "ModalPosition | undefined | undefined"
90
+ "text": "ModalPosition | undefined"
109
91
  },
110
92
  "attribute": "position",
111
93
  "reflects": true
@@ -144,7 +126,7 @@
144
126
  "kind": "field",
145
127
  "name": "variant",
146
128
  "type": {
147
- "text": "ModalVariant | undefined | undefined"
129
+ "text": "ModalVariant | undefined"
148
130
  },
149
131
  "attribute": "variant",
150
132
  "reflects": true
@@ -272,6 +254,33 @@
272
254
  "privacy": "private",
273
255
  "default": "false"
274
256
  },
257
+ {
258
+ "kind": "field",
259
+ "name": "_isSelfClosing",
260
+ "type": {
261
+ "text": "boolean"
262
+ },
263
+ "privacy": "private",
264
+ "default": "false"
265
+ },
266
+ {
267
+ "kind": "field",
268
+ "name": "_originalTrigger",
269
+ "type": {
270
+ "text": "HTMLElement | null"
271
+ },
272
+ "privacy": "private",
273
+ "default": "null"
274
+ },
275
+ {
276
+ "kind": "field",
277
+ "name": "_safariMouseInteraction",
278
+ "type": {
279
+ "text": "boolean"
280
+ },
281
+ "privacy": "private",
282
+ "default": "false"
283
+ },
275
284
  {
276
285
  "kind": "field",
277
286
  "name": "_dialogAnimation",
@@ -310,32 +319,53 @@
310
319
  },
311
320
  {
312
321
  "kind": "field",
313
- "name": "_focusTrap",
322
+ "name": "_inertElements",
323
+ "type": {
324
+ "text": "HTMLElement[]"
325
+ },
314
326
  "privacy": "private",
315
- "default": "new FocusTrapController(this, { getContainer: () => this._modalElement, initialFocus: () => this._modalElement, getTrigger: () => this._triggerElement, onEscape: () => { this.hide(); }, disableEscape: false, })"
327
+ "default": "[]"
316
328
  },
317
329
  {
318
330
  "kind": "field",
319
- "name": "_triggerElement",
331
+ "name": "_triggerPointerBefore",
320
332
  "type": {
321
- "text": "HTMLElement | null"
333
+ "text": "string | null"
322
334
  },
323
- "readonly": true
335
+ "privacy": "private",
336
+ "default": "null"
324
337
  },
325
338
  {
326
339
  "kind": "field",
327
- "name": "_onTriggerSlotChange",
328
- "privacy": "private"
340
+ "name": "_restoreFocusTimer",
341
+ "type": {
342
+ "text": "ReturnType<typeof setTimeout> | null"
343
+ },
344
+ "privacy": "private",
345
+ "default": "null",
346
+ "description": "Timer ID for the focus-restore call in finishHide. Cancelled on reconnect/unmount\nto prevent a stale focus from a previous close cycle firing during a new open."
329
347
  },
330
348
  {
331
349
  "kind": "field",
332
- "name": "_onHeaderSlotChange",
333
- "privacy": "private"
350
+ "name": "_focusTrap",
351
+ "type": {
352
+ "text": "FocusTrapController"
353
+ },
354
+ "privacy": "private",
355
+ "default": "new FocusTrapController(this, { getContainer: () => this._modalElement, initialFocus: () => this._modalElement, getTrigger: () => this._triggerElement, onEscape: () => { this._safariMouseInteraction = false; this.hide(); }, })"
356
+ },
357
+ {
358
+ "kind": "field",
359
+ "name": "_triggerElement",
360
+ "type": {
361
+ "text": "HTMLElement | null"
362
+ },
363
+ "readonly": true
334
364
  },
335
365
  {
336
366
  "kind": "method",
337
- "name": "_setupTriggerListeners",
338
- "privacy": "private",
367
+ "name": "show",
368
+ "privacy": "public",
339
369
  "return": {
340
370
  "type": {
341
371
  "text": "void"
@@ -344,27 +374,17 @@
344
374
  },
345
375
  {
346
376
  "kind": "method",
347
- "name": "_removeTriggerListeners",
348
- "privacy": "private",
377
+ "name": "hide",
378
+ "privacy": "public",
349
379
  "return": {
350
380
  "type": {
351
381
  "text": "void"
352
382
  }
353
383
  }
354
384
  },
355
- {
356
- "kind": "field",
357
- "name": "_onTriggerClick",
358
- "privacy": "private"
359
- },
360
- {
361
- "kind": "field",
362
- "name": "_onTriggerKeydown",
363
- "privacy": "private"
364
- },
365
385
  {
366
386
  "kind": "method",
367
- "name": "show",
387
+ "name": "toggle",
368
388
  "privacy": "public",
369
389
  "return": {
370
390
  "type": {
@@ -374,8 +394,8 @@
374
394
  },
375
395
  {
376
396
  "kind": "method",
377
- "name": "hide",
378
- "privacy": "public",
397
+ "name": "_applyInert",
398
+ "privacy": "private",
379
399
  "return": {
380
400
  "type": {
381
401
  "text": "void"
@@ -384,21 +404,31 @@
384
404
  },
385
405
  {
386
406
  "kind": "method",
387
- "name": "toggle",
388
- "privacy": "public",
407
+ "name": "_removeInert",
408
+ "privacy": "private",
389
409
  "return": {
390
410
  "type": {
391
411
  "text": "void"
392
412
  }
393
413
  }
394
414
  },
415
+ {
416
+ "kind": "field",
417
+ "name": "_handleDialogClick",
418
+ "privacy": "private"
419
+ },
420
+ {
421
+ "kind": "field",
422
+ "name": "_handleBackdropClick",
423
+ "privacy": "private"
424
+ },
395
425
  {
396
426
  "kind": "method",
397
427
  "name": "_showModal",
398
428
  "privacy": "private",
399
429
  "return": {
400
430
  "type": {
401
- "text": "void"
431
+ "text": "Promise<void>"
402
432
  }
403
433
  }
404
434
  },
@@ -424,17 +454,42 @@
424
454
  },
425
455
  {
426
456
  "kind": "field",
427
- "name": "_handleCloseClick",
457
+ "name": "_onTriggerSlotChange",
428
458
  "privacy": "private"
429
459
  },
430
460
  {
431
461
  "kind": "field",
432
- "name": "_handleBackdropClick",
462
+ "name": "_onHeaderSlotChange",
433
463
  "privacy": "private"
434
464
  },
465
+ {
466
+ "kind": "method",
467
+ "name": "_setupTriggerListeners",
468
+ "privacy": "private",
469
+ "return": {
470
+ "type": {
471
+ "text": "void"
472
+ }
473
+ }
474
+ },
475
+ {
476
+ "kind": "method",
477
+ "name": "_removeTriggerListeners",
478
+ "privacy": "private",
479
+ "return": {
480
+ "type": {
481
+ "text": "void"
482
+ }
483
+ }
484
+ },
435
485
  {
436
486
  "kind": "field",
437
- "name": "_handleDialogClick",
487
+ "name": "_onTriggerClick",
488
+ "privacy": "private"
489
+ },
490
+ {
491
+ "kind": "field",
492
+ "name": "_onTriggerKeydown",
438
493
  "privacy": "private"
439
494
  },
440
495
  {
@@ -455,24 +510,22 @@
455
510
  "name": "it-modal-open",
456
511
  "type": {
457
512
  "text": "CustomEvent"
458
- },
459
- "description": "Quando la modale si apre"
513
+ }
460
514
  },
461
515
  {
462
516
  "name": "it-modal-close",
463
517
  "type": {
464
518
  "text": "CustomEvent"
465
- },
466
- "description": "Quando la modale si chiude"
519
+ }
467
520
  }
468
521
  ],
469
522
  "attributes": [
470
523
  {
471
524
  "name": "open",
472
525
  "type": {
473
- "text": "boolean"
526
+ "text": "boolean | undefined"
474
527
  },
475
- "default": "false",
528
+ "default": "undefined",
476
529
  "fieldName": "open"
477
530
  },
478
531
  {
@@ -502,7 +555,7 @@
502
555
  {
503
556
  "name": "position",
504
557
  "type": {
505
- "text": "ModalPosition | undefined | undefined"
558
+ "text": "ModalPosition | undefined"
506
559
  },
507
560
  "fieldName": "position"
508
561
  },
@@ -533,7 +586,7 @@
533
586
  {
534
587
  "name": "variant",
535
588
  "type": {
536
- "text": "ModalVariant | undefined | undefined"
589
+ "text": "ModalVariant | undefined"
537
590
  },
538
591
  "fieldName": "variant"
539
592
  },
@@ -1,19 +1,6 @@
1
1
  import { BaseComponent } from '@italia/globals';
2
2
  import { PropertyValues } from 'lit';
3
3
  import { type ModalSize, type ModalPosition, type ModalVariant } from './types.js';
4
- /**
5
- * Componente Modal per finestre di dialogo modali.
6
- *
7
- * @element it-modal
8
- *
9
- * @slot trigger - Elemento che apre la modale (es. it-button)
10
- * @slot content - Contenuto principale della modale (body)
11
- * @slot header-icon - Icona opzionale nell'header
12
- * @slot footer - Azioni del footer (pulsanti)
13
- *
14
- * @fires it-modal-open - Quando la modale si apre
15
- * @fires it-modal-close - Quando la modale si chiude
16
- */
17
4
  export declare class ItModal extends BaseComponent {
18
5
  static styles: import("lit").CSSResultGroup;
19
6
  static shadowRootOptions: {
@@ -24,15 +11,15 @@ export declare class ItModal extends BaseComponent {
24
11
  serializable?: boolean;
25
12
  slotAssignment?: SlotAssignmentMode;
26
13
  };
27
- open: boolean;
14
+ open: boolean | undefined;
28
15
  modalTitle: string;
29
16
  modalDescription: string;
30
17
  size: ModalSize;
31
- position?: ModalPosition | undefined;
18
+ position?: ModalPosition;
32
19
  scrollable: boolean;
33
20
  staticBackdrop: boolean;
34
21
  hideCloseButton: boolean;
35
- variant?: ModalVariant | undefined;
22
+ variant?: ModalVariant;
36
23
  itAriaLabel: string;
37
24
  closeLabel: string;
38
25
  disableAnimation: boolean;
@@ -47,38 +34,42 @@ export declare class ItModal extends BaseComponent {
47
34
  private _triggerId;
48
35
  private _descriptionId;
49
36
  private isAnimating;
37
+ private _isSelfClosing;
38
+ private _originalTrigger;
39
+ private _safariMouseInteraction;
50
40
  private _dialogAnimation?;
51
41
  private _backdropAnimation?;
52
42
  private readonly _dialogAnimationDuration;
53
43
  private readonly _backdropAnimationDuration;
44
+ private _inertElements;
45
+ private _triggerPointerBefore;
46
+ /** Timer ID for the focus-restore call in finishHide. Cancelled on reconnect/unmount
47
+ * to prevent a stale focus from a previous close cycle firing during a new open. */
48
+ private _restoreFocusTimer;
54
49
  private _focusTrap;
55
50
  get _triggerElement(): HTMLElement | null;
56
51
  constructor();
57
52
  connectedCallback(): void;
58
53
  disconnectedCallback(): void;
54
+ show(): void;
55
+ hide(): void;
56
+ toggle(): void;
59
57
  protected updated(changedProperties: PropertyValues): void;
58
+ private _applyInert;
59
+ private _removeInert;
60
+ private _handleDialogClick;
61
+ private _handleBackdropClick;
62
+ private _showModal;
63
+ private _hideModal;
64
+ private _cleanupAnimations;
60
65
  private _onTriggerSlotChange;
61
66
  private _onHeaderSlotChange;
62
67
  private _setupTriggerListeners;
63
68
  private _removeTriggerListeners;
64
69
  private _onTriggerClick;
65
70
  private _onTriggerKeydown;
66
- show(): void;
67
- hide(): void;
68
- toggle(): void;
69
- private _showModal;
70
- private _hideModal;
71
- private _cleanupAnimations;
72
- private _handleCloseClick;
73
- private _handleBackdropClick;
74
- private _handleDialogClick;
75
71
  private get _modalClasses();
76
72
  private get _modalBodyClasses();
77
73
  render(): import("lit").TemplateResult<1>;
78
74
  }
79
- declare global {
80
- interface HTMLElementTagNameMap {
81
- 'it-modal': ItModal;
82
- }
83
- }
84
75
  //# sourceMappingURL=it-modal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"it-modal.d.ts","sourceRoot":"","sources":["../../src/it-modal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAsC,MAAM,iBAAiB,CAAC;AACpF,OAAO,EAAQ,cAAc,EAAE,MAAM,KAAK,CAAC;AAI3C,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAyB,MAAM,YAAY,CAAC;AAG1G;;;;;;;;;;;;GAYG;AACH,qBACa,OAAQ,SAAQ,aAAa;IACxC,MAAM,CAAC,MAAM,+BAAU;IAEvB,OAAgB,iB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