@abi-software/flatmapvuer 1.20.1-demo.1 → 1.21.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.
@@ -2,80 +2,86 @@
2
2
  <div class="multi-container" ref="multiContainer">
3
3
  <div style="position: absolute; z-index: 100" v-if="!disableUI">
4
4
  <div class="species-display-text">Species</div>
5
- <el-select
6
- id="flatmap-select"
7
- ref="speciesSelect"
8
- v-help-mode="{
9
- id: 'multiflatmap-species-select',
10
- area: 'map-info',
11
- title: 'Select a species',
12
- description: 'Switch between the maps of the available species.',
13
- placement: 'right',
14
- }"
5
+ <el-popover
6
+ content="Select a species"
7
+ placement="right"
8
+ trigger="manual"
9
+ popper-class="flatmap-popper flatmap-teleport-popper right-popper"
10
+ width="max-content"
11
+ :visible="activateTooltipByIndex(0)"
15
12
  :teleported="false"
16
- v-model="activeSpecies"
17
- placeholder="Select"
18
- class="select-box"
19
- popper-class="flatmap-dropdown"
20
- @change="setSpecies"
13
+ ref="selectPopover"
21
14
  >
22
- <el-option v-for="(item, key) in speciesList" :key="key" :label="key" :value="key">
23
- <span class="option-label">
24
- <el-tooltip
25
- v-if="activeSpecies !== key"
26
- :content="`Change species to ${key}`"
27
- placement="top"
28
- effect="light"
29
- :show-after="200"
30
- popper-class="flatmap-species-option-tooltip"
31
- >
32
- <span class="option-title">
33
- <span class="select-box-icon">
34
- <i :class="item.iconClass"></i>
15
+ <template #reference>
16
+ <el-select
17
+ id="flatmap-select"
18
+ ref="speciesSelect"
19
+ :teleported="false"
20
+ v-model="activeSpecies"
21
+ placeholder="Select"
22
+ class="select-box"
23
+ popper-class="flatmap-dropdown"
24
+ @change="setSpecies"
25
+ >
26
+ <el-option v-for="(item, key) in speciesList" :key="key" :label="key" :value="key">
27
+ <span class="option-label">
28
+ <el-tooltip
29
+ v-if="activeSpecies !== key"
30
+ :content="`Change species to ${key}`"
31
+ placement="top"
32
+ effect="light"
33
+ :show-after="200"
34
+ popper-class="flatmap-species-option-tooltip"
35
+ >
36
+ <span class="option-title">
37
+ <span class="select-box-icon">
38
+ <i :class="item.iconClass"></i>
39
+ </span>
40
+ {{ key }}
41
+ </span>
42
+ </el-tooltip>
43
+ <span v-else class="option-title active-species">
44
+ <span class="select-box-icon">
45
+ <i :class="item.iconClass"></i>
46
+ </span>
47
+ {{ key }}
35
48
  </span>
36
- {{ key }}
37
- </span>
38
- </el-tooltip>
39
- <span v-else class="option-title active-species">
40
- <span class="select-box-icon">
41
- <i :class="item.iconClass"></i>
42
- </span>
43
- {{ key }}
44
- </span>
45
- <el-tooltip
46
- v-if="enableOpenMapUI"
47
- :content="`Open ${key} in a new view`"
48
- placement="top"
49
- effect="light"
50
- :show-after="200"
51
- popper-class="flatmap-open-new-view-tooltip"
52
- >
53
- <button
54
- type="button"
55
- class="open-new-view-button"
56
- :aria-label="`Open ${key} in a new view`"
57
- @click.stop="openSpeciesInNewView(key)"
58
- >
59
- <svg
60
- viewBox="0 0 24 24"
61
- width="14"
62
- height="14"
63
- fill="none"
64
- stroke="currentColor"
65
- stroke-width="2"
66
- stroke-linecap="round"
67
- stroke-linejoin="round"
68
- aria-hidden="true"
49
+ <el-tooltip
50
+ v-if="enableOpenMapUI"
51
+ :content="`Open ${key} in a new view`"
52
+ placement="top"
53
+ effect="light"
54
+ :show-after="200"
55
+ popper-class="flatmap-open-new-view-tooltip"
69
56
  >
