@italia/megamenu 1.0.0-alpha.7

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 ADDED
@@ -0,0 +1,3 @@
1
+ # Autori
2
+
3
+ Vedi file AUTHORS nella root del repository principale.
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,29 @@
1
+ # Megamenu Web Component
2
+
3
+ Questo package contiene il web component `<it-megamenu>`, conforme agli standard del progetto e con stili Bootstrap Italia.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm i @italia/megamenu
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```
14
+ <it-megamenu label="Apri il menu">
15
+ <it-dropdown-item href="#">Azione 1</it-dropdown-item>
16
+ <it-dropdown-item href="#">Azione 2</it-dropdown-item>
17
+ <it-dropdown-item href="#">Azione 3</it-dropdown-item>
18
+ </it-dropdown>
19
+ ```
20
+
21
+ ## Sviluppo
22
+
23
+ - Stili: solo SCSS, no CSS inline
24
+ - Test: web-test-runner
25
+ - Storie: Storybook
26
+
27
+ ## License
28
+
29
+ Vedi LICENSE.
@@ -0,0 +1,440 @@
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": "ItMegamenu",
13
+ "declaration": {
14
+ "name": "ItMegamenu",
15
+ "module": "./it-megamenu.js"
16
+ }
17
+ }
18
+ ]
19
+ },
20
+ {
21
+ "kind": "javascript-module",
22
+ "path": "src/it-megamenu.ts",
23
+ "declarations": [
24
+ {
25
+ "kind": "class",
26
+ "description": "",
27
+ "name": "ItMegamenu",
28
+ "members": [
29
+ {
30
+ "kind": "field",
31
+ "name": "FOCUSABLE_SELECTORS",
32
+ "type": {
33
+ "text": "string"
34
+ },
35
+ "privacy": "private",
36
+ "static": true,
37
+ "readonly": true,
38
+ "default": "'a, button, input, select, textarea, [tabindex]:not([tabindex=\"-1\"])'"
39
+ },
40
+ {
41
+ "kind": "field",
42
+ "name": "_hasDescription",
43
+ "type": {
44
+ "text": "boolean"
45
+ },
46
+ "privacy": "private",
47
+ "default": "false"
48
+ },
49
+ {
50
+ "kind": "field",
51
+ "name": "_hasHeader",
52
+ "type": {
53
+ "text": "boolean"
54
+ },
55
+ "privacy": "private",
56
+ "default": "false"
57
+ },
58
+ {
59
+ "kind": "field",
60
+ "name": "_hasFooter",
61
+ "type": {
62
+ "text": "boolean"
63
+ },
64
+ "privacy": "private",
65
+ "default": "false"
66
+ },
67
+ {
68
+ "kind": "field",
69
+ "name": "fullWidth",
70
+ "type": {
71
+ "text": "boolean"
72
+ },
73
+ "default": "true",
74
+ "attribute": "full-width",
75
+ "reflects": true
76
+ },
77
+ {
78
+ "kind": "field",
79
+ "name": "itRole",
80
+ "type": {
81
+ "text": "string"
82
+ },
83
+ "default": "'menu'",
84
+ "attribute": "itRole"
85
+ },
86
+ {
87
+ "kind": "field",
88
+ "name": "active",
89
+ "type": {
90
+ "text": "boolean"
91
+ },
92
+ "default": "false",
93
+ "attribute": "active",
94
+ "reflects": true
95
+ },
96
+ {
97
+ "kind": "field",
98
+ "name": "columns",
99
+ "type": {
100
+ "text": "number"
101
+ },
102
+ "default": "2",
103
+ "attribute": "columns",
104
+ "reflects": true
105
+ },
106
+ {
107
+ "kind": "field",
108
+ "name": "footerAlign",
109
+ "type": {
110
+ "text": "FooterAlign"
111
+ },
112
+ "default": "'left'",
113
+ "attribute": "footer-align",
114
+ "reflects": true
115
+ },
116
+ {
117
+ "kind": "field",
118
+ "name": "footerPosition",
119
+ "type": {
120
+ "text": "FooterPosition"
121
+ },
122
+ "default": "'bottom'",
123
+ "attribute": "footer-position",
124
+ "reflects": true
125
+ },
126
+ {
127
+ "kind": "field",
128
+ "name": "_descriptionItems",
129
+ "type": {
130
+ "text": "Array<HTMLElement>"
131
+ },
132
+ "privacy": "private"
133
+ },
134
+ {
135
+ "kind": "field",
136
+ "name": "_headerItems",
137
+ "type": {
138
+ "text": "Array<HTMLElement>"
139
+ },
140
+ "privacy": "private"
141
+ },
142
+ {
143
+ "kind": "field",
144
+ "name": "_footerItems",
145
+ "type": {
146
+ "text": "Array<HTMLElement>"
147
+ },
148
+ "privacy": "private"
149
+ },
150
+ {
151
+ "kind": "method",
152
+ "name": "_handleSlotDescriptionChange",
153
+ "privacy": "private"
154
+ },
155
+ {
156
+ "kind": "method",
157
+ "name": "_setChildrenProperties"
158
+ },
159
+ {
160
+ "kind": "method",
161
+ "name": "_onSlotHeaderChange",
162
+ "privacy": "private"
163
+ },
164
+ {
165
+ "kind": "method",
166
+ "name": "_onSlotFooterChange",
167
+ "privacy": "private"
168
+ },
169
+ {
170
+ "kind": "method",
171
+ "name": "_getMegamenuFocusableItems",
172
+ "privacy": "private",
173
+ "return": {
174
+ "type": {
175
+ "text": "Element[]"
176
+ }
177
+ }
178
+ },
179
+ {
180
+ "kind": "field",
181
+ "name": "_onTabKeyDown"
182
+ },
183
+ {
184
+ "kind": "field",
185
+ "name": "_onClickItems",
186
+ "privacy": "private"
187
+ }
188
+ ],
189
+ "attributes": [
190
+ {
191
+ "name": "full-width",
192
+ "type": {
193
+ "text": "boolean"
194
+ },
195
+ "default": "true",
196
+ "fieldName": "fullWidth"
197
+ },
198
+ {
199
+ "name": "itRole",
200
+ "type": {
201
+ "text": "string"
202
+ },
203
+ "default": "'menu'",
204
+ "fieldName": "itRole"
205
+ },
206
+ {
207
+ "name": "active",
208
+ "type": {
209
+ "text": "boolean"
210
+ },
211
+ "default": "false",
212
+ "fieldName": "active"
213
+ },
214
+ {
215
+ "name": "columns",
216
+ "type": {
217
+ "text": "number"
218
+ },
219
+ "default": "2",
220
+ "fieldName": "columns"
221
+ },
222
+ {
223
+ "name": "footer-align",
224
+ "type": {
225
+ "text": "FooterAlign"
226
+ },
227
+ "default": "'left'",
228
+ "fieldName": "footerAlign"
229
+ },
230
+ {
231
+ "name": "footer-position",
232
+ "type": {
233
+ "text": "FooterPosition"
234
+ },
235
+ "default": "'bottom'",
236
+ "fieldName": "footerPosition"
237
+ }
238
+ ],
239
+ "superclass": {
240
+ "name": "ItDropdownBase",
241
+ "package": "@italia/dropdown/it-dropdown-base.js"
242
+ },
243
+ "tagName": "it-megamenu",
244
+ "customElement": true
245
+ }
246
+ ],
247
+ "exports": [
248
+ {
249
+ "kind": "js",
250
+ "name": "ItMegamenu",
251
+ "declaration": {
252
+ "name": "ItMegamenu",
253
+ "module": "src/it-megamenu.ts"
254
+ }
255
+ },
256
+ {
257
+ "kind": "custom-element-definition",
258
+ "name": "it-megamenu",
259
+ "declaration": {
260
+ "name": "ItMegamenu",
261
+ "module": "src/it-megamenu.ts"
262
+ }
263
+ }
264
+ ]
265
+ },
266
+ {
267
+ "kind": "javascript-module",
268
+ "path": "src/types.ts",
269
+ "declarations": [
270
+ {
271
+ "kind": "variable",
272
+ "name": "FOOTER_ALIGN",
273
+ "type": {
274
+ "text": "array"
275
+ },
276
+ "default": "['left', 'right']"
277
+ },
278
+ {
279
+ "kind": "variable",
280
+ "name": "FOOTER_POSITION",
281
+ "type": {
282
+ "text": "array"
283
+ },
284
+ "default": "['bottom', 'right']"
285
+ }
286
+ ],
287
+ "exports": [
288
+ {
289
+ "kind": "js",
290
+ "name": "FOOTER_ALIGN",
291
+ "declaration": {
292
+ "name": "FOOTER_ALIGN",
293
+ "module": "src/types.ts"
294
+ }
295
+ },
296
+ {
297
+ "kind": "js",
298
+ "name": "FOOTER_POSITION",
299
+ "declaration": {
300
+ "name": "FOOTER_POSITION",
301
+ "module": "src/types.ts"
302
+ }
303
+ }
304
+ ]
305
+ },
306
+ {
307
+ "kind": "javascript-module",
308
+ "path": "stories/it-megamenu.stories.ts",
309
+ "declarations": [
310
+ {
311
+ "kind": "variable",
312
+ "name": "meta",
313
+ "default": "{ title: 'Componenti/Megamenu', component: 'it-megamenu', parameters: { wrapperClasses: 'w100-layout megamenu-story-layout' }, tags: ['a11y-ok', 'web-component', 'alpha'], args: { label: 'Megamenu', disabled: false, active: false, columns: 2, 'it-aria-label': undefined, 'footer-align': 'right', 'footer-position': undefined, }, argTypes: { label: { control: 'text', description: 'Testo del pulsante che apre il dropdown del megamenu', }, disabled: { control: 'boolean', description: 'Disabilita il dropdown', table: { defaultValue: { summary: 'false' } }, }, active: { control: 'boolean', description: 'Imposta lo stato attivo del pulsante', table: { defaultValue: { summary: 'false' } }, }, columns: { control: 'number', description: 'Numero di colonne su cui verranno suddivisi i link del menu', table: { defaultValue: { summary: 2 } }, }, 'it-aria-label': { control: 'text', description: \"Valore per l'attributo `aria-label` del pulsante (obbligatorio per accessibilità se `label` è vuoto)\", type: 'string', }, 'footer-align': { control: 'select', description: 'Allineamento del contenuto del footer', options: FOOTER_ALIGN, type: 'string', table: { defaultValue: { summary: 'left' } }, }, 'footer-position': { control: 'select', description: 'Posizione del footer all’interno del megamenu', options: FOOTER_POSITION, type: 'string', table: { defaultValue: { summary: 'bottom' } }, }, }, } satisfies Meta<MegamenuProps>"
314
+ },
315
+ {
316
+ "kind": "variable",
317
+ "name": "Base",
318
+ "type": {
319
+ "text": "Story"
320
+ },
321
+ "default": "{ render: (args) => renderNav( args, html` <!-- megamenu 1 --> <li class=\"nav-item\">${renderMegamenuCompleto(args)}</li> <!-- megamenu 2 --> <li class=\"nav-item\"> ${renderMegamenu( { ...args, active: false, label: 'Megamenu 2', columns: 3 }, html`<!-- DROPDOWN LINKS ITEMS --> ${renderLinks(6, 7)} <!-- SLOT FOOTER --> <div slot=\"footer\"> <a class=\"it-footer-link\" href=\"#\"> <span>Esplora tutti i contenuti del megamenu</span> <it-icon name=\"it-arrow-right\" size=\"sm\" color=\"primary\" class=\"ms-2\"></it-icon> </a> </div>`, )} </li>`, ), tags: ['!autodocs', '!dev'], }"
322
+ },
323
+ {
324
+ "kind": "variable",
325
+ "name": "MegamenuCompleto",
326
+ "type": {
327
+ "text": "Story"
328
+ },
329
+ "default": "{ ...meta, name: 'Megamenu completo', render: (args) => renderNav(args, html`<li class=\"nav-item\">${renderMegamenuCompleto(args)}</li> `), }"
330
+ },
331
+ {
332
+ "kind": "variable",
333
+ "name": "MegamenuBase",
334
+ "type": {
335
+ "text": "Story"
336
+ },
337
+ "default": "{ ...meta, name: 'Megamenu base', args: { columns: 3 }, render: (args) => renderNav( args, html` <li class=\"nav-item\"> ${renderMegamenu( args, html` <!-- DROPDOWN LINKS ITEMS --> ${renderLinks(9)}`, )} </li> `, ), }"
338
+ },
339
+ {
340
+ "kind": "variable",
341
+ "name": "MegamenuEsploraSezione",
342
+ "type": {
343
+ "text": "Story"
344
+ },
345
+ "default": "{ ...meta, name: 'Con link “Esplora la sezione”', args: { columns: 3 }, render: (args) => renderNav( args, html` <li class=\"nav-item\"> ${renderMegamenu( args, html` <!-- DROPDOWN LINKS ITEMS --> <!-- SLOT HEADER --> <div slot=\"header\"> <a class=\"it-heading-link\" href=\"#\"> <it-icon name=\"it-arrow-right-triangle\" size=\"sm\" color=\"primary\" class=\"me-2 mb-1\"></it-icon> <span>Esplora la sezione ${args.label}</span> </a> </div> ${renderLinks(9)}`, )} </li> `, ), }"
346
+ },
347
+ {
348
+ "kind": "variable",
349
+ "name": "MegamenuEsploraTutti",
350
+ "type": {
351
+ "text": "Story"
352
+ },
353
+ "default": "{ ...meta, name: 'Con link “Esplora tutti”', args: { columns: 3, 'footer-align': 'right' }, render: (args) => renderNav( args, html` <li class=\"nav-item\"> ${renderMegamenu( args, html` <!-- DROPDOWN LINKS ITEMS --> ${renderLinks(9)} <!-- SLOT FOOTER --> <div slot=\"footer\"> <a class=\"it-footer-link\" href=\"#\"> <span>Esplora tutti i contenuti del megamenu</span> <it-icon name=\"it-arrow-right\" size=\"sm\" color=\"primary\" class=\"ms-2\"></it-icon> </a> </div> `, )} </li> `, ), }"
354
+ },
355
+ {
356
+ "kind": "variable",
357
+ "name": "MegamenuCTABottom",
358
+ "type": {
359
+ "text": "Story"
360
+ },
361
+ "default": "{ ...meta, name: 'Con call to action in basso', args: { columns: 3, 'footer-position': 'bottom', 'footer-align': '' }, render: (args) => renderNav( args, html` <li class=\"nav-item\"> ${renderMegamenu( args, html` <!-- DROPDOWN LINKS ITEMS --> ${renderLinks(9)} <!-- SLOT FOOTER --> <div slot=\"footer\"> <div class=\"d-flex flex-column flex-lg-row\"> <a class=\"it-footer-link flex-grow-1\" href=\"#\"> <it-icon name=\"it-bookmark\" size=\"sm\" color=\"primary\" class=\"me-2\"></it-icon> <span>Call to action 1</span> </a> <a class=\"it-footer-link flex-grow-1\" href=\"#\"> <it-icon name=\"it-bookmark\" size=\"sm\" color=\"primary\" class=\"me-2\"></it-icon> <span>Call to action 2</span> </a> </div> </div> `, )} </li> `, ), }"
362
+ },
363
+ {
364
+ "kind": "variable",
365
+ "name": "MegamenuCTARight",
366
+ "type": {
367
+ "text": "Story"
368
+ },
369
+ "default": "{ ...meta, name: 'Con call to action a destra', args: { columns: 3, 'footer-position': 'right', 'footer-align': '' }, render: (args) => renderNav( args, html` <li class=\"nav-item\"> ${renderMegamenu( args, html` <!-- DROPDOWN LINKS ITEMS --> ${renderLinks(9)} <!-- SLOT FOOTER --> <div slot=\"footer\"> <div class=\"d-flex flex-column justify-content-around\"> <a class=\"it-footer-link\" href=\"#\"> <it-icon name=\"it-bookmark\" size=\"sm\" color=\"primary\" class=\"me-2\"></it-icon> <span>Call to action 1</span> </a> <a class=\"it-footer-link\" href=\"#\"> <it-icon name=\"it-bookmark\" size=\"sm\" color=\"primary\" class=\"me-2\"></it-icon> <span>Call to action 2</span> </a> </div> </div> `, )} </li> `, ), }"
370
+ }
371
+ ],
372
+ "exports": [
373
+ {
374
+ "kind": "js",
375
+ "name": "default",
376
+ "declaration": {
377
+ "name": "meta",
378
+ "module": "stories/it-megamenu.stories.ts"
379
+ }
380
+ },
381
+ {
382
+ "kind": "js",
383
+ "name": "Base",
384
+ "declaration": {
385
+ "name": "Base",
386
+ "module": "stories/it-megamenu.stories.ts"
387
+ }
388
+ },
389
+ {
390
+ "kind": "js",
391
+ "name": "MegamenuCompleto",
392
+ "declaration": {
393
+ "name": "MegamenuCompleto",
394
+ "module": "stories/it-megamenu.stories.ts"
395
+ }
396
+ },
397
+ {
398
+ "kind": "js",
399
+ "name": "MegamenuBase",
400
+ "declaration": {
401
+ "name": "MegamenuBase",
402
+ "module": "stories/it-megamenu.stories.ts"
403
+ }
404
+ },
405
+ {
406
+ "kind": "js",
407
+ "name": "MegamenuEsploraSezione",
408
+ "declaration": {
409
+ "name": "MegamenuEsploraSezione",
410
+ "module": "stories/it-megamenu.stories.ts"
411
+ }
412
+ },
413
+ {
414
+ "kind": "js",
415
+ "name": "MegamenuEsploraTutti",
416
+ "declaration": {
417
+ "name": "MegamenuEsploraTutti",
418
+ "module": "stories/it-megamenu.stories.ts"
419
+ }
420
+ },
421
+ {
422
+ "kind": "js",
423
+ "name": "MegamenuCTABottom",
424
+ "declaration": {
425
+ "name": "MegamenuCTABottom",
426
+ "module": "stories/it-megamenu.stories.ts"
427
+ }
428
+ },
429
+ {
430
+ "kind": "js",
431
+ "name": "MegamenuCTARight",
432
+ "declaration": {
433
+ "name": "MegamenuCTARight",
434
+ "module": "stories/it-megamenu.stories.ts"
435
+ }
436
+ }
437
+ ]
438
+ }
439
+ ]
440
+ }
@@ -0,0 +1,2 @@
1
+ export { ItMegamenu } from './it-megamenu.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { ItMegamenu } from './it-megamenu.js';
2
+ import 'lit/directive.js';
3
+ import 'lit';
4
+ import 'lit/decorators.js';
5
+ import 'lit/directives/if-defined.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -0,0 +1,32 @@
1
+ import { ItDropdownBase } from '@italia/dropdown/it-dropdown-base.js';
2
+ import { FooterAlign, FooterPosition } from './types.js';
3
+ export declare class ItMegamenu extends ItDropdownBase {
4
+ static styles: import("lit").CSSResultGroup[];
5
+ private static readonly FOCUSABLE_SELECTORS;
6
+ private _hasDescription;
7
+ private _hasHeader;
8
+ private _hasFooter;
9
+ fullWidth: boolean;
10
+ itRole: string;
11
+ active: boolean;
12
+ columns: number;
13
+ footerAlign: FooterAlign;
14
+ footerPosition: FooterPosition;
15
+ private _descriptionItems;
16
+ private _headerItems;
17
+ private _footerItems;
18
+ private _handleSlotDescriptionChange;
19
+ _setChildrenProperties(): void;
20
+ private _onSlotHeaderChange;
21
+ private _onSlotFooterChange;
22
+ private _getMegamenuFocusableItems;
23
+ _onTabKeyDown: (event: KeyboardEvent, items: Element[], active: HTMLElement) => void;
24
+ private _onClickItems;
25
+ render(): import("lit").TemplateResult<1>;
26
+ }
27
+ declare global {
28
+ interface HTMLElementTagNameMap {
29
+ 'it-megamenu': ItMegamenu;
30
+ }
31
+ }
32
+ //# sourceMappingURL=it-megamenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"it-megamenu.d.ts","sourceRoot":"","sources":["../../src/it-megamenu.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAItE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAIzD,qBACa,UAAW,SAAQ,cAAc;IAC5C,OAAgB,MAAM,iCAAmC;IAEzD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAyE;IAE3G,OAAO,CAAC,eAAe,CAAS;IAEhC,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO,CAAC,UAAU,CAAS;IAIiC,SAAS,UAAQ;IAE1D,MAAM,EAAE,MAAM,CAAU;IAER,MAAM,UAAS;IAEM,OAAO,EAAE,MAAM,CAAK;IAEf,WAAW,EAAE,WAAW,CAAU;IAE/B,cAAc,EAAE,cAAc,CAAY;IAEpD,OAAO,CAAC,iBAAiB,CAAsB;IAEpD,OAAO,CAAC,YAAY,CAAsB;IAE1C,OAAO,CAAC,YAAY,CAAsB;IAEpG,OAAO,CAAC,4BAA4B;IAK3B,sBAAsB;IAU/B,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,0BAA0B;IA2BzB,aAAa,GAAI,OAAO,aAAa,EAAE,OAAO,OAAO,EAAE,EAAE,QAAQ,WAAW,UAyBnF;IAEF,OAAO,CAAC,aAAa,CAYnB;IAEO,MAAM;CA8HhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,UAAU,CAAC;KAC3B;CACF"}