@internetarchive/collection-browser 2.18.3-alpha-webdev7768.0 → 2.18.3-alpha-webdev7768.2

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.
@@ -11,6 +11,7 @@ export declare class SmartFacetBar extends LitElement {
11
11
  /** The map from collection identifiers to their titles */
12
12
  collectionTitles?: CollectionTitles;
13
13
  filterToggleActive: boolean;
14
+ label?: string;
14
15
  private heuristicRecs;
15
16
  private smartFacets;
16
17
  private lastAggregations?;
@@ -24,6 +25,10 @@ export declare class SmartFacetBar extends LitElement {
24
25
  private get filtersToggleTemplate();
25
26
  private get facetsToDisplay();
26
27
  private toSmartFacet;
28
+ /**
29
+ * Toggles the state of the given smart facet, and updates the selected facets accordingly.
30
+ */
31
+ private toggleSmartFacet;
27
32
  private facetClicked;
28
33
  private facetDropdownClicked;
29
34
  private onDropdownClick;
@@ -31,9 +31,13 @@ let SmartFacetBar = class SmartFacetBar extends LitElement {
31
31
  render() {
32
32
  if (!this.query)
33
33
  return nothing;
34
+ const shouldShowLabel = !!this.label && this.smartFacets.length > 0;
34
35
  return html `
35
36
  <div id="smart-facets-container">
36
37
  ${this.filtersToggleTemplate}
38
+ ${shouldShowLabel
39
+ ? html `<p id="filters-label">${this.label}</p>`
40
+ : nothing}
37
41
  ${repeat(this.smartFacets, f => `${f[0].label}|${f[0].facets[0].facetType}|${f[0].facets[0].bucketKey}`, facet => this.makeSmartFacet(facet))}
38
42
  </div>
39
43
  `;
@@ -196,25 +200,48 @@ let SmartFacetBar = class SmartFacetBar extends LitElement {
196
200
  }),
197
201
  };
198
202
  }
199
- facetClicked(e) {
200
- if (!e.detail.smartFacet.selected) {
203
+ /**
204
+ * Toggles the state of the given smart facet, and updates the selected facets accordingly.
205
+ */
206
+ toggleSmartFacet(facet, details) {
207
+ let newState;
208
+ if (facet.selected) {
209
+ // When deselected, leave the smart facet where it is
210
+ newState = 'none';
211
+ this.smartFacets = this.smartFacets.map(f => {
212
+ if (f[0] === facet)
213
+ return [{ ...facet, selected: false }];
214
+ return f;
215
+ });
216
+ }
217
+ else {
218
+ // When selected, move the toggled smart facet to the front of the list
219
+ newState = 'selected';
201
220
  this.smartFacets = [
202
- [{ ...e.detail.smartFacet, selected: true }],
203
- ...this.smartFacets.filter(f => f[0] !== e.detail.smartFacet),
221
+ [{ ...facet, selected: true }],
222
+ ...this.smartFacets.filter(f => f[0] !== facet),
204
223
  ];
205
224
  }
206
- for (const facet of e.detail.details) {
207
- this.selectedFacets = updateSelectedFacetBucket(this.selectedFacets, facet.facetType, facet.bucket, true);
225
+ // Update the selected facets
226
+ for (const facet of details) {
227
+ this.selectedFacets = updateSelectedFacetBucket(this.selectedFacets, facet.facetType, { ...facet.bucket, state: newState }, true);
208
228
  }
209
229
  const event = new CustomEvent('facetsChanged', {
210
230
  detail: this.selectedFacets,
211
231
  });
212
232
  this.dispatchEvent(event);
213
233
  }
234
+ facetClicked(e) {
235
+ this.toggleSmartFacet(e.detail.smartFacet, e.detail.details);
236
+ }
214
237
  facetDropdownClicked(e) {
215
- if (this.smartFacets.find(sf => smartFacetEquals(sf[0], e.detail.smartFacet))) {
238
+ const existingFacet = this.smartFacets.find(sf => sf.length === 1 && smartFacetEquals(sf[0], e.detail.smartFacet));
239
+ if (existingFacet) {
240
+ // The facet already exists outside the dropdown, so just select it there
241
+ this.toggleSmartFacet(existingFacet[0], e.detail.details);
216
242
  return;
217
243
  }
244
+ // Otherwise, prepend a new smart facet for the selected option
218
245
  this.smartFacets = [
219
246
  [{ ...e.detail.smartFacet, selected: true }],
220
247
  ...this.smartFacets,
@@ -281,6 +308,12 @@ let SmartFacetBar = class SmartFacetBar extends LitElement {
281
308
  #filters-toggle.active > svg {
282
309
  filter: invert(1);
283
310
  }
311
+
312
+ #filters-label {
313
+ font-size: 1.4rem;
314
+ font-weight: bold;
315
+ margin: 0 -5px 0 0;
316
+ }
284
317
  `;
285
318
  }
286
319
  };
@@ -299,6 +332,9 @@ __decorate([
299
332
  __decorate([
300
333
  property({ type: Boolean })
301
334
  ], SmartFacetBar.prototype, "filterToggleActive", void 0);
335
+ __decorate([
336
+ property({ type: String })
337
+ ], SmartFacetBar.prototype, "label", void 0);
302
338
  __decorate([
303
339
  state()
304
340
  ], SmartFacetBar.prototype, "heuristicRecs", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"smart-facet-bar.js","sourceRoot":"","sources":["../../../../src/collection-facets/smart-facets/smart-facet-bar.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EAGV,OAAO,GAER,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAKnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAGpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,UAAU,MAAM,+BAA+B,CAAC;AAEvD,OAAO,sBAAsB,CAAC;AAC9B,OAAO,wBAAwB,CAAC;AAEhC,MAAM,aAAa,GAAyC;IAC1D,UAAU,EAAE,cAAc;IAC1B,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,SAAS;CACnB,CAAC;AAEF,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC;AAGM,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,UAAU;IAAtC;;QAWwB,uBAAkB,GAAG,KAAK,CAAC;QAEv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AE;kDAA0C;AAEjC;IAAhB,KAAK,EAAE;uDAAwD;AAjBrD,aAAa;IADzB,aAAa,CAAC,iBAAiB,CAAC;GACpB,aAAa,CAyUzB","sourcesContent":["import {\n css,\n html,\n LitElement,\n TemplateResult,\n CSSResultGroup,\n nothing,\n PropertyValues,\n} from 'lit';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { msg } from '@lit/localize';\nimport type { Aggregation, Bucket } from '@internetarchive/search-service';\nimport type { CollectionTitles } from '../../data-source/models';\nimport type { FacetOption, SelectedFacets } from '../../models';\nimport { updateSelectedFacetBucket } from '../../utils/facet-utils';\nimport { SmartQueryHeuristicGroup } from './smart-facet-heuristics';\nimport type { SmartFacetDropdown } from './smart-facet-dropdown';\nimport type { SmartFacet, SmartFacetEvent } from './models';\nimport { smartFacetEquals } from './smart-facet-equals';\nimport { dedupe } from './dedupe';\nimport { log } from '../../utils/log';\nimport filterIcon from '../../assets/img/icons/filter';\n\nimport './smart-facet-button';\nimport './smart-facet-dropdown';\n\nconst fieldPrefixes: Partial<Record<FacetOption, string>> = {\n collection: 'Collection: ',\n creator: 'By: ',\n subject: 'About: ',\n};\n\nfunction capitalize(str: string) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\n@customElement('smart-facet-bar')\nexport class SmartFacetBar extends LitElement {\n @property({ type: String }) query?: string;\n\n @property({ type: Object }) aggregations?: Record<string, Aggregation>;\n\n @property({ type: Object }) selectedFacets?: SelectedFacets;\n\n /** The map from collection identifiers to their titles */\n @property({ type: Object })\n collectionTitles?: CollectionTitles;\n\n @property({ type: Boolean }) filterToggleActive = false;\n\n @state() private heuristicRecs: SmartFacet[] = [];\n\n @state() private smartFacets: SmartFacet[][] = [];\n\n @state() private lastAggregations?: Record<string, Aggregation>;\n\n //\n // COMPONENT LIFECYCLE METHODS\n //\n\n render() {\n if (!this.query) return nothing;\n\n return html`\n <div id=\"smart-facets-container\">\n ${this.filtersToggleTemplate}\n ${repeat(\n this.smartFacets,\n f =>\n `${f[0].label}|${f[0].facets[0].facetType}|${f[0].facets[0].bucketKey}`,\n facet => this.makeSmartFacet(facet),\n )}\n </div>\n `;\n }\n\n protected willUpdate(changed: PropertyValues): void {\n let shouldUpdateSmartFacets = false;\n\n if (changed.has('query')) {\n log('query change', changed.get('query'), this.query);\n this.lastAggregations = undefined;\n shouldUpdateSmartFacets = true;\n }\n\n if (\n changed.has('aggregations') &&\n !this.lastAggregations &&\n this.aggregations &&\n Object.keys(this.aggregations).length > 0\n ) {\n log('aggs change', changed.get('aggregations'), this.aggregations);\n this.lastAggregations = this.aggregations;\n shouldUpdateSmartFacets = true;\n }\n\n if (shouldUpdateSmartFacets) {\n log('should update smart facets, doing so...');\n this.updateSmartFacets();\n }\n }\n\n refresh(): void {\n this.lastAggregations = this.aggregations;\n this.updateSmartFacets();\n }\n\n private async updateSmartFacets(): Promise<void> {\n log('updating smart facets');\n if (this.query) {\n this.heuristicRecs =\n await new SmartQueryHeuristicGroup().getRecommendedFacets(this.query);\n log('heuristic recs are', this.heuristicRecs);\n this.smartFacets = dedupe(this.facetsToDisplay);\n log('smart facets are', this.smartFacets);\n }\n }\n\n //\n // OTHER METHODS\n //\n\n private makeSmartFacet(facets: SmartFacet[]) {\n if (facets.length === 0) {\n return nothing;\n }\n if (facets.length === 1) {\n return this.smartFacetButton(facets[0]);\n }\n return this.smartFacetDropdown(facets);\n }\n\n private smartFacetButton(facet: SmartFacet) {\n return html`\n <smart-facet-button\n .facetInfo=${facet}\n .labelPrefix=${fieldPrefixes[facet.facets[0].facetType]}\n .selected=${facet.selected ?? false}\n @facetClick=${this.facetClicked}\n ></smart-facet-button>\n `;\n }\n\n private smartFacetDropdown(facets: SmartFacet[]) {\n return html`\n <smart-facet-dropdown\n .facetInfo=${facets}\n .labelPrefix=${fieldPrefixes[facets[0].facets[0].facetType]}\n .activeFacetRef=${facets[0].facets[0]}\n @facetClick=${this.facetDropdownClicked}\n @dropdownClick=${this.onDropdownClick}\n ></smart-facet-dropdown>\n `;\n }\n\n private get filtersToggleTemplate(): TemplateResult {\n return html`\n <button\n id=\"filters-toggle\"\n class=${this.filterToggleActive ? 'active' : ''}\n title=\"${this.filterToggleActive ? 'Hide' : 'Show'} filters pane\"\n @click=${this.filterToggleClicked}\n >\n ${filterIcon}\n </button>\n `;\n }\n\n private get facetsToDisplay(): SmartFacet[][] {\n const facets: SmartFacet[][] = [];\n\n if (this.heuristicRecs.length > 0) {\n for (const rec of this.heuristicRecs) {\n // Suppress mediatype-only facets for now.\n if (rec.facets.length === 1 && rec.facets[0].facetType === 'mediatype')\n continue;\n\n facets.push([rec]);\n }\n }\n\n if (this.lastAggregations) {\n const keys = [\n 'mediatype',\n 'year',\n 'language',\n 'creator',\n 'subject',\n 'collection',\n ];\n for (const key of keys) {\n const agg = this.lastAggregations[key];\n if (!agg) continue;\n if (agg.buckets.length === 0) continue;\n if (['lending', 'year_histogram', 'date_histogram'].includes(key))\n continue;\n if (typeof agg.buckets[0] === 'number') continue;\n\n if (\n key === 'mediatype' &&\n this.selectedFacets &&\n Object.values(this.selectedFacets.mediatype ?? {}).some(\n bucket => bucket.state !== 'none',\n )\n ) {\n continue;\n }\n\n const facetType = key as FacetOption;\n const buckets = agg.buckets as Bucket[];\n\n const unusedBuckets = buckets.filter(b => {\n const selectedFacetBucket = this.selectedFacets?.[facetType]?.[b.key];\n if (selectedFacetBucket && selectedFacetBucket.state !== 'none') {\n return false;\n }\n return true;\n });\n\n if (facetType === 'mediatype') {\n continue;\n // Don't include mediatype bubbles\n } else if (facetType === 'collection' || facetType === 'subject') {\n const topBuckets = unusedBuckets.slice(0, 5);\n facets.push(topBuckets.map(b => this.toSmartFacet(facetType, [b])));\n } else {\n facets.push([this.toSmartFacet(facetType, [unusedBuckets[0]])]);\n }\n }\n }\n\n return facets;\n }\n\n private toSmartFacet(\n facetType: FacetOption,\n buckets: Bucket[],\n // prefix = true\n ): SmartFacet {\n return {\n facets: buckets.map(bucket => {\n let displayText = capitalize(bucket.key.toString());\n if (facetType === 'collection') {\n const title = this.collectionTitles?.get(bucket.key.toString());\n if (title) displayText = title;\n }\n\n return {\n facetType,\n bucketKey: bucket.key.toString(),\n displayText,\n };\n }),\n } as SmartFacet;\n }\n\n private facetClicked(e: CustomEvent<SmartFacetEvent>): void {\n if (!e.detail.smartFacet.selected) {\n this.smartFacets = [\n [{ ...e.detail.smartFacet, selected: true }],\n ...this.smartFacets.filter(f => f[0] !== e.detail.smartFacet),\n ];\n }\n\n for (const facet of e.detail.details) {\n this.selectedFacets = updateSelectedFacetBucket(\n this.selectedFacets,\n facet.facetType,\n facet.bucket,\n true,\n );\n }\n\n const event = new CustomEvent<SelectedFacets>('facetsChanged', {\n detail: this.selectedFacets,\n });\n this.dispatchEvent(event);\n }\n\n private facetDropdownClicked(e: CustomEvent<SmartFacetEvent>): void {\n if (\n this.smartFacets.find(sf => smartFacetEquals(sf[0], e.detail.smartFacet))\n ) {\n return;\n }\n\n this.smartFacets = [\n [{ ...e.detail.smartFacet, selected: true }],\n ...this.smartFacets,\n ];\n\n for (const facet of e.detail.details) {\n this.selectedFacets = updateSelectedFacetBucket(\n this.selectedFacets,\n facet.facetType,\n facet.bucket,\n true,\n );\n }\n\n const event = new CustomEvent<SelectedFacets>('facetsChanged', {\n detail: this.selectedFacets,\n });\n this.dispatchEvent(event);\n }\n\n private onDropdownClick(e: CustomEvent<SmartFacetDropdown>): void {\n log('smart bar: onDropdownClick', e.detail);\n this.shadowRoot\n ?.querySelectorAll('smart-facet-dropdown')\n .forEach(dropdown => {\n if (dropdown !== e.detail) {\n log('closing', dropdown);\n (dropdown as SmartFacetDropdown).close();\n }\n });\n }\n\n private filterToggleClicked(): void {\n this.dispatchEvent(new CustomEvent('filtersToggled'));\n }\n\n //\n // STYLES\n //\n\n static get styles(): CSSResultGroup {\n return css`\n #smart-facets-container {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 5px 10px;\n padding: 10px 0;\n }\n\n #filters-toggle {\n margin: 0;\n border: 0;\n padding: 5px 8px;\n border-radius: 5px;\n background: white;\n color: #2c2c2c;\n border: 1px solid #194880;\n font-size: 1.4rem;\n font-family: inherit;\n text-decoration: none;\n cursor: pointer;\n }\n\n #filters-toggle.active {\n background: #194880;\n color: white;\n }\n\n #filters-toggle > svg {\n width: 12px;\n filter: invert(0.16667);\n vertical-align: -1px;\n }\n\n #filters-toggle.active > svg {\n filter: invert(1);\n }\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"smart-facet-bar.js","sourceRoot":"","sources":["../../../../src/collection-facets/smart-facets/smart-facet-bar.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EAGV,OAAO,GAER,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAUnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAGpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,UAAU,MAAM,+BAA+B,CAAC;AAEvD,OAAO,sBAAsB,CAAC;AAC9B,OAAO,wBAAwB,CAAC;AAEhC,MAAM,aAAa,GAAyC;IAC1D,UAAU,EAAE,cAAc;IAC1B,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,SAAS;CACnB,CAAC;AAEF,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC;AAGM,IAA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","sourcesContent":["import {\n css,\n html,\n LitElement,\n TemplateResult,\n CSSResultGroup,\n nothing,\n PropertyValues,\n} from 'lit';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { msg } from '@lit/localize';\nimport type { Aggregation, Bucket } from '@internetarchive/search-service';\nimport type { CollectionTitles } from '../../data-source/models';\nimport type {\n FacetEventDetails,\n FacetOption,\n FacetState,\n SelectedFacets,\n} from '../../models';\nimport { updateSelectedFacetBucket } from '../../utils/facet-utils';\nimport { SmartQueryHeuristicGroup } from './smart-facet-heuristics';\nimport type { SmartFacetDropdown } from './smart-facet-dropdown';\nimport type { SmartFacet, SmartFacetEvent } from './models';\nimport { smartFacetEquals } from './smart-facet-equals';\nimport { dedupe } from './dedupe';\nimport { log } from '../../utils/log';\nimport filterIcon from '../../assets/img/icons/filter';\n\nimport './smart-facet-button';\nimport './smart-facet-dropdown';\n\nconst fieldPrefixes: Partial<Record<FacetOption, string>> = {\n collection: 'Collection: ',\n creator: 'By: ',\n subject: 'About: ',\n};\n\nfunction capitalize(str: string) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\n@customElement('smart-facet-bar')\nexport class SmartFacetBar extends LitElement {\n @property({ type: String }) query?: string;\n\n @property({ type: Object }) aggregations?: Record<string, Aggregation>;\n\n @property({ type: Object }) selectedFacets?: SelectedFacets;\n\n /** The map from collection identifiers to their titles */\n @property({ type: Object })\n collectionTitles?: CollectionTitles;\n\n @property({ type: Boolean }) filterToggleActive = false;\n\n @property({ type: String }) label?: string;\n\n @state() private heuristicRecs: SmartFacet[] = [];\n\n @state() private smartFacets: SmartFacet[][] = [];\n\n @state() private lastAggregations?: Record<string, Aggregation>;\n\n //\n // COMPONENT LIFECYCLE METHODS\n //\n\n render() {\n if (!this.query) return nothing;\n\n const shouldShowLabel = !!this.label && this.smartFacets.length > 0;\n return html`\n <div id=\"smart-facets-container\">\n ${this.filtersToggleTemplate}\n ${shouldShowLabel\n ? html`<p id=\"filters-label\">${this.label}</p>`\n : nothing}\n ${repeat(\n this.smartFacets,\n f =>\n `${f[0].label}|${f[0].facets[0].facetType}|${f[0].facets[0].bucketKey}`,\n facet => this.makeSmartFacet(facet),\n )}\n </div>\n `;\n }\n\n protected willUpdate(changed: PropertyValues): void {\n let shouldUpdateSmartFacets = false;\n\n if (changed.has('query')) {\n log('query change', changed.get('query'), this.query);\n this.lastAggregations = undefined;\n shouldUpdateSmartFacets = true;\n }\n\n if (\n changed.has('aggregations') &&\n !this.lastAggregations &&\n this.aggregations &&\n Object.keys(this.aggregations).length > 0\n ) {\n log('aggs change', changed.get('aggregations'), this.aggregations);\n this.lastAggregations = this.aggregations;\n shouldUpdateSmartFacets = true;\n }\n\n if (shouldUpdateSmartFacets) {\n log('should update smart facets, doing so...');\n this.updateSmartFacets();\n }\n }\n\n refresh(): void {\n this.lastAggregations = this.aggregations;\n this.updateSmartFacets();\n }\n\n private async updateSmartFacets(): Promise<void> {\n log('updating smart facets');\n if (this.query) {\n this.heuristicRecs =\n await new SmartQueryHeuristicGroup().getRecommendedFacets(this.query);\n log('heuristic recs are', this.heuristicRecs);\n this.smartFacets = dedupe(this.facetsToDisplay);\n log('smart facets are', this.smartFacets);\n }\n }\n\n //\n // OTHER METHODS\n //\n\n private makeSmartFacet(facets: SmartFacet[]) {\n if (facets.length === 0) {\n return nothing;\n }\n if (facets.length === 1) {\n return this.smartFacetButton(facets[0]);\n }\n return this.smartFacetDropdown(facets);\n }\n\n private smartFacetButton(facet: SmartFacet) {\n return html`\n <smart-facet-button\n .facetInfo=${facet}\n .labelPrefix=${fieldPrefixes[facet.facets[0].facetType]}\n .selected=${facet.selected ?? false}\n @facetClick=${this.facetClicked}\n ></smart-facet-button>\n `;\n }\n\n private smartFacetDropdown(facets: SmartFacet[]) {\n return html`\n <smart-facet-dropdown\n .facetInfo=${facets}\n .labelPrefix=${fieldPrefixes[facets[0].facets[0].facetType]}\n .activeFacetRef=${facets[0].facets[0]}\n @facetClick=${this.facetDropdownClicked}\n @dropdownClick=${this.onDropdownClick}\n ></smart-facet-dropdown>\n `;\n }\n\n private get filtersToggleTemplate(): TemplateResult {\n return html`\n <button\n id=\"filters-toggle\"\n class=${this.filterToggleActive ? 'active' : ''}\n title=\"${this.filterToggleActive ? 'Hide' : 'Show'} filters pane\"\n @click=${this.filterToggleClicked}\n >\n ${filterIcon}\n </button>\n `;\n }\n\n private get facetsToDisplay(): SmartFacet[][] {\n const facets: SmartFacet[][] = [];\n\n if (this.heuristicRecs.length > 0) {\n for (const rec of this.heuristicRecs) {\n // Suppress mediatype-only facets for now.\n if (rec.facets.length === 1 && rec.facets[0].facetType === 'mediatype')\n continue;\n\n facets.push([rec]);\n }\n }\n\n if (this.lastAggregations) {\n const keys = [\n 'mediatype',\n 'year',\n 'language',\n 'creator',\n 'subject',\n 'collection',\n ];\n for (const key of keys) {\n const agg = this.lastAggregations[key];\n if (!agg) continue;\n if (agg.buckets.length === 0) continue;\n if (['lending', 'year_histogram', 'date_histogram'].includes(key))\n continue;\n if (typeof agg.buckets[0] === 'number') continue;\n\n if (\n key === 'mediatype' &&\n this.selectedFacets &&\n Object.values(this.selectedFacets.mediatype ?? {}).some(\n bucket => bucket.state !== 'none',\n )\n ) {\n continue;\n }\n\n const facetType = key as FacetOption;\n const buckets = agg.buckets as Bucket[];\n\n const unusedBuckets = buckets.filter(b => {\n const selectedFacetBucket = this.selectedFacets?.[facetType]?.[b.key];\n if (selectedFacetBucket && selectedFacetBucket.state !== 'none') {\n return false;\n }\n return true;\n });\n\n if (facetType === 'mediatype') {\n continue;\n // Don't include mediatype bubbles\n } else if (facetType === 'collection' || facetType === 'subject') {\n const topBuckets = unusedBuckets.slice(0, 5);\n facets.push(topBuckets.map(b => this.toSmartFacet(facetType, [b])));\n } else {\n facets.push([this.toSmartFacet(facetType, [unusedBuckets[0]])]);\n }\n }\n }\n\n return facets;\n }\n\n private toSmartFacet(\n facetType: FacetOption,\n buckets: Bucket[],\n // prefix = true\n ): SmartFacet {\n return {\n facets: buckets.map(bucket => {\n let displayText = capitalize(bucket.key.toString());\n if (facetType === 'collection') {\n const title = this.collectionTitles?.get(bucket.key.toString());\n if (title) displayText = title;\n }\n\n return {\n facetType,\n bucketKey: bucket.key.toString(),\n displayText,\n };\n }),\n } as SmartFacet;\n }\n\n /**\n * Toggles the state of the given smart facet, and updates the selected facets accordingly.\n */\n private toggleSmartFacet(\n facet: SmartFacet,\n details: FacetEventDetails[],\n ): void {\n let newState: FacetState;\n if (facet.selected) {\n // When deselected, leave the smart facet where it is\n newState = 'none';\n this.smartFacets = this.smartFacets.map(f => {\n if (f[0] === facet) return [{ ...facet, selected: false }];\n return f;\n });\n } else {\n // When selected, move the toggled smart facet to the front of the list\n newState = 'selected';\n this.smartFacets = [\n [{ ...facet, selected: true }],\n ...this.smartFacets.filter(f => f[0] !== facet),\n ];\n }\n\n // Update the selected facets\n for (const facet of details) {\n this.selectedFacets = updateSelectedFacetBucket(\n this.selectedFacets,\n facet.facetType,\n { ...facet.bucket, state: newState },\n true,\n );\n }\n\n const event = new CustomEvent<SelectedFacets>('facetsChanged', {\n detail: this.selectedFacets,\n });\n this.dispatchEvent(event);\n }\n\n private facetClicked(e: CustomEvent<SmartFacetEvent>): void {\n this.toggleSmartFacet(e.detail.smartFacet, e.detail.details);\n }\n\n private facetDropdownClicked(e: CustomEvent<SmartFacetEvent>): void {\n const existingFacet = this.smartFacets.find(\n sf => sf.length === 1 && smartFacetEquals(sf[0], e.detail.smartFacet),\n );\n if (existingFacet) {\n // The facet already exists outside the dropdown, so just select it there\n this.toggleSmartFacet(existingFacet[0], e.detail.details);\n return;\n }\n\n // Otherwise, prepend a new smart facet for the selected option\n this.smartFacets = [\n [{ ...e.detail.smartFacet, selected: true }],\n ...this.smartFacets,\n ];\n\n for (const facet of e.detail.details) {\n this.selectedFacets = updateSelectedFacetBucket(\n this.selectedFacets,\n facet.facetType,\n facet.bucket,\n true,\n );\n }\n\n const event = new CustomEvent<SelectedFacets>('facetsChanged', {\n detail: this.selectedFacets,\n });\n this.dispatchEvent(event);\n }\n\n private onDropdownClick(e: CustomEvent<SmartFacetDropdown>): void {\n log('smart bar: onDropdownClick', e.detail);\n this.shadowRoot\n ?.querySelectorAll('smart-facet-dropdown')\n .forEach(dropdown => {\n if (dropdown !== e.detail) {\n log('closing', dropdown);\n (dropdown as SmartFacetDropdown).close();\n }\n });\n }\n\n private filterToggleClicked(): void {\n this.dispatchEvent(new CustomEvent('filtersToggled'));\n }\n\n //\n // STYLES\n //\n\n static get styles(): CSSResultGroup {\n return css`\n #smart-facets-container {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 5px 10px;\n padding: 10px 0;\n }\n\n #filters-toggle {\n margin: 0;\n border: 0;\n padding: 5px 8px;\n border-radius: 5px;\n background: white;\n color: #2c2c2c;\n border: 1px solid #194880;\n font-size: 1.4rem;\n font-family: inherit;\n text-decoration: none;\n cursor: pointer;\n }\n\n #filters-toggle.active {\n background: #194880;\n color: white;\n }\n\n #filters-toggle > svg {\n width: 12px;\n filter: invert(0.16667);\n vertical-align: -1px;\n }\n\n #filters-toggle.active > svg {\n filter: invert(1);\n }\n\n #filters-label {\n font-size: 1.4rem;\n font-weight: bold;\n margin: 0 -5px 0 0;\n }\n `;\n }\n}\n"]}
@@ -9,7 +9,19 @@ export declare class SmartFacetDropdown extends LitElement {
9
9
  render(): import("lit").TemplateResult<1> | typeof nothing;
10
10
  private get dropdownOptions();
11
11
  private get activeDropdownOption();
12
+ /**
13
+ * Handler for when the default option on the dropdown button is clicked
14
+ */
15
+ private defaultOptionSelected;
16
+ /**
17
+ * Handler for when an option in the dropdown menu is selected
18
+ */
12
19
  private optionSelected;
20
+ /**
21
+ * Responds to a dropdown selection by emitting a `facetClick` event with
22
+ * the appropriate facet details.
23
+ */
24
+ private handleSelection;
13
25
  private onDropdownClick;
14
26
  close(): void;
15
27
  static get styles(): CSSResultGroup;
@@ -20,17 +20,20 @@ let SmartFacetDropdown = class SmartFacetDropdown extends LitElement {
20
20
  <ia-dropdown
21
21
  class="dropdown"
22
22
  displayCaret
23
- openViaButton
24
23
  closeOnSelect
25
24
  closeOnEscape
26
25
  closeOnBackdropClick
27
26
  includeSelectedOption
28
27
  .options=${this.dropdownOptions}
29
28
  .selectedOption=${this.activeDropdownOption}
29
+ .openViaButton=${false}
30
30
  @optionSelected=${this.optionSelected}
31
31
  @click=${this.onDropdownClick}
32
32
  >
33
- <span class="dropdown-label" slot="dropdown-label"
33
+ <span
34
+ class="dropdown-label"
35
+ slot="dropdown-label"
36
+ @click=${this.defaultOptionSelected}
34
37
  >${(_b = this.labelPrefix) !== null && _b !== void 0 ? _b : nothing} ${displayText}</span
35
38
  >
36
39
  </ia-dropdown>
@@ -58,12 +61,29 @@ let SmartFacetDropdown = class SmartFacetDropdown extends LitElement {
58
61
  return undefined;
59
62
  return this.dropdownOptions.find(opt => { var _a; return opt.id === ((_a = this.activeFacetRef) === null || _a === void 0 ? void 0 : _a.bucketKey); });
60
63
  }
64
+ /**
65
+ * Handler for when the default option on the dropdown button is clicked
66
+ */
67
+ defaultOptionSelected() {
68
+ var _a;
69
+ this.handleSelection((_a = this.activeFacetRef) === null || _a === void 0 ? void 0 : _a.bucketKey);
70
+ }
71
+ /**
72
+ * Handler for when an option in the dropdown menu is selected
73
+ */
61
74
  optionSelected(e) {
62
- if (!this.facetInfo || !this.activeFacetRef)
75
+ this.handleSelection(e.detail.option.id);
76
+ }
77
+ /**
78
+ * Responds to a dropdown selection by emitting a `facetClick` event with
79
+ * the appropriate facet details.
80
+ */
81
+ handleSelection(bucketKey) {
82
+ if (!bucketKey || !this.facetInfo || !this.activeFacetRef)
63
83
  return;
64
84
  let selectedSmartFacet;
65
85
  for (const smartFacet of this.facetInfo) {
66
- const selectedRef = smartFacet.facets.find(b => b.bucketKey === e.detail.option.id);
86
+ const selectedRef = smartFacet.facets.find(b => b.bucketKey === bucketKey);
67
87
  if (selectedRef) {
68
88
  this.activeFacetRef = selectedRef;
69
89
  selectedSmartFacet = smartFacet;
@@ -1 +1 @@
1
- {"version":3,"file":"smart-facet-dropdown.js","sourceRoot":"","sources":["../../../../src/collection-facets/smart-facets/smart-facet-dropdown.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkB,OAAO,EAAE,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAGnE,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAG/B,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,UAAU;IAShD,EAAE;IACF,8BAA8B;IAC9B,EAAE;IAEF,MAAM;;QACJ,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,cAAc;YAAE,OAAO,OAAO,CAAC;QAC5D,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,OAAO,CAAC;QAEhD,MAAM,WAAW,GACf,MAAA,IAAI,CAAC,cAAc,CAAC,WAAW,mCAAI,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC;QACnE,IAAI,CAAC,WAAW;YAAE,OAAO,OAAO,CAAC;QAEjC,OAAO,IAAI,CAAA;;;;;;;;;;qBAUM,IAAI,CAAC,eAAe;4BACb,IAAI,CAAC,oBAAoB;4BACzB,IAAI,CAAC,cAAc;mBAC5B,IAAI,CAAC,eAAe;;;eAGxB,MAAA,IAAI,CAAC,WAAW,mCAAI,OAAO,IAAI,WAAW;;;;KAIpD,CAAC;IACJ,CAAC;IAED,EAAE;IACF,gBAAgB;IAChB,EAAE;IAEF,IAAY,eAAe;;QACzB,OAAO,CACL,MAAA,MAAA,IAAI,CAAC,SAAS,0CAAE,GAAG,CAAC,UAAU,CAAC,EAAE;;YAC/B,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACxC,OAAO;gBACL,EAA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AAc,CAAC,SAAS;4BAClC,KAAK,EAAE,CAAC;4BACR,KAAK,EAAE,UAAU;yBAClB;wBACD,QAAQ,EAAE,KAAK;qBAChB;iBACF;aACF;SACF,CAAC,CACH,CAAC;IACJ,CAAC;IAEO,eAAe;QACrB,GAAG,CAAC,iCAAiC,EAAE,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAqB,eAAe,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CACvE,CAAC;IACJ,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,KAAK,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,EAAE;IACF,SAAS;IACT,EAAE;IAEF,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BT,CAAC;IACJ,CAAC;CACF,CAAA;AA1J4B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;qDAA0B;AAExB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAAsB;AAErB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0DAA2B;AAEhC;IAArB,KAAK,CAAC,aAAa,CAAC;oDAAuB;AAPjC,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CA2J9B","sourcesContent":["import { css, html, LitElement, CSSResultGroup, nothing } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport type { IaDropdown, optionInterface } from '@internetarchive/ia-dropdown';\nimport type { FacetRef, SmartFacet, SmartFacetEvent } from './models';\nimport { log } from '../../utils/log';\n\n@customElement('smart-facet-dropdown')\nexport class SmartFacetDropdown extends LitElement {\n @property({ type: Array }) facetInfo?: SmartFacet[];\n\n @property({ type: String }) labelPrefix?: string;\n\n @property({ type: Object }) activeFacetRef?: FacetRef;\n\n @query('ia-dropdown') dropdown?: IaDropdown;\n\n //\n // COMPONENT LIFECYCLE METHODS\n //\n\n render() {\n if (!this.facetInfo || !this.activeFacetRef) return nothing;\n if (this.facetInfo.length === 0) return nothing;\n\n const displayText =\n this.activeFacetRef.displayText ?? this.activeFacetRef.bucketKey;\n if (!displayText) return nothing;\n\n return html`\n <div class=\"dropdown-container\">\n <ia-dropdown\n class=\"dropdown\"\n displayCaret\n openViaButton\n closeOnSelect\n closeOnEscape\n closeOnBackdropClick\n includeSelectedOption\n .options=${this.dropdownOptions}\n .selectedOption=${this.activeDropdownOption}\n @optionSelected=${this.optionSelected}\n @click=${this.onDropdownClick}\n >\n <span class=\"dropdown-label\" slot=\"dropdown-label\"\n >${this.labelPrefix ?? nothing} ${displayText}</span\n >\n </ia-dropdown>\n </div>\n `;\n }\n\n //\n // OTHER METHODS\n //\n\n private get dropdownOptions(): optionInterface[] {\n return (\n this.facetInfo?.map(smartFacet => {\n const firstFacet = smartFacet.facets[0];\n return {\n id: firstFacet.bucketKey,\n label: html`<span>\n ${smartFacet.label ??\n firstFacet.displayText ??\n firstFacet.bucketKey}\n </span>`,\n };\n }) ?? []\n );\n }\n\n private get activeDropdownOption(): optionInterface | undefined {\n if (!this.activeFacetRef) return undefined;\n return this.dropdownOptions.find(\n opt => opt.id === this.activeFacetRef?.bucketKey,\n );\n }\n\n private optionSelected(e: CustomEvent<{ option: optionInterface }>): void {\n if (!this.facetInfo || !this.activeFacetRef) return;\n\n let selectedSmartFacet;\n for (const smartFacet of this.facetInfo) {\n const selectedRef = smartFacet.facets.find(\n b => b.bucketKey === e.detail.option.id,\n );\n if (selectedRef) {\n this.activeFacetRef = selectedRef;\n selectedSmartFacet = smartFacet;\n }\n }\n\n if (!selectedSmartFacet) return;\n\n this.dispatchEvent(\n new CustomEvent<SmartFacetEvent>('facetClick', {\n detail: {\n smartFacet: selectedSmartFacet,\n details: [\n {\n facetType: this.activeFacetRef.facetType,\n bucket: {\n key: this.activeFacetRef.bucketKey,\n count: 0,\n state: 'selected',\n },\n negative: false,\n },\n ],\n },\n }),\n );\n }\n\n private onDropdownClick(): void {\n log('smart dropdown: onDropdownClick', this);\n this.dispatchEvent(\n new CustomEvent<SmartFacetDropdown>('dropdownClick', { detail: this }),\n );\n }\n\n close(): void {\n if (this.dropdown) {\n this.dropdown.open = false;\n }\n }\n\n //\n // STYLES\n //\n\n static get styles(): CSSResultGroup {\n return css`\n .dropdown-container {\n padding: 5px 5px;\n border-radius: 5px;\n background: white;\n color: #2c2c2c;\n border: 1px solid #194880;\n font-size: 1.4rem;\n font-family: inherit;\n }\n\n .dropdown-label {\n font-size: 1.4rem;\n font-family: inherit;\n }\n\n .dropdown {\n --dropdownBorderColor: #194880;\n --dropdownBorderWidth: 1px;\n --dropdownBgColor: white;\n --dropdownHoverBgColor: #f8f8f8;\n --dropdownTextColor: #2c2c2c;\n --dropdownHoverTextColor: #2c2c2c;\n --dropdownCaretColor: #2c2c2c;\n --dropdownWhiteSpace: nowrap;\n --caretWidth: 14px;\n --caretHeight: 14px;\n }\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"smart-facet-dropdown.js","sourceRoot":"","sources":["../../../../src/collection-facets/smart-facets/smart-facet-dropdown.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkB,OAAO,EAAE,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAGnE,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAG/B,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,UAAU;IAShD,EAAE;IACF,8BAA8B;IAC9B,EAAE;IAEF,MAAM;;QACJ,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,cAAc;YAAE,OAAO,OAAO,CAAC;QA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AAqB,eAAe,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CACvE,CAAC;IACJ,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,KAAK,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,EAAE;IACF,SAAS;IACT,EAAE;IAEF,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BT,CAAC;IACJ,CAAC;CACF,CAAA;AA/K4B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;qDAA0B;AAExB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAAsB;AAErB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0DAA2B;AAEhC;IAArB,KAAK,CAAC,aAAa,CAAC;oDAAuB;AAPjC,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CAgL9B","sourcesContent":["import { css, html, LitElement, CSSResultGroup, nothing } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport type { IaDropdown, optionInterface } from '@internetarchive/ia-dropdown';\nimport type { FacetRef, SmartFacet, SmartFacetEvent } from './models';\nimport { log } from '../../utils/log';\n\n@customElement('smart-facet-dropdown')\nexport class SmartFacetDropdown extends LitElement {\n @property({ type: Array }) facetInfo?: SmartFacet[];\n\n @property({ type: String }) labelPrefix?: string;\n\n @property({ type: Object }) activeFacetRef?: FacetRef;\n\n @query('ia-dropdown') dropdown?: IaDropdown;\n\n //\n // COMPONENT LIFECYCLE METHODS\n //\n\n render() {\n if (!this.facetInfo || !this.activeFacetRef) return nothing;\n if (this.facetInfo.length === 0) return nothing;\n\n const displayText =\n this.activeFacetRef.displayText ?? this.activeFacetRef.bucketKey;\n if (!displayText) return nothing;\n\n return html`\n <div class=\"dropdown-container\">\n <ia-dropdown\n class=\"dropdown\"\n displayCaret\n closeOnSelect\n closeOnEscape\n closeOnBackdropClick\n includeSelectedOption\n .options=${this.dropdownOptions}\n .selectedOption=${this.activeDropdownOption}\n .openViaButton=${false}\n @optionSelected=${this.optionSelected}\n @click=${this.onDropdownClick}\n >\n <span\n class=\"dropdown-label\"\n slot=\"dropdown-label\"\n @click=${this.defaultOptionSelected}\n >${this.labelPrefix ?? nothing} ${displayText}</span\n >\n </ia-dropdown>\n </div>\n `;\n }\n\n //\n // OTHER METHODS\n //\n\n private get dropdownOptions(): optionInterface[] {\n return (\n this.facetInfo?.map(smartFacet => {\n const firstFacet = smartFacet.facets[0];\n return {\n id: firstFacet.bucketKey,\n label: html`<span>\n ${smartFacet.label ??\n firstFacet.displayText ??\n firstFacet.bucketKey}\n </span>`,\n };\n }) ?? []\n );\n }\n\n private get activeDropdownOption(): optionInterface | undefined {\n if (!this.activeFacetRef) return undefined;\n return this.dropdownOptions.find(\n opt => opt.id === this.activeFacetRef?.bucketKey,\n );\n }\n\n /**\n * Handler for when the default option on the dropdown button is clicked\n */\n private defaultOptionSelected(): void {\n this.handleSelection(this.activeFacetRef?.bucketKey);\n }\n\n /**\n * Handler for when an option in the dropdown menu is selected\n */\n private optionSelected(e: CustomEvent<{ option: optionInterface }>): void {\n this.handleSelection(e.detail.option.id);\n }\n\n /**\n * Responds to a dropdown selection by emitting a `facetClick` event with\n * the appropriate facet details.\n */\n private handleSelection(bucketKey?: string): void {\n if (!bucketKey || !this.facetInfo || !this.activeFacetRef) return;\n\n let selectedSmartFacet;\n for (const smartFacet of this.facetInfo) {\n const selectedRef = smartFacet.facets.find(\n b => b.bucketKey === bucketKey,\n );\n if (selectedRef) {\n this.activeFacetRef = selectedRef;\n selectedSmartFacet = smartFacet;\n }\n }\n\n if (!selectedSmartFacet) return;\n\n this.dispatchEvent(\n new CustomEvent<SmartFacetEvent>('facetClick', {\n detail: {\n smartFacet: selectedSmartFacet,\n details: [\n {\n facetType: this.activeFacetRef.facetType,\n bucket: {\n key: this.activeFacetRef.bucketKey,\n count: 0,\n state: 'selected',\n },\n negative: false,\n },\n ],\n },\n }),\n );\n }\n\n private onDropdownClick(): void {\n log('smart dropdown: onDropdownClick', this);\n this.dispatchEvent(\n new CustomEvent<SmartFacetDropdown>('dropdownClick', { detail: this }),\n );\n }\n\n close(): void {\n if (this.dropdown) {\n this.dropdown.open = false;\n }\n }\n\n //\n // STYLES\n //\n\n static get styles(): CSSResultGroup {\n return css`\n .dropdown-container {\n padding: 5px 5px;\n border-radius: 5px;\n background: white;\n color: #2c2c2c;\n border: 1px solid #194880;\n font-size: 1.4rem;\n font-family: inherit;\n }\n\n .dropdown-label {\n font-size: 1.4rem;\n font-family: inherit;\n }\n\n .dropdown {\n --dropdownBorderColor: #194880;\n --dropdownBorderWidth: 1px;\n --dropdownBgColor: white;\n --dropdownHoverBgColor: #f8f8f8;\n --dropdownTextColor: #2c2c2c;\n --dropdownHoverTextColor: #2c2c2c;\n --dropdownCaretColor: #2c2c2c;\n --dropdownWhiteSpace: nowrap;\n --caretWidth: 14px;\n --caretHeight: 14px;\n }\n `;\n }\n}\n"]}
@@ -5,123 +5,123 @@ import { srOnlyStyle } from '../../../styles/sr-only';
5
5
  */
6
6
  const tileBackgroundColor = css `var(--tileBackgroundColor, #ffffff)`;
7
7
  const tileCornerRadius = css `var(--tileCornerRadius, 4px)`;
8
- export const baseTileStyles = css `
9
- /* Include .sr-only styles for all tiles */
10
- ${srOnlyStyle}
11
-
12
- .container {
13
- background-color: ${tileBackgroundColor};
14
- border: 1px #2c2c2c;
15
- border-radius: ${tileCornerRadius};
16
- box-shadow: var(--tileBoxShadow, 1px 1px 2px 0);
17
- box-sizing: border-box;
18
- height: 100%;
19
- display: flex;
20
- flex-direction: column;
21
- width: 100%;
22
- }
23
-
24
- image-block {
25
- display: block;
26
- position: relative;
27
- text-align: center;
28
- }
29
-
30
- .tile-details {
31
- display: flex;
32
- flex-direction: column;
33
- height: 100%;
34
- row-gap: 10px;
35
- font-family: 'Helvetica Neue', ui-sans-serif, system-ui, sans-serif;
36
- }
37
-
38
- .item-info {
39
- display: flex;
40
- flex-direction: column;
41
- row-gap: 5px;
42
- flex-grow: 1;
43
- }
44
-
45
- #title {
46
- padding: 0 5px;
47
- }
48
-
49
- .created-by,
50
- .date-sorted-by,
51
- .volume-issue,
52
- .archivist-since {
53
- display: flex;
54
- justify-content: left;
55
- align-items: flex-start;
56
- padding: 0 5px;
57
- }
58
-
59
- .truncated {
60
- flex: 1;
61
- color: #2c2c2c;
62
- min-width: 0; /* Important for long words! */
63
- text-align: left;
64
- line-height: 15px;
65
- text-overflow: ellipsis;
66
- overflow: hidden;
67
- word-wrap: break-word;
68
- -webkit-line-clamp: 3;
69
- -webkit-box-orient: vertical;
70
- }
71
-
72
- h4.truncated {
73
- display: -webkit-box;
74
- margin: 0px;
75
- line-height: 15px;
76
- font-size: 14px;
77
- font-weight: 500;
78
- padding-bottom: 1px;
79
- }
80
-
81
- span {
82
- display: -webkit-box;
83
- font-size: 1.4rem;
84
- line-height: 15px;
85
- overflow: hidden;
86
- word-wrap: break-word;
87
- -webkit-line-clamp: 1;
88
- -webkit-box-orient: vertical;
89
- padding-bottom: 1px;
90
- }
91
-
92
- .container:hover > .tile-details > .item-info > #title > .truncated {
93
- text-decoration: underline;
94
- }
95
-
96
- /** this is a workaround for Safari 15 where the hover effects are not working */
97
- #title:hover > .truncated {
98
- text-decoration: underline;
99
- }
100
-
101
- .info-button {
102
- position: absolute;
103
- right: 10px;
104
- top: 10px;
105
- margin: 0;
106
- padding: 0;
107
- border: none;
108
- border-radius: 50%;
109
- display: flex;
110
- justify-content: center;
111
- align-items: center;
112
- background: rgba(220, 220, 220, 0.5);
113
- color: white;
114
- font-size: 2rem;
115
- font-weight: bold;
116
- line-height: 1;
117
- text-shadow: black 1px 1px 3px;
118
- overflow: visible;
119
- aspect-ratio: 1 / 1;
120
- z-index: 1;
121
- }
122
-
123
- .hidden {
124
- display: none;
125
- }
8
+ export const baseTileStyles = css `
9
+ /* Include .sr-only styles for all tiles */
10
+ ${srOnlyStyle}
11
+
12
+ .container {
13
+ background-color: ${tileBackgroundColor};
14
+ border: 1px #2c2c2c;
15
+ border-radius: ${tileCornerRadius};
16
+ box-shadow: var(--tileBoxShadow, 1px 1px 2px 0);
17
+ box-sizing: border-box;
18
+ height: 100%;
19
+ display: flex;
20
+ flex-direction: column;
21
+ width: 100%;
22
+ }
23
+
24
+ image-block {
25
+ display: block;
26
+ position: relative;
27
+ text-align: center;
28
+ }
29
+
30
+ .tile-details {
31
+ display: flex;
32
+ flex-direction: column;
33
+ height: 100%;
34
+ row-gap: 10px;
35
+ font-family: 'Helvetica Neue', ui-sans-serif, system-ui, sans-serif;
36
+ }
37
+
38
+ .item-info {
39
+ display: flex;
40
+ flex-direction: column;
41
+ row-gap: 5px;
42
+ flex-grow: 1;
43
+ }
44
+
45
+ #title {
46
+ padding: 0 5px;
47
+ }
48
+
49
+ .created-by,
50
+ .date-sorted-by,
51
+ .volume-issue,
52
+ .archivist-since {
53
+ display: flex;
54
+ justify-content: left;
55
+ align-items: flex-start;
56
+ padding: 0 5px;
57
+ }
58
+
59
+ .truncated {
60
+ flex: 1;
61
+ color: #2c2c2c;
62
+ min-width: 0; /* Important for long words! */
63
+ text-align: left;
64
+ line-height: 15px;
65
+ text-overflow: ellipsis;
66
+ overflow: hidden;
67
+ word-wrap: break-word;
68
+ -webkit-line-clamp: 3;
69
+ -webkit-box-orient: vertical;
70
+ }
71
+
72
+ h4.truncated {
73
+ display: -webkit-box;
74
+ margin: 0px;
75
+ line-height: 15px;
76
+ font-size: 14px;
77
+ font-weight: 500;
78
+ padding-bottom: 1px;
79
+ }
80
+
81
+ span {
82
+ display: -webkit-box;
83
+ font-size: 1.4rem;
84
+ line-height: 15px;
85
+ overflow: hidden;
86
+ word-wrap: break-word;
87
+ -webkit-line-clamp: 1;
88
+ -webkit-box-orient: vertical;
89
+ padding-bottom: 1px;
90
+ }
91
+
92
+ .container:hover > .tile-details > .item-info > #title > .truncated {
93
+ text-decoration: underline;
94
+ }
95
+
96
+ /** this is a workaround for Safari 15 where the hover effects are not working */
97
+ #title:hover > .truncated {
98
+ text-decoration: underline;
99
+ }
100
+
101
+ .info-button {
102
+ position: absolute;
103
+ right: 10px;
104
+ top: 10px;
105
+ margin: 0;
106
+ padding: 0;
107
+ border: none;
108
+ border-radius: 50%;
109
+ display: flex;
110
+ justify-content: center;
111
+ align-items: center;
112
+ background: rgba(220, 220, 220, 0.5);
113
+ color: white;
114
+ font-size: 2rem;
115
+ font-weight: bold;
116
+ line-height: 1;
117
+ text-shadow: black 1px 1px 3px;
118
+ overflow: visible;
119
+ aspect-ratio: 1 / 1;
120
+ z-index: 1;
121
+ }
122
+
123
+ .hidden {
124
+ display: none;
125
+ }
126
126
  `;
127
127
  //# sourceMappingURL=tile-grid-shared-styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tile-grid-shared-styles.js","sourceRoot":"","sources":["../../../../../src/tiles/grid/styles/tile-grid-shared-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;GAEG;AAEH,MAAM,mBAAmB,GAAG,GAAG,CAAA,qCAAqC,CAAC;AACrE,MAAM,gBAAgB,GAAG,GAAG,CAAA,8BAA8B,CAAC;AAE3D,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;;IAE7B,WAAW;;;wBAGS,mBAAmB;;qBAEtB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+GpC,CAAC","sourcesContent":["import { css } from 'lit';\r\nimport { srOnlyStyle } from '../../../styles/sr-only';\r\n\r\n/**\r\n * Base tile styles\r\n */\r\n\r\nconst tileBackgroundColor = css`var(--tileBackgroundColor, #ffffff)`;\r\nconst tileCornerRadius = css`var(--tileCornerRadius, 4px)`;\r\n\r\nexport const baseTileStyles = css`\r\n /* Include .sr-only styles for all tiles */\r\n ${srOnlyStyle}\r\n\r\n .container {\r\n background-color: ${tileBackgroundColor};\r\n border: 1px #2c2c2c;\r\n border-radius: ${tileCornerRadius};\r\n box-shadow: var(--tileBoxShadow, 1px 1px 2px 0);\r\n box-sizing: border-box;\r\n height: 100%;\r\n display: flex;\r\n flex-direction: column;\r\n width: 100%;\r\n }\r\n\r\n image-block {\r\n display: block;\r\n position: relative;\r\n text-align: center;\r\n }\r\n\r\n .tile-details {\r\n display: flex;\r\n flex-direction: column;\r\n height: 100%;\r\n row-gap: 10px;\r\n font-family: 'Helvetica Neue', ui-sans-serif, system-ui, sans-serif;\r\n }\r\n\r\n .item-info {\r\n display: flex;\r\n flex-direction: column;\r\n row-gap: 5px;\r\n flex-grow: 1;\r\n }\r\n\r\n #title {\r\n padding: 0 5px;\r\n }\r\n\r\n .created-by,\r\n .date-sorted-by,\r\n .volume-issue,\r\n .archivist-since {\r\n display: flex;\r\n justify-content: left;\r\n align-items: flex-start;\r\n padding: 0 5px;\r\n }\r\n\r\n .truncated {\r\n flex: 1;\r\n color: #2c2c2c;\r\n min-width: 0; /* Important for long words! */\r\n text-align: left;\r\n line-height: 15px;\r\n text-overflow: ellipsis;\r\n overflow: hidden;\r\n word-wrap: break-word;\r\n -webkit-line-clamp: 3;\r\n -webkit-box-orient: vertical;\r\n }\r\n\r\n h4.truncated {\r\n display: -webkit-box;\r\n margin: 0px;\r\n line-height: 15px;\r\n font-size: 14px;\r\n font-weight: 500;\r\n padding-bottom: 1px;\r\n }\r\n\r\n span {\r\n display: -webkit-box;\r\n font-size: 1.4rem;\r\n line-height: 15px;\r\n overflow: hidden;\r\n word-wrap: break-word;\r\n -webkit-line-clamp: 1;\r\n -webkit-box-orient: vertical;\r\n padding-bottom: 1px;\r\n }\r\n\r\n .container:hover > .tile-details > .item-info > #title > .truncated {\r\n text-decoration: underline;\r\n }\r\n\r\n /** this is a workaround for Safari 15 where the hover effects are not working */\r\n #title:hover > .truncated {\r\n text-decoration: underline;\r\n }\r\n\r\n .info-button {\r\n position: absolute;\r\n right: 10px;\r\n top: 10px;\r\n margin: 0;\r\n padding: 0;\r\n border: none;\r\n border-radius: 50%;\r\n display: flex;\r\n justify-content: center;\r\n align-items: center;\r\n background: rgba(220, 220, 220, 0.5);\r\n color: white;\r\n font-size: 2rem;\r\n font-weight: bold;\r\n line-height: 1;\r\n text-shadow: black 1px 1px 3px;\r\n overflow: visible;\r\n aspect-ratio: 1 / 1;\r\n z-index: 1;\r\n }\r\n\r\n .hidden {\r\n display: none;\r\n }\r\n`;\r\n"]}
1
+ {"version":3,"file":"tile-grid-shared-styles.js","sourceRoot":"","sources":["../../../../../src/tiles/grid/styles/tile-grid-shared-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;GAEG;AAEH,MAAM,mBAAmB,GAAG,GAAG,CAAA,qCAAqC,CAAC;AACrE,MAAM,gBAAgB,GAAG,GAAG,CAAA,8BAA8B,CAAC;AAE3D,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;;IAE7B,WAAW;;;wBAGS,mBAAmB;;qBAEtB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+GpC,CAAC","sourcesContent":["import { css } from 'lit';\nimport { srOnlyStyle } from '../../../styles/sr-only';\n\n/**\n * Base tile styles\n */\n\nconst tileBackgroundColor = css`var(--tileBackgroundColor, #ffffff)`;\nconst tileCornerRadius = css`var(--tileCornerRadius, 4px)`;\n\nexport const baseTileStyles = css`\n /* Include .sr-only styles for all tiles */\n ${srOnlyStyle}\n\n .container {\n background-color: ${tileBackgroundColor};\n border: 1px #2c2c2c;\n border-radius: ${tileCornerRadius};\n box-shadow: var(--tileBoxShadow, 1px 1px 2px 0);\n box-sizing: border-box;\n height: 100%;\n display: flex;\n flex-direction: column;\n width: 100%;\n }\n\n image-block {\n display: block;\n position: relative;\n text-align: center;\n }\n\n .tile-details {\n display: flex;\n flex-direction: column;\n height: 100%;\n row-gap: 10px;\n font-family: 'Helvetica Neue', ui-sans-serif, system-ui, sans-serif;\n }\n\n .item-info {\n display: flex;\n flex-direction: column;\n row-gap: 5px;\n flex-grow: 1;\n }\n\n #title {\n padding: 0 5px;\n }\n\n .created-by,\n .date-sorted-by,\n .volume-issue,\n .archivist-since {\n display: flex;\n justify-content: left;\n align-items: flex-start;\n padding: 0 5px;\n }\n\n .truncated {\n flex: 1;\n color: #2c2c2c;\n min-width: 0; /* Important for long words! */\n text-align: left;\n line-height: 15px;\n text-overflow: ellipsis;\n overflow: hidden;\n word-wrap: break-word;\n -webkit-line-clamp: 3;\n -webkit-box-orient: vertical;\n }\n\n h4.truncated {\n display: -webkit-box;\n margin: 0px;\n line-height: 15px;\n font-size: 14px;\n font-weight: 500;\n padding-bottom: 1px;\n }\n\n span {\n display: -webkit-box;\n font-size: 1.4rem;\n line-height: 15px;\n overflow: hidden;\n word-wrap: break-word;\n -webkit-line-clamp: 1;\n -webkit-box-orient: vertical;\n padding-bottom: 1px;\n }\n\n .container:hover > .tile-details > .item-info > #title > .truncated {\n text-decoration: underline;\n }\n\n /** this is a workaround for Safari 15 where the hover effects are not working */\n #title:hover > .truncated {\n text-decoration: underline;\n }\n\n .info-button {\n position: absolute;\n right: 10px;\n top: 10px;\n margin: 0;\n padding: 0;\n border: none;\n border-radius: 50%;\n display: flex;\n justify-content: center;\n align-items: center;\n background: rgba(220, 220, 220, 0.5);\n color: white;\n font-size: 2rem;\n font-weight: bold;\n line-height: 1;\n text-shadow: black 1px 1px 3px;\n overflow: visible;\n aspect-ratio: 1 / 1;\n z-index: 1;\n }\n\n .hidden {\n display: none;\n }\n`;\n"]}