@eodash/eodash 5.7.0 → 5.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.
Files changed (119) hide show
  1. package/core/client/components/EodashOverlay.vue +27 -4
  2. package/core/client/composables/DefineEodash.js +0 -1
  3. package/core/client/composables/DefineWidgets.js +3 -1
  4. package/core/client/eodashSTAC/EodashCollection.js +87 -24
  5. package/core/client/eodashSTAC/cql.js +64 -0
  6. package/core/client/eodashSTAC/createLayers.js +353 -187
  7. package/core/client/eodashSTAC/helpers.js +694 -110
  8. package/core/client/eodashSTAC/mosaic.js +422 -0
  9. package/core/client/plugins/axios.js +31 -1
  10. package/core/client/store/actions.js +1 -1
  11. package/core/client/store/stac.js +54 -4
  12. package/core/client/store/states.js +20 -2
  13. package/core/client/types.ts +152 -28
  14. package/core/client/utils/bands-editor/exampleSchema.json +50 -50
  15. package/core/client/utils/states.js +10 -0
  16. package/dist/client/{DashboardLayout-kRsmsNW5.js → DashboardLayout-DEs4f_Vy.js} +2 -2
  17. package/dist/client/{DynamicWebComponent-CnKhYo0K.js → DynamicWebComponent-PvnV88BA.js} +1 -1
  18. package/dist/client/EodashChart-D-3AGKZY.js +260 -0
  19. package/dist/client/{EodashDatePicker-CMPDT-ce.js → EodashDatePicker-Dm_goZzs.js} +3 -3
  20. package/dist/client/{EodashItemFilter-BpdA8QQa.js → EodashItemFilter-CJy3zYzD.js} +2 -1
  21. package/dist/client/{EodashLayerControl-BHpDA4_0.js → EodashLayerControl-rL8UnpkA.js} +55 -33
  22. package/dist/client/{EodashLayoutSwitcher-B1fRUt7G.js → EodashLayoutSwitcher-ZRlESI9O.js} +3 -3
  23. package/dist/client/{EodashMapBtns-Cpned0tc.js → EodashMapBtns-CG7u2Aq8.js} +227 -112
  24. package/dist/client/EodashStacInfo-CJhhxthD.js +169 -0
  25. package/dist/client/{EodashTools-1zHz26gv.js → EodashTools-CWyK8QJT.js} +4 -4
  26. package/dist/client/{ExportState-DbOm8hBI.js → ExportState-BXhy5TOU.js} +20 -174
  27. package/dist/client/{Footer-BKg-VVkj.js → Footer-DZPvnhcT.js} +1 -1
  28. package/dist/client/{Header-DCrwCvmY.js → Header-CiGsDE_a.js} +2 -2
  29. package/dist/client/{MobileLayout-vWSHpluo.js → MobileLayout-BJHW7x5V.js} +2 -2
  30. package/dist/client/{PopUp-9uimfK49.js → PopUp-7_XnhvCc.js} +4 -168
  31. package/dist/client/{ProcessList-CTTIZa06.js → ProcessList-LL_UCbvc.js} +5 -5
  32. package/dist/client/VDivider-DWYM0WUr.js +168 -0
  33. package/dist/client/{VImg-CrmB76ZY.js → VImg-B75dgw2K.js} +2 -2
  34. package/dist/client/{VMain-OKZNpcEG.js → VMain-DvMmOL4f.js} +1 -1
  35. package/dist/client/{VTooltip-CJw2FyWk.js → VTooltip-ClWHUmWL.js} +2 -2
  36. package/dist/client/{WidgetsContainer-BaWOnE5R.js → WidgetsContainer-BqaWs4ch.js} +1 -1
  37. package/dist/client/{asWebComponent-BHWpMuE3.js → asWebComponent-IZanwL-A.js} +677 -379
  38. package/dist/client/{async-DSKj6g1f.js → async-CiNIOBVz.js} +31 -29
  39. package/dist/client/{create-layers-config-CBoYedqB.js → create-layers-config-3S3y_kZg.js} +17 -17
  40. package/dist/client/dialog-transition-c4ZSnzac.js +170 -0
  41. package/dist/client/eo-dash.js +1 -1
  42. package/dist/client/{forwardRefs-DH51zPUr.js → forwardRefs-B-c1_6yo.js} +8 -87
  43. package/dist/client/{handling-BrcDDlgS.js → handling-NvY8Csry.js} +3 -4
  44. package/dist/client/{helpers-DjZVl_WF.js → helpers-BFuh19CP.js} +1094 -194
  45. package/dist/client/{index-1JKE68n3.js → index-1wMAyuNL.js} +219 -67
  46. package/dist/client/{index-CSG_JoOA.js → index-B8jGJSTA.js} +62 -56
  47. package/dist/client/{index-Cu3-13Xg.js → index-BKQQJkhy.js} +167 -61
  48. package/dist/client/index-D0jUyol8.js +3167 -0
  49. package/dist/client/{index-CUjl-ZsI.js → index-KGxz5Egv.js} +2 -2
  50. package/dist/client/mosaic-vHvSuih6.js +459 -0
  51. package/dist/client/templates.js +251 -121
  52. package/dist/client/{transition-OHcz5Qq1.js → transition-BkyUsZh_.js} +1 -1
  53. package/dist/node/cli.js +5 -5
  54. package/dist/node/types.d.ts +4 -0
  55. package/dist/types/core/client/composables/DefineEodash.d.ts +1 -1
  56. package/dist/types/core/client/eodashSTAC/EodashCollection.d.ts +57 -25
  57. package/dist/types/core/client/eodashSTAC/cql.d.ts +15 -0
  58. package/dist/types/core/client/eodashSTAC/createLayers.d.ts +42 -23
  59. package/dist/types/core/client/eodashSTAC/helpers.d.ts +118 -19
  60. package/dist/types/core/client/eodashSTAC/mosaic.d.ts +56 -0
  61. package/dist/types/core/client/store/stac.d.ts +38 -8
  62. package/dist/types/core/client/store/states.d.ts +24 -2
  63. package/dist/types/core/client/types.d.ts +128 -24
  64. package/dist/types/core/client/utils/states.d.ts +12 -0
  65. package/dist/types/templates/baseConfig.d.ts +1 -100
  66. package/dist/types/templates/compare.d.ts +32 -3
  67. package/dist/types/templates/expert.d.ts +18 -0
  68. package/dist/types/templates/explore.d.ts +10 -1
  69. package/dist/types/templates/lite.d.ts +11 -0
  70. package/dist/types/widgets/EodashChart.vue.d.ts +5 -3
  71. package/dist/types/widgets/EodashItemCatalog/index.vue.d.ts +129 -2
  72. package/dist/types/widgets/EodashItemCatalog/methods/filters.d.ts +28 -6
  73. package/dist/types/widgets/EodashItemCatalog/methods/handlers.d.ts +17 -4
  74. package/dist/types/widgets/EodashItemCatalog/methods/map.d.ts +16 -4
  75. package/dist/types/widgets/EodashLayerControl.vue.d.ts +35 -16
  76. package/dist/types/widgets/EodashMap/EodashMapBtns.vue.d.ts +14 -10
  77. package/dist/types/widgets/EodashMap/index.vue.d.ts +86 -37
  78. package/dist/types/widgets/EodashMap/methods/create-layers-config.d.ts +1 -1
  79. package/dist/types/widgets/EodashMap/methods/index.d.ts +5 -1
  80. package/dist/types/widgets/EodashMap/methods/use-map-loading.d.ts +1 -0
  81. package/dist/types/widgets/EodashProcess/index.vue.d.ts +5 -3
  82. package/dist/types/widgets/EodashProcess/methods/custom-endpoints/layers/eoxhub-workspaces-endpoint.d.ts +1 -1
  83. package/dist/types/widgets/EodashProcess/states.d.ts +1 -1
  84. package/dist/types/widgets/EodashStacInfo.vue.d.ts +20 -0
  85. package/dist/types/widgets/EodashTimeSlider/index.vue.d.ts +20 -0
  86. package/dist/types/widgets/EodashTimeSlider/methods/index.d.ts +3 -8
  87. package/dist/types/widgets/EodashTimeSlider/types.d.ts +6 -16
  88. package/dist/types/widgets/EodashTools.vue.d.ts +5 -5
  89. package/package.json +34 -34
  90. package/templates/baseConfig.js +37 -6
  91. package/templates/compare.js +61 -7
  92. package/templates/expert.js +24 -2
  93. package/templates/explore.js +12 -5
  94. package/templates/lite.js +13 -0
  95. package/widgets/EodashChart.vue +162 -21
  96. package/widgets/EodashItemCatalog/index.vue +363 -35
  97. package/widgets/EodashItemCatalog/methods/filters.js +134 -70
  98. package/widgets/EodashItemCatalog/methods/handlers.js +113 -19
  99. package/widgets/EodashItemCatalog/methods/map.js +141 -28
  100. package/widgets/EodashLayerControl.vue +51 -25
  101. package/widgets/EodashMap/EodashMapBtns.vue +109 -48
  102. package/widgets/EodashMap/index.vue +91 -105
  103. package/widgets/EodashMap/methods/btns.js +64 -31
  104. package/widgets/EodashMap/methods/create-layers-config.js +16 -16
  105. package/widgets/EodashMap/methods/index.js +71 -8
  106. package/widgets/EodashMap/methods/use-map-loading.js +58 -0
  107. package/widgets/EodashProcess/index.vue +136 -16
  108. package/widgets/EodashProcess/methods/composables.js +13 -0
  109. package/widgets/EodashProcess/methods/outputs.js +0 -1
  110. package/widgets/EodashProcess/methods/utils.js +29 -27
  111. package/widgets/EodashProcess/states.js +1 -1
  112. package/widgets/EodashStacInfo.vue +64 -2
  113. package/widgets/EodashTimeSlider/index.vue +58 -2
  114. package/widgets/EodashTimeSlider/methods/index.js +5 -48
  115. package/widgets/EodashTimeSlider/types.ts +7 -17
  116. package/widgets/ExportState.vue +13 -4
  117. package/dist/client/EodashChart-CLDqE93C.js +0 -144
  118. package/dist/client/EodashStacInfo-BQspAHKH.js +0 -107
  119. package/dist/client/index-5Jhsa8Xe.js +0 -570
