@zanichelli/zanichelli-it-frontend-kit 0.1.6 → 1.0.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.
Files changed (103) hide show
  1. package/dist/zanichelli-it-frontend-kit/index-Cn3aX5eK.js +4170 -0
  2. package/dist/zanichelli-it-frontend-kit/index-Cn3aX5eK.js.map +1 -0
  3. package/dist/zanichelli-it-frontend-kit/index.esm.js +10 -0
  4. package/dist/zanichelli-it-frontend-kit/index.esm.js.map +1 -1
  5. package/dist/zanichelli-it-frontend-kit/menu-DZlhu_pe.js +46 -0
  6. package/dist/zanichelli-it-frontend-kit/menu-DZlhu_pe.js.map +1 -0
  7. package/dist/{collection/utils/utils.js → zanichelli-it-frontend-kit/utils-CaxAWyZI.js} +7 -3
  8. package/dist/zanichelli-it-frontend-kit/utils-CaxAWyZI.js.map +1 -0
  9. package/dist/zanichelli-it-frontend-kit/zanichelli-it-frontend-kit.css +993 -1
  10. package/dist/zanichelli-it-frontend-kit/zanichelli-it-frontend-kit.esm.js +49 -1
  11. package/dist/zanichelli-it-frontend-kit/zanichelli-it-frontend-kit.esm.js.map +1 -1
  12. package/dist/zanichelli-it-frontend-kit/zanit-menubar.entry.esm.js.map +1 -0
  13. package/dist/{components/zanit-menubar.js → zanichelli-it-frontend-kit/zanit-menubar.entry.js} +12 -55
  14. package/dist/zanichelli-it-frontend-kit/zanit-menubar.entry.js.map +1 -0
  15. package/dist/zanichelli-it-frontend-kit/zanit-mobile-menubar.entry.esm.js.map +1 -0
  16. package/dist/{components/p-DGmSfTXD.js → zanichelli-it-frontend-kit/zanit-mobile-menubar.entry.js} +13 -86
  17. package/dist/zanichelli-it-frontend-kit/zanit-mobile-menubar.entry.js.map +1 -0
  18. package/dist/zanichelli-it-frontend-kit/zanit-search-form.entry.esm.js.map +1 -0
  19. package/dist/{components/p-CiHl-h3q.js → zanichelli-it-frontend-kit/zanit-search-form.entry.js} +13 -52
  20. package/dist/zanichelli-it-frontend-kit/zanit-search-form.entry.js.map +1 -0
  21. package/package.json +1 -1
  22. package/www/build/index-Cn3aX5eK.js +4170 -0
  23. package/www/build/index-Cn3aX5eK.js.map +1 -0
  24. package/www/build/index.esm.js +10 -0
  25. package/www/build/index.esm.js.map +1 -1
  26. package/www/build/menu-DZlhu_pe.js +46 -0
  27. package/www/build/menu-DZlhu_pe.js.map +1 -0
  28. package/www/build/utils-CaxAWyZI.js +21 -0
  29. package/www/build/utils-CaxAWyZI.js.map +1 -0
  30. package/www/build/zanichelli-it-frontend-kit.css +993 -1
  31. package/www/build/zanichelli-it-frontend-kit.esm.js +49 -1
  32. package/www/build/zanichelli-it-frontend-kit.esm.js.map +1 -1
  33. package/www/build/zanit-menubar.entry.esm.js.map +1 -0
  34. package/{dist/collection/components/menubar/menubar.js → www/build/zanit-menubar.entry.js} +25 -157
  35. package/www/build/zanit-menubar.entry.js.map +1 -0
  36. package/www/build/zanit-mobile-menubar.entry.esm.js.map +1 -0
  37. package/www/build/zanit-mobile-menubar.entry.js +166 -0
  38. package/www/build/zanit-mobile-menubar.entry.js.map +1 -0
  39. package/www/build/zanit-search-form.entry.esm.js.map +1 -0
  40. package/{dist/collection/components/menubar/search-form/search-form.js → www/build/zanit-search-form.entry.js} +22 -98
  41. package/www/build/zanit-search-form.entry.js.map +1 -0
  42. package/www/index.html +297 -244
  43. package/dist/cjs/index-xkrZykI_.js +0 -1532
  44. package/dist/cjs/index-xkrZykI_.js.map +0 -1
  45. package/dist/cjs/index.cjs.js +0 -5
  46. package/dist/cjs/index.cjs.js.map +0 -1
  47. package/dist/cjs/loader.cjs.js +0 -15
  48. package/dist/cjs/loader.cjs.js.map +0 -1
  49. package/dist/cjs/zanichelli-it-frontend-kit.cjs.js +0 -27
  50. package/dist/cjs/zanichelli-it-frontend-kit.cjs.js.map +0 -1
  51. package/dist/cjs/zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.cjs.js.map +0 -1
  52. package/dist/cjs/zanit-menubar_3.cjs.entry.js +0 -676
  53. package/dist/cjs/zanit-menubar_3.cjs.entry.js.map +0 -1
  54. package/dist/collection/collection-manifest.json +0 -14
  55. package/dist/collection/components/menubar/menu/menu.css +0 -98
  56. package/dist/collection/components/menubar/menu/menu.js +0 -38
  57. package/dist/collection/components/menubar/menu/menu.js.map +0 -1
  58. package/dist/collection/components/menubar/menubar.css +0 -167
  59. package/dist/collection/components/menubar/menubar.js.map +0 -1
  60. package/dist/collection/components/menubar/mobile-menubar/mobile-menubar.css +0 -114
  61. package/dist/collection/components/menubar/mobile-menubar/mobile-menubar.js +0 -290
  62. package/dist/collection/components/menubar/mobile-menubar/mobile-menubar.js.map +0 -1
  63. package/dist/collection/components/menubar/search-form/search-form.css +0 -147
  64. package/dist/collection/components/menubar/search-form/search-form.js.map +0 -1
  65. package/dist/collection/index.js +0 -11
  66. package/dist/collection/index.js.map +0 -1
  67. package/dist/collection/utils/types.js +0 -2
  68. package/dist/collection/utils/types.js.map +0 -1
  69. package/dist/collection/utils/utils.js.map +0 -1
  70. package/dist/components/index.js +0 -1290
  71. package/dist/components/index.js.map +0 -1
  72. package/dist/components/p-CiHl-h3q.js.map +0 -1
  73. package/dist/components/p-DGmSfTXD.js.map +0 -1
  74. package/dist/components/zanit-menubar.js.map +0 -1
  75. package/dist/components/zanit-mobile-menubar.js +0 -9
  76. package/dist/components/zanit-mobile-menubar.js.map +0 -1
  77. package/dist/components/zanit-search-form.js +0 -9
  78. package/dist/components/zanit-search-form.js.map +0 -1
  79. package/dist/esm/index-BWVQ0LD4.js +0 -1504
  80. package/dist/esm/index-BWVQ0LD4.js.map +0 -1
  81. package/dist/esm/index.js +0 -4
  82. package/dist/esm/index.js.map +0 -1
  83. package/dist/esm/loader.js +0 -13
  84. package/dist/esm/loader.js.map +0 -1
  85. package/dist/esm/zanichelli-it-frontend-kit.js +0 -23
  86. package/dist/esm/zanichelli-it-frontend-kit.js.map +0 -1
  87. package/dist/esm/zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.js.map +0 -1
  88. package/dist/esm/zanit-menubar_3.entry.js +0 -672
  89. package/dist/esm/zanit-menubar_3.entry.js.map +0 -1
  90. package/dist/index.cjs.js +0 -1
  91. package/dist/index.js +0 -1
  92. package/dist/zanichelli-it-frontend-kit/p-BWVQ0LD4.js +0 -3
  93. package/dist/zanichelli-it-frontend-kit/p-BWVQ0LD4.js.map +0 -1
  94. package/dist/zanichelli-it-frontend-kit/p-eece6410.entry.js +0 -2
  95. package/dist/zanichelli-it-frontend-kit/p-eece6410.entry.js.map +0 -1
  96. package/dist/zanichelli-it-frontend-kit/zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.esm.js.map +0 -1
  97. package/www/build/p-984b8fa6.css +0 -1
  98. package/www/build/p-BWVQ0LD4.js +0 -3
  99. package/www/build/p-BWVQ0LD4.js.map +0 -1
  100. package/www/build/p-eece6410.entry.js +0 -2
  101. package/www/build/p-eece6410.entry.js.map +0 -1
  102. package/www/build/p-fedb810b.js +0 -2
  103. package/www/build/zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.esm.js.map +0 -1
