@abi-software/map-side-bar 2.18.0 → 2.19.1-demo.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 (41) hide show
  1. package/.postcssrc.json +5 -5
  2. package/README.md +8 -9
  3. package/cypress.config.js +6 -7
  4. package/dist/map-side-bar.js +6890 -6026
  5. package/dist/map-side-bar.umd.cjs +65 -62
  6. package/dist/style.css +1 -1
  7. package/eslint.config.js +44 -9
  8. package/package.json +10 -3
  9. package/reporter-config.json +1 -1
  10. package/src/App.vue +89 -80
  11. package/src/algolia/algolia.js +173 -167
  12. package/src/algolia/utils.js +34 -38
  13. package/src/assets/_variables.scss +12 -10
  14. package/src/assets/connectivity-explorer.scss +1 -1
  15. package/src/assets/fonts.scss +0 -1
  16. package/src/assets/searchPopover.scss +1 -2
  17. package/src/components/AnnotationTool.vue +9 -32
  18. package/src/components/BadgesGroup.vue +29 -32
  19. package/src/components/CellCard.vue +992 -0
  20. package/src/components/CellCardExplorer.vue +879 -0
  21. package/src/components/ConnectivityCard.vue +22 -19
  22. package/src/components/ConnectivityExplorer.vue +109 -130
  23. package/src/components/ConnectivityInfo.vue +142 -171
  24. package/src/components/ContributorItem.vue +15 -11
  25. package/src/components/DatasetCard.vue +166 -201
  26. package/src/components/DatasetExplorer.vue +160 -201
  27. package/src/components/ImageGallery.vue +35 -36
  28. package/src/components/SearchFilters.vue +384 -407
  29. package/src/components/SearchHistory.vue +69 -103
  30. package/src/components/SideBar.vue +186 -94
  31. package/src/components/Tabs.vue +25 -21
  32. package/src/components/icons/IconOpenExternal.vue +23 -0
  33. package/src/components/index.js +3 -5
  34. package/src/components/species-map.js +7 -7
  35. package/src/components.d.ts +3 -0
  36. package/src/exampleConnectivityInput.js +310 -318
  37. package/src/main.js +6 -6
  38. package/src/mixins/S3Bucket.vue +10 -13
  39. package/src/utils/common.js +59 -0
  40. package/vite.config.js +62 -61
  41. package/vuese-generator.js +47 -55
@@ -2,13 +2,7 @@
2
2
  <div class="history-container" v-if="searchHistory.length">
3
3
  <div class="saved-search-history" v-if="savedSearchHistory.length">
4
4
  <template v-for="(item, i) in savedSearchHistory" :key="item.id">
5
- <el-tag
6
- class="search-tag"
7
- v-if="i < 2"
8
- v-bind:key="i"
9
- @click="search(item)"
10
- size="large"
11
- >
5
+ <el-tag class="search-tag" v-if="i < 2" v-bind:key="i" @click="search(item)" size="large">
12
6
  <template v-if="item.longLabel">
13
7
  <el-popover
14
8
  width="auto"
@@ -32,10 +26,7 @@
32
26
  <div v-else>
33
27
  <span class="empty-saved-search">No Saved Searches</span>
34
28
  </div>
35
- <el-dropdown
36
- trigger="click"
37
- :hide-on-click="false"
38
- >
29
+ <el-dropdown trigger="click" :hide-on-click="false">
39
30
  <span class="el-dropdown-select">
40
31
  Search history
41
32
  <el-icon class="el-icon--right">
@@ -77,23 +68,26 @@
77
68
  popper-class="popover-dropdown"
78
69
  >
79
70
  <template #reference>
80
- <el-button circle text size="small"
71
+ <el-button
72
+ circle
73
+ text
74
+ size="small"
81
75
  @click="toggleSavedSearch(item)"
82
76
  :disabled="savedSearchHistory.length > 1 && !item.saved"
83
77
  >
84
78
  <el-icon color="#8300BF">
85
79
  <template v-if="item.saved">
86
- <svg
87
- viewBox="0 0 24 24"
88
- >
89
- <path d="m12 21.35-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54z"></path>
80
+ <svg viewBox="0 0 24 24">
81
+ <path
82
+ d="m12 21.35-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54z"
83
+ ></path>
90
84
  </svg>
91
85
  </template>
92
86
  <template v-else>
