@italia/tooltip 1.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUTHORS +3 -0
- package/LICENSE +18 -0
- package/README.md +67 -0
- package/custom-elements.json +497 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/it-tooltip.d.ts +46 -0
- package/dist/src/it-tooltip.d.ts.map +1 -0
- package/dist/src/it-tooltip.js +3146 -0
- package/dist/src/it-tooltip.js.map +1 -0
- package/dist/src/types.d.ts +4 -0
- package/dist/src/types.d.ts.map +1 -0
- package/package.json +73 -0
- package/styles/globals.scss +6 -0
package/AUTHORS
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
14
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
15
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
16
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
17
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
18
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# \<it-tooltip>
|
|
2
|
+
|
|
3
|
+
This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @italia/tooltip
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<script type="module">
|
|
15
|
+
import '@italia/tooltip';
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<it-tooltip></it-tooltip>
|
|
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.
|
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"readme": "",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "src/index.ts",
|
|
8
|
+
"declarations": [],
|
|
9
|
+
"exports": [
|
|
10
|
+
{
|
|
11
|
+
"kind": "js",
|
|
12
|
+
"name": "ItTooltip",
|
|
13
|
+
"declaration": {
|
|
14
|
+
"name": "ItTooltip",
|
|
15
|
+
"module": "./it-tooltip.js"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"kind": "javascript-module",
|
|
22
|
+
"path": "src/it-tooltip.ts",
|
|
23
|
+
"declarations": [
|
|
24
|
+
{
|
|
25
|
+
"kind": "class",
|
|
26
|
+
"description": "",
|
|
27
|
+
"name": "ItTooltip",
|
|
28
|
+
"members": [
|
|
29
|
+
{
|
|
30
|
+
"kind": "field",
|
|
31
|
+
"name": "OFFSET",
|
|
32
|
+
"type": {
|
|
33
|
+
"text": "number"
|
|
34
|
+
},
|
|
35
|
+
"static": true,
|
|
36
|
+
"default": "0"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"kind": "field",
|
|
40
|
+
"name": "TRANSITION_DURATION",
|
|
41
|
+
"type": {
|
|
42
|
+
"text": "number"
|
|
43
|
+
},
|
|
44
|
+
"static": true,
|
|
45
|
+
"default": "150"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"kind": "field",
|
|
49
|
+
"name": "open",
|
|
50
|
+
"type": {
|
|
51
|
+
"text": "boolean"
|
|
52
|
+
},
|
|
53
|
+
"default": "false",
|
|
54
|
+
"attribute": "open",
|
|
55
|
+
"reflects": true
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"kind": "field",
|
|
59
|
+
"name": "controlled",
|
|
60
|
+
"type": {
|
|
61
|
+
"text": "boolean"
|
|
62
|
+
},
|
|
63
|
+
"default": "false",
|
|
64
|
+
"attribute": "controlled"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"kind": "field",
|
|
68
|
+
"name": "placement",
|
|
69
|
+
"type": {
|
|
70
|
+
"text": "TooltipPlacement"
|
|
71
|
+
},
|
|
72
|
+
"default": "'top'",
|
|
73
|
+
"attribute": "placement"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"kind": "field",
|
|
77
|
+
"name": "noFlip",
|
|
78
|
+
"type": {
|
|
79
|
+
"text": "boolean"
|
|
80
|
+
},
|
|
81
|
+
"default": "false",
|
|
82
|
+
"attribute": "no-flip"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"kind": "field",
|
|
86
|
+
"name": "_triggerSlot",
|
|
87
|
+
"type": {
|
|
88
|
+
"text": "HTMLSlotElement"
|
|
89
|
+
},
|
|
90
|
+
"privacy": "private"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"kind": "field",
|
|
94
|
+
"name": "_contentSlot",
|
|
95
|
+
"type": {
|
|
96
|
+
"text": "HTMLSlotElement"
|
|
97
|
+
},
|
|
98
|
+
"privacy": "private"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"kind": "field",
|
|
102
|
+
"name": "_tooltipElement",
|
|
103
|
+
"type": {
|
|
104
|
+
"text": "HTMLElement"
|
|
105
|
+
},
|
|
106
|
+
"privacy": "private"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"kind": "field",
|
|
110
|
+
"name": "_arrowElement",
|
|
111
|
+
"type": {
|
|
112
|
+
"text": "HTMLElement"
|
|
113
|
+
},
|
|
114
|
+
"privacy": "private"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"kind": "field",
|
|
118
|
+
"name": "isTransitioning",
|
|
119
|
+
"type": {
|
|
120
|
+
"text": "boolean"
|
|
121
|
+
},
|
|
122
|
+
"default": "false"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"kind": "field",
|
|
126
|
+
"name": "_contentElement",
|
|
127
|
+
"type": {
|
|
128
|
+
"text": "HTMLElement | null"
|
|
129
|
+
},
|
|
130
|
+
"privacy": "private",
|
|
131
|
+
"default": "null"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"kind": "field",
|
|
135
|
+
"name": "_lastTrigger",
|
|
136
|
+
"type": {
|
|
137
|
+
"text": "HTMLElement | null"
|
|
138
|
+
},
|
|
139
|
+
"privacy": "private",
|
|
140
|
+
"default": "null"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"kind": "field",
|
|
144
|
+
"name": "_triggerElement",
|
|
145
|
+
"type": {
|
|
146
|
+
"text": "HTMLElement | null"
|
|
147
|
+
},
|
|
148
|
+
"privacy": "private",
|
|
149
|
+
"readonly": true
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"kind": "field",
|
|
153
|
+
"name": "_cleanup",
|
|
154
|
+
"type": {
|
|
155
|
+
"text": "() => void | undefined"
|
|
156
|
+
},
|
|
157
|
+
"privacy": "private"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"kind": "field",
|
|
161
|
+
"name": "_onMouseEnter",
|
|
162
|
+
"privacy": "private"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"kind": "field",
|
|
166
|
+
"name": "_onMouseLeave",
|
|
167
|
+
"privacy": "private"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"kind": "field",
|
|
171
|
+
"name": "_onTooltipMouseLeave",
|
|
172
|
+
"privacy": "private"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"kind": "field",
|
|
176
|
+
"name": "_onFocusIn",
|
|
177
|
+
"privacy": "private"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"kind": "field",
|
|
181
|
+
"name": "_onFocusOut",
|
|
182
|
+
"privacy": "private"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"kind": "field",
|
|
186
|
+
"name": "_onKeyDown",
|
|
187
|
+
"privacy": "private"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"kind": "method",
|
|
191
|
+
"name": "_cleanupDescribedBy",
|
|
192
|
+
"privacy": "private",
|
|
193
|
+
"return": {
|
|
194
|
+
"type": {
|
|
195
|
+
"text": "void"
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"kind": "method",
|
|
201
|
+
"name": "_setupAria",
|
|
202
|
+
"privacy": "private",
|
|
203
|
+
"return": {
|
|
204
|
+
"type": {
|
|
205
|
+
"text": "void"
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"kind": "method",
|
|
211
|
+
"name": "_setupStandardEvents",
|
|
212
|
+
"privacy": "private",
|
|
213
|
+
"return": {
|
|
214
|
+
"type": {
|
|
215
|
+
"text": "void"
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"kind": "method",
|
|
221
|
+
"name": "_removeListeners",
|
|
222
|
+
"privacy": "private",
|
|
223
|
+
"return": {
|
|
224
|
+
"type": {
|
|
225
|
+
"text": "void"
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"kind": "method",
|
|
231
|
+
"name": "_show",
|
|
232
|
+
"privacy": "private",
|
|
233
|
+
"return": {
|
|
234
|
+
"type": {
|
|
235
|
+
"text": "void"
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"kind": "method",
|
|
241
|
+
"name": "_hide",
|
|
242
|
+
"privacy": "private",
|
|
243
|
+
"return": {
|
|
244
|
+
"type": {
|
|
245
|
+
"text": "void"
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"kind": "method",
|
|
251
|
+
"name": "showTooltip",
|
|
252
|
+
"privacy": "public",
|
|
253
|
+
"return": {
|
|
254
|
+
"type": {
|
|
255
|
+
"text": "void"
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"kind": "method",
|
|
261
|
+
"name": "hideTooltip",
|
|
262
|
+
"privacy": "public",
|
|
263
|
+
"return": {
|
|
264
|
+
"type": {
|
|
265
|
+
"text": "void"
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
"kind": "method",
|
|
271
|
+
"name": "toggle",
|
|
272
|
+
"privacy": "public",
|
|
273
|
+
"return": {
|
|
274
|
+
"type": {
|
|
275
|
+
"text": "void"
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
],
|
|
280
|
+
"events": [
|
|
281
|
+
{
|
|
282
|
+
"name": "it-tooltip-open",
|
|
283
|
+
"type": {
|
|
284
|
+
"text": "CustomEvent"
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
"name": "it-tooltip-close",
|
|
289
|
+
"type": {
|
|
290
|
+
"text": "CustomEvent"
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
],
|
|
294
|
+
"attributes": [
|
|
295
|
+
{
|
|
296
|
+
"name": "open",
|
|
297
|
+
"type": {
|
|
298
|
+
"text": "boolean"
|
|
299
|
+
},
|
|
300
|
+
"default": "false",
|
|
301
|
+
"fieldName": "open"
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"name": "controlled",
|
|
305
|
+
"type": {
|
|
306
|
+
"text": "boolean"
|
|
307
|
+
},
|
|
308
|
+
"default": "false",
|
|
309
|
+
"fieldName": "controlled"
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
"name": "placement",
|
|
313
|
+
"type": {
|
|
314
|
+
"text": "TooltipPlacement"
|
|
315
|
+
},
|
|
316
|
+
"default": "'top'",
|
|
317
|
+
"fieldName": "placement"
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"name": "no-flip",
|
|
321
|
+
"type": {
|
|
322
|
+
"text": "boolean"
|
|
323
|
+
},
|
|
324
|
+
"default": "false",
|
|
325
|
+
"fieldName": "noFlip"
|
|
326
|
+
}
|
|
327
|
+
],
|
|
328
|
+
"superclass": {
|
|
329
|
+
"name": "BaseComponent",
|
|
330
|
+
"package": "@italia/globals"
|
|
331
|
+
},
|
|
332
|
+
"tagName": "it-tooltip",
|
|
333
|
+
"customElement": true
|
|
334
|
+
}
|
|
335
|
+
],
|
|
336
|
+
"exports": [
|
|
337
|
+
{
|
|
338
|
+
"kind": "js",
|
|
339
|
+
"name": "ItTooltip",
|
|
340
|
+
"declaration": {
|
|
341
|
+
"name": "ItTooltip",
|
|
342
|
+
"module": "src/it-tooltip.ts"
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
"kind": "custom-element-definition",
|
|
347
|
+
"name": "it-tooltip",
|
|
348
|
+
"declaration": {
|
|
349
|
+
"name": "ItTooltip",
|
|
350
|
+
"module": "src/it-tooltip.ts"
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
]
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"kind": "javascript-module",
|
|
357
|
+
"path": "src/types.ts",
|
|
358
|
+
"declarations": [
|
|
359
|
+
{
|
|
360
|
+
"kind": "variable",
|
|
361
|
+
"name": "TOOLTIP_PLACEMENTS",
|
|
362
|
+
"type": {
|
|
363
|
+
"text": "[\n 'top',\n 'top-start',\n 'top-end',\n 'right',\n 'right-start',\n 'right-end',\n 'bottom',\n 'bottom-start',\n 'bottom-end',\n 'left',\n 'left-start',\n 'left-end',\n]"
|
|
364
|
+
},
|
|
365
|
+
"default": "[ 'top', 'top-start', 'top-end', 'right', 'right-start', 'right-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', ]"
|
|
366
|
+
}
|
|
367
|
+
],
|
|
368
|
+
"exports": [
|
|
369
|
+
{
|
|
370
|
+
"kind": "js",
|
|
371
|
+
"name": "TOOLTIP_PLACEMENTS",
|
|
372
|
+
"declaration": {
|
|
373
|
+
"name": "TOOLTIP_PLACEMENTS",
|
|
374
|
+
"module": "src/types.ts"
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
]
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
"kind": "javascript-module",
|
|
381
|
+
"path": "stories/it-tooltip.stories.ts",
|
|
382
|
+
"declarations": [
|
|
383
|
+
{
|
|
384
|
+
"kind": "variable",
|
|
385
|
+
"name": "meta",
|
|
386
|
+
"default": "{ title: 'Componenti/Tooltip', component: 'it-tooltip', tags: ['alpha', 'web-component', 'a11y-ok'], parameters: { layout: 'padded', }, args: { placement: 'top', }, argTypes: { placement: { control: 'select', options: TOOLTIP_PLACEMENTS, description: 'Posizione del Tooltip rispetto al suo elemento trigger', table: { defaultValue: { summary: 'top' } }, }, }, } satisfies Meta<TooltipArgs>"
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
"kind": "variable",
|
|
390
|
+
"name": "Base",
|
|
391
|
+
"type": {
|
|
392
|
+
"text": "Story"
|
|
393
|
+
},
|
|
394
|
+
"default": "{ decorators: [(story) => html`<div style=\"padding:30px 0;text-align:center\">${story()}</div>`], render: (args) => html` <it-tooltip placement=${ifDefined(args.placement)}> <it-button slot=\"trigger\" variant=\"primary\">Mostra tooltip</it-button> <span slot=\"content\">Testo del tooltip</span> </it-tooltip> `, tags: ['!autodocs', '!dev'], }"
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
"kind": "variable",
|
|
398
|
+
"name": "SuLink",
|
|
399
|
+
"type": {
|
|
400
|
+
"text": "Story"
|
|
401
|
+
},
|
|
402
|
+
"default": "{ name: 'Su link e testo', render: (args) => html` <p style=\"max-width:400px;line-height:2\"> Il tooltip può essere usato su qualsiasi elemento interattivo, come i <it-tooltip placement=${ifDefined(args.placement)}> <a slot=\"trigger\" href=\"#\" @click=${(e: Event) => e.preventDefault()}>link in una frase</a> <span slot=\"content\">Primo link con tooltip</span> </it-tooltip> di testo, per fornire informazioni contestuali senza occupare spazio nella pagina. Basta passare il mouse o portare il focus su un <it-tooltip placement=${ifDefined(args.placement)}> <a slot=\"trigger\" href=\"#\" @click=${(e: Event) => e.preventDefault()}>elemento con tooltip</a> <span slot=\"content\">Secondo link con tooltip</span> </it-tooltip> per vedere l'etichetta comparire. </p> `, }"
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
"kind": "variable",
|
|
406
|
+
"name": "Posizione",
|
|
407
|
+
"type": {
|
|
408
|
+
"text": "Story"
|
|
409
|
+
},
|
|
410
|
+
"default": "{ argTypes: { ...disabledControls() }, decorators: [ (story) => html`<div style=\"display:grid;gap:.5rem;grid-template:1fr 1fr 1fr / 1fr 1fr 1fr;place-items:center\"> ${story()} </div>`, ], render: () => html` <it-tooltip placement=\"bottom\" style=\"grid-column:2;grid-row:1\"> <it-button slot=\"trigger\" variant=\"primary\">Giù</it-button> <span slot=\"content\">Tooltip in basso</span> </it-tooltip> <it-tooltip placement=\"top\" style=\"grid-column:2;grid-row:3\"> <it-button slot=\"trigger\" variant=\"primary\">Su</it-button> <span slot=\"content\">Tooltip in alto</span> </it-tooltip> <it-tooltip placement=\"right\" style=\"grid-column:1;grid-row:2\"> <it-button slot=\"trigger\" variant=\"primary\">Destra</it-button> <span slot=\"content\">Tooltip a destra</span> </it-tooltip> <it-tooltip placement=\"left\" style=\"grid-column:3;grid-row:2\"> <it-button slot=\"trigger\" variant=\"primary\">Sinistra</it-button> <span slot=\"content\">Tooltip a sinistra</span> </it-tooltip> `, }"
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"kind": "variable",
|
|
414
|
+
"name": "TestoFormattato",
|
|
415
|
+
"type": {
|
|
416
|
+
"text": "Story"
|
|
417
|
+
},
|
|
418
|
+
"default": "{ name: 'Testo formattato', argTypes: { ...disabledControls() }, render: () => html` <it-tooltip placement=\"right\"> <it-button slot=\"trigger\" variant=\"primary\">Mostra tooltip</it-button> <span slot=\"content\"><em>Tooltip</em> <u>con</u> <strong>HTML</strong></span> </it-tooltip> `, }"
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
"kind": "variable",
|
|
422
|
+
"name": "AttivazioneControllata",
|
|
423
|
+
"type": {
|
|
424
|
+
"text": "Story"
|
|
425
|
+
},
|
|
426
|
+
"default": "{ name: 'Attivazione controllata', argTypes: { ...disabledControls() }, decorators: [(story) => html`<div style=\"display:flex;gap:1rem;align-items:flex-start;height:70px\">${story()}</div>`], render: () => { const show = (e: Event) => { const btn = e.currentTarget as HTMLElement; const tooltip = btn.closest('div')?.querySelector('it-tooltip') as any; tooltip?.showTooltip(); }; const hide = (e: Event) => { const btn = e.currentTarget as HTMLElement; const tooltip = btn.closest('div')?.querySelector('it-tooltip') as any; tooltip?.hideTooltip(); }; return html` <it-tooltip placement=\"bottom\" controlled> <it-button slot=\"trigger\" variant=\"primary\">Target</it-button> <span slot=\"content\">Tooltip controllato</span> </it-tooltip> <button @mouseenter=${show} @mouseleave=${hide} class=\"btn btn-secondary\"> Hover qui per mostrare il tooltip </button> `; }, }"
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
"kind": "variable",
|
|
430
|
+
"name": "Eventi",
|
|
431
|
+
"type": {
|
|
432
|
+
"text": "Story"
|
|
433
|
+
},
|
|
434
|
+
"default": "{ args: { placement: 'right', }, argTypes: { ...disabledControls() }, render: (args) => { const onOpen = (e: CustomEvent) => console.log('Tooltip aperto', e); const onClose = (e: CustomEvent) => console.log('Tooltip chiuso', e); return html` <it-tooltip placement=${ifDefined(args.placement)} @it-tooltip-open=${onOpen} @it-tooltip-close=${onClose}> <it-button slot=\"trigger\" variant=\"primary\">Hover o focus</it-button> <span slot=\"content\">Tooltip con eventi</span> </it-tooltip> `; }, }"
|
|
435
|
+
}
|
|
436
|
+
],
|
|
437
|
+
"exports": [
|
|
438
|
+
{
|
|
439
|
+
"kind": "js",
|
|
440
|
+
"name": "default",
|
|
441
|
+
"declaration": {
|
|
442
|
+
"name": "meta",
|
|
443
|
+
"module": "stories/it-tooltip.stories.ts"
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
"kind": "js",
|
|
448
|
+
"name": "Base",
|
|
449
|
+
"declaration": {
|
|
450
|
+
"name": "Base",
|
|
451
|
+
"module": "stories/it-tooltip.stories.ts"
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
"kind": "js",
|
|
456
|
+
"name": "SuLink",
|
|
457
|
+
"declaration": {
|
|
458
|
+
"name": "SuLink",
|
|
459
|
+
"module": "stories/it-tooltip.stories.ts"
|
|
460
|
+
}
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
"kind": "js",
|
|
464
|
+
"name": "Posizione",
|
|
465
|
+
"declaration": {
|
|
466
|
+
"name": "Posizione",
|
|
467
|
+
"module": "stories/it-tooltip.stories.ts"
|
|
468
|
+
}
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
"kind": "js",
|
|
472
|
+
"name": "TestoFormattato",
|
|
473
|
+
"declaration": {
|
|
474
|
+
"name": "TestoFormattato",
|
|
475
|
+
"module": "stories/it-tooltip.stories.ts"
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
"kind": "js",
|
|
480
|
+
"name": "AttivazioneControllata",
|
|
481
|
+
"declaration": {
|
|
482
|
+
"name": "AttivazioneControllata",
|
|
483
|
+
"module": "stories/it-tooltip.stories.ts"
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
"kind": "js",
|
|
488
|
+
"name": "Eventi",
|
|
489
|
+
"declaration": {
|
|
490
|
+
"name": "Eventi",
|
|
491
|
+
"module": "stories/it-tooltip.stories.ts"
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
]
|
|
495
|
+
}
|
|
496
|
+
]
|
|
497
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { BaseComponent } from '@italia/globals';
|
|
2
|
+
import { PropertyValues } from 'lit';
|
|
3
|
+
import type { TooltipPlacement } from './types.js';
|
|
4
|
+
export declare class ItTooltip extends BaseComponent {
|
|
5
|
+
static styles: import("lit").CSSResultGroup;
|
|
6
|
+
static OFFSET: number;
|
|
7
|
+
static TRANSITION_DURATION: number;
|
|
8
|
+
open: boolean;
|
|
9
|
+
controlled: boolean;
|
|
10
|
+
placement: TooltipPlacement;
|
|
11
|
+
noFlip: boolean;
|
|
12
|
+
private _triggerSlot;
|
|
13
|
+
private _contentSlot;
|
|
14
|
+
private _tooltipElement;
|
|
15
|
+
private _arrowElement;
|
|
16
|
+
isTransitioning: boolean;
|
|
17
|
+
private _contentElement;
|
|
18
|
+
private _lastTrigger;
|
|
19
|
+
private get _triggerElement();
|
|
20
|
+
private _cleanup?;
|
|
21
|
+
private _onMouseEnter;
|
|
22
|
+
private _onMouseLeave;
|
|
23
|
+
private _onTooltipMouseLeave;
|
|
24
|
+
private _onFocusIn;
|
|
25
|
+
private _onFocusOut;
|
|
26
|
+
private _onKeyDown;
|
|
27
|
+
disconnectedCallback(): void;
|
|
28
|
+
private _cleanupDescribedBy;
|
|
29
|
+
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
30
|
+
protected updated(changedProps: Map<string, unknown>): void;
|
|
31
|
+
private _setupAria;
|
|
32
|
+
private _setupStandardEvents;
|
|
33
|
+
private _removeListeners;
|
|
34
|
+
private _show;
|
|
35
|
+
private _hide;
|
|
36
|
+
showTooltip(): void;
|
|
37
|
+
hideTooltip(): void;
|
|
38
|
+
toggle(): void;
|
|
39
|
+
render(): import("lit").TemplateResult<1>;
|
|
40
|
+
}
|
|
41
|
+
declare global {
|
|
42
|
+
interface HTMLElementTagNameMap {
|
|
43
|
+
'it-tooltip': ItTooltip;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=it-tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"it-tooltip.d.ts","sourceRoot":"","sources":["../../src/it-tooltip.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAQ,cAAc,EAAE,MAAM,KAAK,CAAC;AAG3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AASnD,qBACa,SAAU,SAAQ,aAAa;IAC1C,MAAM,CAAC,MAAM,+BAAU;IAEvB,MAAM,CAAC,MAAM,SAAK;IAElB,MAAM,CAAC,mBAAmB,SAAO;IAEW,IAAI,UAAS;IAE5B,UAAU,UAAS;IAEpB,SAAS,EAAE,gBAAgB,CAAS;IAEb,MAAM,EAAE,OAAO,CAAS;IAE5C,OAAO,CAAC,YAAY,CAAmB;IAEvC,OAAO,CAAC,YAAY,CAAmB;IAEnD,OAAO,CAAC,eAAe,CAAe;IAEhC,OAAO,CAAC,aAAa,CAAe;IAE7D,eAAe,UAAS;IAExB,OAAO,CAAC,eAAe,CAA4B;IAEnD,OAAO,CAAC,YAAY,CAA4B;IAEhD,OAAO,KAAK,eAAe,GAE1B;IAED,OAAO,CAAC,QAAQ,CAAC,CAAa;IAE9B,OAAO,CAAC,aAAa,CAEnB;IAEF,OAAO,CAAC,aAAa,CAOnB;IAEF,OAAO,CAAC,oBAAoB,CAO1B;IAEF,OAAO,CAAC,UAAU,CAEhB;IAEF,OAAO,CAAC,WAAW,CAEjB;IAEF,OAAO,CAAC,UAAU,CAEhB;IAEF,oBAAoB,IAAI,IAAI;IAU5B,OAAO,CAAC,mBAAmB;IAS3B,SAAS,CAAC,YAAY,CAAC,kBAAkB,EAAE,cAAc,GAAG,IAAI;IAMhE,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAc3D,OAAO,CAAC,UAAU;IA2BlB,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,KAAK;IAyCb,OAAO,CAAC,KAAK;IAUN,WAAW,IAAI,IAAI;IAInB,WAAW,IAAI,IAAI;IAInB,MAAM,IAAI,IAAI;IAIrB,MAAM;CAoBP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,YAAY,EAAE,SAAS,CAAC;KACzB;CACF"}
|