vue2-excel-grid 1.2.0 → 1.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-excel-grid",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Excel-style grid component for Vue 2.6.14 with virtual scrolling",
5
5
  "license": "MIT",
6
6
  "author": "Fozilbek Raimberdiyev",
@@ -12,7 +12,11 @@
12
12
  @click.stop="toggle"
13
13
  >
14
14
  <span v-if="selectedOpt && selectedOpt.color" class="eg-select-dot" :style="{ background: selectedOpt.color }"></span>
15
- <span class="eg-select-trigger-label" :class="{ 'eg-select-placeholder': !selectedOpt }">
15
+ <span
16
+ class="eg-select-trigger-label"
17
+ :class="{ 'eg-select-placeholder': !selectedOpt }"
18
+ :title="selectedOpt ? selectedOpt.tooltip : null"
19
+ >
16
20
  {{ selectedOpt ? selectedOpt.label : placeholder }}
17
21
  </span>
18
22
  <span class="eg-select-caret">▾</span>
@@ -42,6 +46,7 @@
42
46
  'eg-select-option--active': String(opt.value) === String(value),
43
47
  'eg-select-option--highlighted': idx === highlight
44
48
  }"
49
+ :title="opt.tooltip"
45
50
  @mousedown.prevent="pickOption(opt)"
46
51
  @mouseover="highlight = idx"
47
52
  >
@@ -79,6 +84,7 @@
79
84
  'eg-select-option--active': String(opt.value) === String(value),
80
85
  'eg-select-option--highlighted': idx === highlight
81
86
  }"
87
+ :title="opt.tooltip"
82
88
  @mousedown.prevent="pickOption(opt)"
83
89
  @mouseover="highlight = idx"
84
90
  >
@@ -134,11 +140,11 @@ export default {
134
140
  normalizedOptions() {
135
141
  const vk = this.valueKey
136
142
  const lk = this.labelKey
137
- return (this.options || []).map(o =>
138
- typeof o === 'string'
139
- ? { value: o, label: o }
140
- : { value: o[vk], label: o[lk] != null ? o[lk] : String(o[vk]), color: o.color }
141
- )
143
+ return (this.options || []).map(o => {
144
+ if (typeof o === 'string') return { value: o, label: o, tooltip: o }
145
+ const label = o[lk] != null ? o[lk] : String(o[vk])
146
+ return { value: o[vk], label, color: o.color, tooltip: o.tooltip != null ? o.tooltip : label }
147
+ })
142
148
  },
143
149
  filteredOptions() {
144
150
  if (!this.enableSearch || !this.searchQuery.trim()) return this.normalizedOptions
@@ -11,7 +11,11 @@
11
11
  :class="{ 'eg-select-trigger--disabled': disabled, 'eg-select-trigger--open': open }"
12
12
  @click.stop="toggle"
13
13
  >
14
- <span class="eg-select-trigger-label" :class="{ 'eg-select-placeholder': selectedLabel == null }">
14
+ <span
15
+ class="eg-select-trigger-label"
16
+ :class="{ 'eg-select-placeholder': selectedLabel == null }"
17
+ :title="selectedTooltip"
18
+ >
15
19
  {{ selectedLabel != null ? selectedLabel : placeholder }}
16
20
  </span>
17
21
  <span class="eg-select-caret">▾</span>
@@ -42,6 +46,7 @@
42
46
  'eg-select-option--highlighted': idx === highlight
43
47
  }"
44
48
  :style="!searchQuery ? { paddingLeft: (12 + opt.depth * 16) + 'px' } : null"
49
+ :title="opt.tooltip"
45
50
  @mousedown.prevent="pickOption(opt)"
46
51
  @mouseover="highlight = idx"
47
52
  >
@@ -86,6 +91,7 @@
86
91
  'eg-select-option--highlighted': idx === highlight
87
92
  }"
88
93
  :style="!searchQuery ? { paddingLeft: (12 + opt.depth * 16) + 'px' } : null"
94
+ :title="opt.tooltip"
89
95
  @mousedown.prevent="pickOption(opt)"
90
96
  @mouseover="highlight = idx"
91
97
  >
@@ -165,6 +171,14 @@ export default {
165
171
  const found = this._treeFindLabel(this.options || [], this.keys, v)
166
172
  return found != null ? found : null
167
173
  },
174
+ selectedTooltip() {
175
+ const v = String(this.value == null ? '' : this.value)
176
+ if (!v) return null
177
+ const node = this._treeFindNode(this.options || [], this.keys, v)
178
+ if (!node) return null
179
+ const label = node[this.keys.labelKey] != null ? node[this.keys.labelKey] : String(node[this.keys.valueKey])
180
+ return node.tooltip != null ? node.tooltip : label
181
+ },
168
182
  overlayStyle() {
169
183
  if (!this.dropdownOnly || !this.triggerRect) return { position: 'fixed', zIndex: 9999 }
170
184
  const rect = this.triggerRect
@@ -375,7 +389,8 @@ export default {
375
389
  const children = Array.isArray(node[keys.childrenKey]) ? node[keys.childrenKey] : []
376
390
  const hasChildren = children.length > 0
377
391
  const expanded = hasChildren && !!expandedMap[id]
378
- out.push({ value: node[keys.valueKey], label: node[keys.labelKey] != null ? node[keys.labelKey] : String(node[keys.valueKey]), color: node.color, id, depth, hasChildren, expanded })
392
+ const label = node[keys.labelKey] != null ? node[keys.labelKey] : String(node[keys.valueKey])
393
+ out.push({ value: node[keys.valueKey], label, color: node.color, tooltip: node.tooltip != null ? node.tooltip : label, id, depth, hasChildren, expanded })
379
394
  if (expanded) out = out.concat(this._treeFlatten(children, keys, expandedMap, depth + 1, path))
380
395
  })
381
396
  return out
@@ -385,7 +400,8 @@ export default {
385
400
  const walk = (list) => {
386
401
  ;(list || []).forEach(node => {
387
402
  const children = Array.isArray(node[keys.childrenKey]) ? node[keys.childrenKey] : []
388
- result.push({ value: node[keys.valueKey], label: node[keys.labelKey] != null ? node[keys.labelKey] : String(node[keys.valueKey]), color: node.color, id: String(node[keys.valueKey]), depth: 0, hasChildren: false, expanded: false })
403
+ const label = node[keys.labelKey] != null ? node[keys.labelKey] : String(node[keys.valueKey])
404
+ result.push({ value: node[keys.valueKey], label, color: node.color, tooltip: node.tooltip != null ? node.tooltip : label, id: String(node[keys.valueKey]), depth: 0, hasChildren: false, expanded: false })
389
405
  if (children.length) walk(children)
390
406
  })
391
407
  }
@@ -402,6 +418,14 @@ export default {
402
418
  }
403
419
  return null
404
420
  },
421
+ _treeFindNode(nodes, keys, value) {
422
+ for (const node of (nodes || [])) {
423
+ if (String(node[keys.valueKey]) === value) return node
424
+ const found = this._treeFindNode(node[keys.childrenKey], keys, value)
425
+ if (found != null) return found
426
+ }
427
+ return null
428
+ },
405
429
  _treeFindPath(nodes, keys, value, pathArr) {
406
430
  for (let i = 0; i < (nodes || []).length; i++) {
407
431
  const node = nodes[i]