@zanichelli/zanichelli-it-frontend-kit 1.3.0 → 1.4.0-RC1

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 (60) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/zanichelli-it-frontend-kit.cjs.js +1 -1
  3. package/dist/cjs/zanit-back-to-top.zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.cjs.js.map +1 -1
  4. package/dist/cjs/zanit-back-to-top_4.cjs.entry.js +264 -22
  5. package/dist/cjs/zanit-back-to-top_4.cjs.entry.js.map +1 -1
  6. package/dist/collection/components/menubar/menubar.css +2 -0
  7. package/dist/collection/components/menubar/menubar.js +52 -2
  8. package/dist/collection/components/menubar/menubar.js.map +1 -1
  9. package/dist/collection/components/menubar/mobile-menubar/mobile-menubar.css +1 -0
  10. package/dist/collection/components/menubar/mobile-menubar/mobile-menubar.js +51 -1
  11. package/dist/collection/components/menubar/mobile-menubar/mobile-menubar.js.map +1 -1
  12. package/dist/collection/components/menubar/search-form/search-form.css +52 -0
  13. package/dist/collection/components/menubar/search-form/search-form.js +207 -22
  14. package/dist/collection/components/menubar/search-form/search-form.js.map +1 -1
  15. package/dist/collection/components/menubar/search-form/suggestions.js +84 -0
  16. package/dist/collection/components/menubar/search-form/suggestions.js.map +1 -0
  17. package/dist/collection/utils/subjects.api.js +25 -0
  18. package/dist/collection/utils/subjects.api.js.map +1 -0
  19. package/dist/collection/utils/utils.js +8 -0
  20. package/dist/collection/utils/utils.js.map +1 -1
  21. package/dist/components/p-WUj4Aaz8.js +375 -0
  22. package/dist/components/p-WUj4Aaz8.js.map +1 -0
  23. package/dist/components/{p-BJzEFXY7.js → p-_cX2Kfxg.js} +11 -5
  24. package/dist/components/p-_cX2Kfxg.js.map +1 -0
  25. package/dist/components/zanit-menubar.js +11 -5
  26. package/dist/components/zanit-menubar.js.map +1 -1
  27. package/dist/components/zanit-mobile-menubar.js +1 -1
  28. package/dist/components/zanit-search-form.js +1 -1
  29. package/dist/esm/loader.js +1 -1
  30. package/dist/esm/zanichelli-it-frontend-kit.js +1 -1
  31. package/dist/esm/zanit-back-to-top.zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.js.map +1 -1
  32. package/dist/esm/zanit-back-to-top_4.entry.js +264 -22
  33. package/dist/esm/zanit-back-to-top_4.entry.js.map +1 -1
  34. package/dist/types/components/menubar/menubar.d.ts +5 -0
  35. package/dist/types/components/menubar/mobile-menubar/mobile-menubar.d.ts +5 -0
  36. package/dist/types/components/menubar/search-form/search-form.d.ts +28 -5
  37. package/dist/types/components/menubar/search-form/suggestions.d.ts +11 -0
  38. package/dist/types/components.d.ts +60 -4
  39. package/dist/types/utils/subjects.api.d.ts +6 -0
  40. package/dist/types/utils/types.d.ts +7 -0
  41. package/dist/types/utils/utils.d.ts +8 -0
  42. package/dist/zanichelli-it-frontend-kit/p-457d6be5.entry.js +2 -0
  43. package/dist/zanichelli-it-frontend-kit/p-457d6be5.entry.js.map +1 -0
  44. package/dist/zanichelli-it-frontend-kit/zanichelli-it-frontend-kit.esm.js +1 -1
  45. package/dist/zanichelli-it-frontend-kit/zanit-back-to-top.zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.esm.js.map +1 -1
  46. package/package.json +1 -1
  47. package/www/build/p-457d6be5.entry.js +2 -0
  48. package/www/build/p-457d6be5.entry.js.map +1 -0
  49. package/www/build/p-f274d1db.js +2 -0
  50. package/www/build/zanichelli-it-frontend-kit.esm.js +1 -1
  51. package/www/build/zanit-back-to-top.zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.esm.js.map +1 -1
  52. package/www/index.html +1 -1
  53. package/dist/components/p-BJzEFXY7.js.map +0 -1
  54. package/dist/components/p-Cfa-BVne.js +0 -133
  55. package/dist/components/p-Cfa-BVne.js.map +0 -1
  56. package/dist/zanichelli-it-frontend-kit/p-8349e91a.entry.js +0 -2
  57. package/dist/zanichelli-it-frontend-kit/p-8349e91a.entry.js.map +0 -1
  58. package/www/build/p-271550c5.js +0 -2
  59. package/www/build/p-8349e91a.entry.js +0 -2
  60. package/www/build/p-8349e91a.entry.js.map +0 -1
@@ -68,6 +68,14 @@ const moveFocus = (current, next) => {
68
68
  next.tabIndex = 0;
69
69
  next.focus({ preventScroll: true });
70
70
  };
71
+ /** Check if event key is ArrowUp */
72
+ const isArrowUpKey = (event) => event.key === 'ArrowUp';
73
+ /** Check if event key is ArrowDown */
74
+ const isArrowDownKey = (event) => event.key === 'ArrowDown';
75
+ /** Check if event key is Tab */
76
+ const isTabKey = (event) => event.key === 'Tab';
77
+ /** Check if event key is Escape */
78
+ const isEscKey = (event) => event.key === 'Escape';
71
79
 
72
80
  const DEFAULT_GROUP_KEY = 'default';
73
81
  const DEFAULT_GROUP = {
@@ -109,7 +117,32 @@ const Menu = ({ controlledBy, items, currentPath = [], onItemKeyDown }) => {
109
117
  }, href: item.href, role: "menuitem", tabIndex: -1, "aria-current": isActive(item) ? 'page' : 'false', onKeyDown: (event) => onItemKeyDown(event), target: item.target }, item.label))))))))))));
110
118
  };
111
119
 