@@ -1,114 +0,0 @@
1
- :host {
2
- position: relative;
3
- z-index: 2;
4
- display: block;
5
- width: 100%;
6
- max-width: 100%;
7
- background-color: #fff;
8
- color: var(--gray900);
9
- fill: var(--gray900);
10
- font-family: var(--font-family-sans);
11
- }
12
-
13
- :host,
14
- *,
15
- ::before,
16
- ::after {
17
- box-sizing: border-box;
18
- }
19
-
20
- *:focus:focus-visible {
21
- box-shadow: var(--shadow-focus-primary);
22
- outline: none;
23
- }
24
-
25
- ul {
26
- padding: 0;
27
- margin: 0;
28
- list-style: none;
29
- }
30
-
31
- a {
32
- color: var(--gray900);
33
- cursor: pointer;
34
- text-decoration: none;
35
- }
36
-
37
- button {
38
- all: unset;
39
- cursor: pointer;
40
- }
41
-
42
- nav {
43
- display: flex;
44
- width: 100%;
45
- align-items: center;
46
- padding: 8px var(--grid-margin);
47
- }
48
-
49
- nav::after {
50
- position: absolute;
51
- top: 0;
52
- right: 0;
53
- width: 100%;
54
- height: 100%;
55
- background: transparent;
56
- box-shadow: var(--shadow-1);
57
- content: '';
58
- pointer-events: none;
59
- }
60
-
61
- .burger-button {
62
- margin-left: auto;
63
- }
64
-
65
- .mobile-menu {
66
- position: absolute;
67
- top: 100%;
68
- left: 0;
69
- display: flex;
70
- width: 100%;
71
- flex-direction: column;
72
- padding: 16px var(--grid-margin) 32px;
73
- background-color: #fff;
74
- box-shadow: var(--shadow-2);
75
- gap: 8px;
76
- }
77
-
78
- .mobile-menu li {
79
- width: 100%;
80
- }
81
-
82
- .mobile-menu .items-container {
83
- display: flex;
84
- min-height: 256px;
85
- flex-direction: column;
86
- gap: 8px;
87
- }
88
-
89
- .mobile-menu .items-container z-ghost-loading {
90
- width: 40%;
91
- height: 1.2rem;
92
- }
93
-
94
- .mobile-menu .items-container .menubar-item {
95
- display: block;
96
- width: 100%;
97
- padding: 8px 0;
98
- font-size: 1rem;
99
- text-align: left;
100
- }
101
-
102
- .mobile-menu .items-container li:not(:last-child) .menubar-item {
103
- border-bottom: 1px solid #000;
104
- }
105
-
106
- [role='menuitem'].parent {
107
- display: flex;
108
- width: fit-content;
109
- align-items: center;
110
- padding: 0;
111
- border: none;
112
- font-size: 0.875rem;
113
- gap: 8px;
114
- }
@@ -1,290 +0,0 @@
1
- import { h } from "@stencil/core";
2
- import { containsTarget, moveFocus } from "../../../utils/utils";
3
- import { Menu } from "../menu/menu";
4
- /** Mobile menubar component. */
5
- export class ZanitMobileMenubar {
6
- host;
7
- /** IDs path of the current item. */
8
- currentPath = [];
9
- /** Menubar items. */
10
- items = [];
11
- /** Initial search query. */
12
- searchQuery = undefined;
13
- /** Whether the menubar is loading the data. */
14
- loading = false;
15
- /** Last active item ID. */
16
- lastCurrent = undefined;
17
- parentItem = undefined;
18
- menuItems = undefined;
19
- /** Whether the items to render come from a menubar or a menu. */
20
- menuType = undefined;
21
- open;
22
- onItemsChange() {
23
- this.lastCurrent = this.currentPath?.length ? this.currentPath[this.currentPath.length - 1] : undefined;
24
- this.setupData(this.items);
25
- }
26
- /**
27
- * Find the current item and take its parent, `menuItems` or the `navbarItems`.
28
- */
29
- setupData(items, parent) {
30
- // If no current item is defined, we show all items
31
- if (this.lastCurrent === undefined) {
32
- this.parentItem = undefined;
33
- this.menuType = 'menubar';
34
- this.menuItems = items;
35
- return;
36
- }
37
- for (const item of items) {
38
- if (item.id === this.lastCurrent) {
39
- this.parentItem = parent;
40
- this.menuType = item.menuItems?.length ? 'menu' : 'menubar';
41
- this.menuItems = item.menuItems || item.navbarItems;
42
- return;
43
- }
44
- if (this.currentPath.length > 1 &&
45
- item.id === this.currentPath[this.currentPath.length - 2] &&
46
- item.menuItems?.some(({ id }) => id === this.lastCurrent)) {
47
- this.parentItem = item;
48
- this.menuType = item.menuItems?.length ? 'menu' : 'menubar';
49
- this.menuItems = item.menuItems || item.navbarItems;
50
- return;
51
- }
52
- if (item.navbarItems?.length) {
53
- this.setupData(item.navbarItems, item);
54
- }
55
- }
56
- }
57
- get menuItemsElement() {
58
- return Array.from(this.host.shadowRoot.querySelectorAll('[role="menuitem"]'));
59
- }
60
- /** Initialize tabindex on menuitems, setting -1 to all but the first one. */
61
- initTabindex() {
62
- this.menuItemsElement.forEach((item, index) => item.setAttribute('tabindex', index === 0 ? '0' : '-1'));
63
- }
64
- toggleMenu() {
65
- if (this.open) {
66
- this.open = false;
67
- }
68
- else {
69
- this.open = true;
70
- setTimeout(() => {
71
- this.initTabindex();
72
- this.menuItemsElement[0]?.focus();
73
- }, 200);
74
- }
75
- }
76
- /** Handles keyboard navigation on mobile menu. */
77
- handleItemKeydown(event) {
78
- switch (event.key) {
79
- case 'ArrowUp': {
80
- event.preventDefault();
81
- event.stopPropagation();
82
- const items = this.menuItemsElement;
83
- const currentIndex = items.indexOf(event.target);
84
- const prevItem = items[(currentIndex - 1 + items.length) % items.length];
85
- moveFocus(items[currentIndex], prevItem);
86
- break;
87
- }
88
- case 'ArrowDown': {
89
- event.preventDefault();
90
- event.stopPropagation();
91
- const items = this.menuItemsElement;
92
- const currentIndex = items.indexOf(event.target);
93
- const nextItem = items[(currentIndex + 1) % items.length];
94
- moveFocus(items[currentIndex], nextItem);
95
- break;
96
- }
97
- case 'Home': {
98
- event.preventDefault();
99
- event.stopPropagation();
100
- moveFocus(event.target, this.menuItemsElement[0]);
101
- break;
102
- }
103
- case 'End': {
104
- event.preventDefault();
105
- event.stopPropagation();
106
- moveFocus(event.target, this.menuItemsElement.pop());
107
- break;
108
- }
109
- }
110
- }
111
- connectedCallback() {
112
- this.lastCurrent = this.currentPath?.length ? this.currentPath[this.currentPath.length - 1] : undefined;
113
- this.setupData(this.items);
114
- }
115
- /** Close the menu when clicking outside. */
116
- handleOutsideClick(event) {
117
- if (containsTarget(this.host, event)) {
118
- return;
119
- }
120
- this.open = false;
121
- }
122
- /** Close the menu when pressing Escape or Tab. */
123
- handleKeydown(event) {
124
- switch (event.key) {
125
- case 'Escape':
126
- this.open = false;
127
- break;
128
- case 'Tab':
129
- if (containsTarget(this.host, event)) {
130
- break;
131
- }
132
- this.open = false;
133
- break;
134
- }
135
- }
136
- /** Close the menu when the focus goes out. */
137
- handleFocusout(event) {
138
- if (containsTarget(this.host, event)) {
139
- return;
140
- }
141
- this.open = false;
142
- }
143
- render() {
144
- return (h("nav", { key: '8670451f03909d3008f6e21d02ee5c7412d86bac', "aria-label": "Zanichelli.it" }, h("z-logo", { key: '8f8704851b84185e6c01bc6cd5e2a3b3cda53a61', imageAlt: "Logo Zanichelli", link: "/", height: 32, width: 126 }), h("button", { key: '02271df658a071f9ae0d91f8140b9e8e15064ccc', class: "burger-button", type: "button", "aria-expanded": this.open ? 'true' : 'false', "aria-controls": "mobile-menu", "aria-label": this.open ? 'Chiudi menù' : 'Apri menù', onClick: () => this.toggleMenu() }, h("z-icon", { key: 'fcbff94368d67da8a237190518452048276882a0', name: this.open ? 'multiply' : 'burger-menu', width: "1.5rem", height: "1.5rem" })), this.open && (h("ul", { key: '94fae1693d0ebd41d86cfe55450a40cbff88b7dd', class: "mobile-menu", role: "menubar" }, h("li", { key: '5e09e8484e6450646d4da570a0791da92e477fc7', role: "none" }, h("zanit-search-form", { key: '564813af11cc4b6c62db80ee2acdbeb54cec935f', searchQuery: this.searchQuery, onResetSearch: () => (this.searchQuery = undefined) })), !this.loading && this.currentPath && this.currentPath.length > 0 && (h("li", { key: '7b501d3a1c7dcf705bd1bfd8d03a29573c27f891', role: "none" }, h("a", { key: '949db4a79629f0d0ab44cc94d11f717abc87cb4d', class: "parent", href: this.parentItem?.href ?? '/', id: this.parentItem?.id ?? undefined, role: "menuitem", tabIndex: -1, onKeyDown: (event) => this.handleItemKeydown(event), target: this.parentItem?.target }, h("z-icon", { key: '2537588429f0185c67f87702d040fdc8ad7fbe06', name: "arrow-left", width: "0.5rem", height: "0.5rem" }), h("span", { key: '732de0ec2a09d41ecacd62d7fa8e5c799e67e533' }, this.parentItem?.label || 'Home')))), this.loading && (h("div", { key: '56c066be63a1de19e4d76fcf22624378d0898602', class: "items-container", role: "none" }, [...new Array(4)].map(() => (h("li", { role: "none" }, h("div", { class: "menubar-item", role: "none" }, h("z-ghost-loading", null))))))), this.menuType === 'menu' ? (h(Menu, { items: this.menuItems, controlledBy: this.parentItem?.id, currentPath: this.currentPath, onItemKeyDown: (event) => this.handleItemKeydown(event) })) : (this.menuItems?.length && (h("div", { class: "items-container", role: "none" }, this.menuItems.map((item) => (h("li", { role: "none" }, h("a", { class: {
145
- 'menu-item': this.menuType === 'menu',
146
- 'menubar-item': this.menuType === 'menubar',
147
- }, href: item.href, id: item.id, role: "menuitem", "aria-current": this.lastCurrent === item.id ? 'page' : 'false', tabIndex: -1, onKeyDown: (event) => this.handleItemKeydown(event), target: item.target }, h("span", { "data-text": item.label }, item.label))))))))))));
148
- }
149
- static get is() { return "zanit-mobile-menubar"; }
150
- static get encapsulation() { return "shadow"; }
151
- static get originalStyleUrls() {
152
- return {
153
- "$": ["mobile-menubar.css", "../menu/menu.css"]
154
- };
155
- }
156
- static get styleUrls() {
157
- return {
158
- "$": ["mobile-menubar.css", "../menu/menu.css"]
159
- };
160
- }
161
- static get properties() {
162
- return {
163
- "currentPath": {
164
- "type": "unknown",
165
- "attribute": "current-path",
166
- "mutable": false,
167
- "complexType": {
168
- "original": "string[]",
169
- "resolved": "string[]",
170
- "references": {}
171
- },
172
- "required": false,
173
- "optional": false,
174
- "docs": {
175
- "tags": [],
176
- "text": "IDs path of the current item."
177
- },
178
- "getter": false,
179
- "setter": false,
180
- "defaultValue": "[]"
181
- },
182
- "items": {
183
- "type": "unknown",
184
- "attribute": "items",
185
- "mutable": false,
186
- "complexType": {
187
- "original": "MenubarItem[]",
188
- "resolved": "MenubarItem[]",
189
- "references": {
190
- "MenubarItem": {
191
- "location": "import",
192
- "path": "../../../utils/types",
193
- "id": "src/utils/types.ts::MenubarItem"
194
- }
195
- }
196
- },
197
- "required": false,
198
- "optional": false,
199
- "docs": {
200
- "tags": [],
201
- "text": "Menubar items."
202
- },
203
- "getter": false,
204
- "setter": false,
205
- "defaultValue": "[]"
206
- },
207
- "searchQuery": {
208
- "type": "string",
209
- "attribute": "search-query",
210
- "mutable": true,
211
- "complexType": {
212
- "original": "string | undefined",
213
- "resolved": "string",
214
- "references": {}
215
- },
216
- "required": false,
217
- "optional": false,
218
- "docs": {
219
- "tags": [],
220
- "text": "Initial search query."
221
- },
222
- "getter": false,
223
- "setter": false,
224
- "reflect": false,
225
- "defaultValue": "undefined"
226
- },
227
- "loading": {
228
- "type": "boolean",
229
- "attribute": "loading",
230
- "mutable": false,
231
- "complexType": {
232
- "original": "boolean",
233
- "resolved": "boolean",
234
- "references": {}
235
- },
236
- "required": false,
237
- "optional": false,
238
- "docs": {
239
- "tags": [],
240
- "text": "Whether the menubar is loading the data."
241
- },
242
- "getter": false,
243
- "setter": false,
244
- "reflect": false,
245
- "defaultValue": "false"
246
- }
247
- };
248
- }
249
- static get states() {
250
- return {
251
- "lastCurrent": {},
252
- "parentItem": {},
253
- "menuItems": {},
254
- "menuType": {},
255
- "open": {}
256
- };
257
- }
258
- static get elementRef() { return "host"; }
259
- static get watchers() {
260
- return [{
261
- "propName": "items",
262
- "methodName": "onItemsChange"
263
- }, {
264
- "propName": "currentPath",
265
- "methodName": "onItemsChange"
266
- }];
267
- }
268
- static get listeners() {
269
- return [{
270
- "name": "click",
271
- "method": "handleOutsideClick",
272
- "target": "document",
273
- "capture": false,
274
- "passive": true
275
- }, {
276
- "name": "keydown",
277
- "method": "handleKeydown",
278
- "target": undefined,
279
- "capture": false,
280
- "passive": true
281
- }, {
282
- "name": "focusin",
283
- "method": "handleFocusout",
284
- "target": "document",
285
- "capture": false,
286
- "passive": true
287
- }];
288
- }
289
- }
290
- //# sourceMappingURL=mobile-menubar.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mobile-menubar.js","sourceRoot":"","sources":["../../../../src/components/menubar/mobile-menubar/mobile-menubar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAElF,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,gCAAgC;AAMhC,MAAM,OAAO,kBAAkB;IAClB,IAAI,CAAgC;IAE/C,oCAAoC;IAC5B,WAAW,GAAa,EAAE,CAAC;IAEnC,qBAAqB;IACb,KAAK,GAAkB,EAAE,CAAC;IAElC,4BAA4B;IACH,WAAW,GAAuB,SAAS,CAAC;IAErE,+CAA+C;IACvC,OAAO,GAAY,KAAK,CAAC;IAEjC,2BAA2B;IAClB,WAAW,GAAuB,SAAS,CAAC;IAC5C,UAAU,GAA4B,SAAS,CAAC;IAChD,SAAS,GAA2C,SAAS,CAAC;IACvE,iEAAiE;IACxD,QAAQ,GAAmC,SAAS,CAAC;IACr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AAK,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAC7D,QAAQ,EAAE,CAAC,CAAC,EACZ,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,EACnD,MAAM,EAAE,IAAI,CAAC,MAAM;wBAEnB,yBAAiB,IAAI,CAAC,KAAK,IAAG,IAAI,CAAC,KAAK,CAAQ,CAC9C,CACD,CACN,CAAC,CACE,CACP,CACF,CACE,CACN,CACG,CACP,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, h, Listen, Prop, State, Watch } from '@stencil/core';\nimport { MenubarItem, MenuItem } from '../../../utils/types';\nimport { containsTarget, moveFocus } from '../../../utils/utils';\nimport { Menu } from '../menu/menu';\n\n/** Mobile menubar component. */\n@Component({\n tag: 'zanit-mobile-menubar',\n styleUrls: ['mobile-menubar.css', '../menu/menu.css'],\n shadow: true,\n})\nexport class ZanitMobileMenubar {\n @Element() host: HTMLZanitMobileMenubarElement;\n\n /** IDs path of the current item. */\n @Prop() currentPath: string[] = [];\n\n /** Menubar items. */\n @Prop() items: MenubarItem[] = [];\n\n /** Initial search query. */\n @Prop({ mutable: true }) searchQuery: string | undefined = undefined;\n\n /** Whether the menubar is loading the data. */\n @Prop() loading: boolean = false;\n\n /** Last active item ID. */\n @State() lastCurrent: string | undefined = undefined;\n @State() parentItem: MenubarItem | undefined = undefined;\n @State() menuItems: MenubarItem[] | MenuItem[] | undefined = undefined;\n /** Whether the items to render come from a menubar or a menu. */\n @State() menuType: 'menubar' | 'menu' | undefined = undefined;\n @State() open: boolean;\n\n @Watch('items')\n @Watch('currentPath')\n onItemsChange() {\n this.lastCurrent = this.currentPath?.length ? this.currentPath[this.currentPath.length - 1] : undefined;\n this.setupData(this.items);\n }\n\n /**\n * Find the current item and take its parent, `menuItems` or the `navbarItems`.\n */\n private setupData(items: MenubarItem[], parent?: MenubarItem) {\n // If no current item is defined, we show all items\n if (this.lastCurrent === undefined) {\n this.parentItem = undefined;\n this.menuType = 'menubar';\n this.menuItems = items;\n return;\n }\n\n for (const item of items) {\n if (item.id === this.lastCurrent) {\n this.parentItem = parent;\n this.menuType = item.menuItems?.length ? 'menu' : 'menubar';\n this.menuItems = item.menuItems || item.navbarItems;\n return;\n }\n\n if (\n this.currentPath.length > 1 &&\n item.id === this.currentPath[this.currentPath.length - 2] &&\n item.menuItems?.some(({ id }) => id === this.lastCurrent)\n ) {\n this.parentItem = item;\n this.menuType = item.menuItems?.length ? 'menu' : 'menubar';\n this.menuItems = item.menuItems || item.navbarItems;\n return;\n }\n\n if (item.navbarItems?.length) {\n this.setupData(item.navbarItems, item);\n }\n }\n }\n\n private get menuItemsElement() {\n return Array.from(this.host.shadowRoot.querySelectorAll('[role=\"menuitem\"]')) as HTMLElement[];\n }\n\n /** Initialize tabindex on menuitems, setting -1 to all but the first one. */\n private initTabindex() {\n this.menuItemsElement.forEach((item, index) => item.setAttribute('tabindex', index === 0 ? '0' : '-1'));\n }\n\n private toggleMenu() {\n if (this.open) {\n this.open = false;\n } else {\n this.open = true;\n setTimeout(() => {\n this.initTabindex();\n this.menuItemsElement[0]?.focus();\n }, 200);\n }\n }\n\n /** Handles keyboard navigation on mobile menu. */\n private handleItemKeydown(event: KeyboardEvent) {\n switch (event.key) {\n case 'ArrowUp': {\n event.preventDefault();\n event.stopPropagation();\n const items = this.menuItemsElement;\n const currentIndex = items.indexOf(event.target as HTMLElement);\n const prevItem = items[(currentIndex - 1 + items.length) % items.length];\n moveFocus(items[currentIndex], prevItem);\n break;\n }\n case 'ArrowDown': {\n event.preventDefault();\n event.stopPropagation();\n const items = this.menuItemsElement;\n const currentIndex = items.indexOf(event.target as HTMLElement);\n const nextItem = items[(currentIndex + 1) % items.length];\n moveFocus(items[currentIndex], nextItem);\n break;\n }\n case 'Home': {\n event.preventDefault();\n event.stopPropagation();\n moveFocus(event.target as HTMLElement, this.menuItemsElement[0]);\n break;\n }\n case 'End': {\n event.preventDefault();\n event.stopPropagation();\n moveFocus(event.target as HTMLElement, this.menuItemsElement.pop());\n break;\n }\n }\n }\n\n connectedCallback() {\n this.lastCurrent = this.currentPath?.length ? this.currentPath[this.currentPath.length - 1] : undefined;\n this.setupData(this.items);\n }\n\n /** Close the menu when clicking outside. */\n @Listen('click', { target: 'document', passive: true })\n handleOutsideClick(event: MouseEvent) {\n if (containsTarget(this.host, event)) {\n return;\n }\n\n this.open = false;\n }\n\n /** Close the menu when pressing Escape or Tab. */\n @Listen('keydown', { passive: true })\n handleKeydown(event: KeyboardEvent) {\n switch (event.key) {\n case 'Escape':\n this.open = false;\n break;\n case 'Tab':\n if (containsTarget(this.host, event)) {\n break;\n }\n\n this.open = false;\n break;\n }\n }\n\n /** Close the menu when the focus goes out. */\n @Listen('focusin', { target: 'document', passive: true })\n handleFocusout(event: FocusEvent) {\n if (containsTarget(this.host, event)) {\n return;\n }\n\n this.open = false;\n }\n\n render() {\n return (\n <nav aria-label=\"Zanichelli.it\">\n <z-logo\n imageAlt=\"Logo Zanichelli\"\n link=\"/\"\n height={32}\n width={126}\n ></z-logo>\n <button\n class=\"burger-button\"\n type=\"button\"\n aria-expanded={this.open ? 'true' : 'false'}\n aria-controls=\"mobile-menu\"\n aria-label={this.open ? 'Chiudi menù' : 'Apri menù'}\n onClick={() => this.toggleMenu()}\n >\n <z-icon\n name={this.open ? 'multiply' : 'burger-menu'}\n width=\"1.5rem\"\n height=\"1.5rem\"\n ></z-icon>\n </button>\n {this.open && (\n <ul\n class=\"mobile-menu\"\n role=\"menubar\"\n >\n <li role=\"none\">\n <zanit-search-form\n searchQuery={this.searchQuery}\n onResetSearch={() => (this.searchQuery = undefined)}\n />\n </li>\n\n {!this.loading && this.currentPath && this.currentPath.length > 0 && (\n <li role=\"none\">\n <a\n class=\"parent\"\n href={this.parentItem?.href ?? '/'}\n id={this.parentItem?.id ?? undefined}\n role=\"menuitem\"\n tabIndex={-1}\n onKeyDown={(event) => this.handleItemKeydown(event)}\n target={this.parentItem?.target}\n >\n <z-icon\n name=\"arrow-left\"\n width=\"0.5rem\"\n height=\"0.5rem\"\n ></z-icon>\n <span>\n {/* Show the 'Home' label if the current item is a root child. */}\n {this.parentItem?.label || 'Home'}\n </span>\n </a>\n </li>\n )}\n\n {this.loading && (\n <div\n class=\"items-container\"\n role=\"none\"\n >\n {[...new Array(4)].map(() => (\n <li role=\"none\">\n <div\n class=\"menubar-item\"\n role=\"none\"\n >\n <z-ghost-loading></z-ghost-loading>\n </div>\n </li>\n ))}\n </div>\n )}\n\n {this.menuType === 'menu' ? (\n <Menu\n items={this.menuItems}\n controlledBy={this.parentItem?.id}\n currentPath={this.currentPath}\n onItemKeyDown={(event) => this.handleItemKeydown(event)}\n />\n ) : (\n this.menuItems?.length && (\n <div\n class=\"items-container\"\n role=\"none\"\n >\n {this.menuItems.map((item) => (\n <li role=\"none\">\n <a\n class={{\n 'menu-item': this.menuType === 'menu',\n 'menubar-item': this.menuType === 'menubar',\n }}\n href={item.href}\n id={item.id}\n role=\"menuitem\"\n aria-current={this.lastCurrent === item.id ? 'page' : 'false'}\n tabIndex={-1}\n onKeyDown={(event) => this.handleItemKeydown(event)}\n target={item.target}\n >\n <span data-text={item.label}>{item.label}</span>\n </a>\n </li>\n ))}\n </div>\n )\n )}\n </ul>\n )}\n </nav>\n );\n }\n}\n"]}
@@ -1,147 +0,0 @@
1
- :host,
2
- *,
3
- ::before,
4
- ::after {
5
- box-sizing: border-box;
6
- }
7
-
8
- *:focus:focus-visible {
9
- box-shadow: var(--shadow-focus-primary);
10
- outline: none;
11
- }
12
-
13
- button {
14
- all: unset;
15
- cursor: pointer;
16
- }
17
-
18
- @media (width < 768px) {
19
- .searchbar {
20
- display: flex;
21
- align-items: center;
22
- border: 1px solid #000;
23
- border-radius: 4px;
24
- }
25
-
26
- .searchbar > *:first-child {
27
- /* To have a seamless appearance of the border radius of an internal child element nested within a parent element with rounded borders, we need to subtract the parent's border thickness from the child's border radius. Inner Radius = Outer Radius - Border Thickness */
28
- border-bottom-left-radius: 3px;
29
- border-top-left-radius: 3px;
30
- }
31
-
32
- .searchbar button[type='reset'] {
33
- display: flex;
34
- padding: 0 0 0 8px;
35
- cursor: pointer;
36
- }
37
-
38
- .searchbar input {
39
- width: 100%;
40
- height: 100%;
41
- padding: 4px 8px;
42
- border: none;
43
- background-color: #fff;
44
- font-family: var(--font-family-sans);
45
- font-size: 1rem;
46
- }
47
-
48
- .searchbar input[type='search']::-webkit-search-cancel-button,
49
- .searchbar input[type='search']::-webkit-search-decoration {
50
- appearance: none;
51
- }
52
-
53
- .searchbar input::placeholder {
54
- color: var(--gray500);
55
- }
56
-
57
- .searchbar .searchbar-button {
58
- padding: 4px 8px;
59
- border-left: 1px solid #000;
60
- background: var(--zanit-accent-color);
61
- border-bottom-right-radius: 3px;
62
- border-top-right-radius: 3px;
63
- }
64
-
65
- .searchbar input:focus:focus-visible,
66
- .searchbar .searchbar-button:focus:focus-visible {
67
- z-index: 1;
68
- }
69
- }
70
-
71
- @media (width >= 768px) {
72
- .searchbar {
73
- display: flex;
74
- font-size: 1.5rem;
75
- }
76
-
77
- .searchbar.searchbar-open {
78
- position: absolute;
79
- width: 100%;
80
- height: 100%;
81
- inset: 0;
82
- }
83
-
84
- .searchbar .input-wrapper {
85
- display: none;
86
- width: 100%;
87
- align-items: center;
88
- padding: 0 0 0 var(--grid-margin);
89
- background-color: #fff;
90
- gap: 6px; /* diventa 14px sommato al padding a sinistra della input */
91
- }
92
-
93
- .searchbar .input-wrapper:not(.hide) {
94
- display: flex;
95
- }
96
-
97
- .searchbar button[type='reset'] {
98
- display: flex;
99
- align-items: center;
100
- border-radius: 4px;
101
- cursor: pointer;
102
- }
103
-
104
- .searchbar input {
105
- z-index: 1;
106
- width: 100%;
107
- height: 100%;
108
- padding: 8px;
109
- border: none;
110
- background-color: #fff;
111
- font-family: var(--font-family-sans);
112
- font-size: inherit;
113
- }
114
-
115
- .searchbar input[type='search']::-webkit-search-cancel-button,
116
- .searchbar input[type='search']::-webkit-search-decoration {
117
- appearance: none;
118
- }
119
-
120
- .searchbar input::placeholder {
121
- color: var(--gray500);
122
- }
123
-
124
- .searchbar .searchbar-button {
125
- display: flex;
126
- align-items: center;
127
- padding: 8px 16px;
128
- border-right: 1px solid #000;
129
- border-left: 1px solid #000;
130
- background: var(--zanit-accent-color);
131
- font-family: inherit;
132
- font-size: inherit;
133
- gap: 64px;
134
- line-height: 1;
135
- }
136
-
137
- .searchbar input:focus:focus-visible,
138
- .searchbar .searchbar-button:focus:focus-visible {
139
- z-index: 1;
140
- }
141
- }
142
-
143
- @media (width >= 768px) and (width < 1152px) {
144
- .searchbar .searchbar-button > .searchbar-button-label {
145
- display: none;
146
- }
147
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"search-form.js","sourceRoot":"","sources":["../../../../src/components/menubar/search-form/search-form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAOtD,MAAM,OAAO,eAAe;IAClB,WAAW,CAAkB;IAE1B,IAAI,CAA6B;IAG5C,QAAQ,GAAY,KAAK,CAAC;IAE1B,6DAA6D;IAE7D,aAAa,GAAY,KAAK,CAAC;IAE/B,6BAA6B;IAE7B,YAAY,GAAuB,SAAS,CAAC;IAE7C,2BAA2B;IAE3B,WAAW,GAAuB,SAAS,CAAC;IAG5C,mBAAmB;QACjB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC;QACrC,IAAI,IAAI,CA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AK,CAAC,EACjD,KAAK,EAAE,IAAI,CAAC,WAAW,EACvB,QAAQ,SACD,CACL;YAEN,cACE,KAAK,EAAC,kBAAkB,gBACb,OAAO,mBACJ,iBAAiB,EAC/B,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAC9C,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE;gBAElC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAM,KAAK,EAAC,wBAAwB,YAAa;gBAC9E,cACE,IAAI,EAAC,QAAQ,EACb,KAAK,EAAC,MAAM,EACZ,MAAM,EAAC,MAAM,GACL,CACH,CACJ,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Listen, Prop, State, Watch } from '@stencil/core';\nimport { containsTarget } from '../../../utils/utils';\n\n@Component({\n tag: 'zanit-search-form',\n styleUrl: 'search-form.css',\n shadow: true,\n})\nexport class ZanitSearchForm {\n private formElement: HTMLFormElement;\n\n @Element() host: HTMLZanitSearchFormElement;\n\n @State()\n isMobile: boolean = false;\n\n /** Indicates whether the searchbar is visible and usable. */\n @State()\n showSearchbar: boolean = false;\n\n /** Search query to apply. */\n @State()\n _searchQuery: string | undefined = undefined;\n\n /** Initial search query */\n @Prop({ mutable: true })\n searchQuery: string | undefined = undefined;\n\n @Watch('searchQuery')\n onSearchQueryChange() {\n this._searchQuery = this.searchQuery;\n if (this.searchQuery) {\n this.openSearchbar();\n }\n }\n\n /** Emitted on search form submission. */\n @Event({ cancelable: true }) search: EventEmitter<{ query: string }>;\n\n @Event() resetSearch: EventEmitter<void>;\n\n async connectedCallback() {\n this.showSearchbar = !!this.searchQuery;\n const mobileMediaQuery = window.matchMedia('(width < 768px)');\n this.isMobile = mobileMediaQuery.matches;\n mobileMediaQuery.onchange = (mql) => {\n this.isMobile = mql.matches;\n };\n }\n\n /** Close open searchbar when clicking outside. */\n @Listen('click', { target: 'document', passive: true })\n handleOutsideClick(event: MouseEvent) {\n if (this.showSearchbar && this.formElement && !containsTarget(this.formElement, event)) {\n this.showSearchbar = false;\n }\n }\n\n private openSearchbar() {\n this.showSearchbar = true;\n setTimeout(() => {\n const searchbarInput = this.host.shadowRoot.querySelector('#searchbar-input') as HTMLInputElement;\n searchbarInput.focus();\n }, 100);\n }\n\n private resetSearchQuery() {\n this.searchQuery = undefined;\n this.resetSearch.emit();\n }\n\n private handleInputChange(event: Event) {\n this._searchQuery = (event.target as HTMLInputElement).value;\n if (!this._searchQuery) {\n this.searchQuery = undefined;\n }\n }\n\n private onSearchSubmit(event: Event) {\n event.preventDefault();\n if (!this._searchQuery) {\n return;\n }\n\n this.showSearchbar = false;\n const searchEv = this.search.emit({ query: this._searchQuery });\n // do not submit the form if the event default behavior was prevented\n if (searchEv.defaultPrevented) {\n return;\n }\n\n this.formElement.submit();\n }\n\n render() {\n if (this.isMobile) {\n return (\n <form\n class=\"searchbar\"\n ref={(el) => (this.formElement = el)}\n role=\"search\"\n aria-label=\"Cerca\"\n method=\"get\"\n action=\"/ricerca\"\n onSubmit={(event) => this.onSearchSubmit(event)}\n onReset={() => this.resetSearchQuery()}\n >\n {this.searchQuery && (\n <button\n type=\"reset\"\n aria-label=\"Svuota campo di ricerca\"\n >\n <z-icon\n name=\"multiply-circled\"\n width=\"1rem\"\n height=\"1rem\"\n />\n </button>\n )}\n <input\n id=\"searchbar-input\"\n name=\"q\"\n type=\"search\"\n placeholder=\"Cerca per parola chiave o ISBN\"\n onInput={(event) => this.handleInputChange(event)}\n value={this.searchQuery}\n required\n ></input>\n <button\n class=\"searchbar-button\"\n aria-controls=\"searchbar-input\"\n aria-label=\"Cerca\"\n type=\"submit\"\n >\n <z-icon\n name=\"search\"\n width=\"1.25rem\"\n height=\"1.25rem\"\n ></z-icon>\n </button>\n </form>\n );\n }\n\n return (\n <form\n class={{ 'searchbar': true, 'searchbar-open': this.showSearchbar }}\n ref={(el) => (this.formElement = el)}\n role=\"search\"\n aria-label=\"Cerca\"\n method=\"get\"\n action=\"/ricerca\"\n onSubmit={(event) => this.onSearchSubmit(event)}\n onReset={() => this.resetSearchQuery()}\n >\n <div\n class={{ 'hide': !this.showSearchbar, 'input-wrapper': true }}\n role=\"none\"\n >\n {this.searchQuery && (\n <button\n type=\"reset\"\n aria-label=\"Svuota campo di ricerca\"\n >\n <z-icon\n name=\"multiply-circled\"\n width=\"1.5rem\"\n height=\"1.5rem\"\n />\n </button>\n )}\n <input\n id=\"searchbar-input\"\n name=\"q\"\n type=\"search\"\n placeholder=\"Cerca per parola chiave o ISBN\"\n onInput={(event) => this.handleInputChange(event)}\n value={this.searchQuery}\n required\n ></input>\n </div>\n\n <button\n class=\"searchbar-button\"\n aria-label=\"Cerca\"\n aria-controls=\"searchbar-input\"\n type={this.showSearchbar ? 'submit' : 'button'}\n onClick={() => this.openSearchbar()}\n >\n {this.showSearchbar ? null : <span class=\"searchbar-button-label\">Cerca</span>}\n <z-icon\n name=\"search\"\n width=\"2rem\"\n height=\"2rem\"\n ></z-icon>\n </button>\n </form>\n );\n }\n}\n"]}
@@ -1,11 +0,0 @@
1
- /**
2
- * @fileoverview entry point for your component library
3
- *
4
- * This is the entry point for your component library. Use this file to export utilities,
5
- * constants or data structure that accompany your components.
6
- *
7
- * DO NOT use this file to export your components. Instead, use the recommended approaches
8
- * to consume components of this package as outlined in the `README.md`.
9
- */
10
- export * from './utils/types';
11
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,cAAc,eAAe,CAAC","sourcesContent":["/**\n * @fileoverview entry point for your component library\n *\n * This is the entry point for your component library. Use this file to export utilities,\n * constants or data structure that accompany your components.\n *\n * DO NOT use this file to export your components. Instead, use the recommended approaches\n * to consume components of this package as outlined in the `README.md`.\n */\n\nexport type * from './components.d.ts';\nexport * from './utils/types';\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"","sourcesContent":["export type MenuItem = {\n label: string;\n href?: string;\n target?: '_self' | '_blank' | '_parent' | '_top';\n highlight?: boolean;\n id?: string;\n group?: { id: string; label: string };\n};\n\nexport type MenubarItem = Omit<MenuItem, 'group' | 'highlight'> & {\n navbarItems?: MenubarItem[];\n menuItems?: MenuItem[];\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAqB,EAAE,KAAY,EAAE,EAAE;IACpE,OAAO,KAAK;SACT,YAAY,EAAE;SACd,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,QAAQ,IAAI,EAAE,KAAK,MAAM,CAAC,MAAM,CAAC;SACvD,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAiB,CAAC,CAAC,CAAC;AACxD,CAAC,CAAC;AAEF,0FAA0F;AAC1F,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAoB,EAAE,IAAiB,EAAE,EAAE;IACnE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;IACtB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;IAClB,IAAI,CAAC,KAAK,EAAE,CAAC;AACf,CAAC,CAAC","sourcesContent":["/**\n * Check if an element contains an event target by checking its composedPath.\n * Useful when an event target may come from a component's shadow DOM.\n */\nexport const containsTarget = (ancestor: HTMLElement, event: Event) => {\n return event\n .composedPath()\n .filter((el) => el !== document && el !== window.window)\n .some((el) => ancestor.contains(el as HTMLElement));\n};\n\n/** Move the focus to `next` element, set tabindex to 0 for `next` and -1 to `current`. */\nexport const moveFocus = (current: HTMLElement, next: HTMLElement) => {\n current.tabIndex = -1;\n next.tabIndex = 0;\n next.focus();\n};\n"]}