misp-ui-library-test 0.0.1
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/README.md +113 -0
- package/dist/theme-chalk/alert/index.scss +152 -0
- package/dist/theme-chalk/avatar/index.scss +51 -0
- package/dist/theme-chalk/backtop/index.scss +38 -0
- package/dist/theme-chalk/badge/index.scss +63 -0
- package/dist/theme-chalk/breadcrumb/index.scss +36 -0
- package/dist/theme-chalk/breadcrumb-item/index.scss +36 -0
- package/dist/theme-chalk/button/index.scss +157 -0
- package/dist/theme-chalk/card/index.scss +38 -0
- package/dist/theme-chalk/chart/index.scss +21 -0
- package/dist/theme-chalk/checkbox/index.scss +358 -0
- package/dist/theme-chalk/col/index.scss +131 -0
- package/dist/theme-chalk/container/index.scss +40 -0
- package/dist/theme-chalk/css/alert.css +484 -0
- package/dist/theme-chalk/css/avatar.css +409 -0
- package/dist/theme-chalk/css/backtop.css +401 -0
- package/dist/theme-chalk/css/badge.css +419 -0
- package/dist/theme-chalk/css/breadcrumb-item.css +395 -0
- package/dist/theme-chalk/css/breadcrumb.css +395 -0
- package/dist/theme-chalk/css/button.css +587 -0
- package/dist/theme-chalk/css/card.css +397 -0
- package/dist/theme-chalk/css/chart.css +386 -0
- package/dist/theme-chalk/css/checkbox.css +648 -0
- package/dist/theme-chalk/css/col.css +2111 -0
- package/dist/theme-chalk/css/container.css +404 -0
- package/dist/theme-chalk/css/dialog.css +505 -0
- package/dist/theme-chalk/css/divider.css +405 -0
- package/dist/theme-chalk/css/drawer.css +546 -0
- package/dist/theme-chalk/css/empty.css +394 -0
- package/dist/theme-chalk/css/form.css +561 -0
- package/dist/theme-chalk/css/icon.css +1534 -0
- package/dist/theme-chalk/css/image.css +400 -0
- package/dist/theme-chalk/css/input-number.css +424 -0
- package/dist/theme-chalk/css/input.css +721 -0
- package/dist/theme-chalk/css/link.css +424 -0
- package/dist/theme-chalk/css/loading.css +483 -0
- package/dist/theme-chalk/css/message-box.css +479 -0
- package/dist/theme-chalk/css/message.css +456 -0
- package/dist/theme-chalk/css/no-data.css +397 -0
- package/dist/theme-chalk/css/notification.css +431 -0
- package/dist/theme-chalk/css/page-header.css +396 -0
- package/dist/theme-chalk/css/pagination.css +565 -0
- package/dist/theme-chalk/css/popover.css +421 -0
- package/dist/theme-chalk/css/popper.css +454 -0
- package/dist/theme-chalk/css/progress.css +451 -0
- package/dist/theme-chalk/css/radio.css +626 -0
- package/dist/theme-chalk/css/rate.css +414 -0
- package/dist/theme-chalk/css/result.css +403 -0
- package/dist/theme-chalk/css/row.css +433 -0
- package/dist/theme-chalk/css/scrollbar.css +422 -0
- package/dist/theme-chalk/css/select.css +1897 -0
- package/dist/theme-chalk/css/skeleton-item.css +407 -0
- package/dist/theme-chalk/css/skeleton.css +390 -0
- package/dist/theme-chalk/css/slider.css +460 -0
- package/dist/theme-chalk/css/spinner.css +403 -0
- package/dist/theme-chalk/css/statistic.css +396 -0
- package/dist/theme-chalk/css/status-timeline-chart.css +388 -0
- package/dist/theme-chalk/css/step.css +496 -0
- package/dist/theme-chalk/css/steps.css +496 -0
- package/dist/theme-chalk/css/switch.css +507 -0
- package/dist/theme-chalk/css/tab-pane.css +457 -0
- package/dist/theme-chalk/css/table.css +461 -0
- package/dist/theme-chalk/css/tabs-navigation.css +925 -0
- package/dist/theme-chalk/css/tabs.css +457 -0
- package/dist/theme-chalk/css/tag.css +599 -0
- package/dist/theme-chalk/css/time-picker.css +683 -0
- package/dist/theme-chalk/css/timeline-item.css +459 -0
- package/dist/theme-chalk/css/timeline.css +459 -0
- package/dist/theme-chalk/css/tooltip.css +485 -0
- package/dist/theme-chalk/css/tree.css +473 -0
- package/dist/theme-chalk/css/upload.css +665 -0
- package/dist/theme-chalk/dialog/index.scss +168 -0
- package/dist/theme-chalk/divider/index.scss +46 -0
- package/dist/theme-chalk/drawer/index.scss +172 -0
- package/dist/theme-chalk/empty/index.scss +36 -0
- package/dist/theme-chalk/fonts/element-icons.ttf +0 -0
- package/dist/theme-chalk/fonts/element-icons.woff +0 -0
- package/dist/theme-chalk/form/index.scss +220 -0
- package/dist/theme-chalk/icon/index.scss +1171 -0
- package/dist/theme-chalk/image/index.scss +39 -0
- package/dist/theme-chalk/index.scss +127 -0
- package/dist/theme-chalk/input/index.scss +363 -0
- package/dist/theme-chalk/input-number/index.scss +71 -0
- package/dist/theme-chalk/link/index.scss +75 -0
- package/dist/theme-chalk/loading/index.scss +131 -0
- package/dist/theme-chalk/message/index.scss +100 -0
- package/dist/theme-chalk/message-box/index.scss +131 -0
- package/dist/theme-chalk/mixins.scss +203 -0
- package/dist/theme-chalk/no-data/index.scss +36 -0
- package/dist/theme-chalk/notification/index.scss +76 -0
- package/dist/theme-chalk/page-header/index.scss +36 -0
- package/dist/theme-chalk/pagination/index.scss +225 -0
- package/dist/theme-chalk/popover/index.scss +56 -0
- package/dist/theme-chalk/popper/index.scss +89 -0
- package/dist/theme-chalk/progress/index.scss +105 -0
- package/dist/theme-chalk/radio/index.scss +328 -0
- package/dist/theme-chalk/rate/index.scss +56 -0
- package/dist/theme-chalk/reset.scss +262 -0
- package/dist/theme-chalk/result/index.scss +46 -0
- package/dist/theme-chalk/row/index.scss +88 -0
- package/dist/theme-chalk/scrollbar/index.scss +67 -0
- package/dist/theme-chalk/select/index.scss +223 -0
- package/dist/theme-chalk/skeleton/index.scss +30 -0
- package/dist/theme-chalk/skeleton-item/index.scss +49 -0
- package/dist/theme-chalk/slider/index.scss +113 -0
- package/dist/theme-chalk/spinner/index.scss +40 -0
- package/dist/theme-chalk/statistic/index.scss +38 -0
- package/dist/theme-chalk/status-timeline-chart/index.scss +23 -0
- package/dist/theme-chalk/step/index.scss +160 -0
- package/dist/theme-chalk/steps/index.scss +160 -0
- package/dist/theme-chalk/switch/index.scss +153 -0
- package/dist/theme-chalk/tab-pane/index.scss +112 -0
- package/dist/theme-chalk/table/index.scss +110 -0
- package/dist/theme-chalk/tabs/index.scss +112 -0
- package/dist/theme-chalk/tabs-navigation/index.scss +631 -0
- package/dist/theme-chalk/tag/index.scss +138 -0
- package/dist/theme-chalk/themes/blue.scss +76 -0
- package/dist/theme-chalk/themes/dark.scss +99 -0
- package/dist/theme-chalk/themes/index.scss +260 -0
- package/dist/theme-chalk/themes/light.scss +99 -0
- package/dist/theme-chalk/time-picker/index.scss +332 -0
- package/dist/theme-chalk/timeline/index.scss +119 -0
- package/dist/theme-chalk/timeline-item/index.scss +119 -0
- package/dist/theme-chalk/tooltip/index.scss +122 -0
- package/dist/theme-chalk/tree/index.scss +125 -0
- package/dist/theme-chalk/upload/index.scss +348 -0
- package/dist/theme-chalk/variables.scss +93 -0
- package/dist/vue2-ui-library.cjs.temp.js.map +1 -0
- package/dist/vue2-ui-library.common.js +28 -0
- package/dist/vue2-ui-library.common.js.map +1 -0
- package/dist/vue2-ui-library.esm.js +29 -0
- package/dist/vue2-ui-library.umd.js +27 -0
- package/package.json +161 -0
- package/src/directives/clickoutside/index.js +111 -0
- package/src/directives/init/index.js +50 -0
- package/src/directives/resize/index.js +69 -0
- package/src/index.js +174 -0
- package/src/mixins/emitter.js +47 -0
- package/src/mixins/focus.js +42 -0
- package/src/mixins/locale.js +24 -0
- package/src/mixins/migrating.js +46 -0
- package/src/packages/alert/index.js +12 -0
- package/src/packages/alert/src/main.vue +98 -0
- package/src/packages/aside/index.js +12 -0
- package/src/packages/aside/src/main.vue +20 -0
- package/src/packages/auto-grid-layout/index.js +18 -0
- package/src/packages/auto-grid-layout/prop.js +92 -0
- package/src/packages/auto-grid-layout/src/components/GridItem.vue +759 -0
- package/src/packages/auto-grid-layout/src/components/GridLayout.vue +367 -0
- package/src/packages/auto-grid-layout/src/main.vue +287 -0
- package/src/packages/auto-grid-layout/src/utils/DOM.js +46 -0
- package/src/packages/auto-grid-layout/src/utils/interact.js +333 -0
- package/src/packages/auto-grid-layout/src/utils/responsiveUtils.js +75 -0
- package/src/packages/auto-grid-layout/src/utils/utils.js +339 -0
- package/src/packages/autocomplete/index.js +12 -0
- package/src/packages/autocomplete/src/main.vue +170 -0
- package/src/packages/avatar/index.js +12 -0
- package/src/packages/avatar/src/main.vue +87 -0
- package/src/packages/backtop/index.js +12 -0
- package/src/packages/backtop/src/main.vue +120 -0
- package/src/packages/badge/index.js +12 -0
- package/src/packages/badge/src/main.vue +53 -0
- package/src/packages/breadcrumb/index.js +12 -0
- package/src/packages/breadcrumb/src/main.vue +34 -0
- package/src/packages/breadcrumb-item/index.js +12 -0
- package/src/packages/breadcrumb-item/src/main.vue +41 -0
- package/src/packages/button/index.js +13 -0
- package/src/packages/button/src/main.vue +106 -0
- package/src/packages/calendar/index.js +12 -0
- package/src/packages/calendar/src/main.vue +173 -0
- package/src/packages/card/index.js +12 -0
- package/src/packages/card/src/main.vue +26 -0
- package/src/packages/carousel/index.js +12 -0
- package/src/packages/carousel/src/main.vue +186 -0
- package/src/packages/carousel-item/index.js +12 -0
- package/src/packages/carousel-item/src/main.vue +34 -0
- package/src/packages/cascader/index.js +12 -0
- package/src/packages/cascader/src/main.vue +232 -0
- package/src/packages/chart/index.js +7 -0
- package/src/packages/chart/src/axis-chart.js +700 -0
- package/src/packages/chart/src/main.vue +828 -0
- package/src/packages/chart/src/utils.js +21 -0
- package/src/packages/checkbox/index.js +44 -0
- package/src/packages/checkbox/src/main.vue +312 -0
- package/src/packages/col/index.js +12 -0
- package/src/packages/col/src/main.vue +85 -0
- package/src/packages/collapse/index.js +12 -0
- package/src/packages/collapse/src/main.vue +69 -0
- package/src/packages/collapse-item/index.js +12 -0
- package/src/packages/collapse-item/src/main.vue +75 -0
- package/src/packages/color-picker/index.js +12 -0
- package/src/packages/color-picker/src/main.vue +206 -0
- package/src/packages/container/index.js +12 -0
- package/src/packages/container/src/main.vue +33 -0
- package/src/packages/date-picker/index.js +12 -0
- package/src/packages/date-picker/src/main.vue +246 -0
- package/src/packages/descriptions/index.js +12 -0
- package/src/packages/descriptions/src/main.vue +89 -0
- package/src/packages/descriptions-item/index.js +12 -0
- package/src/packages/descriptions-item/src/main.vue +26 -0
- package/src/packages/dialog/index.js +12 -0
- package/src/packages/dialog/src/main.vue +336 -0
- package/src/packages/divider/index.js +12 -0
- package/src/packages/divider/src/main.vue +37 -0
- package/src/packages/drawer/index.js +7 -0
- package/src/packages/drawer/src/main.vue +310 -0
- package/src/packages/dropdown/index.js +12 -0
- package/src/packages/dropdown/src/main.vue +82 -0
- package/src/packages/dropdown-menu-item/index.js +12 -0
- package/src/packages/dropdown-menu-item/src/main.vue +29 -0
- package/src/packages/empty/index.js +12 -0
- package/src/packages/empty/src/img-empty.vue +12 -0
- package/src/packages/empty/src/main.vue +49 -0
- package/src/packages/footer/index.js +12 -0
- package/src/packages/footer/src/main.vue +20 -0
- package/src/packages/form/index.js +13 -0
- package/src/packages/form/src/form-field.vue +790 -0
- package/src/packages/form/src/form-item.vue +464 -0
- package/src/packages/form/src/label-wrap.vue +127 -0
- package/src/packages/form/src/main.vue +442 -0
- package/src/packages/form-item/index.js +11 -0
- package/src/packages/header/index.js +12 -0
- package/src/packages/header/src/main.vue +20 -0
- package/src/packages/icon/index.js +12 -0
- package/src/packages/icon/src/main.vue +48 -0
- package/src/packages/image/index.js +12 -0
- package/src/packages/image/src/main.vue +224 -0
- package/src/packages/input/index.js +13 -0
- package/src/packages/input/src/calcTextareaHeight.js +123 -0
- package/src/packages/input/src/main.vue +510 -0
- package/src/packages/input-number/index.js +12 -0
- package/src/packages/input-number/src/main.vue +121 -0
- package/src/packages/link/index.js +12 -0
- package/src/packages/link/src/main.vue +53 -0
- package/src/packages/loading/index.js +17 -0
- package/src/packages/loading/src/directive.js +54 -0
- package/src/packages/loading/src/main.vue +38 -0
- package/src/packages/loading/src/service.js +63 -0
- package/src/packages/main/index.js +12 -0
- package/src/packages/main/src/main.vue +12 -0
- package/src/packages/menu/index.js +12 -0
- package/src/packages/menu/src/main.vue +117 -0
- package/src/packages/menu-item/index.js +12 -0
- package/src/packages/menu-item/src/main.vue +61 -0
- package/src/packages/message/index.js +95 -0
- package/src/packages/message/src/main.vue +131 -0
- package/src/packages/message-box/index.js +75 -0
- package/src/packages/message-box/src/main.vue +207 -0
- package/src/packages/no-data/index.js +8 -0
- package/src/packages/no-data/src/main.vue +23 -0
- package/src/packages/notification/index.js +72 -0
- package/src/packages/notification/src/main.vue +139 -0
- package/src/packages/option/index.js +13 -0
- package/src/packages/page-header/index.js +12 -0
- package/src/packages/page-header/src/main.vue +27 -0
- package/src/packages/pagination/index.js +12 -0
- package/src/packages/pagination/src/main.vue +255 -0
- package/src/packages/popconfirm/index.js +12 -0
- package/src/packages/popconfirm/src/main.vue +89 -0
- package/src/packages/popover/index.js +12 -0
- package/src/packages/popover/src/main.vue +452 -0
- package/src/packages/progress/index.js +12 -0
- package/src/packages/progress/src/main.vue +236 -0
- package/src/packages/radio/index.js +44 -0
- package/src/packages/radio/src/main.vue +291 -0
- package/src/packages/rate/index.js +12 -0
- package/src/packages/rate/src/main.vue +129 -0
- package/src/packages/result/index.js +12 -0
- package/src/packages/result/src/main.vue +52 -0
- package/src/packages/row/index.js +12 -0
- package/src/packages/row/src/main.vue +57 -0
- package/src/packages/scrollbar/index.js +12 -0
- package/src/packages/scrollbar/src/bar.vue +116 -0
- package/src/packages/scrollbar/src/main.vue +124 -0
- package/src/packages/select/index.js +15 -0
- package/src/packages/select/src/clickoutside.js +20 -0
- package/src/packages/select/src/main.vue +1055 -0
- package/src/packages/select/src/navigation-mixin.js +49 -0
- package/src/packages/select/src/option.vue +249 -0
- package/src/packages/select/src/select-dropdown.vue +95 -0
- package/src/packages/select/src/utils.js +5 -0
- package/src/packages/skeleton/index.js +12 -0
- package/src/packages/skeleton/src/main.vue +76 -0
- package/src/packages/skeleton-item/index.js +12 -0
- package/src/packages/skeleton-item/src/img-placeholder.vue +13 -0
- package/src/packages/skeleton-item/src/main.vue +22 -0
- package/src/packages/slider/index.js +12 -0
- package/src/packages/slider/src/main.vue +176 -0
- package/src/packages/spinner/index.js +12 -0
- package/src/packages/spinner/src/main.vue +27 -0
- package/src/packages/statistic/index.js +12 -0
- package/src/packages/statistic/src/main.vue +100 -0
- package/src/packages/status-timeline-chart/index.js +7 -0
- package/src/packages/status-timeline-chart/src/constants.js +20 -0
- package/src/packages/status-timeline-chart/src/main.vue +499 -0
- package/src/packages/status-timeline-chart/src/option-builder.js +475 -0
- package/src/packages/step/index.js +12 -0
- package/src/packages/step/src/main.vue +183 -0
- package/src/packages/steps/index.js +12 -0
- package/src/packages/steps/src/main.vue +57 -0
- package/src/packages/submenu/index.js +12 -0
- package/src/packages/submenu/src/main.vue +68 -0
- package/src/packages/switch/index.js +12 -0
- package/src/packages/switch/src/main.vue +166 -0
- package/src/packages/tab-pane/index.js +12 -0
- package/src/packages/tab-pane/src/main.vue +74 -0
- package/src/packages/table/index.js +8 -0
- package/src/packages/table/src/components/PagePagination.vue +82 -0
- package/src/packages/table/src/main.vue +153 -0
- package/src/packages/tabs/index.js +12 -0
- package/src/packages/tabs/src/main.vue +167 -0
- package/src/packages/tabs-navigation/index.js +7 -0
- package/src/packages/tabs-navigation/src/main.vue +462 -0
- package/src/packages/tag/index.js +12 -0
- package/src/packages/tag/src/main.vue +194 -0
- package/src/packages/time-picker/index.js +17 -0
- package/src/packages/time-picker/src/date-utils.js +455 -0
- package/src/packages/time-picker/src/main.vue +321 -0
- package/src/packages/time-picker/src/pane/date-range.vue +193 -0
- package/src/packages/time-picker/src/pane/date-time-range.vue +362 -0
- package/src/packages/time-picker/src/pane/date-time.vue +362 -0
- package/src/packages/time-picker/src/pane/date.vue +441 -0
- package/src/packages/time-picker/src/pane/time.vue +260 -0
- package/src/packages/time-picker/src/time-input.vue +203 -0
- package/src/packages/time-picker/src/time-range-input.vue +170 -0
- package/src/packages/timeline/index.js +12 -0
- package/src/packages/timeline/src/main.vue +24 -0
- package/src/packages/timeline-item/index.js +12 -0
- package/src/packages/timeline-item/src/main.vue +78 -0
- package/src/packages/tooltip/index.js +12 -0
- package/src/packages/tooltip/src/main.js +367 -0
- package/src/packages/transfer/index.js +8 -0
- package/src/packages/transfer/src/main.vue +229 -0
- package/src/packages/transfer/src/transfer-panel.vue +245 -0
- package/src/packages/transitions/collapse-transition.js +75 -0
- package/src/packages/tree/index.js +12 -0
- package/src/packages/tree/src/main.vue +322 -0
- package/src/packages/tree/src/model/node.js +348 -0
- package/src/packages/tree/src/model/tree-store.js +354 -0
- package/src/packages/tree/src/model/util.js +10 -0
- package/src/packages/tree/src/tree-node.vue +262 -0
- package/src/packages/upload/index.js +9 -0
- package/src/packages/upload/src/main.vue +415 -0
- package/src/playground/mixins/element.js +98 -0
- package/src/playground/types/element.js +197 -0
- package/src/playground/types/layout.js +80 -0
- package/src/plugins/i18n.js +125 -0
- package/src/styles/fonts/element-icons.ttf +0 -0
- package/src/styles/fonts/element-icons.woff +0 -0
- package/src/styles/index.scss +138 -0
- package/src/styles/reset.scss +257 -0
- package/src/styles/themes/blue.scss +75 -0
- package/src/styles/themes/dark.scss +98 -0
- package/src/styles/themes/index.scss +34 -0
- package/src/styles/themes/light.scss +98 -0
- package/src/styles/themes/variables.scss +233 -0
- package/src/styles/variables.scss +146 -0
- package/src/utils/async-validator/index.js +659 -0
- package/src/utils/browser/index.js +39 -0
- package/src/utils/color.js +76 -0
- package/src/utils/dom/index.js +421 -0
- package/src/utils/dom/scrollbar-width.js +49 -0
- package/src/utils/draggable/core.js +379 -0
- package/src/utils/draggable/draggable.js +478 -0
- package/src/utils/draggable/index.js +61 -0
- package/src/utils/draggable/sortable.js +751 -0
- package/src/utils/lodash/index.js +2395 -0
- package/src/utils/moment/index.js +909 -0
- package/src/utils/playground/index.js +37 -0
- package/src/utils/popper/index.js +308 -0
- package/src/utils/popper/popper.js +1132 -0
- package/src/utils/popper/popup-manager.js +288 -0
- package/src/utils/popper/popup.js +344 -0
|
@@ -0,0 +1,1055 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
v-resize="handleResize"
|
|
4
|
+
v-clickoutside="handleClose"
|
|
5
|
+
class="ui-select"
|
|
6
|
+
:class="[selectSize ? 'ui-select--' + selectSize : '', autoSize ? 'is-autosize' : '']"
|
|
7
|
+
:style="autoSizeStyle"
|
|
8
|
+
@click.stop="toggleMenu"
|
|
9
|
+
>
|
|
10
|
+
<div class="ui-select__tags" v-if="multiple" ref="tags" :style="{ 'max-width': inputWidth - 32 + 'px', width: '100%' }">
|
|
11
|
+
<span v-if="collapseTags && selected.length">
|
|
12
|
+
<ui-tag :closable="!selectDisabled" :size="collapseTagSize" :hit="selected[0].hitState" type="info" @close="deleteTag($event, selected[0])" disable-transitions>
|
|
13
|
+
<span class="ui-select__tags-text">{{ selected[0].currentLabel }}</span>
|
|
14
|
+
</ui-tag>
|
|
15
|
+
<ui-tag v-if="selected.length > 1" :closable="false" :size="collapseTagSize" type="info" disable-transitions>
|
|
16
|
+
<span class="ui-select__tags-text multi-count">+ {{ selected.length - 1 }}</span>
|
|
17
|
+
</ui-tag>
|
|
18
|
+
</span>
|
|
19
|
+
<transition-group @after-leave="resetInputHeight" v-if="!collapseTags">
|
|
20
|
+
<ui-tag v-for="item in selected" :key="getValueKey(item)" :closable="!selectDisabled" :size="collapseTagSize" :hit="item.hitState" type="info" @close="deleteTag($event, item)" disable-transitions>
|
|
21
|
+
<span class="ui-select__tags-text">{{ item.currentLabel }}</span>
|
|
22
|
+
</ui-tag>
|
|
23
|
+
</transition-group>
|
|
24
|
+
<input
|
|
25
|
+
v-if="filterable"
|
|
26
|
+
ref="input"
|
|
27
|
+
type="text"
|
|
28
|
+
class="ui-select__input"
|
|
29
|
+
:class="[selectSize ? `is-${selectSize}` : '']"
|
|
30
|
+
:style="{ 'flex-grow': '1', width: inputLength / (inputWidth - 32) + '%', 'max-width': inputWidth - 42 + 'px' }"
|
|
31
|
+
v-model="query"
|
|
32
|
+
:disabled="selectDisabled"
|
|
33
|
+
:autocomplete="autocomplete"
|
|
34
|
+
@focus="handleFocus"
|
|
35
|
+
@blur="softFocus = false"
|
|
36
|
+
@keyup="managePlaceholder"
|
|
37
|
+
@keydown="resetInputState"
|
|
38
|
+
@keydown.down.prevent="handleNavigate('next')"
|
|
39
|
+
@keydown.up.prevent="handleNavigate('prev')"
|
|
40
|
+
@keydown.enter.prevent="selectOption"
|
|
41
|
+
@keydown.esc.stop.prevent="visible = false"
|
|
42
|
+
@keydown.delete="deletePrevTag"
|
|
43
|
+
@keydown.tab="visible = false"
|
|
44
|
+
@compositionstart="handleComposition"
|
|
45
|
+
@compositionupdate="handleComposition"
|
|
46
|
+
@compositionend="handleComposition"
|
|
47
|
+
@input="debouncedQueryChange"
|
|
48
|
+
/>
|
|
49
|
+
</div>
|
|
50
|
+
<ui-input
|
|
51
|
+
ref="reference"
|
|
52
|
+
v-model="selectedLabel"
|
|
53
|
+
type="text"
|
|
54
|
+
:placeholder="currentPlaceholder"
|
|
55
|
+
:name="name"
|
|
56
|
+
:id="id"
|
|
57
|
+
:autocomplete="autocomplete"
|
|
58
|
+
:size="selectSize"
|
|
59
|
+
:disabled="selectDisabled"
|
|
60
|
+
:readonly="readonly"
|
|
61
|
+
:validate-event="false"
|
|
62
|
+
:class="{ 'is-focus': visible }"
|
|
63
|
+
:tabindex="multiple && filterable ? '-1' : null"
|
|
64
|
+
@focus="handleFocus"
|
|
65
|
+
@blur="handleBlur"
|
|
66
|
+
@input="debouncedOnInputChange"
|
|
67
|
+
@keydown.native.down.stop.prevent="handleNavigate('next')"
|
|
68
|
+
@keydown.native.up.stop.prevent="handleNavigate('prev')"
|
|
69
|
+
@keydown.native.enter.prevent="selectOption"
|
|
70
|
+
@keydown.native.esc.stop.prevent="visible = false"
|
|
71
|
+
@keydown.native.tab="visible = false"
|
|
72
|
+
@compositionstart="handleComposition"
|
|
73
|
+
@compositionupdate="handleComposition"
|
|
74
|
+
@compositionend="handleComposition"
|
|
75
|
+
@mouseenter.native="inputHovering = true"
|
|
76
|
+
@mouseleave.native="inputHovering = false"
|
|
77
|
+
>
|
|
78
|
+
<template v-if="$slots.prefix || $scopedSlots.prefix" slot="prefix"><slot name="prefix"></slot></template>
|
|
79
|
+
<template slot="suffix">
|
|
80
|
+
<i v-show="!showClose" :class="['ui-select__caret', 'ui-input__icon', 'ui-icon-' + iconClass]" />
|
|
81
|
+
<i v-if="showClose" class="ui-select__caret ui-input__icon ui-icon-circle-close" @click="handleClearClick" />
|
|
82
|
+
</template>
|
|
83
|
+
</ui-input>
|
|
84
|
+
<transition name="ui-zoom-in-top" @before-enter="handleMenuEnter" @after-leave="doDestroy">
|
|
85
|
+
<ui-select-menu v-show="visible && emptyText !== false" ref="popper" :append-to-body="popperAppendToBody">
|
|
86
|
+
<div class="ui-scrollbar">
|
|
87
|
+
<div class="ui-select-dropdown__wrap ui-scrollbar__wrap ui-scrollbar__wrap--hidden-default">
|
|
88
|
+
<ul v-show="options.length > 0 && !loading" ref="scrollbar" :class="{ 'ui-select-dropdown__list': true, 'is-empty': !allowCreate && query && filteredOptionsCount === 0 }">
|
|
89
|
+
<ui-option :value="query" created v-if="showNewOption" />
|
|
90
|
+
<slot></slot>
|
|
91
|
+
</ul>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
<template v-if="emptyText && (!allowCreate || loading || (allowCreate && options.length === 0))">
|
|
95
|
+
<slot v-if="$slots.empty || $scopedSlots.empty" name="empty"></slot>
|
|
96
|
+
<p v-else class="ui-select-dropdown__empty">
|
|
97
|
+
{{ emptyText }}
|
|
98
|
+
</p>
|
|
99
|
+
</template>
|
|
100
|
+
</ui-select-menu>
|
|
101
|
+
</transition>
|
|
102
|
+
</div>
|
|
103
|
+
</template>
|
|
104
|
+
|
|
105
|
+
<script>
|
|
106
|
+
import UiInput from '../../input'
|
|
107
|
+
import UiTag from '../../tag'
|
|
108
|
+
import UiSelectMenu from './select-dropdown.vue'
|
|
109
|
+
import UiOption from './option.vue'
|
|
110
|
+
|
|
111
|
+
import emitter from '../../../mixins/emitter.js'
|
|
112
|
+
import focus from '../../../mixins/focus.js'
|
|
113
|
+
import locale from '../../../mixins/locale.js'
|
|
114
|
+
import navigationMixin from './navigation-mixin'
|
|
115
|
+
import clickoutside from '../../../directives/clickoutside'
|
|
116
|
+
import resize from '../../../directives/resize'
|
|
117
|
+
import { debounce, get, isEqual, isKorean } from '../../../utils/lodash'
|
|
118
|
+
import { scrollIntoView, getStyle, getTextWidth } from '../../../utils/dom'
|
|
119
|
+
import { isIE, isEdge } from '../../../utils/browser'
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* UiSelect 选择器组件
|
|
123
|
+
* 当选项过多时,使用下拉菜单展示并选择内容。
|
|
124
|
+
* @component UiSelect
|
|
125
|
+
*/
|
|
126
|
+
export default {
|
|
127
|
+
name: 'UiSelect',
|
|
128
|
+
components: { UiInput, UiSelectMenu, UiOption, UiTag },
|
|
129
|
+
mixins: [emitter, locale, focus('reference'), navigationMixin],
|
|
130
|
+
directives: { clickoutside, resize },
|
|
131
|
+
inject: {
|
|
132
|
+
uiForm: { default: '' },
|
|
133
|
+
uiFormItem: { default: '' },
|
|
134
|
+
},
|
|
135
|
+
props: {
|
|
136
|
+
/**
|
|
137
|
+
* native input 原生属性 name
|
|
138
|
+
* @type {String}
|
|
139
|
+
*/
|
|
140
|
+
name: String,
|
|
141
|
+
/**
|
|
142
|
+
* native input 原生属性 id
|
|
143
|
+
* @type {String}
|
|
144
|
+
*/
|
|
145
|
+
id: String,
|
|
146
|
+
/**
|
|
147
|
+
* 绑定值
|
|
148
|
+
* @type {string|number|boolean|object|array}
|
|
149
|
+
* @required
|
|
150
|
+
*/
|
|
151
|
+
value: { required: true },
|
|
152
|
+
/**
|
|
153
|
+
* 原生属性 autocomplete
|
|
154
|
+
* @type {String}
|
|
155
|
+
* @default 'off'
|
|
156
|
+
*/
|
|
157
|
+
autocomplete: { type: String, default: 'off' },
|
|
158
|
+
/**
|
|
159
|
+
* 是否自动弹出下拉框
|
|
160
|
+
* @type {Boolean}
|
|
161
|
+
*/
|
|
162
|
+
automaticDropdown: Boolean,
|
|
163
|
+
/**
|
|
164
|
+
* 选择器尺寸
|
|
165
|
+
* @type {String}
|
|
166
|
+
* @values 'medium'|'small'|'mini'
|
|
167
|
+
*/
|
|
168
|
+
size: String,
|
|
169
|
+
/**
|
|
170
|
+
* 是否自适应大小
|
|
171
|
+
* @type {Boolean}
|
|
172
|
+
*/
|
|
173
|
+
autoSize: Boolean,
|
|
174
|
+
/**
|
|
175
|
+
* 是否禁用
|
|
176
|
+
* @type {Boolean}
|
|
177
|
+
*/
|
|
178
|
+
disabled: Boolean,
|
|
179
|
+
/**
|
|
180
|
+
* 是否可以清空选项
|
|
181
|
+
* @type {Boolean}
|
|
182
|
+
*/
|
|
183
|
+
clearable: Boolean,
|
|
184
|
+
/**
|
|
185
|
+
* 是否可搜索
|
|
186
|
+
* @type {Boolean}
|
|
187
|
+
*/
|
|
188
|
+
filterable: Boolean,
|
|
189
|
+
/**
|
|
190
|
+
* 是否允许用户创建新条目,需配合 filterable 使用
|
|
191
|
+
* @type {Boolean}
|
|
192
|
+
*/
|
|
193
|
+
allowCreate: Boolean,
|
|
194
|
+
/**
|
|
195
|
+
* 是否正在从远程获取数据
|
|
196
|
+
* @type {Boolean}
|
|
197
|
+
*/
|
|
198
|
+
loading: Boolean,
|
|
199
|
+
/**
|
|
200
|
+
* Select 下拉框的类名
|
|
201
|
+
* @type {String}
|
|
202
|
+
*/
|
|
203
|
+
popperClass: String,
|
|
204
|
+
/**
|
|
205
|
+
* 是否为远程搜索
|
|
206
|
+
* @type {Boolean}
|
|
207
|
+
*/
|
|
208
|
+
remote: Boolean,
|
|
209
|
+
/**
|
|
210
|
+
* 远程加载时显示的文字
|
|
211
|
+
* @type {String}
|
|
212
|
+
*/
|
|
213
|
+
loadingText: String,
|
|
214
|
+
/**
|
|
215
|
+
* 搜索条件无匹配时显示的文字
|
|
216
|
+
* @type {String}
|
|
217
|
+
*/
|
|
218
|
+
noMatchText: String,
|
|
219
|
+
/**
|
|
220
|
+
* 选项为空时显示的文字
|
|
221
|
+
* @type {String}
|
|
222
|
+
*/
|
|
223
|
+
noDataText: String,
|
|
224
|
+
/**
|
|
225
|
+
* 远程搜索方法
|
|
226
|
+
* @type {Function}
|
|
227
|
+
*/
|
|
228
|
+
remoteMethod: Function,
|
|
229
|
+
/**
|
|
230
|
+
* 自定义搜索方法
|
|
231
|
+
* @type {Function}
|
|
232
|
+
*/
|
|
233
|
+
filterMethod: Function,
|
|
234
|
+
/**
|
|
235
|
+
* 是否多选
|
|
236
|
+
* @type {Boolean}
|
|
237
|
+
*/
|
|
238
|
+
multiple: Boolean,
|
|
239
|
+
/**
|
|
240
|
+
* 多选时用户最多可以选择的项目数,为 0 则不限制
|
|
241
|
+
* @type {Number}
|
|
242
|
+
* @default 0
|
|
243
|
+
*/
|
|
244
|
+
multipleLimit: { type: Number, default: 0 },
|
|
245
|
+
/**
|
|
246
|
+
* 占位符
|
|
247
|
+
* @type {String}
|
|
248
|
+
*/
|
|
249
|
+
placeholder: { type: String, required: false },
|
|
250
|
+
/**
|
|
251
|
+
* 是否默认选中第一个选项
|
|
252
|
+
* @type {Boolean}
|
|
253
|
+
*/
|
|
254
|
+
defaultFirstOption: Boolean,
|
|
255
|
+
/**
|
|
256
|
+
* 多选且可搜索时,是否在选中一个选项后保留当前的搜索关键词
|
|
257
|
+
* @type {Boolean}
|
|
258
|
+
*/
|
|
259
|
+
reserveKeyword: Boolean,
|
|
260
|
+
/**
|
|
261
|
+
* 当选项对象的 value 属性为非基础类型时,必选。它接受一个字符串,代表 value 的 key
|
|
262
|
+
* @type {String}
|
|
263
|
+
* @default 'value'
|
|
264
|
+
*/
|
|
265
|
+
valueKey: { type: String, default: 'value' },
|
|
266
|
+
/**
|
|
267
|
+
* 多选时折叠 Tags
|
|
268
|
+
* @type {Boolean}
|
|
269
|
+
*/
|
|
270
|
+
collapseTags: Boolean,
|
|
271
|
+
/**
|
|
272
|
+
* 下拉框是否插入到 body 元素下
|
|
273
|
+
* @type {Boolean}
|
|
274
|
+
* @default true
|
|
275
|
+
*/
|
|
276
|
+
popperAppendToBody: { type: Boolean, default: true },
|
|
277
|
+
},
|
|
278
|
+
data: vm => ({
|
|
279
|
+
/**
|
|
280
|
+
* 选项列表数据
|
|
281
|
+
* @type {Array}
|
|
282
|
+
*/
|
|
283
|
+
options: [],
|
|
284
|
+
/**
|
|
285
|
+
* 缓存的选项列表
|
|
286
|
+
* @type {Array}
|
|
287
|
+
*/
|
|
288
|
+
cachedOptions: [],
|
|
289
|
+
createdLabel: null,
|
|
290
|
+
createdSelected: false,
|
|
291
|
+
/**
|
|
292
|
+
* 当前选中项
|
|
293
|
+
* @type {Object|Array}
|
|
294
|
+
*/
|
|
295
|
+
selected: vm.multiple ? [] : {},
|
|
296
|
+
inputLength: 20,
|
|
297
|
+
inputWidth: 0,
|
|
298
|
+
initialInputHeight: 0,
|
|
299
|
+
cachedPlaceHolder: '',
|
|
300
|
+
optionsCount: 0,
|
|
301
|
+
filteredOptionsCount: 0,
|
|
302
|
+
/**
|
|
303
|
+
* 下拉框是否可见
|
|
304
|
+
* @type {Boolean}
|
|
305
|
+
*/
|
|
306
|
+
visible: false,
|
|
307
|
+
softFocus: false,
|
|
308
|
+
selectedLabel: '',
|
|
309
|
+
hoverIndex: -1,
|
|
310
|
+
selectedLabelWidth: null,
|
|
311
|
+
/**
|
|
312
|
+
* 搜索关键词
|
|
313
|
+
* @type {String}
|
|
314
|
+
*/
|
|
315
|
+
query: '',
|
|
316
|
+
previousQuery: null,
|
|
317
|
+
inputHovering: false,
|
|
318
|
+
currentPlaceholder: '',
|
|
319
|
+
menuVisibleOnFocus: false,
|
|
320
|
+
isOnComposition: false,
|
|
321
|
+
isSilentBlur: false,
|
|
322
|
+
}),
|
|
323
|
+
provide() {
|
|
324
|
+
return {
|
|
325
|
+
select: this,
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
computed: {
|
|
329
|
+
_uiFormItemSize() {
|
|
330
|
+
return (this.uiFormItem || {}).uiFormItemSize
|
|
331
|
+
},
|
|
332
|
+
/**
|
|
333
|
+
* 输入框是否只读
|
|
334
|
+
* @returns {Boolean}
|
|
335
|
+
*/
|
|
336
|
+
readonly() {
|
|
337
|
+
return !this.filterable || this.multiple || (!isIE() && !isEdge() && !this.visible)
|
|
338
|
+
},
|
|
339
|
+
/**
|
|
340
|
+
* 是否显示关闭按钮
|
|
341
|
+
* @returns {Boolean}
|
|
342
|
+
*/
|
|
343
|
+
showClose() {
|
|
344
|
+
let hasValue = this.multiple ? Array.isArray(this.value) && this.value.length > 0 : this.value !== undefined && this.value !== null && this.value !== ''
|
|
345
|
+
let criteria = this.clearable && !this.selectDisabled && this.inputHovering && hasValue
|
|
346
|
+
return criteria
|
|
347
|
+
},
|
|
348
|
+
/**
|
|
349
|
+
* 图标类名
|
|
350
|
+
* @returns {String}
|
|
351
|
+
*/
|
|
352
|
+
iconClass() {
|
|
353
|
+
return this.remote && this.filterable ? '' : this.visible ? 'arrow-up is-reverse' : 'arrow-up'
|
|
354
|
+
},
|
|
355
|
+
/**
|
|
356
|
+
* 防抖延迟时间
|
|
357
|
+
* @returns {Number}
|
|
358
|
+
*/
|
|
359
|
+
debounce() {
|
|
360
|
+
return this.remote ? 300 : 0
|
|
361
|
+
},
|
|
362
|
+
/**
|
|
363
|
+
* 空状态显示文本
|
|
364
|
+
* @returns {String|Boolean|null}
|
|
365
|
+
*/
|
|
366
|
+
emptyText() {
|
|
367
|
+
if (this.loading) {
|
|
368
|
+
return this.loadingText || this.t('components.select.loadingText')
|
|
369
|
+
} else {
|
|
370
|
+
if (this.remote && this.query === '' && this.options.length === 0) return false
|
|
371
|
+
if (this.filterable && this.query && this.options.length > 0 && this.filteredOptionsCount === 0) {
|
|
372
|
+
return this.noMatchText || this.t('components.select.noMatchText')
|
|
373
|
+
}
|
|
374
|
+
if (this.options.length === 0) {
|
|
375
|
+
return this.noDataText || this.t('components.select.noDataText')
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
return null
|
|
379
|
+
},
|
|
380
|
+
/**
|
|
381
|
+
* 是否显示新建选项
|
|
382
|
+
* @returns {Boolean}
|
|
383
|
+
*/
|
|
384
|
+
showNewOption() {
|
|
385
|
+
let hasExistingOption = this.options.filter((option) => !option.created).some((option) => option.currentLabel === this.query)
|
|
386
|
+
return this.filterable && this.allowCreate && this.query !== '' && !hasExistingOption
|
|
387
|
+
},
|
|
388
|
+
/**
|
|
389
|
+
* 选择器尺寸
|
|
390
|
+
* @returns {String}
|
|
391
|
+
*/
|
|
392
|
+
selectSize() {
|
|
393
|
+
return this.size || this._uiFormItemSize || (this.$ELEMENT || {}).size
|
|
394
|
+
},
|
|
395
|
+
autoSizeStyle() {
|
|
396
|
+
return {
|
|
397
|
+
width: this.autoSize && this.selectedLabelWidth ? `${this.selectedLabelWidth + 40}px` : undefined
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
/**
|
|
401
|
+
* 选择器是否禁用
|
|
402
|
+
* @returns {Boolean}
|
|
403
|
+
*/
|
|
404
|
+
selectDisabled() {
|
|
405
|
+
return this.disabled || (this.uiForm || {}).disabled
|
|
406
|
+
},
|
|
407
|
+
/**
|
|
408
|
+
* 折叠标签的尺寸
|
|
409
|
+
* @returns {String}
|
|
410
|
+
*/
|
|
411
|
+
collapseTagSize() {
|
|
412
|
+
return ['small', 'mini'].indexOf(this.selectSize) > -1 ? 'mini' : 'small'
|
|
413
|
+
},
|
|
414
|
+
propPlaceholder() {
|
|
415
|
+
return this.placeholder || ''
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
watch: {
|
|
419
|
+
selectDisabled() {
|
|
420
|
+
this.$nextTick(() => {
|
|
421
|
+
this.resetInputHeight()
|
|
422
|
+
})
|
|
423
|
+
},
|
|
424
|
+
propPlaceholder(val) {
|
|
425
|
+
this.cachedPlaceHolder = this.currentPlaceholder = val
|
|
426
|
+
},
|
|
427
|
+
value(val, oldVal) {
|
|
428
|
+
if (this.multiple) {
|
|
429
|
+
this.resetInputHeight()
|
|
430
|
+
if ((val && val.length > 0) || (this.$refs.input && this.query !== '')) {
|
|
431
|
+
this.currentPlaceholder = ''
|
|
432
|
+
} else {
|
|
433
|
+
this.currentPlaceholder = this.cachedPlaceHolder
|
|
434
|
+
}
|
|
435
|
+
if (this.filterable && !this.reserveKeyword) {
|
|
436
|
+
this.query = ''
|
|
437
|
+
this.handleQueryChange(this.query)
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
this.setSelected()
|
|
441
|
+
if (this.filterable && !this.multiple) {
|
|
442
|
+
this.inputLength = 20
|
|
443
|
+
}
|
|
444
|
+
if (!isEqual(val, oldVal)) {
|
|
445
|
+
this.dispatch('UiFormItem', 'ui.form.change', val)
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
|
|
449
|
+
visible(val) {
|
|
450
|
+
if (!val) {
|
|
451
|
+
this.broadcast('UiSelectDropdown', 'destroyPopper')
|
|
452
|
+
if (this.$refs.input) {
|
|
453
|
+
this.$refs.input.blur()
|
|
454
|
+
}
|
|
455
|
+
this.query = ''
|
|
456
|
+
this.previousQuery = null
|
|
457
|
+
this.selectedLabel = ''
|
|
458
|
+
this.inputLength = 20
|
|
459
|
+
this.menuVisibleOnFocus = false
|
|
460
|
+
this.resetHoverIndex()
|
|
461
|
+
this.$nextTick(() => {
|
|
462
|
+
if (this.$refs.input && this.$refs.input.value === '' && this.selected.length === 0) {
|
|
463
|
+
this.currentPlaceholder = this.cachedPlaceHolder
|
|
464
|
+
}
|
|
465
|
+
})
|
|
466
|
+
if (!this.multiple) {
|
|
467
|
+
if (this.selected) {
|
|
468
|
+
if (this.filterable && this.allowCreate && this.createdSelected && this.createdLabel) {
|
|
469
|
+
this.selectedLabel = this.createdLabel
|
|
470
|
+
} else {
|
|
471
|
+
this.selectedLabel = this.selected.currentLabel
|
|
472
|
+
}
|
|
473
|
+
if (this.filterable) this.query = this.selectedLabel
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
if (this.filterable) {
|
|
477
|
+
this.currentPlaceholder = this.cachedPlaceHolder
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
} else {
|
|
481
|
+
this.broadcast('UiSelectDropdown', 'updatePopper')
|
|
482
|
+
if (this.filterable) {
|
|
483
|
+
this.query = this.remote ? '' : this.selectedLabel
|
|
484
|
+
this.handleQueryChange(this.query)
|
|
485
|
+
if (this.multiple) {
|
|
486
|
+
this.$refs.input.focus()
|
|
487
|
+
} else {
|
|
488
|
+
if (!this.remote) {
|
|
489
|
+
this.broadcast('UiOption', 'queryChange', '')
|
|
490
|
+
this.broadcast('UiOptionGroup', 'queryChange')
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
if (this.selectedLabel) {
|
|
494
|
+
this.currentPlaceholder = this.selectedLabel
|
|
495
|
+
this.selectedLabel = ''
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
this.$emit('visible-change', val)
|
|
501
|
+
},
|
|
502
|
+
|
|
503
|
+
selectedLabel() {
|
|
504
|
+
this.debounceLabelWidth && this.debounceLabelWidth()
|
|
505
|
+
},
|
|
506
|
+
options() {
|
|
507
|
+
if (this.$isServer) return
|
|
508
|
+
this.$nextTick(() => {
|
|
509
|
+
this.broadcast('UiSelectDropdown', 'updatePopper')
|
|
510
|
+
})
|
|
511
|
+
if (this.multiple) {
|
|
512
|
+
this.resetInputHeight()
|
|
513
|
+
}
|
|
514
|
+
let inputs = this.$el.querySelectorAll('input')
|
|
515
|
+
if ([].indexOf.call(inputs, document.activeElement) === -1) {
|
|
516
|
+
this.setSelected()
|
|
517
|
+
}
|
|
518
|
+
if (this.defaultFirstOption && (this.filterable || this.remote) && this.filteredOptionsCount) {
|
|
519
|
+
this.checkDefaultFirstOption()
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
created() {
|
|
524
|
+
this.cachedPlaceHolder = this.currentPlaceholder = this.propPlaceholder
|
|
525
|
+
if (this.multiple && !Array.isArray(this.value)) {
|
|
526
|
+
this.$emit('input', [])
|
|
527
|
+
}
|
|
528
|
+
if (!this.multiple && Array.isArray(this.value)) {
|
|
529
|
+
this.$emit('input', '')
|
|
530
|
+
}
|
|
531
|
+
this.debouncedOnInputChange = debounce(() => {
|
|
532
|
+
this.onInputChange()
|
|
533
|
+
}, this.debounce)
|
|
534
|
+
this.debouncedQueryChange = debounce((e) => {
|
|
535
|
+
this.handleQueryChange(e.target.value)
|
|
536
|
+
}, this.debounce)
|
|
537
|
+
if (this.autoSize) {
|
|
538
|
+
this.debounceLabelWidth = () => this.$nextTick(this.handleLabelChange)
|
|
539
|
+
}
|
|
540
|
+
this.$on('handleOptionClick', this.handleOptionSelect)
|
|
541
|
+
this.$on('setSelected', this.setSelected)
|
|
542
|
+
},
|
|
543
|
+
mounted() {
|
|
544
|
+
if (this.multiple && Array.isArray(this.value) && this.value.length > 0) {
|
|
545
|
+
this.currentPlaceholder = ''
|
|
546
|
+
}
|
|
547
|
+
const reference = this.$refs.reference
|
|
548
|
+
if (reference && reference.$el) {
|
|
549
|
+
const sizeMap = {
|
|
550
|
+
medium: 36,
|
|
551
|
+
small: 32,
|
|
552
|
+
mini: 28,
|
|
553
|
+
}
|
|
554
|
+
const input = reference.$el.querySelector('input')
|
|
555
|
+
this.initialInputHeight = input.getBoundingClientRect().height || sizeMap[this.selectSize]
|
|
556
|
+
}
|
|
557
|
+
if (this.remote && this.multiple) {
|
|
558
|
+
this.resetInputHeight()
|
|
559
|
+
}
|
|
560
|
+
this.$nextTick(() => {
|
|
561
|
+
if (reference && reference.$el) {
|
|
562
|
+
this.inputWidth = reference.$el.getBoundingClientRect().width
|
|
563
|
+
}
|
|
564
|
+
})
|
|
565
|
+
this.setSelected()
|
|
566
|
+
},
|
|
567
|
+
methods: {
|
|
568
|
+
/**
|
|
569
|
+
* 处理键盘上下导航
|
|
570
|
+
* @param {String} direction - 'next' 或 'prev'
|
|
571
|
+
*/
|
|
572
|
+
handleNavigate(direction) {
|
|
573
|
+
if (this.isOnComposition) return
|
|
574
|
+
this.navigateOptions(direction)
|
|
575
|
+
},
|
|
576
|
+
/**
|
|
577
|
+
* 处理输入法组合事件
|
|
578
|
+
* @param {Event} event
|
|
579
|
+
*/
|
|
580
|
+
handleComposition(event) {
|
|
581
|
+
const text = event.target.value
|
|
582
|
+
if (event.type === 'compositionend') {
|
|
583
|
+
this.isOnComposition = false
|
|
584
|
+
this.$nextTick(() => this.handleQueryChange(text))
|
|
585
|
+
} else {
|
|
586
|
+
const lastCharacter = text[text.length - 1] || ''
|
|
587
|
+
this.isOnComposition = !isKorean(lastCharacter)
|
|
588
|
+
}
|
|
589
|
+
},
|
|
590
|
+
/**
|
|
591
|
+
* 处理查询变化
|
|
592
|
+
* @param {String} val - 查询字符串
|
|
593
|
+
*/
|
|
594
|
+
handleQueryChange(val) {
|
|
595
|
+
if (this.previousQuery === val || this.isOnComposition) return
|
|
596
|
+
if (this.previousQuery === null && (typeof this.filterMethod === 'function' || typeof this.remoteMethod === 'function')) {
|
|
597
|
+
this.previousQuery = val
|
|
598
|
+
return
|
|
599
|
+
}
|
|
600
|
+
this.previousQuery = val
|
|
601
|
+
this.$nextTick(() => {
|
|
602
|
+
if (this.visible) this.broadcast('UiSelectDropdown', 'updatePopper')
|
|
603
|
+
})
|
|
604
|
+
this.hoverIndex = -1
|
|
605
|
+
if (this.multiple && this.filterable) {
|
|
606
|
+
this.$nextTick(() => {
|
|
607
|
+
const length = this.$refs.input.value.length * 15 + 20
|
|
608
|
+
this.inputLength = this.collapseTags ? Math.min(50, length) : length
|
|
609
|
+
this.managePlaceholder()
|
|
610
|
+
this.resetInputHeight()
|
|
611
|
+
})
|
|
612
|
+
}
|
|
613
|
+
if (this.remote && typeof this.remoteMethod === 'function') {
|
|
614
|
+
this.hoverIndex = -1
|
|
615
|
+
this.remoteMethod(val)
|
|
616
|
+
} else if (typeof this.filterMethod === 'function') {
|
|
617
|
+
this.filterMethod(val)
|
|
618
|
+
this.broadcast('UiOptionGroup', 'queryChange')
|
|
619
|
+
} else {
|
|
620
|
+
this.filteredOptionsCount = this.optionsCount
|
|
621
|
+
this.broadcast('UiOption', 'queryChange', val)
|
|
622
|
+
this.broadcast('UiOptionGroup', 'queryChange')
|
|
623
|
+
}
|
|
624
|
+
if (this.defaultFirstOption && (this.filterable || this.remote) && this.filteredOptionsCount) {
|
|
625
|
+
this.checkDefaultFirstOption()
|
|
626
|
+
}
|
|
627
|
+
},
|
|
628
|
+
handleLabelChange() {
|
|
629
|
+
const font = getStyle(this.$refs.reference.$el, 'font')
|
|
630
|
+
this.selectedLabelWidth = getTextWidth(this.selectedLabel, font)
|
|
631
|
+
},
|
|
632
|
+
/**
|
|
633
|
+
* 滚动到指定选项
|
|
634
|
+
* @param {Object|Array} option - 选项对象或数组
|
|
635
|
+
*/
|
|
636
|
+
scrollToOption(option) {
|
|
637
|
+
const target = Array.isArray(option) && option[0] ? option[0].$el : option.$el
|
|
638
|
+
if (this.$refs.popper && target) {
|
|
639
|
+
const menu = this.$refs.popper.$el.querySelector('.ui-select-dropdown__wrap')
|
|
640
|
+
scrollIntoView(menu, target)
|
|
641
|
+
}
|
|
642
|
+
},
|
|
643
|
+
/**
|
|
644
|
+
* 下拉菜单出现时的回调
|
|
645
|
+
*/
|
|
646
|
+
handleMenuEnter() {
|
|
647
|
+
this.$nextTick(() => this.scrollToOption(this.selected))
|
|
648
|
+
},
|
|
649
|
+
/**
|
|
650
|
+
* 触发 change 事件
|
|
651
|
+
* @param {*} val
|
|
652
|
+
*/
|
|
653
|
+
emitChange(val) {
|
|
654
|
+
if (!isEqual(this.value, val)) {
|
|
655
|
+
this.$emit('change', val)
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
/**
|
|
659
|
+
* 根据 value 获取选项对象
|
|
660
|
+
* @param {*} value - 选项的值
|
|
661
|
+
* @returns {Object} 选项对象
|
|
662
|
+
*/
|
|
663
|
+
getOption(value) {
|
|
664
|
+
let option
|
|
665
|
+
const isObject = Object.prototype.toString.call(value).toLowerCase() === '[object object]'
|
|
666
|
+
const isNull = Object.prototype.toString.call(value).toLowerCase() === '[object null]'
|
|
667
|
+
const isUndefined = Object.prototype.toString.call(value).toLowerCase() === '[object undefined]'
|
|
668
|
+
|
|
669
|
+
for (let i = this.cachedOptions.length - 1; i >= 0; i--) {
|
|
670
|
+
const cachedOption = this.cachedOptions[i]
|
|
671
|
+
const isEqual = isObject ? get(cachedOption.value, this.valueKey) === get(value, this.valueKey) : cachedOption.value === value
|
|
672
|
+
if (isEqual) {
|
|
673
|
+
option = cachedOption
|
|
674
|
+
break
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
if (option) return option
|
|
678
|
+
const label = !isObject && !isNull && !isUndefined ? String(value) : ''
|
|
679
|
+
let newOption = {
|
|
680
|
+
value: value,
|
|
681
|
+
currentLabel: label,
|
|
682
|
+
}
|
|
683
|
+
if (this.multiple) {
|
|
684
|
+
newOption.hitState = false
|
|
685
|
+
}
|
|
686
|
+
return newOption
|
|
687
|
+
},
|
|
688
|
+
/**
|
|
689
|
+
* 设置选中状态
|
|
690
|
+
*/
|
|
691
|
+
setSelected() {
|
|
692
|
+
if (!this.multiple) {
|
|
693
|
+
let option = this.getOption(this.value)
|
|
694
|
+
if (option.created) {
|
|
695
|
+
this.createdLabel = option.currentLabel
|
|
696
|
+
this.createdSelected = true
|
|
697
|
+
} else {
|
|
698
|
+
this.createdSelected = false
|
|
699
|
+
}
|
|
700
|
+
this.selectedLabel = option.currentLabel
|
|
701
|
+
this.selected = option
|
|
702
|
+
if (this.filterable) this.query = this.selectedLabel
|
|
703
|
+
return
|
|
704
|
+
}
|
|
705
|
+
let result = []
|
|
706
|
+
if (Array.isArray(this.value)) {
|
|
707
|
+
this.value.forEach((value) => {
|
|
708
|
+
result.push(this.getOption(value))
|
|
709
|
+
})
|
|
710
|
+
}
|
|
711
|
+
this.selected = result
|
|
712
|
+
this.$nextTick(() => {
|
|
713
|
+
this.resetInputHeight()
|
|
714
|
+
})
|
|
715
|
+
},
|
|
716
|
+
/**
|
|
717
|
+
* 处理焦点事件
|
|
718
|
+
* @param {Event} event
|
|
719
|
+
*/
|
|
720
|
+
handleFocus(event) {
|
|
721
|
+
if (!this.softFocus) {
|
|
722
|
+
if (this.automaticDropdown || this.filterable) {
|
|
723
|
+
if (this.filterable && !this.visible) {
|
|
724
|
+
this.menuVisibleOnFocus = true
|
|
725
|
+
}
|
|
726
|
+
this.visible = true
|
|
727
|
+
}
|
|
728
|
+
this.$emit('focus', event)
|
|
729
|
+
} else {
|
|
730
|
+
this.softFocus = false
|
|
731
|
+
}
|
|
732
|
+
},
|
|
733
|
+
/**
|
|
734
|
+
* 手动触发 blur
|
|
735
|
+
*/
|
|
736
|
+
blur() {
|
|
737
|
+
this.visible = false
|
|
738
|
+
this.$refs.reference.blur()
|
|
739
|
+
},
|
|
740
|
+
/**
|
|
741
|
+
* 处理失焦事件
|
|
742
|
+
* @param {Event} event
|
|
743
|
+
*/
|
|
744
|
+
handleBlur(event) {
|
|
745
|
+
setTimeout(() => {
|
|
746
|
+
if (this.isSilentBlur) {
|
|
747
|
+
this.isSilentBlur = false
|
|
748
|
+
} else {
|
|
749
|
+
this.$emit('blur', event)
|
|
750
|
+
}
|
|
751
|
+
}, 50)
|
|
752
|
+
this.softFocus = false
|
|
753
|
+
},
|
|
754
|
+
/**
|
|
755
|
+
* 处理清除按钮点击
|
|
756
|
+
* @param {Event} event
|
|
757
|
+
*/
|
|
758
|
+
handleClearClick(event) {
|
|
759
|
+
this.deleteSelected(event)
|
|
760
|
+
},
|
|
761
|
+
/**
|
|
762
|
+
* 销毁 Popper
|
|
763
|
+
*/
|
|
764
|
+
doDestroy() {
|
|
765
|
+
this.$refs.popper && this.$refs.popper.doDestroy()
|
|
766
|
+
},
|
|
767
|
+
/**
|
|
768
|
+
* 处理点击外部关闭下拉框
|
|
769
|
+
*/
|
|
770
|
+
handleClose() {
|
|
771
|
+
this.visible = false
|
|
772
|
+
},
|
|
773
|
+
/**
|
|
774
|
+
* 切换最后一个选中 Tag 的 hit 状态
|
|
775
|
+
* @param {Boolean} [hit]
|
|
776
|
+
* @returns {Boolean}
|
|
777
|
+
*/
|
|
778
|
+
toggleLastOptionHitState(hit) {
|
|
779
|
+
if (!Array.isArray(this.selected)) return
|
|
780
|
+
const option = this.selected[this.selected.length - 1]
|
|
781
|
+
if (!option) return
|
|
782
|
+
if (hit === true || hit === false) {
|
|
783
|
+
option.hitState = hit
|
|
784
|
+
return hit
|
|
785
|
+
}
|
|
786
|
+
option.hitState = !option.hitState
|
|
787
|
+
return option.hitState
|
|
788
|
+
},
|
|
789
|
+
/**
|
|
790
|
+
* 删除前一个 Tag (Backspace)
|
|
791
|
+
* @param {KeyboardEvent} e
|
|
792
|
+
*/
|
|
793
|
+
deletePrevTag(e) {
|
|
794
|
+
if (e.target.value.length <= 0 && !this.toggleLastOptionHitState()) {
|
|
795
|
+
const value = this.value.slice()
|
|
796
|
+
value.pop()
|
|
797
|
+
this.$emit('input', value)
|
|
798
|
+
this.emitChange(value)
|
|
799
|
+
}
|
|
800
|
+
},
|
|
801
|
+
/**
|
|
802
|
+
* 管理 Placeholder 显示
|
|
803
|
+
*/
|
|
804
|
+
managePlaceholder() {
|
|
805
|
+
if (this.currentPlaceholder !== '') {
|
|
806
|
+
this.currentPlaceholder = this.$refs.input.value ? '' : this.cachedPlaceHolder
|
|
807
|
+
}
|
|
808
|
+
},
|
|
809
|
+
/**
|
|
810
|
+
* 重置输入框状态
|
|
811
|
+
* @param {KeyboardEvent} e
|
|
812
|
+
*/
|
|
813
|
+
resetInputState(e) {
|
|
814
|
+
if (e.keyCode !== 8) this.toggleLastOptionHitState(false)
|
|
815
|
+
this.inputLength = this.$refs.input.value.length * 15 + 20
|
|
816
|
+
this.resetInputHeight()
|
|
817
|
+
},
|
|
818
|
+
/**
|
|
819
|
+
* 重置输入框高度
|
|
820
|
+
*/
|
|
821
|
+
resetInputHeight() {
|
|
822
|
+
if (this.collapseTags && !this.filterable) return
|
|
823
|
+
this.$nextTick(() => {
|
|
824
|
+
if (!this.$refs.reference) return
|
|
825
|
+
let inputChildNodes = this.$refs.reference.$el.childNodes
|
|
826
|
+
let input = [].filter.call(inputChildNodes, (item) => item.tagName === 'INPUT')[0]
|
|
827
|
+
const tags = this.$refs.tags
|
|
828
|
+
const tagsHeight = tags ? Math.round(tags.getBoundingClientRect().height) : 0
|
|
829
|
+
const sizeInMap = this.initialInputHeight || 40
|
|
830
|
+
input.style.height = this.selected.length === 0 ? sizeInMap + 'px' : Math.max(tags ? tagsHeight + (tagsHeight > sizeInMap ? 6 : 0) : 0, sizeInMap) + 'px'
|
|
831
|
+
if (this.visible && this.emptyText !== false) {
|
|
832
|
+
this.broadcast('UiSelectDropdown', 'updatePopper')
|
|
833
|
+
}
|
|
834
|
+
})
|
|
835
|
+
},
|
|
836
|
+
/**
|
|
837
|
+
* 重置 Hover 索引
|
|
838
|
+
*/
|
|
839
|
+
resetHoverIndex() {
|
|
840
|
+
setTimeout(() => {
|
|
841
|
+
if (!this.multiple) {
|
|
842
|
+
this.hoverIndex = this.options.indexOf(this.selected)
|
|
843
|
+
} else {
|
|
844
|
+
if (this.selected.length > 0) {
|
|
845
|
+
this.hoverIndex = Math.min.apply(
|
|
846
|
+
null,
|
|
847
|
+
this.selected.map((item) => this.options.indexOf(item))
|
|
848
|
+
)
|
|
849
|
+
} else {
|
|
850
|
+
this.hoverIndex = -1
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
}, 300)
|
|
854
|
+
},
|
|
855
|
+
/**
|
|
856
|
+
* 处理选项选择
|
|
857
|
+
* @param {Object} option - 选中的选项对象
|
|
858
|
+
* @param {Boolean} byClick - 是否由点击触发
|
|
859
|
+
*/
|
|
860
|
+
handleOptionSelect(option, byClick) {
|
|
861
|
+
if (this.multiple) {
|
|
862
|
+
const value = (this.value || []).slice()
|
|
863
|
+
const optionIndex = this.getValueIndex(value, option.value)
|
|
864
|
+
if (optionIndex > -1) {
|
|
865
|
+
value.splice(optionIndex, 1)
|
|
866
|
+
} else if (this.multipleLimit <= 0 || value.length < this.multipleLimit) {
|
|
867
|
+
value.push(option.value)
|
|
868
|
+
}
|
|
869
|
+
this.$emit('input', value)
|
|
870
|
+
this.emitChange(value)
|
|
871
|
+
if (option.created) {
|
|
872
|
+
this.query = ''
|
|
873
|
+
this.handleQueryChange('')
|
|
874
|
+
this.inputLength = 20
|
|
875
|
+
}
|
|
876
|
+
if (this.filterable) this.$refs.input.focus()
|
|
877
|
+
} else {
|
|
878
|
+
this.$emit('input', option.value)
|
|
879
|
+
this.emitChange(option.value)
|
|
880
|
+
this.visible = false
|
|
881
|
+
}
|
|
882
|
+
this.isSilentBlur = byClick
|
|
883
|
+
this.setSoftFocus()
|
|
884
|
+
if (this.visible) return
|
|
885
|
+
this.$nextTick(() => {
|
|
886
|
+
this.scrollToOption(option)
|
|
887
|
+
})
|
|
888
|
+
},
|
|
889
|
+
/**
|
|
890
|
+
* 设置软焦点
|
|
891
|
+
*/
|
|
892
|
+
setSoftFocus() {
|
|
893
|
+
this.softFocus = true
|
|
894
|
+
const input = this.$refs.input || this.$refs.reference
|
|
895
|
+
if (input) {
|
|
896
|
+
input.focus()
|
|
897
|
+
}
|
|
898
|
+
},
|
|
899
|
+
/**
|
|
900
|
+
* 获取值在数组中的索引
|
|
901
|
+
* @param {Array} arr
|
|
902
|
+
* @param {*} value
|
|
903
|
+
* @returns {Number}
|
|
904
|
+
*/
|
|
905
|
+
getValueIndex(arr = [], value) {
|
|
906
|
+
const isObject = Object.prototype.toString.call(value).toLowerCase() === '[object object]'
|
|
907
|
+
if (!isObject) {
|
|
908
|
+
return arr.indexOf(value)
|
|
909
|
+
} else {
|
|
910
|
+
const valueKey = this.valueKey
|
|
911
|
+
let index = -1
|
|
912
|
+
arr.some((item, i) => {
|
|
913
|
+
if (get(item, valueKey) === get(value, valueKey)) {
|
|
914
|
+
index = i
|
|
915
|
+
return true
|
|
916
|
+
}
|
|
917
|
+
return false
|
|
918
|
+
})
|
|
919
|
+
return index
|
|
920
|
+
}
|
|
921
|
+
},
|
|
922
|
+
/**
|
|
923
|
+
* 切换菜单显示状态
|
|
924
|
+
*/
|
|
925
|
+
toggleMenu() {
|
|
926
|
+
if (!this.selectDisabled) {
|
|
927
|
+
if (this.menuVisibleOnFocus) {
|
|
928
|
+
this.menuVisibleOnFocus = false
|
|
929
|
+
} else {
|
|
930
|
+
this.visible = !this.visible
|
|
931
|
+
}
|
|
932
|
+
if (this.visible) {
|
|
933
|
+
;(this.$refs.input || this.$refs.reference).focus()
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
},
|
|
937
|
+
/**
|
|
938
|
+
* 选择当前高亮选项
|
|
939
|
+
*/
|
|
940
|
+
selectOption() {
|
|
941
|
+
if (!this.visible) {
|
|
942
|
+
this.toggleMenu()
|
|
943
|
+
} else {
|
|
944
|
+
if (this.options[this.hoverIndex]) {
|
|
945
|
+
this.handleOptionSelect(this.options[this.hoverIndex])
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
},
|
|
949
|
+
/**
|
|
950
|
+
* 删除所有选中项
|
|
951
|
+
* @param {Event} event
|
|
952
|
+
*/
|
|
953
|
+
deleteSelected(event) {
|
|
954
|
+
event.stopPropagation()
|
|
955
|
+
const value = this.multiple ? [] : ''
|
|
956
|
+
this.$emit('input', value)
|
|
957
|
+
this.emitChange(value)
|
|
958
|
+
this.visible = false
|
|
959
|
+
this.$emit('clear')
|
|
960
|
+
},
|
|
961
|
+
/**
|
|
962
|
+
* 删除单个 Tag
|
|
963
|
+
* @param {Event} event
|
|
964
|
+
* @param {Object} tag - 要删除的标签对应的选项
|
|
965
|
+
*/
|
|
966
|
+
deleteTag(event, tag) {
|
|
967
|
+
let index = this.selected.indexOf(tag)
|
|
968
|
+
if (index > -1 && !this.selectDisabled) {
|
|
969
|
+
const value = this.value.slice()
|
|
970
|
+
value.splice(index, 1)
|
|
971
|
+
this.$emit('input', value)
|
|
972
|
+
this.emitChange(value)
|
|
973
|
+
this.$emit('remove-tag', tag.value)
|
|
974
|
+
}
|
|
975
|
+
event.stopPropagation()
|
|
976
|
+
},
|
|
977
|
+
/**
|
|
978
|
+
* 输入框值改变时触发
|
|
979
|
+
*/
|
|
980
|
+
onInputChange() {
|
|
981
|
+
if (this.filterable && this.query !== this.selectedLabel) {
|
|
982
|
+
this.query = this.selectedLabel
|
|
983
|
+
this.handleQueryChange(this.query)
|
|
984
|
+
}
|
|
985
|
+
},
|
|
986
|
+
/**
|
|
987
|
+
* 选项销毁时触发
|
|
988
|
+
* @param {Number} index
|
|
989
|
+
*/
|
|
990
|
+
onOptionDestroy(index) {
|
|
991
|
+
if (index > -1) {
|
|
992
|
+
this.optionsCount--
|
|
993
|
+
this.filteredOptionsCount--
|
|
994
|
+
this.options.splice(index, 1)
|
|
995
|
+
}
|
|
996
|
+
},
|
|
997
|
+
/**
|
|
998
|
+
* 重置输入框宽度
|
|
999
|
+
*/
|
|
1000
|
+
resetInputWidth() {
|
|
1001
|
+
this.inputWidth = this.$refs.reference.$el.getBoundingClientRect().width
|
|
1002
|
+
},
|
|
1003
|
+
/**
|
|
1004
|
+
* 处理窗口大小调整
|
|
1005
|
+
*/
|
|
1006
|
+
handleResize() {
|
|
1007
|
+
this.resetInputWidth()
|
|
1008
|
+
if (this.multiple) this.resetInputHeight()
|
|
1009
|
+
},
|
|
1010
|
+
/**
|
|
1011
|
+
* 检查并设置默认第一个选项
|
|
1012
|
+
*/
|
|
1013
|
+
checkDefaultFirstOption() {
|
|
1014
|
+
this.hoverIndex = -1
|
|
1015
|
+
let hasCreated = false
|
|
1016
|
+
for (let i = this.options.length - 1; i >= 0; i--) {
|
|
1017
|
+
if (this.options[i].created) {
|
|
1018
|
+
hasCreated = true
|
|
1019
|
+
this.hoverIndex = i
|
|
1020
|
+
break
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
if (hasCreated) return
|
|
1024
|
+
for (let i = 0; i !== this.options.length; ++i) {
|
|
1025
|
+
const option = this.options[i]
|
|
1026
|
+
if (this.query) {
|
|
1027
|
+
if (!option.disabled && !option.groupDisabled && option.visible) {
|
|
1028
|
+
this.hoverIndex = i
|
|
1029
|
+
break
|
|
1030
|
+
}
|
|
1031
|
+
} else {
|
|
1032
|
+
if (option.itemSelected) {
|
|
1033
|
+
this.hoverIndex = i
|
|
1034
|
+
break
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
},
|
|
1039
|
+
/**
|
|
1040
|
+
* 获取选项的唯一 Key
|
|
1041
|
+
* @param {Object} item
|
|
1042
|
+
* @returns {*}
|
|
1043
|
+
*/
|
|
1044
|
+
getValueKey(item) {
|
|
1045
|
+
if (Object.prototype.toString.call(item.value).toLowerCase() !== '[object object]') {
|
|
1046
|
+
return item.value
|
|
1047
|
+
} else {
|
|
1048
|
+
return get(item.value, this.valueKey)
|
|
1049
|
+
}
|
|
1050
|
+
},
|
|
1051
|
+
},
|
|
1052
|
+
}
|
|
1053
|
+
</script>
|
|
1054
|
+
|
|
1055
|
+
<style lang="scss"> </style>
|