@eox/itemfilter 1.7.1 → 1.8.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 +2642 -2578
- package/dist/eox-itemfilter.umd.cjs +126 -89
- package/package.json +3 -2
- package/src/components/chips.js +3 -3
- package/src/components/expand-container.js +0 -1
- package/src/components/filters/range.js +3 -5
- package/src/components/filters/selector.js +1 -4
- package/src/components/filters/spatial.js +0 -3
- package/src/components/filters/text.js +1 -3
- package/src/components/itemfilter-container.js +8 -12
- package/src/components/results.js +17 -8
- package/src/helpers/toggle-accordion.js +1 -1
- package/src/main.js +52 -6
- package/src/methods/chips/handler.js +15 -5
- package/src/methods/container/handler.js +2 -1
- package/src/methods/container/init-popver.js +1 -1
- package/src/methods/container/reset-filter.js +3 -0
- package/src/methods/container/reset-search.js +4 -1
- package/src/methods/container/search-filter.js +3 -0
- package/src/methods/filters/range.js +5 -2
- package/src/methods/filters/selector.js +4 -1
- package/src/methods/itemfilter/create-filter.js +1 -1
- package/src/methods/itemfilter/create-reset.js +1 -1
- package/src/methods/results/create.js +22 -5
- package/src/style.eox.js +27 -0
- package/types/components/chips.d.ts.map +1 -1
- package/types/components/expand-container.d.ts.map +1 -1
- package/types/components/filters/range.d.ts +2 -2
- package/types/components/filters/range.d.ts.map +1 -1
- package/types/components/filters/selector.d.ts.map +1 -1
- package/types/components/filters/spatial.d.ts.map +1 -1
- package/types/components/filters/text.d.ts +4 -0
- package/types/components/filters/text.d.ts.map +1 -1
- package/types/components/itemfilter-container.d.ts +6 -4
- package/types/components/itemfilter-container.d.ts.map +1 -1
- package/types/components/results.d.ts +15 -3
- package/types/components/results.d.ts.map +1 -1
- package/types/helpers/chip-items.d.ts.map +1 -1
- package/types/helpers/filter-client.d.ts.map +1 -1
- package/types/helpers/filter-external.d.ts.map +1 -1
- package/types/helpers/highlighting.d.ts.map +1 -1
- package/types/helpers/map-layers.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 +36 -0
- package/types/main.d.ts.map +1 -1
- package/types/methods/chips/handler.d.ts +2 -2
- package/types/methods/chips/handler.d.ts.map +1 -1
- package/types/methods/container/handler.d.ts +2 -2
- package/types/methods/container/handler.d.ts.map +1 -1
- package/types/methods/container/init-popver.d.ts +2 -2
- package/types/methods/container/init-popver.d.ts.map +1 -1
- package/types/methods/container/reset-filter.d.ts.map +1 -1
- package/types/methods/container/reset-search.d.ts.map +1 -1
- 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 +2 -2
- package/types/methods/filters/selector.d.ts.map +1 -1
- package/types/methods/itemfilter/create-filter.d.ts +2 -2
- package/types/methods/itemfilter/create-filter.d.ts.map +1 -1
- package/types/methods/itemfilter/create-reset.d.ts +2 -2
- package/types/methods/itemfilter/create-reset.d.ts.map +1 -1
- package/types/methods/itemfilter/filter-apply.d.ts.map +1 -1
- package/types/methods/itemfilter/search.d.ts.map +1 -1
- package/types/methods/itemfilter/sort-results.d.ts.map +1 -1
- package/types/methods/results/aggregate-results.d.ts.map +1 -1
- package/types/methods/results/create.d.ts +5 -5
- package/types/methods/results/create.d.ts.map +1 -1
- package/types/style.eox.d.ts +1 -1
- package/types/style.eox.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.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@types/geojson": "^7946.0.14",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
|
-
"
|
|
32
|
+
"types:generate": "tsc --project tsconfig.build.json || true",
|
|
33
|
+
"prepack": "npm run types:generate",
|
|
33
34
|
"build": "vite build",
|
|
34
35
|
"watch": "vite build --watch"
|
|
35
36
|
},
|
package/src/components/chips.js
CHANGED
|
@@ -68,6 +68,7 @@ export class EOxItemFilterChipsV2 extends LitElement {
|
|
|
68
68
|
*
|
|
69
69
|
* @private
|
|
70
70
|
*/
|
|
71
|
+
// @ts-expect-error is called from chips method
|
|
71
72
|
_dispatchEvent() {
|
|
72
73
|
this.dispatchEvent(
|
|
73
74
|
new CustomEvent("items-selected", {
|
|
@@ -79,8 +80,8 @@ export class EOxItemFilterChipsV2 extends LitElement {
|
|
|
79
80
|
/**
|
|
80
81
|
* Handles keyboard events for the component.
|
|
81
82
|
*
|
|
82
|
-
* @
|
|
83
|
-
* @
|
|
83
|
+
* @type {EventListener}
|
|
84
|
+
* @param {KeyboardEvent} event - The keyboard event.
|
|
84
85
|
*/
|
|
85
86
|
#keyboardEventListener(event) {
|
|
86
87
|
keyboardEventListenerMethod(event, this);
|
|
@@ -90,7 +91,6 @@ export class EOxItemFilterChipsV2 extends LitElement {
|
|
|
90
91
|
* Handles click events for the chips.
|
|
91
92
|
*
|
|
92
93
|
* @param {Event} evt - The click event.
|
|
93
|
-
* @private
|
|
94
94
|
*/
|
|
95
95
|
#handleChipClick(evt) {
|
|
96
96
|
handleChipClickMethod(evt, this);
|
|
@@ -39,7 +39,6 @@ export class EOxItemFilterExpandContainer extends LitElement {
|
|
|
39
39
|
* Dispatches a custom event "details-toggled" with the event details.
|
|
40
40
|
*
|
|
41
41
|
* @param {Event} event - The toggle event.
|
|
42
|
-
* @private
|
|
43
42
|
*/
|
|
44
43
|
#handleDetailsToggle(event) {
|
|
45
44
|
this.dispatchEvent(
|
|
@@ -39,7 +39,7 @@ export class EOxItemFilterRange extends LitElement {
|
|
|
39
39
|
this.tabIndex = 0;
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* @type
|
|
42
|
+
* @type {(evt: CustomEvent<any>) => void}
|
|
43
43
|
*/
|
|
44
44
|
this.inputHandler = this.#inputHandler.bind(this);
|
|
45
45
|
|
|
@@ -54,8 +54,7 @@ export class EOxItemFilterRange extends LitElement {
|
|
|
54
54
|
/**
|
|
55
55
|
* Handles the input event for the range slider.
|
|
56
56
|
*
|
|
57
|
-
* @param {
|
|
58
|
-
* @private
|
|
57
|
+
* @param {CustomEvent} evt - The input event.
|
|
59
58
|
*/
|
|
60
59
|
#inputHandler(evt) {
|
|
61
60
|
rangeInputHandlerMethod(evt, this);
|
|
@@ -66,8 +65,7 @@ export class EOxItemFilterRange extends LitElement {
|
|
|
66
65
|
*
|
|
67
66
|
* @param {string} val - The value of the label.
|
|
68
67
|
* @param {string} pos - The position of the label (before or after).
|
|
69
|
-
* @returns {
|
|
70
|
-
* @private
|
|
68
|
+
* @returns {import("lit").HTMLTemplateResult} - The generated label.
|
|
71
69
|
*/
|
|
72
70
|
#label(val, pos) {
|
|
73
71
|
return rangeLabelMethod(val, pos, this);
|
|
@@ -119,7 +119,6 @@ export class EOxSelector extends LitElement {
|
|
|
119
119
|
* Handles input events on the autocomplete input element.
|
|
120
120
|
*
|
|
121
121
|
* @param {Event} event - The input event.
|
|
122
|
-
* @private
|
|
123
122
|
*/
|
|
124
123
|
#handleInput(event) {
|
|
125
124
|
handleInputSelectorMethod(event, this);
|
|
@@ -128,8 +127,7 @@ export class EOxSelector extends LitElement {
|
|
|
128
127
|
/**
|
|
129
128
|
* Handles keydown events on the autocomplete input element.
|
|
130
129
|
*
|
|
131
|
-
* @param {
|
|
132
|
-
* @private
|
|
130
|
+
* @param {KeyboardEvent} event - The keydown event.
|
|
133
131
|
*/
|
|
134
132
|
#handleKeyDown(event) {
|
|
135
133
|
handleKeyDownSelectorMethod(event, this);
|
|
@@ -139,7 +137,6 @@ export class EOxSelector extends LitElement {
|
|
|
139
137
|
* Toggles the selection of an item.
|
|
140
138
|
*
|
|
141
139
|
* @param {Object} item - The item to toggle.
|
|
142
|
-
* @private
|
|
143
140
|
*/
|
|
144
141
|
#toggleItem(item) {
|
|
145
142
|
toggleItemSelectorMethod(item, this);
|
|
@@ -74,7 +74,6 @@ class EOxItemFilterSpatial extends LitElement {
|
|
|
74
74
|
/**
|
|
75
75
|
* Handles the click event for spatial filter mode selection.
|
|
76
76
|
*
|
|
77
|
-
* @private
|
|
78
77
|
* @param {string} mode - The mode of the spatial filter (e.g., "intersects", "within").
|
|
79
78
|
*/
|
|
80
79
|
#handleClick(mode) {
|
|
@@ -165,8 +164,6 @@ class SpatialFilter extends LitElement {
|
|
|
165
164
|
|
|
166
165
|
/**
|
|
167
166
|
* Sets up the spatial filter using the setupSpatialMethod.
|
|
168
|
-
*
|
|
169
|
-
* @private
|
|
170
167
|
*/
|
|
171
168
|
#setup() {
|
|
172
169
|
setupSpatialMethod(this);
|
|
@@ -44,13 +44,11 @@ export class EOxItemFilterText extends LitElement {
|
|
|
44
44
|
/**
|
|
45
45
|
* @type Boolean
|
|
46
46
|
*/
|
|
47
|
-
this.
|
|
47
|
+
this.isValid = false;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Handles the input event by calling the textInputHandlerMethod with the current context.
|
|
52
|
-
*
|
|
53
|
-
* @private
|
|
54
52
|
*/
|
|
55
53
|
#inputHandler = () => {
|
|
56
54
|
textInputHandlerMethod(this);
|
|
@@ -58,12 +58,12 @@ export class EOxItemFilterContainer extends LitElement {
|
|
|
58
58
|
this.filters = {};
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
* @type
|
|
61
|
+
* @type {(this: Document, ev: MouseEvent|FocusEvent) => any}
|
|
62
62
|
*/
|
|
63
63
|
this._handleClickOutside = this.#handleClickOutside.bind(this);
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
* @type
|
|
66
|
+
* @type {(this: Document, ev: KeyboardEvent) => any}
|
|
67
67
|
*/
|
|
68
68
|
this._handleKeyDown = this.#handleKeyDown.bind(this);
|
|
69
69
|
}
|
|
@@ -72,7 +72,9 @@ export class EOxItemFilterContainer extends LitElement {
|
|
|
72
72
|
* @type Boolean
|
|
73
73
|
*/
|
|
74
74
|
set showDropdown(show) {
|
|
75
|
-
|
|
75
|
+
/** @type {HTMLElement} **/ (
|
|
76
|
+
this.renderRoot.querySelector("[popover]")
|
|
77
|
+
).togglePopover(show);
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
get showDropdown() {
|
|
@@ -125,6 +127,8 @@ export class EOxItemFilterContainer extends LitElement {
|
|
|
125
127
|
/**
|
|
126
128
|
* Stores the autoUpdate cleanup function to be called
|
|
127
129
|
* when disconnected
|
|
130
|
+
*
|
|
131
|
+
* @type {() => void}
|
|
128
132
|
* @private
|
|
129
133
|
*/
|
|
130
134
|
_overlayCleanup() {}
|
|
@@ -133,7 +137,6 @@ export class EOxItemFilterContainer extends LitElement {
|
|
|
133
137
|
* Handles click events outside the component to close the dropdown.
|
|
134
138
|
*
|
|
135
139
|
* @param {Event} event - The click event.
|
|
136
|
-
* @private
|
|
137
140
|
*/
|
|
138
141
|
#handleClickOutside(event) {
|
|
139
142
|
handleClickOutsideMethod(event, this);
|
|
@@ -142,8 +145,7 @@ export class EOxItemFilterContainer extends LitElement {
|
|
|
142
145
|
/**
|
|
143
146
|
* Handles keydown events for the component.
|
|
144
147
|
*
|
|
145
|
-
* @param {
|
|
146
|
-
* @private
|
|
148
|
+
* @param {KeyboardEvent} event - The keydown event.
|
|
147
149
|
*/
|
|
148
150
|
#handleKeyDown(event) {
|
|
149
151
|
handleKeyDownMethod(event, this);
|
|
@@ -153,7 +155,6 @@ export class EOxItemFilterContainer extends LitElement {
|
|
|
153
155
|
* Toggles the dropdown visibility.
|
|
154
156
|
*
|
|
155
157
|
* @param {Event} event - The toggle event.
|
|
156
|
-
* @private
|
|
157
158
|
*/
|
|
158
159
|
#handleToggleDropdown(event) {
|
|
159
160
|
handleToggleDropdownMethod(event, this);
|
|
@@ -161,8 +162,6 @@ export class EOxItemFilterContainer extends LitElement {
|
|
|
161
162
|
|
|
162
163
|
/**
|
|
163
164
|
* Shows the dropdown on input focus.
|
|
164
|
-
*
|
|
165
|
-
* @private
|
|
166
165
|
*/
|
|
167
166
|
#handleShowDropdownOnFocus() {
|
|
168
167
|
handleShowDropdownOnFocusMethod(this);
|
|
@@ -172,7 +171,6 @@ export class EOxItemFilterContainer extends LitElement {
|
|
|
172
171
|
* Handles click events on the form to prevent closing the dropdown.
|
|
173
172
|
*
|
|
174
173
|
* @param {Event} event - The click event.
|
|
175
|
-
* @private
|
|
176
174
|
*/
|
|
177
175
|
#handleFormClick(event) {
|
|
178
176
|
handleFormClickMethod(event, this);
|
|
@@ -182,7 +180,6 @@ export class EOxItemFilterContainer extends LitElement {
|
|
|
182
180
|
* Resets the filter using the resetFilterMethod.
|
|
183
181
|
*
|
|
184
182
|
* @param {Event} event - The reset event.
|
|
185
|
-
* @private
|
|
186
183
|
*/
|
|
187
184
|
#resetFilter(event) {
|
|
188
185
|
resetFilterMethod(event, this);
|
|
@@ -192,7 +189,6 @@ export class EOxItemFilterContainer extends LitElement {
|
|
|
192
189
|
* Searches the filter using the searchFilterMethod.
|
|
193
190
|
*
|
|
194
191
|
* @param {Event} event - The search event.
|
|
195
|
-
* @private
|
|
196
192
|
*/
|
|
197
193
|
#searchFilter(event) {
|
|
198
194
|
searchFilterMethod(event, this);
|
|
@@ -26,11 +26,12 @@ export class EOxItemFilterResults extends LitElement {
|
|
|
26
26
|
static get properties() {
|
|
27
27
|
return {
|
|
28
28
|
config: { attribute: false, type: Object },
|
|
29
|
-
results: { state: true, type:
|
|
29
|
+
results: { state: true, type: Array },
|
|
30
30
|
filters: { state: true, type: Object },
|
|
31
31
|
resultAggregation: { attribute: false, type: Array },
|
|
32
32
|
selectedResult: { state: true, type: Object },
|
|
33
33
|
resultType: { attribute: "result-type", type: String },
|
|
34
|
+
resultActionIcon: { attribute: false, type: String },
|
|
34
35
|
};
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -42,6 +43,11 @@ export class EOxItemFilterResults extends LitElement {
|
|
|
42
43
|
*/
|
|
43
44
|
this.config = null;
|
|
44
45
|
|
|
46
|
+
/**
|
|
47
|
+
* @type Array
|
|
48
|
+
*/
|
|
49
|
+
this.results = null;
|
|
50
|
+
|
|
45
51
|
/**
|
|
46
52
|
* @type Object
|
|
47
53
|
*/
|
|
@@ -61,25 +67,28 @@ export class EOxItemFilterResults extends LitElement {
|
|
|
61
67
|
* @type String("list"|"card")
|
|
62
68
|
*/
|
|
63
69
|
this.resultType = "list";
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @type String
|
|
73
|
+
*/
|
|
74
|
+
this.resultActionIcon = undefined;
|
|
64
75
|
}
|
|
65
76
|
|
|
66
77
|
/**
|
|
67
78
|
* Creates a list of items based on the aggregation property.
|
|
68
79
|
*
|
|
69
|
-
* @param {string} aggregationProperty - The property used for aggregation.
|
|
70
|
-
* @returns {import("lit")} - The template result for the item list.
|
|
71
|
-
* @private
|
|
80
|
+
* @param {string} [aggregationProperty] - The property used for aggregation.
|
|
81
|
+
* @returns {import("lit").HTMLTemplateResult} - The template result for the item list.
|
|
72
82
|
*/
|
|
73
83
|
#createItemList(aggregationProperty) {
|
|
74
|
-
return createItemListMethod(
|
|
84
|
+
return createItemListMethod(this, aggregationProperty);
|
|
75
85
|
}
|
|
76
86
|
|
|
77
87
|
/**
|
|
78
88
|
* Creates item details based on the aggregation property.
|
|
79
89
|
*
|
|
80
90
|
* @param {string} aggregationProperty - The property used for aggregation.
|
|
81
|
-
* @returns {import("lit")} - The template result for the item details.
|
|
82
|
-
* @private
|
|
91
|
+
* @returns {import("lit").HTMLTemplateResult} - The template result for the item details.
|
|
83
92
|
*/
|
|
84
93
|
#createItemDetails(aggregationProperty) {
|
|
85
94
|
return createItemDetailsMethod(aggregationProperty, this);
|
|
@@ -108,7 +117,7 @@ export class EOxItemFilterResults extends LitElement {
|
|
|
108
117
|
/**
|
|
109
118
|
* Handles the toggle event for accordion.
|
|
110
119
|
*
|
|
111
|
-
* @param {
|
|
120
|
+
* @param {CustomEvent} event - The toggle event.
|
|
112
121
|
*/
|
|
113
122
|
handleAccordion(event) {
|
|
114
123
|
toggleAccordion(event, this.config, this);
|
package/src/main.js
CHANGED
|
@@ -68,6 +68,9 @@ export class EOxItemFilter extends LitElement {
|
|
|
68
68
|
},
|
|
69
69
|
externalFilter: { attribute: false, type: Function },
|
|
70
70
|
resultType: { attribute: "result-type", type: String },
|
|
71
|
+
enableResultAction: { attribute: false, type: Boolean },
|
|
72
|
+
resultActionIcon: { attribute: false, type: String },
|
|
73
|
+
styleOverride: { type: String },
|
|
71
74
|
unstyled: { type: Boolean },
|
|
72
75
|
};
|
|
73
76
|
}
|
|
@@ -241,6 +244,27 @@ export class EOxItemFilter extends LitElement {
|
|
|
241
244
|
*/
|
|
242
245
|
this.resultType = "list";
|
|
243
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Enable result action button (a secondary action besides the normal result selection)
|
|
249
|
+
*
|
|
250
|
+
* @type Boolean
|
|
251
|
+
*/
|
|
252
|
+
this.enableResultAction = false;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Icon for result action. Supports html
|
|
256
|
+
*
|
|
257
|
+
* @type String
|
|
258
|
+
*/
|
|
259
|
+
this.resultActionIcon =
|
|
260
|
+
'<svg style="width: 24px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>click me!</title><path fill="#004170" d="M11.5,11L17.88,16.37L17,16.55L16.36,16.67C15.73,16.8 15.37,17.5 15.65,18.07L15.92,18.65L17.28,21.59L15.86,22.25L14.5,19.32L14.24,18.74C13.97,18.15 13.22,17.97 12.72,18.38L12.21,18.78L11.5,19.35V11M10.76,8.69A0.76,0.76 0 0,0 10,9.45V20.9C10,21.32 10.34,21.66 10.76,21.66C10.95,21.66 11.11,21.6 11.24,21.5L13.15,19.95L14.81,23.57C14.94,23.84 15.21,24 15.5,24C15.61,24 15.72,24 15.83,23.92L18.59,22.64C18.97,22.46 19.15,22 18.95,21.63L17.28,18L19.69,17.55C19.85,17.5 20,17.43 20.12,17.29C20.39,16.97 20.35,16.5 20,16.21L11.26,8.86L11.25,8.87C11.12,8.76 10.95,8.69 10.76,8.69M15,10V8H20V10H15M13.83,4.76L16.66,1.93L18.07,3.34L15.24,6.17L13.83,4.76M10,0H12V5H10V0M3.93,14.66L6.76,11.83L8.17,13.24L5.34,16.07L3.93,14.66M3.93,3.34L5.34,1.93L8.17,4.76L6.76,6.17L3.93,3.34M7,10H2V8H7V10" /></svg>';
|
|
261
|
+
|
|
262
|
+
/** Overrides elements current CSS.
|
|
263
|
+
*
|
|
264
|
+
* @type {String}
|
|
265
|
+
*/
|
|
266
|
+
this.styleOverride = "";
|
|
267
|
+
|
|
244
268
|
/**
|
|
245
269
|
* Render the element without additional styles
|
|
246
270
|
*/
|
|
@@ -279,7 +303,9 @@ export class EOxItemFilter extends LitElement {
|
|
|
279
303
|
}),
|
|
280
304
|
);
|
|
281
305
|
if (this.inlineMode)
|
|
282
|
-
|
|
306
|
+
/** @type {import("./components/itemfilter-container").EOxItemFilterContainer} **/ (
|
|
307
|
+
this.renderRoot.querySelector("eox-itemfilter-container")
|
|
308
|
+
).updateInline();
|
|
283
309
|
this.requestUpdate();
|
|
284
310
|
}
|
|
285
311
|
|
|
@@ -298,8 +324,7 @@ export class EOxItemFilter extends LitElement {
|
|
|
298
324
|
*
|
|
299
325
|
* @param {Object} filterObject - The filter object.
|
|
300
326
|
* @param {number} tabIndex - The tab index for the filter element.
|
|
301
|
-
* @returns {import("lit")} - The template result for the filter element.
|
|
302
|
-
* @private
|
|
327
|
+
* @returns {import("lit").HTMLTemplateResult} - The template result for the filter element.
|
|
303
328
|
*/
|
|
304
329
|
#createFilter(filterObject, tabIndex) {
|
|
305
330
|
return createFilterMethod(filterObject, tabIndex, this);
|
|
@@ -310,8 +335,7 @@ export class EOxItemFilter extends LitElement {
|
|
|
310
335
|
*
|
|
311
336
|
* @param {Object} filterObject - The filter object.
|
|
312
337
|
* @param {number} tabIndex - The tab index for the reset element.
|
|
313
|
-
* @returns {import("lit")} - The template result for the filter element.
|
|
314
|
-
* @private
|
|
338
|
+
* @returns {import("lit").HTMLTemplateResult} - The template result for the filter element.
|
|
315
339
|
*/
|
|
316
340
|
#createReset(filterObject, tabIndex) {
|
|
317
341
|
return createResetMethod(filterObject, tabIndex, this);
|
|
@@ -355,9 +379,10 @@ export class EOxItemFilter extends LitElement {
|
|
|
355
379
|
updated(changedProperties) {
|
|
356
380
|
ELEMENT_PROPERTIES.map((property) => {
|
|
357
381
|
if (changedProperties.has(property)) {
|
|
358
|
-
this.firstUpdated();
|
|
382
|
+
this.firstUpdated(undefined);
|
|
359
383
|
return true;
|
|
360
384
|
}
|
|
385
|
+
return false;
|
|
361
386
|
});
|
|
362
387
|
}
|
|
363
388
|
|
|
@@ -381,6 +406,24 @@ export class EOxItemFilter extends LitElement {
|
|
|
381
406
|
this.requestUpdate();
|
|
382
407
|
}
|
|
383
408
|
|
|
409
|
+
/**
|
|
410
|
+
* Emits "click:result-action" event.
|
|
411
|
+
*
|
|
412
|
+
* @param {{detail: Object}} evt - "click:result-action" event triggered by result component
|
|
413
|
+
*/
|
|
414
|
+
emitResultAction(evt) {
|
|
415
|
+
/**
|
|
416
|
+
* Fires when a result-action is clicked; event detail is `result`
|
|
417
|
+
*/
|
|
418
|
+
this.dispatchEvent(
|
|
419
|
+
new CustomEvent("click:result-action", {
|
|
420
|
+
detail: evt.detail,
|
|
421
|
+
bubbles: true,
|
|
422
|
+
composed: true,
|
|
423
|
+
}),
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
|
|
384
427
|
/**
|
|
385
428
|
* Renders the HTML template for the component.
|
|
386
429
|
*/
|
|
@@ -471,7 +514,10 @@ export class EOxItemFilter extends LitElement {
|
|
|
471
514
|
.resultAggregation=${this.#resultAggregation}
|
|
472
515
|
.selectedResult=${this.selectedResult}
|
|
473
516
|
.resultType=${this.resultType}
|
|
517
|
+
.enableResultAction=${this.enableResultAction}
|
|
518
|
+
.resultActionIcon=${this.resultActionIcon}
|
|
474
519
|
@result=${this.updateResult}
|
|
520
|
+
@click:result-action=${this.emitResultAction}
|
|
475
521
|
>
|
|
476
522
|
<slot name="resultstitle"
|
|
477
523
|
><h6 class="main-heading">Results</h6></slot
|
|
@@ -10,7 +10,9 @@ export function handleChipClickMethod(evt, EOxItemFilterChips) {
|
|
|
10
10
|
chip.classList.remove("highlighted");
|
|
11
11
|
});
|
|
12
12
|
// Add the 'highlighted' class to the clicked chip
|
|
13
|
-
evt.target
|
|
13
|
+
if (evt.target instanceof HTMLElement) {
|
|
14
|
+
evt.target.classList.add("highlighted");
|
|
15
|
+
}
|
|
14
16
|
EOxItemFilterChips.requestUpdate();
|
|
15
17
|
}
|
|
16
18
|
|
|
@@ -29,14 +31,18 @@ export function handleCloseMethod(event, index, EOxItemFilterChips) {
|
|
|
29
31
|
/**
|
|
30
32
|
* Handles keyboard events for the EOxItemFilterChips component.
|
|
31
33
|
*
|
|
32
|
-
* @param {
|
|
34
|
+
* @param {KeyboardEvent} event - The keyboard event.
|
|
33
35
|
* @param {Object} EOxItemFilterChips - The EOxItemFilterChips component instance.
|
|
34
36
|
*/
|
|
35
37
|
export function keyboardEventListenerMethod(event, EOxItemFilterChips) {
|
|
36
38
|
const { code, target } = event;
|
|
37
39
|
|
|
38
|
-
// Ignore
|
|
39
|
-
if (
|
|
40
|
+
// Ignore the events that don't come from search input
|
|
41
|
+
if (
|
|
42
|
+
target instanceof HTMLElement &&
|
|
43
|
+
target.id !== "eox-itemfilter-input-search"
|
|
44
|
+
)
|
|
45
|
+
return;
|
|
40
46
|
|
|
41
47
|
// If the parent element is hidden and the key is one of the specified keys, do nothing
|
|
42
48
|
if (
|
|
@@ -53,7 +59,11 @@ export function keyboardEventListenerMethod(event, EOxItemFilterChips) {
|
|
|
53
59
|
|
|
54
60
|
// Handle specific keyboard keys
|
|
55
61
|
if (["ArrowLeft", "ArrowRight", "Escape", "Backspace"].includes(code))
|
|
56
|
-
handleKeyboard(
|
|
62
|
+
handleKeyboard(
|
|
63
|
+
code,
|
|
64
|
+
/** @type {HTMLInputElement} **/ (event.target).value ?? "",
|
|
65
|
+
EOxItemFilterChips,
|
|
66
|
+
);
|
|
57
67
|
}
|
|
58
68
|
|
|
59
69
|
/**
|
|
@@ -37,7 +37,7 @@ export function handleToggleDropdownMethod(event, EOxItemFilterContainer) {
|
|
|
37
37
|
/**
|
|
38
38
|
* Handles the keydown event, resetting the search and hiding the dropdown if Escape is pressed in inline mode.
|
|
39
39
|
*
|
|
40
|
-
* @param {
|
|
40
|
+
* @param {KeyboardEvent} event - The keydown event.
|
|
41
41
|
* @param {Object} EOxItemFilterContainer - The EOxItemFilterContainer component instance.
|
|
42
42
|
*/
|
|
43
43
|
export function handleKeyDownMethod(event, EOxItemFilterContainer) {
|
|
@@ -60,6 +60,7 @@ export function handleKeyDownMethod(event, EOxItemFilterContainer) {
|
|
|
60
60
|
export function handleClickOutsideMethod(event, EOxItemFilterContainer) {
|
|
61
61
|
if (
|
|
62
62
|
EOxItemFilterContainer.inlineMode &&
|
|
63
|
+
event.target instanceof HTMLElement &&
|
|
63
64
|
event.target.tagName !== "DROPDOWN-FORM" &&
|
|
64
65
|
event.target.tagName !== "EOX-ITEMFILTER" &&
|
|
65
66
|
EOxItemFilterContainer.showDropdown
|
|
@@ -4,7 +4,7 @@ import { autoUpdate, computePosition } from "@floating-ui/dom";
|
|
|
4
4
|
* Init popover autoUpdate and position
|
|
5
5
|
*
|
|
6
6
|
* @param {Object} EOxItemFilterContainer - The EOxItemFilterContainer component instance.
|
|
7
|
-
* @return {
|
|
7
|
+
* @return {() => void}
|
|
8
8
|
*/
|
|
9
9
|
function initPopover(EOxItemFilterContainer) {
|
|
10
10
|
const trigger = EOxItemFilterContainer.renderRoot.querySelector(
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* @param {Object} EOxItemFilterContainer - The EOxItemFilterContainer component instance.
|
|
6
6
|
*/
|
|
7
7
|
function resetFilterMethod(event, EOxItemFilterContainer) {
|
|
8
|
+
if (!(event.target instanceof HTMLElement)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
8
11
|
const filterKey = event.target.getAttribute("data-close").replace("|", "-");
|
|
9
12
|
EOxItemFilterContainer.querySelector(`#filter-${filterKey}`).reset();
|
|
10
13
|
EOxItemFilterContainer.dispatchEvent(new CustomEvent("filter"));
|
|
@@ -10,7 +10,10 @@ function resetSearchMethod(EOxItemFilterContainer) {
|
|
|
10
10
|
"#eox-itemfilter-input-search",
|
|
11
11
|
).value = "";
|
|
12
12
|
const event = { target: { value: "" } };
|
|
13
|
-
searchFilterMethod(
|
|
13
|
+
searchFilterMethod(
|
|
14
|
+
/** @type {Event} **/ (/** @type {unknown} **/ (event)),
|
|
15
|
+
EOxItemFilterContainer,
|
|
16
|
+
);
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
export default resetSearchMethod;
|
|
@@ -11,6 +11,9 @@ function searchFilterMethod(event, EOxItemFilterContainer) {
|
|
|
11
11
|
const fuse = new Fuse(EOxItemFilterContainer.filterProperties, {
|
|
12
12
|
keys: ["title"],
|
|
13
13
|
});
|
|
14
|
+
if (!(event.target instanceof HTMLInputElement)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
14
17
|
const inputText = event.target.value;
|
|
15
18
|
const result = fuse.search(inputText);
|
|
16
19
|
const matches = result.map((res) => res.item.key || res.item.keys.join("|"));
|
|
@@ -14,6 +14,9 @@ export function resetRangeMethod(EOxItemFilterRange) {
|
|
|
14
14
|
EOxItemFilterRange.filterObject,
|
|
15
15
|
);
|
|
16
16
|
if (EOxItemFilterRange.filterObject) {
|
|
17
|
+
/**
|
|
18
|
+
* @type {import("toolcool-range-slider").RangeSlider}
|
|
19
|
+
*/
|
|
17
20
|
const eleTCRangeSlider =
|
|
18
21
|
EOxItemFilterRange.querySelector("tc-range-slider");
|
|
19
22
|
const min = EOxItemFilterRange.filterObject.min;
|
|
@@ -27,7 +30,7 @@ export function resetRangeMethod(EOxItemFilterRange) {
|
|
|
27
30
|
/**
|
|
28
31
|
* Handles input changes for the range filter and updates the filter state accordingly.
|
|
29
32
|
*
|
|
30
|
-
* @param {
|
|
33
|
+
* @param {CustomEvent} evt - The input event that triggers the update.
|
|
31
34
|
* @param {Object} EOxItemFilterRange - The EOxItemFilterRange component instance.
|
|
32
35
|
*/
|
|
33
36
|
export function rangeInputHandlerMethod(evt, EOxItemFilterRange) {
|
|
@@ -70,7 +73,7 @@ export function rangeInputHandlerMethod(evt, EOxItemFilterRange) {
|
|
|
70
73
|
* @param {number|string} val - The value of the range label.
|
|
71
74
|
* @param {string} pos - The position of the range label (e.g., "min" or "max").
|
|
72
75
|
* @param {Object} EOxItemFilterRange - The EOxItemFilterRange component instance.
|
|
73
|
-
* @returns {
|
|
76
|
+
* @returns {import("lit").HTMLTemplateResult}
|
|
74
77
|
*/
|
|
75
78
|
export function rangeLabelMethod(val, pos, EOxItemFilterRange) {
|
|
76
79
|
const isDate = Boolean(EOxItemFilterRange.filterObject.format === "date");
|
|
@@ -67,6 +67,9 @@ export function toggleItemSelectorMethod(item, EOxItemFilterSelector) {
|
|
|
67
67
|
* @param {Object} EOxItemFilterSelector - The EOxItemFilterSelector component instance.
|
|
68
68
|
*/
|
|
69
69
|
export function handleInputSelectorMethod(event, EOxItemFilterSelector) {
|
|
70
|
+
if (!(event.target instanceof HTMLInputElement)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
70
73
|
EOxItemFilterSelector.query = event.target.value;
|
|
71
74
|
EOxItemFilterSelector.showSuggestions = true;
|
|
72
75
|
}
|
|
@@ -74,7 +77,7 @@ export function handleInputSelectorMethod(event, EOxItemFilterSelector) {
|
|
|
74
77
|
/**
|
|
75
78
|
* Handles keydown events for the selector and navigates or selects items based on the key pressed.
|
|
76
79
|
*
|
|
77
|
-
* @param {
|
|
80
|
+
* @param {KeyboardEvent} event - The keydown event.
|
|
78
81
|
* @param {Object} EOxItemFilterSelector - The EOxItemFilterSelector component instance.
|
|
79
82
|
*/
|
|
80
83
|
export function handleKeyDownSelectorMethod(event, EOxItemFilterSelector) {
|
|
@@ -8,7 +8,7 @@ import flatMap from "lodash.flatmap";
|
|
|
8
8
|
* @param {Object} filterObject - The filter object containing filter details.
|
|
9
9
|
* @param {number} tabIndex - The tab index for the filter element.
|
|
10
10
|
* @param {Object} EOxItemFilter - The EOxItemFilter component instance.
|
|
11
|
-
* @returns {
|
|
11
|
+
* @returns {import("lit").HTMLTemplateResult} The HTML template for the filter element.
|
|
12
12
|
*/
|
|
13
13
|
function createFilterMethod(filterObject, tabIndex, EOxItemFilter) {
|
|
14
14
|
// Create a unique ID for the filter element by replacing '|' with '-'
|
|
@@ -7,7 +7,7 @@ import { when } from "lit/directives/when.js";
|
|
|
7
7
|
* @param {Object} filterObject - The filter object containing filter details.
|
|
8
8
|
* @param {number} tabIndex - The tab index for the reset button.
|
|
9
9
|
* @param {Object} EOxItemFilter - The EOxItemFilter component instance.
|
|
10
|
-
* @returns {
|
|
10
|
+
* @returns {import("lit").HTMLTemplateResult} The HTML template for the reset button.
|
|
11
11
|
*/
|
|
12
12
|
function createResetMethod(filterObject, tabIndex, EOxItemFilter) {
|
|
13
13
|
return html`
|
|
@@ -9,7 +9,7 @@ import { getValue } from "../../helpers";
|
|
|
9
9
|
*
|
|
10
10
|
* @param {string} aggregationProperty - The property used for aggregation.
|
|
11
11
|
* @param {Object} EOxItemFilterResults - The EOxItemFilterResults component instance.
|
|
12
|
-
* @returns {
|
|
12
|
+
* @returns {import("lit").HTMLTemplateResult} The HTML template for the item details view.
|
|
13
13
|
*/
|
|
14
14
|
export function createItemDetailsMethod(
|
|
15
15
|
aggregationProperty,
|
|
@@ -33,7 +33,7 @@ export function createItemDetailsMethod(
|
|
|
33
33
|
</span>
|
|
34
34
|
</summary>
|
|
35
35
|
<div>
|
|
36
|
-
${createItemListMethod(
|
|
36
|
+
${createItemListMethod(EOxItemFilterResults, aggregationProperty)}
|
|
37
37
|
</div>
|
|
38
38
|
</details>
|
|
39
39
|
`;
|
|
@@ -42,13 +42,13 @@ export function createItemDetailsMethod(
|
|
|
42
42
|
/**
|
|
43
43
|
* Creates the item list view for the aggregation property in the EOxItemFilterResults component.
|
|
44
44
|
*
|
|
45
|
-
* @param {string} aggregationProperty - The property used for aggregation.
|
|
46
45
|
* @param {Object} EOxItemFilterResults - The EOxItemFilterResults component instance.
|
|
47
|
-
* @
|
|
46
|
+
* @param {string} [aggregationProperty] - The property used for aggregation.
|
|
47
|
+
* @returns {import("lit").HTMLTemplateResult} The HTML template for the item list view.
|
|
48
48
|
*/
|
|
49
49
|
export function createItemListMethod(
|
|
50
|
-
aggregationProperty,
|
|
51
50
|
EOxItemFilterResults,
|
|
51
|
+
aggregationProperty,
|
|
52
52
|
) {
|
|
53
53
|
const results = EOxItemFilterResults.results;
|
|
54
54
|
const items = aggregationProperty
|
|
@@ -125,6 +125,23 @@ export function createItemListMethod(
|
|
|
125
125
|
`,
|
|
126
126
|
)}
|
|
127
127
|
</span>
|
|
128
|
+
${when(
|
|
129
|
+
EOxItemFilterResults.enableResultAction,
|
|
130
|
+
() => html`
|
|
131
|
+
<span
|
|
132
|
+
class="result-action"
|
|
133
|
+
@click=${(event) => {
|
|
134
|
+
event.stopPropagation(); // prevents emitting the `li` event above
|
|
135
|
+
EOxItemFilterResults.dispatchEvent(
|
|
136
|
+
new CustomEvent("click:result-action", {
|
|
137
|
+
detail: item,
|
|
138
|
+
}),
|
|
139
|
+
);
|
|
140
|
+
}}
|
|
141
|
+
>${unsafeHTML(EOxItemFilterResults.resultActionIcon)}</span
|
|
142
|
+
>
|
|
143
|
+
`,
|
|
144
|
+
)}
|
|
128
145
|
</li>
|
|
129
146
|
`,
|
|
130
147
|
)}
|