@eox/itemfilter 1.6.0 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@eox/itemfilter",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "type": "module",
5
5
  "devDependencies": {
6
6
  "@types/geojson": "^7946.0.14",
7
7
  "@types/lodash.debounce": "^4.0.7",
8
- "vite": "^5.0.2"
8
+ "vite": "^6.0.3"
9
9
  },
10
10
  "engines": {
11
11
  "npm": ">=8.0.0",
@@ -34,10 +34,11 @@
34
34
  "watch": "vite build --watch"
35
35
  },
36
36
  "dependencies": {
37
- "@eox/elements-utils": "^0.1.1",
37
+ "@eox/elements-utils": "^0.1.2",
38
38
  "@floating-ui/dom": "^1.6.8",
39
39
  "@turf/boolean-intersects": "^7.0.0",
40
40
  "@turf/boolean-within": "^7.0.0",
41
+ "dayjs": "^1.11.9",
41
42
  "fuse.js": "^7.0.0",
42
43
  "lit": "^3.2.0",
43
44
  "lodash.debounce": "^4.0.8",
@@ -46,8 +46,8 @@ export class EOxItemFilterRange extends LitElement {
46
46
  /**
47
47
  * @type Function
48
48
  */
49
- this.debouncedInputHandler = _debounce(this.inputHandler, 0, {
50
- leading: true,
49
+ this.debouncedInputHandler = _debounce(this.inputHandler, 500, {
50
+ leading: false,
51
51
  });
52
52
  }
53
53
 
@@ -100,8 +100,8 @@ export class EOxItemFilterRange extends LitElement {
100
100
  <tc-range-slider
101
101
  min="${this.filterObject.min}"
102
102
  max="${this.filterObject.max}"
103
- value1="${this.filterObject.min || this.filterObject.state.min}"
104
- value2="${this.filterObject.max || this.filterObject.state.max}"
103
+ value1="${this.filterObject.state.min || this.filterObject.min}"
104
+ value2="${this.filterObject.state.max || this.filterObject.max}"
105
105
  step="${this.filterObject.step || 1}"
106
106
  @change=${this.debouncedInputHandler}
107
107
  ></tc-range-slider>
@@ -2,6 +2,8 @@ import { resetFilter } from "../../helpers/index.js";
2
2
  import dayjs from "dayjs";
3
3
  import { html } from "lit";
4
4
 
5
+ const DATE_TIME_FORMAT = "ddd, D MMM YYYY HH:mm:ss";
6
+
5
7
  /**
6
8
  * Resets the range filter to its default state and requests an update.
7
9
  *
@@ -47,7 +49,7 @@ export function rangeInputHandlerMethod(evt, EOxItemFilterRange) {
47
49
  if (EOxItemFilterRange.filterObject.dirty) {
48
50
  EOxItemFilterRange.filterObject.stringifiedState =
49
51
  EOxItemFilterRange.filterObject.format === "date"
50
- ? `${dayjs(min)} - ${dayjs(max)}`
52
+ ? `${dayjs.unix(min).format(DATE_TIME_FORMAT)} - ${dayjs.unix(max).format(DATE_TIME_FORMAT)}`
51
53
  : `${min} - ${max}`;
52
54
  }
53
55
 
@@ -73,6 +75,8 @@ export function rangeInputHandlerMethod(evt, EOxItemFilterRange) {
73
75
  export function rangeLabelMethod(val, pos, EOxItemFilterRange) {
74
76
  const isDate = Boolean(EOxItemFilterRange.filterObject.format === "date");
75
77
  const filteredVal = EOxItemFilterRange.filterObject.state[val];
76
- const label = isDate ? dayjs.unix(filteredVal) : filteredVal;
78
+ const label = isDate
79
+ ? dayjs.unix(filteredVal).format(DATE_TIME_FORMAT)
80
+ : filteredVal;
77
81
  return html`<div class="range-${pos}">${label}</div>`;
78
82
  }
@@ -59,7 +59,9 @@ function filterApplyMethod(config, items, EOxItemFilter) {
59
59
  });
60
60
  } else {
61
61
  if (filterProperty.type === "spatial") {
62
- filterKeys.geometry = undefined;
62
+ filterKeys.geometry = filterProperty?.state?.geometry || undefined;
63
+ if (filterKeys.geometry)
64
+ filterProperty.stringifiedState = filterKeys.geometry.type;
63
65
  filterKeys.mode = filterProperty.mode || "intersects";
64
66
  } else {
65
67
  if (filterProperty.key?.includes(".")) {
@@ -78,7 +80,9 @@ function filterApplyMethod(config, items, EOxItemFilter) {
78
80
  EOxItemFilter.filters[filterKey] = Object.assign(
79
81
  {
80
82
  type: filterProperty.type || "multiselect",
81
- dirty: filterProperty.state ? false : undefined,
83
+ dirty: filterProperty.state
84
+ ? Object.values(filterProperty.state).some((value) => value)
85
+ : undefined,
82
86
  key: filterKey,
83
87
  },
84
88
  filterProperty.type === "range"
@@ -69,24 +69,24 @@ export function createItemListMethod(
69
69
  items,
70
70
  (item) => item.id,
71
71
  (item) => html`
72
- <li class=${className(item)}>
73
- <span
74
- id="${item.id}"
75
- @click=${() => {
76
- if (EOxItemFilterResults.selectedResult === item) {
77
- EOxItemFilterResults.selectedResult = null;
78
- } else {
79
- EOxItemFilterResults.selectedResult = item;
80
- }
81
- EOxItemFilterResults.dispatchEvent(
82
- new CustomEvent("result", {
83
- detail: EOxItemFilterResults.selectedResult,
84
- }),
85
- );
86
- }}
87
- >
72
+ <li
73
+ class=${className(item)}
74
+ @click=${() => {
75
+ if (EOxItemFilterResults.selectedResult === item) {
76
+ EOxItemFilterResults.selectedResult = null;
77
+ } else {
78
+ EOxItemFilterResults.selectedResult = item;
79
+ }
80
+ EOxItemFilterResults.dispatchEvent(
81
+ new CustomEvent("result", {
82
+ detail: EOxItemFilterResults.selectedResult,
83
+ }),
84
+ );
85
+ }}
86
+ >
87
+ <span id="${item.id}">
88
88
  ${when(
89
- config.subTitleProperty,
89
+ config.subTitleProperty || config.imageProperty,
90
90
  () => html`
91
91
  ${getValue(config.imageProperty, item)
92
92
  ? html`
@@ -1 +1 @@
1
- {"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../../src/methods/filters/range.js"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,qDAFW,OAAO,mCAAmC,EAAE,kBAAkB,QAexE;AAED;;;;;GAKG;AACH,6CAHW,KAAK,iCAmCf;AAED;;;;;;;GAOG;AACH,sCALW,MAAM,GAAC,MAAM,OACb,MAAM,8CAShB"}
1
+ {"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../../src/methods/filters/range.js"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,qDAFW,OAAO,mCAAmC,EAAE,kBAAkB,QAexE;AAED;;;;;GAKG;AACH,6CAHW,KAAK,iCAmCf;AAED;;;;;;;GAOG;AACH,sCALW,MAAM,GAAC,MAAM,OACb,MAAM,8CAWhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"filter-apply.d.ts","sourceRoot":"","sources":["../../../src/methods/itemfilter/filter-apply.js"],"names":[],"mappings":";AAKA;;;;;;;GAOG;AACH,uDAJW,UAAa,uBAEX,MAAM,MAAM,CAAC,CA8HzB"}
1
+ {"version":3,"file":"filter-apply.d.ts","sourceRoot":"","sources":["../../../src/methods/itemfilter/filter-apply.js"],"names":[],"mappings":";AAKA;;;;;;;GAOG;AACH,uDAJW,UAAa,uBAEX,MAAM,MAAM,CAAC,CAkIzB"}