@@ -1,6 +1,8 @@
1
1
  import { sanitizeBbox } from "@/eodashSTAC/helpers";
2
2
  import { indicator, mapEl } from "@/store/states";
3
3
  import { useSTAcStore } from "@/store/stac";
4
+ import axios from "@/plugins/axios";
5
+ import { buildCqlFilter } from "@/eodashSTAC/cql";
4
6
 
5
7
  /**
6
8
  *
@@ -43,14 +45,20 @@ export const createSubtitleProperty = (filtersConfig) => {
43
45
  * title?: string,
44
46
  * min?: number,
45
47
  * max?: number,
48
+ * step?: number,
46
49
  * filterKeys?: string[],
47
50
  * state?: Record<string, boolean>,
48
51
  * placeholder?: string,
52
+ * format?: string,
49
53
  * }>} filtersConfig
54
+ * @param {boolean} datetimeFilter
50
55
  */
51
56
  // Transform simple filter configs into eox-itemfilter format
52
- export const createFilterProperties = (filtersConfig) => {
57
+ export const createFilterProperties = (filtersConfig, datetimeFilter) => {
53
58
  const store = useSTAcStore();
59
+ const customDatetimeConfig = filtersConfig.find(
60
+ (f) => f.property === "datetime",
61
+ );
54
62
  const baseFilters = [
55
63
  {
56
64
  key: "collection",
@@ -58,18 +66,25 @@ export const createFilterProperties = (filtersConfig) => {
58
66
  type: "multiselect",
59
67
  placeholder: "Select collections",
60
68
  inline: false,
61
- filterKeys: store.stac?.map((col) => col.id) || [],
69
+ filterKeys:
70
+ store.stac?.filter((col) => col.id).map((col) => col.id) || [],
62
71
  ...(indicator.value && { state: { [indicator.value]: true } }),
63
72
  },
64
- // {
65
- // key: "properties.datetime",
66
- // title: "Date",
67
- // type: "range",
68
- // format: "date",
69
- // }
73
+ ...(datetimeFilter || customDatetimeConfig
74
+ ? [
75
+ {
76
+ key: "datetime",
77
+ title: "Date",
78
+ type: "range",
79
+ format: "date",
80
+ ...(customDatetimeConfig || {}),
81
+ },
82
+ ]
83
+ : []),
70
84
  ];
71
85
 
72
86
  const dynamicFilters = filtersConfig
87
+ .filter((f) => f.property !== "datetime")
73
88
  .map((filter) => {
74
89
  const propertyKey = `properties.${filter.property}`;
75
90
 
@@ -79,8 +94,12 @@ export const createFilterProperties = (filtersConfig) => {
79
94
  title: filter.title || filter.property,
80
95
  type: "range",
81
96
  expanded: true,
97
+ min: filter.min,
98
+ max: filter.max,
99
+ step: filter.step,
100
+ format: filter.format,
82
101
  filterKeys: [filter.min || 0, filter.max || 100],
83
- state: {
102
+ state: filter.state ?? {
84
103
  min: filter.min ?? 0,
85
104
  max: filter.max ?? 100,
86
105
  },
@@ -114,65 +133,28 @@ export const createFilterProperties = (filtersConfig) => {
114
133
  return [...baseFilters, ...dynamicFilters];
115
134
  };
116
135
 
117
- /**
118
- * Build STAC API filter string from dynamic filters
119
- * @param {Record<string,any>} filters
120
- * @param {import("../types").FiltersConfig} propsFilters
121
- * @returns {string}
122
- */
123
- export const buildStacFilters = (filters, propsFilters) => {
124
- /** @type {string[]} */
125
- const stacFilters = [];
126
-
127
- propsFilters.forEach((filterConfig) => {
128
- const filterKey = `properties.${filterConfig.property}`;
129
- const filterValue = filters[filterKey];
130
-
131
- if (!filterValue) return;
132
-
133
- if (filterConfig.type === "range" && filterValue.state) {
134
- const { min, max } = filterValue.state;
135
-
136
- // Add range filters based on configuration
137
- if (min !== undefined && min > (filterConfig.min || 0)) {
138
- stacFilters.push(`${filterConfig.property}>=${min}`);
139
- }
140
- if (max !== undefined && max < (filterConfig.max || 100)) {
141
- stacFilters.push(`${filterConfig.property}<=${max}`);
142
- }
143
- } else if (
144
- filterConfig.type === "multiselect" &&
145
- filterValue.stringifiedState
146
- ) {
147
- // Handle multiselect filters
148
- const selectedValues = filterValue.stringifiedState;
149
- if (selectedValues.length > 0) {
150
- stacFilters.push(`${filterConfig.property} IN (${selectedValues})`);
151
- }
152
- } else if (filterConfig.type === "select" && filterValue.stringifiedState) {
153
- // Handle single select filters
154
- const selectedValue = filterValue.stringifiedState;
155
- if (selectedValue) {
156
- stacFilters.push(`${filterConfig.property}='${selectedValue}'`);
157
- }
158
- }
159
- });
160
-
161
- return stacFilters.join(" AND ");
162
- };
163
-
164
136
  /**
165
137
  * Build search URL with proper STAC API parameters
166
- * @param {Record<string,any>} filters
167
- * @param {Array<any>} propsFilters
138
+ * @param {import("@/types").ItemFilterFilters} filters
168
139
  * @param {boolean} bboxFilter
140
+ * @param {boolean} datetimeFilter
141
+ * @param {Number} searchLimit
142
+ * @param {string} [sortBy]
143
+ * @param {string | null} [stacEndpoint]
169
144
  * @returns {string}
170
145
  */
171
- export const buildSearchUrl = (filters, propsFilters, bboxFilter) => {
146
+ export const buildSearchUrl = (
147
+ filters,
148
+ bboxFilter,
149
+ datetimeFilter,
150
+ searchLimit,
151
+ sortBy,
152
+ stacEndpoint,
153
+ ) => {
172
154
  const store = useSTAcStore();
155
+ const endpoint = stacEndpoint || store.stacEndpoint;
173
156
  const params = new URLSearchParams();
174
157
 
175
- // Add collections
176
158
  if (filters.collection?.stringifiedState) {
177
159
  params.append(
178
160
  "collections",
@@ -187,30 +169,112 @@ export const buildSearchUrl = (filters, propsFilters, bboxFilter) => {
187
169
  );
188
170
  }
189
171
 
190
- // Add dynamic filters
191
- const stacFilter = buildStacFilters(filters, propsFilters);
192
- if (stacFilter) {
193
- params.append("filter", stacFilter);
172
+ if (datetimeFilter) {
173
+ const datetime = formatDatetimeParam(
174
+ /** @type {import("@/types").ItemFilterRange} */ (filters.datetime),
175
+ );
176
+ if (datetime) {
177
+ params.append("datetime", datetime);
178
+ }
179
+ }
180
+
181
+ const cqlFilter = buildCqlFilter(filters);
182
+ if (cqlFilter) {
183
+ params.append("filter", cqlFilter);
184
+ }
185
+ if (sortBy) {
186
+ params.append("sortby", sortBy);
194
187
  }
195
188
 
196
- // Add limit
197
- params.append("limit", "100");
189
+ params.append("limit", searchLimit.toString());
198
190
 
199
- return `${store.stacEndpoint}/search?${params.toString()}`;
191
+ return `${endpoint}/search?${params.toString()}`;
200
192
  };
201
193
 
202
194
  /**
203
195
  *
204
196
  * @param {import("../types").FiltersConfig} propsFilters
205
197
  * @param {boolean} bboxFilter
198
+ * @param {boolean} datetimeFilter
199
+ * @param {import("vue").Ref<import("@/types").GeoJsonFeature[]>} currentItems
200
+ * @param {import("vue").Ref<string>} sortBy
201
+ * @param {Number} searchLimit
202
+ * @param {import("vue").Ref<import("stac-ts").StacItem | null>} [selectedItemRef]
203
+ * @param {import("vue").Ref<string | null> | string | null} [stacEndpoint]
206
204
  */
207
- export const createExternalFilter = (propsFilters, bboxFilter) => {
205
+ export const createExternalFilter = (
206
+ propsFilters,
207
+ bboxFilter,
208
+ datetimeFilter,
209
+ currentItems,
210
+ sortBy,
211
+ searchLimit,
212
+ selectedItemRef,
213
+ stacEndpoint,
214
+ ) => {
215
+ const hasCustomDatetime = propsFilters.some((f) => f.property === "datetime");
216
+ const effectiveDatetimeFilter = datetimeFilter || hasCustomDatetime;
217
+ let controller = new AbortController();
208
218
  /**
209
219
  * @param {Array<any>} _items
210
220
  * @param {Record<string,any>} filters
211
221
  */
212
222
  return (_items, filters) => ({
213
- url: buildSearchUrl(filters, propsFilters, bboxFilter),
214
- key: "features",
223
+ url: buildSearchUrl(
224
+ filters,
225
+ bboxFilter,
226
+ effectiveDatetimeFilter,
227
+ searchLimit,
228
+ sortBy.value,
229
+ typeof stacEndpoint === "object" ? stacEndpoint?.value : stacEndpoint,
230
+ ),
231
+ /** @param {string} url */
232
+ fetchFn: async (url) => {
233
+ controller.abort();
234
+ controller = new AbortController();
235
+ const signal = controller.signal;
236
+ return await axios
237
+ .get(url, { signal })
238
+ .then((res) => {
239
+ /** @type {import("@/types").GeoJsonFeature[]} */
240
+ const results = res.data.features;
241
+ const selected = selectedItemRef?.value;
242
+ if (selected && !results.some((r) => r.id === selected.id)) {
243
+ return [selected, ...results];
244
+ }
245
+ return results;
246
+ })
247
+ .catch((e) => {
248
+ // return previous items if aborted
249
+ if (e.name === "AbortError" || e.name === "CanceledError") {
250
+ return currentItems.value;
251
+ }
252
+ console.error(e);
253
+ return [];
254
+ });
255
+ },
215
256
  });
216
257
  };
258
+ /**
259
+ *
260
+ * @param {import("@/types").ItemFilterRange} datetimeFilter
261
+ */
262
+ function formatDatetimeParam(datetimeFilter) {
263
+ if (!datetimeFilter) {
264
+ return null;
265
+ }
266
+ const min = datetimeFilter?.min ? new Date(datetimeFilter.min) : null;
267
+ const max = datetimeFilter?.max ? new Date(datetimeFilter.max) : null;
268
+ const start = datetimeFilter.state?.min
269
+ ? new Date(datetimeFilter.state.min)
270
+ : null;
271
+ const end = datetimeFilter.state?.max
272
+ ? new Date(datetimeFilter.state.max)
273
+ : null;
274
+ const includeStart = start && (!min || start > min);
275
+ const includeEnd = end && (!max || end < max);
276
+ if (!includeStart && !includeEnd) {
277
+ return null;
278
+ }
279
+ return `${includeStart ? start.toISOString() : ".."}/${includeEnd ? end.toISOString() : ".."}`;
280
+ }
@@ -1,50 +1,144 @@
1
- import { mapEl } from "@/store/states";
2
1
  import { inAndOut } from "ol/easing";
3
2
  import { renderItemsFeatures } from "./map";
4
3
 
5
4
  /**
6
- * @param {import("vue").Ref<import("@/types").GeoJsonFeature[]>} currentItems
5
+ * Build a compact signature from filter key + stringified state.
6
+ * @param {import("@/types").ItemFilterFilters | undefined} filters
7
+ * @returns {string}
7
8
  */
8
- export const createOnFilterHandler = (currentItems) => {
9
+ const getFiltersSignature = (filters) => {
10
+ if (!filters) return "";
11
+ return Object.keys(filters)
12
+ .sort()
13
+ .map((key) => `${key}:${filters[key]?.stringifiedState ?? ""}`)
14
+ .join("|");
15
+ };
16
+
17
+ /**
18
+ * @param {{
19
+ * currentItems: import("vue").Ref<import("@/types").GeoJsonFeature[]>,
20
+ * mapElement: import("vue").Ref<import("@eox/map").EOxMap | null>,
21
+ * hoverProperties: string[] | undefined,
22
+ * stacItemsStyle?: object,
23
+ * stacItemsInteractionStyle?: object,
24
+ * itemfilterEl?: import("vue").Ref<any>,
25
+ * selectedItemRef?: import("vue").Ref<import("stac-ts").StacItem | null>,
26
+ * mosaicOptions?: {
27
+ * isMosaicEnabled: import("vue").ComputedRef<boolean>,
28
+ * getMosaicEndpoint: () => string | null | undefined,
29
+ * scheduleMosaicUpdate: (mosaicEndpoint: string | null | undefined, timeRange?: [string,string], filters?: import("@/types").ItemFilterFilters) => void,
30
+ * } | null
31
+ * }} params
32
+ */
33
+ export const createOnFilterHandler = ({
34
+ currentItems,
35
+ mapElement,
36
+ hoverProperties,
37
+ stacItemsStyle,
38
+ stacItemsInteractionStyle,
39
+ itemfilterEl,
40
+ selectedItemRef,
41
+ mosaicOptions = null,
42
+ }) => {
43
+ let lastScheduledFiltersKey = "";
44
+
9
45
  /** @param {CustomEvent} evt */
10
46
  return (evt) => {
11
47
  currentItems.value = evt.detail.results;
12
- renderItemsFeatures(currentItems.value);
48
+ renderItemsFeatures(
49
+ currentItems.value,
50
+ mapElement,
51
+ hoverProperties,
52
+ stacItemsStyle,
53
+ stacItemsInteractionStyle,
54
+ );
55
+
56
+ const selected = selectedItemRef?.value;
57
+ if (selected && itemfilterEl?.value) {
58
+ itemfilterEl.value.selectedResult = selected;
59
+ }
60
+
61
+ if (mosaicOptions?.isMosaicEnabled.value && !selected) {
62
+ const nextFiltersKey = getFiltersSignature(evt.detail.filters);
63
+ if (nextFiltersKey === lastScheduledFiltersKey) {
64
+ return;
65
+ }
66
+
67
+ lastScheduledFiltersKey = nextFiltersKey;
68
+ mosaicOptions.scheduleMosaicUpdate(
69
+ mosaicOptions.getMosaicEndpoint(),
70
+ undefined,
71
+ evt.detail.filters,
72
+ );
73
+ }
13
74
  };
14
75
  };
15
76
  /**
16
77
  *
17
78
  * @param {ReturnType<typeof import("@/store/stac.js").useSTAcStore>} store
79
+ * @param {boolean} enableCompare
80
+ * @param {import("vue").Ref<import("@eox/map").EOxMap | null>} mapElement
18
81
  * @returns
19
82
  */
20
- export const createOnSelectHandler = (store) => {
83
+ export const createOnSelectHandler = (store, enableCompare, mapElement) => {
21
84
  /** @param {CustomEvent} evt */
22
85
  return async (evt) => {
23
86
  const item = /** @type {import("stac-ts").StacItem} */ (evt.detail);
24
87
  if (!item) {
25
88
  return;
26
89
  }
27
- if (store.selectedStac?.id === item.collection) {
28
- store.selectedItem = item;
90
+ if (enableCompare) {
91
+ if (item.id === store.selectedCompareItem?.id) {
92
+ store.selectedCompareItem = null;
93
+ return;
94
+ }
95
+ if (store.selectedCompareStac?.id === item.collection) {
96
+ store.selectedCompareItem = item;
97
+ } else {
98
+ await store.loadSelectedCompareSTAC(item.collection, false, item);
99
+ }
29
100
  } else {
30
- await store.loadSelectedSTAC(item.collection, false, item);
101
+ if (item.id === store.selectedItem?.id) {
102
+ store.selectedItem = null;
103
+ return;
104
+ }
105
+ if (store.selectedStac?.id === item.collection) {
106
+ store.selectedItem = item;
107
+ } else {
108
+ await store.loadSelectedSTAC(item.collection, false, item);
109
+ }
31
110
  }
32
111
 
33
- mapEl.value?.selectInteractions["stac-items"]?.highlightById([item.id], {
34
- padding: [100, 100, 100, 100],
35
- duration: 1200,
36
- easing: inAndOut,
37
- });
112
+ mapElement.value?.selectInteractions["stac-items"]?.highlightById(
113
+ [item.id],
114
+ {
115
+ padding: [100, 100, 100, 100],
116
+ duration: 1200,
117
+ easing: inAndOut,
118
+ },
119
+ );
38
120
  };
39
121
  };
40
122
 
41
123
  /**
42
- *
43
- * @param {CustomEvent} evt
124
+ * @param {import("vue").Ref<import("@eox/map").EOxMap | null>} mapElement
44
125
  */
45
- export const onMouseEnterResult = (evt) => {
46
- mapEl.value?.selectInteractions["stac-items"]?.highlightById([evt.detail.id]);
126
+ export const createOnMouseEnterResult = (mapElement) => {
127
+ /**
128
+ * @param {CustomEvent} evt
129
+ */
130
+ return (evt) => {
131
+ mapElement.value?.selectInteractions["stac-item-hover"]?.highlightById([
132
+ evt.detail.id,
133
+ ]);
134
+ };
47
135
  };
48
- export const onMouseLeaveResult = () => {
49
- mapEl.value?.selectInteractions["stac-items"]?.highlightById([]);
136
+
137
+ /**
138
+ * @param {import("vue").Ref<import("@eox/map").EOxMap | null>} mapElement
139
+ */
140
+ export const createOnMouseLeaveResult = (mapElement) => {
141
+ return () => {
142
+ mapElement.value?.selectInteractions["stac-item-hover"]?.highlightById([]);
143
+ };
50
144
  };