@eox/itemfilter 1.16.0 → 1.17.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 +238 -202
- package/dist/eox-itemfilter.umd.cjs +57 -38
- package/package.json +4 -3
- package/src/components/filters/range.js +70 -14
- package/src/enums/config.js +2 -0
- package/src/enums/index.js +1 -1
- package/src/helpers/filter-client.js +1 -1
- package/src/helpers/index.js +1 -0
- package/src/helpers/is-date.js +9 -0
- package/src/methods/filters/range.js +20 -11
- package/src/methods/itemfilter/create-filter.js +3 -0
- package/src/methods/itemfilter/filter-apply.js +1 -1
- package/src/style.eox.js +2 -0
- package/types/components/filters/range.d.ts +9 -0
- package/types/components/filters/range.d.ts.map +1 -1
- package/types/enums/config.d.ts +1 -0
- package/types/enums/config.d.ts.map +1 -1
- package/types/enums/index.d.ts +1 -1
- package/types/helpers/index.d.ts +1 -0
- package/types/helpers/is-date.d.ts +8 -0
- package/types/helpers/is-date.d.ts.map +1 -0
- package/types/methods/filters/range.d.ts.map +1 -1
- package/types/methods/itemfilter/create-filter.d.ts.map +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.17.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.0.
|
|
12
|
+
"vite": "^8.0.12"
|
|
13
13
|
},
|
|
14
14
|
"engines": {
|
|
15
15
|
"npm": ">=8.0.0",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@eox/layout": "*",
|
|
57
|
-
"@eox/map": ">=2.0.0 || >=2.1.0-dev.1"
|
|
57
|
+
"@eox/map": ">=2.0.0 || >=2.1.0-dev.1",
|
|
58
|
+
"@eox/timecontrol": ">=2.0.0"
|
|
58
59
|
}
|
|
59
60
|
}
|
|
@@ -2,11 +2,14 @@ import { LitElement, html } from "lit";
|
|
|
2
2
|
import { when } from "lit/directives/when.js";
|
|
3
3
|
import _debounce from "lodash.debounce";
|
|
4
4
|
import "toolcool-range-slider";
|
|
5
|
+
import dayjs from "dayjs";
|
|
6
|
+
import { DATE_TIME_FORMAT } from "../../enums/index.js";
|
|
5
7
|
import {
|
|
6
8
|
rangeInputHandlerMethod,
|
|
7
9
|
rangeLabelMethod,
|
|
8
10
|
resetRangeMethod,
|
|
9
11
|
} from "../../methods/filters/index.js";
|
|
12
|
+
import { isDate } from "../../helpers/index.js";
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* EOxItemFilterRange is a custom web component that provides a range slider for filtering items.
|
|
@@ -16,12 +19,14 @@ import {
|
|
|
16
19
|
* @module EOxItemFilterRange
|
|
17
20
|
* @extends LitElement
|
|
18
21
|
* @property {Object} filterObject - The filter object containing state and range limits.
|
|
22
|
+
* @property {Array} suggestions - The list of suggestions for the selector.
|
|
19
23
|
* @property {Number} tabIndex - The tab index for the input elements.
|
|
20
24
|
*/
|
|
21
25
|
export class EOxItemFilterRange extends LitElement {
|
|
22
26
|
// Define properties with defaults and types
|
|
23
27
|
static properties = {
|
|
24
28
|
filterObject: { attribute: false, type: Object },
|
|
29
|
+
suggestions: { attribute: false, type: Array },
|
|
25
30
|
tabIndex: { attribute: false, type: Number },
|
|
26
31
|
};
|
|
27
32
|
|
|
@@ -33,6 +38,11 @@ export class EOxItemFilterRange extends LitElement {
|
|
|
33
38
|
*/
|
|
34
39
|
this.filterObject = {};
|
|
35
40
|
|
|
41
|
+
/**
|
|
42
|
+
* @type Array
|
|
43
|
+
*/
|
|
44
|
+
this.suggestions = [];
|
|
45
|
+
|
|
36
46
|
/**
|
|
37
47
|
* @type Boolean
|
|
38
48
|
*/
|
|
@@ -94,20 +104,66 @@ export class EOxItemFilterRange extends LitElement {
|
|
|
94
104
|
return when(
|
|
95
105
|
this.filterObject,
|
|
96
106
|
() => html`
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
${when(
|
|
108
|
+
isDate(this.filterObject),
|
|
109
|
+
() => html`
|
|
110
|
+
<eox-timecontrol
|
|
111
|
+
.controlValues=${[
|
|
112
|
+
{
|
|
113
|
+
id: this.filterObject.key,
|
|
114
|
+
title: this.filterObject.title || "Filter",
|
|
115
|
+
timeControlValues: (
|
|
116
|
+
this.filterObject.filterKeys ||
|
|
117
|
+
this.suggestions ||
|
|
118
|
+
[]
|
|
119
|
+
).map((item) =>
|
|
120
|
+
typeof item === "object" ? item : { date: item },
|
|
121
|
+
),
|
|
122
|
+
},
|
|
123
|
+
]}
|
|
124
|
+
.initDate=${[
|
|
125
|
+
dayjs(this.filterObject.state.min || this.filterObject.min),
|
|
126
|
+
dayjs(this.filterObject.state.max || this.filterObject.max),
|
|
127
|
+
]}
|
|
128
|
+
@select=${(e) =>
|
|
129
|
+
rangeInputHandlerMethod(
|
|
130
|
+
new CustomEvent("values", {
|
|
131
|
+
detail: {
|
|
132
|
+
values: [
|
|
133
|
+
dayjs(e.detail.date[0]).valueOf(),
|
|
134
|
+
dayjs(e.detail.date[1]).valueOf(),
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
}),
|
|
138
|
+
this,
|
|
139
|
+
)}
|
|
140
|
+
>
|
|
141
|
+
<eox-timecontrol-date
|
|
142
|
+
.format=${DATE_TIME_FORMAT}
|
|
143
|
+
></eox-timecontrol-date>
|
|
144
|
+
<eox-timecontrol-picker
|
|
145
|
+
popup
|
|
146
|
+
range
|
|
147
|
+
show-dots
|
|
148
|
+
.position=${["bottom", "left"]}
|
|
149
|
+
></eox-timecontrol-picker>
|
|
150
|
+
</eox-timecontrol>
|
|
151
|
+
`,
|
|
152
|
+
() => html`
|
|
153
|
+
<div style="display: flex; gap: .5rem; align-items: center;">
|
|
154
|
+
${this.#label("min", "before")}
|
|
155
|
+
<tc-range-slider
|
|
156
|
+
min="${this.filterObject.min}"
|
|
157
|
+
max="${this.filterObject.max}"
|
|
158
|
+
value1="${this.filterObject.state.min || this.filterObject.min}"
|
|
159
|
+
value2="${this.filterObject.state.max || this.filterObject.max}"
|
|
160
|
+
step="${this.filterObject.step || 1}"
|
|
161
|
+
@change=${this.debouncedInputHandler}
|
|
162
|
+
></tc-range-slider>
|
|
163
|
+
${this.#label("max", "after")}
|
|
164
|
+
</div>
|
|
165
|
+
`,
|
|
166
|
+
)}
|
|
111
167
|
`,
|
|
112
168
|
);
|
|
113
169
|
}
|
package/src/enums/config.js
CHANGED
package/src/enums/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ELEMENT_CONFIG, ELEMENT_PROPERTIES } from "./config";
|
|
1
|
+
export { ELEMENT_CONFIG, ELEMENT_PROPERTIES, DATE_TIME_FORMAT } from "./config";
|
|
@@ -100,7 +100,7 @@ export const filter = async (items, filters, config) => {
|
|
|
100
100
|
for (const [key, value] of Object.entries(rangeFilters)) {
|
|
101
101
|
// Function to parse value based on format
|
|
102
102
|
const parseValue = (input) => {
|
|
103
|
-
return value.format === "date" ? dayjs(input).
|
|
103
|
+
return value.format === "date" ? dayjs(input).valueOf() : input;
|
|
104
104
|
};
|
|
105
105
|
const rangeValue = getValue(key, results[i]);
|
|
106
106
|
if (rangeValue) {
|
package/src/helpers/index.js
CHANGED
|
@@ -11,3 +11,4 @@ export { default as toggleAccordion } from "./toggle-accordion";
|
|
|
11
11
|
export { default as getValue } from "./get-value";
|
|
12
12
|
export { default as capitalize } from "./capitalize";
|
|
13
13
|
export { default as mergeHighlightIndices } from "./merge-highlight-indices";
|
|
14
|
+
export { default as isDate } from "./is-date";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the filterObject format is date-like.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} filterObject - The filter object.
|
|
5
|
+
* @returns {boolean} True if it is a date, otherwise false.
|
|
6
|
+
*/
|
|
7
|
+
export default function isDate(filterObject) {
|
|
8
|
+
return Boolean(filterObject.format === "date");
|
|
9
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { resetFilter } from "../../helpers/index.js";
|
|
1
|
+
import { resetFilter, isDate } from "../../helpers/index.js";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
3
|
import { html } from "lit";
|
|
4
|
-
|
|
5
|
-
const DATE_TIME_FORMAT = "ddd, D MMM YYYY HH:mm:ss";
|
|
4
|
+
import { DATE_TIME_FORMAT } from "../../enums/index.js";
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Resets the range filter to its default state and requests an update.
|
|
@@ -14,15 +13,26 @@ export function resetRangeMethod(EOxItemFilterRange) {
|
|
|
14
13
|
EOxItemFilterRange.filterObject,
|
|
15
14
|
);
|
|
16
15
|
if (EOxItemFilterRange.filterObject) {
|
|
16
|
+
const min = EOxItemFilterRange.filterObject.min;
|
|
17
|
+
const max = EOxItemFilterRange.filterObject.max;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @type {import("@eox/timecontrol").EOxTimeControl}
|
|
21
|
+
*/
|
|
22
|
+
const eleTimeControl = EOxItemFilterRange.querySelector("eox-timecontrol");
|
|
23
|
+
if (eleTimeControl) {
|
|
24
|
+
eleTimeControl.dateChange([dayjs(min), dayjs(max)], eleTimeControl);
|
|
25
|
+
}
|
|
26
|
+
|
|
17
27
|
/**
|
|
18
28
|
* @type {import("toolcool-range-slider").RangeSlider}
|
|
19
29
|
*/
|
|
20
30
|
const eleTCRangeSlider =
|
|
21
31
|
EOxItemFilterRange.querySelector("tc-range-slider");
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
if (eleTCRangeSlider) {
|
|
33
|
+
if (eleTCRangeSlider.value1 !== min) eleTCRangeSlider.value1 = min;
|
|
34
|
+
if (eleTCRangeSlider.value2 !== max) eleTCRangeSlider.value2 = max;
|
|
35
|
+
}
|
|
26
36
|
}
|
|
27
37
|
EOxItemFilterRange.requestUpdate();
|
|
28
38
|
}
|
|
@@ -52,7 +62,7 @@ export function rangeInputHandlerMethod(evt, EOxItemFilterRange) {
|
|
|
52
62
|
if (EOxItemFilterRange.filterObject.dirty) {
|
|
53
63
|
EOxItemFilterRange.filterObject.stringifiedState =
|
|
54
64
|
EOxItemFilterRange.filterObject.format === "date"
|
|
55
|
-
? `${dayjs
|
|
65
|
+
? `${dayjs(min).format(DATE_TIME_FORMAT)} - ${dayjs(max).format(DATE_TIME_FORMAT)}`
|
|
56
66
|
: `${min} - ${max}`;
|
|
57
67
|
}
|
|
58
68
|
|
|
@@ -76,10 +86,9 @@ export function rangeInputHandlerMethod(evt, EOxItemFilterRange) {
|
|
|
76
86
|
* @returns {import("lit").HTMLTemplateResult}
|
|
77
87
|
*/
|
|
78
88
|
export function rangeLabelMethod(val, pos, EOxItemFilterRange) {
|
|
79
|
-
const isDate = Boolean(EOxItemFilterRange.filterObject.format === "date");
|
|
80
89
|
const filteredVal = EOxItemFilterRange.filterObject.state[val];
|
|
81
|
-
const label = isDate
|
|
82
|
-
? dayjs
|
|
90
|
+
const label = isDate(EOxItemFilterRange.filterObject)
|
|
91
|
+
? dayjs(filteredVal).format(DATE_TIME_FORMAT)
|
|
83
92
|
: filteredVal;
|
|
84
93
|
return html`<div class="range-${pos}">${label}</div>`;
|
|
85
94
|
}
|
|
@@ -59,6 +59,9 @@ function createFilterMethod(filterObject, tabIndex, EOxItemFilter) {
|
|
|
59
59
|
.tabIndex=${tabIndex}
|
|
60
60
|
.filterObject=${filterObject}
|
|
61
61
|
slot="filter"
|
|
62
|
+
.suggestions="${uniq(
|
|
63
|
+
flatMap(EOxItemFilter.items, filterObject.key),
|
|
64
|
+
).filter((i) => i)}"
|
|
62
65
|
.unstyled=${EOxItemFilter.unstyled}
|
|
63
66
|
@filter=${() => EOxItemFilter.search()}
|
|
64
67
|
></eox-itemfilter-range>
|
|
@@ -22,7 +22,7 @@ function filterApplyMethod(config, items, EOxItemFilter) {
|
|
|
22
22
|
// Function to parse values based on their format
|
|
23
23
|
const parseValue = (value) => {
|
|
24
24
|
return filterProperty.format === "date"
|
|
25
|
-
? dayjs(value).
|
|
25
|
+
? dayjs(value).valueOf()
|
|
26
26
|
: parseFloat(value);
|
|
27
27
|
};
|
|
28
28
|
|
package/src/style.eox.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @module EOxItemFilterRange
|
|
7
7
|
* @extends LitElement
|
|
8
8
|
* @property {Object} filterObject - The filter object containing state and range limits.
|
|
9
|
+
* @property {Array} suggestions - The list of suggestions for the selector.
|
|
9
10
|
* @property {Number} tabIndex - The tab index for the input elements.
|
|
10
11
|
*/
|
|
11
12
|
export class EOxItemFilterRange extends LitElement {
|
|
@@ -14,6 +15,10 @@ export class EOxItemFilterRange extends LitElement {
|
|
|
14
15
|
attribute: boolean;
|
|
15
16
|
type: ObjectConstructor;
|
|
16
17
|
};
|
|
18
|
+
suggestions: {
|
|
19
|
+
attribute: boolean;
|
|
20
|
+
type: ArrayConstructor;
|
|
21
|
+
};
|
|
17
22
|
tabIndex: {
|
|
18
23
|
attribute: boolean;
|
|
19
24
|
type: NumberConstructor;
|
|
@@ -23,6 +28,10 @@ export class EOxItemFilterRange extends LitElement {
|
|
|
23
28
|
* @type Object
|
|
24
29
|
*/
|
|
25
30
|
filterObject: any;
|
|
31
|
+
/**
|
|
32
|
+
* @type Array
|
|
33
|
+
*/
|
|
34
|
+
suggestions: any[];
|
|
26
35
|
/**
|
|
27
36
|
* @type {(evt: CustomEvent<any>) => void}
|
|
28
37
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../../src/components/filters/range.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../../src/components/filters/range.js"],"names":[],"mappings":"AAaA;;;;;;;;;;GAUG;AACH;IAEE;;;;;;;;;;;;;MAIE;IAKA;;OAEG;IACH,kBAAsB;IAEtB;;OAEG;IACH,mBAAqB;IAOrB;;OAEG;IACH,cAFU,CAAC,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC,KAAK,IAAI,CAEQ;IAEjD;;OAEG;IACH,gCAEE;IAuBJ;;OAEG;IACH,cAEC;IAED;;;;OAIG;IACH,oBAFa,IAAI,CAIhB;IAED;;OAEG;IACH,oBAkEC;;CACF;2BAzKgC,KAAK"}
|
package/types/enums/config.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/enums/config.js"],"names":[],"mappings":"AAAA;IACE;;OAEG;;IAGH;;;OAGG;;IAGH;;OAEG;;IAGH;;;;;OAKG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;;;OAKG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;GAEF;AAEH,0CAmBE"}
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/enums/config.js"],"names":[],"mappings":"AAAA;IACE;;OAEG;;IAGH;;;OAGG;;IAGH;;OAEG;;IAGH;;;;;OAKG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;;;OAKG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;GAEF;AAEH,0CAmBE;AAEF,+BAAgC,YAAY,CAAC"}
|
package/types/enums/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ELEMENT_CONFIG, ELEMENT_PROPERTIES } from "./config";
|
|
1
|
+
export { ELEMENT_CONFIG, ELEMENT_PROPERTIES, DATE_TIME_FORMAT } from "./config";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/types/helpers/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { default as toggleAccordion } from "./toggle-accordion";
|
|
|
9
9
|
export { default as getValue } from "./get-value";
|
|
10
10
|
export { default as capitalize } from "./capitalize";
|
|
11
11
|
export { default as mergeHighlightIndices } from "./merge-highlight-indices";
|
|
12
|
+
export { default as isDate } from "./is-date";
|
|
12
13
|
export { intersects, within } from "./spatial";
|
|
13
14
|
export { indexItems, filter } from "./filter-client";
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the filterObject format is date-like.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} filterObject - The filter object.
|
|
5
|
+
* @returns {boolean} True if it is a date, otherwise false.
|
|
6
|
+
*/
|
|
7
|
+
export default function isDate(filterObject: any): boolean;
|
|
8
|
+
//# sourceMappingURL=is-date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-date.d.ts","sourceRoot":"","sources":["../../src/helpers/is-date.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,mDAFa,OAAO,CAInB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../../src/methods/filters/range.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../../src/methods/filters/range.js"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,qDAFW,OAAO,mCAAmC,EAAE,kBAAkB,QA6BxE;AAED;;;;;GAKG;AACH,6CAHW,WAAW,iCAmCrB;AAED;;;;;;;GAOG;AACH,sCALW,MAAM,GAAC,MAAM,OACb,MAAM,4BAEJ,OAAO,KAAK,EAAE,kBAAkB,CAQ5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-filter.d.ts","sourceRoot":"","sources":["../../../src/methods/itemfilter/create-filter.js"],"names":[],"mappings":";AAIA;;;;;;;GAOG;AACH,iEAJW,MAAM,uBAEJ,OAAO,KAAK,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"create-filter.d.ts","sourceRoot":"","sources":["../../../src/methods/itemfilter/create-filter.js"],"names":[],"mappings":";AAIA;;;;;;;GAOG;AACH,iEAJW,MAAM,uBAEJ,OAAO,KAAK,EAAE,kBAAkB,CA2E5C"}
|
package/types/style.eox.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.eox.d.ts","sourceRoot":"","sources":["../src/style.eox.js"],"names":[],"mappings":"AAKA,
|
|
1
|
+
{"version":3,"file":"style.eox.d.ts","sourceRoot":"","sources":["../src/style.eox.js"],"names":[],"mappings":"AAKA,8BA0eE"}
|