70
- <rect x="8" y="8" width="13" height="13" rx="2" />
71
- <path d="M16 8V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h3" />
72
- <path d="M14.5 11.5v6M11.5 14.5h6" />
73
- </svg>
74
- </button>
75
- </el-tooltip>
76
- </span>
77
- </el-option>
78
- </el-select>
57
+ <button
58
+ type="button"
59
+ class="open-new-view-button"
60
+ :aria-label="`Open ${key} in a new view`"
61
+ @click.stop="openSpeciesInNewView(key)"
62
+ >
63
+ <svg
64
+ viewBox="0 0 24 24"
65
+ width="14"
66
+ height="14"
67
+ fill="none"
68
+ stroke="currentColor"
69
+ stroke-width="2"
70
+ stroke-linecap="round"
71
+ stroke-linejoin="round"
72
+ aria-hidden="true"
73
+ >
74
+ <rect x="8" y="8" width="13" height="13" rx="2" />
75
+ <path d="M16 8V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h3" />
76
+ <path d="M14.5 11.5v6M11.5 14.5h6" />
77
+ </svg>
78
+ </button>
79
+ </el-tooltip>
80
+ </span>
81
+ </el-option>
82
+ </el-select>
83
+ </template>
84
+ </el-popover>
79
85
  </div>
80
86
  <!--
81
87
  This event is emitted when the user chooses a different map option
@@ -121,6 +127,13 @@
121
127
  @open-map="$emit('open-map', $event)"
122
128
  @pathway-selection-changed="onSelectionsDataChanged"
123
129
  :minZoom="minZoom"
130
+ :helpMode="activeSpecies == key && helpMode"
131
+ :helpModeActiveItem="helpModeActiveItem"
132
+ :helpModeDialog="helpModeDialog"
133
+ :helpModeInitialIndex="-2"
134
+ @help-mode-last-item="onHelpModeLastItem"
135
+ @shown-tooltip="onTooltipShown"
136
+ @shown-map-tooltip="onMapTooltipShown"
124
137
  :renderAtMounted="renderAtMounted"
125
138
  :render="render && activeSpecies == key"
126
139
  :displayMinimap="displayMinimap"
@@ -145,7 +158,6 @@
145
158
  import { markRaw } from 'vue';
146
159
  import EventBus from './EventBus';
147
160
  import FlatmapVuer from './FlatmapVuer.vue';
148
- import { collectHelpModeSteps, helpModeDirective } from '@abi-software/map-utilities';
149
161
  import flatmap from '../services/flatmapLoader.js';
150
162
 
