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,321 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="[
|
|
4
|
+
'ui-time-picker',
|
|
5
|
+
visibleType === 'time' ? 'is-time' : '',
|
|
6
|
+
visibleType === 'date' ? 'is-date' : '',
|
|
7
|
+
visibleType === 'datetime' || visibleType === 'timestamp' ? 'is-datetime' : '',
|
|
8
|
+
visibleType === 'date-range' ? 'is-date-range' : '',
|
|
9
|
+
visibleType === 'datetime-range' || visibleType === 'timestamp-range' ? 'is-datetime-range' : '',
|
|
10
|
+
]"
|
|
11
|
+
>
|
|
12
|
+
<ui-popover v-if="['time', 'date', 'date-range'].includes(visibleType)" ref="mainPopover" :placement="placement" :trigger="disabled ? 'manual' : 'focus'" @show="handleFocus" @hide="handleBlur">
|
|
13
|
+
<template slot="reference">
|
|
14
|
+
<time-range-input v-if="isRange" v-model="dateRange" :format="formatType" :separator="separator" :compact="compact" :config="inputProps" @clear="clearDateRange" />
|
|
15
|
+
<time-input v-else v-model="dateValue" :format="formatType" :compact="compact" v-bind="inputProps" @clear="clearDate" />
|
|
16
|
+
</template>
|
|
17
|
+
<div>
|
|
18
|
+
<time-pane v-if="visibleType === 'time'" ref="paneRef" v-model="dateValue" :format="formatTypeIgnoreRange" :readonly="readonly" :arrow-control="timeArrowControl" />
|
|
19
|
+
<date-range-pane v-else-if="isRange" ref="paneRef" v-model="dateRange" :format="formatTypeIgnoreRange" :readonly="readonly" />
|
|
20
|
+
<date-pane v-else ref="paneRef" v-model="dateValue" :format="formatTypeIgnoreRange" :readonly="readonly" />
|
|
21
|
+
</div>
|
|
22
|
+
</ui-popover>
|
|
23
|
+
<ui-popover v-else ref="mainPopover" :placement="placement" :visible.sync="paneVisible" trigger="manual" @show="handleFocus" @hide="handleBlur" >
|
|
24
|
+
<template slot="reference">
|
|
25
|
+
<time-range-input v-if="isRange" v-model="dateRange" :format="formatType" :separator="separator" :compact="compact" :config="inputProps" @focus="handleTriggerFocus" @clear="clearDateRange" />
|
|
26
|
+
<time-input v-else v-model="dateValue" :format="formatType" :compact="compact" v-bind="inputProps" @focus="handleTriggerFocus" @clear="clearDate" />
|
|
27
|
+
</template>
|
|
28
|
+
<div>
|
|
29
|
+
<date-time-range-pane v-if="isRange" ref="paneRef" v-model="dateRange" :format="formatTypeIgnoreRange" :readonly="readonly" :arrow-control="timeArrowControl" @close="closeEdit" />
|
|
30
|
+
<date-time-pane v-else ref="paneRef" v-model="dateValue" :format="formatTypeIgnoreRange" :readonly="readonly" :arrow-control="timeArrowControl" @close="closeEdit" />
|
|
31
|
+
</div>
|
|
32
|
+
</ui-popover>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script>
|
|
37
|
+
import UiInput from '../../input/src/main.vue'
|
|
38
|
+
import UiPopover from '../../popover/src/main.vue'
|
|
39
|
+
import TimePane from './pane/time.vue'
|
|
40
|
+
import DatePane from './pane/date.vue'
|
|
41
|
+
import DateRangePane from './pane/date-range.vue'
|
|
42
|
+
import DateTimePane from './pane/date-time.vue'
|
|
43
|
+
import DateTimeRangePane from './pane/date-time-range.vue'
|
|
44
|
+
import TimeInput from './time-input.vue'
|
|
45
|
+
import TimeRangeInput from './time-range-input.vue'
|
|
46
|
+
|
|
47
|
+
import clickoutside from '../../../directives/clickoutside/index.js'
|
|
48
|
+
import { formatDate } from '../../../utils/moment/index.js'
|
|
49
|
+
import { formatterType, classifyFormat, getRangeSeparator } from './date-utils.js'
|
|
50
|
+
import { isArray, isNaN, isEqual } from '../../../utils/lodash/index.js'
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 转换时间,将输入值转换为 Date 对象
|
|
54
|
+
* 如果输入为空或非法,返回 null,避免隐式转换为当前时间导致的数据污染
|
|
55
|
+
* @param {*} time
|
|
56
|
+
* @returns {Date|null}
|
|
57
|
+
*/
|
|
58
|
+
function timeToDateType(time) {
|
|
59
|
+
// 处理空值
|
|
60
|
+
if (time === null || time === undefined || time === '') {
|
|
61
|
+
return null
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 尝试创建日期对象
|
|
65
|
+
const date = new Date(time)
|
|
66
|
+
|
|
67
|
+
// 检查是否为 Invalid Date
|
|
68
|
+
if (isNaN(date.getTime())) {
|
|
69
|
+
return null
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return date
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default {
|
|
76
|
+
name: 'UiTimePicker',
|
|
77
|
+
components: {
|
|
78
|
+
UiInput,
|
|
79
|
+
UiPopover,
|
|
80
|
+
TimePane,
|
|
81
|
+
DatePane,
|
|
82
|
+
DateRangePane,
|
|
83
|
+
DateTimePane,
|
|
84
|
+
DateTimeRangePane,
|
|
85
|
+
TimeInput,
|
|
86
|
+
TimeRangeInput,
|
|
87
|
+
},
|
|
88
|
+
props: {
|
|
89
|
+
value: {},
|
|
90
|
+
format: { type: String, default: '' },
|
|
91
|
+
valueFormat: { type: String, default: 'YYYY-MM-DD HH:mm:ss' },
|
|
92
|
+
readonly: Boolean,
|
|
93
|
+
disabled: Boolean,
|
|
94
|
+
placeholder: String,
|
|
95
|
+
startPlaceholder: String,
|
|
96
|
+
endPlaceholder: String,
|
|
97
|
+
prefixIcon: String,
|
|
98
|
+
clearable: Boolean,
|
|
99
|
+
size: String,
|
|
100
|
+
compact: { type: Boolean, default: true },
|
|
101
|
+
placement: { type: String, default: 'bottom' },
|
|
102
|
+
timeArrowControl: Boolean,
|
|
103
|
+
},
|
|
104
|
+
data: () => ({
|
|
105
|
+
timeVisibleStr: '', // 展示在控件上的时间字符串,根据 format 格式化
|
|
106
|
+
paneVisible: false,
|
|
107
|
+
dateValue: null, // 单值时间 Date
|
|
108
|
+
dateRange: [], // 时间范围 Date[]
|
|
109
|
+
isInternalUpdate: false, // 内部更新标记
|
|
110
|
+
}),
|
|
111
|
+
computed: {
|
|
112
|
+
// 时间展示格式规整,缺省与 valueFormat 一致
|
|
113
|
+
formatType() {
|
|
114
|
+
return formatterType(this.format || this.valueFormat)
|
|
115
|
+
},
|
|
116
|
+
// 去除 -range,timestamp 转标准年月日时分秒,标识时间格式或范围格式,用于控制面板
|
|
117
|
+
formatTypeIgnoreRange() {
|
|
118
|
+
return this.formatType.replace('timestamp', 'YYYY-MM-DD HH:mm:ss').replace('-range', '')
|
|
119
|
+
},
|
|
120
|
+
// 可视化时间类型(业务类型)
|
|
121
|
+
visibleType() {
|
|
122
|
+
return classifyFormat(this.formatType)
|
|
123
|
+
},
|
|
124
|
+
// 是否为范围时间选择
|
|
125
|
+
isRange() {
|
|
126
|
+
return this.formatType.includes('range')
|
|
127
|
+
},
|
|
128
|
+
// value 时间格式规整
|
|
129
|
+
valueFormatType() {
|
|
130
|
+
return formatterType(this.valueFormat)
|
|
131
|
+
},
|
|
132
|
+
// 输出时间格式规整,去除 -range
|
|
133
|
+
outputType() {
|
|
134
|
+
return this.valueFormatType.replace('-range', '')
|
|
135
|
+
},
|
|
136
|
+
// 提取范围时间分隔符
|
|
137
|
+
separator() {
|
|
138
|
+
return getRangeSeparator(this.format || this.valueFormat)
|
|
139
|
+
},
|
|
140
|
+
showClear() {
|
|
141
|
+
if (this.isRange) {
|
|
142
|
+
const [d1, d2] = this.dateRange
|
|
143
|
+
return d1 && !isNaN(d1.getTime()) && d2 && !isNaN(d2.getTime())
|
|
144
|
+
} else {
|
|
145
|
+
const d = this.dateValue
|
|
146
|
+
return d && !isNaN(d.getTime())
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
inputProps() {
|
|
150
|
+
return {
|
|
151
|
+
readonly: this.readonly || false,
|
|
152
|
+
disabled: this.disabled || false,
|
|
153
|
+
placeholder: this.placeholder || '',
|
|
154
|
+
startPlaceholder: this.startPlaceholder || '',
|
|
155
|
+
endPlaceholder: this.endPlaceholder || '',
|
|
156
|
+
prefixIcon: this.prefixIcon === undefined ? (this.visibleType === 'time' ? 'ui-icon-time' : 'ui-icon-date') : (this.prefixIcon || ''),
|
|
157
|
+
clearable: (this.clearable && this.showClear) || false,
|
|
158
|
+
size: this.size || '',
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
directives: { clickoutside },
|
|
163
|
+
watch: {
|
|
164
|
+
value: {
|
|
165
|
+
handler(val) {
|
|
166
|
+
if (this.isInternalUpdate) return
|
|
167
|
+
|
|
168
|
+
let nextDateValue = null
|
|
169
|
+
let nextDateRange = []
|
|
170
|
+
|
|
171
|
+
if (this.isRange && isArray(val)) {
|
|
172
|
+
if (val.length === 2) {
|
|
173
|
+
nextDateRange = [timeToDateType(val[0]), timeToDateType(val[1])]
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// 比较时间对象是否相同
|
|
177
|
+
const isRangeChanged = this.dateRange.length !== nextDateRange.length ||
|
|
178
|
+
nextDateRange.some((d, i) => {
|
|
179
|
+
const oldD = this.dateRange[i]
|
|
180
|
+
// 如果一个是 null 一个不是,或者都不是 null 但时间不同
|
|
181
|
+
if (!d && !oldD) return false
|
|
182
|
+
if (!d || !oldD) return true
|
|
183
|
+
return d.getTime() !== oldD.getTime()
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
if (isRangeChanged) {
|
|
187
|
+
this.dateRange = nextDateRange
|
|
188
|
+
}
|
|
189
|
+
} else if (!isArray(val) && val != null) {
|
|
190
|
+
nextDateValue = timeToDateType(val)
|
|
191
|
+
|
|
192
|
+
// 安全比较
|
|
193
|
+
const oldVal = this.dateValue
|
|
194
|
+
const newVal = nextDateValue
|
|
195
|
+
|
|
196
|
+
let hasChanged = false
|
|
197
|
+
if (!oldVal && !newVal) hasChanged = false
|
|
198
|
+
else if (!oldVal || !newVal) hasChanged = true
|
|
199
|
+
else hasChanged = oldVal.getTime() !== newVal.getTime()
|
|
200
|
+
|
|
201
|
+
if (hasChanged) {
|
|
202
|
+
this.dateValue = nextDateValue
|
|
203
|
+
}
|
|
204
|
+
} else {
|
|
205
|
+
if (this.dateValue !== null) {
|
|
206
|
+
this.dateValue = null
|
|
207
|
+
}
|
|
208
|
+
if (this.dateRange.length > 0) {
|
|
209
|
+
this.dateRange = []
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
immediate: true,
|
|
214
|
+
deep: true,
|
|
215
|
+
},
|
|
216
|
+
dateValue(val) {
|
|
217
|
+
// 如果是内部更新,跳过 emit
|
|
218
|
+
if (this.isInternalUpdate) return
|
|
219
|
+
|
|
220
|
+
let outputVal = undefined
|
|
221
|
+
let shouldEmit = false
|
|
222
|
+
|
|
223
|
+
if (!this.isRange && val) {
|
|
224
|
+
if (this.outputType === 'timestamp') {
|
|
225
|
+
outputVal = val.getTime()
|
|
226
|
+
} else {
|
|
227
|
+
outputVal = formatDate(val, this.outputType)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// 只有当值真正改变时才 emit
|
|
231
|
+
if (outputVal !== this.value) {
|
|
232
|
+
shouldEmit = true
|
|
233
|
+
}
|
|
234
|
+
} else if (!val && this.value) {
|
|
235
|
+
// 从有值变为无值
|
|
236
|
+
outputVal = undefined
|
|
237
|
+
shouldEmit = true
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
shouldEmit && this.handleEmit(outputVal)
|
|
241
|
+
},
|
|
242
|
+
dateRange: {
|
|
243
|
+
handler(range) {
|
|
244
|
+
// 如果是内部更新,跳过 emit
|
|
245
|
+
if (this.isInternalUpdate) return
|
|
246
|
+
|
|
247
|
+
let outputVal = []
|
|
248
|
+
let shouldEmit = false
|
|
249
|
+
|
|
250
|
+
if (this.isRange && isArray(range) && range[0] && range[1]) {
|
|
251
|
+
if (this.outputType === 'timestamp') {
|
|
252
|
+
outputVal = [range[0].getTime(), range[1].getTime()]
|
|
253
|
+
} else {
|
|
254
|
+
outputVal = [formatDate(range[0], this.outputType), formatDate(range[1], this.outputType)]
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// 使用 lodash isEqual 进行深比较,避免引用不同但内容相同导致的重复 emit
|
|
258
|
+
if (!isEqual(this.value, outputVal)) {
|
|
259
|
+
shouldEmit = true
|
|
260
|
+
}
|
|
261
|
+
} else if ((!range || range.length === 0) && this.value) {
|
|
262
|
+
// 从有值变为无值 (空数组)
|
|
263
|
+
outputVal = []
|
|
264
|
+
// 如果原值不是空数组,则需要 emit
|
|
265
|
+
if (!(isArray(this.value) && this.value.length === 0)) {
|
|
266
|
+
shouldEmit = true
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
shouldEmit && this.handleEmit(outputVal)
|
|
271
|
+
},
|
|
272
|
+
deep: true,
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
methods: {
|
|
276
|
+
paneScrollInit() {
|
|
277
|
+
this.$nextTick(() => {
|
|
278
|
+
// 增加安全检查,防止 ref 不存在时报错
|
|
279
|
+
if (this.$refs.paneRef && typeof this.$refs.paneRef.scrollInit === 'function') {
|
|
280
|
+
this.$refs.paneRef.scrollInit()
|
|
281
|
+
}
|
|
282
|
+
})
|
|
283
|
+
},
|
|
284
|
+
handleTriggerFocus() {
|
|
285
|
+
if (this.disabled) return
|
|
286
|
+
this.paneVisible = true
|
|
287
|
+
},
|
|
288
|
+
closeEdit() {
|
|
289
|
+
this.paneVisible = false
|
|
290
|
+
},
|
|
291
|
+
clearDateRange() {
|
|
292
|
+
this.$emit('input', [])
|
|
293
|
+
},
|
|
294
|
+
clearDate() {
|
|
295
|
+
this.$emit('input', null)
|
|
296
|
+
},
|
|
297
|
+
focus() {
|
|
298
|
+
this.$refs?.mainPopover?.referenceElm?.focus()
|
|
299
|
+
},
|
|
300
|
+
blur() {
|
|
301
|
+
this.$refs?.mainPopover?.referenceElm?.blur()
|
|
302
|
+
},
|
|
303
|
+
handleFocus() {
|
|
304
|
+
this.focus()
|
|
305
|
+
this.paneScrollInit()
|
|
306
|
+
this.$emit('focus')
|
|
307
|
+
},
|
|
308
|
+
handleBlur() {
|
|
309
|
+
this.$emit('blur')
|
|
310
|
+
},
|
|
311
|
+
handleEmit(val) {
|
|
312
|
+
this.isInternalUpdate = true
|
|
313
|
+
this.$emit('input', val)
|
|
314
|
+
this.$emit('change', val)
|
|
315
|
+
this.$nextTick(() => {
|
|
316
|
+
this.isInternalUpdate = false
|
|
317
|
+
})
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
}
|
|
321
|
+
</script>
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-clickoutside="handleClose" class="ui-timepicker-date-range-pane">
|
|
3
|
+
<!-- 左面板 -->
|
|
4
|
+
<ui-time-picker-date-pane
|
|
5
|
+
mode="range"
|
|
6
|
+
:view-date="leftViewDate"
|
|
7
|
+
:range="displayRange"
|
|
8
|
+
:hover-date="hoverDate"
|
|
9
|
+
:value="null"
|
|
10
|
+
:readonly="readonly"
|
|
11
|
+
@pick="handlePick"
|
|
12
|
+
@hover="handleHover"
|
|
13
|
+
@view-change="handleLeftViewChange"
|
|
14
|
+
/>
|
|
15
|
+
<!-- 右面板 -->
|
|
16
|
+
<ui-time-picker-date-pane
|
|
17
|
+
mode="range"
|
|
18
|
+
:view-date="rightViewDate"
|
|
19
|
+
:range="displayRange"
|
|
20
|
+
:hover-date="hoverDate"
|
|
21
|
+
:value="null"
|
|
22
|
+
:readonly="readonly"
|
|
23
|
+
@pick="handlePick"
|
|
24
|
+
@hover="handleHover"
|
|
25
|
+
@view-change="handleRightViewChange"
|
|
26
|
+
/>
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script>
|
|
31
|
+
import UiTimePickerDatePane from './date.vue'
|
|
32
|
+
|
|
33
|
+
import clickoutside from '../../../../directives/clickoutside/index.js'
|
|
34
|
+
|
|
35
|
+
export default {
|
|
36
|
+
name: 'UiTimePickerDateRangePane',
|
|
37
|
+
components: {
|
|
38
|
+
UiTimePickerDatePane,
|
|
39
|
+
},
|
|
40
|
+
props: {
|
|
41
|
+
value: {
|
|
42
|
+
type: Array,
|
|
43
|
+
required: true,
|
|
44
|
+
default: () => [],
|
|
45
|
+
},
|
|
46
|
+
readonly: Boolean,
|
|
47
|
+
},
|
|
48
|
+
data() {
|
|
49
|
+
return {
|
|
50
|
+
// 左侧面板的视图日期
|
|
51
|
+
leftViewDate: new Date(),
|
|
52
|
+
// 选择状态
|
|
53
|
+
selecting: false,
|
|
54
|
+
tempStart: null,
|
|
55
|
+
hoverDate: null,
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
computed: {
|
|
59
|
+
// 【关键修改】右侧面板始终显示左侧面板的下一月
|
|
60
|
+
rightViewDate() {
|
|
61
|
+
const d = new Date(this.leftViewDate)
|
|
62
|
+
d.setMonth(d.getMonth() + 1)
|
|
63
|
+
return d
|
|
64
|
+
},
|
|
65
|
+
// 传递给子组件的范围数据
|
|
66
|
+
displayRange() {
|
|
67
|
+
if (this.selecting && this.tempStart) {
|
|
68
|
+
// 正在选择时,返回 [起点, 空],子组件会结合 hoverDate 显示预览
|
|
69
|
+
return [this.tempStart, null]
|
|
70
|
+
}
|
|
71
|
+
return this.value
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
watch: {
|
|
75
|
+
// 监听外部 value 变化,重置选择状态并调整视图
|
|
76
|
+
value: {
|
|
77
|
+
handler(newVal) {
|
|
78
|
+
if (newVal && newVal.length === 2) {
|
|
79
|
+
this.selecting = false
|
|
80
|
+
this.tempStart = null
|
|
81
|
+
this.hoverDate = null
|
|
82
|
+
} else if (!newVal || newVal.length === 0) {
|
|
83
|
+
this.selecting = false
|
|
84
|
+
this.tempStart = null
|
|
85
|
+
this.hoverDate = null
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
immediate: true,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
directives: { clickoutside },
|
|
92
|
+
methods: {
|
|
93
|
+
scrollInit() {
|
|
94
|
+
// 初始化,将视图跳转到选中范围的起始月份
|
|
95
|
+
const startDate = this.value[0] || new Date()
|
|
96
|
+
this.leftViewDate = new Date(startDate)
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 辅助函数:判断两个日期是否在同一个月
|
|
101
|
+
*/
|
|
102
|
+
isSameMonth(d1, d2) {
|
|
103
|
+
if (!d1 || !d2) return false
|
|
104
|
+
return d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth()
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* 处理日期点击
|
|
109
|
+
*/
|
|
110
|
+
handlePick(date) {
|
|
111
|
+
if (!this.selecting) {
|
|
112
|
+
// 第一步:选择起点
|
|
113
|
+
this.selecting = true
|
|
114
|
+
this.tempStart = date
|
|
115
|
+
this.hoverDate = date
|
|
116
|
+
} else {
|
|
117
|
+
// 第二步:选择终点
|
|
118
|
+
let start = this.tempStart
|
|
119
|
+
let end = date
|
|
120
|
+
|
|
121
|
+
// 确保 start <= end
|
|
122
|
+
if (start.getTime() > end.getTime()) {
|
|
123
|
+
;[start, end] = [end, start]
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const newRange = [start, end]
|
|
127
|
+
this.$emit('input', newRange)
|
|
128
|
+
this.$emit('pick', newRange)
|
|
129
|
+
|
|
130
|
+
// 重置选择状态
|
|
131
|
+
this.selecting = false
|
|
132
|
+
this.tempStart = null
|
|
133
|
+
this.hoverDate = null
|
|
134
|
+
|
|
135
|
+
// 【核心修改】智能调整视图
|
|
136
|
+
// 获取当前的右面板视图月份
|
|
137
|
+
const currentRightView = this.rightViewDate
|
|
138
|
+
|
|
139
|
+
// 如果结束日期 (end) 落在当前右面板显示的月份内
|
|
140
|
+
// 则保持左面板视图不变,这样右面板也保持不变,用户能直接看到刚才选的结束日期
|
|
141
|
+
if (this.isSameMonth(end, currentRightView)) {
|
|
142
|
+
// 不做任何操作,保持 this.leftViewDate 不变
|
|
143
|
+
return
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 其他情况(例如结束日期不在当前右面板月份,或者跨了多个月等)
|
|
147
|
+
// 恢复默认行为:让左面板显示开始日期的月份,以便完整展示范围起点
|
|
148
|
+
this.leftViewDate = new Date(start)
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* 处理鼠标悬停
|
|
154
|
+
*/
|
|
155
|
+
handleHover(date) {
|
|
156
|
+
if (this.selecting) {
|
|
157
|
+
this.hoverDate = date
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
handleClose(mouseup, mousedown) {
|
|
161
|
+
// 获取点击的元素
|
|
162
|
+
const target = mousedown.target
|
|
163
|
+
// 获取点击的元素是否在父触发器内
|
|
164
|
+
const clickParentTrigger = this.$parent.$el.contains(target)
|
|
165
|
+
!clickParentTrigger && this.$emit('close')
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* 左面板视图改变
|
|
170
|
+
* 直接更新 leftViewDate,rightViewDate 会通过 computed 自动更新
|
|
171
|
+
*/
|
|
172
|
+
handleLeftViewChange(date) {
|
|
173
|
+
this.leftViewDate = date
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* 右面板视图改变
|
|
178
|
+
* 当用户在右面板点击“上个月”或“下个月”时,
|
|
179
|
+
* 我们需要反向推算出 leftViewDate 应该是多少。
|
|
180
|
+
*
|
|
181
|
+
* 右面板显示的是 rightViewDate (即 left + 1)
|
|
182
|
+
* 如果右面板变成了 newDate,那么左面板应该变成 newDate - 1
|
|
183
|
+
*/
|
|
184
|
+
handleRightViewChange(date) {
|
|
185
|
+
const newLeftDate = new Date(date)
|
|
186
|
+
newLeftDate.setMonth(newLeftDate.getMonth() - 1)
|
|
187
|
+
this.leftViewDate = newLeftDate
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
}
|
|
191
|
+
</script>
|
|
192
|
+
|
|
193
|
+
<style lang="scss" scoped></style>
|