@zanichelli/zanichelli-it-frontend-kit 1.3.1 → 1.4.0-RC2

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 (124) hide show
  1. package/dist/types/components/menubar/menubar.d.ts +5 -0
  2. package/dist/types/components/menubar/mobile-menubar/mobile-menubar.d.ts +5 -0
  3. package/dist/types/components/menubar/search-form/search-form.d.ts +28 -5
  4. package/dist/types/components/menubar/search-form/suggestions.d.ts +11 -0
  5. package/dist/types/components.d.ts +60 -4
  6. package/dist/types/utils/subjects.api.d.ts +6 -0
  7. package/dist/types/utils/types.d.ts +7 -0
  8. package/dist/types/utils/utils.d.ts +8 -0
  9. package/dist/zanichelli-it-frontend-kit/index-DPw_TAEB.js +4170 -0
  10. package/dist/zanichelli-it-frontend-kit/index-DPw_TAEB.js.map +1 -0
  11. package/dist/zanichelli-it-frontend-kit/index.esm.js +10 -0
  12. package/dist/zanichelli-it-frontend-kit/index.esm.js.map +1 -1
  13. package/dist/zanichelli-it-frontend-kit/menu-BsP3cOc_.js +46 -0
  14. package/dist/zanichelli-it-frontend-kit/menu-BsP3cOc_.js.map +1 -0
  15. package/dist/zanichelli-it-frontend-kit/subjects.api-BRhngFD0.js +54 -0
  16. package/dist/zanichelli-it-frontend-kit/subjects.api-BRhngFD0.js.map +1 -0
  17. package/dist/zanichelli-it-frontend-kit/zanichelli-it-frontend-kit.css +993 -1
  18. package/dist/zanichelli-it-frontend-kit/zanichelli-it-frontend-kit.esm.js +49 -1
  19. package/dist/zanichelli-it-frontend-kit/zanichelli-it-frontend-kit.esm.js.map +1 -1
  20. package/dist/zanichelli-it-frontend-kit/zanit-back-to-top.entry.esm.js.map +1 -0
  21. package/dist/{components/zanit-back-to-top.js → zanichelli-it-frontend-kit/zanit-back-to-top.entry.js} +10 -34
  22. package/dist/zanichelli-it-frontend-kit/zanit-back-to-top.entry.js.map +1 -0
  23. package/dist/zanichelli-it-frontend-kit/zanit-menubar.entry.esm.js.map +1 -0
  24. package/dist/{components/zanit-menubar.js → zanichelli-it-frontend-kit/zanit-menubar.entry.js} +19 -58
  25. package/dist/zanichelli-it-frontend-kit/zanit-menubar.entry.js.map +1 -0
  26. package/dist/zanichelli-it-frontend-kit/zanit-mobile-menubar.entry.esm.js.map +1 -0
  27. package/dist/{components/p-BJzEFXY7.js → zanichelli-it-frontend-kit/zanit-mobile-menubar.entry.js} +18 -87
  28. package/dist/zanichelli-it-frontend-kit/zanit-mobile-menubar.entry.js.map +1 -0
  29. package/dist/zanichelli-it-frontend-kit/zanit-search-form.entry.esm.js.map +1 -0
  30. package/dist/zanichelli-it-frontend-kit/zanit-search-form.entry.js +307 -0
  31. package/dist/zanichelli-it-frontend-kit/zanit-search-form.entry.js.map +1 -0
  32. package/package.json +1 -1
  33. package/www/build/index-DPw_TAEB.js +4170 -0
  34. package/www/build/index-DPw_TAEB.js.map +1 -0
  35. package/www/build/index.esm.js +10 -0
  36. package/www/build/index.esm.js.map +1 -1
  37. package/www/build/menu-BsP3cOc_.js +46 -0
  38. package/www/build/menu-BsP3cOc_.js.map +1 -0
  39. package/www/build/subjects.api-BRhngFD0.js +54 -0
  40. package/www/build/subjects.api-BRhngFD0.js.map +1 -0
  41. package/www/build/zanichelli-it-frontend-kit.css +993 -1
  42. package/www/build/zanichelli-it-frontend-kit.esm.js +49 -1
  43. package/www/build/zanichelli-it-frontend-kit.esm.js.map +1 -1
  44. package/www/build/zanit-back-to-top.entry.esm.js.map +1 -0
  45. package/www/build/zanit-back-to-top.entry.js +64 -0
  46. package/www/build/zanit-back-to-top.entry.js.map +1 -0
  47. package/www/build/zanit-menubar.entry.esm.js.map +1 -0
  48. package/{dist/collection/components/menubar/menubar.js → www/build/zanit-menubar.entry.js} +31 -159
  49. package/www/build/zanit-menubar.entry.js.map +1 -0
  50. package/www/build/zanit-mobile-menubar.entry.esm.js.map +1 -0
  51. package/www/build/zanit-mobile-menubar.entry.js +171 -0
  52. package/www/build/zanit-mobile-menubar.entry.js.map +1 -0
  53. package/www/build/zanit-search-form.entry.esm.js.map +1 -0
  54. package/www/build/zanit-search-form.entry.js +307 -0
  55. package/www/build/zanit-search-form.entry.js.map +1 -0
  56. package/www/index.html +11 -2
  57. package/dist/cjs/index-BLzQAHAI.js +0 -1578
  58. package/dist/cjs/index-BLzQAHAI.js.map +0 -1
  59. package/dist/cjs/index.cjs.js +0 -5
  60. package/dist/cjs/index.cjs.js.map +0 -1
  61. package/dist/cjs/loader.cjs.js +0 -15
  62. package/dist/cjs/loader.cjs.js.map +0 -1
  63. package/dist/cjs/zanichelli-it-frontend-kit.cjs.js +0 -27
  64. package/dist/cjs/zanichelli-it-frontend-kit.cjs.js.map +0 -1
  65. package/dist/cjs/zanit-back-to-top.zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.cjs.js.map +0 -1
  66. package/dist/cjs/zanit-back-to-top_4.cjs.entry.js +0 -771
  67. package/dist/cjs/zanit-back-to-top_4.cjs.entry.js.map +0 -1
  68. package/dist/collection/collection-manifest.json +0 -15
  69. package/dist/collection/components/back-to-top/back-to-top.css +0 -16
  70. package/dist/collection/components/back-to-top/back-to-top.js +0 -130
  71. package/dist/collection/components/back-to-top/back-to-top.js.map +0 -1
  72. package/dist/collection/components/menubar/menu/menu.css +0 -95
  73. package/dist/collection/components/menubar/menu/menu.js +0 -38
  74. package/dist/collection/components/menubar/menu/menu.js.map +0 -1
  75. package/dist/collection/components/menubar/menubar.css +0 -168
  76. package/dist/collection/components/menubar/menubar.js.map +0 -1
  77. package/dist/collection/components/menubar/mobile-menubar/mobile-menubar.css +0 -121
  78. package/dist/collection/components/menubar/mobile-menubar/mobile-menubar.js +0 -291
  79. package/dist/collection/components/menubar/mobile-menubar/mobile-menubar.js.map +0 -1
  80. package/dist/collection/components/menubar/search-form/search-form.css +0 -155
  81. package/dist/collection/components/menubar/search-form/search-form.js +0 -176
  82. package/dist/collection/components/menubar/search-form/search-form.js.map +0 -1
  83. package/dist/collection/index.js +0 -11
  84. package/dist/collection/index.js.map +0 -1
  85. package/dist/collection/utils/index.js +0 -2
  86. package/dist/collection/utils/index.js.map +0 -1
  87. package/dist/collection/utils/utils.js +0 -17
  88. package/dist/collection/utils/utils.js.map +0 -1
  89. package/dist/components/index.js +0 -1335
  90. package/dist/components/index.js.map +0 -1
  91. package/dist/components/p-BJzEFXY7.js.map +0 -1
  92. package/dist/components/p-Cfa-BVne.js +0 -133
  93. package/dist/components/p-Cfa-BVne.js.map +0 -1
  94. package/dist/components/zanit-back-to-top.js.map +0 -1
  95. package/dist/components/zanit-menubar.js.map +0 -1
  96. package/dist/components/zanit-mobile-menubar.js +0 -9
  97. package/dist/components/zanit-mobile-menubar.js.map +0 -1
  98. package/dist/components/zanit-search-form.js +0 -9
  99. package/dist/components/zanit-search-form.js.map +0 -1
  100. package/dist/esm/index-DSdvvVFj.js +0 -1549
  101. package/dist/esm/index-DSdvvVFj.js.map +0 -1
  102. package/dist/esm/index.js +0 -4
  103. package/dist/esm/index.js.map +0 -1
  104. package/dist/esm/loader.js +0 -13
  105. package/dist/esm/loader.js.map +0 -1
  106. package/dist/esm/zanichelli-it-frontend-kit.js +0 -23
  107. package/dist/esm/zanichelli-it-frontend-kit.js.map +0 -1
  108. package/dist/esm/zanit-back-to-top.zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.js.map +0 -1
  109. package/dist/esm/zanit-back-to-top_4.entry.js +0 -766
  110. package/dist/esm/zanit-back-to-top_4.entry.js.map +0 -1
  111. package/dist/index.cjs.js +0 -1
  112. package/dist/index.js +0 -1
  113. package/dist/zanichelli-it-frontend-kit/p-DSdvvVFj.js +0 -3
  114. package/dist/zanichelli-it-frontend-kit/p-DSdvvVFj.js.map +0 -1
  115. package/dist/zanichelli-it-frontend-kit/p-fe01ee7e.entry.js +0 -2
  116. package/dist/zanichelli-it-frontend-kit/p-fe01ee7e.entry.js.map +0 -1
  117. package/dist/zanichelli-it-frontend-kit/zanit-back-to-top.zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.esm.js.map +0 -1
  118. package/www/build/p-43c395dc.css +0 -1
  119. package/www/build/p-DSdvvVFj.js +0 -3
  120. package/www/build/p-DSdvvVFj.js.map +0 -1
  121. package/www/build/p-b4df0dec.js +0 -2
  122. package/www/build/p-fe01ee7e.entry.js +0 -2
  123. package/www/build/p-fe01ee7e.entry.js.map +0 -1
  124. package/www/build/zanit-back-to-top.zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.esm.js.map +0 -1