112
- const menubarCss = ":host{position:relative;z-index:2;display:flex;width:100%;background-color:#fff;color:var(--gray900);font-family:var(--font-family-sans)}:host,*,::before,::after{box-sizing:border-box}*:focus:focus-visible{box-shadow:var(--shadow-focus-primary);outline:none}ul{padding:0;margin:0;list-style:none}a{color:var(--gray900);cursor:pointer;text-decoration:none}button{all:unset;cursor:pointer}:host nav{width:100%}.shadow-wrapper{position:relative;z-index:1;display:flex;width:100%}.shadow-wrapper::after{position:absolute;top:0;right:0;width:100%;height:100%;background:transparent;box-shadow:var(--shadow-1);content:'';pointer-events:none}.width-limiter{position:relative;display:flex;width:100%;max-width:var(--zanit-menubar-max-width, 1366px);margin:0 auto}.shadow-wrapper+.shadow-wrapper{z-index:0}.sub-menubar>ul{gap:28px}.width-limiter>ul,.sub-menubar>ul{position:relative;display:flex;width:100%;align-items:center;padding:0 var(--grid-margin);margin-right:auto;margin-left:auto;gap:20px}.shadow-wrapper>.width-limiter,.shadow-wrapper>ul{width:100%;max-width:var(--zanit-menubar-max-width, 1366px)}ul.menubar{padding-right:0}.menubar z-ghost-loading{display:block;width:120px;height:1.25rem}.menubar>li[role='separator']{width:1px;height:1.25rem;background-color:#000}.menubar-item{position:relative;display:flex;align-items:center;padding:14px 0;font-size:1rem;gap:8px;line-height:1.25rem}.menubar .menubar-item{text-transform:uppercase}.menubar-item [data-text]{display:flex;flex-direction:column}.menubar-item.active>[data-text],.menubar-item:hover>[data-text],.menubar-item:focus:focus-visible>[data-text]{font-weight:var(--font-bd)}.menubar-item>[data-text]::after{height:0;content:attr(data-text) / '';font-weight:var(--font-bd);letter-spacing:normal;pointer-events:none;user-select:none;visibility:hidden}.sub-menubar .menubar-item.active::after{position:absolute;z-index:-1;bottom:0;left:-4px;width:calc(100% + 8px);height:4px;background-color:var(--red500);content:''}zanit-search-form{margin-left:auto}";
120
+ var SearchEnv;
121
+ (function (SearchEnv) {
122
+ SearchEnv["DEV"] = "dev";
123
+ SearchEnv["TEST"] = "test";
124
+ SearchEnv["PROD"] = "prod";
125
+ })(SearchEnv || (SearchEnv = {}));
126
+ const S3_SHOP_URL = {
127
+ dev: 'https://zanichelli-shop-dev.s3.eu-west-1.amazonaws.com',
128
+ test: 'https://zanichelli-shop-test.s3.eu-west-1.amazonaws.com',
129
+ prod: 'https://zanichelli-shop.s3.eu-west-1.amazonaws.com',
130
+ };
131
+ async function getSubjectsByArea(searchEnv) {
132
+ try {
133
+ const response = await fetch(`${S3_SHOP_URL[searchEnv]}/categories.json`);
134
+ if (!response.ok) {
135
+ throw new Error(`HTTP ${response.status}`);
136
+ }
137
+ return await response.json();
138
+ }
139
+ catch (err) {
140
+ console.error('Error fetching subjects:', err);
141
+ return {};
142
+ }
143
+ }
144
+
145
+ const menubarCss = ":host{position:relative;z-index:2;display:flex;width:100%;background-color:#fff;color:var(--gray900);font-family:var(--font-family-sans)}:host,*,::before,::after{box-sizing:border-box}*:focus:focus-visible{box-shadow:var(--shadow-focus-primary);outline:none}ul{padding:0;margin:0;list-style:none}a{color:var(--gray900);cursor:pointer;text-decoration:none}button{all:unset;cursor:pointer}:host nav{width:100%}.shadow-wrapper{position:relative;z-index:1;display:flex;width:100%}.shadow-wrapper::after{position:absolute;top:0;right:0;width:100%;height:100%;background:transparent;box-shadow:var(--shadow-1);content:'';pointer-events:none}.width-limiter{position:relative;display:flex;width:100%;max-width:var(--zanit-menubar-max-width, 1366px);margin:0 auto}.shadow-wrapper+.shadow-wrapper{z-index:0}.sub-menubar>ul{gap:28px}.width-limiter>ul,.sub-menubar>ul{position:relative;z-index:3;display:flex;width:100%;align-items:center;padding:0 var(--grid-margin);margin-right:auto;margin-left:auto;gap:20px}.shadow-wrapper>.width-limiter,.shadow-wrapper>ul{width:100%;max-width:var(--zanit-menubar-max-width, 1366px)}ul.menubar{height:3rem;padding-right:0}.menubar z-ghost-loading{display:block;width:120px;height:1.25rem}.menubar>li[role='separator']{width:1px;height:1.25rem;background-color:#000}.menubar-item{position:relative;display:flex;align-items:center;padding:14px 0;font-size:1rem;gap:8px;line-height:1.25rem}.menubar .menubar-item{text-transform:uppercase}.menubar-item [data-text]{display:flex;flex-direction:column}.menubar-item.active>[data-text],.menubar-item:hover>[data-text],.menubar-item:focus:focus-visible>[data-text]{font-weight:var(--font-bd)}.menubar-item>[data-text]::after{height:0;content:attr(data-text) / '';font-weight:var(--font-bd);letter-spacing:normal;pointer-events:none;user-select:none;visibility:hidden}.sub-menubar .menubar-item.active::after{position:absolute;z-index:-1;bottom:0;left:-4px;width:calc(100% + 8px);height:4px;background-color:var(--red500);content:''}zanit-search-form{margin-left:auto}";
113
146
 
114
147
  const menuCss$1 = ".menu-wrapper{width:100%;background-color:#fff}.menu{position:relative;display:flex;width:100%;flex-direction:column;gap:32px 0}.menu .group{display:flex;flex-direction:column}.menu .group .group-name{border-bottom:1px solid currentcolor;margin-bottom:4px;color:var(--red500);font-size:0.875rem;font-weight:var(--font-md)}.menu .group .menu-list{display:flex;flex-direction:column;gap:8px}.menu .group .menu-list .menu-item{display:block;border-bottom:2px solid transparent;font-size:0.875rem;font-weight:var(--font-md)}.menu .menu-list .menu-item.active,.menu .menu-list .menu-item:hover{border-bottom-color:var(--red500)}.menu .group.highlight .menu-list .menu-item{font-size:1rem}@media (width >= 768px){.menu-wrapper{position:absolute;top:100%;left:0;display:flex;justify-content:center;box-shadow:var(--shadow-1)}.menu{display:grid;width:100%;max-width:var(--zanit-menubar-max-width, 1366px);padding:16px var(--grid-margin);gap:0 24px;grid-auto-columns:minmax(0, max-content);grid-auto-flow:column;grid-template-rows:minmax(0, max-content) max-content}.menu .group{display:grid;grid-row:1 / -1;grid-template-columns:1fr;grid-template-rows:subgrid}@supports not (grid-template-rows: subgrid){.menu .group{grid-template-rows:repeat(auto-fit, minmax(0, max-content))}}.menu .group .group-name{border:none;margin-bottom:16px}.menu .group .menu-list .menu-item{font-size:1rem}.menu .group.highlight .menu-list .menu-item{font-size:1.5rem}}";
