@fluid-topics/ft-search-result-metadata 1.1.16 → 1.1.17
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.
|
@@ -26,6 +26,7 @@ export declare class FtSearchResultMetadata extends FtSearchResultMetadata_base
|
|
|
26
26
|
setResultStateManager(resultStateManager: FtSearchResultStateManager): void;
|
|
27
27
|
protected render(): import("lit").TemplateResult<1>;
|
|
28
28
|
private renderClusterList;
|
|
29
|
+
private hideIfEmpty;
|
|
29
30
|
private onClusterSelected;
|
|
30
31
|
private computeClusters;
|
|
31
32
|
private renderClusterItem;
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { html } from "lit";
|
|
7
|
+
import { html, nothing } from "lit";
|
|
8
8
|
import { property, state } from "lit/decorators.js";
|
|
9
9
|
import { redux } from "@fluid-topics/ft-wc-utils";
|
|
10
10
|
import { styles } from "./ft-search-result-metadata.css";
|
|
@@ -38,7 +38,10 @@ class FtSearchResultMetadata extends withI18n(FtSearchResultComponent) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
render() {
|
|
41
|
-
return
|
|
41
|
+
return html `
|
|
42
|
+
${this.displayCluster ? this.renderClusterList() : this.renderChip()}
|
|
43
|
+
${this.hideIfEmpty()}
|
|
44
|
+
`;
|
|
42
45
|
}
|
|
43
46
|
renderClusterList() {
|
|
44
47
|
return html `
|
|
@@ -53,6 +56,18 @@ class FtSearchResultMetadata extends withI18n(FtSearchResultComponent) {
|
|
|
53
56
|
</div>
|
|
54
57
|
`;
|
|
55
58
|
}
|
|
59
|
+
hideIfEmpty() {
|
|
60
|
+
if (this.valueText.length == 0 && this.clusters.length == 0 && !this.editorMode) {
|
|
61
|
+
return html `
|
|
62
|
+
<style>
|
|
63
|
+
:host {
|
|
64
|
+
display: none !important;
|
|
65
|
+
}
|
|
66
|
+
</style>
|
|
67
|
+
`;
|
|
68
|
+
}
|
|
69
|
+
return nothing;
|
|
70
|
+
}
|
|
56
71
|
onClusterSelected(e) {
|
|
57
72
|
var _a;
|
|
58
73
|
(_a = this.resultStateManager) === null || _a === void 0 ? void 0 : _a.selectResult(this.clustersByValue[e.detail].result);
|
|
@@ -1104,7 +1104,10 @@ const Pt=Symbol.for(""),Ht=t=>{if(t?.r===Pt)return t?._$litStatic$},Mt=t=>({_$li
|
|
|
1104
1104
|
<slot></slot>
|
|
1105
1105
|
</ft-typography>
|
|
1106
1106
|
</div>
|
|
1107
|
-
`}}function Zr(t){var o,e;return(null!==(e=null!==(o=null==t?void 0:t.map)&&void 0!==o?o:null==t?void 0:t.document)&&void 0!==e?e:null==t?void 0:t.topic).metadata.map((t=>function(t){if(t.hierarchicalValues){const o=[],e=[];return t.hierarchicalValues.forEach((t=>{o.push(t.join(" / ")),t.length>2?e.push(`... / ${t[t.length-1]}`):e.push(t.join(" / "))})),{key:t.key,value:o.join(", "),displayValue:e.join(", ")}}{const o=t.values.join(", ");return{key:t.key,value:o,displayValue:o}}}(t)))}Br.elementDefinitions={"ft-typography":de},Br.styles=Kr,o.customElement("ft-floating-menu")(Wr),o.customElement("ftds-floating-menu")(Ar),o.customElement("ft-floating-menu-item")(kr),o.customElement("ft-floating-menu-label")(Br);class Dr extends CustomEvent{constructor(t,o){super("ft-search-result-click",{detail:{result:t,rank:o},bubbles:!0,composed:!0})}}class Fr{constructor(t,o,e,i){this.cluster=t,this.selectedResult=o,this.clusteringMetadata=e,this.metadataDescriptors=i}computeClustersItemsForMetadata(t,o){var e;const i=null===(e=this.cluster)||void 0===e?void 0:e.entries.flatMap((o=>Zr(o).filter((o=>o.key===t)))).filter(((t,o,e)=>e.findIndex((o=>o.value===t.value))===o));return i.map((o=>({result:this.findMatchingResult(t,o.value),metadata:o}))).sort(((e,i)=>this.compareMetadata(e.metadata.value,i.metadata.value,t,o)))}compareMetadata(t,o,e,i){let r=this.metadataDescriptors.find((t=>e==t.key)),n=(null==r?void 0:r.sortRule)||"NONE",a=(null==r?void 0:r.reverseSort)||!1;if("ALPHABET"==n||"VERSION"==n){let e=t.localeCompare(o,i,{numeric:!0});return a?-1*e:e}return 0}findMatchingResult(t,o){var e,i;let r=Zr(this.selectedResult).filter((t=>this.clusteringMetadata.has(t.key))),n=[...r.filter((o=>o.key!==t)),{key:t,value:o,displayValue:o}];return null!==(i=null!==(e=this.findResultMatchingMetadata(n))&&void 0!==e?e:this.findResultMatchingMetadata([{key:t,value:o,displayValue:o}]))&&void 0!==i?i:this.cluster.entries[0]}findResultMatchingMetadata(t){return this.cluster.entries.find((o=>this.resultMatchesMetadata(o,t)))}resultMatchesMetadata(t,o){let e=Zr(t);return o.every((t=>e.some((o=>o.key==t.key&&o.value==t.value))))}}var Tr=function(t,o,e,i){for(var r,n=arguments.length,a=n<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i,l=t.length-1;l>=0;l--)(r=t[l])&&(a=(n<3?r(a):n>3?r(o,e,a):r(o,e))||a);return n>3&&a&&Object.defineProperty(o,e,a),a};class Pr extends(Q(V)){constructor(){super(),this.useChip=!1,this.useAsClusterSwitch=!1,this.goToDocumentOnSwitch=!1,this.editorMode=!1,this.metadataDescriptors=[],this.clustersByValue={},this.clusters=[],this.addStore(I),this.addI18nContext(nt)}setResultStateManager(t){super.setResultStateManager(t),this.key&&this.useAsClusterSwitch&&t.registerMetadata(this.key)}render(){return
|
|
1107
|
+
`}}function Zr(t){var o,e;return(null!==(e=null!==(o=null==t?void 0:t.map)&&void 0!==o?o:null==t?void 0:t.document)&&void 0!==e?e:null==t?void 0:t.topic).metadata.map((t=>function(t){if(t.hierarchicalValues){const o=[],e=[];return t.hierarchicalValues.forEach((t=>{o.push(t.join(" / ")),t.length>2?e.push(`... / ${t[t.length-1]}`):e.push(t.join(" / "))})),{key:t.key,value:o.join(", "),displayValue:e.join(", ")}}{const o=t.values.join(", ");return{key:t.key,value:o,displayValue:o}}}(t)))}Br.elementDefinitions={"ft-typography":de},Br.styles=Kr,o.customElement("ft-floating-menu")(Wr),o.customElement("ftds-floating-menu")(Ar),o.customElement("ft-floating-menu-item")(kr),o.customElement("ft-floating-menu-label")(Br);class Dr extends CustomEvent{constructor(t,o){super("ft-search-result-click",{detail:{result:t,rank:o},bubbles:!0,composed:!0})}}class Fr{constructor(t,o,e,i){this.cluster=t,this.selectedResult=o,this.clusteringMetadata=e,this.metadataDescriptors=i}computeClustersItemsForMetadata(t,o){var e;const i=null===(e=this.cluster)||void 0===e?void 0:e.entries.flatMap((o=>Zr(o).filter((o=>o.key===t)))).filter(((t,o,e)=>e.findIndex((o=>o.value===t.value))===o));return i.map((o=>({result:this.findMatchingResult(t,o.value),metadata:o}))).sort(((e,i)=>this.compareMetadata(e.metadata.value,i.metadata.value,t,o)))}compareMetadata(t,o,e,i){let r=this.metadataDescriptors.find((t=>e==t.key)),n=(null==r?void 0:r.sortRule)||"NONE",a=(null==r?void 0:r.reverseSort)||!1;if("ALPHABET"==n||"VERSION"==n){let e=t.localeCompare(o,i,{numeric:!0});return a?-1*e:e}return 0}findMatchingResult(t,o){var e,i;let r=Zr(this.selectedResult).filter((t=>this.clusteringMetadata.has(t.key))),n=[...r.filter((o=>o.key!==t)),{key:t,value:o,displayValue:o}];return null!==(i=null!==(e=this.findResultMatchingMetadata(n))&&void 0!==e?e:this.findResultMatchingMetadata([{key:t,value:o,displayValue:o}]))&&void 0!==i?i:this.cluster.entries[0]}findResultMatchingMetadata(t){return this.cluster.entries.find((o=>this.resultMatchesMetadata(o,t)))}resultMatchesMetadata(t,o){let e=Zr(t);return o.every((t=>e.some((o=>o.key==t.key&&o.value==t.value))))}}var Tr=function(t,o,e,i){for(var r,n=arguments.length,a=n<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i,l=t.length-1;l>=0;l--)(r=t[l])&&(a=(n<3?r(a):n>3?r(o,e,a):r(o,e))||a);return n>3&&a&&Object.defineProperty(o,e,a),a};class Pr extends(Q(V)){constructor(){super(),this.useChip=!1,this.useAsClusterSwitch=!1,this.goToDocumentOnSwitch=!1,this.editorMode=!1,this.metadataDescriptors=[],this.clustersByValue={},this.clusters=[],this.addStore(I),this.addI18nContext(nt)}setResultStateManager(t){super.setResultStateManager(t),this.key&&this.useAsClusterSwitch&&t.registerMetadata(this.key)}render(){return e.html`
|
|
1108
|
+
${this.displayCluster?this.renderClusterList():this.renderChip()}
|
|
1109
|
+
${this.hideIfEmpty()}
|
|
1110
|
+
`}renderClusterList(){return e.html`
|
|
1108
1111
|
<div class="ft-search-result-metadata--container">
|
|
1109
1112
|
<ft-floating-menu icon="THIN_ARROW"
|
|
1110
1113
|
@select=${this.onClusterSelected}
|
|
@@ -1114,7 +1117,13 @@ const Pt=Symbol.for(""),Ht=t=>{if(t?.r===Pt)return t?._$litStatic$},Mt=t=>({_$li
|
|
|
1114
1117
|
${a.repeat(this.clusters,(t=>t.metadata.value),(t=>this.renderClusterItem(t.result,t.metadata)))}
|
|
1115
1118
|
</ft-floating-menu>
|
|
1116
1119
|
</div>
|
|
1117
|
-
`}
|
|
1120
|
+
`}hideIfEmpty(){return 0!=this.valueText.length||0!=this.clusters.length||this.editorMode?e.nothing:e.html`
|
|
1121
|
+
<style>
|
|
1122
|
+
:host {
|
|
1123
|
+
display: none !important;
|
|
1124
|
+
}
|
|
1125
|
+
</style>
|
|
1126
|
+
`}onClusterSelected(t){var o;null===(o=this.resultStateManager)||void 0===o||o.selectResult(this.clustersByValue[t.detail].result)}computeClusters(){var t;const o={},e=new Fr(this.cluster,this.result,this.resultStateManager.registeredMetadata,this.metadataDescriptors);this.clusters=e.computeClustersItemsForMetadata(this.key,(null===(t=this.request)||void 0===t?void 0:t.contentLocale)||"en"),this.clusters.forEach((t=>{o[t.metadata.value]=t})),this.clustersByValue=o}renderClusterItem(t,o){return this.goToDocumentOnSwitch?e.html`
|
|
1118
1127
|
<a href="${function(t){switch(t.type){case N.MAP:return t.map.readerUrl;case N.DOCUMENT:return t.document.viewerUrl;case N.TOPIC:return t.topic.readerUrl}return""}(t)}" @click=${()=>this.onResultClick(t)}>
|
|
1119
1128
|
<ft-floating-menu-item value="${o.value}">${this.renderClusterItemValue(o.value,o.displayValue)}
|
|
1120
1129
|
</ft-floating-menu-item>
|
|
@@ -1255,7 +1255,10 @@ class zs extends ks{constructor(t){if(super(t),this.et=rt,t.type!==$s)throw Erro
|
|
|
1255
1255
|
* @license
|
|
1256
1256
|
* Copyright 2017 Google LLC
|
|
1257
1257
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
1258
|
-
*/var ic=function(t,e,o,i){for(var r,n=arguments.length,a=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i,s=t.length-1;s>=0;s--)(r=t[s])&&(a=(n<3?r(a):n>3?r(e,o,a):r(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a};class rc extends(zr(Mr)){constructor(){super(),this.useChip=!1,this.useAsClusterSwitch=!1,this.goToDocumentOnSwitch=!1,this.editorMode=!1,this.metadataDescriptors=[],this.clustersByValue={},this.clusters=[],this.addStore(gr),this.addI18nContext(Vr)}setResultStateManager(t){super.setResultStateManager(t),this.key&&this.useAsClusterSwitch&&t.registerMetadata(this.key)}render(){return
|
|
1258
|
+
*/var ic=function(t,e,o,i){for(var r,n=arguments.length,a=n<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i,s=t.length-1;s>=0;s--)(r=t[s])&&(a=(n<3?r(a):n>3?r(e,o,a):r(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a};class rc extends(zr(Mr)){constructor(){super(),this.useChip=!1,this.useAsClusterSwitch=!1,this.goToDocumentOnSwitch=!1,this.editorMode=!1,this.metadataDescriptors=[],this.clustersByValue={},this.clusters=[],this.addStore(gr),this.addI18nContext(Vr)}setResultStateManager(t){super.setResultStateManager(t),this.key&&this.useAsClusterSwitch&&t.registerMetadata(this.key)}render(){return le`
|
|
1259
|
+
${this.displayCluster?this.renderClusterList():this.renderChip()}
|
|
1260
|
+
${this.hideIfEmpty()}
|
|
1261
|
+
`}renderClusterList(){return le`
|
|
1259
1262
|
<div class="ft-search-result-metadata--container">
|
|
1260
1263
|
<ft-floating-menu icon="THIN_ARROW"
|
|
1261
1264
|
@select=${this.onClusterSelected}
|
|
@@ -1265,7 +1268,13 @@ class zs extends ks{constructor(t){if(super(t),this.et=rt,t.type!==$s)throw Erro
|
|
|
1265
1268
|
${oc(this.clusters,(t=>t.metadata.value),(t=>this.renderClusterItem(t.result,t.metadata)))}
|
|
1266
1269
|
</ft-floating-menu>
|
|
1267
1270
|
</div>
|
|
1268
|
-
`}
|
|
1271
|
+
`}hideIfEmpty(){return 0!=this.valueText.length||0!=this.clusters.length||this.editorMode?fe:le`
|
|
1272
|
+
<style>
|
|
1273
|
+
:host {
|
|
1274
|
+
display: none !important;
|
|
1275
|
+
}
|
|
1276
|
+
</style>
|
|
1277
|
+
`}onClusterSelected(t){var e;null===(e=this.resultStateManager)||void 0===e||e.selectResult(this.clustersByValue[t.detail].result)}computeClusters(){var t;const e={},o=new Vl(this.cluster,this.result,this.resultStateManager.registeredMetadata,this.metadataDescriptors);this.clusters=o.computeClustersItemsForMetadata(this.key,(null===(t=this.request)||void 0===t?void 0:t.contentLocale)||"en"),this.clusters.forEach((t=>{e[t.metadata.value]=t})),this.clustersByValue=e}renderClusterItem(t,e){return this.goToDocumentOnSwitch?le`
|
|
1269
1278
|
<a href="${function(t){switch(t.type){case hr.MAP:return t.map.readerUrl;case hr.DOCUMENT:return t.document.viewerUrl;case hr.TOPIC:return t.topic.readerUrl}return""}(t)}" @click=${()=>this.onResultClick(t)}>
|
|
1270
1279
|
<ft-floating-menu-item value="${e.value}">${this.renderClusterItemValue(e.value,e.displayValue)}
|
|
1271
1280
|
</ft-floating-menu-item>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-search-result-metadata",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.17",
|
|
4
4
|
"description": "Search result metadata for integrated search component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-chip": "1.1.
|
|
23
|
-
"@fluid-topics/ft-floating-menu": "1.1.
|
|
24
|
-
"@fluid-topics/ft-search-result-context": "1.1.
|
|
25
|
-
"@fluid-topics/ft-tooltip": "1.1.
|
|
26
|
-
"@fluid-topics/ft-wc-utils": "1.1.
|
|
22
|
+
"@fluid-topics/ft-chip": "1.1.17",
|
|
23
|
+
"@fluid-topics/ft-floating-menu": "1.1.17",
|
|
24
|
+
"@fluid-topics/ft-search-result-context": "1.1.17",
|
|
25
|
+
"@fluid-topics/ft-tooltip": "1.1.17",
|
|
26
|
+
"@fluid-topics/ft-wc-utils": "1.1.17",
|
|
27
27
|
"lit": "3.1.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@fluid-topics/public-api": "1.0.54"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "a8c1d6ed00e2cad51f1e81aa0486f251050db54d"
|
|
33
33
|
}
|