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,452 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span>
|
|
3
|
+
<span class="ui-popover__reference-wrapper" ref="wrapper">
|
|
4
|
+
<slot name="reference"></slot>
|
|
5
|
+
</span>
|
|
6
|
+
<transition :name="transition" @after-enter="handleAfterEnter" @after-leave="handleAfterLeave">
|
|
7
|
+
<div
|
|
8
|
+
class="ui-popover ui-popper"
|
|
9
|
+
:class="[popperClass, content && 'ui-popover--plain']"
|
|
10
|
+
ref="popper"
|
|
11
|
+
v-show="!disabled && showPopper"
|
|
12
|
+
:style="{ width: width + 'px' }"
|
|
13
|
+
role="tooltip"
|
|
14
|
+
:id="tooltipId"
|
|
15
|
+
:aria-hidden="disabled || !showPopper ? 'true' : 'false'"
|
|
16
|
+
>
|
|
17
|
+
<div class="ui-popover__title" v-if="title" v-text="title"></div>
|
|
18
|
+
<slot>{{ content }}</slot>
|
|
19
|
+
</div>
|
|
20
|
+
</transition>
|
|
21
|
+
</span>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
import Popper from '../../../utils/popper/index.js'
|
|
26
|
+
import { on, off, addClass, removeClass } from '../../../utils/dom/index.js'
|
|
27
|
+
import { random } from '../../../utils/lodash/index.js'
|
|
28
|
+
|
|
29
|
+
const generateId = () => random(0, 10000)
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* UiPopper 组件
|
|
33
|
+
* 用于创建浮动层(如 Tooltip, Popover),支持多种触发方式(点击、悬停、聚焦、手动)。
|
|
34
|
+
* 基于 Popper.js进行定位,并处理无障碍访问(ARIA)属性。
|
|
35
|
+
*
|
|
36
|
+
* @component
|
|
37
|
+
* @example
|
|
38
|
+
* <ui-popper content="Hello World">
|
|
39
|
+
* <template #reference>
|
|
40
|
+
* <button>Hover me</button>
|
|
41
|
+
* </template>
|
|
42
|
+
* </ui-popper>
|
|
43
|
+
*/
|
|
44
|
+
export default {
|
|
45
|
+
name: 'UiPopper',
|
|
46
|
+
directives: {},
|
|
47
|
+
mixins: [Popper],
|
|
48
|
+
props: {
|
|
49
|
+
/**
|
|
50
|
+
* 弹窗展示状态
|
|
51
|
+
* @type {boolean}
|
|
52
|
+
*/
|
|
53
|
+
visible: { type: Boolean, default: undefined },
|
|
54
|
+
/**
|
|
55
|
+
* 触发方式
|
|
56
|
+
* - click: 点击触发
|
|
57
|
+
* - focus: 聚焦触发
|
|
58
|
+
* - hover: 悬停触发
|
|
59
|
+
* - manual: 手动控制(通过 visible 属性或方法)
|
|
60
|
+
* @type {'click' | 'focus' | 'hover' | 'manual'}
|
|
61
|
+
* @default 'click'
|
|
62
|
+
*/
|
|
63
|
+
trigger: {
|
|
64
|
+
type: String,
|
|
65
|
+
default: 'click',
|
|
66
|
+
validator: (value) => ['click', 'focus', 'hover', 'manual'].indexOf(value) > -1,
|
|
67
|
+
},
|
|
68
|
+
/**
|
|
69
|
+
* 延迟显示的时间(毫秒)
|
|
70
|
+
* @type {number}
|
|
71
|
+
* @default 0
|
|
72
|
+
*/
|
|
73
|
+
openDelay: {
|
|
74
|
+
type: Number,
|
|
75
|
+
default: 0,
|
|
76
|
+
},
|
|
77
|
+
/**
|
|
78
|
+
* 延迟隐藏的时间(毫秒)
|
|
79
|
+
* @type {number}
|
|
80
|
+
* @default 200
|
|
81
|
+
*/
|
|
82
|
+
closeDelay: {
|
|
83
|
+
type: Number,
|
|
84
|
+
default: 200,
|
|
85
|
+
},
|
|
86
|
+
/**
|
|
87
|
+
* 标题文本
|
|
88
|
+
* @type {string}
|
|
89
|
+
*/
|
|
90
|
+
title: String,
|
|
91
|
+
/**
|
|
92
|
+
* 是否禁用 Popover
|
|
93
|
+
* @type {boolean}
|
|
94
|
+
*/
|
|
95
|
+
disabled: Boolean,
|
|
96
|
+
/**
|
|
97
|
+
* 显示的内容字符串。如果使用了默认插槽,此属性将被忽略。
|
|
98
|
+
* @type {string}
|
|
99
|
+
*/
|
|
100
|
+
content: String,
|
|
101
|
+
/**
|
|
102
|
+
* 触发参考元素。可以是 DOM 元素或 Vue 组件实例。
|
|
103
|
+
* 如果未提供,将自动使用默认插槽中的第一个子元素。
|
|
104
|
+
* @type {HTMLElement | VueComponent}
|
|
105
|
+
*/
|
|
106
|
+
reference: {},
|
|
107
|
+
/**
|
|
108
|
+
* 自定义 Popper 的类名
|
|
109
|
+
* @type {string}
|
|
110
|
+
*/
|
|
111
|
+
popperClass: String,
|
|
112
|
+
/**
|
|
113
|
+
* Popper 的宽度
|
|
114
|
+
* @type {number | string}
|
|
115
|
+
*/
|
|
116
|
+
width: {},
|
|
117
|
+
/**
|
|
118
|
+
* 是否显示箭头
|
|
119
|
+
* @type {boolean}
|
|
120
|
+
* @default true
|
|
121
|
+
*/
|
|
122
|
+
visibleArrow: {
|
|
123
|
+
default: true,
|
|
124
|
+
},
|
|
125
|
+
/**
|
|
126
|
+
* 箭头的偏移量
|
|
127
|
+
* @type {number}
|
|
128
|
+
* @default 0
|
|
129
|
+
*/
|
|
130
|
+
arrowOffset: {
|
|
131
|
+
type: Number,
|
|
132
|
+
default: 0,
|
|
133
|
+
},
|
|
134
|
+
/**
|
|
135
|
+
* 过渡动画名称
|
|
136
|
+
* @type {string}
|
|
137
|
+
* @default 'fade-in-linear'
|
|
138
|
+
*/
|
|
139
|
+
transition: {
|
|
140
|
+
type: String,
|
|
141
|
+
default: 'fade-in-linear',
|
|
142
|
+
},
|
|
143
|
+
/**
|
|
144
|
+
* Tab 索引,用于键盘导航。
|
|
145
|
+
* 如果设置为负数,元素将无法通过 Tab 键聚焦。
|
|
146
|
+
* @type {number}
|
|
147
|
+
* @default 0
|
|
148
|
+
*/
|
|
149
|
+
tabindex: {
|
|
150
|
+
type: Number,
|
|
151
|
+
default: 0,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
computed: {
|
|
156
|
+
/**
|
|
157
|
+
* 生成唯一的 Tooltip ID,用于 ARIA 关联
|
|
158
|
+
* @returns {string}
|
|
159
|
+
*/
|
|
160
|
+
tooltipId() {
|
|
161
|
+
return `ui-popover-${generateId()}`
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
watch: {
|
|
165
|
+
/**
|
|
166
|
+
* 监听外部 visible 属性变化,同步到内部 showPopper
|
|
167
|
+
* @param {boolean} val - 新的 visible 值
|
|
168
|
+
*/
|
|
169
|
+
visible: {
|
|
170
|
+
handler(val) {
|
|
171
|
+
const isControlled = this.$props.hasOwnProperty('visible')
|
|
172
|
+
if (isControlled) {
|
|
173
|
+
if (val !== this.showPopper) {
|
|
174
|
+
this.showPopper = val
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
immediate: true,
|
|
179
|
+
deep: true,
|
|
180
|
+
},
|
|
181
|
+
/**
|
|
182
|
+
* 监听显示状态变化,发射相应的事件
|
|
183
|
+
* @param {boolean} val - 当前的显示状态
|
|
184
|
+
*/
|
|
185
|
+
showPopper(val) {
|
|
186
|
+
// 1. 处理禁用状态
|
|
187
|
+
if (this.disabled) {
|
|
188
|
+
if (val) {
|
|
189
|
+
// 如果试图在禁用状态下显示,强制关闭
|
|
190
|
+
this.showPopper = false
|
|
191
|
+
// 如果是受控模式,通知父组件
|
|
192
|
+
if (this.$props.hasOwnProperty('visible')) {
|
|
193
|
+
this.$emit('update:visible', false)
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// 2. 发射业务事件
|
|
200
|
+
if (val) {
|
|
201
|
+
this.$emit('show')
|
|
202
|
+
// 重要:当显示时,需要确保 Popper 实例已创建并更新位置
|
|
203
|
+
// 通常 Popper mixin 会在 watch showPopper 中处理这个,但为了保险,可以手动调用
|
|
204
|
+
this.$nextTick(() => {
|
|
205
|
+
if (typeof this.updatePopper === 'function') {
|
|
206
|
+
this.updatePopper()
|
|
207
|
+
}
|
|
208
|
+
})
|
|
209
|
+
} else {
|
|
210
|
+
this.$emit('hide')
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// 3. 处理受控模式的双向绑定
|
|
214
|
+
if (this.$props.hasOwnProperty('visible')) {
|
|
215
|
+
// 只有当内部状态与外部不一致时才发射,避免死循环
|
|
216
|
+
// 但由于 Vue 的单向数据流,通常直接发射即可,父组件更新后 watch visible 会再次同步
|
|
217
|
+
this.$emit('update:visible', val)
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
mounted() {
|
|
223
|
+
// 初始化逻辑
|
|
224
|
+
const isControlled = this.$props.hasOwnProperty('visible')
|
|
225
|
+
if (isControlled) {
|
|
226
|
+
this.showPopper = !!this.visible
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
let reference = (this.referenceElm = this.reference || this.$refs.reference)
|
|
230
|
+
const popper = this.popper || this.$refs.popper
|
|
231
|
+
|
|
232
|
+
if (!reference && this.$refs.wrapper.children) {
|
|
233
|
+
reference = this.referenceElm = this.$refs.wrapper.children[0]
|
|
234
|
+
}
|
|
235
|
+
// 可访问性
|
|
236
|
+
if (reference) {
|
|
237
|
+
addClass(reference, 'ui-popover__reference')
|
|
238
|
+
reference.setAttribute('aria-describedby', this.tooltipId)
|
|
239
|
+
reference.setAttribute('tabindex', this.tabindex) // tab序列
|
|
240
|
+
popper.setAttribute('tabindex', 0)
|
|
241
|
+
|
|
242
|
+
if (this.trigger !== 'click') {
|
|
243
|
+
on(reference, 'focusin', () => {
|
|
244
|
+
this.handleFocus()
|
|
245
|
+
const instance = reference.__vue__
|
|
246
|
+
if (instance && typeof instance.focus === 'function') {
|
|
247
|
+
instance.focus()
|
|
248
|
+
}
|
|
249
|
+
})
|
|
250
|
+
on(popper, 'focusin', this.handleFocus)
|
|
251
|
+
on(reference, 'focusout', this.handleBlur)
|
|
252
|
+
on(popper, 'focusout', this.handleBlur)
|
|
253
|
+
}
|
|
254
|
+
on(reference, 'keydown', this.handleKeydown)
|
|
255
|
+
on(reference, 'click', this.handleClick)
|
|
256
|
+
}
|
|
257
|
+
if (this.trigger === 'click') {
|
|
258
|
+
on(reference, 'click', this.doToggle)
|
|
259
|
+
on(document, 'click', this.handleDocumentClick)
|
|
260
|
+
} else if (this.trigger === 'hover') {
|
|
261
|
+
on(reference, 'mouseenter', this.handleMouseEnter)
|
|
262
|
+
on(popper, 'mouseenter', this.handleMouseEnter)
|
|
263
|
+
on(reference, 'mouseleave', this.handleMouseLeave)
|
|
264
|
+
on(popper, 'mouseleave', this.handleMouseLeave)
|
|
265
|
+
} else if (this.trigger === 'focus') {
|
|
266
|
+
if (this.tabindex < 0) {
|
|
267
|
+
console.warn('[Element Warn][Popover]a negative taindex means that the element cannot be focused by tab key')
|
|
268
|
+
}
|
|
269
|
+
if (reference.querySelector('input, textarea')) {
|
|
270
|
+
on(reference, 'focusin', this.doShow)
|
|
271
|
+
on(reference, 'focusout', this.doClose)
|
|
272
|
+
} else {
|
|
273
|
+
on(reference, 'mousedown', this.doShow)
|
|
274
|
+
on(reference, 'mouseup', this.doClose)
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
|
|
279
|
+
beforeDestroy() {
|
|
280
|
+
this.cleanup()
|
|
281
|
+
},
|
|
282
|
+
|
|
283
|
+
deactivated() {
|
|
284
|
+
this.cleanup()
|
|
285
|
+
},
|
|
286
|
+
|
|
287
|
+
methods: {
|
|
288
|
+
/**
|
|
289
|
+
* 切换显示/隐藏状态
|
|
290
|
+
*/
|
|
291
|
+
doToggle() {
|
|
292
|
+
this.setShowPopper(!this.showPopper)
|
|
293
|
+
},
|
|
294
|
+
/**
|
|
295
|
+
* 显示 Popover
|
|
296
|
+
*/
|
|
297
|
+
doShow() {
|
|
298
|
+
this.setShowPopper(true)
|
|
299
|
+
},
|
|
300
|
+
/**
|
|
301
|
+
* 隐藏 Popover
|
|
302
|
+
*/
|
|
303
|
+
doClose() {
|
|
304
|
+
this.setShowPopper(false)
|
|
305
|
+
},
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* 统一的设置显示状态方法
|
|
309
|
+
* 处理受控与非受控模式的逻辑
|
|
310
|
+
* @param {boolean} val
|
|
311
|
+
*/
|
|
312
|
+
setShowPopper(val) {
|
|
313
|
+
if (this.disabled && val === true) return
|
|
314
|
+
|
|
315
|
+
// 调整组件受控判断逻辑,父组件没有传入 visible 属性时,默认为非受控模式 undefined
|
|
316
|
+
// const isControlled = this.$props.hasOwnProperty('visible')
|
|
317
|
+
const isControlled = this.visible !== undefined
|
|
318
|
+
|
|
319
|
+
if (isControlled) {
|
|
320
|
+
// 受控模式:只发射事件,不直接改状态
|
|
321
|
+
// 父组件收到事件更新 visible -> watch visible 触发 -> 更新 showPopper
|
|
322
|
+
this.$emit('update:visible', val)
|
|
323
|
+
} else {
|
|
324
|
+
// 非受控模式:直接改状态
|
|
325
|
+
this.showPopper = val
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* 处理焦点事件
|
|
331
|
+
* 添加 focusing 类并根据触发类型显示 Popover
|
|
332
|
+
*/
|
|
333
|
+
handleFocus() {
|
|
334
|
+
addClass(this.referenceElm, 'focusing')
|
|
335
|
+
if (this.trigger === 'click' || this.trigger === 'focus') {
|
|
336
|
+
this.setShowPopper(true)
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
/**
|
|
340
|
+
* 处理点击事件
|
|
341
|
+
* 移除 focusing 类
|
|
342
|
+
*/
|
|
343
|
+
handleClick() {
|
|
344
|
+
removeClass(this.referenceElm, 'focusing')
|
|
345
|
+
},
|
|
346
|
+
/**
|
|
347
|
+
* 处理失焦事件
|
|
348
|
+
* 移除 focusing 类并根据触发类型隐藏 Popover
|
|
349
|
+
*/
|
|
350
|
+
handleBlur() {
|
|
351
|
+
removeClass(this.referenceElm, 'focusing')
|
|
352
|
+
if (this.trigger === 'click' || this.trigger === 'focus') {
|
|
353
|
+
this.setShowPopper(false)
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
/**
|
|
357
|
+
* 处理鼠标进入事件
|
|
358
|
+
* 清除之前的定时器,并根据 openDelay 设置显示定时器
|
|
359
|
+
*/
|
|
360
|
+
handleMouseEnter() {
|
|
361
|
+
clearTimeout(this._timer)
|
|
362
|
+
if (this.openDelay) {
|
|
363
|
+
this._timer = setTimeout(() => {
|
|
364
|
+
this.setShowPopper(true)
|
|
365
|
+
}, this.openDelay)
|
|
366
|
+
} else {
|
|
367
|
+
this.setShowPopper(true)
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* 处理键盘按键事件
|
|
373
|
+
* 按下 ESC 键时关闭 Popover
|
|
374
|
+
* @param {KeyboardEvent} ev - 键盘事件对象
|
|
375
|
+
*/
|
|
376
|
+
handleKeydown(ev) {
|
|
377
|
+
if (ev.keyCode === 27 && this.trigger !== 'manual') {
|
|
378
|
+
// esc
|
|
379
|
+
this.setShowPopper(false)
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
/**
|
|
383
|
+
* 处理鼠标离开事件
|
|
384
|
+
* 清除之前的定时器,并根据 closeDelay 设置隐藏定时器
|
|
385
|
+
*/
|
|
386
|
+
handleMouseLeave() {
|
|
387
|
+
clearTimeout(this._timer)
|
|
388
|
+
if (this.closeDelay) {
|
|
389
|
+
this._timer = setTimeout(() => {
|
|
390
|
+
this.setShowPopper(false)
|
|
391
|
+
}, this.closeDelay)
|
|
392
|
+
} else {
|
|
393
|
+
this.setShowPopper(false)
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* 处理文档点击事件
|
|
399
|
+
* 如果点击区域不在参考元素或 Popper 内部,则关闭 Popover
|
|
400
|
+
* @param {MouseEvent} e - 鼠标事件对象
|
|
401
|
+
*/
|
|
402
|
+
handleDocumentClick(e) {
|
|
403
|
+
let reference = this.reference || this.$refs.reference
|
|
404
|
+
const popper = this.popper || this.$refs.popper
|
|
405
|
+
|
|
406
|
+
if (!reference && this.$refs.wrapper.children) {
|
|
407
|
+
reference = this.referenceElm = this.$refs.wrapper.children[0]
|
|
408
|
+
}
|
|
409
|
+
if (!this.$el || !reference || this.$el.contains(e.target) || reference.contains(e.target) || !popper || popper.contains(e.target)) return
|
|
410
|
+
this.setShowPopper(false)
|
|
411
|
+
},
|
|
412
|
+
/**
|
|
413
|
+
* 过渡动画进入完成后的回调
|
|
414
|
+
* 发射 'after-enter' 事件
|
|
415
|
+
*/
|
|
416
|
+
handleAfterEnter() {
|
|
417
|
+
this.$emit('after-enter')
|
|
418
|
+
},
|
|
419
|
+
/**
|
|
420
|
+
* 过渡动画离开完成后的回调
|
|
421
|
+
* 发射 'after-leave' 事件并销毁 Popper 实例
|
|
422
|
+
*/
|
|
423
|
+
handleAfterLeave() {
|
|
424
|
+
this.$emit('after-leave')
|
|
425
|
+
this.doDestroy()
|
|
426
|
+
},
|
|
427
|
+
/**
|
|
428
|
+
* 清理定时器
|
|
429
|
+
*/
|
|
430
|
+
cleanup() {
|
|
431
|
+
if (this.openDelay || this.closeDelay) {
|
|
432
|
+
clearTimeout(this._timer)
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
},
|
|
436
|
+
|
|
437
|
+
destroyed() {
|
|
438
|
+
const reference = this.reference
|
|
439
|
+
|
|
440
|
+
off(reference, 'click', this.doToggle)
|
|
441
|
+
off(reference, 'mouseup', this.doClose)
|
|
442
|
+
off(reference, 'mousedown', this.doShow)
|
|
443
|
+
off(reference, 'focusin', this.doShow)
|
|
444
|
+
off(reference, 'focusout', this.doClose)
|
|
445
|
+
off(reference, 'mousedown', this.doShow)
|
|
446
|
+
off(reference, 'mouseup', this.doClose)
|
|
447
|
+
off(reference, 'mouseleave', this.handleMouseLeave)
|
|
448
|
+
off(reference, 'mouseenter', this.handleMouseEnter)
|
|
449
|
+
off(document, 'click', this.handleDocumentClick)
|
|
450
|
+
},
|
|
451
|
+
}
|
|
452
|
+
</script>
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="ui-progress"
|
|
4
|
+
:class="[
|
|
5
|
+
'ui-progress--' + type,
|
|
6
|
+
status ? 'is-' + status : '',
|
|
7
|
+
{
|
|
8
|
+
'ui-progress--without-text': !showText,
|
|
9
|
+
'ui-progress--text-inside': textInside,
|
|
10
|
+
}
|
|
11
|
+
]"
|
|
12
|
+
role="progressbar"
|
|
13
|
+
:aria-valuenow="percentage"
|
|
14
|
+
aria-valuemin="0"
|
|
15
|
+
aria-valuemax="100"
|
|
16
|
+
>
|
|
17
|
+
<div class="ui-progress-bar" v-if="type === 'line'">
|
|
18
|
+
<div class="ui-progress-bar__outer" :style="{height: strokeWidth + 'px', backgroundColor: defineBackColor}">
|
|
19
|
+
<div class="ui-progress-bar__inner" :style="barStyle">
|
|
20
|
+
<div class="ui-progress-bar__innerText" :style="{color: textColor}" v-if="showText && textInside">{{content}}</div>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="ui-progress-circle" :style="{height: width + 'px', width: width + 'px'}" v-else>
|
|
25
|
+
<svg viewBox="0 0 100 100">
|
|
26
|
+
<path
|
|
27
|
+
class="ui-progress-circle__track"
|
|
28
|
+
:d="trackPath"
|
|
29
|
+
:stroke="defineBackColor"
|
|
30
|
+
:stroke-width="relativeStrokeWidth"
|
|
31
|
+
fill="none"
|
|
32
|
+
:style="trailPathStyle"></path>
|
|
33
|
+
<path
|
|
34
|
+
class="ui-progress-circle__path"
|
|
35
|
+
:d="trackPath"
|
|
36
|
+
:stroke="stroke"
|
|
37
|
+
fill="none"
|
|
38
|
+
:stroke-linecap="strokeLinecap"
|
|
39
|
+
:stroke-width="percentage ? relativeStrokeWidth : 0"
|
|
40
|
+
:style="circlePathStyle"></path>
|
|
41
|
+
</svg>
|
|
42
|
+
</div>
|
|
43
|
+
<div
|
|
44
|
+
class="ui-progress__text"
|
|
45
|
+
v-if="showText && !textInside"
|
|
46
|
+
:style="{fontSize: progressTextSize + 'px', color: textColor}"
|
|
47
|
+
>
|
|
48
|
+
<template v-if="!status">{{content}}</template>
|
|
49
|
+
<i v-else :class="iconClass"></i>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<script>
|
|
55
|
+
export default {
|
|
56
|
+
name: 'UiProgress',
|
|
57
|
+
props: {
|
|
58
|
+
type: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: 'line',
|
|
61
|
+
validator: val => ['line', 'circle', 'dashboard'].indexOf(val) > -1
|
|
62
|
+
},
|
|
63
|
+
percentage: {
|
|
64
|
+
type: Number,
|
|
65
|
+
default: 0,
|
|
66
|
+
required: true,
|
|
67
|
+
validator: val => val >= 0 && val <= 100
|
|
68
|
+
},
|
|
69
|
+
status: {
|
|
70
|
+
type: String,
|
|
71
|
+
validator: val => ['success', 'exception', 'warning'].indexOf(val) > -1
|
|
72
|
+
},
|
|
73
|
+
strokeWidth: {
|
|
74
|
+
type: Number,
|
|
75
|
+
default: 6
|
|
76
|
+
},
|
|
77
|
+
strokeLinecap: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: 'round'
|
|
80
|
+
},
|
|
81
|
+
textInside: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: false
|
|
84
|
+
},
|
|
85
|
+
width: {
|
|
86
|
+
type: Number,
|
|
87
|
+
default: 126
|
|
88
|
+
},
|
|
89
|
+
showText: {
|
|
90
|
+
type: Boolean,
|
|
91
|
+
default: true
|
|
92
|
+
},
|
|
93
|
+
color: {
|
|
94
|
+
type: [String, Array, Function],
|
|
95
|
+
default: ''
|
|
96
|
+
},
|
|
97
|
+
defineBackColor: {
|
|
98
|
+
type: [String, Array, Function],
|
|
99
|
+
default: '#ebeef5'
|
|
100
|
+
},
|
|
101
|
+
textColor: {
|
|
102
|
+
type: [String, Array, Function],
|
|
103
|
+
default: '#606266'
|
|
104
|
+
},
|
|
105
|
+
format: Function
|
|
106
|
+
},
|
|
107
|
+
computed: {
|
|
108
|
+
barStyle() {
|
|
109
|
+
const style = {};
|
|
110
|
+
style.width = this.percentage + '%';
|
|
111
|
+
style.backgroundColor = this.getCurrentColor(this.percentage);
|
|
112
|
+
return style;
|
|
113
|
+
},
|
|
114
|
+
relativeStrokeWidth() {
|
|
115
|
+
return (this.strokeWidth / this.width * 100).toFixed(1);
|
|
116
|
+
},
|
|
117
|
+
radius() {
|
|
118
|
+
if (this.type === 'circle' || this.type === 'dashboard') {
|
|
119
|
+
return parseInt(50 - parseFloat(this.relativeStrokeWidth) / 2, 10);
|
|
120
|
+
} else {
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
trackPath() {
|
|
125
|
+
const radius = this.radius;
|
|
126
|
+
const isDashboard = this.type === 'dashboard';
|
|
127
|
+
return `
|
|
128
|
+
M 50 50
|
|
129
|
+
m 0 ${isDashboard ? '' : '-'}${radius}
|
|
130
|
+
a ${radius} ${radius} 0 1 1 0 ${isDashboard ? '-' : ''}${radius * 2}
|
|
131
|
+
a ${radius} ${radius} 0 1 1 0 ${isDashboard ? '' : '-'}${radius * 2}
|
|
132
|
+
`;
|
|
133
|
+
},
|
|
134
|
+
perimeter() {
|
|
135
|
+
return 2 * Math.PI * this.radius;
|
|
136
|
+
},
|
|
137
|
+
rate() {
|
|
138
|
+
return this.type === 'dashboard' ? 0.75 : 1;
|
|
139
|
+
},
|
|
140
|
+
strokeDashoffset() {
|
|
141
|
+
const offset = -1 * this.perimeter * (1 - this.rate) / 2;
|
|
142
|
+
return `${offset}px`;
|
|
143
|
+
},
|
|
144
|
+
trailPathStyle() {
|
|
145
|
+
return {
|
|
146
|
+
strokeDasharray: `${(this.perimeter * this.rate)}px, ${this.perimeter}px`,
|
|
147
|
+
strokeDashoffset: this.strokeDashoffset
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
circlePathStyle() {
|
|
151
|
+
return {
|
|
152
|
+
strokeDasharray: `${this.perimeter * this.rate * (this.percentage / 100) }px, ${this.perimeter}px`,
|
|
153
|
+
strokeDashoffset: this.strokeDashoffset,
|
|
154
|
+
transition: 'stroke-dasharray 0.6s ease 0s, stroke 0.6s ease'
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
stroke() {
|
|
158
|
+
let ret;
|
|
159
|
+
if (this.color) {
|
|
160
|
+
ret = this.getCurrentColor(this.percentage);
|
|
161
|
+
} else {
|
|
162
|
+
switch (this.status) {
|
|
163
|
+
case 'success':
|
|
164
|
+
ret = '#13ce66';
|
|
165
|
+
break;
|
|
166
|
+
case 'exception':
|
|
167
|
+
ret = '#ff4949';
|
|
168
|
+
break;
|
|
169
|
+
case 'warning':
|
|
170
|
+
ret = '#e6a23c';
|
|
171
|
+
break;
|
|
172
|
+
default:
|
|
173
|
+
ret = '#20a0ff';
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return ret;
|
|
177
|
+
},
|
|
178
|
+
iconClass() {
|
|
179
|
+
if (this.status === 'warning') {
|
|
180
|
+
return 'icon-warning';
|
|
181
|
+
}
|
|
182
|
+
if (this.type === 'line') {
|
|
183
|
+
return this.status === 'success' ? 'icon-circle-check' : 'icon-circle-close';
|
|
184
|
+
} else {
|
|
185
|
+
return this.status === 'success' ? 'icon-check' : 'icon-close';
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
progressTextSize() {
|
|
189
|
+
return this.type === 'line'
|
|
190
|
+
? 12 + this.strokeWidth * 0.4
|
|
191
|
+
: this.width * 0.111111 + 2 ;
|
|
192
|
+
},
|
|
193
|
+
content() {
|
|
194
|
+
if (typeof this.format === 'function') {
|
|
195
|
+
return this.format(this.percentage) || '';
|
|
196
|
+
} else {
|
|
197
|
+
return `${this.percentage}%`;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
methods: {
|
|
202
|
+
getCurrentColor(percentage) {
|
|
203
|
+
if (typeof this.color === 'function') {
|
|
204
|
+
return this.color(percentage);
|
|
205
|
+
} else if (typeof this.color === 'string') {
|
|
206
|
+
return this.color;
|
|
207
|
+
} else {
|
|
208
|
+
return this.getLevelColor(percentage);
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
getLevelColor(percentage) {
|
|
212
|
+
const colorArray = this.getColorArray().sort((a, b) => a.percentage - b.percentage);
|
|
213
|
+
|
|
214
|
+
for (let i = 0; i < colorArray.length; i++) {
|
|
215
|
+
if (colorArray[i].percentage > percentage) {
|
|
216
|
+
return colorArray[i].color;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return colorArray[colorArray.length - 1].color;
|
|
220
|
+
},
|
|
221
|
+
getColorArray() {
|
|
222
|
+
const color = this.color;
|
|
223
|
+
const span = 100 / color.length;
|
|
224
|
+
return color.map((seriesColor, index) => {
|
|
225
|
+
if (typeof seriesColor === 'string') {
|
|
226
|
+
return {
|
|
227
|
+
color: seriesColor,
|
|
228
|
+
percentage: (index + 1) * span
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
return seriesColor;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
</script>
|