pull/6493/head
tugcekucukoglu 2024-09-27 08:57:00 +03:00
parent 3845ff8bba
commit 7ddf56dc88
1 changed files with 16 additions and 11 deletions

View File

@ -30,16 +30,21 @@
{{ label || 'empty' }} {{ label || 'empty' }}
</template> </template>
<template v-else-if="display === 'chip'"> <template v-else-if="display === 'chip'">
<span v-for="item of chipSelectedItems" :key="getLabelByValue(item)" :class="cx('chipItem')" v-bind="ptm('chipItem')"> <template v-if="chipSelectedItems">
<slot name="chip" :value="item" :removeCallback="(event) => removeOption(event, item)"> <span>{{ label }}</span>
<!-- TODO: removetokenicon and removeTokenIcon deprecated since v4.0. Use chipicon slot and chipIcon prop--> </template>
<Chip :class="cx('pcChip')" :label="getLabelByValue(item)" :removeIcon="chipIcon || removeTokenIcon" removable :unstyled="unstyled" @remove="removeOption($event, item)" :pt="ptm('pcChip')"> <template v-else>
<template #removeicon> <span v-for="item of modelValue" :key="getLabelByValue(item)" :class="cx('chipItem')" v-bind="ptm('chipItem')">
<slot :name="$slots.chipicon ? 'chipicon' : 'removetokenicon'" :class="cx('chipIcon')" :item="item" :removeCallback="(event) => removeOption(event, item)" /> <slot name="chip" :value="item" :removeCallback="(event) => removeOption(event, item)">
</template> <!-- TODO: removetokenicon and removeTokenIcon deprecated since v4.0. Use chipicon slot and chipIcon prop-->
</Chip> <Chip :class="cx('pcChip')" :label="getLabelByValue(item)" :removeIcon="chipIcon || removeTokenIcon" removable :unstyled="unstyled" @remove="removeOption($event, item)" :pt="ptm('pcChip')">
</slot> <template #removeicon>
</span> <slot :name="$slots.chipicon ? 'chipicon' : 'removetokenicon'" :class="cx('chipIcon')" :item="item" :removeCallback="(event) => removeOption(event, item)" />
</template>
</Chip>
</slot>
</span>
</template>
<template v-if="!modelValue || modelValue.length === 0">{{ placeholder || 'empty' }}</template> <template v-if="!modelValue || modelValue.length === 0">{{ placeholder || 'empty' }}</template>
</template> </template>
</slot> </slot>
@ -1059,7 +1064,7 @@ export default {
return label; return label;
}, },
chipSelectedItems() { chipSelectedItems() {
return isNotEmpty(this.maxSelectedLabels) && this.modelValue && this.modelValue.length > this.maxSelectedLabels ? this.modelValue.slice(0, this.maxSelectedLabels) : this.modelValue; return isNotEmpty(this.maxSelectedLabels) && this.modelValue && this.modelValue.length > this.maxSelectedLabels;
}, },
allSelected() { allSelected() {
return this.selectAll !== null ? this.selectAll : isNotEmpty(this.visibleOptions) && this.visibleOptions.every((option) => this.isOptionGroup(option) || this.isOptionDisabled(option) || this.isSelected(option)); return this.selectAll !== null ? this.selectAll : isNotEmpty(this.visibleOptions) && this.visibleOptions.every((option) => this.isOptionGroup(option) || this.isOptionDisabled(option) || this.isSelected(option));