@eox/itemfilter 1.3.0 → 1.4.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/README.md +4 -0
- package/dist/eox-itemfilter.js +1156 -1276
- package/dist/eox-itemfilter.umd.cjs +110 -112
- package/package.json +8 -13
- package/src/components/chips.js +131 -0
- package/src/components/expand-container.js +94 -0
- package/src/components/filters/range.js +114 -0
- package/src/components/filters/selector.js +245 -0
- package/src/components/filters/spatial.js +192 -0
- package/src/components/filters/text.js +114 -0
- package/src/components/itemfilter-container.js +289 -0
- package/src/components/results.js +156 -0
- package/src/enums/config.js +104 -0
- package/src/enums/index.js +1 -0
- package/src/helpers/chip-items.js +19 -0
- package/src/helpers/filter-client.js +179 -0
- package/src/helpers/filter-external.js +18 -0
- package/src/helpers/get-value.js +12 -0
- package/src/helpers/highlighting.js +79 -0
- package/src/helpers/index.js +11 -0
- package/src/helpers/is-filters-dirty.js +13 -0
- package/src/helpers/map-layers.js +42 -0
- package/src/helpers/reset-filter.js +60 -0
- package/src/helpers/spatial.js +35 -0
- package/src/helpers/tab-index.js +13 -0
- package/src/helpers/toggle-accordion.js +39 -0
- package/src/main.js +466 -0
- package/src/methods/chips/handler.js +129 -0
- package/src/methods/chips/index.js +5 -0
- package/src/methods/container/handler.js +70 -0
- package/src/methods/container/index.js +10 -0
- package/src/methods/container/init-popver.js +34 -0
- package/src/methods/container/reset-filter.js +14 -0
- package/src/methods/container/reset-search.js +16 -0
- package/src/methods/container/search-filter.js +27 -0
- package/src/methods/filters/index.js +20 -0
- package/src/methods/filters/range.js +78 -0
- package/src/methods/filters/selector.js +209 -0
- package/src/methods/filters/spatial.js +114 -0
- package/src/methods/filters/text.js +32 -0
- package/src/methods/itemfilter/create-filter.js +83 -0
- package/src/methods/itemfilter/create-reset.js +39 -0
- package/src/methods/itemfilter/filter-apply.js +140 -0
- package/src/methods/itemfilter/index.js +6 -0
- package/src/methods/itemfilter/reset-filter.js +13 -0
- package/src/methods/itemfilter/search.js +23 -0
- package/src/methods/itemfilter/sort-results.js +14 -0
- package/src/methods/results/aggregate-results.js +43 -0
- package/src/methods/results/create.js +111 -0
- package/src/methods/results/index.js +2 -0
- package/src/style.eox.js +457 -0
- package/src/style.js +26 -0
- package/test/_mockMap.js +0 -20
- package/test/cases/filters/filter-keys.js +0 -22
- package/test/cases/filters/index.js +0 -3
- package/test/cases/general/accordion.js +0 -60
- package/test/cases/general/disable-highlight.js +0 -21
- package/test/cases/general/external-filter.js +0 -35
- package/test/cases/general/highlight-result.js +0 -16
- package/test/cases/general/index.js +0 -13
- package/test/cases/general/multiple-filters.js +0 -21
- package/test/cases/general/nested-property.js +0 -25
- package/test/cases/general/search-bar.js +0 -12
- package/test/cases/general/search-result.js +0 -14
- package/test/cases/general/spatial-filter.js +0 -22
- package/test/cases/general/subtitle.js +0 -15
- package/test/cases/general/validation.js +0 -22
- package/test/cases/state/custom-order.js +0 -24
- package/test/cases/state/index.js +0 -6
- package/test/cases/state/render-checkbox.js +0 -17
- package/test/cases/state/result-pre-checked.js +0 -20
- package/test/cases/state/results-with-pre-set-filters.js +0 -30
- package/test/filters.cy.js +0 -54
- package/test/general.cy.js +0 -110
- package/test/state.cy.js +0 -74
- package/test/testItems.json +0 -440
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { LitElement, html, nothing } from "lit";
|
|
2
|
+
import { map } from "lit/directives/map.js";
|
|
3
|
+
import { when } from "lit/directives/when.js";
|
|
4
|
+
import booleanWithin from "@turf/boolean-within";
|
|
5
|
+
import {
|
|
6
|
+
handleClickSpatialMethod,
|
|
7
|
+
resetSpatialFilterMethod,
|
|
8
|
+
resetSpatialMethod,
|
|
9
|
+
setupSpatialMethod,
|
|
10
|
+
} from "../../methods/filters/index.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Determines if one geometry is within another using Turf.js booleanWithin function.
|
|
14
|
+
*
|
|
15
|
+
* @param {Object} itemGeometry - The geometry of the item.
|
|
16
|
+
* @param {Object} filterGeometry - The geometry of the filter.
|
|
17
|
+
* @returns {boolean} - True if itemGeometry is within filterGeometry, otherwise false.
|
|
18
|
+
*/
|
|
19
|
+
export const within = (itemGeometry, filterGeometry) => {
|
|
20
|
+
if (!filterGeometry) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return booleanWithin(itemGeometry, filterGeometry);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* EOxItemFilterSpatial is a custom web component that provides a spatial filter for items.
|
|
28
|
+
* The component allows users to select a spatial filter mode (intersects or within) and apply it to a map.
|
|
29
|
+
*
|
|
30
|
+
* @module EOxItemFilterSpatial
|
|
31
|
+
* @extends 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
|
+
*/
|
|
35
|
+
class EOxItemFilterSpatial extends LitElement {
|
|
36
|
+
// Define properties with defaults and types
|
|
37
|
+
static get properties() {
|
|
38
|
+
return {
|
|
39
|
+
filterObject: { type: Object },
|
|
40
|
+
tabIndex: { attribute: false, type: Number },
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
constructor() {
|
|
45
|
+
super();
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @type Object
|
|
49
|
+
*/
|
|
50
|
+
this.filterObject = {};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @type Number
|
|
54
|
+
*/
|
|
55
|
+
this.tabIndex = 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Resets the spatial filter using the resetSpatialMethod.
|
|
60
|
+
*/
|
|
61
|
+
reset() {
|
|
62
|
+
resetSpatialMethod(this);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Overrides the default createRenderRoot method to render in the light DOM.
|
|
67
|
+
*
|
|
68
|
+
* @returns {this} - The current instance to render in the light DOM.
|
|
69
|
+
*/
|
|
70
|
+
createRenderRoot() {
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Handles the click event for spatial filter mode selection.
|
|
76
|
+
*
|
|
77
|
+
* @private
|
|
78
|
+
* @param {string} mode - The mode of the spatial filter (e.g., "intersects", "within").
|
|
79
|
+
*/
|
|
80
|
+
#handleClick(mode) {
|
|
81
|
+
handleClickSpatialMethod(mode, this);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Renders the HTML template for the component.he template result for rendering.
|
|
86
|
+
*/
|
|
87
|
+
render() {
|
|
88
|
+
return when(
|
|
89
|
+
this.filterObject,
|
|
90
|
+
() => html`
|
|
91
|
+
<form style="display: inline">
|
|
92
|
+
${map(
|
|
93
|
+
["intersects", "within"],
|
|
94
|
+
(mode) => html`
|
|
95
|
+
<label>
|
|
96
|
+
<input
|
|
97
|
+
tabindex=${this.tabIndex}
|
|
98
|
+
type="radio"
|
|
99
|
+
name="mode"
|
|
100
|
+
.checked="${(this.filterObject.state.mode || "") === mode ||
|
|
101
|
+
nothing}"
|
|
102
|
+
value="${mode}"
|
|
103
|
+
@click=${() => this.#handleClick(mode)}
|
|
104
|
+
/>
|
|
105
|
+
<small>${mode} filter geometry</small>
|
|
106
|
+
</label>
|
|
107
|
+
`,
|
|
108
|
+
)}
|
|
109
|
+
</form>
|
|
110
|
+
<eox-itemfilter-spatial-filter
|
|
111
|
+
exportparts="map: spatial-filter-map"
|
|
112
|
+
.geometry="${this.filterObject.state?.geometry}"
|
|
113
|
+
@filter="${(e) => {
|
|
114
|
+
this.filterObject.state.geometry = e.detail.geometry;
|
|
115
|
+
this.filterObject.dirty = true;
|
|
116
|
+
this.filterObject.stringifiedState = "Polygon";
|
|
117
|
+
this.dispatchEvent(new CustomEvent("filter"));
|
|
118
|
+
}}"
|
|
119
|
+
></eox-itemfilter-spatial>
|
|
120
|
+
`,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
customElements.define("eox-itemfilter-spatial", EOxItemFilterSpatial);
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* SpatialFilter is a custom web component that renders a map and allows users to apply spatial filters.
|
|
129
|
+
* It uses the LitElement base class and integrates with external methods for setup and reset functionalities.
|
|
130
|
+
*
|
|
131
|
+
* @module SpatialFilter
|
|
132
|
+
* @extends LitElement
|
|
133
|
+
* @property {Object} geometry - The geometry object used for the spatial filter.
|
|
134
|
+
* @property {Object} eoxMap - The map object used to display and interact with the spatial filter.
|
|
135
|
+
*/
|
|
136
|
+
class SpatialFilter extends LitElement {
|
|
137
|
+
// Define properties with defaults and types
|
|
138
|
+
static get properties() {
|
|
139
|
+
return {
|
|
140
|
+
geometry: { type: Object },
|
|
141
|
+
eoxMap: { type: Object },
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
constructor() {
|
|
146
|
+
super();
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @type Object
|
|
150
|
+
*/
|
|
151
|
+
this.geometry = null;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @type Object
|
|
155
|
+
*/
|
|
156
|
+
this.eoxMap = null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Lifecycle method called after the first update. Initializes the spatial filter.
|
|
161
|
+
*/
|
|
162
|
+
firstUpdated() {
|
|
163
|
+
this.#setup();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Sets up the spatial filter using the setupSpatialMethod.
|
|
168
|
+
*
|
|
169
|
+
* @private
|
|
170
|
+
*/
|
|
171
|
+
#setup() {
|
|
172
|
+
setupSpatialMethod(this);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Resets the spatial filter using the resetSpatialFilterMethod.
|
|
177
|
+
*/
|
|
178
|
+
reset() {
|
|
179
|
+
resetSpatialFilterMethod(this);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Renders the HTML template for the component.
|
|
184
|
+
*/
|
|
185
|
+
render() {
|
|
186
|
+
return html`<div id="eox-map"></div>`;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
customElements.define("eox-itemfilter-spatial-filter", SpatialFilter);
|
|
191
|
+
|
|
192
|
+
export { EOxItemFilterSpatial, SpatialFilter };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { LitElement, html } from "lit";
|
|
2
|
+
import _debounce from "lodash.debounce";
|
|
3
|
+
import { when } from "lit/directives/when.js";
|
|
4
|
+
import { resetTextMethod, textInputHandlerMethod } from "../../methods/filters";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* EOxItemFilterText is a custom web component that provides a text input field for filtering items.
|
|
8
|
+
*
|
|
9
|
+
* @module EOxItemFilterText
|
|
10
|
+
* @extends LitElement
|
|
11
|
+
* @property {Object} filterObject - The filter object containing the state and placeholder.
|
|
12
|
+
* @property {Number} tabIndex - The tab index for the input element.
|
|
13
|
+
* @property {Boolean} unstyled - Flag to determine if default styles should be applied.
|
|
14
|
+
*/
|
|
15
|
+
export class EOxItemFilterText extends LitElement {
|
|
16
|
+
// Define properties with defaults and types
|
|
17
|
+
static get properties() {
|
|
18
|
+
return {
|
|
19
|
+
filterObject: { attribute: false, type: Object },
|
|
20
|
+
tabIndex: { attribute: false, type: Number },
|
|
21
|
+
unstyled: { type: Boolean },
|
|
22
|
+
isValid: { state: true, type: Boolean },
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @type Object
|
|
31
|
+
*/
|
|
32
|
+
this.filterObject = {};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @type Boolean
|
|
36
|
+
*/
|
|
37
|
+
this.unstyled = false;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @type Number
|
|
41
|
+
*/
|
|
42
|
+
this.tabIndex = 0;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @type Boolean
|
|
46
|
+
*/
|
|
47
|
+
this.unstyled = false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Handles the input event by calling the textInputHandlerMethod with the current context.
|
|
52
|
+
*
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
#inputHandler = () => {
|
|
56
|
+
textInputHandlerMethod(this);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Resets the text input by calling the resetTextMethod with the current context.
|
|
61
|
+
*/
|
|
62
|
+
reset() {
|
|
63
|
+
resetTextMethod(this);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Debounced version of the input handler to improve performance by limiting the rate at which the input handler is called.
|
|
68
|
+
*/
|
|
69
|
+
debouncedInputHandler = _debounce(this.#inputHandler, 500, {
|
|
70
|
+
leading: true,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Overrides the default createRenderRoot method to render in the light DOM.
|
|
75
|
+
*
|
|
76
|
+
* @returns {this} - The current instance to render in the light DOM.
|
|
77
|
+
*/
|
|
78
|
+
createRenderRoot() {
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Render method for UI display
|
|
83
|
+
render() {
|
|
84
|
+
return when(
|
|
85
|
+
this.filterObject,
|
|
86
|
+
() => html`
|
|
87
|
+
<style></style>
|
|
88
|
+
<div class="text-container">
|
|
89
|
+
<div class="text-container-wrapper">
|
|
90
|
+
<input
|
|
91
|
+
type="text"
|
|
92
|
+
placeholder=${this.filterObject.placeholder}
|
|
93
|
+
data-cy="search"
|
|
94
|
+
class="text-input"
|
|
95
|
+
part="input-search"
|
|
96
|
+
value="${Object.values(this.filterObject.state)[0]}"
|
|
97
|
+
tabindex=${this.tabIndex}
|
|
98
|
+
pattern="${this.filterObject.validation?.pattern || ".*"}"
|
|
99
|
+
@input="${this.debouncedInputHandler}"
|
|
100
|
+
@click=${(evt) => evt.stopPropagation()}
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
<small class="error-validation"
|
|
105
|
+
>${this.filterObject.validation && this.isValid === false
|
|
106
|
+
? this.filterObject.validation.message
|
|
107
|
+
: ""}</small
|
|
108
|
+
>
|
|
109
|
+
`,
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
customElements.define("eox-itemfilter-text", EOxItemFilterText);
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { LitElement, html } from "lit";
|
|
2
|
+
import { when } from "lit/directives/when.js";
|
|
3
|
+
import { styleEOX } from "../style.eox";
|
|
4
|
+
import {
|
|
5
|
+
searchFilterMethod,
|
|
6
|
+
resetFilterMethod,
|
|
7
|
+
handleFormClickMethod,
|
|
8
|
+
handleShowDropdownOnFocusMethod,
|
|
9
|
+
handleToggleDropdownMethod,
|
|
10
|
+
handleKeyDownMethod,
|
|
11
|
+
handleClickOutsideMethod,
|
|
12
|
+
initPopoverMethod,
|
|
13
|
+
} from "../methods/container";
|
|
14
|
+
import { getChipItems, isFiltersDirty } from "../helpers";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* EOxItemFilterContainer is a custom web component that provides a container for item filters.
|
|
18
|
+
*
|
|
19
|
+
* @module EOxItemFilterContainer
|
|
20
|
+
* @extends LitElement
|
|
21
|
+
* @property {Object} filterProperties - The properties for the filter.
|
|
22
|
+
* @property {Boolean} inlineMode - Flag to determine if the component should operate in inline mode.
|
|
23
|
+
* @property {Boolean} unstyled - Flag to determine if default styles should be applied.
|
|
24
|
+
* @property {Object} filters - The filters applied in the container.
|
|
25
|
+
*/
|
|
26
|
+
export class EOxItemFilterContainer extends LitElement {
|
|
27
|
+
// Define properties with defaults and types
|
|
28
|
+
static get properties() {
|
|
29
|
+
return {
|
|
30
|
+
filterProperties: { attribute: false, type: Object },
|
|
31
|
+
inlineMode: { attribute: "inline-mode", type: Boolean },
|
|
32
|
+
unstyled: { type: Boolean },
|
|
33
|
+
filters: { state: true, type: Object },
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
constructor() {
|
|
38
|
+
super();
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @type Object
|
|
42
|
+
*/
|
|
43
|
+
this.filterProperties = {};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @type Boolean
|
|
47
|
+
*/
|
|
48
|
+
this.unstyled = false;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @type Boolean
|
|
52
|
+
*/
|
|
53
|
+
this.inlineMode = false;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @type Object
|
|
57
|
+
*/
|
|
58
|
+
this.filters = {};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @type Function
|
|
62
|
+
*/
|
|
63
|
+
this._handleClickOutside = this.#handleClickOutside.bind(this);
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @type Function
|
|
67
|
+
*/
|
|
68
|
+
this._handleKeyDown = this.#handleKeyDown.bind(this);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @type Boolean
|
|
73
|
+
*/
|
|
74
|
+
set showDropdown(show) {
|
|
75
|
+
this.renderRoot.querySelector("[popover]").togglePopover(show);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
get showDropdown() {
|
|
79
|
+
return this.renderRoot.querySelector("[popover]")?.matches(":popover-open");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
#handlePopover() {
|
|
83
|
+
// Wait for first render tick
|
|
84
|
+
setTimeout(() => (this._overlayCleanup = initPopoverMethod(this)));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Function to add all the inline mode event listener
|
|
89
|
+
*/
|
|
90
|
+
#addInlineModeEventListener() {
|
|
91
|
+
document.addEventListener("click", this._handleClickOutside);
|
|
92
|
+
document.addEventListener("focusout", this._handleClickOutside);
|
|
93
|
+
document.addEventListener("keydown", this._handleKeyDown);
|
|
94
|
+
this.#handlePopover();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Lifecycle method called when the element is connected to the DOM.
|
|
99
|
+
* Adds event listeners if inline mode is enabled.
|
|
100
|
+
*/
|
|
101
|
+
connectedCallback() {
|
|
102
|
+
super.connectedCallback();
|
|
103
|
+
if (this.inlineMode) this.#addInlineModeEventListener();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Function to remove all the inline mode event listener
|
|
108
|
+
*/
|
|
109
|
+
#removeInlineModeEventListener() {
|
|
110
|
+
document.removeEventListener("click", this._handleClickOutside);
|
|
111
|
+
document.removeEventListener("focusout", this._handleClickOutside);
|
|
112
|
+
document.removeEventListener("keydown", this._handleKeyDown);
|
|
113
|
+
this._overlayCleanup();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Lifecycle method called when the element is disconnected from the DOM.
|
|
118
|
+
* Removes event listeners if inline mode is enabled.
|
|
119
|
+
*/
|
|
120
|
+
disconnectedCallback() {
|
|
121
|
+
if (this.inlineMode) this.#removeInlineModeEventListener();
|
|
122
|
+
super.disconnectedCallback();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Stores the autoUpdate cleanup function to be called
|
|
127
|
+
* when disconnected
|
|
128
|
+
* @private
|
|
129
|
+
*/
|
|
130
|
+
_overlayCleanup() {}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Handles click events outside the component to close the dropdown.
|
|
134
|
+
*
|
|
135
|
+
* @param {Event} event - The click event.
|
|
136
|
+
* @private
|
|
137
|
+
*/
|
|
138
|
+
#handleClickOutside(event) {
|
|
139
|
+
handleClickOutsideMethod(event, this);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Handles keydown events for the component.
|
|
144
|
+
*
|
|
145
|
+
* @param {Event} event - The keydown event.
|
|
146
|
+
* @private
|
|
147
|
+
*/
|
|
148
|
+
#handleKeyDown(event) {
|
|
149
|
+
handleKeyDownMethod(event, this);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Toggles the dropdown visibility.
|
|
154
|
+
*
|
|
155
|
+
* @param {Event} event - The toggle event.
|
|
156
|
+
* @private
|
|
157
|
+
*/
|
|
158
|
+
#handleToggleDropdown(event) {
|
|
159
|
+
handleToggleDropdownMethod(event, this);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Shows the dropdown on input focus.
|
|
164
|
+
*
|
|
165
|
+
* @private
|
|
166
|
+
*/
|
|
167
|
+
#handleShowDropdownOnFocus() {
|
|
168
|
+
handleShowDropdownOnFocusMethod(this);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Handles click events on the form to prevent closing the dropdown.
|
|
173
|
+
*
|
|
174
|
+
* @param {Event} event - The click event.
|
|
175
|
+
* @private
|
|
176
|
+
*/
|
|
177
|
+
#handleFormClick(event) {
|
|
178
|
+
handleFormClickMethod(event, this);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Resets the filter using the resetFilterMethod.
|
|
183
|
+
*
|
|
184
|
+
* @param {Event} event - The reset event.
|
|
185
|
+
* @private
|
|
186
|
+
*/
|
|
187
|
+
#resetFilter(event) {
|
|
188
|
+
resetFilterMethod(event, this);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Searches the filter using the searchFilterMethod.
|
|
193
|
+
*
|
|
194
|
+
* @param {Event} event - The search event.
|
|
195
|
+
* @private
|
|
196
|
+
*/
|
|
197
|
+
#searchFilter(event) {
|
|
198
|
+
searchFilterMethod(event, this);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Re renders when inline mode is configured
|
|
203
|
+
*
|
|
204
|
+
*/
|
|
205
|
+
updateInline() {
|
|
206
|
+
if (this.inlineMode) this.requestUpdate();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
updated(_changedProperties) {
|
|
210
|
+
if (_changedProperties.has("inlineMode")) {
|
|
211
|
+
if (this.inlineMode) this.#addInlineModeEventListener();
|
|
212
|
+
else this.#removeInlineModeEventListener();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Renders the HTML template for the component.
|
|
218
|
+
*/
|
|
219
|
+
render() {
|
|
220
|
+
return html`
|
|
221
|
+
<style>
|
|
222
|
+
${!this.unstyled && styleEOX}
|
|
223
|
+
</style>
|
|
224
|
+
${this.inlineMode
|
|
225
|
+
? html`
|
|
226
|
+
<div
|
|
227
|
+
class="inline-container-wrapper"
|
|
228
|
+
@click="${this.#handleToggleDropdown}"
|
|
229
|
+
>
|
|
230
|
+
<div class="inline-container" part="container">
|
|
231
|
+
<div class="chip-container">
|
|
232
|
+
<div class="chip-wrapper">
|
|
233
|
+
<eox-itemfilter-chips
|
|
234
|
+
.items=${getChipItems(this.filters)}
|
|
235
|
+
.controller=${{
|
|
236
|
+
remove: (event) => this.#resetFilter(event),
|
|
237
|
+
}}
|
|
238
|
+
>
|
|
239
|
+
</eox-itemfilter-chips>
|
|
240
|
+
</div>
|
|
241
|
+
|
|
242
|
+
${when(
|
|
243
|
+
isFiltersDirty(this.filters),
|
|
244
|
+
() => html`
|
|
245
|
+
<span
|
|
246
|
+
class="chip-close"
|
|
247
|
+
@click=${() =>
|
|
248
|
+
this.dispatchEvent(new CustomEvent("reset"))}
|
|
249
|
+
></span>
|
|
250
|
+
`,
|
|
251
|
+
)}
|
|
252
|
+
</div>
|
|
253
|
+
<div
|
|
254
|
+
class="input-container ${isFiltersDirty(this.filters)
|
|
255
|
+
? "dirty-filter-input"
|
|
256
|
+
: ""}"
|
|
257
|
+
>
|
|
258
|
+
<input
|
|
259
|
+
autocomplete="off"
|
|
260
|
+
id="eox-itemfilter-input-search"
|
|
261
|
+
type="text"
|
|
262
|
+
@click="${this.#handleToggleDropdown}"
|
|
263
|
+
@focus="${this.#handleShowDropdownOnFocus}"
|
|
264
|
+
@input="${this.#searchFilter}"
|
|
265
|
+
placeholder="Search and add filter"
|
|
266
|
+
aria-haspopup="true"
|
|
267
|
+
aria-expanded="${this.showDropdown}"
|
|
268
|
+
/>
|
|
269
|
+
</div>
|
|
270
|
+
</div>
|
|
271
|
+
<div popover="manual">
|
|
272
|
+
<div
|
|
273
|
+
class="inline-content"
|
|
274
|
+
slot="content"
|
|
275
|
+
@keydown="${this.#handleKeyDown}"
|
|
276
|
+
@click="${this.#handleFormClick}"
|
|
277
|
+
@focus="${this.#handleFormClick}"
|
|
278
|
+
>
|
|
279
|
+
<slot name="section"></slot>
|
|
280
|
+
</div>
|
|
281
|
+
</div>
|
|
282
|
+
</div>
|
|
283
|
+
`
|
|
284
|
+
: html`<slot name="section"></slot>`}
|
|
285
|
+
`;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
customElements.define("eox-itemfilter-container", EOxItemFilterContainer);
|