@italia/modal 1.0.0-alpha.8 → 1.0.0-beta.0
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/custom-elements.json +172 -76
- package/dist/src/index.js.map +1 -1
- package/dist/src/it-modal.d.ts +24 -30
- package/dist/src/it-modal.d.ts.map +1 -1
- package/dist/src/it-modal.js +1175 -399
- package/dist/src/it-modal.js.map +1 -1
- package/dist/src/types.d.ts +5 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/styles/globals.scss +20 -2
package/custom-elements.json
CHANGED
|
@@ -31,26 +31,8 @@
|
|
|
31
31
|
"declarations": [
|
|
32
32
|
{
|
|
33
33
|
"kind": "class",
|
|
34
|
-
"description": "
|
|
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": "
|
|
52
|
+
"default": "undefined",
|
|
71
53
|
"attribute": "open",
|
|
72
54
|
"reflects": true
|
|
73
55
|
},
|
|
@@ -91,6 +73,16 @@
|
|
|
91
73
|
"attribute": "modal-description",
|
|
92
74
|
"reflects": true
|
|
93
75
|
},
|
|
76
|
+
{
|
|
77
|
+
"kind": "field",
|
|
78
|
+
"name": "customHeader",
|
|
79
|
+
"type": {
|
|
80
|
+
"text": "boolean"
|
|
81
|
+
},
|
|
82
|
+
"default": "false",
|
|
83
|
+
"attribute": "custom-header",
|
|
84
|
+
"reflects": true
|
|
85
|
+
},
|
|
94
86
|
{
|
|
95
87
|
"kind": "field",
|
|
96
88
|
"name": "size",
|
|
@@ -105,7 +97,7 @@
|
|
|
105
97
|
"kind": "field",
|
|
106
98
|
"name": "position",
|
|
107
99
|
"type": {
|
|
108
|
-
"text": "ModalPosition | undefined
|
|
100
|
+
"text": "ModalPosition | undefined"
|
|
109
101
|
},
|
|
110
102
|
"attribute": "position",
|
|
111
103
|
"reflects": true
|
|
@@ -140,11 +132,21 @@
|
|
|
140
132
|
"attribute": "hide-close-button",
|
|
141
133
|
"reflects": true
|
|
142
134
|
},
|
|
135
|
+
{
|
|
136
|
+
"kind": "field",
|
|
137
|
+
"name": "closeButtonPlacement",
|
|
138
|
+
"type": {
|
|
139
|
+
"text": "| 'header'\n | 'backdrop'"
|
|
140
|
+
},
|
|
141
|
+
"default": "'header'",
|
|
142
|
+
"attribute": "close-button-placement",
|
|
143
|
+
"reflects": true
|
|
144
|
+
},
|
|
143
145
|
{
|
|
144
146
|
"kind": "field",
|
|
145
147
|
"name": "variant",
|
|
146
148
|
"type": {
|
|
147
|
-
"text": "ModalVariant | undefined
|
|
149
|
+
"text": "ModalVariant | undefined"
|
|
148
150
|
},
|
|
149
151
|
"attribute": "variant",
|
|
150
152
|
"reflects": true
|
|
@@ -272,6 +274,33 @@
|
|
|
272
274
|
"privacy": "private",
|
|
273
275
|
"default": "false"
|
|
274
276
|
},
|
|
277
|
+
{
|
|
278
|
+
"kind": "field",
|
|
279
|
+
"name": "_isSelfClosing",
|
|
280
|
+
"type": {
|
|
281
|
+
"text": "boolean"
|
|
282
|
+
},
|
|
283
|
+
"privacy": "private",
|
|
284
|
+
"default": "false"
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"kind": "field",
|
|
288
|
+
"name": "_originalTrigger",
|
|
289
|
+
"type": {
|
|
290
|
+
"text": "HTMLElement | null"
|
|
291
|
+
},
|
|
292
|
+
"privacy": "private",
|
|
293
|
+
"default": "null"
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
"kind": "field",
|
|
297
|
+
"name": "_safariMouseInteraction",
|
|
298
|
+
"type": {
|
|
299
|
+
"text": "boolean"
|
|
300
|
+
},
|
|
301
|
+
"privacy": "private",
|
|
302
|
+
"default": "false"
|
|
303
|
+
},
|
|
275
304
|
{
|
|
276
305
|
"kind": "field",
|
|
277
306
|
"name": "_dialogAnimation",
|
|
@@ -310,32 +339,53 @@
|
|
|
310
339
|
},
|
|
311
340
|
{
|
|
312
341
|
"kind": "field",
|
|
313
|
-
"name": "
|
|
342
|
+
"name": "_inertElements",
|
|
343
|
+
"type": {
|
|
344
|
+
"text": "HTMLElement[]"
|
|
345
|
+
},
|
|
314
346
|
"privacy": "private",
|
|
315
|
-
"default": "
|
|
347
|
+
"default": "[]"
|
|
316
348
|
},
|
|
317
349
|
{
|
|
318
350
|
"kind": "field",
|
|
319
|
-
"name": "
|
|
351
|
+
"name": "_triggerPointerBefore",
|
|
320
352
|
"type": {
|
|
321
|
-
"text": "
|
|
353
|
+
"text": "string | null"
|
|
322
354
|
},
|
|
323
|
-
"
|
|
355
|
+
"privacy": "private",
|
|
356
|
+
"default": "null"
|
|
324
357
|
},
|
|
325
358
|
{
|
|
326
359
|
"kind": "field",
|
|
327
|
-
"name": "
|
|
328
|
-
"
|
|
360
|
+
"name": "_restoreFocusTimer",
|
|
361
|
+
"type": {
|
|
362
|
+
"text": "ReturnType<typeof setTimeout> | null"
|
|
363
|
+
},
|
|
364
|
+
"privacy": "private",
|
|
365
|
+
"default": "null",
|
|
366
|
+
"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
367
|
},
|
|
330
368
|
{
|
|
331
369
|
"kind": "field",
|
|
332
|
-
"name": "
|
|
333
|
-
"
|
|
370
|
+
"name": "_focusTrap",
|
|
371
|
+
"type": {
|
|
372
|
+
"text": "FocusTrapController"
|
|
373
|
+
},
|
|
374
|
+
"privacy": "private",
|
|
375
|
+
"default": "new FocusTrapController(this, { getContainer: () => this._modalElement, initialFocus: () => this._modalElement, getTrigger: () => this._triggerElement, onEscape: () => { this._safariMouseInteraction = false; this.hide(); }, })"
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
"kind": "field",
|
|
379
|
+
"name": "_triggerElement",
|
|
380
|
+
"type": {
|
|
381
|
+
"text": "HTMLElement | null"
|
|
382
|
+
},
|
|
383
|
+
"readonly": true
|
|
334
384
|
},
|
|
335
385
|
{
|
|
336
386
|
"kind": "method",
|
|
337
|
-
"name": "
|
|
338
|
-
"privacy": "
|
|
387
|
+
"name": "show",
|
|
388
|
+
"privacy": "public",
|
|
339
389
|
"return": {
|
|
340
390
|
"type": {
|
|
341
391
|
"text": "void"
|
|
@@ -344,27 +394,17 @@
|
|
|
344
394
|
},
|
|
345
395
|
{
|
|
346
396
|
"kind": "method",
|
|
347
|
-
"name": "
|
|
348
|
-
"privacy": "
|
|
397
|
+
"name": "hide",
|
|
398
|
+
"privacy": "public",
|
|
349
399
|
"return": {
|
|
350
400
|
"type": {
|
|
351
401
|
"text": "void"
|
|
352
402
|
}
|
|
353
403
|
}
|
|
354
404
|
},
|
|
355
|
-
{
|
|
356
|
-
"kind": "field",
|
|
357
|
-
"name": "_onTriggerClick",
|
|
358
|
-
"privacy": "private"
|
|
359
|
-
},
|
|
360
|
-
{
|
|
361
|
-
"kind": "field",
|
|
362
|
-
"name": "_onTriggerKeydown",
|
|
363
|
-
"privacy": "private"
|
|
364
|
-
},
|
|
365
405
|
{
|
|
366
406
|
"kind": "method",
|
|
367
|
-
"name": "
|
|
407
|
+
"name": "toggle",
|
|
368
408
|
"privacy": "public",
|
|
369
409
|
"return": {
|
|
370
410
|
"type": {
|
|
@@ -374,8 +414,8 @@
|
|
|
374
414
|
},
|
|
375
415
|
{
|
|
376
416
|
"kind": "method",
|
|
377
|
-
"name": "
|
|
378
|
-
"privacy": "
|
|
417
|
+
"name": "_applyInert",
|
|
418
|
+
"privacy": "private",
|
|
379
419
|
"return": {
|
|
380
420
|
"type": {
|
|
381
421
|
"text": "void"
|
|
@@ -384,21 +424,31 @@
|
|
|
384
424
|
},
|
|
385
425
|
{
|
|
386
426
|
"kind": "method",
|
|
387
|
-
"name": "
|
|
388
|
-
"privacy": "
|
|
427
|
+
"name": "_removeInert",
|
|
428
|
+
"privacy": "private",
|
|
389
429
|
"return": {
|
|
390
430
|
"type": {
|
|
391
431
|
"text": "void"
|
|
392
432
|
}
|
|
393
433
|
}
|
|
394
434
|
},
|
|
435
|
+
{
|
|
436
|
+
"kind": "field",
|
|
437
|
+
"name": "_handleDialogClick",
|
|
438
|
+
"privacy": "private"
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
"kind": "field",
|
|
442
|
+
"name": "_handleBackdropClick",
|
|
443
|
+
"privacy": "private"
|
|
444
|
+
},
|
|
395
445
|
{
|
|
396
446
|
"kind": "method",
|
|
397
447
|
"name": "_showModal",
|
|
398
448
|
"privacy": "private",
|
|
399
449
|
"return": {
|
|
400
450
|
"type": {
|
|
401
|
-
"text": "void"
|
|
451
|
+
"text": "Promise<void>"
|
|
402
452
|
}
|
|
403
453
|
}
|
|
404
454
|
},
|
|
@@ -424,17 +474,42 @@
|
|
|
424
474
|
},
|
|
425
475
|
{
|
|
426
476
|
"kind": "field",
|
|
427
|
-
"name": "
|
|
477
|
+
"name": "_onTriggerSlotChange",
|
|
428
478
|
"privacy": "private"
|
|
429
479
|
},
|
|
430
480
|
{
|
|
431
481
|
"kind": "field",
|
|
432
|
-
"name": "
|
|
482
|
+
"name": "_onHeaderSlotChange",
|
|
433
483
|
"privacy": "private"
|
|
434
484
|
},
|
|
485
|
+
{
|
|
486
|
+
"kind": "method",
|
|
487
|
+
"name": "_setupTriggerListeners",
|
|
488
|
+
"privacy": "private",
|
|
489
|
+
"return": {
|
|
490
|
+
"type": {
|
|
491
|
+
"text": "void"
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
"kind": "method",
|
|
497
|
+
"name": "_removeTriggerListeners",
|
|
498
|
+
"privacy": "private",
|
|
499
|
+
"return": {
|
|
500
|
+
"type": {
|
|
501
|
+
"text": "void"
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
},
|
|
435
505
|
{
|
|
436
506
|
"kind": "field",
|
|
437
|
-
"name": "
|
|
507
|
+
"name": "_onTriggerClick",
|
|
508
|
+
"privacy": "private"
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
"kind": "field",
|
|
512
|
+
"name": "_onTriggerKeydown",
|
|
438
513
|
"privacy": "private"
|
|
439
514
|
},
|
|
440
515
|
{
|
|
@@ -448,31 +523,20 @@
|
|
|
448
523
|
"name": "_modalBodyClasses",
|
|
449
524
|
"privacy": "private",
|
|
450
525
|
"readonly": true
|
|
451
|
-
}
|
|
452
|
-
],
|
|
453
|
-
"events": [
|
|
454
|
-
{
|
|
455
|
-
"name": "it-modal-open",
|
|
456
|
-
"type": {
|
|
457
|
-
"text": "CustomEvent"
|
|
458
|
-
},
|
|
459
|
-
"description": "Quando la modale si apre"
|
|
460
526
|
},
|
|
461
527
|
{
|
|
462
|
-
"
|
|
463
|
-
"
|
|
464
|
-
|
|
465
|
-
},
|
|
466
|
-
"description": "Quando la modale si chiude"
|
|
528
|
+
"kind": "method",
|
|
529
|
+
"name": "_renderCloseButton",
|
|
530
|
+
"privacy": "private"
|
|
467
531
|
}
|
|
468
532
|
],
|
|
469
533
|
"attributes": [
|
|
470
534
|
{
|
|
471
535
|
"name": "open",
|
|
472
536
|
"type": {
|
|
473
|
-
"text": "boolean"
|
|
537
|
+
"text": "boolean | undefined"
|
|
474
538
|
},
|
|
475
|
-
"default": "
|
|
539
|
+
"default": "undefined",
|
|
476
540
|
"fieldName": "open"
|
|
477
541
|
},
|
|
478
542
|
{
|
|
@@ -491,6 +555,14 @@
|
|
|
491
555
|
"default": "''",
|
|
492
556
|
"fieldName": "modalDescription"
|
|
493
557
|
},
|
|
558
|
+
{
|
|
559
|
+
"name": "custom-header",
|
|
560
|
+
"type": {
|
|
561
|
+
"text": "boolean"
|
|
562
|
+
},
|
|
563
|
+
"default": "false",
|
|
564
|
+
"fieldName": "customHeader"
|
|
565
|
+
},
|
|
494
566
|
{
|
|
495
567
|
"name": "size",
|
|
496
568
|
"type": {
|
|
@@ -502,7 +574,7 @@
|
|
|
502
574
|
{
|
|
503
575
|
"name": "position",
|
|
504
576
|
"type": {
|
|
505
|
-
"text": "ModalPosition | undefined
|
|
577
|
+
"text": "ModalPosition | undefined"
|
|
506
578
|
},
|
|
507
579
|
"fieldName": "position"
|
|
508
580
|
},
|
|
@@ -530,10 +602,18 @@
|
|
|
530
602
|
"default": "false",
|
|
531
603
|
"fieldName": "hideCloseButton"
|
|
532
604
|
},
|
|
605
|
+
{
|
|
606
|
+
"name": "close-button-placement",
|
|
607
|
+
"type": {
|
|
608
|
+
"text": "| 'header'\n | 'backdrop'"
|
|
609
|
+
},
|
|
610
|
+
"default": "'header'",
|
|
611
|
+
"fieldName": "closeButtonPlacement"
|
|
612
|
+
},
|
|
533
613
|
{
|
|
534
614
|
"name": "variant",
|
|
535
615
|
"type": {
|
|
536
|
-
"text": "ModalVariant | undefined
|
|
616
|
+
"text": "ModalVariant | undefined"
|
|
537
617
|
},
|
|
538
618
|
"fieldName": "variant"
|
|
539
619
|
},
|
|
@@ -660,7 +740,7 @@
|
|
|
660
740
|
{
|
|
661
741
|
"kind": "variable",
|
|
662
742
|
"name": "meta",
|
|
663
|
-
"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', size: '', position: undefined, scrollable: false, 'static-backdrop': false, 'hide-close-button': false, 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.', }, 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', }, 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>"
|
|
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>"
|
|
664
744
|
},
|
|
665
745
|
{
|
|
666
746
|
"kind": "variable",
|
|
@@ -668,7 +748,7 @@
|
|
|
668
748
|
"type": {
|
|
669
749
|
"text": "Story"
|
|
670
750
|
},
|
|
671
|
-
"default": "{ name: 'Esempio interattivo', tags: ['!dev'], parameters: { docs: { canvas: { sourceState: 'hidden' }, }, }, render: (args) => html` <it-modal ?hide-close-button=\"${args['hide-close-button']}\" ?disable-animation=\"${args['disable-animation']}\" size=\"${ifDefined(args.size || undefined)}\" position=\"${args.position}\" variant=\"${ifDefined(args.variant || undefined)}\" ?scrollable=\"${args.scrollable}\" ?static-backdrop=\"${args['static-backdrop']}\" ?footer-shadow=\"${args['footer-shadow']}\" close-label=\"${args['close-label']}\" modal-title=\"${args['modal-title']}\" modal-description=\"${args['modal-description']}\" > <it-button variant=\"primary\" slot=\"trigger\">Lancia la demo della modale</it-button> <span slot=\"header\">${args['modal-title']}</span> <span slot=\"description\">${args['modal-description']}</span> <p slot=\"content\">${args.bodyContent}</p> <it-button slot=\"footer\" variant=\"outline-primary\" @click=\"${closeModal}\">Annulla</it-button> <it-button slot=\"footer\" variant=\"primary\" @click=\"${closeModal}\">Conferma</it-button> </it-modal> `, }"
|
|
751
|
+
"default": "{ name: 'Esempio interattivo', tags: ['!dev'], parameters: { docs: { canvas: { sourceState: 'hidden' }, }, }, render: (args) => html` <it-modal ?hide-close-button=\"${args['hide-close-button']}\" ?disable-animation=\"${args['disable-animation']}\" size=\"${ifDefined(args.size || undefined)}\" position=\"${args.position}\" variant=\"${ifDefined(args.variant || undefined)}\" ?scrollable=\"${args.scrollable}\" ?static-backdrop=\"${args['static-backdrop']}\" ?footer-shadow=\"${args['footer-shadow']}\" close-label=\"${args['close-label']}\" close-button-placement=\"${args['close-button-placement']}\" modal-title=\"${args['modal-title']}\" modal-description=\"${args['modal-description']}\" custom-header=\"${args['custom-header']}\" > <it-button variant=\"primary\" slot=\"trigger\">Lancia la demo della modale</it-button> <span slot=\"header\">${args['modal-title']}</span> <span slot=\"description\">${args['modal-description']}</span> <p slot=\"content\">${args.bodyContent}</p> <it-button slot=\"footer\" variant=\"outline-primary\" @click=\"${closeModal}\">Annulla</it-button> <it-button slot=\"footer\" variant=\"primary\" @click=\"${closeModal}\">Conferma</it-button> </it-modal> `, }"
|
|
672
752
|
},
|
|
673
753
|
{
|
|
674
754
|
"kind": "variable",
|
|
@@ -789,6 +869,14 @@
|
|
|
789
869
|
"text": "Story"
|
|
790
870
|
},
|
|
791
871
|
"default": "{ name: 'Attivazione manuale via JS', decorators: [ (story) => html` <div style=\"display:flex; height:100%; align-items:center; gap:2rem;\">${story()}</div> `, ], parameters: { docs: { source: { excludeDecorators: true, code: ` <it-modal disable-animation close-label=\"Chiudi finestra modale\"> <it-button slot=\"trigger\" variant=\"primary\">Modale con apertura manuale (show)</it-button> <span slot=\"header\">Modale con apertura manuale</span> <p slot=\"content\">Questa modale appare immediatamente senza animazione di dissolvenza.</p> <it-button slot=\"footer\" variant=\"outline-primary\">Annulla</it-button> <it-button slot=\"footer\" variant=\"primary\">Conferma</it-button> </it-modal> <it-modal disable-animation close-label=\"Chiudi finestra modale\"> <it-button slot=\"trigger\" variant=\"primary\">Modale con apertura manuale (toggle)</it-button > <span slot=\"header\">Modale con toggle manuale</span> <p slot=\"content\">Questa modale appare immediatamente senza animazione di dissolvenza.</p> <it-button slot=\"footer\" variant=\"outline-primary\">Annulla</it-button> <it-button slot=\"footer\" variant=\"primary\">Conferma</it-button> </it-modal> <script> // Script di esempio per mostrare come attivare la modale via JS utilizzando i metodi show(), hide() e toggle() const modals = document.querySelectorAll('it-modal'); const [modalShow, modalToggle] = modals; const openModal = (event) => { const el = event.currentTarget; const modal = el.closest('it-modal'); console.log('openModal -> modal', modal); modal?.show(); }; const closeModal = (event) => { const el = event.currentTarget; const modal = el.closest('it-modal'); console.log('closeModal -> modal', modal); modal?.hide(); }; const toggleModal = (event) => { const el = event.currentTarget; const modal = el.closest('it-modal'); console.log('toggleModal -> modal', modal); modal?.toggle(); }; // Assegna gli event listener ai bottoni di trigger e footer modalShow.querySelector('[slot=\"trigger\"]').addEventListener('click', openModal); modalShow.querySelectorAll('[slot=\"footer\"] it-button').forEach((btn) => btn.addEventListener('click', closeModal)); modalToggle.querySelector('[slot=\"trigger\"]').addEventListener('click', toggleModal); modalToggle.querySelectorAll('[slot=\"footer\"] it-button').forEach((btn) => btn.addEventListener('click', toggleModal)); </script> `, }, }, }, render: () => html` <it-modal disable-animation close-label=\"Chiudi finestra modale\"> <it-button slot=\"trigger\" variant=\"primary\" @click=\"${openModal}\">Modale con apertura manuale (show)</it-button> <span slot=\"header\">Modale con apertura manuale</span> <p slot=\"content\">Questa modale appare immediatamente senza animazione di dissolvenza.</p> <it-button slot=\"footer\" variant=\"outline-primary\" @click=\"${closeModal}\">Annulla</it-button> <it-button slot=\"footer\" variant=\"primary\" @click=\"${closeModal}\">Conferma</it-button> </it-modal> <it-modal disable-animation close-label=\"Chiudi finestra modale\"> <it-button slot=\"trigger\" variant=\"primary\" @click=\"${toggleModal}\" >Modale con apertura manuale (toggle)</it-button > <span slot=\"header\">Modale con toggle manuale</span> <p slot=\"content\">Questa modale appare immediatamente senza animazione di dissolvenza.</p> <it-button slot=\"footer\" variant=\"outline-primary\" @click=\"${toggleModal}\">Annulla</it-button> <it-button slot=\"footer\" variant=\"primary\" @click=\"${toggleModal}\">Conferma</it-button> </it-modal> `, }"
|
|
872
|
+
},
|
|
873
|
+
{
|
|
874
|
+
"kind": "variable",
|
|
875
|
+
"name": "ChiusuraConConferma",
|
|
876
|
+
"type": {
|
|
877
|
+
"text": "Story"
|
|
878
|
+
},
|
|
879
|
+
"default": "{ name: 'Chiusura con logica personalizzata', parameters: { docs: { description: { story: `L'evento \\`it-modal-close\\` è **cancelable**. Chiamando \\`event.preventDefault()\\` puoi intercettare la chiusura, eseguire una logica personalizzata — in questo esempio viene mostrato un messaggio informativo — e poi richiamare \\`hide()\\` per chiudere effettivamente la modale. Lo stesso schema si applica a \\`it-modal-open\\`.`, }, source: { code: `<it-modal id=\"modal-custom-close\"> <it-button variant=\"primary\" slot=\"trigger\">Apri modale</it-button> <span slot=\"header\">Chiusura con logica personalizzata</span> <p slot=\"content\">Prova a chiudere la modale: verrà eseguita una logica personalizzata prima della chiusura effettiva.</p> <it-button slot=\"footer\" variant=\"primary\" id=\"modal-custom-close-footer\">Chiudi</it-button> </it-modal> <div id=\"modal-close-alert\" class=\"alert alert-info\" role=\"alert\" style=\"display:none\"> <strong>Operazione completata.</strong> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </div> <script type=\"module\"> const modal = document.getElementById('modal-custom-close'); const alertEl = document.getElementById('modal-close-alert'); let _closing = false; modal.addEventListener('it-modal-close', (e) => { if (_closing) return; e.preventDefault(); alertEl.style.display = ''; _closing = true; modal.hide(); _closing = false; }); document.getElementById('modal-custom-close-footer') ?.addEventListener('click', () => modal.hide()); </script>`, }, }, }, render: () => { let _closing = false; return html` <it-modal id=\"modal-custom-close\" @it-modal-close=${(e: Event) => { if (_closing) return; e.preventDefault(); const alertEl = document.getElementById('modal-close-alert'); if (alertEl) alertEl.style.display = ''; _closing = true; (e.currentTarget as HTMLElement & { hide(): void }).hide(); _closing = false; }} > <it-button variant=\"primary\" slot=\"trigger\">Apri modale</it-button> <span slot=\"header\">Chiusura con logica personalizzata</span> <p slot=\"content\"> Prova a chiudere la modale: verrà eseguita una logica personalizzata prima della chiusura effettiva. </p> <it-button slot=\"footer\" variant=\"primary\" @click=${(e: Event) => { (e.currentTarget as HTMLElement).closest<HTMLElement & { hide(): void }>('it-modal')?.hide(); }} >Chiudi</it-button > </it-modal> <div id=\"modal-close-alert\" class=\"alert alert-info\" role=\"alert\" style=\"display:none\"> <strong>Operazione completata.</strong> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </div> `; }, }"
|
|
792
880
|
}
|
|
793
881
|
],
|
|
794
882
|
"exports": [
|
|
@@ -927,6 +1015,14 @@
|
|
|
927
1015
|
"name": "AttivazioneViaJS",
|
|
928
1016
|
"module": "stories/it-modal.stories.ts"
|
|
929
1017
|
}
|
|
1018
|
+
},
|
|
1019
|
+
{
|
|
1020
|
+
"kind": "js",
|
|
1021
|
+
"name": "ChiusuraConConferma",
|
|
1022
|
+
"declaration": {
|
|
1023
|
+
"name": "ChiusuraConConferma",
|
|
1024
|
+
"module": "stories/it-modal.stories.ts"
|
|
1025
|
+
}
|
|
930
1026
|
}
|
|
931
1027
|
]
|
|
932
1028
|
}
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/types.ts"],"sourcesContent":["export const MODAL_SIZES = ['sm', 'lg', 'xl'] as const;\nexport const MODAL_POSITIONS = ['center', 'left', 'right'] as const;\nexport const MODAL_VARIANTS = ['alert', 'popconfirm', 'link-list'] as const;\n\nexport type ModalSize = (typeof MODAL_SIZES)[number] | '';\nexport type ModalPosition = (typeof MODAL_POSITIONS)[number];\nexport type ModalVariant = (typeof MODAL_VARIANTS)[number];\n\nexport interface ModalEventDetail {\n /** Riferimento all'elemento modale */\n modal: HTMLElement;\n}\n"],"names":[],"mappings":";;;;;;;AAAO,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI;AACrC,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO;AAClD,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/types.ts"],"sourcesContent":["export const MODAL_SIZES = ['sm', 'lg', 'xl'] as const;\nexport const MODAL_POSITIONS = ['center', 'left', 'right'] as const;\nexport const MODAL_VARIANTS = ['alert', 'popconfirm', 'link-list'] as const;\n\nexport type ModalSize = (typeof MODAL_SIZES)[number] | '';\nexport type ModalPosition = (typeof MODAL_POSITIONS)[number];\nexport type ModalVariant = (typeof MODAL_VARIANTS)[number];\n\n/**\n * Detail degli eventi `it-modal-open` / `it-modal-close`.\n * Entrambi gli eventi sono cancelable: `event.preventDefault()` impedisce\n * rispettivamente l'apertura e la chiusura della modale.\n */\nexport interface ModalEventDetail {\n /** Riferimento all'elemento modale */\n modal: HTMLElement;\n}\n"],"names":[],"mappings":";;;;;;;AAAO,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI;AACrC,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO;AAClD,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW;;;;"}
|
package/dist/src/it-modal.d.ts
CHANGED
|
@@ -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,17 @@ 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;
|
|
17
|
+
customHeader: boolean;
|
|
30
18
|
size: ModalSize;
|
|
31
|
-
position?: ModalPosition
|
|
19
|
+
position?: ModalPosition;
|
|
32
20
|
scrollable: boolean;
|
|
33
21
|
staticBackdrop: boolean;
|
|
34
22
|
hideCloseButton: boolean;
|
|
35
|
-
|
|
23
|
+
closeButtonPlacement: 'header' | 'backdrop';
|
|
24
|
+
variant?: ModalVariant;
|
|
36
25
|
itAriaLabel: string;
|
|
37
26
|
closeLabel: string;
|
|
38
27
|
disableAnimation: boolean;
|
|
@@ -47,38 +36,43 @@ export declare class ItModal extends BaseComponent {
|
|
|
47
36
|
private _triggerId;
|
|
48
37
|
private _descriptionId;
|
|
49
38
|
private isAnimating;
|
|
39
|
+
private _isSelfClosing;
|
|
40
|
+
private _originalTrigger;
|
|
41
|
+
private _safariMouseInteraction;
|
|
50
42
|
private _dialogAnimation?;
|
|
51
43
|
private _backdropAnimation?;
|
|
52
44
|
private readonly _dialogAnimationDuration;
|
|
53
45
|
private readonly _backdropAnimationDuration;
|
|
46
|
+
private _inertElements;
|
|
47
|
+
private _triggerPointerBefore;
|
|
48
|
+
/** Timer ID for the focus-restore call in finishHide. Cancelled on reconnect/unmount
|
|
49
|
+
* to prevent a stale focus from a previous close cycle firing during a new open. */
|
|
50
|
+
private _restoreFocusTimer;
|
|
54
51
|
private _focusTrap;
|
|
55
52
|
get _triggerElement(): HTMLElement | null;
|
|
56
53
|
constructor();
|
|
57
54
|
connectedCallback(): void;
|
|
58
55
|
disconnectedCallback(): void;
|
|
56
|
+
show(): void;
|
|
57
|
+
hide(): void;
|
|
58
|
+
toggle(): void;
|
|
59
59
|
protected updated(changedProperties: PropertyValues): void;
|
|
60
|
+
private _applyInert;
|
|
61
|
+
private _removeInert;
|
|
62
|
+
private _handleDialogClick;
|
|
63
|
+
private _handleBackdropClick;
|
|
64
|
+
private _showModal;
|
|
65
|
+
private _hideModal;
|
|
66
|
+
private _cleanupAnimations;
|
|
60
67
|
private _onTriggerSlotChange;
|
|
61
68
|
private _onHeaderSlotChange;
|
|
62
69
|
private _setupTriggerListeners;
|
|
63
70
|
private _removeTriggerListeners;
|
|
64
71
|
private _onTriggerClick;
|
|
65
72
|
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
73
|
private get _modalClasses();
|
|
76
74
|
private get _modalBodyClasses();
|
|
75
|
+
private _renderCloseButton;
|
|
77
76
|
render(): import("lit").TemplateResult<1>;
|
|
78
77
|
}
|
|
79
|
-
declare global {
|
|
80
|
-
interface HTMLElementTagNameMap {
|
|
81
|
-
'it-modal': ItModal;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
78
|
//# sourceMappingURL=it-modal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"it-modal.d.ts","sourceRoot":"","sources":["../../src/it-modal.ts"],"names":[],"mappings":"
|
|
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;IAEjC,OAAO,CAAC,gBAAgB,CAAmB;IAEpD,OAAO,CAAC,gBAAgB,CAAe;IAEzC,OAAO,CAAC,cAAc,CAAe;IAE7D,OAAO,CAAC,QAAQ,CAAM;IAEtB,OAAO,CAAC,UAAU,CAAM;IAExB,OAAO,CAAC,cAAc,CAAM;IAE5B,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,CAAC,gBAAgB,CAA4B;IAGpD,OAAO,CAAC,uBAAuB,CAAS;IAExC,OAAO,CAAC,gBAAgB,CAAC,CAAY;IAErC,OAAO,CAAC,kBAAkB,CAAC,CAAY;IAEvC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAO;IAEhD,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAO;IAElD,OAAO,CAAC,cAAc,CAAqB;IAE3C,OAAO,CAAC,qBAAqB,CAAuB;IAEpD;yFACqF;IACrF,OAAO,CAAC,kBAAkB,CAA8C;IAExE,OAAO,CAAC,UAAU,CAAsB;IAExC,IAAI,eAAe,IAAI,WAAW,GAAG,IAAI,CAGxC;;IAkBD,iBAAiB,IAAI,IAAI;IAIzB,oBAAoB,IAAI,IAAI;IAYrB,IAAI,IAAI,IAAI;IAWZ,IAAI,IAAI,IAAI;IASZ,MAAM,IAAI,IAAI;IAQrB,SAAS,CAAC,OAAO,CAAC,iBAAiB,EAAE,cAAc,GAAG,IAAI;IA6B1D,OAAO,CAAC,WAAW;IAiCnB,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,kBAAkB,CAQxB;IAEF,OAAO,CAAC,oBAAoB,CAI1B;YAEY,UAAU;IAoExB,OAAO,CAAC,UAAU;IAuFlB,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,oBAAoB,CAE1B;IAEF,OAAO,CAAC,mBAAmB,CAEzB;IAEF,OAAO,CAAC,sBAAsB;IAc9B,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,CAAC,eAAe,CASrB;IAEF,OAAO,CAAC,iBAAiB,CAYvB;IAEF,OAAO,KAAK,aAAa,GAUxB;IAED,OAAO,KAAK,iBAAiB,GAW5B;IAED,OAAO,CAAC,kBAAkB;IAkB1B,MAAM;CAwEP"}
|