93
- <svg
94
- viewBox="0 0 24 24"
95
- >
96
- <path d="M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3m-4.4 15.55-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05"></path>
87
+ <svg viewBox="0 0 24 24">
88
+ <path
89
+ d="M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3m-4.4 15.55-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05"
90
+ ></path>
97
91
  </svg>
98
92
  </template>
99
93
  </el-icon>
@@ -102,12 +96,8 @@
102
96
  <span v-if="savedSearchHistory.length > 1 && !item.saved">
103
97
  Limit 2: Please remove a saved search before adding another.
104
98
  </span>
105
- <span v-else-if="item.saved">
106
- Remove from saved searches.
107
- </span>
108
- <span v-else>
109
- Add up to two saved searches.
110
- </span>
99
+ <span v-else-if="item.saved">Remove from saved searches.</span>
100
+ <span v-else>Add up to two saved searches.</span>
111
101
  </el-popover>
112
102
  <el-popover
113
103
  width="auto"
@@ -117,17 +107,13 @@
117
107
  popper-class="popover-dropdown"
118
108
  >
119
109
  <template #reference>
120
- <el-button circle text size="small"
121
- @click="removeFromSavedSearch(item)"
122
- >
110
+ <el-button circle text size="small" @click="removeFromSavedSearch(item)">
123
111
  <el-icon color="#8300BF">
124
112
  <el-icon-delete />
125
113
  </el-icon>
126
114
  </el-button>
127
115
  </template>
128
- <span>
129
- Remove from search history.
130
- </span>
116
+ <span>Remove from search history.</span>
131
117
  </el-popover>
132
118
  </div>
133
119
  </el-dropdown-item>
@@ -138,38 +124,13 @@
138
124
  </template>
139
125
 
140
126
  <script>
141
- /* eslint-disable no-alert, no-console */
142
- import {
143
- ElTag as Tag,
144
- ElSelect as Select,
145
- ElDropdown,
146
- ElIcon,
147
- } from 'element-plus'
148
-
149
- import EventBus from './EventBus.js'
127
+ import EventBus from './EventBus.js';
128
+ import { generateUUID } from '../utils/common.js';
150
129
 
151
130
  const MAX_SEARCH_HISTORY = 12;
152
131
 