151
163
  const TAXON_UUID = {
@@ -164,9 +176,6 @@ export default {
164
176
  components: {
165
177
  FlatmapVuer,
166
178
  },
167
- directives: {
168
- helpMode: helpModeDirective,
169
- },
170
179
  created: function () {
171
180
  this.loadMapManager();
172
181
  },
@@ -378,17 +387,6 @@ export default {
378
387
  getCurrentFlatmap: function () {
379
388
  return this.$refs[this.activeSpecies][0];
380
389
  },
381
- /**
382
- * @public
383
- * Function to get the help mode steps of this component and the current flatmap,
384
- * from the elements with ``v-help-mode``, to be used with ``HelpModeTour`` and
385
- * ``HelpModeHover`` from ``@abi-software/map-utilities``.
386
- * The flatmaps of the other species are hidden and left out.
387
- * @returns {Array} The list of help steps.
388
- */
389
- getHelpModeSteps: function () {
390
- return collectHelpModeSteps(this.$el);
391
- },
392
390
  /**
393
391
  * @public
394
392
  * Function to request opening the given species in a new view/panel,
@@ -626,6 +624,44 @@ export default {
626
624
  });
627
625
  }
628
626
  },
627
+ /**
628
+ * @public
629
+ * Function to activate help mode tooltip by item index number
630
+ * @arg {Number} `index`
631
+ */
632
+ activateTooltipByIndex: function (index) {
633
+ return index === this.helpModeActiveItem && this.helpMode;
634
+ },
635
+ /**
636
+ * @public
637
+ * Function to check the last item of help mode
638
+ * @arg {Boolean} `isLastItem`
639
+ */
640
+ onHelpModeLastItem: function (isLastItem) {
641
+ if (isLastItem) {
642
+ this.$emit('help-mode-last-item', true);
643
+ }
644
+ },
645
+ /**
646
+ * @public
647
+ * Function to emit event after a tooltip is shown.
648
+ */
649
+ onTooltipShown: function () {
650
+ /**
651
+ * This event is emitted after a tooltip in Flatmap is shown.
652
+ */
653
+ this.$emit('shown-tooltip');
654
+ },
655
+ /**
656
+ * @public
657
+ * Function to emit event after a tooltip on the map is shown.
658
+ */
659
+ onMapTooltipShown: function () {
660
+ /**
661
+ * This event is emitted after a tooltip on Flatmap's map is shown.
662
+ */
663
+ this.$emit('shown-map-tooltip');
664
+ },
629
665
  /**
630
666
  * @public
631
667
  * Function to change the view mode of the map.
@@ -672,6 +708,36 @@ export default {
672
708
  type: Boolean,
673
709
  default: true,
674
710
  },
711
+ /**
712
+ * The option to show tooltips for help mode.
713
+ */
714
+ helpMode: {
715
+ type: Boolean,
716
+ default: false,
717
+ },
718
+ /**
719
+ * The active item index of help mode.
720
+ */
721
+ helpModeActiveItem: {
722
+ type: Number,
723
+ default: 0,
724
+ },
725
+ /**
726
+ * The option to use helpModeDialog.
727
+ * On default, `false`, clicking help will show all tooltips.
728
+ * If `true`, clicking help will show the help-mode-dialog.
729
+ */
730
+ helpModeDialog: {
731
+ type: Boolean,
732
+ default: false,
733
+ },
734
+ /**
735
+ * The last item of help mode.
736
+ */
737
+ helpModeLastItem: {
738
+ type: Boolean,
739
+ default: false,
740
+ },
675
741
  /**
676
742
  * The option to display minimap at the top-right corner of the map.
677
743
  */
@@ -15,23 +15,11 @@
15
15
  width="max-content"
16
16
  :offset="0"
17
17
  popper-class="flatmap-popper flatmap-teleport-popper"
18
- :visible="isHovering"
18
+ :visible="tooltipVisible"
19
19
  ref="featuredMarkerPopover"
20
20
  >
21
21
  <template #reference>
22
- <div
23
- v-popover:featuredMarkerPopover
24
- v-help-mode="{
25
- id: 'flatmap-featured-marker',
26
- area: 'legends',
27
- title: 'Featured dataset marker',
28
- description: 'Shows the location of the featured dataset on the map.',
29
- placement: 'right',
30
- onEnter: openHelpModeDrawer,
31
- }"
32
- @mouseover="onMouseOver"
33
- @mouseout="onMouseOut"
34
- >
22
+ <div v-popover:featuredMarkerPopover @mouseover="onMouseOver" @mouseout="onMouseOut">
35
23
  <LegendItem
36
24
  :item="item"
37
25
  :identifierKey="identifierKey"
@@ -56,19 +44,12 @@
56
44
 
57
45
  <script>
58
46
  import LegendItem from './LegendItem.vue';
59
- import { helpModeDirective } from '@abi-software/map-utilities';
60
47
 
61
48
  export default {
62
49
  name: 'DynamicLegends',
63
50
  components: {
64
51
  LegendItem,
65
52
  },
66
- directives: {
67
- helpMode: helpModeDirective,
68
- },
69
- inject: {
70
- openHelpModeDrawer: { default: () => () => {} },
71
- },
72
53
  props: {
73
54
  identifierKey: {
74
55
  type: String,
@@ -92,6 +73,10 @@ export default {
92
73
  type: Boolean,
93
74
  default: false,
94
75
  },
76
+ showDatasetMarkerTooltip: {
77
+ type: Boolean,
78
+ default: false,
79
+ },
95
80
  },
96
81
  data() {
97
82
  return {
@@ -99,6 +84,12 @@ export default {
99
84
  hoverTimeout: null,
100
85
  };
101
86
  },
87
+ computed: {
88
+ tooltipVisible() {
89
+ // Show tooltip when either help mode is active OR user is hovering
90
+ return (this.showDatasetMarkerTooltip && this.showStarInLegend) || this.isHovering;
91
+ },
92
+ },
102
93
  methods: {
103
94
  onMouseOver() {
104
95
  clearTimeout(this.hoverTimeout);