Skip to content

Commit

Permalink
feat-completed-riophae#536
Browse files Browse the repository at this point in the history
  • Loading branch information
Siva authored and Siva committed Oct 7, 2023
1 parent 9ae16b6 commit 585df22
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/MultiValueItem.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<script>
import { onLeftClick } from '../utils'
import treeselectMixin from '../mixins/treeselectMixin'
import DeleteIcon from './icons/Delete'
export default {
name: 'vue-treeselect--multi-value-item',
inject: [ 'instance' ],
mixins: [ treeselectMixin ],
props: {
node: {
Expand All @@ -31,11 +33,14 @@
}
const customValueLabelRenderer = instance.$scopedSlots['value-label']
const labelRenderer = customValueLabelRenderer ? customValueLabelRenderer({ node }) : node.label
let value = labelRenderer
if (this.trimLength > 0) {
value = labelRenderer.length > this.trimLength ? labelRenderer.slice(0, this.trimLength) + '...' : labelRenderer
}
return (
<div class="vue-treeselect__multi-value-item-container">
<div class={itemClass} onMousedown={this.handleMouseDown}>
<span class="vue-treeselect__multi-value-label">{ labelRenderer }</span>
<span class="vue-treeselect__multi-value-label" title={ this.showTitle ? labelRenderer : null }>{ value }</span>
<span class="vue-treeselect__icon vue-treeselect__value-remove"><DeleteIcon /></span>
</div>
</div>
Expand Down
16 changes: 16 additions & 0 deletions src/mixins/treeselectMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,22 @@ export default {
type: [ Number, String ],
default: 999,
},

/**
* to trim the label
*/
trimLength: {
type: Number,
default: 0,
},

/**
*to show the title
*/
showTitle: {
type: Boolean,
default: false,
},
},

data() {
Expand Down

0 comments on commit 585df22

Please sign in to comment.