153
- function generateUUID() {
154
- const arr = new Uint8Array(16);
155
- window.crypto.getRandomValues(arr);
156
-
157
- arr[6] = (arr[6] & 0x0f) | 0x40;
158
- arr[8] = (arr[8] & 0x3f) | 0x80;
159
-
160
- const hex = Array.from(arr)
161
- .map(byte => byte.toString(16).padStart(2, '0'))
162
- .join('');
163
-
164
- return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
165
- }
166
-
167
132
  export default {
168
133
  name: 'SearchHistory',
169
- components: {
170
- Tag,
171
- Select
172
- },
173
134
  props: {
174
135
  localStorageKey: {
175
136
  type: String,
@@ -180,12 +141,12 @@ export default {
180
141
  return {
181
142
  searchHistory: [],
182
143
  savedSearchHistory: [],
183
- }
144
+ };
184
145
  },
185
146
  mounted: function () {
186
- this.getSearchHistory()
147
+ this.getSearchHistory();
187
148
  EventBus.on('search-changed', (data) => {
188
- this.setSearchHistory(data)
149
+ this.setSearchHistory(data);
189
150
  });
190
151
  this.updateSearchHistory();
191
152
  this.savedSearchHistory = this.searchHistory.filter((item) => item.saved);
@@ -193,14 +154,14 @@ export default {
193
154
  methods: {
194
155
  getSearchHistory() {
195
156
  if (localStorage.getItem(this.localStorageKey)) {
196
- this.searchHistory = JSON.parse(localStorage.getItem(this.localStorageKey))
157
+ this.searchHistory = JSON.parse(localStorage.getItem(this.localStorageKey));
197
158
  } else {
198
- this.searchHistory = []
159
+ this.searchHistory = [];
199
160
  }
200
161
  },
201
162
  clearSearchHistory() {
202
- localStorage.removeItem(this.localStorageKey)
203
- this.searchHistory = []
163
+ localStorage.removeItem(this.localStorageKey);
164
+ this.searchHistory = [];
204
165
  },
205
166
  sortFilters(a, b) {
206
167
  return a.facetPropPath.localeCompare(b.facetPropPath);
@@ -216,7 +177,7 @@ export default {
216
177
  return 0;
217
178
  },
218
179
  addSearchToHistory(filters = [], search = '') {
219
- search = search.trim() // remove whitespace
180
+ search = search.trim(); // remove whitespace
220
181
 
221
182
  const isExistingItem = this.searchHistory.some((item) => {
222
183
  let historyFilters = item.filters;
@@ -229,14 +190,11 @@ export default {
229
190
  const historyFiltersString = JSON.stringify(historyFilters);
230
191
  const newFiltersString = JSON.stringify(newFilters);
231
192
 
232
- return (
233
- item.search === search &&
234
- historyFiltersString === newFiltersString
235
- );
193
+ return item.search === search && historyFiltersString === newFiltersString;
236
194
  });
237
195
 
238
196
  if (!isExistingItem) {
239
- const {label, longLabel} = this.searchHistoryItemLabel(search, filters);
197
+ const { label, longLabel } = this.searchHistoryItemLabel(search, filters);
240
198
  if (label || longLabel) {
241
199
  const newItem = {
242
200
  filters: filters,
@@ -245,7 +203,7 @@ export default {
245
203
  label: label,
246
204
  longLabel: longLabel,
247
205
  id: generateUUID(),
248
- updated: (new Date()).getTime(),
206
+ updated: new Date().getTime(),
249
207
  };
250
208
 
251
209
  this.searchHistory.push(newItem);
@@ -269,7 +227,7 @@ export default {
269
227
 
270
228
  this.searchHistory.forEach((item) => {
271
229
  const key = `${item.search}-${JSON.stringify(item.filters)}`;
272
- const existingItem = keys.find(k => k.key === key);
230
+ const existingItem = keys.find((k) => k.key === key);
273
231
  // duplicate item
274
232
  if (existingItem) {
275
233
  // if current item is saved item
@@ -282,13 +240,15 @@ export default {
282
240
  } else {
283
241
  keys.push({
284
242
  id: item.id,
285
- key: key
243
+ key: key,
286
244
  });
287
245
  }
288
246
  });
289
247
 
290
248
  if (duplicateItemIDs.length) {
291
- this.searchHistory = this.searchHistory.filter((item) => !duplicateItemIDs.includes(item.id));
249
+ this.searchHistory = this.searchHistory.filter(
250
+ (item) => !duplicateItemIDs.includes(item.id),
251
+ );
292
252
  }
293
253
  },
294
254
  /**
@@ -302,10 +262,7 @@ export default {
302
262
  const unsavedItems = this.searchHistory.filter((item) => !item.saved);
303
263
  const extra = MAX_SEARCH_HISTORY - this.searchHistory.length;
304
264
 
305
- this.searchHistory = [
306
- ...savedItems,
307
- ...unsavedItems.slice(0, extra),
308
- ];
265
+ this.searchHistory = [...savedItems, ...unsavedItems.slice(0, extra)];
309
266
  }
310
267
  },
311
268
  updateSearchHistory: function () {
@@ -316,7 +273,7 @@ export default {
316
273
  }
317
274
 
318
275
  if (!item.label) {
319
- const {label, longLabel} = this.searchHistoryItemLabel(item.search, item.filters);
276
+ const { label, longLabel } = this.searchHistoryItemLabel(item.search, item.filters);
320
277
  item['label'] = label;
321
278
  item['longLabel'] = longLabel;
322
279
  }
@@ -329,7 +286,7 @@ export default {
329
286
  }
330
287
 
331
288
  if (!item.updated) {
332
- item['updated'] = (new Date()).getTime();
289
+ item['updated'] = new Date().getTime();
333
290
  }
334
291
  });
335
292
 
@@ -342,23 +299,30 @@ export default {
342
299
  this.trimSearchHistory();
343
300
 
344
301
  // Save updated data
345
- localStorage.setItem(this.localStorageKey, JSON.stringify(this.searchHistory))
302
+ localStorage.setItem(this.localStorageKey, JSON.stringify(this.searchHistory));
346
303
  },
347
304
  getParentComponentName: function () {
348
305
  const isConnectivity = this.localStorageKey?.indexOf('connectivity') !== -1;
349
306
  const isDataset = this.localStorageKey?.indexOf('dataset') !== -1;
350
- const location = isConnectivity ? 'connectivity' : isDataset ? 'dataset' : '';
307
+ const isCellCard = this.localStorageKey?.indexOf('cell-card') !== -1;
308
+ const location = isConnectivity
309
+ ? 'connectivity'
310
+ : isDataset
311
+ ? 'dataset'
312
+ : isCellCard
313
+ ? 'cell_card'
314
+ : '';
351
315
  return location;
352
316
  },
353
317
  search: function (item) {
354
- this.$emit('search', item)
318
+ this.$emit('search', item);
355
319
 
356
320
  // Event tracking
357
321
  const location = this.getParentComponentName();
358
322
  EventBus.emit('trackEvent', {
359
- 'event_name': `portal_maps_search_history_click`,
360
- 'category': item.longLabel || item.label,
361
- 'location': `map_sidebar_${location}`,
323
+ event_name: `portal_maps_search_history_click`,
324
+ category: item.longLabel || item.label,
325
+ location: `map_sidebar_${location}`,
362
326
  });
363
327
  },
364
328
  searchHistoryItemLabel: function (search, filters) {
@@ -393,7 +357,7 @@ export default {
393
357
  longLabel = label;
394
358
  }
395
359
 
396
- return {label, longLabel};
360
+ return { label, longLabel };
397
361
  },
398
362
  toggleSavedSearch: function (item) {
399
363
  this.searchHistory.forEach((_item) => {
@@ -404,12 +368,14 @@ export default {
404
368
  this.savedSearchHistory = this.searchHistory.filter((item) => item.saved);
405
369
  this.updateSearchHistory();
406
370
 
407
- const eventName = item.saved ? 'portal_maps_search_history_saved' : 'portal_maps_search_history_unsaved';
371
+ const eventName = item.saved
372
+ ? 'portal_maps_search_history_saved'
373
+ : 'portal_maps_search_history_unsaved';
408
374
  const location = this.getParentComponentName();
409
375
  EventBus.emit('trackEvent', {
410
- 'event_name': eventName,
411
- 'category': item.longLabel || item.label,
412
- 'location': `map_sidebar_${location}`,
376
+ event_name: eventName,
377
+ category: item.longLabel || item.label,
378
+ location: `map_sidebar_${location}`,
413
379
  });
414
380
  },
415
381
  removeFromSavedSearch: function (item) {
@@ -420,13 +386,13 @@ export default {
420
386
 
421
387
  const location = this.getParentComponentName();
422
388
  EventBus.emit('trackEvent', {
423
- 'event_name': 'portal_maps_search_history_removed',
424
- 'category': item.longLabel || item.label,
425
- 'location': `map_sidebar_${location}`,
389
+ event_name: 'portal_maps_search_history_removed',
390
+ category: item.longLabel || item.label,
391
+ location: `map_sidebar_${location}`,
426
392
  });
427
393
  },
428
394
  },
429
- }
395
+ };
430
396
  </script>
431
397
 
432
398
  <style lang="scss" scoped>
@@ -453,9 +419,9 @@ export default {
453
419
  .search-tag.el-tag {
454
420
  margin: 0;
455
421
  cursor: pointer !important;
456
- background: #f9f2fc!important;
457
- border-color: $app-primary-color!important;
458
- color:$app-primary-color!important;
422
+ background: #f9f2fc !important;
423
+ border-color: $app-primary-color !important;
424
+ color: $app-primary-color !important;
459
425
 
460
426
  :deep(.el-tag__content) {
461
427
  max-width: 15ch;
@@ -504,7 +470,7 @@ export default {
504
470
  color: var(--el-text-color-placeholder);
505
471
  }
506
472
 
507
- &[aria-expanded="true"] {
473
+ &[aria-expanded='true'] {
508
474
  .el-icon {
509
475
  transform: rotate(180deg);
510
476
  }
@@ -533,7 +499,7 @@ export default {
533
499
 
534
500
  + .el-dropdown-menu__item {
535
501
  &::before {
536
- content: "";
502
+ content: '';
537
503
  display: block;
538
504
  width: calc(100% - 32px);
539
505
  border-top: 1px solid var(--el-border-color);
@@ -570,7 +536,7 @@ export default {
570
536
 
571
537
  .el-button {
572
538
  background-color: transparent !important;
573
- transition: all .25s ease;
539
+ transition: all 0.25s ease;
574
540
 
575
541
  > span {
576
542
  pointer-events: none;