@internetarchive/collection-browser 2.7.2-alpha.0 → 2.7.2-alpha.1
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/.github/workflows/ci.yml +2 -3
- package/dist/src/app-root.d.ts +0 -4
- package/dist/src/app-root.js +0 -15
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.d.ts +6 -3
- package/dist/src/collection-browser.js +22 -25
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.js +7 -6
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/package.json +1 -1
- package/src/app-root.ts +0 -16
- package/src/collection-browser.ts +43 -21
- package/src/data-source/collection-browser-data-source.ts +14 -8
- package/dist/src/assets/img/icons/filter.d.ts +0 -2
- package/dist/src/assets/img/icons/filter.js +0 -10
- package/dist/src/assets/img/icons/filter.js.map +0 -1
- package/dist/src/collection-facets/smart-facets/heuristics/query-keywords-heuristic.d.ts +0 -5
- package/dist/src/collection-facets/smart-facets/heuristics/query-keywords-heuristic.js +0 -45
- package/dist/src/collection-facets/smart-facets/heuristics/query-keywords-heuristic.js.map +0 -1
- package/dist/src/collection-facets/smart-facets/heuristics/wikidata-heuristic.d.ts +0 -5
- package/dist/src/collection-facets/smart-facets/heuristics/wikidata-heuristic.js +0 -130
- package/dist/src/collection-facets/smart-facets/heuristics/wikidata-heuristic.js.map +0 -1
- package/dist/src/collection-facets/smart-facets/models.d.ts +0 -24
- package/dist/src/collection-facets/smart-facets/models.js +0 -2
- package/dist/src/collection-facets/smart-facets/models.js.map +0 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.d.ts +0 -27
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +0 -240
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +0 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-button.d.ts +0 -10
- package/dist/src/collection-facets/smart-facets/smart-facet-button.js +0 -108
- package/dist/src/collection-facets/smart-facets/smart-facet-button.js.map +0 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.d.ts +0 -14
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js +0 -112
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js.map +0 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.d.ts +0 -4
- package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js +0 -11
- package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js.map +0 -1
- package/src/assets/img/icons/filter.ts +0 -10
- package/src/collection-facets/smart-facets/heuristics/query-keywords-heuristic.ts +0 -55
- package/src/collection-facets/smart-facets/heuristics/wikidata-heuristic.ts +0 -148
- package/src/collection-facets/smart-facets/models.ts +0 -30
- package/src/collection-facets/smart-facets/smart-facet-bar.ts +0 -281
- package/src/collection-facets/smart-facets/smart-facet-button.ts +0 -114
- package/src/collection-facets/smart-facets/smart-facet-dropdown.ts +0 -109
- package/src/collection-facets/smart-facets/smart-facet-heuristics.ts +0 -12
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { css, html, LitElement, nothing } from 'lit';
|
|
3
|
-
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
-
import { mediatypeConfig } from '../../mediatype/mediatype-config';
|
|
5
|
-
let SmartFacetButton = class SmartFacetButton extends LitElement {
|
|
6
|
-
constructor() {
|
|
7
|
-
super(...arguments);
|
|
8
|
-
this.selected = false;
|
|
9
|
-
}
|
|
10
|
-
//
|
|
11
|
-
// COMPONENT LIFECYCLE METHODS
|
|
12
|
-
//
|
|
13
|
-
render() {
|
|
14
|
-
var _a, _b;
|
|
15
|
-
if (!this.facetInfo)
|
|
16
|
-
return nothing;
|
|
17
|
-
const isSingleFacet = this.facetInfo.facets.length === 1;
|
|
18
|
-
const firstFacet = this.facetInfo.facets[0];
|
|
19
|
-
const displayText = (_b = (_a = this.facetInfo.label) !== null && _a !== void 0 ? _a : firstFacet.displayText) !== null && _b !== void 0 ? _b : firstFacet.bucketKey;
|
|
20
|
-
if (!displayText)
|
|
21
|
-
return nothing;
|
|
22
|
-
const icon = isSingleFacet && firstFacet.facetType === 'mediatype'
|
|
23
|
-
? mediatypeConfig[firstFacet.bucketKey].icon
|
|
24
|
-
: nothing;
|
|
25
|
-
return html `
|
|
26
|
-
<a
|
|
27
|
-
class="smart-facet-button ${this.selected ? 'selected' : ''}"
|
|
28
|
-
href=${this.href}
|
|
29
|
-
@click=${this.facetClicked}
|
|
30
|
-
>
|
|
31
|
-
${icon} ${displayText}
|
|
32
|
-
${this.selected
|
|
33
|
-
? html `<span style="margin-left: 5px;">×</span>`
|
|
34
|
-
: nothing}
|
|
35
|
-
</a>
|
|
36
|
-
`;
|
|
37
|
-
}
|
|
38
|
-
//
|
|
39
|
-
// OTHER METHODS
|
|
40
|
-
//
|
|
41
|
-
get href() {
|
|
42
|
-
const url = new URL(window.location.href);
|
|
43
|
-
if (this.facetInfo) {
|
|
44
|
-
for (const facet of this.facetInfo.facets) {
|
|
45
|
-
url.searchParams.append('and[]', encodeURIComponent(`${facet.facetType}:"${facet.bucketKey}"`));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return url.toString();
|
|
49
|
-
}
|
|
50
|
-
facetClicked(e) {
|
|
51
|
-
e.preventDefault();
|
|
52
|
-
if (!this.facetInfo)
|
|
53
|
-
return;
|
|
54
|
-
this.selected = !this.selected;
|
|
55
|
-
this.dispatchEvent(new CustomEvent('facetClick', {
|
|
56
|
-
detail: {
|
|
57
|
-
smartFacet: this.facetInfo,
|
|
58
|
-
details: this.facetInfo.facets.map(f => ({
|
|
59
|
-
facetType: f.facetType,
|
|
60
|
-
bucket: {
|
|
61
|
-
key: f.bucketKey,
|
|
62
|
-
count: 0,
|
|
63
|
-
state: this.selected ? 'selected' : 'none',
|
|
64
|
-
},
|
|
65
|
-
negative: false,
|
|
66
|
-
})),
|
|
67
|
-
},
|
|
68
|
-
}));
|
|
69
|
-
}
|
|
70
|
-
//
|
|
71
|
-
// STYLES
|
|
72
|
-
//
|
|
73
|
-
static get styles() {
|
|
74
|
-
return css `
|
|
75
|
-
.smart-facet-button {
|
|
76
|
-
padding: 5px 10px;
|
|
77
|
-
border-radius: 15px;
|
|
78
|
-
background: #194880;
|
|
79
|
-
color: white;
|
|
80
|
-
font-size: 1.6rem;
|
|
81
|
-
font-family: inherit;
|
|
82
|
-
text-decoration: none;
|
|
83
|
-
box-shadow: 1px 1px rgba(0, 0, 0, 0.4);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.smart-facet-button.selected {
|
|
87
|
-
background: #4c76aa;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.smart-facet-button > svg {
|
|
91
|
-
width: 15px;
|
|
92
|
-
filter: invert(1);
|
|
93
|
-
vertical-align: text-top;
|
|
94
|
-
}
|
|
95
|
-
`;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
__decorate([
|
|
99
|
-
property({ type: Object })
|
|
100
|
-
], SmartFacetButton.prototype, "facetInfo", void 0);
|
|
101
|
-
__decorate([
|
|
102
|
-
property({ type: Boolean })
|
|
103
|
-
], SmartFacetButton.prototype, "selected", void 0);
|
|
104
|
-
SmartFacetButton = __decorate([
|
|
105
|
-
customElement('smart-facet-button')
|
|
106
|
-
], SmartFacetButton);
|
|
107
|
-
export { SmartFacetButton };
|
|
108
|
-
//# sourceMappingURL=smart-facet-button.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"smart-facet-button.js","sourceRoot":"","sources":["../../../../src/collection-facets/smart-facets/smart-facet-button.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkB,OAAO,EAAE,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAk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CAAC,oBAAoB,CAAC;GACvB,gBAAgB,CA2G5B;SA3GY,gBAAgB","sourcesContent":["import { css, html, LitElement, CSSResultGroup, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { mediatypeConfig } from '../../mediatype/mediatype-config';\nimport type { SmartFacet } from './models';\n\n@customElement('smart-facet-button')\nexport class SmartFacetButton extends LitElement {\n @property({ type: Object }) facetInfo?: SmartFacet;\n\n @property({ type: Boolean }) selected = false;\n\n //\n // COMPONENT LIFECYCLE METHODS\n //\n\n render() {\n if (!this.facetInfo) return nothing;\n\n const isSingleFacet = this.facetInfo.facets.length === 1;\n const firstFacet = this.facetInfo.facets[0];\n\n const displayText =\n this.facetInfo.label ?? firstFacet.displayText ?? firstFacet.bucketKey;\n if (!displayText) return nothing;\n\n const icon =\n isSingleFacet && firstFacet.facetType === 'mediatype'\n ? mediatypeConfig[firstFacet.bucketKey].icon\n : nothing;\n\n return html`\n <a\n class=\"smart-facet-button ${this.selected ? 'selected' : ''}\"\n href=${this.href}\n @click=${this.facetClicked}\n >\n ${icon} ${displayText}\n ${this.selected\n ? html`<span style=\"margin-left: 5px;\">×</span>`\n : nothing}\n </a>\n `;\n }\n\n //\n // OTHER METHODS\n //\n\n private get href(): string {\n const url = new URL(window.location.href);\n if (this.facetInfo) {\n for (const facet of this.facetInfo.facets) {\n url.searchParams.append(\n 'and[]',\n encodeURIComponent(`${facet.facetType}:\"${facet.bucketKey}\"`)\n );\n }\n }\n return url.toString();\n }\n\n private facetClicked(e: Event): void {\n e.preventDefault();\n if (!this.facetInfo) return;\n\n this.selected = !this.selected;\n\n this.dispatchEvent(\n new CustomEvent('facetClick', {\n detail: {\n smartFacet: this.facetInfo,\n details: this.facetInfo.facets.map(f => ({\n facetType: f.facetType,\n bucket: {\n key: f.bucketKey,\n count: 0,\n state: this.selected ? 'selected' : 'none',\n },\n negative: false,\n })),\n },\n })\n );\n }\n\n //\n // STYLES\n //\n\n static get styles(): CSSResultGroup {\n return css`\n .smart-facet-button {\n padding: 5px 10px;\n border-radius: 15px;\n background: #194880;\n color: white;\n font-size: 1.6rem;\n font-family: inherit;\n text-decoration: none;\n box-shadow: 1px 1px rgba(0, 0, 0, 0.4);\n }\n\n .smart-facet-button.selected {\n background: #4c76aa;\n }\n\n .smart-facet-button > svg {\n width: 15px;\n filter: invert(1);\n vertical-align: text-top;\n }\n `;\n }\n}\n"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { LitElement, CSSResultGroup, nothing } from 'lit';
|
|
2
|
-
import type { IaDropdown } from '@internetarchive/ia-dropdown';
|
|
3
|
-
import type { FacetBucket, FacetOption } from '../../models';
|
|
4
|
-
export declare class SmartFacetDropdown extends LitElement {
|
|
5
|
-
facetType?: FacetOption;
|
|
6
|
-
buckets?: FacetBucket[];
|
|
7
|
-
activeBucket?: FacetBucket;
|
|
8
|
-
dropdown?: IaDropdown;
|
|
9
|
-
render(): import("lit-html").TemplateResult<1> | typeof nothing;
|
|
10
|
-
private get dropdownOptions();
|
|
11
|
-
private get activeDropdownOption();
|
|
12
|
-
private optionSelected;
|
|
13
|
-
static get styles(): CSSResultGroup;
|
|
14
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { css, html, LitElement, nothing } from 'lit';
|
|
3
|
-
import { customElement, property, query } from 'lit/decorators.js';
|
|
4
|
-
let SmartFacetDropdown = class SmartFacetDropdown extends LitElement {
|
|
5
|
-
//
|
|
6
|
-
// COMPONENT LIFECYCLE METHODS
|
|
7
|
-
//
|
|
8
|
-
render() {
|
|
9
|
-
var _a;
|
|
10
|
-
if (!this.facetType || !this.buckets || !this.activeBucket)
|
|
11
|
-
return nothing;
|
|
12
|
-
if (this.buckets.length === 0)
|
|
13
|
-
return nothing;
|
|
14
|
-
const displayText = (_a = this.activeBucket.displayText) !== null && _a !== void 0 ? _a : this.activeBucket.key;
|
|
15
|
-
if (!displayText)
|
|
16
|
-
return nothing;
|
|
17
|
-
return html `
|
|
18
|
-
<div class="dropdown-container">
|
|
19
|
-
<ia-dropdown
|
|
20
|
-
class="dropdown"
|
|
21
|
-
displayCaret
|
|
22
|
-
openViaButton
|
|
23
|
-
closeOnSelect
|
|
24
|
-
includeSelectedOption
|
|
25
|
-
.options=${this.dropdownOptions}
|
|
26
|
-
.selectedOption=${this.activeDropdownOption}
|
|
27
|
-
@optionSelected=${this.optionSelected}
|
|
28
|
-
>
|
|
29
|
-
<span class="dropdown-label" slot="dropdown-label"
|
|
30
|
-
>${displayText}</span
|
|
31
|
-
>
|
|
32
|
-
</ia-dropdown>
|
|
33
|
-
</div>
|
|
34
|
-
`;
|
|
35
|
-
}
|
|
36
|
-
//
|
|
37
|
-
// OTHER METHODS
|
|
38
|
-
//
|
|
39
|
-
get dropdownOptions() {
|
|
40
|
-
var _a, _b;
|
|
41
|
-
return ((_b = (_a = this.buckets) === null || _a === void 0 ? void 0 : _a.map(bucket => {
|
|
42
|
-
var _a;
|
|
43
|
-
return ({
|
|
44
|
-
id: bucket.key,
|
|
45
|
-
label: (_a = bucket.displayText) !== null && _a !== void 0 ? _a : bucket.key,
|
|
46
|
-
});
|
|
47
|
-
})) !== null && _b !== void 0 ? _b : []);
|
|
48
|
-
}
|
|
49
|
-
get activeDropdownOption() {
|
|
50
|
-
if (!this.activeBucket)
|
|
51
|
-
return undefined;
|
|
52
|
-
return this.dropdownOptions.find(opt => { var _a; return opt.id === ((_a = this.activeBucket) === null || _a === void 0 ? void 0 : _a.key); });
|
|
53
|
-
}
|
|
54
|
-
optionSelected(e) {
|
|
55
|
-
var _a;
|
|
56
|
-
this.dispatchEvent(new CustomEvent('facetClick', {
|
|
57
|
-
detail: {
|
|
58
|
-
facetType: this.facetType,
|
|
59
|
-
bucket: {
|
|
60
|
-
...(_a = this.buckets) === null || _a === void 0 ? void 0 : _a.find(b => b.key === e.detail.option.id),
|
|
61
|
-
state: 'selected',
|
|
62
|
-
},
|
|
63
|
-
negative: false,
|
|
64
|
-
},
|
|
65
|
-
}));
|
|
66
|
-
}
|
|
67
|
-
//
|
|
68
|
-
// STYLES
|
|
69
|
-
//
|
|
70
|
-
static get styles() {
|
|
71
|
-
return css `
|
|
72
|
-
.dropdown-container {
|
|
73
|
-
padding: 5px 8px;
|
|
74
|
-
border-radius: 5px;
|
|
75
|
-
background: #194880;
|
|
76
|
-
color: white;
|
|
77
|
-
font-size: 1.6rem;
|
|
78
|
-
font-family: inherit;
|
|
79
|
-
box-shadow: 1px 1px rgba(0, 0, 0, 0.4);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.dropdown-label {
|
|
83
|
-
font-size: 1.6rem;
|
|
84
|
-
font-family: inherit;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.dropdown {
|
|
88
|
-
--dropdownBorderWidth: 5px;
|
|
89
|
-
--dropdownBorderColor: transparent;
|
|
90
|
-
--caretWidth: 14px;
|
|
91
|
-
--caretHeight: 14px;
|
|
92
|
-
}
|
|
93
|
-
`;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
__decorate([
|
|
97
|
-
property({ type: String })
|
|
98
|
-
], SmartFacetDropdown.prototype, "facetType", void 0);
|
|
99
|
-
__decorate([
|
|
100
|
-
property({ type: Array })
|
|
101
|
-
], SmartFacetDropdown.prototype, "buckets", void 0);
|
|
102
|
-
__decorate([
|
|
103
|
-
property({ type: Object })
|
|
104
|
-
], SmartFacetDropdown.prototype, "activeBucket", void 0);
|
|
105
|
-
__decorate([
|
|
106
|
-
query('ia-dropdown')
|
|
107
|
-
], SmartFacetDropdown.prototype, "dropdown", void 0);
|
|
108
|
-
SmartFacetDropdown = __decorate([
|
|
109
|
-
customElement('smart-facet-dropdown')
|
|
110
|
-
], SmartFacetDropdown);
|
|
111
|
-
export { SmartFacetDropdown };
|
|
112
|
-
//# sourceMappingURL=smart-facet-dropdown.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"smart-facet-dropdown.js","sourceRoot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,OAAO,SAAS,CAAC;QACzC,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,WAAC,OAAA,GAAG,CAAC,EAAE,MAAK,MAAA,IAAI,CAAC,YAAY,0CAAE,GAAG,CAAA,CAAA,EAAA,CAAC,CAAC;IAC7E,CAAC;IAEO,cAAc,CAAC,CAA2C;;QAChE,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,YAAY,EAAE;YAC5B,MAAM,EAAE;gBACN,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,MAAM,EAAE;oBACN,GAAG,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;oBACxD,KAAK,EAAE,UAAU;iBAClB;gBACD,QAAQ,EAAE,KAAK;aAChB;SACF,CAAC,CACH,CAAC;IACJ,CAAC;IAED,EAAE;IACF,SAAS;IACT,EAAE;IAEF,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;KAsBT,CAAC;IACJ,CAAC;CACF,CAAA;AArG6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAyB;AAEzB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;mDAAyB;AAEvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDAA4B;AAEjC;IAArB,KAAK,CAAC,aAAa,CAAC;oDAAuB;AAPjC,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CAsG9B;SAtGY,kBAAkB","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 { FacetBucket, FacetOption } from '../../models';\n\n@customElement('smart-facet-dropdown')\nexport class SmartFacetDropdown extends LitElement {\n @property({ type: String }) facetType?: FacetOption;\n\n @property({ type: Array }) buckets?: FacetBucket[];\n\n @property({ type: Object }) activeBucket?: FacetBucket;\n\n @query('ia-dropdown') dropdown?: IaDropdown;\n\n //\n // COMPONENT LIFECYCLE METHODS\n //\n\n render() {\n if (!this.facetType || !this.buckets || !this.activeBucket) return nothing;\n if (this.buckets.length === 0) return nothing;\n\n const displayText = this.activeBucket.displayText ?? this.activeBucket.key;\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 includeSelectedOption\n .options=${this.dropdownOptions}\n .selectedOption=${this.activeDropdownOption}\n @optionSelected=${this.optionSelected}\n >\n <span class=\"dropdown-label\" slot=\"dropdown-label\"\n >${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.buckets?.map(bucket => ({\n id: bucket.key,\n label: bucket.displayText ?? bucket.key,\n })) ?? []\n );\n }\n\n private get activeDropdownOption(): optionInterface | undefined {\n if (!this.activeBucket) return undefined;\n return this.dropdownOptions.find(opt => opt.id === this.activeBucket?.key);\n }\n\n private optionSelected(e: CustomEvent<{ option: optionInterface }>): void {\n this.dispatchEvent(\n new CustomEvent('facetClick', {\n detail: {\n facetType: this.facetType,\n bucket: {\n ...this.buckets?.find(b => b.key === e.detail.option.id),\n state: 'selected',\n },\n negative: false,\n },\n })\n );\n }\n\n //\n // STYLES\n //\n\n static get styles(): CSSResultGroup {\n return css`\n .dropdown-container {\n padding: 5px 8px;\n border-radius: 5px;\n background: #194880;\n color: white;\n font-size: 1.6rem;\n font-family: inherit;\n box-shadow: 1px 1px rgba(0, 0, 0, 0.4);\n }\n\n .dropdown-label {\n font-size: 1.6rem;\n font-family: inherit;\n }\n\n .dropdown {\n --dropdownBorderWidth: 5px;\n --dropdownBorderColor: transparent;\n --caretWidth: 14px;\n --caretHeight: 14px;\n }\n `;\n }\n}\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { QueryKeywordsHeuristic } from './heuristics/query-keywords-heuristic';
|
|
2
|
-
import { WikidataEntityHeuristic } from './heuristics/wikidata-heuristic';
|
|
3
|
-
export class SmartQueryHeuristicGroup {
|
|
4
|
-
async getRecommendedFacets(query) {
|
|
5
|
-
return [
|
|
6
|
-
...(await new QueryKeywordsHeuristic().getRecommendedFacets(query)),
|
|
7
|
-
...(await new WikidataEntityHeuristic().getRecommendedFacets(query)),
|
|
8
|
-
];
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=smart-facet-heuristics.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"smart-facet-heuristics.js","sourceRoot":"","sources":["../../../../src/collection-facets/smart-facets/smart-facet-heuristics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAG1E,MAAM,OAAO,wBAAwB;IACnC,KAAK,CAAC,oBAAoB,CAAC,KAAa;QACtC,OAAO;YACL,GAAG,CAAC,MAAM,IAAI,sBAAsB,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YACnE,GAAG,CAAC,MAAM,IAAI,uBAAuB,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;SACrE,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { QueryKeywordsHeuristic } from './heuristics/query-keywords-heuristic';\nimport { WikidataEntityHeuristic } from './heuristics/wikidata-heuristic';\nimport type { SmartFacet, SmartQueryHeuristic } from './models';\n\nexport class SmartQueryHeuristicGroup implements SmartQueryHeuristic {\n async getRecommendedFacets(query: string): Promise<SmartFacet[]> {\n return [\n ...(await new QueryKeywordsHeuristic().getRecommendedFacets(query)),\n ...(await new WikidataEntityHeuristic().getRecommendedFacets(query)),\n ];\n }\n}\n"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { html } from 'lit';
|
|
2
|
-
|
|
3
|
-
export default html`
|
|
4
|
-
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
|
5
|
-
<path
|
|
6
|
-
d="m 91.666668,8.3333328 v 0.9708343 l -35.3625,39.2916669 -2.137502,2.375 v 3.195832 32.350001 L 45.833334,82.35 V 54.166666 50.970834 l -2.1375,-2.375 L 8.3333328,9.3041671 V 8.3333328 H 91.666668 M 100,0 H 0 V 12.5 L 37.500001,54.166666 V 87.5 l 25,12.5 V 54.166666 L 100,12.5 Z"
|
|
7
|
-
fill="#000"
|
|
8
|
-
/>
|
|
9
|
-
</svg>
|
|
10
|
-
`;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
SmartQueryHeuristic,
|
|
3
|
-
KeywordFacetMap,
|
|
4
|
-
SmartFacet,
|
|
5
|
-
} from '../models';
|
|
6
|
-
|
|
7
|
-
// If the query contains X word but Y facet isn't selected, recommend facet Y
|
|
8
|
-
export class QueryKeywordsHeuristic implements SmartQueryHeuristic {
|
|
9
|
-
private static readonly KEYWORDS: KeywordFacetMap = {
|
|
10
|
-
text: [{ facets: [{ facetType: 'mediatype', bucketKey: 'texts' }] }],
|
|
11
|
-
book: [{ facets: [{ facetType: 'mediatype', bucketKey: 'texts' }] }],
|
|
12
|
-
pdf: [{ facets: [{ facetType: 'mediatype', bucketKey: 'texts' }] }],
|
|
13
|
-
epub: [{ facets: [{ facetType: 'mediatype', bucketKey: 'texts' }] }],
|
|
14
|
-
audio: [{ facets: [{ facetType: 'mediatype', bucketKey: 'audio' }] }],
|
|
15
|
-
song: [{ facets: [{ facetType: 'mediatype', bucketKey: 'audio' }] }],
|
|
16
|
-
music: [{ facets: [{ facetType: 'mediatype', bucketKey: 'audio' }] }],
|
|
17
|
-
listen: [{ facets: [{ facetType: 'mediatype', bucketKey: 'audio' }] }],
|
|
18
|
-
podcast: [{ facets: [{ facetType: 'mediatype', bucketKey: 'audio' }] }],
|
|
19
|
-
radio: [{ facets: [{ facetType: 'mediatype', bucketKey: 'audio' }] }],
|
|
20
|
-
stream: [
|
|
21
|
-
{ facets: [{ facetType: 'mediatype', bucketKey: 'audio' }] },
|
|
22
|
-
{ facets: [{ facetType: 'mediatype', bucketKey: 'movies' }] },
|
|
23
|
-
],
|
|
24
|
-
video: [{ facets: [{ facetType: 'mediatype', bucketKey: 'movies' }] }],
|
|
25
|
-
movie: [{ facets: [{ facetType: 'mediatype', bucketKey: 'movies' }] }],
|
|
26
|
-
film: [{ facets: [{ facetType: 'mediatype', bucketKey: 'movies' }] }],
|
|
27
|
-
image: [{ facets: [{ facetType: 'mediatype', bucketKey: 'image' }] }],
|
|
28
|
-
photo: [{ facets: [{ facetType: 'mediatype', bucketKey: 'image' }] }],
|
|
29
|
-
picture: [{ facets: [{ facetType: 'mediatype', bucketKey: 'image' }] }],
|
|
30
|
-
software: [{ facets: [{ facetType: 'mediatype', bucketKey: 'software' }] }],
|
|
31
|
-
app: [{ facets: [{ facetType: 'mediatype', bucketKey: 'software' }] }],
|
|
32
|
-
program: [{ facets: [{ facetType: 'mediatype', bucketKey: 'software' }] }],
|
|
33
|
-
game: [{ facets: [{ facetType: 'mediatype', bucketKey: 'software' }] }],
|
|
34
|
-
etree: [{ facets: [{ facetType: 'mediatype', bucketKey: 'etree' }] }],
|
|
35
|
-
concert: [{ facets: [{ facetType: 'mediatype', bucketKey: 'etree' }] }],
|
|
36
|
-
'live music': [
|
|
37
|
-
{ facets: [{ facetType: 'mediatype', bucketKey: 'etree' }] },
|
|
38
|
-
],
|
|
39
|
-
dataset: [{ facets: [{ facetType: 'mediatype', bucketKey: 'data' }] }],
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
async getRecommendedFacets(query: string): Promise<SmartFacet[]> {
|
|
43
|
-
const recommendations: SmartFacet[] = [];
|
|
44
|
-
|
|
45
|
-
for (const [keyword, facets] of Object.entries(
|
|
46
|
-
QueryKeywordsHeuristic.KEYWORDS
|
|
47
|
-
)) {
|
|
48
|
-
if (query.includes(keyword)) {
|
|
49
|
-
recommendations.push(...facets);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return recommendations;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
SmartQueryHeuristic,
|
|
3
|
-
KeywordFacetMap,
|
|
4
|
-
SmartFacet,
|
|
5
|
-
} from '../models';
|
|
6
|
-
|
|
7
|
-
// If wikidata says the query is an entity of type X, recommend facet Y, e.g.:
|
|
8
|
-
// X Y
|
|
9
|
-
// written work mt:texts
|
|
10
|
-
// film mt:movies
|
|
11
|
-
// author mt:texts and creator:<query>
|
|
12
|
-
// filmmaker mt:movies and creator:<query>
|
|
13
|
-
// photographer mt:image and creator:<query>
|
|
14
|
-
// visual artist mt:image and creator:<query>
|
|
15
|
-
export class WikidataEntityHeuristic implements SmartQueryHeuristic {
|
|
16
|
-
private static readonly ENTITIES: KeywordFacetMap = {
|
|
17
|
-
literature: [{ facets: [{ facetType: 'mediatype', bucketKey: 'texts' }] }],
|
|
18
|
-
filmmaker: [
|
|
19
|
-
{
|
|
20
|
-
label: 'Films by __QUERY',
|
|
21
|
-
facets: [
|
|
22
|
-
{ facetType: 'mediatype', bucketKey: 'movies' },
|
|
23
|
-
{ facetType: 'creator', bucketKey: '__QUERY' },
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
author: [
|
|
28
|
-
{
|
|
29
|
-
label: 'Writing by __QUERY',
|
|
30
|
-
facets: [
|
|
31
|
-
{ facetType: 'mediatype', bucketKey: 'texts' },
|
|
32
|
-
{ facetType: 'creator', bucketKey: '__QUERY' },
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
writer: [
|
|
37
|
-
{
|
|
38
|
-
label: 'Writing by __QUERY',
|
|
39
|
-
facets: [
|
|
40
|
-
{ facetType: 'mediatype', bucketKey: 'texts' },
|
|
41
|
-
{ facetType: 'creator', bucketKey: '__QUERY' },
|
|
42
|
-
],
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
poet: [
|
|
46
|
-
{
|
|
47
|
-
label: 'Writing by __QUERY',
|
|
48
|
-
facets: [
|
|
49
|
-
{ facetType: 'mediatype', bucketKey: 'texts' },
|
|
50
|
-
{ facetType: 'creator', bucketKey: '__QUERY' },
|
|
51
|
-
],
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
photographer: [
|
|
55
|
-
{
|
|
56
|
-
label: 'Images by __QUERY',
|
|
57
|
-
facets: [
|
|
58
|
-
{ facetType: 'mediatype', bucketKey: 'image' },
|
|
59
|
-
{ facetType: 'creator', bucketKey: '__QUERY' },
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
painter: [
|
|
64
|
-
{
|
|
65
|
-
label: 'Images by __QUERY',
|
|
66
|
-
facets: [
|
|
67
|
-
{ facetType: 'mediatype', bucketKey: 'image' },
|
|
68
|
-
{ facetType: 'creator', bucketKey: '__QUERY' },
|
|
69
|
-
],
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
singer: [
|
|
73
|
-
{
|
|
74
|
-
label: 'Music by __QUERY',
|
|
75
|
-
facets: [
|
|
76
|
-
{ facetType: 'mediatype', bucketKey: 'audio' },
|
|
77
|
-
{ facetType: 'creator', bucketKey: '__QUERY' },
|
|
78
|
-
],
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
songwriter: [
|
|
82
|
-
{
|
|
83
|
-
label: 'Music by __QUERY',
|
|
84
|
-
facets: [
|
|
85
|
-
{ facetType: 'mediatype', bucketKey: 'audio' },
|
|
86
|
-
{ facetType: 'creator', bucketKey: '__QUERY' },
|
|
87
|
-
],
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
musician: [
|
|
91
|
-
{
|
|
92
|
-
label: 'Music by __QUERY',
|
|
93
|
-
facets: [
|
|
94
|
-
{ facetType: 'mediatype', bucketKey: 'audio' },
|
|
95
|
-
{ facetType: 'creator', bucketKey: '__QUERY' },
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
async getRecommendedFacets(query: string): Promise<SmartFacet[]> {
|
|
102
|
-
const recommendations: SmartFacet[] = [];
|
|
103
|
-
|
|
104
|
-
try {
|
|
105
|
-
const urlQuery = encodeURIComponent(query);
|
|
106
|
-
|
|
107
|
-
const wikidataResponse = await fetch(
|
|
108
|
-
`https://www.wikidata.org/w/api.php?action=wbsearchentities&search=${urlQuery}&format=json&language=en&uselang=en&origin=*&type=item&limit=5`
|
|
109
|
-
);
|
|
110
|
-
const searchResults = await wikidataResponse.json();
|
|
111
|
-
|
|
112
|
-
for (const [keyword, facets] of Object.entries(
|
|
113
|
-
WikidataEntityHeuristic.ENTITIES
|
|
114
|
-
)) {
|
|
115
|
-
if (searchResults.search[0]?.description.includes(keyword)) {
|
|
116
|
-
const entityName = searchResults.search[0].label;
|
|
117
|
-
recommendations.push(
|
|
118
|
-
...facets.map(
|
|
119
|
-
sf =>
|
|
120
|
-
({
|
|
121
|
-
label: sf.label?.replace('__QUERY', entityName),
|
|
122
|
-
facets: sf.facets.map(f => {
|
|
123
|
-
const replaced = {
|
|
124
|
-
...f,
|
|
125
|
-
bucketKey: f.bucketKey.replace('__QUERY', query),
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
if (f.displayText) {
|
|
129
|
-
replaced.displayText = replaced.displayText?.replace(
|
|
130
|
-
'__QUERY',
|
|
131
|
-
entityName
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return replaced;
|
|
136
|
-
}),
|
|
137
|
-
} as SmartFacet)
|
|
138
|
-
)
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return recommendations;
|
|
144
|
-
} catch (err) {
|
|
145
|
-
return [];
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { FacetEventDetails, FacetOption } from '../../models';
|
|
2
|
-
|
|
3
|
-
export interface FacetRef {
|
|
4
|
-
facetType: FacetOption;
|
|
5
|
-
bucketKey: string;
|
|
6
|
-
displayText?: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface LabeledSmartFacet {
|
|
10
|
-
label: string;
|
|
11
|
-
facets: FacetRef[];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface UnlabeledSmartFacet {
|
|
15
|
-
label?: string;
|
|
16
|
-
facets: [FacetRef];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type SmartFacet = LabeledSmartFacet | UnlabeledSmartFacet;
|
|
20
|
-
|
|
21
|
-
export interface SmartFacetEvent {
|
|
22
|
-
smartFacet: SmartFacet;
|
|
23
|
-
details: FacetEventDetails[];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type KeywordFacetMap = Record<string, SmartFacet[]>;
|
|
27
|
-
|
|
28
|
-
export interface SmartQueryHeuristic {
|
|
29
|
-
getRecommendedFacets(query: string): Promise<SmartFacet[]>;
|
|
30
|
-
}
|