115
148
 
@@ -134,6 +167,10 @@ const ZanitMenubar = class {
134
167
  current = undefined;
135
168
  /** Initial search query. */
136
169
  searchQuery = undefined;
170
+ /** Environment for search suggestions */
171
+ searchEnv = SearchEnv.PROD;
172
+ /** Search area (e.g. "SCUOLA", "UNIVERSITÀ", "DIZIONARI"). */
173
+ searchArea;
137
174
  timerId;
138
175
  /** Setup the list of items. */
139
176
  async parseData(data) {
@@ -485,13 +522,13 @@ const ZanitMenubar = class {
485
522
  }
486
523
  render() {
487
524
  if (this.isMobile) {
488
- return (h("zanit-mobile-menubar", { items: this.items, currentPath: this.currentPath, searchQuery: this.searchQuery, loading: this.loading }));
525
+ return (h("zanit-mobile-menubar", { items: this.items, currentPath: this.currentPath, searchQuery: this.searchQuery, loading: this.loading, searchArea: this.searchArea, searchEnv: this.searchEnv }));
489
526
  }
490
527
  return (h("nav", { "aria-label": "Zanichelli.it" }, h("div", { class: "shadow-wrapper" }, h("div", { class: "width-limiter" }, h("ul", { class: "menubar", role: "menubar", "aria-label": "Zanichelli.it" }, this.loading &&
491
528
  [...new Array(4)].map((_, index) => (h(Fragment, null, h("li", { role: "none" }, h("div", { class: "menubar-item" }, h("z-ghost-loading", null))), index < 3 && h("li", { role: "separator" })))), this.items?.map((item, index) => (h(Fragment, null, h("li", { role: "none" }, h("a", { class: {
492
529
  'menubar-item': true,
493
530
  'active': this.isActive(item),
494
- }, href: item.href, id: item.id, role: "menuitem", tabIndex: -1, "aria-expanded": item.menuItems?.length ? (this.openMenu === item.id ? 'true' : 'false') : undefined, "aria-haspopup": item.menuItems?.length ? 'true' : 'false', "aria-current": this.current.includes(item.id) ? 'page' : 'false', onPointerOver: () => this.showMenu(item), onKeyDown: (event) => this.handleItemKeydown(event, item), target: item.target }, h("span", { "data-text": item.label }, item.label), item.menuItems?.length > 0 && (h("z-icon", { name: this.openMenu === item.id ? 'chevron-up' : 'chevron-down', width: "0.875rem", height: "0.875rem" })))), index < this.items?.length - 1 && h("li", { role: "separator" }))))), h("zanit-search-form", { searchQuery: this.searchQuery, onResetSearch: () => (this.searchQuery = undefined) })), this.items.map((item) => this.openMenu === item.id && (h(Menu, { controlledBy: item.id, items: item.menuItems, currentPath: this.currentPath, onItemKeyDown: (event) => this.handleMenuKeydown(event) })))), this.items
531
+ }, href: item.href, id: item.id, role: "menuitem", tabIndex: -1, "aria-expanded": item.menuItems?.length ? (this.openMenu === item.id ? 'true' : 'false') : undefined, "aria-haspopup": item.menuItems?.length ? 'true' : 'false', "aria-current": this.current.includes(item.id) ? 'page' : 'false', onPointerOver: () => this.showMenu(item), onKeyDown: (event) => this.handleItemKeydown(event, item), target: item.target }, h("span", { "data-text": item.label }, item.label), item.menuItems?.length > 0 && (h("z-icon", { name: this.openMenu === item.id ? 'chevron-up' : 'chevron-down', width: "0.875rem", height: "0.875rem" })))), index < this.items?.length - 1 && h("li", { role: "separator" }))))), h("zanit-search-form", { searchQuery: this.searchQuery, searchArea: this.searchArea, searchEnv: this.searchEnv, onResetSearch: () => (this.searchQuery = undefined) })), this.items.map((item) => this.openMenu === item.id && (h(Menu, { controlledBy: item.id, items: item.menuItems, currentPath: this.currentPath, onItemKeyDown: (event) => this.handleMenuKeydown(event) })))), this.items
495
532
  ?.filter((item) => this.isActive(item))
