@eox/itemfilter 1.10.1 → 1.10.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.
package/dist/eox-itemfilter.js
CHANGED
|
@@ -4477,18 +4477,16 @@ function id(t, e) {
|
|
|
4477
4477
|
}
|
|
4478
4478
|
function nd(t, e) {
|
|
4479
4479
|
var i;
|
|
4480
|
-
const r = ((i = t.filterObject) == null ? void 0 : i.sort) || ((n, o) => n.localeCompare(o));
|
|
4480
|
+
const r = ((i = t.filterObject) == null ? void 0 : i.sort) || ((n, o) => n.toString().localeCompare(o.toString(), void 0, { numeric: !0 }));
|
|
4481
4481
|
return e.sort(r).map((n) => n);
|
|
4482
4482
|
}
|
|
4483
4483
|
function mo(t) {
|
|
4484
|
-
var
|
|
4485
|
-
|
|
4486
|
-
|
|
4484
|
+
var i, n, o;
|
|
4485
|
+
const e = (((i = t.filterObject) == null ? void 0 : i.filterKeys) || t.suggestions).map((a) => `${a}`);
|
|
4486
|
+
let r = e;
|
|
4487
|
+
t.query && (r = new Gt(e, {
|
|
4487
4488
|
threshold: 0.4
|
|
4488
|
-
}).search(t.query).map((
|
|
4489
|
-
t,
|
|
4490
|
-
e || t.suggestions
|
|
4491
|
-
), (r = t.filterObject) != null && r.filterKeys && (t.filteredSuggestions = (i = t.filterObject) == null ? void 0 : i.filterKeys.map((o) => `${o}`), t.filterObject.state = (n = t.filterObject) == null ? void 0 : n.filterKeys.map((o) => `${o}`).reduce((o, a) => (a in o || (o[a] = void 0), o), t.filterObject.state)), t.highlightedIndex = -1;
|
|
4489
|
+
}).search(t.query).map((l) => l.item)), t.filteredSuggestions = (n = t.filterObject) != null && n.filterKeys ? r : nd(t, r), (o = t.filterObject) != null && o.filterKeys && (t.filterObject.state = e.reduce((a, l) => (l in a || (a[l] = void 0), a), t.filterObject.state)), t.highlightedIndex = -1;
|
|
4492
4490
|
}
|
|
4493
4491
|
function Ua(t) {
|
|
4494
4492
|
Object.keys(t.filterObject.state).forEach((e) => {
|
|
@@ -5107,7 +5105,7 @@ class Ja extends tt {
|
|
|
5107
5105
|
}
|
|
5108
5106
|
</style>
|
|
5109
5107
|
${qe(
|
|
5110
|
-
this.suggestions.length
|
|
5108
|
+
(this.filterObject.filterKeys || this.suggestions).length >= 10,
|
|
5111
5109
|
() => V`<div class="autocomplete-container">
|
|
5112
5110
|
<div
|
|
5113
5111
|
class="autocomplete-container-wrapper field small no-round"
|
|
@@ -642,7 +642,7 @@ input {
|
|
|
642
642
|
</div>
|
|
643
643
|
</div>
|
|
644
644
|
`:V`<slot name="section"></slot>`}
|
|
645
|
-
`}}ze=new WeakSet,Ja=function(){setTimeout(()=>this._overlayCleanup=Il(this))},co=function(){document.addEventListener("click",this._handleClickOutside),document.addEventListener("focusout",this._handleClickOutside),document.addEventListener("keydown",this._handleKeyDown),fe(this,ze,Ja).call(this)},uo=function(){document.removeEventListener("click",this._handleClickOutside),document.removeEventListener("focusout",this._handleClickOutside),document.removeEventListener("keydown",this._handleKeyDown),this._overlayCleanup()},Za=function(r){Vl(r,this)},po=function(r){Wl(r,this)},fo=function(r){Fl(r,this)},Qa=function(){Ul(this)},ho=function(r){ql(r,this)},es=function(r){gl(r,this)},ts=function(r){Ko(r,this)},customElements.define("eox-itemfilter-container",Hc);var Wn,Ma;function Ic(){if(Ma)return Wn;Ma=1;var t="Expected a function",e=NaN,r="[object Symbol]",i=/^\s+|\s+$/g,n=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,a=/^0o[0-7]+$/i,l=parseInt,c=typeof ht=="object"&&ht&&ht.Object===Object&&ht,d=typeof self=="object"&&self&&self.Object===Object&&self,m=c||d||Function("return this")(),g=Object.prototype,w=g.toString,b=Math.max,$=Math.min,C=function(){return m.Date.now()};function F(R,le,ne){var ke,_e,he,ee,ye,Ue,E=0,M=!1,z=!1,N=!0;if(typeof R!="function")throw new TypeError(t);le=se(le)||0,q(ne)&&(M=!!ne.leading,z="maxWait"in ne,he=z?b(se(ne.maxWait)||0,le):he,N="trailing"in ne?!!ne.trailing:N);function L(j){var Oe=ke,Se=_e;return ke=_e=void 0,E=j,ee=R.apply(Se,Oe),ee}function Y(j){return E=j,ye=setTimeout(me,le),M?L(j):ee}function K(j){var Oe=j-Ue,Se=j-E,G=le-Oe;return z?$(G,he-Se):G}function ie(j){var Oe=j-Ue,Se=j-E;return Ue===void 0||Oe>=le||Oe<0||z&&Se>=he}function me(){var j=C();if(ie(j))return Me(j);ye=setTimeout(me,K(j))}function Me(j){return ye=void 0,N&&ke?L(j):(ke=_e=void 0,ee)}function Pe(){ye!==void 0&&clearTimeout(ye),E=0,ke=Ue=_e=ye=void 0}function Ie(){return ye===void 0?ee:Me(C())}function Ce(){var j=C(),Oe=ie(j);if(ke=arguments,_e=this,Ue=j,Oe){if(ye===void 0)return Y(Ue);if(z)return ye=setTimeout(me,le),L(Ue)}return ye===void 0&&(ye=setTimeout(me,le)),ee}return Ce.cancel=Pe,Ce.flush=Ie,Ce}function q(R){var le=typeof R;return!!R&&(le=="object"||le=="function")}function ae(R){return!!R&&typeof R=="object"}function te(R){return typeof R=="symbol"||ae(R)&&w.call(R)==r}function se(R){if(typeof R=="number")return R;if(te(R))return e;if(q(R)){var le=typeof R.valueOf=="function"?R.valueOf():R;R=q(le)?le+"":le}if(typeof R!="string")return R===0?R:+R;R=R.replace(i,"");var ne=o.test(R);return ne||a.test(R)?l(R.slice(2),ne?2:8):n.test(R)?e:+R}return Wn=F,Wn}var qc=Ic();const Xi=Yi(qc);function Uc(t){const e=t.renderRoot.querySelector("input[type='text']");e.value="",Gi(t.filterObject),t.requestUpdate()}function Fc(t){const e=t.renderRoot.querySelector("input[type='text']");t.isValid=e.checkValidity(),t.filterObject.keys.forEach(r=>{t.filterObject.state[r]=e.value}),t.filterObject.dirty=!0,t.filterObject.stringifiedState=e.value,t.dispatchEvent(new CustomEvent("filter")),e.value===""&&t.reset()}const Vn="ddd, D MMM YYYY HH:mm:ss";function Wc(t){if(t.filterObject=Gi(t.filterObject),t.filterObject){const e=t.querySelector("tc-range-slider"),r=t.filterObject.min,i=t.filterObject.max;e.value1!==r&&(e.value1=r),e.value2!==i&&(e.value2=i)}t.requestUpdate()}function Vc(t,e){const[r,i]=t.detail.values;(r!==e.filterObject.state.min||i!==e.filterObject.state.max)&&([e.filterObject.state.min,e.filterObject.state.max]=[r,i],e.filterObject.dirty=!0),e.filterObject.dirty&&(e.filterObject.stringifiedState=e.filterObject.format==="date"?`${ni.unix(r).format(Vn)} - ${ni.unix(i).format(Vn)}`:`${r} - ${i}`),e.dispatchEvent(new CustomEvent("filter")),r===e.filterObject.min&&i===e.filterObject.max?e.reset():e.requestUpdate()}function Yc(t,e,r){const i=r.filterObject.format==="date",n=r.filterObject.state[t],o=i?ni.unix(n).format(Vn):n;return V`<div class="range-${e}">${o}</div>`}function Kc(t){Gc(-1,t),Gi(t.filterObject),t.requestUpdate()}function Gc(t,e){e.selectedItems=[],Yn(e),Ca(e)}function Sa(t,e){const r=e.selectedItems.indexOf(t);r>=0?e.selectedItems=e.selectedItems.filter((i,n)=>n!==r):e.type==="multiselect"?e.selectedItems=[...e.selectedItems,t]:(e.selectedItems=[t],e.showSuggestions=!1),Yn(e),Ca(e)}function Xc(t,e){t.target instanceof HTMLInputElement&&(e.query=t.target.value,e.showSuggestions=!0)}function Jc(t,e){switch(t.key){case"ArrowDown":e.highlightedIndex=Math.min(e.highlightedIndex+1,e.filteredSuggestions.length-1);break;case"ArrowUp":e.highlightedIndex=Math.max(e.highlightedIndex-1,0);break;case"Enter":e.highlightedIndex>=0&&Sa(e.filteredSuggestions[e.highlightedIndex],e);break;case"Escape":e.showSuggestions=!1;break}}function Zc(t,e){(t.has("suggestions")||t.has("query"))&&Yn(e)}function Qc(t,e){var i;const r=((i=t.filterObject)==null?void 0:i.sort)||((n,o)=>n.localeCompare(o));return e.sort(r).map(n=>n)}function Yn(t){var
|
|
645
|
+
`}}ze=new WeakSet,Ja=function(){setTimeout(()=>this._overlayCleanup=Il(this))},co=function(){document.addEventListener("click",this._handleClickOutside),document.addEventListener("focusout",this._handleClickOutside),document.addEventListener("keydown",this._handleKeyDown),fe(this,ze,Ja).call(this)},uo=function(){document.removeEventListener("click",this._handleClickOutside),document.removeEventListener("focusout",this._handleClickOutside),document.removeEventListener("keydown",this._handleKeyDown),this._overlayCleanup()},Za=function(r){Vl(r,this)},po=function(r){Wl(r,this)},fo=function(r){Fl(r,this)},Qa=function(){Ul(this)},ho=function(r){ql(r,this)},es=function(r){gl(r,this)},ts=function(r){Ko(r,this)},customElements.define("eox-itemfilter-container",Hc);var Wn,Ma;function Ic(){if(Ma)return Wn;Ma=1;var t="Expected a function",e=NaN,r="[object Symbol]",i=/^\s+|\s+$/g,n=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,a=/^0o[0-7]+$/i,l=parseInt,c=typeof ht=="object"&&ht&&ht.Object===Object&&ht,d=typeof self=="object"&&self&&self.Object===Object&&self,m=c||d||Function("return this")(),g=Object.prototype,w=g.toString,b=Math.max,$=Math.min,C=function(){return m.Date.now()};function F(R,le,ne){var ke,_e,he,ee,ye,Ue,E=0,M=!1,z=!1,N=!0;if(typeof R!="function")throw new TypeError(t);le=se(le)||0,q(ne)&&(M=!!ne.leading,z="maxWait"in ne,he=z?b(se(ne.maxWait)||0,le):he,N="trailing"in ne?!!ne.trailing:N);function L(j){var Oe=ke,Se=_e;return ke=_e=void 0,E=j,ee=R.apply(Se,Oe),ee}function Y(j){return E=j,ye=setTimeout(me,le),M?L(j):ee}function K(j){var Oe=j-Ue,Se=j-E,G=le-Oe;return z?$(G,he-Se):G}function ie(j){var Oe=j-Ue,Se=j-E;return Ue===void 0||Oe>=le||Oe<0||z&&Se>=he}function me(){var j=C();if(ie(j))return Me(j);ye=setTimeout(me,K(j))}function Me(j){return ye=void 0,N&&ke?L(j):(ke=_e=void 0,ee)}function Pe(){ye!==void 0&&clearTimeout(ye),E=0,ke=Ue=_e=ye=void 0}function Ie(){return ye===void 0?ee:Me(C())}function Ce(){var j=C(),Oe=ie(j);if(ke=arguments,_e=this,Ue=j,Oe){if(ye===void 0)return Y(Ue);if(z)return ye=setTimeout(me,le),L(Ue)}return ye===void 0&&(ye=setTimeout(me,le)),ee}return Ce.cancel=Pe,Ce.flush=Ie,Ce}function q(R){var le=typeof R;return!!R&&(le=="object"||le=="function")}function ae(R){return!!R&&typeof R=="object"}function te(R){return typeof R=="symbol"||ae(R)&&w.call(R)==r}function se(R){if(typeof R=="number")return R;if(te(R))return e;if(q(R)){var le=typeof R.valueOf=="function"?R.valueOf():R;R=q(le)?le+"":le}if(typeof R!="string")return R===0?R:+R;R=R.replace(i,"");var ne=o.test(R);return ne||a.test(R)?l(R.slice(2),ne?2:8):n.test(R)?e:+R}return Wn=F,Wn}var qc=Ic();const Xi=Yi(qc);function Uc(t){const e=t.renderRoot.querySelector("input[type='text']");e.value="",Gi(t.filterObject),t.requestUpdate()}function Fc(t){const e=t.renderRoot.querySelector("input[type='text']");t.isValid=e.checkValidity(),t.filterObject.keys.forEach(r=>{t.filterObject.state[r]=e.value}),t.filterObject.dirty=!0,t.filterObject.stringifiedState=e.value,t.dispatchEvent(new CustomEvent("filter")),e.value===""&&t.reset()}const Vn="ddd, D MMM YYYY HH:mm:ss";function Wc(t){if(t.filterObject=Gi(t.filterObject),t.filterObject){const e=t.querySelector("tc-range-slider"),r=t.filterObject.min,i=t.filterObject.max;e.value1!==r&&(e.value1=r),e.value2!==i&&(e.value2=i)}t.requestUpdate()}function Vc(t,e){const[r,i]=t.detail.values;(r!==e.filterObject.state.min||i!==e.filterObject.state.max)&&([e.filterObject.state.min,e.filterObject.state.max]=[r,i],e.filterObject.dirty=!0),e.filterObject.dirty&&(e.filterObject.stringifiedState=e.filterObject.format==="date"?`${ni.unix(r).format(Vn)} - ${ni.unix(i).format(Vn)}`:`${r} - ${i}`),e.dispatchEvent(new CustomEvent("filter")),r===e.filterObject.min&&i===e.filterObject.max?e.reset():e.requestUpdate()}function Yc(t,e,r){const i=r.filterObject.format==="date",n=r.filterObject.state[t],o=i?ni.unix(n).format(Vn):n;return V`<div class="range-${e}">${o}</div>`}function Kc(t){Gc(-1,t),Gi(t.filterObject),t.requestUpdate()}function Gc(t,e){e.selectedItems=[],Yn(e),Ca(e)}function Sa(t,e){const r=e.selectedItems.indexOf(t);r>=0?e.selectedItems=e.selectedItems.filter((i,n)=>n!==r):e.type==="multiselect"?e.selectedItems=[...e.selectedItems,t]:(e.selectedItems=[t],e.showSuggestions=!1),Yn(e),Ca(e)}function Xc(t,e){t.target instanceof HTMLInputElement&&(e.query=t.target.value,e.showSuggestions=!0)}function Jc(t,e){switch(t.key){case"ArrowDown":e.highlightedIndex=Math.min(e.highlightedIndex+1,e.filteredSuggestions.length-1);break;case"ArrowUp":e.highlightedIndex=Math.max(e.highlightedIndex-1,0);break;case"Enter":e.highlightedIndex>=0&&Sa(e.filteredSuggestions[e.highlightedIndex],e);break;case"Escape":e.showSuggestions=!1;break}}function Zc(t,e){(t.has("suggestions")||t.has("query"))&&Yn(e)}function Qc(t,e){var i;const r=((i=t.filterObject)==null?void 0:i.sort)||((n,o)=>n.toString().localeCompare(o.toString(),void 0,{numeric:!0}));return e.sort(r).map(n=>n)}function Yn(t){var i,n,o;const e=(((i=t.filterObject)==null?void 0:i.filterKeys)||t.suggestions).map(a=>`${a}`);let r=e;t.query&&(r=new qt(e,{threshold:.4}).search(t.query).map(l=>l.item)),t.filteredSuggestions=(n=t.filterObject)!=null&&n.filterKeys?r:Qc(t,r),(o=t.filterObject)!=null&&o.filterKeys&&(t.filterObject.state=e.reduce((a,l)=>(l in a||(a[l]=void 0),a),t.filterObject.state)),t.highlightedIndex=-1}function Ca(t){Object.keys(t.filterObject.state).forEach(e=>{t.filterObject.state[e]=t.selectedItems.includes(e)}),t.filterObject.stringifiedState=Object.keys(t.filterObject.state).filter(e=>t.filterObject.state[e]).join(", ")||"",t.filterObject.dirty=t.filterObject.stringifiedState.length>0,t.dispatchEvent(new CustomEvent("filter")),t.requestUpdate()}function ed(t){Gi(t.filterObject),t.renderRoot.querySelector("eox-itemfilter-spatial-filter").reset(),t.requestUpdate()}function td(t){t.renderRoot.querySelector("#eox-map").innerHTML="",La(t)}function rd(t,e){e.filterObject.state.mode=t;const r=new CustomEvent("filter",{detail:{[e.filterObject.key]:{}}});e.dispatchEvent(r)}function La(t){const e=t.renderRoot.querySelector("#eox-map");e.innerHTML===""&&(e.innerHTML='<eox-map part="map" style="height: 400px"></eox-map>');const r=t.geometry&&id(t.geometry),i=jc(t.geometry,r);t.eoxMap=t.renderRoot.querySelector("eox-map"),setTimeout(()=>{t.eoxMap.layers=i;const n=o=>{const a=new CustomEvent("filter",{detail:{geometry:{type:"Polygon",coordinates:o.getGeometry().clone().transform("EPSG:3857","EPSG:4326").getCoordinates()}}});t.dispatchEvent(a)};t.eoxMap.interactions.drawInteraction.on("drawend",o=>{n(o.feature),t.eoxMap.removeInteraction("drawInteraction")}),t.eoxMap.interactions.drawInteraction_modify.on("modifyend",o=>{n(o.features.getArray()[0])})},1e3)}function id(t){return`data:text/json,${encodeURIComponent(JSON.stringify({type:"FeatureCollection",features:[{type:"Feature",properties:null,geometry:t}]}))}`}class nd extends tt{constructor(){super();nt(this,Qi,()=>{Fc(this)});Ci(this,"debouncedInputHandler",Xi(pt(this,Qi),500,{leading:!0}));this.filterObject={},this.unstyled=!1,this.tabIndex=0,this.isValid=!1}static get properties(){return{filterObject:{attribute:!1,type:Object},tabIndex:{attribute:!1,type:Number},unstyled:{type:Boolean},isValid:{state:!0,type:Boolean}}}reset(){Uc(this)}createRenderRoot(){return this}render(){return Fe(this.filterObject,()=>{var r;return V`
|
|
646
646
|
<style></style>
|
|
647
647
|
<div class="text-container">
|
|
648
648
|
<div
|
|
@@ -813,7 +813,7 @@ input {
|
|
|
813
813
|
--select-filter-max-items: 5;
|
|
814
814
|
}
|
|
815
815
|
</style>
|
|
816
|
-
${Fe(this.suggestions.length
|
|
816
|
+
${Fe((this.filterObject.filterKeys||this.suggestions).length>=10,()=>V`<div class="autocomplete-container">
|
|
817
817
|
<div
|
|
818
818
|
class="autocomplete-container-wrapper field small no-round"
|
|
819
819
|
style="margin-left: var(--list-padding)"
|
package/package.json
CHANGED
|
@@ -140,7 +140,9 @@ export function updatedSelectorMethod(
|
|
|
140
140
|
*/
|
|
141
141
|
function getSortedSuggestions(EOxItemFilterSelector, suggestion) {
|
|
142
142
|
const sortCallback =
|
|
143
|
-
EOxItemFilterSelector.filterObject?.sort ||
|
|
143
|
+
EOxItemFilterSelector.filterObject?.sort ||
|
|
144
|
+
((a, b) =>
|
|
145
|
+
a.toString().localeCompare(b.toString(), undefined, { numeric: true }));
|
|
144
146
|
|
|
145
147
|
return suggestion.sort(sortCallback).map((i) => i);
|
|
146
148
|
}
|
|
@@ -151,33 +153,34 @@ function getSortedSuggestions(EOxItemFilterSelector, suggestion) {
|
|
|
151
153
|
* @param {Object} EOxItemFilterSelector - The EOxItemFilterSelector component instance.
|
|
152
154
|
*/
|
|
153
155
|
function updateSuggestions(EOxItemFilterSelector) {
|
|
154
|
-
|
|
156
|
+
const items = (
|
|
157
|
+
EOxItemFilterSelector.filterObject?.filterKeys ||
|
|
158
|
+
EOxItemFilterSelector.suggestions
|
|
159
|
+
).map((i) => `${i}`);
|
|
160
|
+
let filteredSuggestion = items;
|
|
161
|
+
|
|
155
162
|
if (EOxItemFilterSelector.query) {
|
|
156
|
-
const fuse = new Fuse(
|
|
163
|
+
const fuse = new Fuse(items, {
|
|
157
164
|
threshold: 0.4,
|
|
158
165
|
});
|
|
159
166
|
filteredSuggestion = fuse
|
|
160
167
|
.search(EOxItemFilterSelector.query)
|
|
161
168
|
.map((result) => result.item);
|
|
162
169
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
170
|
+
|
|
171
|
+
EOxItemFilterSelector.filteredSuggestions = EOxItemFilterSelector.filterObject
|
|
172
|
+
?.filterKeys
|
|
173
|
+
? filteredSuggestion
|
|
174
|
+
: getSortedSuggestions(EOxItemFilterSelector, filteredSuggestion);
|
|
167
175
|
|
|
168
176
|
// if `filterKeys` is defined, force filter keys
|
|
169
177
|
if (EOxItemFilterSelector.filterObject?.filterKeys) {
|
|
170
|
-
EOxItemFilterSelector.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (!(curr in acc)) {
|
|
177
|
-
acc[curr] = undefined;
|
|
178
|
-
}
|
|
179
|
-
return acc;
|
|
180
|
-
}, EOxItemFilterSelector.filterObject.state);
|
|
178
|
+
EOxItemFilterSelector.filterObject.state = items.reduce((acc, curr) => {
|
|
179
|
+
if (!(curr in acc)) {
|
|
180
|
+
acc[curr] = undefined;
|
|
181
|
+
}
|
|
182
|
+
return acc;
|
|
183
|
+
}, EOxItemFilterSelector.filterObject.state);
|
|
181
184
|
}
|
|
182
185
|
|
|
183
186
|
EOxItemFilterSelector.highlightedIndex = -1;
|