@italia/notification 1.0.0-alpha.9 → 1.0.0-beta.1
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 +6 -70
- package/custom-elements.json +220 -150
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/it-notification.d.ts +15 -0
- package/dist/src/it-notification.d.ts.map +1 -1
- package/dist/src/it-notification.js +564 -70
- package/dist/src/it-notification.js.map +1 -1
- package/dist/src/types.d.ts +9 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +24 -24
- package/styles/globals.scss +1 -1
package/README.md
CHANGED
|
@@ -1,75 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# <it-notification>
|
|
2
2
|
|
|
3
|
-
This
|
|
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
|
-
|
|
8
|
-
npm i @italia/notification
|
|
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
|
-
##
|
|
9
|
+
## Documentation
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
<script type="module">
|
|
15
|
-
import '@italia/notification';
|
|
16
|
-
</script>
|
|
17
|
-
|
|
18
|
-
<it-notification></it-notification>
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Linting and formatting
|
|
22
|
-
|
|
23
|
-
To scan the project for linting and formatting errors, run
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
npm run lint
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
To automatically fix linting and formatting errors, run
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
npm run format
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Testing with Web Test Runner
|
|
36
|
-
|
|
37
|
-
To execute a single test run:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
npm run test
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
To run the tests in interactive watch mode run:
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
npm run test:watch
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Demoing with Storybook
|
|
50
|
-
|
|
51
|
-
To run a local instance of Storybook for your component, run
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
npm run storybook
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
To build a production version of Storybook, run
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
npm run storybook:build
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## Tooling configs
|
|
64
|
-
|
|
65
|
-
For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
|
|
66
|
-
|
|
67
|
-
If you customize the configuration a lot, you can consider moving them to individual files.
|
|
68
|
-
|
|
69
|
-
## Local Demo with `web-dev-server`
|
|
70
|
-
|
|
71
|
-
```bash
|
|
72
|
-
npm start
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
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-notification--documentazione).
|
package/custom-elements.json
CHANGED
|
@@ -2,155 +2,6 @@
|
|
|
2
2
|
"schemaVersion": "1.0.0",
|
|
3
3
|
"readme": "",
|
|
4
4
|
"modules": [
|
|
5
|
-
{
|
|
6
|
-
"kind": "javascript-module",
|
|
7
|
-
"path": "stories/it-notification.stories.ts",
|
|
8
|
-
"declarations": [
|
|
9
|
-
{
|
|
10
|
-
"kind": "variable",
|
|
11
|
-
"name": "meta",
|
|
12
|
-
"default": "{ title: 'Componenti/Notification', tags: ['a11y-ok', 'web-component', 'alpha'], component: 'it-notification', parameters: { layout: 'padded', }, // decorators: [(story) => html` <div class=\"container p-0\">${story()}</div> `], args: { icon: 'it-info-circle', dismissable: false, }, argTypes: { headingLevel: { name: 'heading-level', control: 'select', type: 'string', options: [undefined, ...NOTIFICATION_HEADING_LEVELS], description: 'Livello di heading da usare per il titolo della notifica. Se non specificato, viene usato h2. Vedi la sezione \"Accessibilità\" della documentazione per maggiori dettagli.', }, icon: { name: 'icon', control: 'text', description: \"Nome dell'icona da visualizzare nella notifica.\", }, status: { control: 'select', type: 'string', options: [undefined, ...NOTIFICATION_STATUS], description: 'Stato della notifica, che ne influenza il colore.', }, dismissable: { control: 'boolean', type: 'boolean', description: 'Se presente, mostra un pulsante per chiudere la notifica.', }, fix: { control: 'select', type: 'string', options: [undefined, ...NOTIFICATION_FIX], description: 'Fissa la posizione della notifica nel lato scelto dello schermo.', }, timeout: { control: 'number', type: 'number', description: 'Tempo di permanenza della notifica, espresso in millisecondi.', }, }, } satisfies Meta<NotificationProps>"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"kind": "variable",
|
|
16
|
-
"name": "EsempioInterattivo",
|
|
17
|
-
"type": {
|
|
18
|
-
"text": "Story"
|
|
19
|
-
},
|
|
20
|
-
"default": "{ name: 'Esempio interattivo', tags: ['!dev'], parameters: { docs: { canvas: { sourceState: 'shown', }, }, }, decorators: [ (story) => html` <div class=\"test-docs\" style=\"display:grid;gap:24px;grid-template-columns:1fr 1fr;\">${story()}</div> `, ], render: (args) => html` <div> <p class=\"mb-4\"><strong>Notification standard</strong></p> <it-notification heading-level=${ifDefined(args.headingLevel)} status=${ifDefined(args.status)} ?dismissable=${args.dismissable} ?fix=${args.fix} timeout=${ifDefined(args.timeout || undefined)} > <span slot=\"title\">Titolo notifica</span> </it-notification> </div> <div> <p class=\"mb-4\"><strong>Notification con icona</strong></p> <it-notification heading-level=${ifDefined(args.headingLevel)} icon=${ifDefined(args.icon || undefined)} status=${ifDefined(args.status)} ?dismissable=${args.dismissable} ?fix=${args.fix} timeout=${ifDefined(args.timeout || undefined)} > <span slot=\"title\">Titolo notifica</span> </it-notification> </div> `, }"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"kind": "variable",
|
|
24
|
-
"name": "ConMessaggio",
|
|
25
|
-
"type": {
|
|
26
|
-
"text": "Story"
|
|
27
|
-
},
|
|
28
|
-
"default": "{ name: 'Notifica con messaggio', decorators: [ (story) => html` <div class=\"test-docs\" style=\"display:grid;gap:24px;grid-template-columns:1fr 1fr;\">${story()}</div> `, ], argTypes: { ...disabledControls(['headingLevel', 'status']) }, render: (args) => html` <div> <p class=\"mb-4\"><strong>Notifica standard con testo</strong></p> <it-notification heading-level=${ifDefined(args.headingLevel)} status=${ifDefined(args.status)}> <span slot=\"title\">Titolo notifica</span> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor…</p> </it-notification> </div> <div> <p class=\"mb-4\"><strong>Notifica con icona e testo</strong></p> <it-notification heading-level=${ifDefined(args.headingLevel)} icon=${ifDefined(args.icon || undefined)} status=${ifDefined(args.status)} > <span slot=\"title\">Titolo notifica</span> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor…</p> </it-notification> </div> `, }"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"kind": "variable",
|
|
32
|
-
"name": "Eliminabili",
|
|
33
|
-
"type": {
|
|
34
|
-
"text": "Story"
|
|
35
|
-
},
|
|
36
|
-
"default": "{ decorators: [ (story) => html` <div class=\"test-docs\" style=\"display:grid;gap:24px;grid-template-columns:1fr 1fr;\">${story()}</div> `, ], argTypes: { ...disabledControls() }, render: (args) => html` <div> <p class=\"mb-4\"><strong>Notification standard</strong></p> <it-notification dismissable> <span slot=\"title\">Titolo notifica</span> </it-notification> </div> <div> <p class=\"mb-4\"><strong>Notification con icona</strong></p> <it-notification icon=${ifDefined(args.icon || undefined)} status=\"success\" dismissable> <span slot=\"title\">Titolo notifica</span> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor…</p> </it-notification> </div> `, }"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"kind": "variable",
|
|
40
|
-
"name": "Stati",
|
|
41
|
-
"type": {
|
|
42
|
-
"text": "Story"
|
|
43
|
-
},
|
|
44
|
-
"default": "{ decorators: [ (story) => html` <div class=\"test-docs\" style=\"display:grid;gap:24px;grid-template-columns:1fr 1fr;\">${story()}</div> `, ], argTypes: { ...disabledControls() }, render: () => html` <div> <p class=\"mb-4\"><strong>Successo</strong></p> <it-notification status=\"success\" icon=\"it-check-circle\"> <span slot=\"title\">Titolo notifica</span> </it-notification> </div> <div> <p class=\"mb-4\"><strong>Errore</strong></p> <it-notification status=\"error\" icon=\"it-close-circle\"> <span slot=\"title\">Titolo notifica</span> </it-notification> </div> <div> <p class=\"mb-4\"><strong>Info</strong></p> <it-notification status=\"info\" icon=\"it-info-circle\"> <span slot=\"title\">Titolo notifica</span> </it-notification> </div> <div> <p class=\"mb-4\"><strong>Precauzione</strong></p> <it-notification status=\"warning\" icon=\"it-error\"> <span slot=\"title\">Titolo notifica</span> </it-notification> </div> `, }"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"kind": "variable",
|
|
48
|
-
"name": "PosizionePredefinita",
|
|
49
|
-
"type": {
|
|
50
|
-
"text": "Story"
|
|
51
|
-
},
|
|
52
|
-
"default": "{ name: 'Posizione predefinita', decorators: [(story) => html` <div class=\"test-desktop\">${story()}</div> `], argTypes: { ...disabledControls() }, render: () => html` <it-notification icon=\"it-check-circle\" status=\"success\"> <span slot=\"title\">Titolo notifica</span> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor…</p> </it-notification> `, }"
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
"kind": "variable",
|
|
56
|
-
"name": "PosizioneFissa",
|
|
57
|
-
"type": {
|
|
58
|
-
"text": "Story"
|
|
59
|
-
},
|
|
60
|
-
"default": "{ name: 'Posizione fissa', parameters: { layout: 'fullscreen', }, decorators: [(story) => html` <div class=\"test-desktop\">${story()}</div> `], argTypes: { ...disabledControls() }, render: () => html` <it-notification icon=\"it-check-circle\" status=\"success\" fix=\"top\"> <span slot=\"title\">Top fix</span> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor…</p> </it-notification> <it-notification icon=\"it-check-circle\" status=\"success\" fix=\"bottom\"> <span slot=\"title\">Bottom fix</span> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor…</p> </it-notification> <it-notification icon=\"it-check-circle\" status=\"success\" fix=\"left\"> <span slot=\"title\">Titolo notifica</span> </it-notification> <it-notification icon=\"it-check-circle\" status=\"success\" fix=\"right\"> <span slot=\"title\">Titolo notifica</span> </it-notification> `, }"
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
"kind": "variable",
|
|
64
|
-
"name": "Attivazione",
|
|
65
|
-
"type": {
|
|
66
|
-
"text": "Story"
|
|
67
|
-
},
|
|
68
|
-
"default": "{ name: 'A scomparsa automatica', decorators: [(story) => html` <div style=\"position:relative;width:100%;height:400px\">${story()}</div> `], argTypes: { ...disabledControls(['timeout']) }, render: (args) => html` <div id=\"esempio-attivazione\"> <it-button type=\"button\" variant=\"primary\">Inviami una notifica</it-button> <it-button type=\"button\" variant=\"primary\" id=\"five-sec\"> Inviami una notifica (durata 5 secondi) </it-button> <it-notification icon=\"it-check-circle\" status=\"success\" timeout=\"${ifDefined(args.timeout || undefined)}\"> <span slot=\"title\">Titolo notifica</span> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor…</p> </it-notification> </div> <script> document.querySelector('#esempio-attivazione it-button').addEventListener('click', () => { document.querySelector('#esempio-attivazione it-notification').show(); }); document.querySelector('#esempio-attivazione it-button#five-sec').addEventListener('click', () => { document.querySelector('#esempio-attivazione it-notification').show(5000); }); </script> `, }"
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
"kind": "variable",
|
|
72
|
-
"name": "AttivazioneEdEliminazione",
|
|
73
|
-
"type": {
|
|
74
|
-
"text": "Story"
|
|
75
|
-
},
|
|
76
|
-
"default": "{ name: 'A scomparsa manuale', decorators: [(story) => html` <div style=\"position:relative;width:100%;height:400px\">${story()}</div> `], argTypes: { ...disabledControls() }, render: () => html` <div id=\"esempio-eliminazione\"> <it-button type=\"button\" variant=\"primary\">Inviami una notifica</it-button> <it-button type=\"button\" variant=\"primary\" id=\"delete-notification\"> Rimuovi notifica </it-button> <it-notification icon=\"it-check-circle\" status=\"success\" dismissable> <span slot=\"title\">Titolo notifica</span> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor…</p> </it-notification> </div> <script> document.querySelector('#esempio-eliminazione it-button').addEventListener('click', () => { document.querySelector('#esempio-eliminazione it-notification').show(); }); document.querySelector('#esempio-eliminazione it-button#delete-notification').addEventListener('click', () => { document.querySelector('#esempio-eliminazione it-notification').hide(); }); </script> `, }"
|
|
77
|
-
}
|
|
78
|
-
],
|
|
79
|
-
"exports": [
|
|
80
|
-
{
|
|
81
|
-
"kind": "js",
|
|
82
|
-
"name": "default",
|
|
83
|
-
"declaration": {
|
|
84
|
-
"name": "meta",
|
|
85
|
-
"module": "stories/it-notification.stories.ts"
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
"kind": "js",
|
|
90
|
-
"name": "EsempioInterattivo",
|
|
91
|
-
"declaration": {
|
|
92
|
-
"name": "EsempioInterattivo",
|
|
93
|
-
"module": "stories/it-notification.stories.ts"
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
"kind": "js",
|
|
98
|
-
"name": "ConMessaggio",
|
|
99
|
-
"declaration": {
|
|
100
|
-
"name": "ConMessaggio",
|
|
101
|
-
"module": "stories/it-notification.stories.ts"
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
"kind": "js",
|
|
106
|
-
"name": "Eliminabili",
|
|
107
|
-
"declaration": {
|
|
108
|
-
"name": "Eliminabili",
|
|
109
|
-
"module": "stories/it-notification.stories.ts"
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
"kind": "js",
|
|
114
|
-
"name": "Stati",
|
|
115
|
-
"declaration": {
|
|
116
|
-
"name": "Stati",
|
|
117
|
-
"module": "stories/it-notification.stories.ts"
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
"kind": "js",
|
|
122
|
-
"name": "PosizionePredefinita",
|
|
123
|
-
"declaration": {
|
|
124
|
-
"name": "PosizionePredefinita",
|
|
125
|
-
"module": "stories/it-notification.stories.ts"
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
"kind": "js",
|
|
130
|
-
"name": "PosizioneFissa",
|
|
131
|
-
"declaration": {
|
|
132
|
-
"name": "PosizioneFissa",
|
|
133
|
-
"module": "stories/it-notification.stories.ts"
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
"kind": "js",
|
|
138
|
-
"name": "Attivazione",
|
|
139
|
-
"declaration": {
|
|
140
|
-
"name": "Attivazione",
|
|
141
|
-
"module": "stories/it-notification.stories.ts"
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
"kind": "js",
|
|
146
|
-
"name": "AttivazioneEdEliminazione",
|
|
147
|
-
"declaration": {
|
|
148
|
-
"name": "AttivazioneEdEliminazione",
|
|
149
|
-
"module": "stories/it-notification.stories.ts"
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
]
|
|
153
|
-
},
|
|
154
5
|
{
|
|
155
6
|
"kind": "javascript-module",
|
|
156
7
|
"path": "src/index.ts",
|
|
@@ -163,6 +14,14 @@
|
|
|
163
14
|
"name": "ItNotification",
|
|
164
15
|
"module": "./it-notification.js"
|
|
165
16
|
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"kind": "js",
|
|
20
|
+
"name": "NotificationEventDetail",
|
|
21
|
+
"declaration": {
|
|
22
|
+
"name": "NotificationEventDetail",
|
|
23
|
+
"module": "./types.js"
|
|
24
|
+
}
|
|
166
25
|
}
|
|
167
26
|
]
|
|
168
27
|
},
|
|
@@ -172,7 +31,7 @@
|
|
|
172
31
|
"declarations": [
|
|
173
32
|
{
|
|
174
33
|
"kind": "class",
|
|
175
|
-
"description": "",
|
|
34
|
+
"description": "Componente Notification.",
|
|
176
35
|
"name": "ItNotification",
|
|
177
36
|
"members": [
|
|
178
37
|
{
|
|
@@ -272,6 +131,13 @@
|
|
|
272
131
|
"text": "HTMLElement"
|
|
273
132
|
}
|
|
274
133
|
},
|
|
134
|
+
{
|
|
135
|
+
"kind": "field",
|
|
136
|
+
"name": "liveRegion",
|
|
137
|
+
"type": {
|
|
138
|
+
"text": "HTMLElement"
|
|
139
|
+
}
|
|
140
|
+
},
|
|
275
141
|
{
|
|
276
142
|
"kind": "field",
|
|
277
143
|
"name": "isShown",
|
|
@@ -288,6 +154,16 @@
|
|
|
288
154
|
},
|
|
289
155
|
"default": "false"
|
|
290
156
|
},
|
|
157
|
+
{
|
|
158
|
+
"kind": "field",
|
|
159
|
+
"name": "_returnFocusTarget",
|
|
160
|
+
"type": {
|
|
161
|
+
"text": "HTMLElement | null"
|
|
162
|
+
},
|
|
163
|
+
"privacy": "private",
|
|
164
|
+
"default": "null",
|
|
165
|
+
"description": "Element focused right before `show()` was called (e.g. the button that triggered it).\nRestored on `hide()` if focus was left inside the notification (e.g. its close button),\nsince there is no author-provided trigger slot to fall back on like `it-modal` has."
|
|
166
|
+
},
|
|
291
167
|
{
|
|
292
168
|
"kind": "method",
|
|
293
169
|
"name": "show",
|
|
@@ -316,6 +192,51 @@
|
|
|
316
192
|
"text": "NotificationHeadingLevel"
|
|
317
193
|
}
|
|
318
194
|
}
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"kind": "method",
|
|
198
|
+
"name": "getSlotText",
|
|
199
|
+
"privacy": "protected",
|
|
200
|
+
"return": {
|
|
201
|
+
"type": {
|
|
202
|
+
"text": "string"
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
"parameters": [
|
|
206
|
+
{
|
|
207
|
+
"name": "name",
|
|
208
|
+
"optional": true,
|
|
209
|
+
"type": {
|
|
210
|
+
"text": "string"
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
]
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"kind": "method",
|
|
217
|
+
"name": "announce",
|
|
218
|
+
"privacy": "protected",
|
|
219
|
+
"return": {
|
|
220
|
+
"type": {
|
|
221
|
+
"text": "void"
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
],
|
|
226
|
+
"events": [
|
|
227
|
+
{
|
|
228
|
+
"name": "it-notification-show",
|
|
229
|
+
"type": {
|
|
230
|
+
"text": "CustomEvent"
|
|
231
|
+
},
|
|
232
|
+
"description": "Quando la notifica viene mostrata"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"name": "it-notification-close",
|
|
236
|
+
"type": {
|
|
237
|
+
"text": "CustomEvent"
|
|
238
|
+
},
|
|
239
|
+
"description": "Quando la notifica viene chiusa (click sul pulsante di chiusura, scomparsa automatica o chiamata a `hide()`)"
|
|
319
240
|
}
|
|
320
241
|
],
|
|
321
242
|
"attributes": [
|
|
@@ -472,6 +393,155 @@
|
|
|
472
393
|
}
|
|
473
394
|
]
|
|
474
395
|
},
|
|
396
|
+
{
|
|
397
|
+
"kind": "javascript-module",
|
|
398
|
+
"path": "stories/it-notification.stories.ts",
|
|
399
|
+
"declarations": [
|
|
400
|
+
{
|
|
401
|
+
"kind": "variable",
|
|
402
|
+
"name": "meta",
|
|
403
|
+
"default": "{ title: 'Componenti/Notification', tags: ['a11y-ok', 'web-component'], component: 'it-notification', parameters: { layout: 'padded', }, // decorators: [(story) => html` <div class=\"container p-0\">${story()}</div> `], args: { icon: 'it-info-circle', dismissable: false, }, argTypes: { headingLevel: { name: 'heading-level', control: 'select', type: 'string', options: [undefined, ...NOTIFICATION_HEADING_LEVELS], description: 'Livello di heading da usare per il titolo della notifica. Se non specificato, viene usato h2. Vedi la sezione \"Accessibilità\" della documentazione per maggiori dettagli.', }, icon: { name: 'icon', control: 'text', description: \"Nome dell'icona da visualizzare nella notifica.\", }, status: { control: 'select', type: 'string', options: [undefined, ...NOTIFICATION_STATUS], description: 'Stato della notifica, che ne influenza il colore.', }, dismissable: { control: 'boolean', type: 'boolean', description: 'Se presente, mostra un pulsante per chiudere la notifica.', }, fix: { control: 'select', type: 'string', options: [undefined, ...NOTIFICATION_FIX], description: 'Fissa la posizione della notifica nel lato scelto dello schermo.', }, timeout: { control: 'number', type: 'number', description: 'Tempo di permanenza della notifica, espresso in millisecondi.', }, }, } satisfies Meta<NotificationProps>"
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
"kind": "variable",
|
|
407
|
+
"name": "EsempioInterattivo",
|
|
408
|
+
"type": {
|
|
409
|
+
"text": "Story"
|
|
410
|
+
},
|
|
411
|
+
"default": "{ name: 'Esempio interattivo', tags: ['!dev'], parameters: { docs: { canvas: { sourceState: 'shown', }, }, }, decorators: [ (story) => html` <div class=\"test-docs\" style=\"display:grid;gap:24px;grid-template-columns:1fr 1fr;\">${story()}</div> `, ], render: (args) => html` <div> <p class=\"mb-4\"><strong>Notification standard</strong></p> <it-notification heading-level=${ifDefined(args.headingLevel)} status=${ifDefined(args.status)} ?dismissable=${args.dismissable} ?fix=${args.fix} timeout=${ifDefined(args.timeout || undefined)} > <span slot=\"title\">Titolo notifica</span> </it-notification> </div> <div> <p class=\"mb-4\"><strong>Notification con icona</strong></p> <it-notification heading-level=${ifDefined(args.headingLevel)} icon=${ifDefined(args.icon || undefined)} status=${ifDefined(args.status)} ?dismissable=${args.dismissable} ?fix=${args.fix} timeout=${ifDefined(args.timeout || undefined)} > <span slot=\"title\">Titolo notifica</span> </it-notification> </div> `, }"
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
"kind": "variable",
|
|
415
|
+
"name": "ConMessaggio",
|
|
416
|
+
"type": {
|
|
417
|
+
"text": "Story"
|
|
418
|
+
},
|
|
419
|
+
"default": "{ name: 'Notifica con messaggio', decorators: [ (story) => html` <div class=\"test-docs\" style=\"display:grid;gap:24px;grid-template-columns:1fr 1fr;\">${story()}</div> `, ], argTypes: { ...disabledControls(['headingLevel', 'status']) }, render: (args) => html` <div> <p class=\"mb-4\"><strong>Notifica standard con testo</strong></p> <it-notification heading-level=${ifDefined(args.headingLevel)} status=${ifDefined(args.status)}> <span slot=\"title\">Titolo notifica</span> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor…</p> </it-notification> </div> <div> <p class=\"mb-4\"><strong>Notifica con icona e testo</strong></p> <it-notification heading-level=${ifDefined(args.headingLevel)} icon=${ifDefined(args.icon || undefined)} status=${ifDefined(args.status)} > <span slot=\"title\">Titolo notifica</span> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor…</p> </it-notification> </div> `, }"
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
"kind": "variable",
|
|
423
|
+
"name": "Eliminabili",
|
|
424
|
+
"type": {
|
|
425
|
+
"text": "Story"
|
|
426
|
+
},
|
|
427
|
+
"default": "{ decorators: [ (story) => html` <div class=\"test-docs\" style=\"display:grid;gap:24px;grid-template-columns:1fr 1fr;\">${story()}</div> `, ], argTypes: { ...disabledControls() }, render: (args) => html` <div> <p class=\"mb-4\"><strong>Notification standard</strong></p> <it-notification dismissable> <span slot=\"title\">Titolo notifica</span> </it-notification> </div> <div> <p class=\"mb-4\"><strong>Notification con icona</strong></p> <it-notification icon=${ifDefined(args.icon || undefined)} status=\"success\" dismissable> <span slot=\"title\">Titolo notifica</span> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor…</p> </it-notification> </div> `, }"
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
"kind": "variable",
|
|
431
|
+
"name": "Stati",
|
|
432
|
+
"type": {
|
|
433
|
+
"text": "Story"
|
|
434
|
+
},
|
|
435
|
+
"default": "{ decorators: [ (story) => html` <div class=\"test-docs\" style=\"display:grid;gap:24px;grid-template-columns:1fr 1fr;\">${story()}</div> `, ], argTypes: { ...disabledControls() }, render: () => html` <div> <p class=\"mb-4\"><strong>Successo</strong></p> <it-notification status=\"success\" icon=\"it-check-circle\"> <span slot=\"title\">Titolo notifica</span> </it-notification> </div> <div> <p class=\"mb-4\"><strong>Errore</strong></p> <it-notification status=\"error\" icon=\"it-close-circle\"> <span slot=\"title\">Titolo notifica</span> </it-notification> </div> <div> <p class=\"mb-4\"><strong>Info</strong></p> <it-notification status=\"info\" icon=\"it-info-circle\"> <span slot=\"title\">Titolo notifica</span> </it-notification> </div> <div> <p class=\"mb-4\"><strong>Precauzione</strong></p> <it-notification status=\"warning\" icon=\"it-error\"> <span slot=\"title\">Titolo notifica</span> </it-notification> </div> `, }"
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
"kind": "variable",
|
|
439
|
+
"name": "PosizionePredefinita",
|
|
440
|
+
"type": {
|
|
441
|
+
"text": "Story"
|
|
442
|
+
},
|
|
443
|
+
"default": "{ name: 'Posizione predefinita', decorators: [(story) => html` <div class=\"test-desktop\">${story()}</div> `], argTypes: { ...disabledControls() }, render: () => html` <it-notification icon=\"it-check-circle\" status=\"success\"> <span slot=\"title\">Titolo notifica</span> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor…</p> </it-notification> `, }"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
"kind": "variable",
|
|
447
|
+
"name": "PosizioneFissa",
|
|
448
|
+
"type": {
|
|
449
|
+
"text": "Story"
|
|
450
|
+
},
|
|
451
|
+
"default": "{ name: 'Posizione fissa', parameters: { layout: 'fullscreen', }, decorators: [(story) => html` <div class=\"test-desktop\">${story()}</div> `], argTypes: { ...disabledControls() }, render: () => html` <it-notification icon=\"it-check-circle\" status=\"success\" fix=\"top\"> <span slot=\"title\">Top fix</span> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor…</p> </it-notification> <it-notification icon=\"it-check-circle\" status=\"success\" fix=\"bottom\"> <span slot=\"title\">Bottom fix</span> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor…</p> </it-notification> <it-notification icon=\"it-check-circle\" status=\"success\" fix=\"left\"> <span slot=\"title\">Titolo notifica</span> </it-notification> <it-notification icon=\"it-check-circle\" status=\"success\" fix=\"right\"> <span slot=\"title\">Titolo notifica</span> </it-notification> `, }"
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
"kind": "variable",
|
|
455
|
+
"name": "Attivazione",
|
|
456
|
+
"type": {
|
|
457
|
+
"text": "Story"
|
|
458
|
+
},
|
|
459
|
+
"default": "{ name: 'A scomparsa automatica', decorators: [(story) => html` <div style=\"position:relative;width:100%;height:400px\">${story()}</div> `], argTypes: { ...disabledControls(['timeout']) }, render: (args) => html` <div id=\"esempio-attivazione\"> <it-button type=\"button\" variant=\"primary\">Inviami una notifica</it-button> <it-button type=\"button\" variant=\"primary\" id=\"five-sec\"> Inviami una notifica (durata 5 secondi) </it-button> <it-notification icon=\"it-check-circle\" status=\"success\" timeout=\"${ifDefined(args.timeout || undefined)}\"> <span slot=\"title\">Titolo notifica</span> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor…</p> </it-notification> </div> <script> document.querySelector('#esempio-attivazione it-button').addEventListener('click', () => { document.querySelector('#esempio-attivazione it-notification').show(); }); document.querySelector('#esempio-attivazione it-button#five-sec').addEventListener('click', () => { document.querySelector('#esempio-attivazione it-notification').show(5000); }); </script> `, }"
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
"kind": "variable",
|
|
463
|
+
"name": "AttivazioneEdEliminazione",
|
|
464
|
+
"type": {
|
|
465
|
+
"text": "Story"
|
|
466
|
+
},
|
|
467
|
+
"default": "{ name: 'A scomparsa manuale', decorators: [(story) => html` <div style=\"position:relative;width:100%;height:400px\">${story()}</div> `], argTypes: { ...disabledControls() }, render: () => html` <div id=\"esempio-eliminazione\"> <it-button type=\"button\" variant=\"primary\">Inviami una notifica</it-button> <it-button type=\"button\" variant=\"primary\" id=\"delete-notification\"> Rimuovi notifica </it-button> <it-notification icon=\"it-check-circle\" status=\"success\" dismissable> <span slot=\"title\">Titolo notifica</span> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor…</p> </it-notification> </div> <script> document.querySelector('#esempio-eliminazione it-button').addEventListener('click', () => { document.querySelector('#esempio-eliminazione it-notification').show(); }); document.querySelector('#esempio-eliminazione it-button#delete-notification').addEventListener('click', () => { document.querySelector('#esempio-eliminazione it-notification').hide(); }); </script> `, }"
|
|
468
|
+
}
|
|
469
|
+
],
|
|
470
|
+
"exports": [
|
|
471
|
+
{
|
|
472
|
+
"kind": "js",
|
|
473
|
+
"name": "default",
|
|
474
|
+
"declaration": {
|
|
475
|
+
"name": "meta",
|
|
476
|
+
"module": "stories/it-notification.stories.ts"
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
"kind": "js",
|
|
481
|
+
"name": "EsempioInterattivo",
|
|
482
|
+
"declaration": {
|
|
483
|
+
"name": "EsempioInterattivo",
|
|
484
|
+
"module": "stories/it-notification.stories.ts"
|
|
485
|
+
}
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
"kind": "js",
|
|
489
|
+
"name": "ConMessaggio",
|
|
490
|
+
"declaration": {
|
|
491
|
+
"name": "ConMessaggio",
|
|
492
|
+
"module": "stories/it-notification.stories.ts"
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
"kind": "js",
|
|
497
|
+
"name": "Eliminabili",
|
|
498
|
+
"declaration": {
|
|
499
|
+
"name": "Eliminabili",
|
|
500
|
+
"module": "stories/it-notification.stories.ts"
|
|
501
|
+
}
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
"kind": "js",
|
|
505
|
+
"name": "Stati",
|
|
506
|
+
"declaration": {
|
|
507
|
+
"name": "Stati",
|
|
508
|
+
"module": "stories/it-notification.stories.ts"
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
"kind": "js",
|
|
513
|
+
"name": "PosizionePredefinita",
|
|
514
|
+
"declaration": {
|
|
515
|
+
"name": "PosizionePredefinita",
|
|
516
|
+
"module": "stories/it-notification.stories.ts"
|
|
517
|
+
}
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
"kind": "js",
|
|
521
|
+
"name": "PosizioneFissa",
|
|
522
|
+
"declaration": {
|
|
523
|
+
"name": "PosizioneFissa",
|
|
524
|
+
"module": "stories/it-notification.stories.ts"
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
"kind": "js",
|
|
529
|
+
"name": "Attivazione",
|
|
530
|
+
"declaration": {
|
|
531
|
+
"name": "Attivazione",
|
|
532
|
+
"module": "stories/it-notification.stories.ts"
|
|
533
|
+
}
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
"kind": "js",
|
|
537
|
+
"name": "AttivazioneEdEliminazione",
|
|
538
|
+
"declaration": {
|
|
539
|
+
"name": "AttivazioneEdEliminazione",
|
|
540
|
+
"module": "stories/it-notification.stories.ts"
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
]
|
|
544
|
+
},
|
|
475
545
|
{
|
|
476
546
|
"kind": "javascript-module",
|
|
477
547
|
"path": "src/locales/en.ts",
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { BaseLocalizedComponent } from '@italia/globals';
|
|
2
2
|
import { PropertyValues } from 'lit';
|
|
3
3
|
import { type NotificationFix, type NotificationHeadingLevel, type NotificationStatus } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Componente Notification.
|
|
6
|
+
*
|
|
7
|
+
* @element it-notification
|
|
8
|
+
*
|
|
9
|
+
* @fires it-notification-show - Quando la notifica viene mostrata
|
|
10
|
+
* @fires it-notification-close - Quando la notifica viene chiusa (click sul pulsante di chiusura, scomparsa automatica o chiamata a `hide()`)
|
|
11
|
+
*/
|
|
4
12
|
export declare class ItNotification extends BaseLocalizedComponent {
|
|
5
13
|
static styles: import("lit").CSSResultGroup;
|
|
6
14
|
static CLASS_NAME_FADE: string;
|
|
@@ -14,12 +22,19 @@ export declare class ItNotification extends BaseLocalizedComponent {
|
|
|
14
22
|
fix?: NotificationFix;
|
|
15
23
|
timeout: number;
|
|
16
24
|
container: HTMLElement;
|
|
25
|
+
liveRegion: HTMLElement;
|
|
17
26
|
isShown: boolean;
|
|
18
27
|
isTransitioning: boolean;
|
|
28
|
+
/** Element focused right before `show()` was called (e.g. the button that triggered it).
|
|
29
|
+
* Restored on `hide()` if focus was left inside the notification (e.g. its close button),
|
|
30
|
+
* since there is no author-provided trigger slot to fall back on like `it-modal` has. */
|
|
31
|
+
private _returnFocusTarget;
|
|
19
32
|
protected updated(_changedProperties: PropertyValues): void;
|
|
20
33
|
show(timeout?: number): void;
|
|
21
34
|
hide(): void;
|
|
22
35
|
protected getHeadingLevel(): NotificationHeadingLevel;
|
|
36
|
+
protected getSlotText(name?: string): string;
|
|
37
|
+
protected announce(): void;
|
|
23
38
|
render(): import("lit").TemplateResult<1>;
|
|
24
39
|
}
|
|
25
40
|
declare global {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"it-notification.d.ts","sourceRoot":"","sources":["../../src/it-notification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,
|
|
1
|
+
{"version":3,"file":"it-notification.d.ts","sourceRoot":"","sources":["../../src/it-notification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAyD,MAAM,iBAAiB,CAAC;AAChH,OAAO,EAAQ,cAAc,EAAE,MAAM,KAAK,CAAC;AAK3C,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EAExB,MAAM,YAAY,CAAC;AASpB;;;;;;;GAOG;AACH,qBACa,cAAe,SAAQ,sBAAsB;IACxD,MAAM,CAAC,MAAM,+BAAU;IAEvB,MAAM,CAAC,eAAe,SAAU;IAEhC,MAAM,CAAC,eAAe,SAAU;IAEhC,MAAM,CAAC,mBAAmB,SAAO;IAGjC,YAAY,EAAE,wBAAwB,CAAQ;IAG9C,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAG5B,WAAW,UAAS;IAGpB,IAAI,UAAQ;IAGZ,GAAG,CAAC,EAAE,eAAe,CAAC;IAGtB,OAAO,EAAE,MAAM,CAAQ;IAGvB,SAAS,EAAG,WAAW,CAAC;IAGxB,UAAU,EAAG,WAAW,CAAC;IAGzB,OAAO,UAAS;IAGhB,eAAe,UAAS;IAExB;;8FAE0F;IAC1F,OAAO,CAAC,kBAAkB,CAA4B;cAEnC,OAAO,CAAC,kBAAkB,EAAE,cAAc,GAAG,IAAI;IAgB7D,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM;IAuDrB,IAAI;IA0CX,SAAS,CAAC,eAAe,IAAI,wBAAwB;IAOrD,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM;IAU5C,SAAS,CAAC,QAAQ,IAAI,IAAI;IAIjB,MAAM;CAgDhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,cAAc,CAAC;KACnC;CACF"}
|