@zanichelli/zanichelli-it-frontend-kit 1.4.0-RC1 → 1.4.0-RC3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/zanit-back-to-top.zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.cjs.js.map +1 -1
- package/dist/cjs/zanit-back-to-top_4.cjs.entry.js +33 -16
- package/dist/cjs/zanit-back-to-top_4.cjs.entry.js.map +1 -1
- package/dist/collection/components/back-to-top/back-to-top.js +10 -4
- package/dist/collection/components/back-to-top/back-to-top.js.map +1 -1
- package/dist/collection/components/menubar/search-form/search-form.css +29 -4
- package/dist/collection/components/menubar/search-form/search-form.js +13 -3
- package/dist/collection/components/menubar/search-form/search-form.js.map +1 -1
- package/dist/collection/components/menubar/search-form/suggestions.js +9 -8
- package/dist/collection/components/menubar/search-form/suggestions.js.map +1 -1
- package/dist/components/{p-_cX2Kfxg.js → p-CmameXB-.js} +3 -3
- package/dist/components/{p-_cX2Kfxg.js.map → p-CmameXB-.js.map} +1 -1
- package/dist/components/{p-WUj4Aaz8.js → p-DNk0AZSw.js} +25 -14
- package/dist/components/p-DNk0AZSw.js.map +1 -0
- package/dist/components/zanit-back-to-top.js +10 -4
- package/dist/components/zanit-back-to-top.js.map +1 -1
- package/dist/components/zanit-menubar.js +2 -2
- package/dist/components/zanit-mobile-menubar.js +1 -1
- package/dist/components/zanit-search-form.js +1 -1
- package/dist/esm/zanit-back-to-top.zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.js.map +1 -1
- package/dist/esm/zanit-back-to-top_4.entry.js +33 -16
- package/dist/esm/zanit-back-to-top_4.entry.js.map +1 -1
- package/dist/types/components/back-to-top/back-to-top.d.ts +1 -0
- package/dist/types/components/menubar/search-form/suggestions.d.ts +1 -1
- package/dist/zanichelli-it-frontend-kit/p-0f6b9e37.entry.js +2 -0
- package/dist/zanichelli-it-frontend-kit/p-0f6b9e37.entry.js.map +1 -0
- package/dist/zanichelli-it-frontend-kit/zanichelli-it-frontend-kit.esm.js +1 -1
- package/dist/zanichelli-it-frontend-kit/zanit-back-to-top.zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.esm.js.map +1 -1
- package/package.json +1 -1
- package/www/build/p-0f6b9e37.entry.js +2 -0
- package/www/build/p-0f6b9e37.entry.js.map +1 -0
- package/www/build/{p-f274d1db.js → p-9134b2b7.js} +1 -1
- package/www/build/zanichelli-it-frontend-kit.esm.js +1 -1
- package/www/build/zanit-back-to-top.zanit-menubar.zanit-mobile-menubar.zanit-search-form.entry.esm.js.map +1 -1
- package/www/index.html +1 -1
- package/dist/components/p-WUj4Aaz8.js.map +0 -1
- package/dist/zanichelli-it-frontend-kit/p-457d6be5.entry.js +0 -2
- package/dist/zanichelli-it-frontend-kit/p-457d6be5.entry.js.map +0 -1
- package/www/build/p-457d6be5.entry.js +0 -2
- package/www/build/p-457d6be5.entry.js.map +0 -1
|
@@ -7,6 +7,7 @@ const ZanitBackTop = class {
|
|
|
7
7
|
registerInstance(this, hostRef);
|
|
8
8
|
}
|
|
9
9
|
resizeObserver;
|
|
10
|
+
mutationObserver;
|
|
10
11
|
get host() { return getElement(this); }
|
|
11
12
|
/** Indicates whether the back-to-top button is visible and usable. */
|
|
12
13
|
showFab = false;
|
|
@@ -22,14 +23,18 @@ const ZanitBackTop = class {
|
|
|
22
23
|
this.updateFabVisibility();
|
|
23
24
|
}
|
|
24
25
|
handleResize = () => {
|
|
25
|
-
const newHeight = document.
|
|
26
|
-
if (newHeight !== this.currentPageHeight)
|
|
26
|
+
const newHeight = document.body.scrollHeight;
|
|
27
|
+
if (newHeight !== this.currentPageHeight) {
|
|
27
28
|
this.currentPageHeight = newHeight;
|
|
29
|
+
this.updateFabVisibility();
|
|
30
|
+
}
|
|
28
31
|
};
|
|
29
32
|
connectedCallback() {
|
|
30
33
|
this.currentPageHeight = document.body.scrollHeight;
|
|
31
34
|
this.resizeObserver = new ResizeObserver(this.handleResize);
|
|
32
|
-
this.resizeObserver.observe(document.
|
|
35
|
+
this.resizeObserver.observe(document.body);
|
|
36
|
+
this.mutationObserver = new MutationObserver(this.handleResize);
|
|
37
|
+
this.mutationObserver.observe(document.body, { childList: true, subtree: true });
|
|
33
38
|
this.updateFabVisibility();
|
|
34
39
|
const mobileMediaQuery = window.matchMedia('(width < 768px)');
|
|
35
40
|
this.isMobile = mobileMediaQuery.matches;
|
|
@@ -39,6 +44,7 @@ const ZanitBackTop = class {
|
|
|
39
44
|
}
|
|
40
45
|
disconnectedCallback() {
|
|
41
46
|
this.resizeObserver.disconnect();
|
|
47
|
+
this.mutationObserver.disconnect();
|
|
42
48
|
}
|
|
43
49
|
updateFabVisibility() {
|
|
44
50
|
this.showFab = this.currentPageHeight > this.pageMinHeight && window.scrollY > this.scrollMinHeight;
|
|
@@ -47,7 +53,7 @@ const ZanitBackTop = class {
|
|
|
47
53
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
48
54
|
}
|
|
49
55
|
render() {
|
|
50
|
-
return (h(Host, { key: '
|
|
56
|
+
return (h(Host, { key: '3abd8ab70075d8042285d8ed6fab0729c4b5ec42', class: { hidden: !this.showFab }, "aria-hidden": this.showFab ? 'false' : 'true' }, h("button", { key: '11b149d5f1d75720d4bdd329e9897da782092ed1', class: { 'z-fab': true, 'z-fab-extended': !this.isMobile }, onClick: () => this.scroll() }, h("z-icon", { key: 'fbdff1419da6d20ab594ffd11c58d7bf25fb7aa6', name: "back-top" }), h("span", { key: '0292f761b5459c372f003ed514abbd3403570c75' }, "Torna su"))));
|
|
51
57
|
}
|
|
52
58
|
};
|
|
53
59
|
ZanitBackTop.style = backToTopCss;
|
|
@@ -745,8 +751,8 @@ function buildSuggestions(query, subjectsByArea, selectedArea) {
|
|
|
745
751
|
const buildWordSuggestion = (user_query, area) => {
|
|
746
752
|
return {
|
|
747
753
|
id: buildId(`word-${user_query}-${area}`),
|
|
748
|
-
label: buildLabel(user_query, area
|
|
749
|
-
|
|
754
|
+
label: buildLabel(user_query, area),
|
|
755
|
+
aria_label: buildAriaLabel(user_query, area, false),
|
|
750
756
|
url: buildUrl({ q: user_query, ...(area ? { area } : {}), user_query }),
|
|
751
757
|
...buildDetail(user_query, user_query, area),
|
|
752
758
|
};
|
|
@@ -754,8 +760,8 @@ const buildWordSuggestion = (user_query, area) => {
|
|
|
754
760
|
const buildSubjectSuggestion = (user_query, area, subject) => {
|
|
755
761
|
return {
|
|
756
762
|
id: buildId(`subj-${user_query}-${area}-${subject}`),
|
|
757
|
-
label: buildLabel(user_query, area
|
|
758
|
-
|
|
763
|
+
label: buildLabel(user_query, area),
|
|
764
|
+
aria_label: buildAriaLabel(user_query, area, true),
|
|
759
765
|
url: buildUrl({ area, materia: subject, user_query }),
|
|
760
766
|
...buildDetail(user_query, undefined, area, subject),
|
|
761
767
|
};
|
|
@@ -773,10 +779,11 @@ const buildDetail = (user_query, query, area, subject) => ({
|
|
|
773
779
|
...(area ? { area } : {}),
|
|
774
780
|
...(subject ? { subject } : {}),
|
|
775
781
|
});
|
|
776
|
-
const buildLabel = (user_query, area
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
782
|
+
const buildLabel = (user_query, area) => {
|
|
783
|
+
return `<mark>${user_query}</mark> in <strong>${area ? `${AREA_LABELS[area] ?? area}` : `tutto il sito`}</strong>`;
|
|
784
|
+
};
|
|
785
|
+
const buildAriaLabel = (user_query, area, isSubject = false) => {
|
|
786
|
+
return `Cerca la ${isSubject ? `materia` : `parola`} ${user_query} ${area ? `nel catalogo ${AREA_LABELS[area] ?? area}` : `in tutto il sito`}`;
|
|
780
787
|
};
|
|
781
788
|
function findSubjectAreas(query, subjectsByArea) {
|
|
782
789
|
const cleanedQuery = cleanSearch(query);
|
|
@@ -791,7 +798,7 @@ const getAreaOrder = (area) => {
|
|
|
791
798
|
return index >= 0 ? index : 100;
|
|
792
799
|
};
|
|
793
800
|
|
|
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);
|
|
801
|
+
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-head{padding:calc(var(--space-unit) * 0.75) var(--space-unit);color:var(--gray700);font-size:0.875rem;font-weight:var(--font-md);line-height:1.125rem}.suggestion{display:flex;padding:calc(var(--space-unit) * 0.75) var(--space-unit);color:var(--gray900);cursor:pointer;font-size:1rem;gap:var(--space-unit);line-height:1.5rem}.suggestion:hover,.suggestion[aria-selected='true']{background:var(--gray100)}.suggestion strong{font-weight:var(--font-bd)}.suggestion mark{background-color:var(--red50)}.suggestion z-icon{--z-icon-height:1.125rem;margin-top:0.125rem}.suggestions z-divider{margin:var(--space-unit) 0}@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)}}";
|
|
795
802
|
|
|
796
803
|
const ZanitSearchForm = class {
|
|
797
804
|
constructor(hostRef) {
|
|
@@ -974,18 +981,28 @@ const ZanitSearchForm = class {
|
|
|
974
981
|
this.activeSuggestion = nextId;
|
|
975
982
|
}
|
|
976
983
|
renderSuggestions() {
|
|
984
|
+
const renderHeading = (label, key) => (h("span", { key: key, class: "suggestion-head", "aria-hidden": "true" }, label));
|
|
977
985
|
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
|
-
|
|
986
|
+
const items = [];
|
|
987
|
+
if (k === 0) {
|
|
988
|
+
items.push(renderHeading('Cerca la parola', 'word-head'));
|
|
989
|
+
}
|
|
990
|
+
else if (suggestion.subject && !this.suggestions[k - 1].subject) {
|
|
991
|
+
items.push(h("z-divider", { "aria-hidden": "true" }));
|
|
992
|
+
items.push(renderHeading('Cerca la materia', 'subj-head'));
|
|
993
|
+
}
|
|
994
|
+
items.push(h("span", { key: k, id: suggestion.id, class: "suggestion", role: "option", "aria-label": suggestion.aria_label, "aria-selected": this.activeSuggestion === suggestion.id ? 'true' : undefined, onClick: () => this.submitSuggestionSearch(suggestion) }, h("z-icon", { name: "left-magnifying-glass" }), h("span", { "aria-hidden": "true", innerHTML: suggestion.label })));
|
|
995
|
+
return items;
|
|
979
996
|
}))));
|
|
980
997
|
}
|
|
981
998
|
render() {
|
|
982
|
-
return (h(Host, { key: '
|
|
999
|
+
return (h(Host, { key: '9535c68b8cd3e76a55785cb993bed5026f84a589' }, h("form", { key: '26271b8f9034b3ea64bbea6ff413e75d0e857612', 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: '90e9dc4252a02a00db5160d374bd4ea42c4dce17', type: "hidden", name: "area", value: this.searchArea })), h("div", { key: '6189f91f8cbf9086c1dcddac5a1b649065d4319c', class: "input-wrapper", role: "none" }, this.searchQuery && (h("button", { key: '6292dc5e90576b49993ed15d908c675b501568d9', 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: '67f07f13b459afad718d2687f5feea4271d6ec6a', name: "multiply-circled" }))), h("input", { key: 'ee4f88993f3bf1ba768eaf1b6ff63cd346bd552e', 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
1000
|
// INFO: prevent ESC from clearing input
|
|
984
1001
|
if (isEscKey(e)) {
|
|
985
1002
|
e.preventDefault();
|
|
986
1003
|
}
|
|
987
1004
|
this.handleSuggestionsNav(e);
|
|
988
|
-
} })), h("button", { key: '
|
|
1005
|
+
} })), h("button", { key: '4e0feaeaff7bcecaf6a29409a6accac895810fdf', 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: '49eec7e6f04c34df57fcf99f405d1c3ada1fcdfb', name: "search" }))), this.renderSuggestions()));
|
|
989
1006
|
}
|
|
990
1007
|
static get watchers() { return {
|
|
991
1008
|
"searchQuery": ["onSearchQueryChange"],
|