@fluid-topics/ft-search-bar 0.2.15 → 0.2.16
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/build/ft-search-bar.d.ts +2 -0
- package/build/ft-search-bar.inline-styles.js +28 -15
- package/build/ft-search-bar.js +33 -17
- package/build/ft-search-bar.light.js +161 -148
- package/build/ft-search-bar.min.js +28 -15
- package/package.json +14 -14
|
@@ -135,7 +135,7 @@ var ht,pt;null==ct||ct(Q,et),(null!==(E=globalThis.litHtmlVersions)&&void 0!==E?
|
|
|
135
135
|
* Copyright 2020 Google LLC
|
|
136
136
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
137
137
|
*/
|
|
138
|
-
const At=Symbol.for(""),_t=t=>{var e,i;if((null===(e=t)||void 0===e?void 0:e.r)===At)return null===(i=t)||void 0===i?void 0:i._$litStatic$},Ht=t=>({_$litStatic$:t,r:At}),Zt=new Map,Kt=(t=>(e,...i)=>{const o=i.length;let s,n;const r=[],l=[];let a,c=0,h=!1;for(;c<o;){for(a=e[c];c<o&&void 0!==(n=i[c],s=_t(n));)a+=s+e[++c],h=!0;l.push(n),r.push(a),c++}if(c===o&&r.push(e[o]),h){const t=r.join("$$lit$$");void 0===(e=Zt.get(t))&&(r.raw=r,Zt.set(t,e=r)),i=l}return t(e,...i)})(W);var Wt,Vt=function(t,e,i,o){for(var s,n=arguments.length,r=n<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o,l=t.length-1;l>=0;l--)(s=t[l])&&(r=(n<3?s(r):n>3?s(e,i,r):s(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r};!function(t){t.title="title",t.title_dense="title-dense",t.subtitle1="subtitle1",t.subtitle2="subtitle2",t.body1="body1",t.body2="body2",t.caption="caption",t.breadcrumb="breadcrumb",t.overline="overline",t.button="button"}(Wt||(Wt={}));const qt=ut.extend("--ft-typography-font-family",vt.titleFont),Jt=ut.extend("--ft-typography-font-family",vt.contentFont),Xt={fontFamily:Jt,fontSize:ut.create("--ft-typography-font-size","SIZE","16px"),fontWeight:ut.create("--ft-typography-font-weight","UNKNOWN","normal"),letterSpacing:ut.create("--ft-typography-letter-spacing","SIZE","0.496px"),lineHeight:ut.create("--ft-typography-line-height","
|
|
138
|
+
const At=Symbol.for(""),_t=t=>{var e,i;if((null===(e=t)||void 0===e?void 0:e.r)===At)return null===(i=t)||void 0===i?void 0:i._$litStatic$},Ht=t=>({_$litStatic$:t,r:At}),Zt=new Map,Kt=(t=>(e,...i)=>{const o=i.length;let s,n;const r=[],l=[];let a,c=0,h=!1;for(;c<o;){for(a=e[c];c<o&&void 0!==(n=i[c],s=_t(n));)a+=s+e[++c],h=!0;l.push(n),r.push(a),c++}if(c===o&&r.push(e[o]),h){const t=r.join("$$lit$$");void 0===(e=Zt.get(t))&&(r.raw=r,Zt.set(t,e=r)),i=l}return t(e,...i)})(W);var Wt,Vt=function(t,e,i,o){for(var s,n=arguments.length,r=n<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o,l=t.length-1;l>=0;l--)(s=t[l])&&(r=(n<3?s(r):n>3?s(e,i,r):s(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r};!function(t){t.title="title",t.title_dense="title-dense",t.subtitle1="subtitle1",t.subtitle2="subtitle2",t.body1="body1",t.body2="body2",t.caption="caption",t.breadcrumb="breadcrumb",t.overline="overline",t.button="button"}(Wt||(Wt={}));const qt=ut.extend("--ft-typography-font-family",vt.titleFont),Jt=ut.extend("--ft-typography-font-family",vt.contentFont),Xt={fontFamily:Jt,fontSize:ut.create("--ft-typography-font-size","SIZE","16px"),fontWeight:ut.create("--ft-typography-font-weight","UNKNOWN","normal"),letterSpacing:ut.create("--ft-typography-letter-spacing","SIZE","0.496px"),lineHeight:ut.create("--ft-typography-line-height","NUMBER","1.5"),textTransform:ut.create("--ft-typography-text-transform","UNKNOWN","inherit")},Yt=ut.extend("--ft-typography-title-font-family",qt),Qt=ut.extend("--ft-typography-title-font-size",Xt.fontSize,"20px"),Gt=ut.extend("--ft-typography-title-font-weight",Xt.fontWeight,"normal"),te=ut.extend("--ft-typography-title-letter-spacing",Xt.letterSpacing,"0.15px"),ee=ut.extend("--ft-typography-title-line-height",Xt.lineHeight,"1.2"),ie=ut.extend("--ft-typography-title-text-transform",Xt.textTransform,"inherit"),oe=ut.extend("--ft-typography-title-dense-font-family",qt),se=ut.extend("--ft-typography-title-dense-font-size",Xt.fontSize,"14px"),ne=ut.extend("--ft-typography-title-dense-font-weight",Xt.fontWeight,"normal"),re=ut.extend("--ft-typography-title-dense-letter-spacing",Xt.letterSpacing,"0.105px"),le=ut.extend("--ft-typography-title-dense-line-height",Xt.lineHeight,"1.7"),ae=ut.extend("--ft-typography-title-dense-text-transform",Xt.textTransform,"inherit"),ce=ut.extend("--ft-typography-subtitle1-font-family",Jt),he=ut.extend("--ft-typography-subtitle1-font-size",Xt.fontSize,"16px"),pe=ut.extend("--ft-typography-subtitle1-font-weight",Xt.fontWeight,"600"),de=ut.extend("--ft-typography-subtitle1-letter-spacing",Xt.letterSpacing,"0.144px"),fe=ut.extend("--ft-typography-subtitle1-line-height",Xt.lineHeight,"1.5"),ue=ut.extend("--ft-typography-subtitle1-text-transform",Xt.textTransform,"inherit"),be=ut.extend("--ft-typography-subtitle2-font-family",Jt),ve=ut.extend("--ft-typography-subtitle2-font-size",Xt.fontSize,"14px"),ge=ut.extend("--ft-typography-subtitle2-font-weight",Xt.fontWeight,"normal"),xe=ut.extend("--ft-typography-subtitle2-letter-spacing",Xt.letterSpacing,"0.098px"),ye=ut.extend("--ft-typography-subtitle2-line-height",Xt.lineHeight,"1.7"),me=ut.extend("--ft-typography-subtitle2-text-transform",Xt.textTransform,"inherit"),$e={fontFamily:ut.extend("--ft-typography-body1-font-family",Jt),fontSize:ut.extend("--ft-typography-body1-font-size",Xt.fontSize,"16px"),fontWeight:ut.extend("--ft-typography-body1-font-weight",Xt.fontWeight,"normal"),letterSpacing:ut.extend("--ft-typography-body1-letter-spacing",Xt.letterSpacing,"0.496px"),lineHeight:ut.extend("--ft-typography-body1-line-height",Xt.lineHeight,"1.5"),textTransform:ut.extend("--ft-typography-body1-text-transform",Xt.textTransform,"inherit")},we={fontFamily:ut.extend("--ft-typography-body2-font-family",Jt),fontSize:ut.extend("--ft-typography-body2-font-size",Xt.fontSize,"14px"),fontWeight:ut.extend("--ft-typography-body2-font-weight",Xt.fontWeight,"normal"),letterSpacing:ut.extend("--ft-typography-body2-letter-spacing",Xt.letterSpacing,"0.252px"),lineHeight:ut.extend("--ft-typography-body2-line-height",Xt.lineHeight,"1.4"),textTransform:ut.extend("--ft-typography-body2-text-transform",Xt.textTransform,"inherit")},ke={fontFamily:ut.extend("--ft-typography-caption-font-family",Jt),fontSize:ut.extend("--ft-typography-caption-font-size",Xt.fontSize,"12px"),fontWeight:ut.extend("--ft-typography-caption-font-weight",Xt.fontWeight,"normal"),letterSpacing:ut.extend("--ft-typography-caption-letter-spacing",Xt.letterSpacing,"0.396px"),lineHeight:ut.extend("--ft-typography-caption-line-height",Xt.lineHeight,"1.33"),textTransform:ut.extend("--ft-typography-caption-text-transform",Xt.textTransform,"inherit")},Se=ut.extend("--ft-typography-breadcrumb-font-family",Jt),Oe=ut.extend("--ft-typography-breadcrumb-font-size",Xt.fontSize,"10px"),Ce=ut.extend("--ft-typography-breadcrumb-font-weight",Xt.fontWeight,"normal"),ze=ut.extend("--ft-typography-breadcrumb-letter-spacing",Xt.letterSpacing,"0.33px"),Ee=ut.extend("--ft-typography-breadcrumb-line-height",Xt.lineHeight,"1.6"),Be=ut.extend("--ft-typography-breadcrumb-text-transform",Xt.textTransform,"inherit"),Me=ut.extend("--ft-typography-overline-font-family",Jt),Ne=ut.extend("--ft-typography-overline-font-size",Xt.fontSize,"10px"),Re=ut.extend("--ft-typography-overline-font-weight",Xt.fontWeight,"normal"),Fe=ut.extend("--ft-typography-overline-letter-spacing",Xt.letterSpacing,"1.5px"),Le=ut.extend("--ft-typography-overline-line-height",Xt.lineHeight,"1.6"),De=ut.extend("--ft-typography-overline-text-transform",Xt.textTransform,"uppercase"),Ie={fontFamily:ut.extend("--ft-typography-button-font-family",Jt),fontSize:ut.extend("--ft-typography-button-font-size",Xt.fontSize,"14px"),fontWeight:ut.extend("--ft-typography-button-font-weight",Xt.fontWeight,"600"),letterSpacing:ut.extend("--ft-typography-button-letter-spacing",Xt.letterSpacing,"1.246px"),lineHeight:ut.extend("--ft-typography-button-line-height",Xt.lineHeight,"1.15"),textTransform:ut.extend("--ft-typography-button-text-transform",Xt.textTransform,"uppercase")},je=g`
|
|
139
139
|
.ft-typography--title {
|
|
140
140
|
font-family: ${Yt};
|
|
141
141
|
font-size: ${Qt};
|
|
@@ -478,8 +478,10 @@ class gi extends zt{constructor(t){if(super(t),this.it=q,t.type!==Ot)throw Error
|
|
|
478
478
|
<slot @slotchange=${()=>this.requestUpdate()} ?hidden=${"material"!==this.variant}></slot>
|
|
479
479
|
</i>
|
|
480
480
|
`}get textContent(){var t,e;return null!==(e=null===(t=this.slottedContent)||void 0===t?void 0:t.assignedNodes().map((t=>t.textContent)).join("").trim())&&void 0!==e?e:""}getIcon(){var t,e;let i=this.textContent;return this.variant===ki.file_format?null!==(t=mi[i.toUpperCase()])&&void 0!==t?t:i:this.variant===ki.fluid_topics?null!==(e=yi[i.toUpperCase()])&&void 0!==e?e:i:q}}Ci.elementDefinitions={},Ci.styles=g`
|
|
481
|
-
:host
|
|
481
|
+
:host {
|
|
482
482
|
display: inline-block;
|
|
483
|
+
}
|
|
484
|
+
:host, i.ft-icon {
|
|
483
485
|
width: ${Oi.size};
|
|
484
486
|
height: ${Oi.size};
|
|
485
487
|
text-align: center;
|
|
@@ -549,6 +551,7 @@ class gi extends zt{constructor(t){if(super(t),this.it=q,t.type!==Ot)throw Error
|
|
|
549
551
|
box-sizing: border-box;
|
|
550
552
|
border: none;
|
|
551
553
|
pointer-events: auto;
|
|
554
|
+
line-height: 0;
|
|
552
555
|
|
|
553
556
|
--ft-button-internal-font-size: ${Bi.fontSize};
|
|
554
557
|
--ft-button-internal-line-height: calc(var(--ft-button-internal-font-size) + 2px);
|
|
@@ -2294,7 +2297,8 @@ class gi extends zt{constructor(t){if(super(t),this.it=q,t.type!==Ot)throw Error
|
|
|
2294
2297
|
${this.labelResolver.resolve("searchButton")}
|
|
2295
2298
|
</ft-button>
|
|
2296
2299
|
`:q}
|
|
2297
|
-
`}renderMobileSearchBarButtons(){
|
|
2300
|
+
`}renderMobileSearchBarButtons(){const t=this.query||this.isMobileMenuOpen&&!this.forceMobileMenuOpen;return W`
|
|
2301
|
+
${t?W`
|
|
2298
2302
|
<div class="ft-search-bar--actions"
|
|
2299
2303
|
part="search-bar-actions">
|
|
2300
2304
|
<ft-button class="ft-search-bar--clear-query"
|
|
@@ -2302,10 +2306,11 @@ class gi extends zt{constructor(t){if(super(t),this.it=q,t.type!==Ot)throw Error
|
|
|
2302
2306
|
icon="close"
|
|
2303
2307
|
round
|
|
2304
2308
|
label="${this.labelResolver.resolve("clearInputButton")}"
|
|
2309
|
+
tooltipPosition="left"
|
|
2305
2310
|
@click=${()=>{this.setQuery(""),this.mobileMenuOpen=!1,this.displayFacets=!1}}
|
|
2306
2311
|
></ft-button>
|
|
2307
2312
|
</div>
|
|
2308
|
-
`:
|
|
2313
|
+
`:q}
|
|
2309
2314
|
<div class="ft-search-bar--actions"
|
|
2310
2315
|
part="search-bar-actions">
|
|
2311
2316
|
<ft-button class="ft-search-bar--launch-search"
|
|
@@ -2313,7 +2318,8 @@ class gi extends zt{constructor(t){if(super(t),this.it=q,t.type!==Ot)throw Error
|
|
|
2313
2318
|
icon="search"
|
|
2314
2319
|
round
|
|
2315
2320
|
label="${this.labelResolver.resolve("searchButton")}"
|
|
2316
|
-
|
|
2321
|
+
tooltipPosition="left"
|
|
2322
|
+
@click=${()=>{var t;return this.isMobileMenuOpen?this.launchSearch():null===(t=this.input)||void 0===t?void 0:t.focus()}}
|
|
2317
2323
|
></ft-button>
|
|
2318
2324
|
</div>
|
|
2319
2325
|
`}renderMobileFacets(){var t;const e=this.availableContentLocales.filter((t=>t.lang===this.contentLocale)).pop();return W`
|
|
@@ -2328,7 +2334,8 @@ class gi extends zt{constructor(t){if(super(t),this.it=q,t.type!==Ot)throw Error
|
|
|
2328
2334
|
</ft-typography>
|
|
2329
2335
|
</div>
|
|
2330
2336
|
<ft-filter
|
|
2331
|
-
part="filters"
|
|
2337
|
+
part="filters filter-ft-locale"
|
|
2338
|
+
exportparts=${this.getFilterExportParts("ft-locale")}
|
|
2332
2339
|
class="ft-search-bar--content-locale"
|
|
2333
2340
|
filterPlaceHolder="${this.labelResolver.resolve("filterInputPlaceHolder",this.labelResolver.resolve("contentLocaleSelector"))}"
|
|
2334
2341
|
.options=${this.contentLocalesAsFilterOptions()}
|
|
@@ -2336,7 +2343,7 @@ class gi extends zt{constructor(t){if(super(t),this.it=q,t.type!==Ot)throw Error
|
|
|
2336
2343
|
></ft-filter>
|
|
2337
2344
|
</ft-accordion-item>
|
|
2338
2345
|
`:null}
|
|
2339
|
-
${Dt(this.facets,(t=>t.key),(t=>{const e=Ye(t);return W`
|
|
2346
|
+
${Dt(this.facets,(t=>t.key),(t=>{const e=Ye(t),i=t.key.replace(":","-");return W`
|
|
2340
2347
|
<ft-accordion-item data-facet-key="${t.key}">
|
|
2341
2348
|
<div class="ft-search-bar--filter-label" slot="toggle">
|
|
2342
2349
|
<ft-typography variant="button">${t.label}</ft-typography>
|
|
@@ -2345,7 +2352,8 @@ class gi extends zt{constructor(t){if(super(t),this.it=q,t.type!==Ot)throw Error
|
|
|
2345
2352
|
</ft-typography>
|
|
2346
2353
|
</div>
|
|
2347
2354
|
<ft-filter
|
|
2348
|
-
part="filters"
|
|
2355
|
+
part="filters filter-${i}"
|
|
2356
|
+
exportparts=${this.getFilterExportParts(i)}
|
|
2349
2357
|
id="${e.id}"
|
|
2350
2358
|
filterPlaceHolder="${this.labelResolver.resolve("filterInputPlaceHolder",e.label)}"
|
|
2351
2359
|
clearButtonLabel="${this.labelResolver.resolve("clearFilterButton")}"
|
|
@@ -2460,20 +2468,23 @@ class gi extends zt{constructor(t){if(super(t),this.it=q,t.type!==Ot)throw Error
|
|
|
2460
2468
|
`}renderDesktopFacets(){return this.hasFacets?W`
|
|
2461
2469
|
<ft-snap-scroll horizontal limitSize controls
|
|
2462
2470
|
class="ft-search-bar--filters-container"
|
|
2463
|
-
part="filters-container"
|
|
2471
|
+
part="filters-container"
|
|
2472
|
+
exportparts="controls:snap-scroll-controls">
|
|
2464
2473
|
${this.hasLocaleSelector?W`
|
|
2465
|
-
<ft-filter
|
|
2466
|
-
|
|
2474
|
+
<ft-filter class="ft-search-bar--content-locale"
|
|
2475
|
+
part="filters filter-ft-locale"
|
|
2476
|
+
exportparts=${this.getFilterExportParts("ft-locale")}
|
|
2467
2477
|
label="${this.labelResolver.resolve("contentLocaleSelector")}"
|
|
2468
2478
|
filterPlaceHolder="${this.labelResolver.resolve("filterInputPlaceHolder",this.labelResolver.resolve("contentLocaleSelector"))}"
|
|
2469
2479
|
.options=${this.contentLocalesAsFilterOptions()}
|
|
2470
2480
|
@change=${t=>this.contentLocale=t.detail[0]}
|
|
2471
2481
|
></ft-filter>
|
|
2472
2482
|
`:q}
|
|
2473
|
-
${Dt(this.facets,(t=>t.key),(t=>{const e=Ye(t),i=e.options.some((t=>{var e,i;return(null!==(i=null===(e=t.subOptions)||void 0===e?void 0:e.length)&&void 0!==i?i:0)>0}));return W`
|
|
2483
|
+
${Dt(this.facets,(t=>t.key),(t=>{const e=Ye(t),i=e.options.some((t=>{var e,i;return(null!==(i=null===(e=t.subOptions)||void 0===e?void 0:e.length)&&void 0!==i?i:0)>0})),o=t.key.replace(":","-");return W`
|
|
2474
2484
|
<ft-filter
|
|
2475
2485
|
class="${i?"ft-search-bar--hierarchical-filter":""}"
|
|
2476
|
-
part="filters"
|
|
2486
|
+
part="filters filter-${o}"
|
|
2487
|
+
exportparts=${this.getFilterExportParts(o)}
|
|
2477
2488
|
id="${e.id}"
|
|
2478
2489
|
label="${e.label}"
|
|
2479
2490
|
filterPlaceHolder="${this.labelResolver.resolve("filterInputPlaceHolder",e.label)}"
|
|
@@ -2525,7 +2536,8 @@ class gi extends zt{constructor(t){if(super(t),this.it=q,t.type!==Ot)throw Error
|
|
|
2525
2536
|
`;return t?W`
|
|
2526
2537
|
<ft-snap-scroll horizontal controls hideScrollbar limitSize
|
|
2527
2538
|
class="ft-search-bar--selected-filters"
|
|
2528
|
-
part="selected-filters-container"
|
|
2539
|
+
part="selected-filters-container"
|
|
2540
|
+
exportparts="controls:snap-scroll-controls">
|
|
2529
2541
|
${e}
|
|
2530
2542
|
</ft-snap-scroll>
|
|
2531
2543
|
`:W`
|
|
@@ -2549,6 +2561,7 @@ class gi extends zt{constructor(t){if(super(t),this.it=q,t.type!==Ot)throw Error
|
|
|
2549
2561
|
part="remove-suggestion"
|
|
2550
2562
|
?dense=${!this.isMobile}
|
|
2551
2563
|
label="${this.labelResolver.resolve("removeRecentSearch")}"
|
|
2564
|
+
tooltipPosition="left"
|
|
2552
2565
|
@click=${e=>this.removeRecentSearch(e,t)}></ft-button>
|
|
2553
2566
|
</a>
|
|
2554
2567
|
`))}
|
|
@@ -2574,4 +2587,4 @@ class gi extends zt{constructor(t){if(super(t),this.it=q,t.type!==Ot)throw Error
|
|
|
2574
2587
|
<ft-icon variant="${e}" part="suggestion-icon">
|
|
2575
2588
|
${i}
|
|
2576
2589
|
</ft-icon>
|
|
2577
|
-
`}openMobileFilters(t){this.isMobile&&(this.mobileMenuOpen=!0,this.displayFacets=!0,this.scrollToFacet=t)}async firstUpdated(t){super.firstUpdated(t),this.initApi()}update(t){var e,i,o,s,n,r;if(t.has("labels")&&(this.labelResolver=new yt(Vo,this.labels)),t.has("sizeCategory")&&(this.mobileMenuOpen=!1,this.displayFacets=this.displayFacets&&!this.isMobile),super.update(t),(t.has("availableContentLocales")||t.has("contentLocale"))&&this.availableContentLocales.length>0){const i=t=>this.availableContentLocales.some((e=>e.lang===t));i(this.contentLocale)||(this.contentLocale=t.has("contentLocale")&&i(t.get("contentLocale"))?t.get("contentLocale"):null===(e=this.availableContentLocales[0])||void 0===e?void 0:e.lang)}if(t.has("baseUrl")&&this.baseUrl&&(this.baseUrl.endsWith("/")&&(this.baseUrl=this.baseUrl.replace(/\/$/,"")),this.recentSearches=JSON.parse(null!==(i=window.localStorage.getItem(this.recentSearchesStorageKey))&&void 0!==i?i:"[]")),t.has("presets")&&(null!==(o=this.presets)&&void 0!==o?o:[]).forEach((t=>t.filters.forEach((t=>t.values=t.values.map((t=>Je(t))))))),t.has("selectedPreset")){const t=(null!==(s=this.presets)&&void 0!==s?s:[]).find((t=>t.name===this.selectedPreset));t&&!this.compareRequests(this.request,t)&&this.setFiltersFromPreset(t)}["contentLocale","searchFilters"].some((e=>t.has(e)))&&(this.selectedPreset=null===(r=(null!==(n=this.presets)&&void 0!==n?n:[]).find((t=>this.compareRequests(t,this.request))))||void 0===r?void 0:r.name),["baseUrl","apiIntegrationIdentifier"].some((e=>t.has(e)))&&(this.api=void 0,this.initApi(),this.availableContentLocalesInitialized=!1,this.facetsInitialized=!1),t.has("api")&&this.updateAvailableContentLocales(),["uiLocale","contentLocale","searchFilters","displayedFilters","api"].some((e=>t.has(e)))&&this.updateFacets(),["query","uiLocale","contentLocale","searchFilters","displayedFilters","api"].some((e=>t.has(e)))&&this.updateSuggestions(),["query","uiLocale","contentLocale","searchFilters"].some((e=>t.has(e)))&&this.dispatchEvent(new Jo(this.request))}async updateAvailableContentLocales(){this.api&&(this.availableContentLocales=await this.api.getAvailableSearchLocales().then((t=>t.contentLocales)).catch((()=>[])),this.availableContentLocalesInitialized=!0)}contentAvailableCallback(t){var e,i,o;if(super.contentAvailableCallback(t),t.has("displayFacets")&&this.displayFacets&&(null===(e=this.floatingContainer)||void 0===e||e.focus()),null!=this.scrollToFacet&&this.facetsLoaded){null===(i=this.scrollingFiltersContainer)||void 0===i||i.scrollIndexIntoView(this.facets.findIndex((t=>t.key===this.scrollToFacet)));const t=null===(o=this.shadowRoot)||void 0===o?void 0:o.querySelector(`ft-accordion-item[data-facet-key="${this.scrollToFacet}"]`);t&&(t.active=!0),this.scrollToFacet=void 0}}initApi(){null==this.api&&(this.api=window.fluidtopics?new window.fluidtopics.FluidTopicsApi(this.baseUrl,this.apiIntegrationIdentifier,!0):void 0,setTimeout((()=>this.initApi()),100))}updateFacets(){this.api&&(this.facetsRequest.length>0?(this.facetsLoaded=!1,this.updateFacetsDebouncer.run((async()=>{var t,e;this.facets=null!==(e=await(null===(t=this.api)||void 0===t?void 0:t.search({...this.request,query:""}).then((t=>t.facets)).catch((()=>[]))))&&void 0!==e?e:[],this.facets.forEach((t=>this.knownFacetLabels[t.key]=t.label)),this.facetsLoaded=!0,this.facetsInitialized=!0}))):(this.facets=[],this.facetsInitialized=!0))}updateSuggestions(){this.suggestionsLoaded=!1,this.suggestDebouncer.run((async()=>{this.suggestions=this.api&&this.query.length>2?await this.api.getSuggestions(this.suggestRequest).then((t=>t.suggestions)).catch((()=>[])):[],this.suggestionsLoaded=!0}))}onSearchBarKeyUp(t){const e=t.composedPath()[0];this.query=e.value,"Enter"===t.key&&this.launchSearch()}onSearchBarKeyDown(t){var e,i;switch(t.key){case"Escape":this.mobileMenuOpen=!1,null===(e=this.input)||void 0===e||e.blur();break;case"ArrowDown":t.stopPropagation(),t.preventDefault(),null===(i=this.firstSuggestion)||void 0===i||i.focus()}}onFloatingContainerKeyUp(t){var e;"Escape"===t.key&&(this.displayFacets=!1,null===(e=this.filtersOpener)||void 0===e||e.focus())}setQuery(t){this.input&&(this.input.value=t),this.query=t}onSuggestClick(t,e){t.ctrlKey||t.metaKey||this.onSuggestSelected(t,e)}onSuggestKeyUp(t,e){"Enter"!==t.key&&" "!==t.key||this.onSuggestSelected(t,e)}onSuggestSelected(t,e){t.preventDefault(),this.setQuery(e),this.launchSearch()}launchSearch(){if(this.query){let t=this.recentSearches.filter((t=>t.toLowerCase()!==this.query.toLowerCase())).filter(((t,e)=>e<20));this.recentSearches=[this.query,...t],this.saveRecentSearches()}this.dispatchEvent(new qo(this.request)),this.mobileMenuOpen=!1,this.displayFacets=!1,this.focus()}saveRecentSearches(){window.localStorage.setItem(this.recentSearchesStorageKey,JSON.stringify(this.recentSearches))}connectedCallback(){super.connectedCallback(),document.addEventListener("focusin",this.closeFloatingContainer),document.addEventListener("click",this.closeFloatingContainer)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("focusin",this.closeFloatingContainer),document.addEventListener("click",this.closeFloatingContainer)}updateSize(t){this.sizeCategory=t.detail.category}getLocaleLabel(t){var e;return null!==(e=this.availableContentLocales.filter((e=>{var i;return(null!==(i=e.lang)&&void 0!==i?i:"").toLowerCase()===(null!=t?t:"").toLowerCase()})).map((t=>t.label)).pop())&&void 0!==e?e:t}setFilter(t,e){let i=this.searchFilters.filter((e=>e.key!==t));this.facets.forEach((i=>{i.key===t&&qe(i.rootNodes,(t=>t.childNodes)).forEach((t=>t.selected=e.includes(t.value)))})),e.length&&i.push({key:t,negative:!1,values:e}),this.searchFilters=i,this.scrollToFacet=t}setFiltersFromPreset(t){null!=t&&(null!=t.contentLocale&&(this.contentLocale=t.contentLocale),this.searchFilters=t.filters)}clearFilters(){this.facets.forEach((t=>qe(t.rootNodes,(t=>t.childNodes)).forEach((t=>t.selected=!1)))),this.searchFilters=[];const t=this.facets[0];this.scrollToFacet=null==t?void 0:t.key}removeRecentSearch(t,e){var i,o,s,n;t.preventDefault(),t.stopPropagation();const r=null!==(n=null!==(o=null===(i=this.focusedSuggestion)||void 0===i?void 0:i.previousElementSibling)&&void 0!==o?o:null===(s=this.focusedSuggestion)||void 0===s?void 0:s.nextElementSibling)&&void 0!==n?n:this.input;null==r||r.focus(),this.recentSearches=this.recentSearches.filter((t=>t.toLowerCase()!==e.toLowerCase())),this.saveRecentSearches()}onSuggestKeyDown(t){var e,i,o,s,n,r;switch(t.key){case"ArrowUp":null===(o=null!==(i=null===(e=this.focusedSuggestion)||void 0===e?void 0:e.previousElementSibling)&&void 0!==i?i:this.lastSuggestion)||void 0===o||o.focus(),t.preventDefault(),t.stopPropagation();break;case"ArrowDown":null===(r=null!==(n=null===(s=this.focusedSuggestion)||void 0===s?void 0:s.nextElementSibling)&&void 0!==n?n:this.firstSuggestion)||void 0===r||r.focus(),t.preventDefault(),t.stopPropagation()}}}Xo.elementDefinitions={"ft-accordion":go,"ft-accordion-item":wo,"ft-button":Fi,"ft-chip":No,"ft-filter":fo,"ft-filter-option":bo,"ft-icon":Ci,"ft-ripple":li,"ft-select":Uo,"ft-select-option":Io,"ft-size-watcher":Tt,"ft-skeleton":To,"ft-snap-scroll":io,"ft-tooltip":ui,"ft-typography":Ve},Xo.styles=[_e,_o,Ho,Zo,Ko],Wo([o({type:Boolean})],Xo.prototype,"dense",void 0),Wo([o()],Xo.prototype,"mode",void 0),Wo([o({type:Boolean})],Xo.prototype,"forceMobileMenuOpen",void 0),Wo([o()],Xo.prototype,"baseUrl",void 0),Wo([o()],Xo.prototype,"apiIntegrationIdentifier",void 0),Wo([o()],Xo.prototype,"contentLocale",void 0),Wo([s()],Xo.prototype,"availableContentLocales",void 0),Wo([s()],Xo.prototype,"availableContentLocalesInitialized",void 0),Wo([o()],Xo.prototype,"uiLocale",void 0),Wo([p({})],Xo.prototype,"labels",void 0),Wo([p([])],Xo.prototype,"displayedFilters",void 0),Wo([p([])],Xo.prototype,"presets",void 0),Wo([o({type:String,reflect:!0})],Xo.prototype,"selectedPreset",void 0),Wo([p([])],Xo.prototype,"priors",void 0),Wo([o()],Xo.prototype,"searchRequestSerializer",void 0),Wo([s()],Xo.prototype,"searchFilters",void 0),Wo([s()],Xo.prototype,"sizeCategory",void 0),Wo([s()],Xo.prototype,"displayFacets",void 0),Wo([s()],Xo.prototype,"mobileMenuOpen",void 0),Wo([s()],Xo.prototype,"facets",void 0),Wo([s()],Xo.prototype,"facetsInitialized",void 0),Wo([r(".ft-search-bar--container")],Xo.prototype,"container",void 0),Wo([r(".ft-search-bar--filters-opener")],Xo.prototype,"filtersOpener",void 0),Wo([r(".ft-search-bar--floating-panel")],Xo.prototype,"floatingContainer",void 0),Wo([r("ft-snap-scroll.ft-search-bar--filters-container")],Xo.prototype,"scrollingFiltersContainer",void 0),Wo([r(".ft-search-bar--input")],Xo.prototype,"input",void 0),Wo([s()],Xo.prototype,"query",void 0),Wo([s()],Xo.prototype,"suggestions",void 0),Wo([s()],Xo.prototype,"suggestionsLoaded",void 0),Wo([s()],Xo.prototype,"recentSearches",void 0),Wo([s()],Xo.prototype,"scrollToFacet",void 0),Wo([r(".ft-search-bar--suggestion:first-child")],Xo.prototype,"firstSuggestion",void 0),Wo([r(".ft-search-bar--suggestion:focus-within")],Xo.prototype,"focusedSuggestion",void 0),Wo([r(".ft-search-bar--suggestion:last-child")],Xo.prototype,"lastSuggestion",void 0),Wo([s()],Xo.prototype,"api",void 0),h("ft-search-bar")(Xo),t.DEFAULT_LABELS=Vo,t.FtSearchBar=Xo,t.FtSearchBarCssVariables=Ao,t.LaunchSearchEvent=qo,t.SearchStateChangeEvent=Jo,Object.defineProperty(t,"t",{value:!0})}({});
|
|
2590
|
+
`}openMobileFilters(t){this.isMobile&&(this.mobileMenuOpen=!0,this.displayFacets=!0,this.scrollToFacet=t)}async firstUpdated(t){super.firstUpdated(t),this.initApi()}update(t){var e,i,o,s,n,r;if(t.has("labels")&&(this.labelResolver=new yt(Vo,this.labels)),t.has("sizeCategory")&&(this.mobileMenuOpen=!1,this.displayFacets=this.displayFacets&&!this.isMobile),super.update(t),(t.has("availableContentLocales")||t.has("contentLocale"))&&this.availableContentLocales.length>0){const i=t=>this.availableContentLocales.some((e=>e.lang===t));i(this.contentLocale)||(this.contentLocale=t.has("contentLocale")&&i(t.get("contentLocale"))?t.get("contentLocale"):null===(e=this.availableContentLocales[0])||void 0===e?void 0:e.lang)}if(t.has("baseUrl")&&this.baseUrl&&(this.baseUrl.endsWith("/")&&(this.baseUrl=this.baseUrl.replace(/\/$/,"")),this.recentSearches=JSON.parse(null!==(i=window.localStorage.getItem(this.recentSearchesStorageKey))&&void 0!==i?i:"[]")),t.has("presets")&&(null!==(o=this.presets)&&void 0!==o?o:[]).forEach((t=>t.filters.forEach((t=>t.values=t.values.map((t=>Je(t))))))),t.has("selectedPreset")){const t=(null!==(s=this.presets)&&void 0!==s?s:[]).find((t=>t.name===this.selectedPreset));t&&!this.compareRequests(this.request,t)&&this.setFiltersFromPreset(t)}["contentLocale","searchFilters"].some((e=>t.has(e)))&&(this.selectedPreset=null===(r=(null!==(n=this.presets)&&void 0!==n?n:[]).find((t=>this.compareRequests(t,this.request))))||void 0===r?void 0:r.name),["baseUrl","apiIntegrationIdentifier"].some((e=>t.has(e)))&&(this.api=void 0,this.initApi(),this.availableContentLocalesInitialized=!1,this.facetsInitialized=!1),t.has("api")&&this.updateAvailableContentLocales(),["uiLocale","contentLocale","searchFilters","displayedFilters","api"].some((e=>t.has(e)))&&this.updateFacets(),["query","uiLocale","contentLocale","searchFilters","displayedFilters","api"].some((e=>t.has(e)))&&this.updateSuggestions(),["query","uiLocale","contentLocale","searchFilters"].some((e=>t.has(e)))&&this.dispatchEvent(new Jo(this.request))}async updateAvailableContentLocales(){this.api&&(this.availableContentLocales=await this.api.getAvailableSearchLocales().then((t=>t.contentLocales)).catch((()=>[])),this.availableContentLocalesInitialized=!0)}contentAvailableCallback(t){var e,i,o;if(super.contentAvailableCallback(t),t.has("displayFacets")&&this.displayFacets&&(null===(e=this.floatingContainer)||void 0===e||e.focus()),null!=this.scrollToFacet&&this.facetsLoaded){null===(i=this.scrollingFiltersContainer)||void 0===i||i.scrollIndexIntoView(this.facets.findIndex((t=>t.key===this.scrollToFacet)));const t=null===(o=this.shadowRoot)||void 0===o?void 0:o.querySelector(`ft-accordion-item[data-facet-key="${this.scrollToFacet}"]`);t&&(t.active=!0),this.scrollToFacet=void 0}}initApi(){null==this.api&&(this.api=window.fluidtopics?new window.fluidtopics.FluidTopicsApi(this.baseUrl,this.apiIntegrationIdentifier,!0):void 0,setTimeout((()=>this.initApi()),100))}updateFacets(){this.api&&(this.facetsRequest.length>0?(this.facetsLoaded=!1,this.updateFacetsDebouncer.run((async()=>{var t,e;this.facets=null!==(e=await(null===(t=this.api)||void 0===t?void 0:t.search({...this.request,query:""}).then((t=>t.facets)).catch((()=>[]))))&&void 0!==e?e:[],this.facets.forEach((t=>this.knownFacetLabels[t.key]=t.label)),this.facetsLoaded=!0,this.facetsInitialized=!0}))):(this.facets=[],this.facetsInitialized=!0))}updateSuggestions(){this.suggestionsLoaded=!1,this.suggestDebouncer.run((async()=>{this.suggestions=this.api&&this.query.length>2?await this.api.getSuggestions(this.suggestRequest).then((t=>t.suggestions)).catch((()=>[])):[],this.suggestionsLoaded=!0}))}onSearchBarKeyUp(t){const e=t.composedPath()[0];this.query=e.value,"Enter"===t.key&&this.launchSearch()}onSearchBarKeyDown(t){var e,i;switch(t.key){case"Escape":this.mobileMenuOpen=!1,null===(e=this.input)||void 0===e||e.blur();break;case"ArrowDown":t.stopPropagation(),t.preventDefault(),null===(i=this.firstSuggestion)||void 0===i||i.focus()}}onFloatingContainerKeyUp(t){var e;"Escape"===t.key&&(this.displayFacets=!1,null===(e=this.filtersOpener)||void 0===e||e.focus())}setQuery(t){this.input&&(this.input.value=t),this.query=t}onSuggestClick(t,e){t.ctrlKey||t.metaKey||this.onSuggestSelected(t,e)}onSuggestKeyUp(t,e){"Enter"!==t.key&&" "!==t.key||this.onSuggestSelected(t,e)}onSuggestSelected(t,e){t.preventDefault(),this.setQuery(e),this.launchSearch()}launchSearch(){if(this.query){let t=this.recentSearches.filter((t=>t.toLowerCase()!==this.query.toLowerCase())).filter(((t,e)=>e<20));this.recentSearches=[this.query,...t],this.saveRecentSearches()}this.dispatchEvent(new qo(this.request)),this.mobileMenuOpen=!1,this.displayFacets=!1,this.focus()}saveRecentSearches(){window.localStorage.setItem(this.recentSearchesStorageKey,JSON.stringify(this.recentSearches))}connectedCallback(){super.connectedCallback(),document.addEventListener("focusin",this.closeFloatingContainer),document.addEventListener("click",this.closeFloatingContainer)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("focusin",this.closeFloatingContainer),document.addEventListener("click",this.closeFloatingContainer)}updateSize(t){this.sizeCategory=t.detail.category}getLocaleLabel(t){var e;return null!==(e=this.availableContentLocales.filter((e=>{var i;return(null!==(i=e.lang)&&void 0!==i?i:"").toLowerCase()===(null!=t?t:"").toLowerCase()})).map((t=>t.label)).pop())&&void 0!==e?e:t}setFilter(t,e){let i=this.searchFilters.filter((e=>e.key!==t));this.facets.forEach((i=>{i.key===t&&qe(i.rootNodes,(t=>t.childNodes)).forEach((t=>t.selected=e.includes(t.value)))})),e.length&&i.push({key:t,negative:!1,values:e}),this.searchFilters=i,this.scrollToFacet=t}setFiltersFromPreset(t){null!=t&&(null!=t.contentLocale&&(this.contentLocale=t.contentLocale),this.searchFilters=t.filters)}clearFilters(){this.facets.forEach((t=>qe(t.rootNodes,(t=>t.childNodes)).forEach((t=>t.selected=!1)))),this.searchFilters=[];const t=this.facets[0];this.scrollToFacet=null==t?void 0:t.key}removeRecentSearch(t,e){var i,o,s,n;t.preventDefault(),t.stopPropagation();const r=null!==(n=null!==(o=null===(i=this.focusedSuggestion)||void 0===i?void 0:i.previousElementSibling)&&void 0!==o?o:null===(s=this.focusedSuggestion)||void 0===s?void 0:s.nextElementSibling)&&void 0!==n?n:this.input;null==r||r.focus(),this.recentSearches=this.recentSearches.filter((t=>t.toLowerCase()!==e.toLowerCase())),this.saveRecentSearches()}onSuggestKeyDown(t){var e,i,o,s,n,r;switch(t.key){case"ArrowUp":null===(o=null!==(i=null===(e=this.focusedSuggestion)||void 0===e?void 0:e.previousElementSibling)&&void 0!==i?i:this.lastSuggestion)||void 0===o||o.focus(),t.preventDefault(),t.stopPropagation();break;case"ArrowDown":null===(r=null!==(n=null===(s=this.focusedSuggestion)||void 0===s?void 0:s.nextElementSibling)&&void 0!==n?n:this.firstSuggestion)||void 0===r||r.focus(),t.preventDefault(),t.stopPropagation()}}getFilterExportParts(t){return["container","header","clear-button","input"].map((e=>this.getFilterSubPartExportAttribute(e,t))).join(",")}getFilterSubPartExportAttribute(t,e){return`${t}:filters-${t},${t}:filter-${e}-${t}`}}Xo.elementDefinitions={"ft-accordion":go,"ft-accordion-item":wo,"ft-button":Fi,"ft-chip":No,"ft-filter":fo,"ft-filter-option":bo,"ft-icon":Ci,"ft-ripple":li,"ft-select":Uo,"ft-select-option":Io,"ft-size-watcher":Tt,"ft-skeleton":To,"ft-snap-scroll":io,"ft-tooltip":ui,"ft-typography":Ve},Xo.styles=[_e,_o,Ho,Zo,Ko],Wo([o({type:Boolean})],Xo.prototype,"dense",void 0),Wo([o()],Xo.prototype,"mode",void 0),Wo([o({type:Boolean})],Xo.prototype,"forceMobileMenuOpen",void 0),Wo([o()],Xo.prototype,"baseUrl",void 0),Wo([o()],Xo.prototype,"apiIntegrationIdentifier",void 0),Wo([o()],Xo.prototype,"contentLocale",void 0),Wo([s()],Xo.prototype,"availableContentLocales",void 0),Wo([s()],Xo.prototype,"availableContentLocalesInitialized",void 0),Wo([o()],Xo.prototype,"uiLocale",void 0),Wo([p({})],Xo.prototype,"labels",void 0),Wo([p([])],Xo.prototype,"displayedFilters",void 0),Wo([p([])],Xo.prototype,"presets",void 0),Wo([o({type:String,reflect:!0})],Xo.prototype,"selectedPreset",void 0),Wo([p([])],Xo.prototype,"priors",void 0),Wo([o()],Xo.prototype,"searchRequestSerializer",void 0),Wo([s()],Xo.prototype,"searchFilters",void 0),Wo([s()],Xo.prototype,"sizeCategory",void 0),Wo([s()],Xo.prototype,"displayFacets",void 0),Wo([s()],Xo.prototype,"mobileMenuOpen",void 0),Wo([s()],Xo.prototype,"facets",void 0),Wo([s()],Xo.prototype,"facetsInitialized",void 0),Wo([r(".ft-search-bar--container")],Xo.prototype,"container",void 0),Wo([r(".ft-search-bar--filters-opener")],Xo.prototype,"filtersOpener",void 0),Wo([r(".ft-search-bar--floating-panel")],Xo.prototype,"floatingContainer",void 0),Wo([r("ft-snap-scroll.ft-search-bar--filters-container")],Xo.prototype,"scrollingFiltersContainer",void 0),Wo([r(".ft-search-bar--input")],Xo.prototype,"input",void 0),Wo([s()],Xo.prototype,"query",void 0),Wo([s()],Xo.prototype,"suggestions",void 0),Wo([s()],Xo.prototype,"suggestionsLoaded",void 0),Wo([s()],Xo.prototype,"recentSearches",void 0),Wo([s()],Xo.prototype,"scrollToFacet",void 0),Wo([r(".ft-search-bar--suggestion:first-child")],Xo.prototype,"firstSuggestion",void 0),Wo([r(".ft-search-bar--suggestion:focus-within")],Xo.prototype,"focusedSuggestion",void 0),Wo([r(".ft-search-bar--suggestion:last-child")],Xo.prototype,"lastSuggestion",void 0),Wo([s()],Xo.prototype,"api",void 0),h("ft-search-bar")(Xo),t.DEFAULT_LABELS=Vo,t.FtSearchBar=Xo,t.FtSearchBarCssVariables=Ao,t.LaunchSearchEvent=qo,t.SearchStateChangeEvent=Jo,Object.defineProperty(t,"t",{value:!0})}({});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-search-bar",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"description": "Search bar component using Fluid Topics public API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-accordion": "^0.2.
|
|
23
|
-
"@fluid-topics/ft-button": "^0.2.
|
|
24
|
-
"@fluid-topics/ft-chip": "^0.2.
|
|
25
|
-
"@fluid-topics/ft-filter": "^0.2.
|
|
26
|
-
"@fluid-topics/ft-icon": "^0.2.
|
|
27
|
-
"@fluid-topics/ft-select": "^0.2.
|
|
28
|
-
"@fluid-topics/ft-size-watcher": "^0.2.
|
|
29
|
-
"@fluid-topics/ft-skeleton": "^0.2.
|
|
30
|
-
"@fluid-topics/ft-snap-scroll": "^0.2.
|
|
31
|
-
"@fluid-topics/ft-tooltip": "^0.2.
|
|
32
|
-
"@fluid-topics/ft-typography": "^0.2.
|
|
33
|
-
"@fluid-topics/ft-wc-utils": "^0.2.
|
|
22
|
+
"@fluid-topics/ft-accordion": "^0.2.16",
|
|
23
|
+
"@fluid-topics/ft-button": "^0.2.16",
|
|
24
|
+
"@fluid-topics/ft-chip": "^0.2.16",
|
|
25
|
+
"@fluid-topics/ft-filter": "^0.2.16",
|
|
26
|
+
"@fluid-topics/ft-icon": "^0.2.16",
|
|
27
|
+
"@fluid-topics/ft-select": "^0.2.16",
|
|
28
|
+
"@fluid-topics/ft-size-watcher": "^0.2.16",
|
|
29
|
+
"@fluid-topics/ft-skeleton": "^0.2.16",
|
|
30
|
+
"@fluid-topics/ft-snap-scroll": "^0.2.16",
|
|
31
|
+
"@fluid-topics/ft-tooltip": "^0.2.16",
|
|
32
|
+
"@fluid-topics/ft-typography": "^0.2.16",
|
|
33
|
+
"@fluid-topics/ft-wc-utils": "^0.2.16",
|
|
34
34
|
"lit": "2.1.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@fluid-topics/public-api": "1.0.18"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "d57a682474d27df7e667d8616a2fbca7643d51c2"
|
|
43
43
|
}
|