@eox/itemfilter 1.18.0 → 1.19.0
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 +1714 -1694
- package/dist/eox-itemfilter.umd.cjs +125 -121
- package/package.json +3 -3
- package/src/components/chips.js +3 -3
- package/src/components/expand-container.js +27 -4
- package/src/components/filters/range.js +8 -5
- package/src/components/filters/selector.js +10 -10
- package/src/components/filters/spatial.js +8 -8
- package/src/components/filters/text.js +4 -4
- package/src/components/itemfilter-container.js +6 -6
- package/src/components/results.js +5 -5
- package/src/helpers/chip-items.js +2 -2
- package/src/helpers/filter-client.js +6 -6
- package/src/helpers/filter-external.js +4 -4
- package/src/helpers/get-value.js +1 -1
- package/src/helpers/highlighting.js +2 -2
- package/src/helpers/is-date.js +1 -1
- package/src/helpers/is-filters-dirty.js +1 -1
- package/src/helpers/map-layers.js +2 -2
- package/src/helpers/merge-highlight-indices.js +1 -1
- package/src/helpers/reset-filter.js +2 -2
- package/src/helpers/spatial.js +4 -4
- package/src/helpers/toggle-accordion.js +1 -1
- package/src/main.js +48 -40
- package/src/methods/chips/handler.js +4 -4
- package/src/methods/container/handler.js +6 -6
- package/src/methods/container/init-popver.js +2 -2
- package/src/methods/container/inline-search.js +4 -4
- package/src/methods/container/reset-filter.js +1 -1
- package/src/methods/container/reset-search.js +1 -1
- package/src/methods/container/search-filter.js +1 -1
- package/src/methods/filters/range.js +2 -2
- package/src/methods/filters/selector.js +26 -18
- package/src/methods/filters/spatial.js +5 -5
- package/src/methods/filters/text.js +3 -3
- package/src/methods/itemfilter/create-filter.js +6 -6
- package/src/methods/itemfilter/create-reset.js +3 -3
- package/src/methods/itemfilter/filter-apply.js +3 -3
- package/src/methods/itemfilter/reset-filter.js +4 -3
- package/src/methods/itemfilter/search.js +3 -3
- package/src/methods/itemfilter/sort-results.js +4 -4
- package/src/methods/results/aggregate-results.js +3 -3
- package/src/methods/results/create.js +2 -2
- package/types/components/chips.d.ts +3 -3
- package/types/components/expand-container.d.ts +3 -3
- package/types/components/expand-container.d.ts.map +1 -1
- package/types/components/filters/range.d.ts +3 -3
- package/types/components/filters/range.d.ts.map +1 -1
- package/types/components/filters/selector.d.ts +9 -9
- package/types/components/filters/spatial.d.ts +7 -7
- package/types/components/filters/spatial.d.ts.map +1 -1
- package/types/components/filters/text.d.ts +4 -4
- package/types/components/itemfilter-container.d.ts +6 -6
- package/types/components/results.d.ts +5 -5
- package/types/helpers/chip-items.d.ts +3 -3
- package/types/helpers/chip-items.d.ts.map +1 -1
- package/types/helpers/filter-client.d.ts +2 -2
- package/types/helpers/filter-client.d.ts.map +1 -1
- package/types/helpers/filter-external.d.ts +5 -5
- package/types/helpers/filter-external.d.ts.map +1 -1
- package/types/helpers/get-value.d.ts +2 -2
- package/types/helpers/get-value.d.ts.map +1 -1
- package/types/helpers/highlighting.d.ts +3 -3
- package/types/helpers/highlighting.d.ts.map +1 -1
- package/types/helpers/is-date.d.ts +2 -2
- package/types/helpers/is-date.d.ts.map +1 -1
- package/types/helpers/is-filters-dirty.d.ts +2 -2
- package/types/helpers/is-filters-dirty.d.ts.map +1 -1
- package/types/helpers/map-layers.d.ts +3 -3
- package/types/helpers/map-layers.d.ts.map +1 -1
- package/types/helpers/merge-highlight-indices.d.ts +1 -1
- package/types/helpers/reset-filter.d.ts +3 -3
- package/types/helpers/reset-filter.d.ts.map +1 -1
- package/types/helpers/spatial.d.ts +2 -2
- package/types/helpers/spatial.d.ts.map +1 -1
- package/types/helpers/toggle-accordion.d.ts +2 -2
- package/types/helpers/toggle-accordion.d.ts.map +1 -1
- package/types/main.d.ts +15 -11
- package/types/main.d.ts.map +1 -1
- package/types/methods/chips/handler.d.ts +6 -6
- package/types/methods/chips/handler.d.ts.map +1 -1
- package/types/methods/container/handler.d.ts +12 -12
- package/types/methods/container/handler.d.ts.map +1 -1
- package/types/methods/container/init-popver.d.ts +3 -3
- package/types/methods/container/init-popver.d.ts.map +1 -1
- package/types/methods/container/inline-search.d.ts +7 -7
- package/types/methods/container/inline-search.d.ts.map +1 -1
- package/types/methods/container/reset-filter.d.ts +2 -2
- package/types/methods/container/reset-filter.d.ts.map +1 -1
- package/types/methods/container/reset-search.d.ts +2 -2
- package/types/methods/container/reset-search.d.ts.map +1 -1
- package/types/methods/container/search-filter.d.ts +2 -2
- package/types/methods/container/search-filter.d.ts.map +1 -1
- package/types/methods/filters/range.d.ts +4 -4
- package/types/methods/filters/range.d.ts.map +1 -1
- package/types/methods/filters/selector.d.ts +15 -14
- package/types/methods/filters/selector.d.ts.map +1 -1
- package/types/methods/filters/spatial.d.ts +8 -8
- package/types/methods/filters/spatial.d.ts.map +1 -1
- package/types/methods/filters/text.d.ts +6 -6
- package/types/methods/filters/text.d.ts.map +1 -1
- package/types/methods/itemfilter/create-filter.d.ts +3 -3
- package/types/methods/itemfilter/create-filter.d.ts.map +1 -1
- package/types/methods/itemfilter/create-reset.d.ts +3 -3
- package/types/methods/itemfilter/create-reset.d.ts.map +1 -1
- package/types/methods/itemfilter/filter-apply.d.ts +4 -4
- package/types/methods/itemfilter/filter-apply.d.ts.map +1 -1
- package/types/methods/itemfilter/reset-filter.d.ts +3 -2
- package/types/methods/itemfilter/reset-filter.d.ts.map +1 -1
- package/types/methods/itemfilter/search.d.ts +4 -4
- package/types/methods/itemfilter/search.d.ts.map +1 -1
- package/types/methods/itemfilter/sort-results.d.ts +6 -6
- package/types/methods/itemfilter/sort-results.d.ts.map +1 -1
- package/types/methods/results/aggregate-results.d.ts +4 -4
- package/types/methods/results/aggregate-results.d.ts.map +1 -1
- package/types/methods/results/create.d.ts +4 -4
- package/types/methods/results/create.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eox/itemfilter",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@types/geojson": "^7946.0.14",
|
|
11
11
|
"@types/lodash.debounce": "^4.0.7",
|
|
12
|
-
"vite": "^8.
|
|
12
|
+
"vite": "^8.3.5"
|
|
13
13
|
},
|
|
14
14
|
"engines": {
|
|
15
15
|
"npm": ">=8.0.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"watch": "vite build --watch"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@eox/elements-utils": "^1.
|
|
42
|
+
"@eox/elements-utils": "^1.3.0",
|
|
43
43
|
"@eox/ui": "^1.1.0",
|
|
44
44
|
"@floating-ui/dom": "^1.8.0",
|
|
45
45
|
"@turf/boolean-intersects": "^7.4.0",
|
package/src/components/chips.js
CHANGED
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
* close events, and keyboard events.
|
|
12
12
|
*
|
|
13
13
|
* @module EOxItemFilterChips
|
|
14
|
-
* @
|
|
15
|
-
* @property {
|
|
16
|
-
* @property {
|
|
14
|
+
* @augments LitElement
|
|
15
|
+
* @property {object} items - The items to be displayed as chips.
|
|
16
|
+
* @property {object} controller - The controller object to manage chip actions.
|
|
17
17
|
*/
|
|
18
18
|
export class EOxItemFilterChipsV2 extends LitElement {
|
|
19
19
|
// Define properties with defaults and types
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LitElement, html, nothing } from "lit";
|
|
2
|
+
import { emitActivity, findHost } from "@eox/elements-utils";
|
|
2
3
|
import { styleEOX } from "../style.eox";
|
|
3
4
|
import { when } from "lit/directives/when.js";
|
|
4
5
|
|
|
@@ -7,9 +8,9 @@ import { when } from "lit/directives/when.js";
|
|
|
7
8
|
* The component supports a featured view and an expandable details view.
|
|
8
9
|
*
|
|
9
10
|
* @module EOxItemFilterExpandContainer
|
|
10
|
-
* @
|
|
11
|
-
* @property {
|
|
12
|
-
* @property {
|
|
11
|
+
* @augments LitElement
|
|
12
|
+
* @property {object} filterObject - The filter object containing state and properties such as title and expanded state.
|
|
13
|
+
* @property {boolean} unstyled - Flag to determine if default styles should be applied.
|
|
13
14
|
*/
|
|
14
15
|
export class EOxItemFilterExpandContainer extends LitElement {
|
|
15
16
|
// Define properties with defaults and types
|
|
@@ -34,6 +35,8 @@ export class EOxItemFilterExpandContainer extends LitElement {
|
|
|
34
35
|
this.unstyled = false;
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
#userClickedSummary = false;
|
|
39
|
+
|
|
37
40
|
/**
|
|
38
41
|
* Handles the toggle event for the details element.
|
|
39
42
|
* Dispatches a custom event "details-toggled" with the event details.
|
|
@@ -48,6 +51,21 @@ export class EOxItemFilterExpandContainer extends LitElement {
|
|
|
48
51
|
composed: true,
|
|
49
52
|
}),
|
|
50
53
|
);
|
|
54
|
+
if (this.#userClickedSummary) {
|
|
55
|
+
this.#userClickedSummary = false;
|
|
56
|
+
const root = findHost(this, "eox-itemfilter");
|
|
57
|
+
if (root) {
|
|
58
|
+
emitActivity(
|
|
59
|
+
root,
|
|
60
|
+
"details-toggled",
|
|
61
|
+
{
|
|
62
|
+
key: this.filterObject?.key,
|
|
63
|
+
title: this.filterObject?.title,
|
|
64
|
+
},
|
|
65
|
+
event,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
51
69
|
}
|
|
52
70
|
|
|
53
71
|
/**
|
|
@@ -68,7 +86,12 @@ export class EOxItemFilterExpandContainer extends LitElement {
|
|
|
68
86
|
class="details-filter max-width"
|
|
69
87
|
?open=${this.filterObject.expanded || nothing}
|
|
70
88
|
>
|
|
71
|
-
<summary
|
|
89
|
+
<summary
|
|
90
|
+
class="square"
|
|
91
|
+
@click=${() => {
|
|
92
|
+
this.#userClickedSummary = true;
|
|
93
|
+
}}
|
|
94
|
+
>
|
|
72
95
|
<nav class="responsive tiny-space">
|
|
73
96
|
<i class="small">
|
|
74
97
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
@@ -17,10 +17,10 @@ import { isDate } from "../../helpers/index.js";
|
|
|
17
17
|
* generating labels, and resetting the range filter.
|
|
18
18
|
*
|
|
19
19
|
* @module EOxItemFilterRange
|
|
20
|
-
* @
|
|
21
|
-
* @property {
|
|
20
|
+
* @augments LitElement
|
|
21
|
+
* @property {object} filterObject - The filter object containing state and range limits.
|
|
22
22
|
* @property {Array} suggestions - The list of suggestions for the selector.
|
|
23
|
-
* @property {
|
|
23
|
+
* @property {number} tabIndex - The tab index for the input elements.
|
|
24
24
|
*/
|
|
25
25
|
export class EOxItemFilterRange extends LitElement {
|
|
26
26
|
// Define properties with defaults and types
|
|
@@ -135,7 +135,8 @@ export class EOxItemFilterRange extends LitElement {
|
|
|
135
135
|
this.filterObject.state.max || this.filterObject.max,
|
|
136
136
|
).format(),
|
|
137
137
|
]}
|
|
138
|
-
@select=${(e) =>
|
|
138
|
+
@select=${(e) => {
|
|
139
|
+
e.stopPropagation();
|
|
139
140
|
rangeInputHandlerMethod(
|
|
140
141
|
new CustomEvent("values", {
|
|
141
142
|
detail: {
|
|
@@ -146,7 +147,9 @@ export class EOxItemFilterRange extends LitElement {
|
|
|
146
147
|
},
|
|
147
148
|
}),
|
|
148
149
|
this,
|
|
149
|
-
)
|
|
150
|
+
);
|
|
151
|
+
}}
|
|
152
|
+
@eox:activity=${(e) => e.stopPropagation()}
|
|
150
153
|
>
|
|
151
154
|
<eox-timecontrol-date
|
|
152
155
|
.format=${DATE_TIME_FORMAT}
|
|
@@ -16,18 +16,18 @@ import { capitalize } from "../../helpers";
|
|
|
16
16
|
* key events, and selection updates.
|
|
17
17
|
*
|
|
18
18
|
* @module EOxSelector
|
|
19
|
-
* @
|
|
20
|
-
* @property {
|
|
19
|
+
* @augments LitElement
|
|
20
|
+
* @property {object} filterObject - The filter object containing state and placeholder.
|
|
21
21
|
* @property {Array} suggestions - The list of suggestions for the selector.
|
|
22
22
|
* @property {Array} selectedItems - The list of currently selected items.
|
|
23
|
-
* @property {
|
|
24
|
-
* @property {
|
|
25
|
-
* @property {
|
|
23
|
+
* @property {string} query - The current input query for autocomplete.
|
|
24
|
+
* @property {boolean} showSuggestions - Flag to control the display of suggestions in autocomplete mode.
|
|
25
|
+
* @property {number} highlightedIndex - The index of the currently highlighted suggestion.
|
|
26
26
|
* @property {Array} filteredSuggestions - The list of suggestions filtered based on the query.
|
|
27
|
-
* @property {
|
|
28
|
-
* @property {
|
|
29
|
-
* @property {
|
|
30
|
-
* @property {
|
|
27
|
+
* @property {string} type - The type of selector ("select", "multi-select", etc.).
|
|
28
|
+
* @property {boolean} unstyled - Flag to determine if default styles should be applied.
|
|
29
|
+
* @property {number} tabIndex - The tab index for the input elements.
|
|
30
|
+
* @property {boolean} inlineMode - State whether to enable or disable inline mode
|
|
31
31
|
*/
|
|
32
32
|
export class EOxSelector extends LitElement {
|
|
33
33
|
// Define properties with defaults and types
|
|
@@ -139,7 +139,7 @@ export class EOxSelector extends LitElement {
|
|
|
139
139
|
/**
|
|
140
140
|
* Toggles the selection of an item.
|
|
141
141
|
*
|
|
142
|
-
* @param {
|
|
142
|
+
* @param {object} item - The item to toggle.
|
|
143
143
|
*/
|
|
144
144
|
#toggleItem(item) {
|
|
145
145
|
toggleItemSelectorMethod(item, this);
|
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
/**
|
|
13
13
|
* Determines if one geometry is within another using Turf.js booleanWithin function.
|
|
14
14
|
*
|
|
15
|
-
* @param {
|
|
16
|
-
* @param {
|
|
15
|
+
* @param {object} itemGeometry - The geometry of the item.
|
|
16
|
+
* @param {object} filterGeometry - The geometry of the filter.
|
|
17
17
|
* @returns {boolean} - True if itemGeometry is within filterGeometry, otherwise false.
|
|
18
18
|
*/
|
|
19
19
|
export const within = (itemGeometry, filterGeometry) => {
|
|
@@ -28,9 +28,9 @@ export const within = (itemGeometry, filterGeometry) => {
|
|
|
28
28
|
* The component allows users to select a spatial filter mode (intersects or within) and apply it to a map.
|
|
29
29
|
*
|
|
30
30
|
* @module EOxItemFilterSpatial
|
|
31
|
-
* @
|
|
32
|
-
* @property {
|
|
33
|
-
* @property {
|
|
31
|
+
* @augments LitElement
|
|
32
|
+
* @property {object} filterObject - The filter object containing the state and geometry.
|
|
33
|
+
* @property {number} tabIndex - The tab index for the input elements.
|
|
34
34
|
*/
|
|
35
35
|
class EOxItemFilterSpatial extends LitElement {
|
|
36
36
|
// Define properties with defaults and types
|
|
@@ -132,9 +132,9 @@ customElements.define("eox-itemfilter-spatial", EOxItemFilterSpatial);
|
|
|
132
132
|
* It uses the LitElement base class and integrates with external methods for setup and reset functionalities.
|
|
133
133
|
*
|
|
134
134
|
* @module SpatialFilter
|
|
135
|
-
* @
|
|
136
|
-
* @property {
|
|
137
|
-
* @property {
|
|
135
|
+
* @augments LitElement
|
|
136
|
+
* @property {object} geometry - The geometry object used for the spatial filter.
|
|
137
|
+
* @property {object} eoxMap - The map object used to display and interact with the spatial filter.
|
|
138
138
|
*/
|
|
139
139
|
class SpatialFilter extends LitElement {
|
|
140
140
|
// Define properties with defaults and types
|
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
* EOxItemFilterText is a custom web component that provides a text input field for filtering items.
|
|
12
12
|
*
|
|
13
13
|
* @module EOxItemFilterText
|
|
14
|
-
* @
|
|
15
|
-
* @property {
|
|
16
|
-
* @property {
|
|
17
|
-
* @property {
|
|
14
|
+
* @augments LitElement
|
|
15
|
+
* @property {object} filterObject - The filter object containing the state and placeholder.
|
|
16
|
+
* @property {number} tabIndex - The tab index for the input element.
|
|
17
|
+
* @property {boolean} unstyled - Flag to determine if default styles should be applied.
|
|
18
18
|
*/
|
|
19
19
|
export class EOxItemFilterText extends LitElement {
|
|
20
20
|
// Define properties with defaults and types
|
|
@@ -20,12 +20,12 @@ import { getChipItems, isFiltersDirty } from "../helpers";
|
|
|
20
20
|
* EOxItemFilterContainer is a custom web component that provides a container for item filters.
|
|
21
21
|
*
|
|
22
22
|
* @module EOxItemFilterContainer
|
|
23
|
-
* @
|
|
24
|
-
* @property {
|
|
25
|
-
* @property {
|
|
26
|
-
* @property {
|
|
27
|
-
* @property {
|
|
28
|
-
* @property {
|
|
23
|
+
* @augments LitElement
|
|
24
|
+
* @property {object} filterProperties - The properties for the filter.
|
|
25
|
+
* @property {boolean} inlineMode - Flag to determine if the component should operate in inline mode.
|
|
26
|
+
* @property {boolean} unstyled - Flag to determine if default styles should be applied.
|
|
27
|
+
* @property {object} filters - The filters applied in the container.
|
|
28
|
+
* @property {string} inlineSearchText - The text in the inline search box, offered as an inline search.
|
|
29
29
|
*/
|
|
30
30
|
export class EOxItemFilterContainer extends LitElement {
|
|
31
31
|
// Define properties with defaults and types
|
|
@@ -14,12 +14,12 @@ import { toggleAccordion } from "../helpers";
|
|
|
14
14
|
* and creating item details and lists.
|
|
15
15
|
*
|
|
16
16
|
* @module EOxItemFilterResults
|
|
17
|
-
* @
|
|
18
|
-
* @property {
|
|
19
|
-
* @property {
|
|
20
|
-
* @property {
|
|
17
|
+
* @augments LitElement
|
|
18
|
+
* @property {object} config - The configuration object for the results display.
|
|
19
|
+
* @property {object} results - The state object containing the filter results.
|
|
20
|
+
* @property {object} filters - The state object containing the applied filters.
|
|
21
21
|
* @property {Array} resultAggregation - The array of properties used for result aggregation.
|
|
22
|
-
* @property {
|
|
22
|
+
* @property {object} selectedResult - Property with pre-selected result
|
|
23
23
|
*/
|
|
24
24
|
export class EOxItemFilterResults extends LitElement {
|
|
25
25
|
// Define properties with defaults and types
|
|
@@ -3,8 +3,8 @@ import { html } from "lit";
|
|
|
3
3
|
/**
|
|
4
4
|
* Generates an array of chip items from the given filters.
|
|
5
5
|
*
|
|
6
|
-
* @param {
|
|
7
|
-
* @returns {Array<
|
|
6
|
+
* @param {object} filters - An object containing filter data.
|
|
7
|
+
* @returns {Array<object>} An array of chip item objects.
|
|
8
8
|
*/
|
|
9
9
|
function getChipItems(filters) {
|
|
10
10
|
return Object.keys(filters)
|
|
@@ -7,8 +7,8 @@ let _fuse;
|
|
|
7
7
|
/**
|
|
8
8
|
* Indexes the given items using Fuse.js with the provided configuration.
|
|
9
9
|
*
|
|
10
|
-
* @param {Array<
|
|
11
|
-
* @param {
|
|
10
|
+
* @param {Array<object>} items - The items to be indexed.
|
|
11
|
+
* @param {object} fuseConfig - Configuration object for Fuse.js.
|
|
12
12
|
*/
|
|
13
13
|
export const indexItems = (items, fuseConfig) => {
|
|
14
14
|
_fuse = new Fuse(items, {
|
|
@@ -24,10 +24,10 @@ export const indexItems = (items, fuseConfig) => {
|
|
|
24
24
|
/**
|
|
25
25
|
* Filters the given items based on the provided filters and configuration.
|
|
26
26
|
*
|
|
27
|
-
* @param {Array<
|
|
28
|
-
* @param {
|
|
29
|
-
* @param {
|
|
30
|
-
* @returns {Promise<Array<
|
|
27
|
+
* @param {Array<object>} items - The items to be filtered.
|
|
28
|
+
* @param {object} filters - The filters to be applied.
|
|
29
|
+
* @param {object} config - Configuration for filtering behavior.
|
|
30
|
+
* @returns {Promise<Array<object>>} The filtered items.
|
|
31
31
|
*/
|
|
32
32
|
export const filter = async (items, filters, config) => {
|
|
33
33
|
// Parse text, select, and multiselect filters
|
|
@@ -2,10 +2,10 @@ import { getValue } from "./";
|
|
|
2
2
|
/**
|
|
3
3
|
* Fetches and filters items based on the provided filters and configuration using an external API.
|
|
4
4
|
*
|
|
5
|
-
* @param {Array<
|
|
6
|
-
* @param {
|
|
7
|
-
* @param {
|
|
8
|
-
* @returns {Promise<Array<
|
|
5
|
+
* @param {Array<object>} items - The items to be filtered.
|
|
6
|
+
* @param {object} filters - The filters to be applied.
|
|
7
|
+
* @param {object} config - Configuration for filtering behavior.
|
|
8
|
+
* @returns {Promise<Array<object>>} The filtered items from the external API.
|
|
9
9
|
*/
|
|
10
10
|
async function filterExternal(items, filters, config) {
|
|
11
11
|
const functionResult = config.externalFilter(items, filters);
|
package/src/helpers/get-value.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Get value based on nested key or individual key
|
|
3
3
|
*
|
|
4
4
|
* @param {string|Function} key - Key to identify the value
|
|
5
|
-
* @param {
|
|
5
|
+
* @param {object} items - Items contain list of key & it's value
|
|
6
6
|
* @returns {any}
|
|
7
7
|
*/
|
|
8
8
|
export default function getValue(key, items) {
|
|
@@ -3,10 +3,10 @@ import { capitalize, mergeHighlightIndices } from "./";
|
|
|
3
3
|
/**
|
|
4
4
|
* Highlights matched text in the Fuse.js search results.
|
|
5
5
|
*
|
|
6
|
-
* @param {Array<
|
|
6
|
+
* @param {Array<object>} fuseSearchResult - The search results from Fuse.js.
|
|
7
7
|
* @param {string} [highlightClassName="highlight"] - The CSS class name to be used for highlighting.
|
|
8
8
|
* @param {string} [matchKey="title"] - The key of the object where matches should be highlighted.
|
|
9
|
-
* @returns {Array<
|
|
9
|
+
* @returns {Array<object>} The search results with highlighted matches.
|
|
10
10
|
*/
|
|
11
11
|
function highlight(
|
|
12
12
|
fuseSearchResult,
|
package/src/helpers/is-date.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Checks if the filterObject format is date-like.
|
|
3
3
|
*
|
|
4
|
-
* @param {
|
|
4
|
+
* @param {object} filterObject - The filter object.
|
|
5
5
|
* @returns {boolean} True if it is a date, otherwise false.
|
|
6
6
|
*/
|
|
7
7
|
export default function isDate(filterObject) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Checks if any of the filters are dirty.
|
|
3
3
|
*
|
|
4
|
-
* @param {
|
|
4
|
+
* @param {object} filters - An object containing filter data.
|
|
5
5
|
* @returns {boolean} True if any filter is dirty, otherwise false.
|
|
6
6
|
*/
|
|
7
7
|
export default function isFiltersDirty(filters) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generates an array of map layer configurations.
|
|
3
3
|
*
|
|
4
|
-
* @param {
|
|
4
|
+
* @param {object} [geometry] - Optional geometry data to include in the Vector source.
|
|
5
5
|
* @param {string} [url] - Optional URL for the GeoJSON data source.
|
|
6
|
-
* @returns {Array<
|
|
6
|
+
* @returns {Array<object>} An array of map layer configurations.
|
|
7
7
|
*/
|
|
8
8
|
export default function getMapLayers(geometry, url) {
|
|
9
9
|
return [
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Merge highlight indices which are overlapping with existing indices and sort the range in ascending order
|
|
3
3
|
*
|
|
4
4
|
* @param {number[][]} indices
|
|
5
|
-
* @param {
|
|
5
|
+
* @param {object} [opts]
|
|
6
6
|
* @param {boolean} [opts.mergeAdjacent=false]
|
|
7
7
|
* @returns {number[][]}
|
|
8
8
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Resets the given filter object to its default state.
|
|
3
3
|
*
|
|
4
|
-
* @param {
|
|
5
|
-
* @returns {
|
|
4
|
+
* @param {object} filterObject - The filter object to reset.
|
|
5
|
+
* @returns {object | null} The reset filter object or null if the filter was not dirty.
|
|
6
6
|
*/
|
|
7
7
|
export default function resetFilter(filterObject) {
|
|
8
8
|
// Return null if the filter is not dirty
|
package/src/helpers/spatial.js
CHANGED
|
@@ -4,8 +4,8 @@ import booleanWithin from "@turf/boolean-within";
|
|
|
4
4
|
/**
|
|
5
5
|
* Checks if the item geometry intersects with the filter geometry.
|
|
6
6
|
*
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {
|
|
7
|
+
* @param {object} itemGeometry - The geometry of the item to check.
|
|
8
|
+
* @param {object} filterGeometry - The geometry of the filter to check against.
|
|
9
9
|
* @returns {boolean} True if the item geometry intersects with the filter geometry, otherwise false.
|
|
10
10
|
*/
|
|
11
11
|
export const intersects = (itemGeometry, filterGeometry) => {
|
|
@@ -20,8 +20,8 @@ export const intersects = (itemGeometry, filterGeometry) => {
|
|
|
20
20
|
/**
|
|
21
21
|
* Checks if the item geometry is within the filter geometry.
|
|
22
22
|
*
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {
|
|
23
|
+
* @param {object} itemGeometry - The geometry of the item to check.
|
|
24
|
+
* @param {object} filterGeometry - The geometry of the filter to check against.
|
|
25
25
|
* @returns {boolean} True if the item geometry is within the filter geometry, otherwise false.
|
|
26
26
|
*/
|
|
27
27
|
export const within = (itemGeometry, filterGeometry) => {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Handles the toggle event for the accordion.
|
|
3
3
|
*
|
|
4
4
|
* @param {CustomEvent} event - The toggle event.
|
|
5
|
-
* @param {
|
|
5
|
+
* @param {object} config - The configuration object for item-filter.
|
|
6
6
|
* @param {Element} that
|
|
7
7
|
*/
|
|
8
8
|
function toggleAccordion(event, config, that) {
|
package/src/main.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LitElement, html, nothing } from "lit";
|
|
2
|
+
import { dispatchElementEvent } from "@eox/elements-utils";
|
|
2
3
|
import { map } from "lit/directives/map.js";
|
|
3
4
|
import { when } from "lit/directives/when.js";
|
|
4
5
|
import { style } from "./style";
|
|
@@ -53,6 +54,7 @@ import {
|
|
|
53
54
|
* @fires mouseenter:result - When a result is hovered
|
|
54
55
|
* @fires mouseleave:result - When a result is un-hovered
|
|
55
56
|
* @fires click:result-action - When a result action button is clicked
|
|
57
|
+
* @fires {CustomEvent<import("@eox/elements-utils").EOxActivityDetail>} eox:activity - Fires on genuine user interactions, wrapping the original event for analytics tracking.
|
|
56
58
|
*/
|
|
57
59
|
export class EOxItemFilter extends LitElement {
|
|
58
60
|
// Define properties with defaults and types
|
|
@@ -134,13 +136,18 @@ export class EOxItemFilter extends LitElement {
|
|
|
134
136
|
*/
|
|
135
137
|
this.selectedResult = null;
|
|
136
138
|
|
|
139
|
+
this._debouncedSearch = _debounce(this.searchHandler, 100, {
|
|
140
|
+
leading: true,
|
|
141
|
+
});
|
|
142
|
+
|
|
137
143
|
/**
|
|
138
144
|
* @type Function
|
|
139
145
|
* @private
|
|
140
146
|
*/
|
|
141
|
-
this.search =
|
|
142
|
-
|
|
143
|
-
|
|
147
|
+
this.search = (isUser = false) => {
|
|
148
|
+
if (isUser) this._isUserFilter = true;
|
|
149
|
+
this._debouncedSearch();
|
|
150
|
+
};
|
|
144
151
|
|
|
145
152
|
/**
|
|
146
153
|
* Aggregate results by a property key
|
|
@@ -298,7 +305,7 @@ export class EOxItemFilter extends LitElement {
|
|
|
298
305
|
|
|
299
306
|
/** Overrides elements current CSS.
|
|
300
307
|
*
|
|
301
|
-
* @type {
|
|
308
|
+
* @type {string}
|
|
302
309
|
*/
|
|
303
310
|
this.styleOverride = "";
|
|
304
311
|
|
|
@@ -329,20 +336,20 @@ export class EOxItemFilter extends LitElement {
|
|
|
329
336
|
* Requests an update after the search completes.
|
|
330
337
|
*/
|
|
331
338
|
async searchHandler() {
|
|
339
|
+
const isUser = Boolean(this._isUserFilter);
|
|
340
|
+
this._isUserFilter = false;
|
|
332
341
|
await searchMethod(this.#config, this.#items, this);
|
|
333
342
|
/**
|
|
334
343
|
* Fires when the filters are changed; event detail includes `filters` and `results`
|
|
335
344
|
*/
|
|
336
|
-
this
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
}),
|
|
345
|
-
);
|
|
345
|
+
dispatchElementEvent(this, "filter", {
|
|
346
|
+
detail: {
|
|
347
|
+
results: this.results,
|
|
348
|
+
filters: this.filters,
|
|
349
|
+
},
|
|
350
|
+
activity: isUser,
|
|
351
|
+
action: "filter",
|
|
352
|
+
});
|
|
346
353
|
if (this.inlineMode)
|
|
347
354
|
/** @type {import("./components/itemfilter-container").EOxItemFilterContainer} **/ (
|
|
348
355
|
this.renderRoot.querySelector("eox-itemfilter-container")
|
|
@@ -354,7 +361,7 @@ export class EOxItemFilter extends LitElement {
|
|
|
354
361
|
* Sorts the given items based on the current configuration.
|
|
355
362
|
*
|
|
356
363
|
* @param {Array<object>} items - The items to be sorted.
|
|
357
|
-
* @param {
|
|
364
|
+
* @param {object} [options] - Optional sorting parameters.
|
|
358
365
|
* @param {boolean} [options.isExternalResult] - Flag for results from external filter.
|
|
359
366
|
* @returns {Array<object>} - The sorted items.
|
|
360
367
|
*/
|
|
@@ -365,7 +372,7 @@ export class EOxItemFilter extends LitElement {
|
|
|
365
372
|
/**
|
|
366
373
|
* Creates a filter element based on the given filter object and tab index.
|
|
367
374
|
*
|
|
368
|
-
* @param {
|
|
375
|
+
* @param {object} filterObject - The filter object.
|
|
369
376
|
* @param {number} tabIndex - The tab index for the filter element.
|
|
370
377
|
* @returns {import("lit").HTMLTemplateResult} - The template result for the filter element.
|
|
371
378
|
*/
|
|
@@ -376,7 +383,7 @@ export class EOxItemFilter extends LitElement {
|
|
|
376
383
|
/**
|
|
377
384
|
* Creates a reset element for the given filter object and tab index.
|
|
378
385
|
*
|
|
379
|
-
* @param {
|
|
386
|
+
* @param {object} filterObject - The filter object.
|
|
380
387
|
* @param {number} tabIndex - The tab index for the reset element.
|
|
381
388
|
* @returns {import("lit").HTMLTemplateResult} - The template result for the filter element.
|
|
382
389
|
*/
|
|
@@ -386,9 +393,10 @@ export class EOxItemFilter extends LitElement {
|
|
|
386
393
|
|
|
387
394
|
/**
|
|
388
395
|
* Resets all applied filters.
|
|
396
|
+
* @param {boolean} [isUser=false]
|
|
389
397
|
*/
|
|
390
|
-
resetFilters() {
|
|
391
|
-
resetFilterMethod(this);
|
|
398
|
+
resetFilters(isUser = false) {
|
|
399
|
+
resetFilterMethod(this, isUser);
|
|
392
400
|
}
|
|
393
401
|
|
|
394
402
|
/**
|
|
@@ -458,27 +466,27 @@ export class EOxItemFilter extends LitElement {
|
|
|
458
466
|
/**
|
|
459
467
|
* Updates selected result when result component triggers the "result" event.
|
|
460
468
|
*
|
|
461
|
-
* @param {{detail:
|
|
469
|
+
* @param {{detail: object}} evt - "result" event triggered by result component
|
|
462
470
|
*/
|
|
463
471
|
updateResult(evt) {
|
|
464
472
|
this.selectedResult = evt.detail;
|
|
465
473
|
/**
|
|
466
474
|
* Fires when a result is selected; event detail is `selectedResult`
|
|
467
475
|
*/
|
|
468
|
-
this
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
);
|
|
476
|
+
dispatchElementEvent(this, "select", {
|
|
477
|
+
detail: this.selectedResult,
|
|
478
|
+
activity: true,
|
|
479
|
+
action: "select",
|
|
480
|
+
bubbles: true,
|
|
481
|
+
composed: true,
|
|
482
|
+
});
|
|
475
483
|
this.requestUpdate();
|
|
476
484
|
}
|
|
477
485
|
|
|
478
486
|
/**
|
|
479
487
|
* Dispatches an event when result component triggers the "mouseenter:result" event.
|
|
480
488
|
*
|
|
481
|
-
* @param {{detail:
|
|
489
|
+
* @param {{detail: object}} evt - "mouseenter:result" event triggered by result component
|
|
482
490
|
*/
|
|
483
491
|
mouseEnterResult(evt) {
|
|
484
492
|
/**
|
|
@@ -496,7 +504,7 @@ export class EOxItemFilter extends LitElement {
|
|
|
496
504
|
/**
|
|
497
505
|
* Dispatches an event when result component triggers the "mouseleave:result" event.
|
|
498
506
|
*
|
|
499
|
-
* @param {{detail:
|
|
507
|
+
* @param {{detail: object}} evt - "mouseleave:result" event triggered by result component
|
|
500
508
|
*/
|
|
501
509
|
mouseLeaveResult(evt) {
|
|
502
510
|
/**
|
|
@@ -514,19 +522,19 @@ export class EOxItemFilter extends LitElement {
|
|
|
514
522
|
/**
|
|
515
523
|
* Emits "click:result-action" event.
|
|
516
524
|
*
|
|
517
|
-
* @param {{detail:
|
|
525
|
+
* @param {{detail: object}} evt - "click:result-action" event triggered by result component
|
|
518
526
|
*/
|
|
519
527
|
emitResultAction(evt) {
|
|
520
528
|
/**
|
|
521
529
|
* Fires when a result-action is clicked; event detail is `result`
|
|
522
530
|
*/
|
|
523
|
-
this
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
);
|
|
531
|
+
dispatchElementEvent(this, "click:result-action", {
|
|
532
|
+
detail: evt.detail,
|
|
533
|
+
activity: true,
|
|
534
|
+
action: "click:result-action",
|
|
535
|
+
bubbles: true,
|
|
536
|
+
composed: true,
|
|
537
|
+
});
|
|
530
538
|
}
|
|
531
539
|
|
|
532
540
|
/**
|
|
@@ -559,8 +567,8 @@ export class EOxItemFilter extends LitElement {
|
|
|
559
567
|
.filters=${this.filters}
|
|
560
568
|
.filterProperties=${this.filterProperties}
|
|
561
569
|
.inlineMode=${this.inlineMode || false}
|
|
562
|
-
@reset=${() => this
|
|
563
|
-
@filter=${() => this.search()}
|
|
570
|
+
@reset=${() => resetFilterMethod(this, true)}
|
|
571
|
+
@filter=${() => this.search(true)}
|
|
564
572
|
>
|
|
565
573
|
<section
|
|
566
574
|
slot="section"
|
|
@@ -587,7 +595,7 @@ export class EOxItemFilter extends LitElement {
|
|
|
587
595
|
id="filter-reset"
|
|
588
596
|
class="reset-icon border small"
|
|
589
597
|
data-cy="filter-reset"
|
|
590
|
-
@click=${() => this.resetFilters()}
|
|
598
|
+
@click=${() => this.resetFilters(true)}
|
|
591
599
|
>
|
|
592
600
|
${this.unstyled
|
|
593
601
|
? nothing
|