496
533
  .map((item) => item.navbarItems?.length && (h("nav", { class: { 'sub-menubar': true, 'shadow-wrapper': true }, "aria-label": `Sezioni: ${item.label}` }, h("ul", { role: "menubar" }, item.navbarItems.map((subitem) => (h(Fragment, null, h("li", { role: "none" }, h("a", { class: {
497
534
  'menubar-item': true,
@@ -507,7 +544,7 @@ const ZanitMenubar = class {
507
544
  };
508
545
  ZanitMenubar.style = menubarCss + menuCss$1;
509
546
 
510
- const mobileMenubarCss = ":host{position:relative;z-index:2;display:block;width:100%;max-width:100%;background-color:#fff;color:var(--gray900);fill:var(--gray900);font-family:var(--font-family-sans)}:host,*,::before,::after{box-sizing:border-box}*:focus:focus-visible{box-shadow:var(--shadow-focus-primary);outline:none}ul{padding:0;margin:0;list-style:none}a{color:var(--gray900);cursor:pointer;text-decoration:none}button{all:unset;cursor:pointer}nav{display:flex;width:100%;align-items:center;padding-left:var(--grid-margin);gap:8px}nav::after{position:absolute;top:0;right:0;width:100%;height:100%;background:transparent;box-shadow:var(--shadow-1);content:'';pointer-events:none}z-logo{margin:8px 0}.mobile-menu{position:absolute;top:100%;left:0;display:flex;overflow:auto;width:100%;max-height:calc(100vh - 48px - var(--zanit-menubar-top-offset, 0px));flex-direction:column;padding:16px var(--grid-margin) 32px;background-color:#fff;box-shadow:var(--shadow-2);gap:8px}.mobile-menu li{width:100%}.mobile-menu .items-container{display:flex;min-height:256px;flex-direction:column;gap:8px}.mobile-menu .items-container z-ghost-loading{width:40%;height:1.2rem}.mobile-menu .items-container .menubar-item{display:block;width:100%;padding:8px 0;font-size:1rem;text-align:left}.mobile-menu .items-container li:not(:last-child) .menubar-item{border-bottom:1px solid #000}[role='menuitem'].parent{display:flex;width:fit-content;align-items:center;padding:0;border:none;font-size:0.875rem;gap:8px}zanit-search-form{margin-left:auto}";
547
+ const mobileMenubarCss = ":host{position:relative;z-index:2;display:block;width:100%;max-width:100%;height:3rem;background-color:#fff;color:var(--gray900);fill:var(--gray900);font-family:var(--font-family-sans)}:host,*,::before,::after{box-sizing:border-box}*:focus:focus-visible{box-shadow:var(--shadow-focus-primary);outline:none}ul{padding:0;margin:0;list-style:none}a{color:var(--gray900);cursor:pointer;text-decoration:none}button{all:unset;cursor:pointer}nav{display:flex;width:100%;align-items:center;padding-left:var(--grid-margin);gap:8px}nav::after{position:absolute;top:0;right:0;width:100%;height:100%;background:transparent;box-shadow:var(--shadow-1);content:'';pointer-events:none}z-logo{margin:8px 0}.mobile-menu{position:absolute;top:100%;left:0;display:flex;overflow:auto;width:100%;max-height:calc(100vh - 48px - var(--zanit-menubar-top-offset, 0px));flex-direction:column;padding:16px var(--grid-margin) 32px;background-color:#fff;box-shadow:var(--shadow-2);gap:8px}.mobile-menu li{width:100%}.mobile-menu .items-container{display:flex;min-height:256px;flex-direction:column;gap:8px}.mobile-menu .items-container z-ghost-loading{width:40%;height:1.2rem}.mobile-menu .items-container .menubar-item{display:block;width:100%;padding:8px 0;font-size:1rem;text-align:left}.mobile-menu .items-container li:not(:last-child) .menubar-item{border-bottom:1px solid #000}[role='menuitem'].parent{display:flex;width:fit-content;align-items:center;padding:0;border:none;font-size:0.875rem;gap:8px}zanit-search-form{margin-left:auto}";
511
548
 
512
549
  const menuCss = ".menu-wrapper{width:100%;background-color:#fff}.menu{position:relative;display:flex;width:100%;flex-direction:column;gap:32px 0}.menu .group{display:flex;flex-direction:column}.menu .group .group-name{border-bottom:1px solid currentcolor;margin-bottom:4px;color:var(--red500);font-size:0.875rem;font-weight:var(--font-md)}.menu .group .menu-list{display:flex;flex-direction:column;gap:8px}.menu .group .menu-list .menu-item{display:block;border-bottom:2px solid transparent;font-size:0.875rem;font-weight:var(--font-md)}.menu .menu-list .menu-item.active,.menu .menu-list .menu-item:hover{border-bottom-color:var(--red500)}.menu .group.highlight .menu-list .menu-item{font-size:1rem}@media (width >= 768px){.menu-wrapper{position:absolute;top:100%;left:0;display:flex;justify-content:center;box-shadow:var(--shadow-1)}.menu{display:grid;width:100%;max-width:var(--zanit-menubar-max-width, 1366px);padding:16px var(--grid-margin);gap:0 24px;grid-auto-columns:minmax(0, max-content);grid-auto-flow:column;grid-template-rows:minmax(0, max-content) max-content}.menu .group{display:grid;grid-row:1 / -1;grid-template-columns:1fr;grid-template-rows:subgrid}@supports not (grid-template-rows: subgrid){.menu .group{grid-template-rows:repeat(auto-fit, minmax(0, max-content))}}.menu .group .group-name{border:none;margin-bottom:16px}.menu .group .menu-list .menu-item{font-size:1rem}.menu .group.highlight .menu-list .menu-item{font-size:1.5rem}}";
513
550
 
@@ -524,6 +561,10 @@ const ZanitMobileMenubar = class {
524
561
  searchQuery = undefined;
525
562
  /** Whether the menubar is loading the data. */
526
563
  loading = false;
564
+ /** Environment for search suggestions */
565
+ searchEnv = SearchEnv.PROD;
566
+ /** Search area (e.g. "SCUOLA", "UNIVERSITÀ", "DIZIONARI"). */
567
+ searchArea;
527
568
  /** Last active item ID. */
528
569
  lastCurrent = undefined;
529
570
  parentItem = undefined;
@@ -653,7 +694,7 @@ const ZanitMobileMenubar = class {
653
694
  this.open = false;
654
695
  }
655
696
  render() {
656
- return (h("nav", { key: '3c60ac4ac98ee3defb91d07ed2b877031f0a35df', "aria-label": "Zanichelli.it" }, h("button", { key: 'bebe58a827addf39e62deb9c3ef44296f14da700', 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: '0b3e97a6bcb3f54c1b0669f9fe012ac3ff5b5632', name: this.open ? 'multiply' : 'burger-menu', width: "1.5rem", height: "1.5rem" })), h("z-logo", { key: 'a7216fc628ab13b243ace77a89d5dc16bde1f6da', imageAlt: "Logo Zanichelli", link: "/", height: 32, width: 126 }), h("zanit-search-form", { key: 'bdfd612ecc8cf6fb7d4d1941474a8b6cc0b8ff2d', searchQuery: this.searchQuery, onResetSearch: () => (this.searchQuery = undefined) }), this.open && (h("ul", { key: 'bf3f32326a98ff6a47a3734ac98f8afda74f0d12', class: "mobile-menu", role: "menubar" }, !this.loading && this.currentPath && this.currentPath.length > 0 && (h("li", { key: 'a157937b4358cba0a1bc990576051f4a703cedd4', role: "none" }, h("a", { key: '9f36e81c276da144abf96e9e1dd7cf2a84bdc4b7', 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: 'ba4c4e1c0b1132cbcd4be7a4088bf1fb6618f062', name: "arrow-left", width: "0.5rem", height: "0.5rem" }), h("span", { key: 'cc30b285857d7cb7908e35dadf424e0940342949' }, this.parentItem?.label || 'Home')))), this.loading ? (h("div", { 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 > 0 && (h("div", { class: "items-container", role: "none" }, this.menuItems.map((item) => (h("li", { role: "none" }, h("a", { class: {
697
+ return (h("nav", { key: '76079ce1e66f1b568f6e7eac1f67b91af0f2f48a', "aria-label": "Zanichelli.it" }, h("button", { key: '630b16be60aba3d7027fbe4b9e19e440cb454267', 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: '4c86d84d421ab93fb1c815c5a667dd55ce8254ac', name: this.open ? 'multiply' : 'burger-menu', width: "1.5rem", height: "1.5rem" })), h("z-logo", { key: '03c7b8613698098cf3a1ff4b1b8d649cb7d5b92a', imageAlt: "Logo Zanichelli", link: "/", height: 32, width: 126 }), h("zanit-search-form", { key: '5a1385991eebcf17ac8c275c8c69f6662f75e3b7', searchQuery: this.searchQuery, onResetSearch: () => (this.searchQuery = undefined), searchArea: this.searchArea, searchEnv: this.searchEnv }), this.open && (h("ul", { key: 'bc627e55f902beaac658f02d90ed78836fde193b', class: "mobile-menu", role: "menubar" }, !this.loading && this.currentPath && this.currentPath.length > 0 && (h("li", { key: '4708f9ee160d62a6cbf6333e11c1b9d02ae3d34c', role: "none" }, h("a", { key: '9fd59125f8cb87f6c86108eea7ba79a04bc4d68c', 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: '615bc59a1f058a745bdadd90c6f51f9abc757df1', name: "arrow-left", width: "0.5rem", height: "0.5rem" }), h("span", { key: '66a80691639e97b2d7d7d61cc45f8b47dcdabafe' }, this.parentItem?.label || 'Home')))), this.loading ? (h("div", { 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 > 0 && (h("div", { class: "items-container", role: "none" }, this.menuItems.map((item) => (h("li", { role: "none" }, h("a", { class: {
657
698
  'menu-item': this.menuType === 'menu',
658
699
  'menubar-item': this.menuType === 'menubar',
659
700
  }, 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))))))))))));
@@ -666,7 +707,91 @@ const ZanitMobileMenubar = class {
666
707
  };
667
708
  ZanitMobileMenubar.style = mobileMenubarCss + menuCss;
668
709
 
669
- const searchFormCss = ":host,*,::before,::after{box-sizing:border-box}*:focus:focus-visible{box-shadow:var(--shadow-focus-primary);outline:none}button{all:unset;cursor:pointer}.searchbar{--searchbar-button-x-padding:14px;--searchbar-button-icon-width:1.75rem;--closed-searchbar-width:calc((var(--searchbar-button-x-padding) * 2) + var(--searchbar-button-icon-width) + 1px);position:absolute;top:0;right:0;display:flex;width:var(--closed-searchbar-width);justify-content:flex-end;transition:width 0.4s ease-in-out}.searchbar.searchbar-open{width:100%}.searchbar .input-wrapper{display:flex;overflow:hidden;width:100%;align-items:center;padding:8px;padding-left:var(--grid-margin);background-color:#fff;gap:8px;transition-duration:0.4s;transition-property:padding-right, padding-left, width;transition-timing-function:ease-in-out}.searchbar:not(.searchbar-open) .input-wrapper{overflow:hidden;width:0;padding:0}.searchbar button[type='reset']{--z-icon-width:1rem;--z-icon-height:1rem;display:flex;align-items:center;cursor:pointer}.searchbar input{z-index:1;width:100%;height:100%;padding:0;border:none;background-color:#fff;font-family:var(--font-family-sans);font-size:1rem}.searchbar.searchbar-open input:first-child{padding-left:4px;margin-left:-4px;}.searchbar input[type='search']::-webkit-search-cancel-button,.searchbar input[type='search']::-webkit-search-decoration{appearance:none}.searchbar input::placeholder{color:var(--gray500)}.searchbar .searchbar-button{display:flex;align-items:center;justify-content:center;padding:10px var(--searchbar-button-x-padding);border-left:1px solid #000;background:var(--zanit-accent-color);font-family:inherit;font-size:inherit;gap:64px;line-height:1}.searchbar .searchbar-button:focus-visible{z-index:1}.searchbar-button z-icon{--z-icon-width:var(--searchbar-button-icon-width);--z-icon-height:var(--searchbar-button-icon-width)}@media (width < 1152px){.searchbar .searchbar-button>.searchbar-button-label{display:none}}@media (width >= 768px){.searchbar{--searchbar-button-x-padding:16px;--searchbar-button-icon-width:2rem}.searchbar .input-wrapper{gap:14px}.searchbar button[type='reset']{--z-icon-width:1.5rem;--z-icon-height:1.5rem}.searchbar input,.searchbar .searchbar-button{font-size:1.5rem}.searchbar .searchbar-button{padding:8px var(--searchbar-button-x-padding)}}@media (width >= 1152px){.searchbar{--closed-searchbar-width:190px}}@media (width >= 1366px){.searchbar .searchbar-button{border-right:1px solid #000}}";
710
+ var AREA_LABELS;
711
+ (function (AREA_LABELS) {
712
+ AREA_LABELS["SCUOLA"] = "Scuola";
713
+ AREA_LABELS["UNIVERSIT\u00C0"] = "Universit\u00E0";
714
+ AREA_LABELS["GIURIDICO"] = "Giuridico";
715
+ AREA_LABELS["DIZIONARI"] = "Dizionari";
716
+ AREA_LABELS["SAGGISTICA"] = "Saggistica";
717
+ })(AREA_LABELS || (AREA_LABELS = {}));
718
+ const AREA_ORDER = Object.keys(AREA_LABELS);
719
+ function buildSuggestions(query, subjectsByArea, selectedArea) {
720
+ const matchingSubjectAreas = findSubjectAreas(query, subjectsByArea);
721
+ const hasSubject = matchingSubjectAreas.length > 0;
722
+ const subject = hasSubject ? query.toUpperCase() : undefined;
723
+ const suggestions = [];
724
+ if (selectedArea)
725
+ suggestions.push(buildWordSuggestion(query, selectedArea));
726
+ suggestions.push(buildWordSuggestion(query));
727
+ if (hasSubject) {
728
+ if (selectedArea) {
729
+ const orderedSubjectAreas = [
730
+ ...matchingSubjectAreas.filter((area) => area === selectedArea),
731
+ ...matchingSubjectAreas
732
+ .filter((area) => area !== selectedArea)
733
+ .sort((a, b) => getAreaOrder(a) - getAreaOrder(b)),
734
+ ];
735
+ orderedSubjectAreas.forEach((area) => suggestions.push(buildSubjectSuggestion(query, area, subject)));
736
+ }
737
+ else {
738
+ matchingSubjectAreas
739
+ .sort((a, b) => getAreaOrder(a) - getAreaOrder(b))
740
+ .forEach((subjectArea) => suggestions.push(buildSubjectSuggestion(query, subjectArea, subject)));
741
+ }
742
+ }
743
+ return suggestions;
744
+ }
745
+ const buildWordSuggestion = (user_query, area) => {
746
+ return {
747
+ id: buildId(`word-${user_query}-${area}`),
748
+ label: buildLabel(user_query, area, false, false),
749
+ html_label: buildLabel(user_query, area, false, true),
750
+ url: buildUrl({ q: user_query, ...(area ? { area } : {}), user_query }),
751
+ ...buildDetail(user_query, user_query, area),
752
+ };
753
+ };
754
+ const buildSubjectSuggestion = (user_query, area, subject) => {
755
+ return {
756
+ id: buildId(`subj-${user_query}-${area}-${subject}`),
757
+ label: buildLabel(user_query, area, true, false),
758
+ html_label: buildLabel(user_query, area, true, true),
759
+ url: buildUrl({ area, materia: subject, user_query }),
760
+ ...buildDetail(user_query, undefined, area, subject),
761
+ };
762
+ };
763
+ const buildId = (string) => string
764
+ .split('')
765
+ .map((c) => c.charCodeAt(0).toString(16))
766
+ .join('');
767
+ const buildUrl = (params) => {
768
+ return `ricerca?${new URLSearchParams(params).toString()}`;
769
+ };
770
+ const buildDetail = (user_query, query, area, subject) => ({
771
+ user_query,
772
+ ...(query ? { query } : {}),
773
+ ...(area ? { area } : {}),
774
+ ...(subject ? { subject } : {}),
775
+ });
776
+ const buildLabel = (user_query, area, isSubject = false, isHtml = false) => {
777
+ const openStrong = isHtml ? `<strong>` : ``;
778
+ const closeStrong = isHtml ? `</strong>` : ``;
779
+ return `Cerca la ${isSubject ? `materia` : `parola`} ${openStrong}${user_query}${closeStrong} ${area ? `nel catalogo ${openStrong}${AREA_LABELS[area] ?? area}${closeStrong}` : `in tutto il sito`}`;
780
+ };
781
+ function findSubjectAreas(query, subjectsByArea) {
782
+ const cleanedQuery = cleanSearch(query);
783
+ return Object.entries(subjectsByArea)
784
+ .filter(([, subjects]) => subjects.some((subject) => subject.toLowerCase() === cleanedQuery))
785
+ .map(([area]) => area);
786
+ }
787
+ /** Clear search string: lowercase, remove multiple spaces */
788
+ const cleanSearch = (s) => s.toLowerCase().replace(/\s+/g, ' ');
789
+ const getAreaOrder = (area) => {
790
+ const index = AREA_ORDER.indexOf(area);
791
+ return index >= 0 ? index : 100;
792
+ };
793
+
794
+ const searchFormCss = ":host,*,::before,::after{box-sizing:border-box}*:focus:focus-visible{box-shadow:var(--shadow-focus-primary);outline:none}button{all:unset;cursor:pointer}.searchbar{--searchbar-button-x-padding:14px;--searchbar-button-icon-width:1.75rem;--closed-searchbar-width:calc((var(--searchbar-button-x-padding) * 2) + var(--searchbar-button-icon-width) + 1px);position:absolute;z-index:5;top:0;right:0;display:flex;width:var(--closed-searchbar-width);height:3rem;justify-content:flex-end;transition:width 0.4s ease-in-out}.searchbar.searchbar-open{width:100%}.searchbar .input-wrapper{display:flex;overflow:hidden;width:100%;align-items:center;padding:8px;padding-left:var(--grid-margin);background-color:#fff;gap:8px;transition-duration:0.4s;transition-property:padding-right, padding-left, width;transition-timing-function:ease-in-out}.searchbar:not(.searchbar-open) .input-wrapper{overflow:hidden;width:0;padding:0}.searchbar button[type='reset']{--z-icon-width:1rem;--z-icon-height:1rem;display:flex;align-items:center;cursor:pointer}.searchbar input{z-index:1;width:100%;height:100%;padding:0;border:none;background-color:#fff;font-family:var(--font-family-sans);font-size:1rem}.searchbar.searchbar-open input:first-child{padding-left:4px;margin-left:-4px;}.searchbar input[type='search']::-webkit-search-cancel-button,.searchbar input[type='search']::-webkit-search-decoration{appearance:none}.searchbar input::placeholder{color:var(--gray500)}.searchbar .searchbar-button{display:flex;align-items:center;justify-content:center;padding:10px var(--searchbar-button-x-padding);border-left:1px solid #000;background:var(--zanit-accent-color);font-family:inherit;font-size:inherit;gap:64px;line-height:1}.searchbar .searchbar-button:focus-visible{z-index:1}.searchbar-button z-icon{--z-icon-width:var(--searchbar-button-icon-width);--z-icon-height:var(--searchbar-button-icon-width)}.suggestions-wrapper{position:absolute;z-index:4;top:3rem;left:50%;width:100vw;border-top:1px solid var(--gray200);margin-left:-50vw;background:#fff;box-shadow:var(--shadow-1)}.suggestions-wrapper.hidden{display:none}.suggestions{display:flex;width:100%;flex-direction:column;align-items:stretch;padding:var(--space-unit);margin:0 auto}.suggestion{padding:calc(var(--space-unit) * 0.75) var(--space-unit);cursor:pointer;font-size:1rem;line-height:1.5rem}.suggestion strong{font-size:1.125rem}.suggestion:hover,.suggestion[aria-selected='true']{background:var(--gray100)}@media (width < 1152px){.searchbar .searchbar-button>.searchbar-button-label{display:none}}@media (width >= 768px){.searchbar{--searchbar-button-x-padding:16px;--searchbar-button-icon-width:2rem}.searchbar .input-wrapper{gap:14px}.searchbar button[type='reset']{--z-icon-width:1.5rem;--z-icon-height:1.5rem}.searchbar input,.searchbar .searchbar-button{font-size:1.5rem}.searchbar .searchbar-button{padding:8px var(--searchbar-button-x-padding)}.suggestions{padding:var(--space-unit) calc(var(--space-unit) * 2)}}@media (width >= 1152px){.searchbar{--closed-searchbar-width:190px}}@media (width >= 1366px){.searchbar .searchbar-button{border-right:1px solid #000}.suggestions{max-width:1366px;padding:var(--space-unit) calc(var(--space-unit) * 3)}}";
670
795
 
671
796
  const ZanitSearchForm = class {
672
797
  constructor(hostRef) {
@@ -675,44 +800,77 @@ const ZanitSearchForm = class {
675
800
  this.resetSearch = createEvent(this, "resetSearch");
676
801
  }
677
802
  formElement;
803
+ subjectsByArea = {};
804
+ timer;
678
805
  get host() { return getElement(this); }
679
806
  /** Indicates whether the searchbar is visible and usable. */
680
807
  showSearchbar = false;
681
808
  /** Search query to apply. */
682
809
  _searchQuery = undefined;
810
+ /** Search suggestions to show in the autocomplete dropdown. */
811
+ suggestions = [];
812
+ /** Active suggestion - used for keyboard navigation */
813
+ activeSuggestion = '';
814
+ /** Show suggestions list */
815
+ showSuggestions = false;
683
816
  /** Initial search query */
684
817
  searchQuery = undefined;
818
+ /** Environment for search suggestions */
819
+ searchEnv = SearchEnv.PROD;
820
+ /** Search area (e.g. "SCUOLA", "UNIVERSITÀ", "DIZIONARI"). */
821
+ searchArea;
685
822
  onSearchQueryChange() {
686
823
  this._searchQuery = this.searchQuery;
687
824
  if (this.searchQuery) {
688
825
  this.openSearchbar();
689
826
  }
827
+ this.resetSuggestions();
828
+ }
829
+ onSearchAreaChange() {
830
+ this.resetSuggestions();
831
+ }
832
+ onShowSearchbarChange() {
833
+ if (!this.showSearchbar) {
834
+ this.showSuggestions = false;
835
+ }
836
+ }
837
+ onShowSuggestionsChange() {
838
+ this.activeSuggestion = '';
690
839
  }
691
840
  /** Emitted on search form submission. */
692
841
  search;
693
842
  resetSearch;
694
843
  async connectedCallback() {
844
+ this.subjectsByArea = await getSubjectsByArea(this.searchEnv);
695
845
  this.showSearchbar = !!this.searchQuery;
696
846
  this._searchQuery = this.searchQuery;
697
847
  }
698
848
  /** Close open searchbar when clicking outside. */
699
849
  handleOutsideClick(event) {
700
- if (this.showSearchbar && this.formElement && !containsTarget(this.formElement, event)) {
850
+ if (this.showSearchbar && this.host && !containsTarget(this.host, event)) {
701
851
  this.showSearchbar = false;
702
852
  }
703
853
  }
704
- /** Close the menu when pressing Escape or Tab. */
705
- handleKeydown(event) {
706
- switch (event.key) {
707
- case 'Escape':
708
- this.showSearchbar = false;
709
- break;
710
- case 'Tab':
711
- if (containsTarget(this.host, event)) {
712
- break;
713
- }
714
- this.showSearchbar = false;
715
- break;
854
+ /** Close the searchbar/suggestions when pressing Escape. */
855
+ handleEsc(event) {
856
+ if (!isEscKey(event)) {
857
+ return;
858
+ }
859
+ if (this.showSuggestions) {
860
+ this.showSuggestions = false;
861
+ }
862
+ else {
863
+ this.showSearchbar = false;
864
+ }
865
+ }
866
+ /** Close the searchbar/suggestions when pressing Tab. */
867
+ handleTab(event) {
868
+ if (!isTabKey(event)) {
869
+ return;
870
+ }
871
+ this.showSuggestions = false;
872
+ if (!containsTarget(this.host, event)) {
873
+ this.showSearchbar = false;
716
874
  }
717
875
  }
718
876
  openSearchbar() {
@@ -726,30 +884,114 @@ const ZanitSearchForm = class {
726
884
  this.searchQuery = undefined;
727
885
  this.resetSearch.emit();
728
886
  }
887
+ resetSuggestions() {
888
+ this.suggestions = [];
889
+ this.showSuggestions = false;
890
+ }
729
891
  handleInputChange(event) {
730
892
  this._searchQuery = event.target.value;
731
893
  if (!this._searchQuery) {
732
894
  this.searchQuery = undefined;
733
895
  }
896
+ this.updateSuggestions();
897
+ }
898
+ updateSuggestions() {
899
+ clearTimeout(this.timer);
900
+ const query = (this._searchQuery || '').trim();
901
+ if (query.length < 3) {
902
+ this.resetSuggestions();
903
+ return;
904
+ }
905
+ this.timer = setTimeout(() => {
906
+ this.resetSuggestions();
907
+ this.suggestions = buildSuggestions(query, this.subjectsByArea, this.searchArea?.toUpperCase());
908
+ this.showSuggestions = true;
909
+ }, 300);
734
910
  }
735
911
  onSearchSubmit(event) {
736
912
  event.preventDefault();
737
913
  if (!this._searchQuery) {
738
914
  return;
739
915
  }
916
+ if (this.activeSuggestion) {
917
+ const suggestion = this.suggestions.find((s) => s.id === this.activeSuggestion);
918
+ if (suggestion) {
919
+ this.submitSuggestionSearch(suggestion);
920
+ this.showSuggestions = false;
921
+ return;
922
+ }
923
+ }
740
924
  this.showSearchbar = false;
741
- const searchEv = this.search.emit({ query: this._searchQuery });
925
+ const searchEv = this.search.emit({ query: this._searchQuery, area: this.searchArea });
742
926
  // do not submit the form if the event default behavior was prevented
743
927
  if (searchEv.defaultPrevented) {
744
928
  return;
745
929
  }
746
930
  this.formElement.submit();
747
931
  }
932
+ submitSuggestionSearch(suggestion) {
933
+ const ev = this.search.emit({
934
+ user_query: suggestion.user_query,
935
+ query: suggestion.query,
936
+ area: suggestion.area,
937
+ subject: suggestion.subject,
938
+ });
939
+ if (!ev.defaultPrevented) {
940
+ window.location.href = suggestion.url;
941
+ }
942
+ }
943
+ handleSuggestionsNav(event) {
944
+ if (!isArrowDownKey(event) && !isArrowUpKey(event)) {
945
+ return;
946
+ }
947
+ if (!this.suggestions.length) {
948
+ return;
949
+ }
950
+ const options = this.suggestions.map((o) => o.id);
951
+ if (!options.length) {
952
+ return;
953
+ }
954
+ event.preventDefault();
955
+ event.stopPropagation();
956
+ if (!this.showSuggestions) {
957
+ this.showSuggestions = true;
958
+ }
959
+ let nextId = null;
960
+ const firstId = options[0];
961
+ const lastId = options[options.length - 1];
962
+ const currOption = options.indexOf(this.activeSuggestion);
963
+ if (currOption < 0) {
964
+ nextId = isArrowDownKey(event) ? firstId : lastId;
965
+ }
966
+ else {
967
+ if (isArrowDownKey(event)) {
968
+ nextId = options[currOption + 1] || lastId;
969
+ }
970
+ else {
971
+ nextId = options[currOption - 1] || firstId;
972
+ }
973
+ }
974
+ this.activeSuggestion = nextId;
975
+ }
976
+ renderSuggestions() {
977
+ return (h("div", { class: { 'suggestions-wrapper': true, 'hidden': !this.showSuggestions || !this.suggestions.length }, onPointerOver: (e) => e.preventDefault() }, h("div", { id: "search-suggestions", class: "suggestions", role: "listbox", "aria-label": "Seleziona tra i suggerimenti" }, this.suggestions.map((suggestion, k) => {
978
+ return (h("span", { key: k, innerHTML: suggestion.html_label, id: suggestion.id, class: "suggestion", role: "option", "aria-label": suggestion.label, "aria-selected": this.activeSuggestion === suggestion.id ? 'true' : undefined, onClick: () => this.submitSuggestionSearch(suggestion) }));
979
+ }))));
980
+ }
748
981
  render() {
749
- return (h("form", { key: 'e1d177efbec2aea39cd30cfc8f02fe4e9f5e82d9', class: { 'searchbar': true, 'searchbar-open': this.showSearchbar }, ref: (el) => (this.formElement = el), role: "search", "aria-label": "Cerca nel sito", method: "get", action: "/ricerca", onSubmit: (event) => this.onSearchSubmit(event), onReset: () => this.resetSearchQuery() }, h("div", { key: '49aeaa97516d5782e1fcf866a5526ff19f8b0c14', class: "input-wrapper", role: "none" }, this.searchQuery && (h("button", { key: '61ec6636b5efd875bcf879b28894ffd1cf8ac802', type: "reset", "aria-label": "Svuota campo di ricerca", disabled: !this.showSearchbar, "aria-hidden": !this.showSearchbar ? 'true' : undefined, tabIndex: !this.showSearchbar ? -1 : 0 }, h("z-icon", { key: 'a896ac0e6ae2762e9d5dbb0351634505b519a684', name: "multiply-circled" }))), h("input", { key: '3ab6655ef669a6c30b5bbe547884c680284d7f14', id: "searchbar-input", name: "q", type: "search", disabled: !this.showSearchbar, placeholder: "Cerca per parola chiave o ISBN", onInput: (event) => this.handleInputChange(event), value: this.searchQuery, required: true, "aria-label": "Cerca per parola chiave o ISBN", "aria-hidden": !this.showSearchbar ? 'true' : undefined, tabIndex: !this.showSearchbar ? -1 : 0 })), h("button", { key: '3df725da35664493fe70a15ea39184ab00b37e32', class: "searchbar-button", "aria-label": this.showSearchbar ? 'Esegui ricerca' : 'Apri il campo di ricerca', "aria-controls": "searchbar-input", type: this.showSearchbar ? 'submit' : 'button', onClick: () => this.openSearchbar() }, this.showSearchbar ? null : h("span", { class: "searchbar-button-label" }, "Cerca"), h("z-icon", { key: '8f6cfd25fbacbc04b7bc060470667eb9b2a45179', name: "search" }))));
982
+ return (h(Host, { key: '5d4462489f2dd40636fd2bb025cb468bc4c5616e' }, h("form", { key: '21b2841bb46a3a839a4e4b4443635d48f70b4ae4', class: { 'searchbar': true, 'searchbar-open': this.showSearchbar }, ref: (el) => (this.formElement = el), role: "search", "aria-label": "Cerca nel sito", method: "get", action: "/ricerca", onSubmit: (event) => this.onSearchSubmit(event), onReset: () => this.resetSearchQuery() }, !!this.searchArea && (h("input", { key: '67a60d9d8995e2e06ce1c27e3946158e55a142b0', type: "hidden", name: "area", value: this.searchArea })), h("div", { key: '09cecaba254019023f8206fa777bda6273cbeb15', class: "input-wrapper", role: "none" }, this.searchQuery && (h("button", { key: 'b50b141eba8ced81b4c97ffb9ed4547eada6494f', type: "reset", "aria-label": "Svuota campo di ricerca", disabled: !this.showSearchbar, "aria-hidden": !this.showSearchbar ? 'true' : undefined, tabIndex: !this.showSearchbar ? -1 : 0 }, h("z-icon", { key: 'b9a46579d4ae8e7850f38758b12eb0ec1aba731f', name: "multiply-circled" }))), h("input", { key: '3fbae3a688e7c775a5c96df4d1390f89da032f5b', id: "searchbar-input", name: "q", type: "search", disabled: !this.showSearchbar, placeholder: "Cerca per parola chiave o ISBN", value: this.searchQuery, required: true, autocomplete: "off", role: "combobox", "aria-autocomplete": "list", "aria-expanded": this.showSuggestions ? 'true' : 'false', "aria-controls": "search-suggestions", "aria-activedescendant": this.activeSuggestion, "aria-label": "Cerca per parola chiave o ISBN", "aria-hidden": !this.showSearchbar ? 'true' : undefined, tabIndex: !this.showSearchbar ? -1 : 0, onInput: (event) => this.handleInputChange(event), onKeyDown: (e) => {
983
+ // INFO: prevent ESC from clearing input
984
+ if (isEscKey(e)) {
985
+ e.preventDefault();
986
+ }
987
+ this.handleSuggestionsNav(e);
988
+ } })), h("button", { key: '996e557aef2f19dedc0d4dc76df392336ce85af3', class: "searchbar-button", "aria-label": this.showSearchbar ? 'Esegui ricerca' : 'Apri il campo di ricerca', "aria-controls": "searchbar-input", type: this.showSearchbar ? 'submit' : 'button', onClick: () => this.openSearchbar() }, this.showSearchbar ? null : h("span", { class: "searchbar-button-label" }, "Cerca"), h("z-icon", { key: '85eac62f283fd347316f7bcdd45220e5f8c32040', name: "search" }))), this.renderSuggestions()));
750
989
  }
751
990
  static get watchers() { return {
752
- "searchQuery": ["onSearchQueryChange"]
991
+ "searchQuery": ["onSearchQueryChange"],
992
+ "searchArea": ["onSearchAreaChange"],
993
+ "showSearchbar": ["onShowSearchbarChange"],
994
+ "showSuggestions": ["onShowSuggestionsChange"]
753
995
  }; }
754
996
  };
755
997
  ZanitSearchForm.style = searchFormCss;