@eox/itemfilter 1.14.0 → 1.16.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.
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eox/itemfilter",
3
- "version": "1.14.0",
3
+ "version": "1.16.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,11 +9,11 @@
9
9
  "devDependencies": {
10
10
  "@types/geojson": "^7946.0.14",
11
11
  "@types/lodash.debounce": "^4.0.7",
12
- "vite": "^7.1.12"
12
+ "vite": "^8.0.10"
13
13
  },
14
14
  "engines": {
15
15
  "npm": ">=8.0.0",
16
- "node": ">=18.0.0"
16
+ "node": ">=24.0.0"
17
17
  },
18
18
  "files": [
19
19
  "types",
@@ -40,12 +40,12 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@eox/elements-utils": "^1.1.0",
43
- "@eox/ui": "^0.5.0",
43
+ "@eox/ui": "^1.1.0",
44
44
  "@floating-ui/dom": "^1.6.8",
45
- "@turf/boolean-intersects": "^7.0.0",
46
- "@turf/boolean-within": "^7.0.0",
45
+ "@turf/boolean-intersects": "^7.3.5",
46
+ "@turf/boolean-within": "^7.3.5",
47
47
  "dayjs": "^1.11.9",
48
- "fuse.js": "^7.0.0",
48
+ "fuse.js": "^7.3.0",
49
49
  "lit": "^3.2.0",
50
50
  "lodash.debounce": "^4.0.8",
51
51
  "lodash.flatmap": "^4.5.0",
@@ -87,8 +87,10 @@ class EOxItemFilterSpatial extends LitElement {
87
87
  return when(
88
88
  this.filterObject,
89
89
  () => html`
90
- <div style="margin-left: var(--list-padding)">
91
- <nav class="vertical-margin small-margin wrap">
90
+ <div
91
+ style="margin-left: var(--list-padding); padding-right: var(--padding)"
92
+ >
93
+ <nav class="no-margin wrap">
92
94
  ${map(
93
95
  ["intersects", "within"],
94
96
  (mode) => html`
@@ -102,7 +104,7 @@ class EOxItemFilterSpatial extends LitElement {
102
104
  value="${mode}"
103
105
  @click=${() => this.#handleClick(mode)}
104
106
  />
105
- <span>${mode} filter geometry</span>
107
+ <span style="font-size: x-small">${mode} geometry</span>
106
108
  </label>
107
109
  `,
108
110
  )}
@@ -116,7 +118,7 @@ class EOxItemFilterSpatial extends LitElement {
116
118
  this.filterObject.stringifiedState = "Polygon";
117
119
  this.dispatchEvent(new CustomEvent("filter"));
118
120
  }}"
119
- ></eox-itemfilter-spatial>
121
+ ></eox-itemfilter-spatial-filter>
120
122
  </div>
121
123
  `,
122
124
  );
@@ -70,6 +70,14 @@ export const ELEMENT_CONFIG = Object.freeze({
70
70
  */
71
71
  imageProperty: undefined,
72
72
 
73
+ /**
74
+ * Sorting behavior for the results.
75
+ * Can be undefined (alphabetical auto-detect), false (no sorting),
76
+ * string (property to sort by), function (custom comparator),
77
+ * or object { key: string, order: 'asc'|'desc' }
78
+ */
79
+ resultSorting: undefined,
80
+
73
81
  /**
74
82
  * Allow opening multiple filter accordions in parallel
75
83
  * @default true
@@ -103,6 +111,7 @@ export const ELEMENT_PROPERTIES = [
103
111
  "subTitleProperty",
104
112
  "imageProperty",
105
113
  "idProperty",
114
+ "resultSorting",
106
115
  "expandMultipleFilters",
107
116
  "expandResults",
108
117
  "expandMultipleResults",
package/src/main.js CHANGED
@@ -35,12 +35,13 @@ import {
35
35
  * - Supports `text`, `select`, `multiselect`, `range` (including date), and `spatial` filters
36
36
  * - Aggregates results by a property key (e.g. themes)
37
37
  * - Inline mode for compact UI
38
- * - Pre-set filter state via `state` in `filterProperties`
38
+ * - Pre-set filter state via `state` in `filterProperties` property/attribute
39
39
  * - Nested property filtering using dot notation
40
- * - External search API endpoint support via `externalFilter`
40
+ * - External search API endpoint support via `externalFilter` property
41
41
  * - Auto-spreading of single-item aggregations to root level
42
42
  * - Card display mode for results (`result-type="cards"`)
43
43
  * - Secondary result action button with custom icon and event handler (`click:result-action`)
44
+ * - Custom result sorting via `resultSorting` property/attribute
44
45
  * - Customizable layout and styling via CSS variables
45
46
  *
46
47
  * Usage examples and visual demos are available in Storybook stories, including scenarios for inline mode, external filtering, nested properties, card display, CSS variable customization, and result actions.
@@ -57,15 +58,15 @@ export class EOxItemFilter extends LitElement {
57
58
  // Define properties with defaults and types
58
59
  static get properties() {
59
60
  return {
60
- items: { attribute: false, type: Object },
61
+ items: { type: Array },
61
62
  results: { state: true, attribute: false, type: Object },
62
63
  filters: { state: true, attribute: false, type: Object },
63
- selectedResult: { attribute: false, type: Object },
64
+ selectedResult: { type: Object },
64
65
  aggregateResults: { attribute: "aggregate-results", type: String },
65
66
  autoSpreadSingle: { attribute: "auto-spread-single", type: Boolean },
66
67
  enableHighlighting: { attribute: "enable-highlighting", type: Boolean },
67
- filterProperties: { attribute: false, type: Array },
68
- fuseConfig: { attribute: false, type: Object },
68
+ filterProperties: { type: Array },
69
+ fuseConfig: { type: Object },
69
70
  inlineMode: { attribute: "inline-mode", type: Boolean },
70
71
  matchAllWhenEmpty: { attribute: "match-all-when-empty", type: Boolean },
71
72
  showResults: { attribute: "show-result", type: Boolean },
@@ -73,6 +74,7 @@ export class EOxItemFilter extends LitElement {
73
74
  titleProperty: { attribute: "title-property", type: String },
74
75
  subTitleProperty: { attribute: "sub-title-property", type: String },
75
76
  imageProperty: { attribute: "image-property", type: String },
77
+ resultSorting: { type: Object },
76
78
  expandMultipleFilters: {
77
79
  attribute: "enable-multiple-filter",
78
80
  type: Boolean,
@@ -84,8 +86,8 @@ export class EOxItemFilter extends LitElement {
84
86
  },
85
87
  externalFilter: { attribute: false, type: Function },
86
88
  resultType: { attribute: "result-type", type: String },
87
- enableResultAction: { attribute: false, type: Boolean },
88
- resultActionIcon: { attribute: false, type: String },
89
+ enableResultAction: { type: Boolean },
90
+ resultActionIcon: { type: String },
89
91
  styleOverride: { type: String },
90
92
  unstyled: { type: Boolean },
91
93
  };
@@ -109,7 +111,7 @@ export class EOxItemFilter extends LitElement {
109
111
  constructor() {
110
112
  super();
111
113
 
112
- /** The items to be filtered
114
+ /** The items to be filtered. Can be passed as a property or stringified JSON attribute.
113
115
  * @type Array<Object>
114
116
  */
115
117
  this.items = null;
@@ -168,13 +170,14 @@ export class EOxItemFilter extends LitElement {
168
170
  * The function can return a URL string, or an object containing a `url,
169
171
  * an optional `fetchFn` to handle the request, or/and an optional `key` to
170
172
  * return a specific property from the fetched data.
173
+ * This is a property-only field as it expects a function.
171
174
  *
172
175
  * @type {() => string| (() => {url:string;key?:string;fetchFn?:string})}
173
176
  */
174
177
  this.externalFilter = null;
175
178
 
176
179
  /**
177
- * The filter properties.
180
+ * The filter properties. Can be passed as a property or stringified JSON attribute.
178
181
  * @type Array<{key?: String, keys?: Array<String>, title: String, type: String, placeholder?: String, format?: String, state?: Object}>
179
182
  */
180
183
  this.filterProperties = [];
@@ -232,6 +235,18 @@ export class EOxItemFilter extends LitElement {
232
235
  */
233
236
  this.imageProperty = undefined;
234
237
 
238
+ /**
239
+ * Sorting behavior for the results. Can be:
240
+ * - undefined (default): smart alphabetical sorting (skips if externalFilter or fuseConfig.shouldSort is truthy)
241
+ * - false: no sorting
242
+ * - string: property key to sort by (ascending)
243
+ * - function: custom comparator function (a, b) => number
244
+ * - object: { key: string, order?: 'asc' | 'desc' }
245
+ *
246
+ * @type false|string|Function|{key:string, order?:'asc'|'desc'}
247
+ */
248
+ this.resultSorting = undefined;
249
+
235
250
  /**
236
251
  * Unique id property of items
237
252
  *
@@ -297,6 +312,10 @@ export class EOxItemFilter extends LitElement {
297
312
  * Applies the filters to the items and updates the result aggregation.
298
313
  */
299
314
  apply() {
315
+ this.#config = ELEMENT_PROPERTIES.reduce((acc, property) => {
316
+ acc[property] = this[property];
317
+ return acc;
318
+ }, {});
300
319
  this.#resultAggregation = filterApplyMethod(
301
320
  this.#config,
302
321
  this.#items,
@@ -335,10 +354,12 @@ export class EOxItemFilter extends LitElement {
335
354
  * Sorts the given items based on the current configuration.
336
355
  *
337
356
  * @param {Array<object>} items - The items to be sorted.
357
+ * @param {Object} [options] - Optional sorting parameters.
358
+ * @param {boolean} [options.isExternalResult] - Flag for results from external filter.
338
359
  * @returns {Array<object>} - The sorted items.
339
360
  */
340
- sortResults(items) {
341
- return sortResultsMethod(items, this.#config);
361
+ sortResults(items, options) {
362
+ return sortResultsMethod(items, this.#config, options);
342
363
  }
343
364
 
344
365
  /**
@@ -40,7 +40,7 @@ function createResetMethod(filterObject, tabIndex, EOxItemFilter) {
40
40
  />
41
41
  </svg>
42
42
  </i>
43
- <div class="tooltip left">Reset filter</div>
43
+ <span class="tooltip left">Reset filter</span>
44
44
  `}
45
45
  </button>
46
46
  `,
@@ -17,7 +17,9 @@ async function searchMethod(config, items, EOxItemFilter) {
17
17
  results = await filterClient(items, EOxItemFilter.filters, config);
18
18
  }
19
19
 
20
- EOxItemFilter.results = EOxItemFilter.sortResults(results);
20
+ EOxItemFilter.results = EOxItemFilter.sortResults(results, {
21
+ isExternalResult: !!EOxItemFilter.externalFilter,
22
+ });
21
23
  }
22
24
 
23
25
  export default searchMethod;
@@ -1,19 +1,65 @@
1
1
  import { getValue } from "../../helpers";
2
2
 
3
3
  /**
4
- * Sorts the provided items based on the title property specified in the configuration.
4
+ * Sorts the provided items based on the resultSorting configuration.
5
+ * Supports:
6
+ * - undefined (default): smart alphabetical sorting (skips if externalFilter or fuseConfig.shouldSort is truthy)
7
+ * - false: no sorting
8
+ * - string: property key to sort by (ascending)
9
+ * - function: custom comparator function (a, b) => number
10
+ * - object: { key: string, order?: 'asc' | 'desc' }
5
11
  *
6
12
  * @param {Array<Object>} items - The items to be sorted.
7
13
  * @param {Object} config - The configuration object containing sorting options.
14
+ * @param {Object} [options] - Optional sorting parameters.
15
+ * @param {boolean} [options.isExternalResult] - Flag for results from external filter.
8
16
  * @returns {Array<Object>} The sorted array of items.
9
17
  */
10
- function sortResultsMethod(items, config) {
11
- return [...items].sort((a, b) =>
12
- getValue(config.titleProperty, a)
13
- .toString()
14
- .localeCompare(getValue(config.titleProperty, b))
15
- .toString(),
16
- );
18
+ function sortResultsMethod(items, config, options = {}) {
19
+ const { resultSorting } = config;
20
+
21
+ // 1. Explicitly disabled sorting
22
+ if (resultSorting === false) {
23
+ return items;
24
+ }
25
+
26
+ // 2. Default/Smart sorting (undefined)
27
+ if (resultSorting === undefined) {
28
+ // Skip sorting if results come from an external source (assumed sorted)
29
+ // or if Fuse.js is configured to handle its own sorting by score.
30
+ if (options.isExternalResult || config.fuseConfig?.shouldSort) {
31
+ return items;
32
+ }
33
+ // Backward compatible default: alphabetical by titleProperty
34
+ return [...items].sort((a, b) => {
35
+ const valA = getValue(config.titleProperty, a) || "";
36
+ const valB = getValue(config.titleProperty, b) || "";
37
+ return valA.toString().localeCompare(valB.toString());
38
+ });
39
+ }
40
+
41
+ // 3. Custom comparator function
42
+ if (typeof resultSorting === "function") {
43
+ return [...items].sort(resultSorting);
44
+ }
45
+
46
+ // 4. Sort by property (string or object)
47
+ const sortKey =
48
+ typeof resultSorting === "string" ? resultSorting : resultSorting.key;
49
+ const sortOrder =
50
+ typeof resultSorting === "object" && resultSorting.order === "desc"
51
+ ? -1
52
+ : 1;
53
+
54
+ if (sortKey) {
55
+ return [...items].sort((a, b) => {
56
+ const valA = getValue(sortKey, a) || "";
57
+ const valB = getValue(sortKey, b) || "";
58
+ return valA.toString().localeCompare(valB.toString()) * sortOrder;
59
+ });
60
+ }
61
+
62
+ return items;
17
63
  }
18
64
 
19
65
  export default sortResultsMethod;
package/src/style.eox.js CHANGED
@@ -8,6 +8,9 @@ ${eoxStyle}
8
8
  .field {
9
9
  margin-block-end: 0;
10
10
  }
11
+ .field>:is(input,textarea,select) {
12
+ width: 100%;
13
+ }
11
14
  .field.small>:is(input,textarea,select) {
12
15
  font-size: 0.75rem;
13
16
  }
@@ -36,19 +39,19 @@ ${eoxStyle}
36
39
  #000000 20%,
37
40
  transparent
38
41
  );
39
- --background-color: var(--eox-background-color, transparent);
40
- --padding: 0.5rem;
41
- --padding-vertical: 0.25rem;
42
- --list-padding: 2rem;
43
- --text-transform: capitalize;
44
- --form-flex-direction: column;
45
- --filter-display: block;
46
- background-color: var(--background-color);
42
+ --_background-color: var(--background-color, var(--eox-background-color, transparent));
43
+ --_padding: var(--padding, 0.5rem);
44
+ --_padding-vertical: var(--padding-vertical, 0.25rem);
45
+ --_list-padding: var(--list-padding, 2rem);
46
+ --_text-transform: var(--text-transform, capitalize);
47
+ --_form-flex-direction: var(--form-flex-direction, column);
48
+ --_filter-display: var(--filter-display, block);
49
+ background-color: var(--_background-color);
47
50
  display: flex;
48
51
  flex-direction: column;
49
52
  }
50
53
  form#itemfilter {
51
- flex-direction: var(--form-flex-direction);
54
+ flex-direction: var(--_form-flex-direction);
52
55
  margin-top: 0;
53
56
  }
54
57
  eox-itemfilter-container {
@@ -69,7 +72,7 @@ eox-itemfilter-results button.chip {
69
72
  pointer-events: none;
70
73
  }
71
74
  .list li {
72
- padding: 0 var(--padding) !important;
75
+ padding: 0 var(--_padding) !important;
73
76
  }
74
77
  .list.no-padding > li {
75
78
  padding: 0 !important;
@@ -79,7 +82,7 @@ li label {
79
82
  align-items: center;
80
83
  }
81
84
  .title {
82
- text-transform: var(--text-transform);
85
+ text-transform: var(--_text-transform);
83
86
  }
84
87
  .title.highlight-enabled {
85
88
  text-transform: inherit;
@@ -108,14 +111,14 @@ eox-itemfilter-expandcontainer > [data-type=filter] {
108
111
  }
109
112
  [data-type=filter] .title,
110
113
  details summary {
111
- text-transform: var(--text-transform);
114
+ text-transform: var(--_text-transform);
112
115
  }
113
116
  details summary nav {
114
117
  height: 32px;
115
118
  }
116
119
  details > summary {
117
120
  min-block-size: 0rem;
118
- padding: 0 var(--padding);
121
+ padding: 0 var(--_padding);
119
122
  user-select: none;
120
123
  }
121
124
  details > summary i {
@@ -124,10 +127,13 @@ details > summary i {
124
127
  details[open] > summary i {
125
128
  transform: rotate(90deg);
126
129
  }
130
+ summary > * {
131
+ pointer-events: all;
132
+ }
127
133
  ul.multiselect.list > li,
128
134
  ul.select.list > li,
129
135
  details > div > ul#results.list > li {
130
- padding-left: var(--list-padding) !important;
136
+ padding-left: var(--_list-padding) !important;
131
137
  }
132
138
  section:not(section:last-of-type) {
133
139
  margin-bottom: 1rem;
@@ -143,14 +149,14 @@ section:not(section:last-of-type) {
143
149
  border-radius: none;
144
150
  }
145
151
  .no-results {
146
- padding-left: var(--padding);
147
- padding-right: var(--padding);
152
+ padding-left: var(--_padding);
153
+ padding-right: var(--_padding);
148
154
  }
149
155
  ul#results li:not(:hover) .result-action {
150
156
  display: none;
151
157
  }
152
158
  eox-layout {
153
- padding: var(--padding-vertical) var(--padding);
159
+ padding: var(--_padding-vertical) var(--_padding);
154
160
  gap: var(--card-gap, 16px);
155
161
  --column-width: var(--card-width, 300px);
156
162
  --row-height: var(--card-height, 200px);
@@ -214,30 +220,30 @@ ul#results eox-layout-item.highlighted .result-action > * {
214
220
  }
215
221
  section {
216
222
  position: relative;
217
- background-color: var(--background-color);
223
+ background-color: var(--_background-color);
218
224
  }
219
225
  nav.title-nav {
220
- padding-left: var(--padding);
221
- padding-right: var(--padding);
226
+ padding-left: var(--_padding);
227
+ padding-right: var(--_padding);
222
228
  }
223
- eox-itemfilter-range,
224
- tc-range-slider {
225
- align-items: center;
229
+ eox-itemfilter-range {
226
230
  display: block;
227
231
  }
232
+ .range-wrapper {
233
+ margin-left: var(--_list-padding);
234
+ padding-right: var(--_padding);
235
+ }
228
236
  tc-range-slider {
229
- width: calc(100% - 32px);
230
- margin-left: 8px;
231
- margin-right: 8px;
237
+ width: 100%;
232
238
  --width: 100%;
233
239
  }
234
- .range-before,
235
- .range-after {
236
- font-size: small;
240
+ .range-labels {
241
+ display: flex;
242
+ justify-content: space-between;
237
243
  }
238
244
  .range-before,
239
245
  .range-after {
240
- margin: 1rem 0px;
246
+ font-size: x-small;
241
247
  }
242
248
 
243
249
  .inline-content {
@@ -472,12 +478,17 @@ mark.highlight {
472
478
  color: #ba1a1a !important;
473
479
  font-size: x-small;
474
480
  }
481
+ .row {
482
+ display: flex;
483
+ flex-direction: row;
484
+ gap: 8px;
485
+ }
475
486
  @media (prefers-color-scheme: dark) {
476
487
  .error-validation {
477
488
  color: #ffb4ab !important;
478
489
  }
479
490
  }
480
491
  input {
481
- background-color: var(--background-color);
492
+ background-color: var(--_background-color);
482
493
  }
483
494
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"spatial.d.ts","sourceRoot":"","sources":["../../../src/components/filters/spatial.js"],"names":[],"mappings":"AAkBO,gEAFM,OAAO,CAOnB;AAED;;;;;;;;GAQG;AACH;IAEE;;;;;;;;MAKC;IAKC;;OAEG;IACH,kBAAsB;IAQxB;;OAEG;IACH,cAEC;IAED;;;;OAIG;IACH,oBAFa,IAAI,CAIhB;IAWD;;OAEG;IACH,oBAqCC;;CACF;AAID;;;;;;;;GAQG;AACH;IAEE;;;;;;;MAKC;IAKC;;OAEG;IACH,cAAoB;IAEpB;;OAEG;IACH,YAAkB;IAGpB;;OAEG;IACH,qBAEC;IASD;;OAEG;IACH,cAEC;IAED;;OAEG;IACH,+CAEC;;CACF;2BA1LyC,KAAK"}
1
+ {"version":3,"file":"spatial.d.ts","sourceRoot":"","sources":["../../../src/components/filters/spatial.js"],"names":[],"mappings":"AAkBO,gEAFM,OAAO,CAOnB;AAED;;;;;;;;GAQG;AACH;IAEE;;;;;;;;MAKC;IAKC;;OAEG;IACH,kBAAsB;IAQxB;;OAEG;IACH,cAEC;IAED;;;;OAIG;IACH,oBAFa,IAAI,CAIhB;IAWD;;OAEG;IACH,oBAuCC;;CACF;AAID;;;;;;;;GAQG;AACH;IAEE;;;;;;;MAKC;IAKC;;OAEG;IACH,cAAoB;IAEpB;;OAEG;IACH,YAAkB;IAGpB;;OAEG;IACH,qBAEC;IASD;;OAEG;IACH,cAEC;IAED;;OAEG;IACH,+CAEC;;CACF;2BA5LyC,KAAK"}
@@ -57,6 +57,13 @@ export const ELEMENT_CONFIG: Readonly<{
57
57
  * The property of the result items used for an image
58
58
  */
59
59
  imageProperty: any;
60
+ /**
61
+ * Sorting behavior for the results.
62
+ * Can be undefined (alphabetical auto-detect), false (no sorting),
63
+ * string (property to sort by), function (custom comparator),
64
+ * or object { key: string, order: 'asc'|'desc' }
65
+ */
66
+ resultSorting: any;
60
67
  /**
61
68
  * Allow opening multiple filter accordions in parallel
62
69
  * @default true
@@ -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;;;OAGG;;IAGH;;;OAGG;;IAGH;;;OAGG;;GAEF;AAEH,0CAkBE"}
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"}
package/types/main.d.ts CHANGED
@@ -5,12 +5,13 @@
5
5
  * - Supports `text`, `select`, `multiselect`, `range` (including date), and `spatial` filters
6
6
  * - Aggregates results by a property key (e.g. themes)
7
7
  * - Inline mode for compact UI
8
- * - Pre-set filter state via `state` in `filterProperties`
8
+ * - Pre-set filter state via `state` in `filterProperties` property/attribute
9
9
  * - Nested property filtering using dot notation
10
- * - External search API endpoint support via `externalFilter`
10
+ * - External search API endpoint support via `externalFilter` property
11
11
  * - Auto-spreading of single-item aggregations to root level
12
12
  * - Card display mode for results (`result-type="cards"`)
13
13
  * - Secondary result action button with custom icon and event handler (`click:result-action`)
14
+ * - Custom result sorting via `resultSorting` property/attribute
14
15
  * - Customizable layout and styling via CSS variables
15
16
  *
16
17
  * Usage examples and visual demos are available in Storybook stories, including scenarios for inline mode, external filtering, nested properties, card display, CSS variable customization, and result actions.
@@ -26,8 +27,7 @@
26
27
  export class EOxItemFilter extends LitElement {
27
28
  static get properties(): {
28
29
  items: {
29
- attribute: boolean;
30
- type: ObjectConstructor;
30
+ type: ArrayConstructor;
31
31
  };
32
32
  results: {
33
33
  state: boolean;
@@ -40,7 +40,6 @@ export class EOxItemFilter extends LitElement {
40
40
  type: ObjectConstructor;
41
41
  };
42
42
  selectedResult: {
43
- attribute: boolean;
44
43
  type: ObjectConstructor;
45
44
  };
46
45
  aggregateResults: {
@@ -56,11 +55,9 @@ export class EOxItemFilter extends LitElement {
56
55
  type: BooleanConstructor;
57
56
  };
58
57
  filterProperties: {
59
- attribute: boolean;
60
58
  type: ArrayConstructor;
61
59
  };
62
60
  fuseConfig: {
63
- attribute: boolean;
64
61
  type: ObjectConstructor;
65
62
  };
66
63
  inlineMode: {
@@ -91,6 +88,9 @@ export class EOxItemFilter extends LitElement {
91
88
  attribute: string;
92
89
  type: StringConstructor;
93
90
  };
91
+ resultSorting: {
92
+ type: ObjectConstructor;
93
+ };
94
94
  expandMultipleFilters: {
95
95
  attribute: string;
96
96
  type: BooleanConstructor;
@@ -112,11 +112,9 @@ export class EOxItemFilter extends LitElement {
112
112
  type: StringConstructor;
113
113
  };
114
114
  enableResultAction: {
115
- attribute: boolean;
116
115
  type: BooleanConstructor;
117
116
  };
118
117
  resultActionIcon: {
119
- attribute: boolean;
120
118
  type: StringConstructor;
121
119
  };
122
120
  styleOverride: {
@@ -126,7 +124,7 @@ export class EOxItemFilter extends LitElement {
126
124
  type: BooleanConstructor;
127
125
  };
128
126
  };
129
- /** The items to be filtered
127
+ /** The items to be filtered. Can be passed as a property or stringified JSON attribute.
130
128
  * @type Array<Object>
131
129
  */
132
130
  items: Array<any>;
@@ -175,6 +173,7 @@ export class EOxItemFilter extends LitElement {
175
173
  * The function can return a URL string, or an object containing a `url,
176
174
  * an optional `fetchFn` to handle the request, or/and an optional `key` to
177
175
  * return a specific property from the fetched data.
176
+ * This is a property-only field as it expects a function.
178
177
  *
179
178
  * @type {() => string| (() => {url:string;key?:string;fetchFn?:string})}
180
179
  */
@@ -184,7 +183,7 @@ export class EOxItemFilter extends LitElement {
184
183
  fetchFn?: string;
185
184
  });
186
185
  /**
187
- * The filter properties.
186
+ * The filter properties. Can be passed as a property or stringified JSON attribute.
188
187
  * @type Array<{key?: String, keys?: Array<String>, title: String, type: String, placeholder?: String, format?: String, state?: Object}>
189
188
  */
190
189
  filterProperties: Array<{
@@ -242,6 +241,20 @@ export class EOxItemFilter extends LitElement {
242
241
  * @type String|Function
243
242
  */
244
243
  imageProperty: string | Function;
244
+ /**
245
+ * Sorting behavior for the results. Can be:
246
+ * - undefined (default): smart alphabetical sorting (skips if externalFilter or fuseConfig.shouldSort is truthy)
247
+ * - false: no sorting
248
+ * - string: property key to sort by (ascending)
249
+ * - function: custom comparator function (a, b) => number
250
+ * - object: { key: string, order?: 'asc' | 'desc' }
251
+ *
252
+ * @type false|string|Function|{key:string, order?:'asc'|'desc'}
253
+ */
254
+ resultSorting: false | string | Function | {
255
+ key: string;
256
+ order?: "asc" | "desc";
257
+ };
245
258
  /**
246
259
  * Unique id property of items
247
260
  *
@@ -306,9 +319,13 @@ export class EOxItemFilter extends LitElement {
306
319
  * Sorts the given items based on the current configuration.
307
320
  *
308
321
  * @param {Array<object>} items - The items to be sorted.
322
+ * @param {Object} [options] - Optional sorting parameters.
323
+ * @param {boolean} [options.isExternalResult] - Flag for results from external filter.
309
324
  * @returns {Array<object>} - The sorted items.
310
325
  */
311
- sortResults(items: Array<object>): Array<object>;
326
+ sortResults(items: Array<object>, options?: {
327
+ isExternalResult?: boolean;
328
+ }): Array<object>;
312
329
  /**
313
330
  * Resets all appl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AAO;KACf,GAAU,KAAK,CAAC,MAAM,CAAC,CAIzB;IAwBD;;OAEG;IACH,qBAEC;IAED;;;;;OAKG;IACH,sDAcC;IAED;;;;;OAKG;IACH,gDAQC;IAED;;;;OAIG;IACH,kBAFW;QAAC,MAAM,MAAQ;KAAC,QAe1B;IAED;;;;OAIG;IACH,sBAFW;QAAC,MAAM,MAAQ;KAAC,QAa1B;IAED;;;;OAIG;IACH,sBAFW;QAAC,MAAM,MAAQ;KAAC,QAa1B;IAED;;;;OAIG;IACH,sBAFW;QAAC,MAAM,MAAQ;KAAC,QAa1B;IAED;;OAEG;IACH,+CAyIC;;CACF;2BAtoByC,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/methods/itemfilter/search.js"],"names":[],"mappings":";AAGA;;;;;;;GAOG;AACH,kDAJW,KAAK,KAAQ,uBAEX,OAAO,CAAC,IAAI,CAAC,CAWzB"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/methods/itemfilter/search.js"],"names":[],"mappings":";AAGA;;;;;;;GAOG;AACH,kDAJW,KAAK,KAAQ,uBAEX,OAAO,CAAC,IAAI,CAAC,CAazB"}