@@ -1,4 +1,5 @@
1
1
  import { MenubarItem } from '../../utils';
2
+ import { SearchEnv } from '../../utils/subjects.api';
2
3
  /**
3
4
  * Main menubar component. Each item can have a menu with subitems
4
5
  * When a main menubar item is the current active one, a sub-menubar is shown and each subitem can have a menu with subitems.
@@ -22,6 +23,10 @@ export declare class ZanitMenubar {
22
23
  current: string | undefined;
23
24
  /** Initial search query. */
24
25
  searchQuery: string | undefined;
26
+ /** Environment for search suggestions */
27
+ searchEnv: SearchEnv;
28
+ /** Search area (e.g. "SCUOLA", "UNIVERSITÀ", "DIZIONARI"). */
29
+ searchArea?: string | undefined;
25
30
  private timerId;
26
31
  /** Setup the list of items. */
27
32
  parseData(data: typeof this.data): Promise<void>;
@@ -1,4 +1,5 @@
1
1
  import { MenubarItem, MenuItem } from '../../../utils';
2
+ import { SearchEnv } from '../../../utils/subjects.api';
2
3
  /** Mobile menubar component. */
3
4
  export declare class ZanitMobileMenubar {
4
5
  host: HTMLZanitMobileMenubarElement;
@@ -10,6 +11,10 @@ export declare class ZanitMobileMenubar {
10
11
  searchQuery: string | undefined;
11
12
  /** Whether the menubar is loading the data. */
12
13
  loading: boolean;
14
+ /** Environment for search suggestions */
15
+ searchEnv: SearchEnv;
16
+ /** Search area (e.g. "SCUOLA", "UNIVERSITÀ", "DIZIONARI"). */
17
+ searchArea?: string | undefined;
13
18
  /** Last active item ID. */
14
19
  lastCurrent: string | undefined;
15
20
  parentItem: MenubarItem | undefined;
@@ -1,27 +1,50 @@
1
1
  import { EventEmitter } from '../../../stencil-public-runtime';
2
+ import { SearchEvent } from '../../../utils';
3
+ import { SearchEnv } from '../../../utils/subjects.api';
4
+ import { SearchSuggestion } from './suggestions';
2
5
  export declare class ZanitSearchForm {
3
6
  private formElement;
7
+ private subjectsByArea;
8
+ private timer;
4
9
  host: HTMLZanitSearchFormElement;
5
10
  /** Indicates whether the searchbar is visible and usable. */
6
11
  showSearchbar: boolean;
7
12
  /** Search query to apply. */
8
13
  _searchQuery: string | undefined;
14
+ /** Search suggestions to show in the autocomplete dropdown. */
15
+ suggestions: SearchSuggestion[];
16
+ /** Active suggestion - used for keyboard navigation */
17
+ activeSuggestion: string;
18
+ /** Show suggestions list */
19
+ showSuggestions: boolean;
9
20
  /** Initial search query */
10
21
  searchQuery: string | undefined;
22
+ /** Environment for search suggestions */
23
+ searchEnv: SearchEnv;
24
+ /** Search area (e.g. "SCUOLA", "UNIVERSITÀ", "DIZIONARI"). */
25
+ searchArea?: string | undefined;
11
26
  onSearchQueryChange(): void;
27
+ onSearchAreaChange(): void;
28
+ onShowSearchbarChange(): void;
29
+ onShowSuggestionsChange(): void;
12
30
  /** Emitted on search form submission. */
13
- search: EventEmitter<{
14
- query: string;
15
- }>;
31
+ search: EventEmitter<SearchEvent>;
16
32
  resetSearch: EventEmitter<void>;
17
33
  connectedCallback(): Promise<void>;
18
34
  /** Close open searchbar when clicking outside. */
19
35
  handleOutsideClick(event: MouseEvent): void;
20
- /** Close the menu when pressing Escape or Tab. */
21
- handleKeydown(event: KeyboardEvent): void;
36
+ /** Close the searchbar/suggestions when pressing Escape. */
37
+ handleEsc(event: KeyboardEvent): void;
38
+ /** Close the searchbar/suggestions when pressing Tab. */
39
+ handleTab(event: KeyboardEvent): void;
22
40
  private openSearchbar;
23
41
  private resetSearchQuery;
42
+ private resetSuggestions;
24
43
  private handleInputChange;
44
+ private updateSuggestions;
25
45
  private onSearchSubmit;
46
+ private submitSuggestionSearch;
47
+ private handleSuggestionsNav;
48
+ private renderSuggestions;
26
49
  render(): any;
27
50
  }
@@ -0,0 +1,11 @@
1
+ export type SearchSuggestion = {
2
+ id: string;
3
+ label: string;
4
+ aria_label: string;
5
+ url: string;
6
+ user_query: string;
7
+ query?: string;
8
+ area?: string;
9
+ subject?: string;
10
+ };
11
+ export declare function buildSuggestions(query: string, subjectsByArea: Record<string, string[]>, selectedArea?: string): SearchSuggestion[];
@@ -5,8 +5,10 @@
5
5
  * It contains typing information for all components that exist in this project.
6
6
  */
7
7
  import { HTMLStencilElement, JSXBase } from "./stencil-public-runtime";
8
- import { MenubarItem } from "./utils";
9
- export { MenubarItem } from "./utils";
8
+ import { MenubarItem, SearchEvent } from "./utils";
9
+ import { SearchEnv } from "./utils/subjects.api";
10
+ export { MenubarItem, SearchEvent } from "./utils";
11
+ export { SearchEnv } from "./utils/subjects.api";
10
12
  export namespace Components {
11
13
  /**
12
14
  * Back to top floating action button component.
@@ -39,6 +41,15 @@ export namespace Components {
39
41
  * The data to build the menu (as an array of `MenubarItem` or a JSON array) or the url to fetch to retrieve it.
40
42
  */
41
43
  "data": Promise<MenubarItem[]> | MenubarItem[] | URL | string;
44
+ /**
45
+ * Search area (e.g. "SCUOLA", "UNIVERSITÀ", "DIZIONARI").
46
+ */
47
+ "searchArea"?: string | undefined;
48
+ /**
49
+ * Environment for search suggestions
50
+ * @default SearchEnv.PROD
51
+ */
52
+ "searchEnv": SearchEnv;
42
53
  /**
43
54
  * Initial search query.
44
55
  * @default undefined
@@ -64,6 +75,15 @@ export namespace Components {
64
75
  * @default false
65
76
  */
66
77
  "loading": boolean;
78
+ /**
79
+ * Search area (e.g. "SCUOLA", "UNIVERSITÀ", "DIZIONARI").
80
+ */
81
+ "searchArea"?: string | undefined;
82
+ /**
83
+ * Environment for search suggestions
84
+ * @default SearchEnv.PROD
85
+ */
86
+ "searchEnv": SearchEnv;
67
87
  /**
68
88
  * Initial search query.
69
89
  * @default undefined
@@ -71,6 +91,15 @@ export namespace Components {
71
91
  "searchQuery": string | undefined;
72
92
  }
73
93
  interface ZanitSearchForm {
94
+ /**
95
+ * Search area (e.g. "SCUOLA", "UNIVERSITÀ", "DIZIONARI").
96
+ */
97
+ "searchArea"?: string | undefined;
98
+ /**
99
+ * Environment for search suggestions
100
+ * @default SearchEnv.PROD
101
+ */
102
+ "searchEnv": SearchEnv;
74
103
  /**
75
104
  * Initial search query
76
105
  * @default undefined
@@ -114,7 +143,7 @@ declare global {
114
143
  new (): HTMLZanitMobileMenubarElement;
115
144
  };
116
145
  interface HTMLZanitSearchFormElementEventMap {
117
- "search": { query: string };
146
+ "search": SearchEvent;
118
147
  "resetSearch": void;
119
148
  }
120
149
  interface HTMLZanitSearchFormElement extends Components.ZanitSearchForm, HTMLStencilElement {
@@ -170,6 +199,15 @@ declare namespace LocalJSX {
170
199
  * The data to build the menu (as an array of `MenubarItem` or a JSON array) or the url to fetch to retrieve it.
171
200
  */
172
201
  "data"?: Promise<MenubarItem[]> | MenubarItem[] | URL | string;
202
+ /**
203
+ * Search area (e.g. "SCUOLA", "UNIVERSITÀ", "DIZIONARI").
204
+ */
205
+ "searchArea"?: string | undefined;
206
+ /**
207
+ * Environment for search suggestions
208
+ * @default SearchEnv.PROD
209
+ */
210
+ "searchEnv"?: SearchEnv;
173
211
  /**
174
212
  * Initial search query.
175
213
  * @default undefined
@@ -195,6 +233,15 @@ declare namespace LocalJSX {
195
233
  * @default false
196
234
  */
197
235
  "loading"?: boolean;
236
+ /**
237
+ * Search area (e.g. "SCUOLA", "UNIVERSITÀ", "DIZIONARI").
238
+ */
239
+ "searchArea"?: string | undefined;
240
+ /**
241
+ * Environment for search suggestions
242
+ * @default SearchEnv.PROD
243
+ */
244
+ "searchEnv"?: SearchEnv;
198
245
  /**
199
246
  * Initial search query.
200
247
  * @default undefined
@@ -206,7 +253,16 @@ declare namespace LocalJSX {
206
253
  /**
207
254
  * Emitted on search form submission.
208
255
  */
209
- "onSearch"?: (event: ZanitSearchFormCustomEvent<{ query: string }>) => void;
256
+ "onSearch"?: (event: ZanitSearchFormCustomEvent<SearchEvent>) => void;
257
+ /**
258
+ * Search area (e.g. "SCUOLA", "UNIVERSITÀ", "DIZIONARI").
259
+ */
260
+ "searchArea"?: string | undefined;
261
+ /**
262
+ * Environment for search suggestions
263
+ * @default SearchEnv.PROD
264
+ */
265
+ "searchEnv"?: SearchEnv;
210
266
  /**
211
267
  * Initial search query
212
268
  * @default undefined
@@ -0,0 +1,6 @@
1
+ export declare enum SearchEnv {
2
+ DEV = "dev",
3
+ TEST = "test",
4
+ PROD = "prod"
5
+ }
6
+ export declare function getSubjectsByArea(searchEnv: SearchEnv): Promise<Record<string, string[]>>;
@@ -11,3 +11,10 @@ export type MenubarItem = Omit<MenuItem, 'group' | 'highlight'> & {
11
11
  navbarItems?: MenubarItem[];
12
12
  menuItems?: MenuItem[];
13
13
  };
14
+
15
+ export type SearchEvent = {
16
+ query?: string;
17
+ area?: string;
18
+ subject?: string;
19
+ user_query?: string;
20
+ }
@@ -5,3 +5,11 @@
5
5
  export declare const containsTarget: (ancestor: HTMLElement, event: Event) => boolean;
6
6
  /** Move the focus to `next` element, set tabindex to 0 for `next` and -1 to `current`. */
7
7
  export declare const moveFocus: (current: HTMLElement, next: HTMLElement) => void;
8
+ /** Check if event key is ArrowUp */
9
+ export declare const isArrowUpKey: (event: KeyboardEvent) => boolean;
10
+ /** Check if event key is ArrowDown */
11
+ export declare const isArrowDownKey: (event: KeyboardEvent) => boolean;
12
+ /** Check if event key is Tab */
13
+ export declare const isTabKey: (event: KeyboardEvent) => boolean;
14
+ /** Check if event key is Escape */
15
+ export declare const isEscKey: (event: KeyboardEvent) => boolean;