@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
|
@@ -9,6 +9,7 @@ const ZanitBackTop = class {
|
|
|
9
9
|
index.registerInstance(this, hostRef);
|
|
10
10
|
}
|
|
11
11
|
resizeObserver;
|
|
12
|
+
mutationObserver;
|
|
12
13
|
get host() { return index.getElement(this); }
|
|
13
14
|
/** Indicates whether the back-to-top button is visible and usable. */
|
|
14
15
|
showFab = false;
|
|
@@ -24,14 +25,18 @@ const ZanitBackTop = class {
|
|
|
24
25
|
this.updateFabVisibility();
|
|
25
26
|
}
|
|
26
27
|
handleResize = () => {
|
|
27
|
-
const newHeight = document.
|
|
28
|
-
if (newHeight !== this.currentPageHeight)
|
|
28
|
+
const newHeight = document.body.scrollHeight;
|
|
29
|
+
if (newHeight !== this.currentPageHeight) {
|
|
29
30
|
this.currentPageHeight = newHeight;
|
|
31
|
+
this.updateFabVisibility();
|
|
32
|
+
}
|
|
30
33
|
};
|
|
31
34
|
connectedCallback() {
|
|
32
35
|
this.currentPageHeight = document.body.scrollHeight;
|
|
33
36
|
this.resizeObserver = new ResizeObserver(this.handleResize);
|
|
34
|
-
this.resizeObserver.observe(document.
|
|
37
|
+
this.resizeObserver.observe(document.body);
|
|
38
|
+
this.mutationObserver = new MutationObserver(this.handleResize);
|
|
39
|
+
this.mutationObserver.observe(document.body, { childList: true, subtree: true });
|
|
35
40
|
this.updateFabVisibility();
|
|
36
41
|
const mobileMediaQuery = window.matchMedia('(width < 768px)');
|
|
37
42
|
this.isMobile = mobileMediaQuery.matches;
|
|
@@ -41,6 +46,7 @@ const ZanitBackTop = class {
|
|
|
41
46
|
}
|
|
42
47
|
disconnectedCallback() {
|
|
43
48
|
this.resizeObserver.disconnect();
|
|
49
|
+
this.mutationObserver.disconnect();
|
|
44
50
|
}
|
|
45
51
|
updateFabVisibility() {
|
|
46
52
|
this.showFab = this.currentPageHeight > this.pageMinHeight && window.scrollY > this.scrollMinHeight;
|
|
@@ -49,7 +55,7 @@ const ZanitBackTop = class {
|
|
|
49
55
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
50
56
|
}
|
|
51
57
|
render() {
|
|
52
|
-
return (index.h(index.Host, { key: '
|
|
58
|
+
return (index.h(index.Host, { key: '3abd8ab70075d8042285d8ed6fab0729c4b5ec42', class: { hidden: !this.showFab }, "aria-hidden": this.showFab ? 'false' : 'true' }, index.h("button", { key: '11b149d5f1d75720d4bdd329e9897da782092ed1', class: { 'z-fab': true, 'z-fab-extended': !this.isMobile }, onClick: () => this.scroll() }, index.h("z-icon", { key: 'fbdff1419da6d20ab594ffd11c58d7bf25fb7aa6', name: "back-top" }), index.h("span", { key: '0292f761b5459c372f003ed514abbd3403570c75' }, "Torna su"))));
|
|
53
59
|
}
|
|
54
60
|
};
|
|
55
61
|
ZanitBackTop.style = backToTopCss;
|
|
@@ -747,8 +753,8 @@ function buildSuggestions(query, subjectsByArea, selectedArea) {
|
|
|
747
753
|
const buildWordSuggestion = (user_query, area) => {
|
|
748
754
|
return {
|
|
749
755
|
id: buildId(`word-${user_query}-${area}`),
|
|
750
|
-
label: buildLabel(user_query, area
|
|
751
|
-
|
|
756
|
+
label: buildLabel(user_query, area),
|
|
757
|
+
aria_label: buildAriaLabel(user_query, area, false),
|
|
752
758
|
url: buildUrl({ q: user_query, ...(area ? { area } : {}), user_query }),
|
|
753
759
|
...buildDetail(user_query, user_query, area),
|
|
754
760
|
};
|
|
@@ -756,8 +762,8 @@ const buildWordSuggestion = (user_query, area) => {
|
|
|
756
762
|
const buildSubjectSuggestion = (user_query, area, subject) => {
|
|
757
763
|
return {
|
|
758
764
|
id: buildId(`subj-${user_query}-${area}-${subject}`),
|
|
759
|
-
label: buildLabel(user_query, area
|
|
760
|
-
|
|
765
|
+
label: buildLabel(user_query, area),
|
|
766
|
+
aria_label: buildAriaLabel(user_query, area, true),
|
|
761
767
|
url: buildUrl({ area, materia: subject, user_query }),
|
|
762
768
|
...buildDetail(user_query, undefined, area, subject),
|
|
763
769
|
};
|
|
@@ -775,10 +781,11 @@ const buildDetail = (user_query, query, area, subject) => ({
|
|
|
775
781
|
...(area ? { area } : {}),
|
|
776
782
|
...(subject ? { subject } : {}),
|
|
777
783
|
});
|
|
778
|
-
const buildLabel = (user_query, area
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
784
|
+
const buildLabel = (user_query, area) => {
|
|
785
|
+
return `<mark>${user_query}</mark> in <strong>${area ? `${AREA_LABELS[area] ?? area}` : `tutto il sito`}</strong>`;
|
|
786
|
+
};
|
|
787
|
+
const buildAriaLabel = (user_query, area, isSubject = false) => {
|
|
788
|
+
return `Cerca la ${isSubject ? `materia` : `parola`} ${user_query} ${area ? `nel catalogo ${AREA_LABELS[area] ?? area}` : `in tutto il sito`}`;
|
|
782
789
|
};
|
|
783
790
|
function findSubjectAreas(query, subjectsByArea) {
|
|
784
791
|
const cleanedQuery = cleanSearch(query);
|
|
@@ -793,7 +800,7 @@ const getAreaOrder = (area) => {
|
|
|
793
800
|
return index >= 0 ? index : 100;
|
|
794
801
|
};
|
|
795
802
|
|
|
796
|
-
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);
|
|
803
|
+
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)}}";
|
|
797
804
|
|
|
798
805
|
const ZanitSearchForm = class {
|
|
799
806
|
constructor(hostRef) {
|
|
@@ -976,18 +983,28 @@ const ZanitSearchForm = class {
|
|
|
976
983
|
this.activeSuggestion = nextId;
|
|
977
984
|
}
|
|
978
985
|
renderSuggestions() {
|
|
986
|
+
const renderHeading = (label, key) => (index.h("span", { key: key, class: "suggestion-head", "aria-hidden": "true" }, label));
|
|
979
987
|
return (index.h("div", { class: { 'suggestions-wrapper': true, 'hidden': !this.showSuggestions || !this.suggestions.length }, onPointerOver: (e) => e.preventDefault() }, index.h("div", { id: "search-suggestions", class: "suggestions", role: "listbox", "aria-label": "Seleziona tra i suggerimenti" }, this.suggestions.map((suggestion, k) => {
|
|
980
|
-
|
|
988
|
+
const items = [];
|
|
989
|
+
if (k === 0) {
|
|
990
|
+
items.push(renderHeading('Cerca la parola', 'word-head'));
|
|
991
|
+
}
|
|
992
|
+
else if (suggestion.subject && !this.suggestions[k - 1].subject) {
|
|
993
|
+
items.push(index.h("z-divider", { "aria-hidden": "true" }));
|
|
994
|
+
items.push(renderHeading('Cerca la materia', 'subj-head'));
|
|
995
|
+
}
|
|
996
|
+
items.push(index.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) }, index.h("z-icon", { name: "left-magnifying-glass" }), index.h("span", { "aria-hidden": "true", innerHTML: suggestion.label })));
|
|
997
|
+
return items;
|
|
981
998
|
}))));
|
|
982
999
|
}
|
|
983
1000
|
render() {
|
|
984
|
-
return (index.h(index.Host, { key: '
|
|
1001
|
+
return (index.h(index.Host, { key: '9535c68b8cd3e76a55785cb993bed5026f84a589' }, index.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 && (index.h("input", { key: '90e9dc4252a02a00db5160d374bd4ea42c4dce17', type: "hidden", name: "area", value: this.searchArea })), index.h("div", { key: '6189f91f8cbf9086c1dcddac5a1b649065d4319c', class: "input-wrapper", role: "none" }, this.searchQuery && (index.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 }, index.h("z-icon", { key: '67f07f13b459afad718d2687f5feea4271d6ec6a', name: "multiply-circled" }))), index.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) => {
|
|
985
1002
|
// INFO: prevent ESC from clearing input
|
|
986
1003
|
if (isEscKey(e)) {
|
|
987
1004
|
e.preventDefault();
|
|
988
1005
|
}
|
|
989
1006
|
this.handleSuggestionsNav(e);
|
|
990
|
-
} })), index.h("button", { key: '
|
|
1007
|
+
} })), index.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 : index.h("span", { class: "searchbar-button-label" }, "Cerca"), index.h("z-icon", { key: '49eec7e6f04c34df57fcf99f405d1c3ada1fcdfb', name: "search" }))), this.renderSuggestions()));
|
|
991
1008
|
}
|
|
992
1009
|
static get watchers() { return {
|
|
993
1010
|
"searchQuery": ["onSearchQueryChange"],
|