rw-admin-ui 1.0.0
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/LICENSE +21 -0
- package/README.md +148 -0
- package/package.json +176 -0
- package/packages/alert/index.js +8 -0
- package/packages/alert/src/main.vue +94 -0
- package/packages/api-cascader/index.js +7 -0
- package/packages/api-cascader/src/api-cascader.vue +80 -0
- package/packages/api-select/index.js +7 -0
- package/packages/api-select/src/api-select.vue +226 -0
- package/packages/api-tree/index.js +7 -0
- package/packages/api-tree/src/api-tree.vue +130 -0
- package/packages/aside/index.js +8 -0
- package/packages/aside/src/main.vue +20 -0
- package/packages/autocomplete/index.js +8 -0
- package/packages/autocomplete/src/autocomplete-suggestions.vue +77 -0
- package/packages/autocomplete/src/autocomplete.vue +285 -0
- package/packages/avatar/index.js +8 -0
- package/packages/avatar/src/main.vue +107 -0
- package/packages/backtop/index.js +8 -0
- package/packages/backtop/src/main.vue +110 -0
- package/packages/badge/index.js +8 -0
- package/packages/badge/src/main.vue +53 -0
- package/packages/basic-form/basic-form-dataflow.md +136 -0
- package/packages/basic-form/index.js +12 -0
- package/packages/basic-form/src/basic-form-action.vue +71 -0
- package/packages/basic-form/src/basic-form-item.vue +179 -0
- package/packages/basic-form/src/basic-form-plain.vue +82 -0
- package/packages/basic-form/src/basic-form-sections.vue +426 -0
- package/packages/basic-form/src/basic-form.vue +48 -0
- package/packages/basic-form/src/components/render-vnode.js +21 -0
- package/packages/basic-form/src/mixins/basic-form-item.js +326 -0
- package/packages/basic-form/src/mixins/basic-form-runtime-factory.js +352 -0
- package/packages/basic-form/src/mixins/basic-form-runtime-sections.js +13 -0
- package/packages/basic-form/src/mixins/basic-form-runtime.js +12 -0
- package/packages/basic-form/src/mixins/basic-form-view.js +180 -0
- package/packages/basic-form/src/mixins/normalize-schemas-with-sections.js +52 -0
- package/packages/basic-table/index.js +7 -0
- package/packages/basic-table/src/actions.js +256 -0
- package/packages/basic-table/src/basic-table-column.vue +264 -0
- package/packages/basic-table/src/basic-table.vue +336 -0
- package/packages/basic-table/src/mixins/actions-context.js +47 -0
- package/packages/basic-table/src/mixins/fetch.js +117 -0
- package/packages/basic-table/src/mixins/form.js +29 -0
- package/packages/basic-table/src/mixins/pagination.js +57 -0
- package/packages/basic-table/src/mixins/watchers.js +60 -0
- package/packages/basic-table/src/overflow-cell.js +35 -0
- package/packages/basic-table/src/table-action.vue +66 -0
- package/packages/basic-table/src/utils.js +161 -0
- package/packages/basic-table-column/index.js +7 -0
- package/packages/breadcrumb/index.js +8 -0
- package/packages/breadcrumb/src/breadcrumb-item.vue +44 -0
- package/packages/breadcrumb/src/breadcrumb.vue +34 -0
- package/packages/breadcrumb-item/index.js +8 -0
- package/packages/button/index.js +8 -0
- package/packages/button/src/button-group.vue +10 -0
- package/packages/button/src/button.vue +79 -0
- package/packages/button-group/index.js +8 -0
- package/packages/calendar/index.js +8 -0
- package/packages/calendar/src/date-table.vue +200 -0
- package/packages/calendar/src/main.vue +280 -0
- package/packages/card/index.js +8 -0
- package/packages/card/src/main.vue +23 -0
- package/packages/carousel/index.js +8 -0
- package/packages/carousel/src/item.vue +138 -0
- package/packages/carousel/src/main.vue +315 -0
- package/packages/carousel-item/index.js +8 -0
- package/packages/cascader/index.js +8 -0
- package/packages/cascader/src/cascader.vue +664 -0
- package/packages/cascader-panel/index.js +8 -0
- package/packages/cascader-panel/src/cascader-menu.vue +138 -0
- package/packages/cascader-panel/src/cascader-node.vue +247 -0
- package/packages/cascader-panel/src/cascader-panel.vue +392 -0
- package/packages/cascader-panel/src/node.js +166 -0
- package/packages/cascader-panel/src/store.js +58 -0
- package/packages/checkbox/index.js +8 -0
- package/packages/checkbox/src/checkbox-button.vue +200 -0
- package/packages/checkbox/src/checkbox-group.vue +48 -0
- package/packages/checkbox/src/checkbox.vue +226 -0
- package/packages/checkbox-button/index.js +8 -0
- package/packages/checkbox-group/index.js +8 -0
- package/packages/col/index.js +9 -0
- package/packages/col/src/col.js +71 -0
- package/packages/collapse/index.js +9 -0
- package/packages/collapse/src/collapse-item.vue +115 -0
- package/packages/collapse/src/collapse.vue +73 -0
- package/packages/collapse-item/index.js +8 -0
- package/packages/color-picker/index.js +8 -0
- package/packages/color-picker/src/color.js +317 -0
- package/packages/color-picker/src/components/alpha-slider.vue +135 -0
- package/packages/color-picker/src/components/hue-slider.vue +125 -0
- package/packages/color-picker/src/components/picker-dropdown.vue +122 -0
- package/packages/color-picker/src/components/predefine.vue +62 -0
- package/packages/color-picker/src/components/sv-panel.vue +103 -0
- package/packages/color-picker/src/draggable.js +36 -0
- package/packages/color-picker/src/main.vue +308 -0
- package/packages/container/index.js +8 -0
- package/packages/container/src/main.vue +33 -0
- package/packages/date-picker/REFACTOR-TASKS.md +63 -0
- package/packages/date-picker/index.js +8 -0
- package/packages/date-picker/src/basic/date-table.vue +546 -0
- package/packages/date-picker/src/basic/month-table.vue +284 -0
- package/packages/date-picker/src/basic/quarter-table.vue +229 -0
- package/packages/date-picker/src/basic/time-spinner.vue +308 -0
- package/packages/date-picker/src/basic/year-table.vue +236 -0
- package/packages/date-picker/src/panel/date-range.vue +777 -0
- package/packages/date-picker/src/panel/date-time-range.vue +731 -0
- package/packages/date-picker/src/panel/date-time.vue +232 -0
- package/packages/date-picker/src/panel/date.vue +775 -0
- package/packages/date-picker/src/panel/month-range.vue +533 -0
- package/packages/date-picker/src/panel/month.vue +203 -0
- package/packages/date-picker/src/panel/quarter-range.vue +363 -0
- package/packages/date-picker/src/panel/quarter.vue +193 -0
- package/packages/date-picker/src/panel/time-range.vue +246 -0
- package/packages/date-picker/src/panel/time-select.vue +179 -0
- package/packages/date-picker/src/panel/time.vue +177 -0
- package/packages/date-picker/src/panel/week-range.vue +666 -0
- package/packages/date-picker/src/panel/year-range.vue +374 -0
- package/packages/date-picker/src/panel/year.vue +169 -0
- package/packages/date-picker/src/picker/date-picker.vue +166 -0
- package/packages/date-picker/src/picker/picker-mixin.js +1245 -0
- package/packages/date-picker/src/picker/range-picker.vue +377 -0
- package/packages/date-picker/src/picker/time-picker.vue +146 -0
- package/packages/date-picker/src/picker/time-select.vue +65 -0
- package/packages/descriptions/index.js +8 -0
- package/packages/descriptions/src/descriptions-item.js +30 -0
- package/packages/descriptions/src/descriptions-row.js +116 -0
- package/packages/descriptions/src/index.js +180 -0
- package/packages/descriptions-item/index.js +8 -0
- package/packages/dialog/index.js +8 -0
- package/packages/dialog/src/component.vue +212 -0
- package/packages/divider/index.js +8 -0
- package/packages/divider/src/main.vue +42 -0
- package/packages/drawer/index.js +8 -0
- package/packages/drawer/src/main.vue +205 -0
- package/packages/dropdown/index.js +8 -0
- package/packages/dropdown/src/dropdown-item.vue +40 -0
- package/packages/dropdown/src/dropdown-menu.vue +63 -0
- package/packages/dropdown/src/dropdown.vue +294 -0
- package/packages/dropdown-item/index.js +8 -0
- package/packages/dropdown-menu/index.js +8 -0
- package/packages/empty/index.js +7 -0
- package/packages/empty/src/img-empty.vue +132 -0
- package/packages/empty/src/index.vue +50 -0
- package/packages/footer/index.js +8 -0
- package/packages/footer/src/main.vue +20 -0
- package/packages/form/index.js +8 -0
- package/packages/form/src/form-item.vue +346 -0
- package/packages/form/src/form.vue +184 -0
- package/packages/form/src/label-wrap.vue +78 -0
- package/packages/form-item/index.js +8 -0
- package/packages/header/index.js +8 -0
- package/packages/header/src/main.vue +20 -0
- package/packages/icon/index.js +8 -0
- package/packages/icon/src/icon.vue +13 -0
- package/packages/image/index.js +8 -0
- package/packages/image/src/image-viewer.vue +330 -0
- package/packages/image/src/main.vue +249 -0
- package/packages/infinite-scroll/index.js +8 -0
- package/packages/infinite-scroll/src/main.js +150 -0
- package/packages/input/index.js +8 -0
- package/packages/input/src/calcTextareaHeight.js +104 -0
- package/packages/input/src/input.vue +446 -0
- package/packages/input-number/index.js +8 -0
- package/packages/input-number/src/input-number.vue +282 -0
- package/packages/link/index.js +8 -0
- package/packages/link/src/main.vue +53 -0
- package/packages/loading/index.js +11 -0
- package/packages/loading/src/directive.js +133 -0
- package/packages/loading/src/index.js +106 -0
- package/packages/loading/src/loading.vue +41 -0
- package/packages/main/index.js +8 -0
- package/packages/main/src/main.vue +12 -0
- package/packages/menu/index.js +8 -0
- package/packages/menu/src/menu-item-group.vue +45 -0
- package/packages/menu/src/menu-item.vue +113 -0
- package/packages/menu/src/menu-mixin.js +44 -0
- package/packages/menu/src/menu.vue +325 -0
- package/packages/menu/src/submenu.vue +349 -0
- package/packages/menu-item/index.js +8 -0
- package/packages/menu-item-group/index.js +8 -0
- package/packages/message/index.js +2 -0
- package/packages/message/src/main.js +91 -0
- package/packages/message/src/main.vue +117 -0
- package/packages/message-box/index.js +2 -0
- package/packages/message-box/src/main.js +216 -0
- package/packages/message-box/src/main.vue +337 -0
- package/packages/notification/index.js +2 -0
- package/packages/notification/src/main.js +94 -0
- package/packages/notification/src/main.vue +152 -0
- package/packages/option/index.js +8 -0
- package/packages/option-group/index.js +8 -0
- package/packages/page-header/index.js +8 -0
- package/packages/page-header/src/main.vue +30 -0
- package/packages/pagination/index.js +8 -0
- package/packages/pagination/src/pager.vue +198 -0
- package/packages/pagination/src/pagination.js +386 -0
- package/packages/popconfirm/index.js +8 -0
- package/packages/popconfirm/src/main.vue +108 -0
- package/packages/popover/index.js +14 -0
- package/packages/popover/src/directive.js +20 -0
- package/packages/popover/src/main.vue +242 -0
- package/packages/progress/index.js +8 -0
- package/packages/progress/src/progress.vue +235 -0
- package/packages/radio/index.js +8 -0
- package/packages/radio/src/radio-button.vue +118 -0
- package/packages/radio/src/radio-group.vue +131 -0
- package/packages/radio/src/radio.vue +137 -0
- package/packages/radio-button/index.js +8 -0
- package/packages/radio-group/index.js +8 -0
- package/packages/range-picker/index.js +8 -0
- package/packages/rate/index.js +8 -0
- package/packages/rate/src/main.vue +348 -0
- package/packages/result/index.js +8 -0
- package/packages/result/src/icon-error.vue +13 -0
- package/packages/result/src/icon-info.vue +13 -0
- package/packages/result/src/icon-success.vue +13 -0
- package/packages/result/src/icon-warning.vue +13 -0
- package/packages/result/src/index.vue +65 -0
- package/packages/row/index.js +9 -0
- package/packages/row/src/row.js +44 -0
- package/packages/scrollbar/index.js +8 -0
- package/packages/scrollbar/src/bar.js +92 -0
- package/packages/scrollbar/src/main.js +130 -0
- package/packages/scrollbar/src/util.js +34 -0
- package/packages/select/index.js +8 -0
- package/packages/select/src/navigation-mixin.js +54 -0
- package/packages/select/src/option-group.vue +60 -0
- package/packages/select/src/option.vue +169 -0
- package/packages/select/src/select-dropdown.vue +78 -0
- package/packages/select/src/select.vue +901 -0
- package/packages/skeleton/index.js +8 -0
- package/packages/skeleton/src/img-placeholder.vue +16 -0
- package/packages/skeleton/src/index.vue +76 -0
- package/packages/skeleton/src/item.vue +22 -0
- package/packages/skeleton-item/index.js +8 -0
- package/packages/slider/index.js +8 -0
- package/packages/slider/src/button.vue +238 -0
- package/packages/slider/src/main.vue +425 -0
- package/packages/slider/src/marker.js +18 -0
- package/packages/spinner/index.js +8 -0
- package/packages/spinner/src/spinner.vue +27 -0
- package/packages/statistic/index.js +8 -0
- package/packages/statistic/src/main.vue +204 -0
- package/packages/step/index.js +8 -0
- package/packages/steps/README.md +69 -0
- package/packages/steps/index.js +8 -0
- package/packages/steps/src/step.vue +184 -0
- package/packages/steps/src/steps.vue +68 -0
- package/packages/submenu/index.js +8 -0
- package/packages/switch/index.js +9 -0
- package/packages/switch/src/component.vue +174 -0
- package/packages/tab-pane/index.js +8 -0
- package/packages/table/index.js +8 -0
- package/packages/table/src/config.js +124 -0
- package/packages/table/src/dropdown.js +28 -0
- package/packages/table/src/filter-panel.vue +197 -0
- package/packages/table/src/layout-observer.js +68 -0
- package/packages/table/src/store/current.js +76 -0
- package/packages/table/src/store/expand.js +65 -0
- package/packages/table/src/store/helper.js +41 -0
- package/packages/table/src/store/index.js +147 -0
- package/packages/table/src/store/tree.js +209 -0
- package/packages/table/src/store/watcher.js +381 -0
- package/packages/table/src/table-body.js +469 -0
- package/packages/table/src/table-column.js +319 -0
- package/packages/table/src/table-footer.js +153 -0
- package/packages/table/src/table-header.js +511 -0
- package/packages/table/src/table-layout.js +249 -0
- package/packages/table/src/table-row.js +101 -0
- package/packages/table/src/table.vue +707 -0
- package/packages/table/src/util.js +273 -0
- package/packages/table-action/index.js +7 -0
- package/packages/table-column/index.js +8 -0
- package/packages/tabs/index.js +8 -0
- package/packages/tabs/src/tab-bar.vue +57 -0
- package/packages/tabs/src/tab-nav.vue +294 -0
- package/packages/tabs/src/tab-pane.vue +61 -0
- package/packages/tabs/src/tabs.vue +193 -0
- package/packages/tag/index.js +8 -0
- package/packages/tag/src/tag.vue +58 -0
- package/packages/theme-chalk/README.md +33 -0
- package/packages/theme-chalk/gulpfile.js +25 -0
- package/packages/theme-chalk/package.json +35 -0
- package/packages/theme-chalk/src/alert.scss +151 -0
- package/packages/theme-chalk/src/api-cascader.scss +0 -0
- package/packages/theme-chalk/src/api-select.scss +7 -0
- package/packages/theme-chalk/src/api-tree.scss +0 -0
- package/packages/theme-chalk/src/aside.scss +7 -0
- package/packages/theme-chalk/src/autocomplete.scss +80 -0
- package/packages/theme-chalk/src/avatar.scss +51 -0
- package/packages/theme-chalk/src/backtop.scss +22 -0
- package/packages/theme-chalk/src/badge.scss +57 -0
- package/packages/theme-chalk/src/base.scss +2 -0
- package/packages/theme-chalk/src/basic-form.scss +29 -0
- package/packages/theme-chalk/src/basic-table-column.scss +0 -0
- package/packages/theme-chalk/src/basic-table.scss +120 -0
- package/packages/theme-chalk/src/breadcrumb-item.scss +0 -0
- package/packages/theme-chalk/src/breadcrumb.scss +59 -0
- package/packages/theme-chalk/src/button-group.scss +0 -0
- package/packages/theme-chalk/src/button.scss +306 -0
- package/packages/theme-chalk/src/calendar.scss +82 -0
- package/packages/theme-chalk/src/card.scss +35 -0
- package/packages/theme-chalk/src/carousel-item.scss +50 -0
- package/packages/theme-chalk/src/carousel.scss +161 -0
- package/packages/theme-chalk/src/cascader-panel.scss +124 -0
- package/packages/theme-chalk/src/cascader.scss +183 -0
- package/packages/theme-chalk/src/checkbox-button.scss +120 -0
- package/packages/theme-chalk/src/checkbox-group.scss +6 -0
- package/packages/theme-chalk/src/checkbox.scss +293 -0
- package/packages/theme-chalk/src/col.scss +156 -0
- package/packages/theme-chalk/src/collapse-item.scss +0 -0
- package/packages/theme-chalk/src/collapse.scss +63 -0
- package/packages/theme-chalk/src/color-picker.scss +431 -0
- package/packages/theme-chalk/src/common/popup.scss +42 -0
- package/packages/theme-chalk/src/common/transition.scss +120 -0
- package/packages/theme-chalk/src/common/var.scss +1569 -0
- package/packages/theme-chalk/src/container.scss +14 -0
- package/packages/theme-chalk/src/date-picker/common/picker-panel.scss +143 -0
- package/packages/theme-chalk/src/date-picker/common/picker.scss +235 -0
- package/packages/theme-chalk/src/date-picker/day/date-picker.scss +104 -0
- package/packages/theme-chalk/src/date-picker/day/date-range-picker.scss +162 -0
- package/packages/theme-chalk/src/date-picker/day/date-table.scss +212 -0
- package/packages/theme-chalk/src/date-picker/month/month-table.scss +133 -0
- package/packages/theme-chalk/src/date-picker/quarter/quarter-table.scss +106 -0
- package/packages/theme-chalk/src/date-picker/time/time-picker.scss +86 -0
- package/packages/theme-chalk/src/date-picker/time/time-range-picker.scss +32 -0
- package/packages/theme-chalk/src/date-picker/time/time-spinner.scss +110 -0
- package/packages/theme-chalk/src/date-picker/year/year-table.scss +143 -0
- package/packages/theme-chalk/src/date-picker.scss +26 -0
- package/packages/theme-chalk/src/descriptions-item.scss +45 -0
- package/packages/theme-chalk/src/descriptions.scss +112 -0
- package/packages/theme-chalk/src/dialog.scss +132 -0
- package/packages/theme-chalk/src/display.scss +12 -0
- package/packages/theme-chalk/src/divider.scss +47 -0
- package/packages/theme-chalk/src/drawer.scss +229 -0
- package/packages/theme-chalk/src/dropdown-item.scss +0 -0
- package/packages/theme-chalk/src/dropdown-menu.scss +0 -0
- package/packages/theme-chalk/src/dropdown.scss +209 -0
- package/packages/theme-chalk/src/empty.scss +45 -0
- package/packages/theme-chalk/src/fonts/element-icons.ttf +0 -0
- package/packages/theme-chalk/src/fonts/element-icons.woff +0 -0
- package/packages/theme-chalk/src/footer.scss +8 -0
- package/packages/theme-chalk/src/form-item.scss +0 -0
- package/packages/theme-chalk/src/form.scss +192 -0
- package/packages/theme-chalk/src/header.scss +8 -0
- package/packages/theme-chalk/src/icon.scss +1182 -0
- package/packages/theme-chalk/src/image.scss +179 -0
- package/packages/theme-chalk/src/index.scss +95 -0
- package/packages/theme-chalk/src/infinite-scroll.scss +0 -0
- package/packages/theme-chalk/src/infiniteScroll.scss +0 -0
- package/packages/theme-chalk/src/input-number.scss +187 -0
- package/packages/theme-chalk/src/input.scss +365 -0
- package/packages/theme-chalk/src/link.scss +81 -0
- package/packages/theme-chalk/src/loading.scss +109 -0
- package/packages/theme-chalk/src/main.scss +12 -0
- package/packages/theme-chalk/src/menu-item-group.scss +0 -0
- package/packages/theme-chalk/src/menu-item.scss +0 -0
- package/packages/theme-chalk/src/menu.scss +317 -0
- package/packages/theme-chalk/src/message-box.scss +231 -0
- package/packages/theme-chalk/src/message.scss +123 -0
- package/packages/theme-chalk/src/mixins/_button.scss +81 -0
- package/packages/theme-chalk/src/mixins/config.scss +4 -0
- package/packages/theme-chalk/src/mixins/function.scss +44 -0
- package/packages/theme-chalk/src/mixins/mixins.scss +190 -0
- package/packages/theme-chalk/src/mixins/utils.scss +39 -0
- package/packages/theme-chalk/src/notification.scss +100 -0
- package/packages/theme-chalk/src/option-group.scss +42 -0
- package/packages/theme-chalk/src/option.scss +36 -0
- package/packages/theme-chalk/src/page-header.scss +42 -0
- package/packages/theme-chalk/src/pagination.scss +334 -0
- package/packages/theme-chalk/src/popconfirm.scss +16 -0
- package/packages/theme-chalk/src/popover.scss +40 -0
- package/packages/theme-chalk/src/popper.scss +159 -0
- package/packages/theme-chalk/src/progress.scss +141 -0
- package/packages/theme-chalk/src/radio-button.scss +118 -0
- package/packages/theme-chalk/src/radio-group.scss +9 -0
- package/packages/theme-chalk/src/radio.scss +384 -0
- package/packages/theme-chalk/src/range-picker.scss +0 -0
- package/packages/theme-chalk/src/rate.scss +49 -0
- package/packages/theme-chalk/src/reset.scss +79 -0
- package/packages/theme-chalk/src/result.scss +61 -0
- package/packages/theme-chalk/src/row.scss +43 -0
- package/packages/theme-chalk/src/scrollbar.scss +72 -0
- package/packages/theme-chalk/src/select-dropdown.scss +62 -0
- package/packages/theme-chalk/src/select.scss +153 -0
- package/packages/theme-chalk/src/skeleton-item.scss +84 -0
- package/packages/theme-chalk/src/skeleton.scss +40 -0
- package/packages/theme-chalk/src/slider.scss +250 -0
- package/packages/theme-chalk/src/spinner.scss +44 -0
- package/packages/theme-chalk/src/statistic.scss +46 -0
- package/packages/theme-chalk/src/step.scss +317 -0
- package/packages/theme-chalk/src/steps.scss +22 -0
- package/packages/theme-chalk/src/submenu.scss +0 -0
- package/packages/theme-chalk/src/switch.scss +122 -0
- package/packages/theme-chalk/src/tab-pane.scss +0 -0
- package/packages/theme-chalk/src/table-action.scss +0 -0
- package/packages/theme-chalk/src/table-column.scss +97 -0
- package/packages/theme-chalk/src/table.scss +577 -0
- package/packages/theme-chalk/src/tabs.scss +671 -0
- package/packages/theme-chalk/src/tag.scss +168 -0
- package/packages/theme-chalk/src/time-picker.scss +8 -0
- package/packages/theme-chalk/src/time-select.scss +37 -0
- package/packages/theme-chalk/src/timeline-item.scss +92 -0
- package/packages/theme-chalk/src/timeline.scss +14 -0
- package/packages/theme-chalk/src/tooltip.scss +141 -0
- package/packages/theme-chalk/src/transfer.scss +238 -0
- package/packages/theme-chalk/src/tree.scss +130 -0
- package/packages/theme-chalk/src/upload.scss +621 -0
- package/packages/time-picker/index.js +8 -0
- package/packages/time-select/index.js +8 -0
- package/packages/timeline/index.js +8 -0
- package/packages/timeline/src/item.vue +77 -0
- package/packages/timeline/src/main.vue +33 -0
- package/packages/timeline-item/index.js +8 -0
- package/packages/tooltip/index.js +8 -0
- package/packages/tooltip/src/main.js +242 -0
- package/packages/transfer/index.js +8 -0
- package/packages/transfer/src/main.vue +233 -0
- package/packages/transfer/src/transfer-panel.vue +252 -0
- package/packages/tree/index.js +8 -0
- package/packages/tree/src/model/node.js +484 -0
- package/packages/tree/src/model/tree-store.js +340 -0
- package/packages/tree/src/model/util.js +27 -0
- package/packages/tree/src/tree-node.vue +281 -0
- package/packages/tree/src/tree.vue +496 -0
- package/packages/upload/index.js +8 -0
- package/packages/upload/src/ajax.js +85 -0
- package/packages/upload/src/index.vue +338 -0
- package/packages/upload/src/upload-dragger.vue +70 -0
- package/packages/upload/src/upload-list.vue +106 -0
- package/packages/upload/src/upload.vue +211 -0
- package/src/directives/mousewheel.js +18 -0
- package/src/directives/repeat-click.js +26 -0
- package/src/index.js +333 -0
- package/src/locale/format.js +46 -0
- package/src/locale/index.js +48 -0
- package/src/locale/lang/af-ZA.js +123 -0
- package/src/locale/lang/ar.js +122 -0
- package/src/locale/lang/az.js +126 -0
- package/src/locale/lang/bg.js +123 -0
- package/src/locale/lang/bn.js +126 -0
- package/src/locale/lang/ca.js +122 -0
- package/src/locale/lang/cs-CZ.js +125 -0
- package/src/locale/lang/da.js +122 -0
- package/src/locale/lang/de.js +124 -0
- package/src/locale/lang/ee.js +123 -0
- package/src/locale/lang/el.js +123 -0
- package/src/locale/lang/en.js +123 -0
- package/src/locale/lang/eo.js +123 -0
- package/src/locale/lang/es.js +122 -0
- package/src/locale/lang/eu.js +123 -0
- package/src/locale/lang/fa.js +123 -0
- package/src/locale/lang/fi.js +123 -0
- package/src/locale/lang/fr.js +122 -0
- package/src/locale/lang/he.js +123 -0
- package/src/locale/lang/hr.js +123 -0
- package/src/locale/lang/hu.js +122 -0
- package/src/locale/lang/hy-AM.js +123 -0
- package/src/locale/lang/id.js +123 -0
- package/src/locale/lang/is.js +124 -0
- package/src/locale/lang/it.js +122 -0
- package/src/locale/lang/ja.js +123 -0
- package/src/locale/lang/kg.js +123 -0
- package/src/locale/lang/km.js +123 -0
- package/src/locale/lang/ko.js +123 -0
- package/src/locale/lang/ku.js +123 -0
- package/src/locale/lang/kz.js +123 -0
- package/src/locale/lang/lo-LA.js +126 -0
- package/src/locale/lang/lt.js +123 -0
- package/src/locale/lang/lv.js +123 -0
- package/src/locale/lang/mn.js +123 -0
- package/src/locale/lang/ms.js +122 -0
- package/src/locale/lang/nb-NO.js +122 -0
- package/src/locale/lang/nl.js +123 -0
- package/src/locale/lang/pl.js +123 -0
- package/src/locale/lang/pt-br.js +123 -0
- package/src/locale/lang/pt.js +123 -0
- package/src/locale/lang/ro.js +123 -0
- package/src/locale/lang/ru-RU.js +123 -0
- package/src/locale/lang/si.js +123 -0
- package/src/locale/lang/sk.js +125 -0
- package/src/locale/lang/sl.js +123 -0
- package/src/locale/lang/sr-Latn.js +123 -0
- package/src/locale/lang/sr.js +123 -0
- package/src/locale/lang/sv-SE.js +123 -0
- package/src/locale/lang/sw.js +123 -0
- package/src/locale/lang/ta.js +122 -0
- package/src/locale/lang/th.js +123 -0
- package/src/locale/lang/tk.js +123 -0
- package/src/locale/lang/tr-TR.js +123 -0
- package/src/locale/lang/ua.js +123 -0
- package/src/locale/lang/ug-CN.js +123 -0
- package/src/locale/lang/uz-UZ.js +123 -0
- package/src/locale/lang/vi.js +123 -0
- package/src/locale/lang/zh-CN.js +131 -0
- package/src/locale/lang/zh-TW.js +123 -0
- package/src/mixins/emitter.js +33 -0
- package/src/mixins/focus.js +9 -0
- package/src/mixins/locale.js +9 -0
- package/src/mixins/migrating.js +54 -0
- package/src/transitions/collapse-transition.js +77 -0
- package/src/utils/after-leave.js +27 -0
- package/src/utils/aria-dialog.js +90 -0
- package/src/utils/aria-utils.js +122 -0
- package/src/utils/clickoutside.js +76 -0
- package/src/utils/date-util.js +282 -0
- package/src/utils/date.js +392 -0
- package/src/utils/dom.js +227 -0
- package/src/utils/lodash.js +18075 -0
- package/src/utils/menu/aria-menubar.js +14 -0
- package/src/utils/menu/aria-menuitem.js +49 -0
- package/src/utils/menu/aria-submenu.js +59 -0
- package/src/utils/merge.js +15 -0
- package/src/utils/popper.js +1276 -0
- package/src/utils/popup/index.js +218 -0
- package/src/utils/popup/popup-manager.js +194 -0
- package/src/utils/resize-event.js +36 -0
- package/src/utils/scroll-into-view.js +27 -0
- package/src/utils/scrollbar-width.js +29 -0
- package/src/utils/shared.js +7 -0
- package/src/utils/types.js +40 -0
- package/src/utils/util.js +245 -0
- package/src/utils/vdom.js +5 -0
- package/src/utils/vue-popper.js +198 -0
- package/types/alert.d.ts +31 -0
- package/types/api-cascader.d.ts +10 -0
- package/types/api-select.d.ts +13 -0
- package/types/api-tree.d.ts +10 -0
- package/types/aside.d.ts +7 -0
- package/types/autocomplete.d.ts +78 -0
- package/types/avatar.d.ts +20 -0
- package/types/backtop.d.ts +16 -0
- package/types/badge.d.ts +16 -0
- package/types/basic-form.d.ts +50 -0
- package/types/basic-table.d.ts +3 -0
- package/types/breadcrumb-item.d.ts +10 -0
- package/types/breadcrumb.d.ts +10 -0
- package/types/button-group.d.ts +4 -0
- package/types/button.d.ts +37 -0
- package/types/calendar.d.ts +15 -0
- package/types/card.d.ts +26 -0
- package/types/carousel-item.d.ts +10 -0
- package/types/carousel.d.ts +57 -0
- package/types/cascader-panel.d.ts +72 -0
- package/types/cascader.d.ts +65 -0
- package/types/checkbox-button.d.ts +22 -0
- package/types/checkbox-group.d.ts +22 -0
- package/types/checkbox.d.ts +34 -0
- package/types/col.d.ts +46 -0
- package/types/collapse-item.d.ts +26 -0
- package/types/collapse.d.ts +10 -0
- package/types/color-picker.d.ts +28 -0
- package/types/component.d.ts +13 -0
- package/types/container.d.ts +7 -0
- package/types/date-picker.d.ts +124 -0
- package/types/descriptions-item.d.ts +37 -0
- package/types/descriptions.d.ts +52 -0
- package/types/dialog.d.ts +62 -0
- package/types/divider.d.ts +12 -0
- package/types/drawer.d.ts +63 -0
- package/types/dropdown-item.d.ts +16 -0
- package/types/dropdown-menu.d.ts +4 -0
- package/types/dropdown.d.ts +38 -0
- package/types/empty.d.ts +31 -0
- package/types/footer.d.ts +7 -0
- package/types/form-item.d.ts +40 -0
- package/types/form.d.ts +82 -0
- package/types/header.d.ts +7 -0
- package/types/icon.d.ts +7 -0
- package/types/image.d.ts +43 -0
- package/types/index.d.ts +4 -0
- package/types/infinite-scroll.d.ts +6 -0
- package/types/input-number.d.ts +47 -0
- package/types/input.d.ts +107 -0
- package/types/link.d.ts +25 -0
- package/types/loading.d.ts +62 -0
- package/types/main.d.ts +4 -0
- package/types/menu-item-group.d.ts +7 -0
- package/types/menu-item.d.ts +10 -0
- package/types/menu.d.ts +46 -0
- package/types/message-box.d.ts +176 -0
- package/types/message.d.ts +90 -0
- package/types/notification.d.ts +84 -0
- package/types/option-group.d.ts +10 -0
- package/types/option.d.ts +13 -0
- package/types/page-header.d.ts +10 -0
- package/types/pagination.d.ts +43 -0
- package/types/popconfirm.d.ts +29 -0
- package/types/popover.d.ts +71 -0
- package/types/progress.d.ts +37 -0
- package/types/radio-button.d.ts +16 -0
- package/types/radio-group.d.ts +18 -0
- package/types/radio.d.ts +19 -0
- package/types/rate.d.ts +64 -0
- package/types/result.d.ts +33 -0
- package/types/row.d.ts +25 -0
- package/types/rowinself-ui.d.ts +400 -0
- package/types/scrollbar.d.ts +12 -0
- package/types/select.d.ts +90 -0
- package/types/skeleton-item.d.ts +7 -0
- package/types/skeleton.d.ts +33 -0
- package/types/slider.d.ts +68 -0
- package/types/spinner.d.ts +16 -0
- package/types/statistic.d.ts +37 -0
- package/types/step.d.ts +34 -0
- package/types/steps.d.ts +28 -0
- package/types/submenu.d.ts +22 -0
- package/types/switch.d.ts +43 -0
- package/types/tab-pane.d.ts +19 -0
- package/types/table-column.d.ts +117 -0
- package/types/table.d.ts +177 -0
- package/types/tabs.d.ts +31 -0
- package/types/tag.d.ts +28 -0
- package/types/time-picker.d.ts +63 -0
- package/types/time-select.d.ts +56 -0
- package/types/timeline-item.d.ts +20 -0
- package/types/timeline.d.ts +6 -0
- package/types/tooltip.d.ts +52 -0
- package/types/transfer.d.ts +73 -0
- package/types/tree.d.ts +266 -0
- package/types/upload.d.ts +124 -0
- package/web-types.json +4195 -0
|
@@ -0,0 +1,1245 @@
|
|
|
1
|
+
|
|
2
|
+
import Vue from 'vue';
|
|
3
|
+
import Clickoutside from 'rowinself-ui/src/utils/clickoutside';
|
|
4
|
+
import { formatDate, parseDate, isDateObject, getWeekNumber } from 'rowinself-ui/src/utils/date-util';
|
|
5
|
+
import Popper from 'rowinself-ui/src/utils/vue-popper';
|
|
6
|
+
import Emitter from 'rowinself-ui/src/mixins/emitter';
|
|
7
|
+
import merge from 'rowinself-ui/src/utils/merge';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* PickerMixin
|
|
11
|
+
*
|
|
12
|
+
* 日期选择器的核心混入对象
|
|
13
|
+
* 负责处理选择器的通用逻辑,包括:
|
|
14
|
+
* 1. 弹出层的管理(显示/隐藏、定位)
|
|
15
|
+
* 2. 值的解析与格式化
|
|
16
|
+
* 3. 输入框的事件处理(聚焦、失焦、键盘事件)
|
|
17
|
+
* 4. 值的校验与同步
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* 自定义 Popper 配置对象
|
|
21
|
+
* 继承自 Element UI 的 VuePopper,用于处理弹出层定位
|
|
22
|
+
*/
|
|
23
|
+
const NewPopper = {
|
|
24
|
+
props: {
|
|
25
|
+
appendToBody: Popper.props.appendToBody,
|
|
26
|
+
offset: Popper.props.offset,
|
|
27
|
+
boundariesPadding: Popper.props.boundariesPadding,
|
|
28
|
+
arrowOffset: Popper.props.arrowOffset,
|
|
29
|
+
transformOrigin: Popper.props.transformOrigin
|
|
30
|
+
},
|
|
31
|
+
methods: Popper.methods,
|
|
32
|
+
data() {
|
|
33
|
+
return merge({ visibleArrow: true }, Popper.data);
|
|
34
|
+
},
|
|
35
|
+
beforeDestroy: Popper.beforeDestroy
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 默认日期格式映射表
|
|
40
|
+
* 定义了不同选择器类型的默认显示格式
|
|
41
|
+
*/
|
|
42
|
+
const DEFAULT_FORMATS = {
|
|
43
|
+
date: 'yyyy-MM-dd',
|
|
44
|
+
month: 'yyyy-MM',
|
|
45
|
+
months: 'yyyy-MM',
|
|
46
|
+
datetime: 'yyyy-MM-dd HH:mm:ss',
|
|
47
|
+
time: 'HH:mm:ss',
|
|
48
|
+
week: 'yyyyWW',
|
|
49
|
+
timerange: 'HH:mm:ss',
|
|
50
|
+
daterange: 'yyyy-MM-dd',
|
|
51
|
+
monthrange: 'yyyy-MM',
|
|
52
|
+
datetimerange: 'yyyy-MM-dd HH:mm:ss',
|
|
53
|
+
year: 'yyyy',
|
|
54
|
+
years: 'yyyy',
|
|
55
|
+
quarter: "yyyy-'Q'q",
|
|
56
|
+
weekrange: 'yyyyWW',
|
|
57
|
+
yearrange: 'yyyy',
|
|
58
|
+
quarterrange: "yyyy-'Q'q",
|
|
59
|
+
dates: 'yyyy-MM-dd'
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 拥有触发行为的类型列表
|
|
64
|
+
* 这些类型的选择器支持通过点击输入框或图标触发展示
|
|
65
|
+
*/
|
|
66
|
+
const HAVE_TRIGGER_TYPES = [
|
|
67
|
+
'date',
|
|
68
|
+
'datetime',
|
|
69
|
+
'time',
|
|
70
|
+
'time-select',
|
|
71
|
+
'week',
|
|
72
|
+
'month',
|
|
73
|
+
'year',
|
|
74
|
+
'quarter',
|
|
75
|
+
'daterange',
|
|
76
|
+
'monthrange',
|
|
77
|
+
'timerange',
|
|
78
|
+
'datetimerange',
|
|
79
|
+
'dates',
|
|
80
|
+
'months',
|
|
81
|
+
'years',
|
|
82
|
+
'weekrange',
|
|
83
|
+
'yearrange',
|
|
84
|
+
'quarterrange'
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 基础日期格式化函数
|
|
89
|
+
* @param {Date} value - 日期对象
|
|
90
|
+
* @param {String} format - 格式字符串
|
|
91
|
+
* @returns {String|Number} - 格式化后的字符串或时间戳
|
|
92
|
+
*/
|
|
93
|
+
const DATE_FORMATTER = function(value, format) {
|
|
94
|
+
if (format === 'timestamp') return value.getTime();
|
|
95
|
+
return formatDate(value, format);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 基础日期解析函数
|
|
100
|
+
* @param {String} text - 日期字符串
|
|
101
|
+
* @param {String} format - 格式字符串
|
|
102
|
+
* @returns {Date} - 解析后的日期对象
|
|
103
|
+
*/
|
|
104
|
+
const DATE_PARSER = function(text, format) {
|
|
105
|
+
if (format === 'timestamp') return new Date(Number(text));
|
|
106
|
+
return parseDate(text, format);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 范围选择格式化函数
|
|
111
|
+
* @param {Array} value - 日期数组 [start, end]
|
|
112
|
+
* @param {String} format - 格式字符串
|
|
113
|
+
* @returns {Array} - 格式化后的字符串数组
|
|
114
|
+
*/
|
|
115
|
+
const RANGE_FORMATTER = function(value, format) {
|
|
116
|
+
if (Array.isArray(value) && value.length === 2) {
|
|
117
|
+
const start = value[0];
|
|
118
|
+
const end = value[1];
|
|
119
|
+
|
|
120
|
+
if (start && end) {
|
|
121
|
+
return [DATE_FORMATTER(start, format), DATE_FORMATTER(end, format)];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return '';
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const WEEK_FORMATTER = function(value, format) {
|
|
128
|
+
let week = getWeekNumber(value);
|
|
129
|
+
let month = value.getMonth();
|
|
130
|
+
const trueDate = new Date(value);
|
|
131
|
+
if (week === 1 && month === 11) {
|
|
132
|
+
trueDate.setHours(0, 0, 0, 0);
|
|
133
|
+
trueDate.setDate(trueDate.getDate() + 3 - (trueDate.getDay() + 6) % 7);
|
|
134
|
+
}
|
|
135
|
+
let date = formatDate(trueDate, format);
|
|
136
|
+
|
|
137
|
+
date = /WW/.test(date)
|
|
138
|
+
? date.replace(/WW/, week < 10 ? '0' + week : week)
|
|
139
|
+
: date.replace(/W/, week);
|
|
140
|
+
return date;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const RANGE_WEEK_FORMATTER = function(value, format) {
|
|
144
|
+
if (Array.isArray(value) && value.length === 2) {
|
|
145
|
+
const start = value[0];
|
|
146
|
+
const end = value[1];
|
|
147
|
+
|
|
148
|
+
if (start && end) {
|
|
149
|
+
return [WEEK_FORMATTER(start, format), WEEK_FORMATTER(end, format)];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return '';
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* 范围选择解析函数
|
|
157
|
+
* @param {Array|String} array - 日期字符串数组或分隔符连接的字符串
|
|
158
|
+
* @param {String} format - 格式字符串
|
|
159
|
+
* @param {String} separator - 分隔符
|
|
160
|
+
* @returns {Array} - 解析后的日期对象数组
|
|
161
|
+
*/
|
|
162
|
+
const RANGE_PARSER = function(array, format, separator) {
|
|
163
|
+
if (!Array.isArray(array)) {
|
|
164
|
+
array = array.split(separator);
|
|
165
|
+
}
|
|
166
|
+
if (array.length === 2) {
|
|
167
|
+
const range1 = array[0];
|
|
168
|
+
const range2 = array[1];
|
|
169
|
+
|
|
170
|
+
return [DATE_PARSER(range1, format), DATE_PARSER(range2, format)];
|
|
171
|
+
}
|
|
172
|
+
return [];
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* 类型值解析器映射表
|
|
177
|
+
* 定义了不同类型的 formatter 和 parser 实现
|
|
178
|
+
*/
|
|
179
|
+
const TYPE_VALUE_RESOLVER_MAP = {
|
|
180
|
+
default: {
|
|
181
|
+
formatter(value) {
|
|
182
|
+
if (!value) return '';
|
|
183
|
+
return '' + value;
|
|
184
|
+
},
|
|
185
|
+
parser(text) {
|
|
186
|
+
if (text === undefined || text === '') return null;
|
|
187
|
+
return text;
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
week: {
|
|
191
|
+
formatter: WEEK_FORMATTER,
|
|
192
|
+
parser(text, format) {
|
|
193
|
+
return TYPE_VALUE_RESOLVER_MAP.date.parser(text, format);
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
date: {
|
|
197
|
+
formatter: DATE_FORMATTER,
|
|
198
|
+
parser: DATE_PARSER
|
|
199
|
+
},
|
|
200
|
+
datetime: {
|
|
201
|
+
formatter: DATE_FORMATTER,
|
|
202
|
+
parser: DATE_PARSER
|
|
203
|
+
},
|
|
204
|
+
daterange: {
|
|
205
|
+
formatter: RANGE_FORMATTER,
|
|
206
|
+
parser: RANGE_PARSER
|
|
207
|
+
},
|
|
208
|
+
monthrange: {
|
|
209
|
+
formatter: RANGE_FORMATTER,
|
|
210
|
+
parser: RANGE_PARSER
|
|
211
|
+
},
|
|
212
|
+
datetimerange: {
|
|
213
|
+
formatter: RANGE_FORMATTER,
|
|
214
|
+
parser: RANGE_PARSER
|
|
215
|
+
},
|
|
216
|
+
timerange: {
|
|
217
|
+
formatter: RANGE_FORMATTER,
|
|
218
|
+
parser: RANGE_PARSER
|
|
219
|
+
},
|
|
220
|
+
weekrange: {
|
|
221
|
+
formatter: RANGE_WEEK_FORMATTER,
|
|
222
|
+
parser: RANGE_PARSER
|
|
223
|
+
},
|
|
224
|
+
yearrange: {
|
|
225
|
+
formatter: RANGE_FORMATTER,
|
|
226
|
+
parser: RANGE_PARSER
|
|
227
|
+
},
|
|
228
|
+
quarterrange: {
|
|
229
|
+
formatter: RANGE_FORMATTER,
|
|
230
|
+
parser: RANGE_PARSER
|
|
231
|
+
},
|
|
232
|
+
time: {
|
|
233
|
+
formatter: DATE_FORMATTER,
|
|
234
|
+
parser: DATE_PARSER
|
|
235
|
+
},
|
|
236
|
+
month: {
|
|
237
|
+
formatter: DATE_FORMATTER,
|
|
238
|
+
parser: DATE_PARSER
|
|
239
|
+
},
|
|
240
|
+
year: {
|
|
241
|
+
formatter: DATE_FORMATTER,
|
|
242
|
+
parser: DATE_PARSER
|
|
243
|
+
},
|
|
244
|
+
quarter: {
|
|
245
|
+
formatter: DATE_FORMATTER,
|
|
246
|
+
parser: DATE_PARSER
|
|
247
|
+
},
|
|
248
|
+
number: {
|
|
249
|
+
formatter(value) {
|
|
250
|
+
if (!value) return '';
|
|
251
|
+
return '' + value;
|
|
252
|
+
},
|
|
253
|
+
parser(text) {
|
|
254
|
+
let result = Number(text);
|
|
255
|
+
|
|
256
|
+
if (!isNaN(text)) {
|
|
257
|
+
return result;
|
|
258
|
+
} else {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
dates: {
|
|
264
|
+
formatter(value, format) {
|
|
265
|
+
return value.map(date => DATE_FORMATTER(date, format));
|
|
266
|
+
},
|
|
267
|
+
parser(value, format) {
|
|
268
|
+
return (typeof value === 'string' ? value.split(', ') : value)
|
|
269
|
+
.map(date => date instanceof Date ? date : DATE_PARSER(date, format));
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
months: {
|
|
273
|
+
formatter(value, format) {
|
|
274
|
+
return value.map(date => DATE_FORMATTER(date, format));
|
|
275
|
+
},
|
|
276
|
+
parser(value, format) {
|
|
277
|
+
return (typeof value === 'string' ? value.split(', ') : value)
|
|
278
|
+
.map(date => date instanceof Date ? date : DATE_PARSER(date, format));
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
years: {
|
|
282
|
+
formatter(value, format) {
|
|
283
|
+
return value.map(date => DATE_FORMATTER(date, format));
|
|
284
|
+
},
|
|
285
|
+
parser(value, format) {
|
|
286
|
+
return (typeof value === 'string' ? value.split(', ') : value)
|
|
287
|
+
.map(date => date instanceof Date ? date : DATE_PARSER(date, format));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* 弹出层位置映射表
|
|
294
|
+
*/
|
|
295
|
+
const PLACEMENT_MAP = {
|
|
296
|
+
left: 'bottom-start',
|
|
297
|
+
center: 'bottom',
|
|
298
|
+
right: 'bottom-end'
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* 根据格式和类型解析值
|
|
303
|
+
* @param {any} value - 待解析的值
|
|
304
|
+
* @param {String} customFormat - 自定义格式
|
|
305
|
+
* @param {String} type - 选择器类型
|
|
306
|
+
* @param {String} rangeSeparator - 范围分隔符
|
|
307
|
+
* @returns {any} - 解析后的值
|
|
308
|
+
*/
|
|
309
|
+
const parseAsFormatAndType = (value, customFormat, type, rangeSeparator = '-') => {
|
|
310
|
+
if (!value) return null;
|
|
311
|
+
const parser = (
|
|
312
|
+
TYPE_VALUE_RESOLVER_MAP[type] ||
|
|
313
|
+
TYPE_VALUE_RESOLVER_MAP['default']
|
|
314
|
+
).parser;
|
|
315
|
+
const format = customFormat || DEFAULT_FORMATS[type];
|
|
316
|
+
return parser(value, format, rangeSeparator);
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* 根据格式和类型格式化值
|
|
321
|
+
* @param {any} value - 待格式化的值
|
|
322
|
+
* @param {String} customFormat - 自定义格式
|
|
323
|
+
* @param {String} type - 选择器类型
|
|
324
|
+
* @returns {any} - 格式化后的值
|
|
325
|
+
*/
|
|
326
|
+
const formatAsFormatAndType = (value, customFormat, type) => {
|
|
327
|
+
if (!value) return null;
|
|
328
|
+
const formatter = (
|
|
329
|
+
TYPE_VALUE_RESOLVER_MAP[type] ||
|
|
330
|
+
TYPE_VALUE_RESOLVER_MAP['default']
|
|
331
|
+
).formatter;
|
|
332
|
+
const format = customFormat || DEFAULT_FORMATS[type];
|
|
333
|
+
return formatter(value, format);
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* 判断两个值是否相等
|
|
338
|
+
* 支持 Date 对象和数组的深度比较
|
|
339
|
+
* @param {any} a - 值 A
|
|
340
|
+
* @param {any} b - 值 B
|
|
341
|
+
* @returns {Boolean} - 是否相等
|
|
342
|
+
*/
|
|
343
|
+
const valueEquals = function(a, b) {
|
|
344
|
+
const dateEquals = function(a, b) {
|
|
345
|
+
const aIsDate = a instanceof Date;
|
|
346
|
+
const bIsDate = b instanceof Date;
|
|
347
|
+
if (aIsDate && bIsDate) {
|
|
348
|
+
return a.getTime() === b.getTime();
|
|
349
|
+
}
|
|
350
|
+
if (!aIsDate && !bIsDate) {
|
|
351
|
+
return a === b;
|
|
352
|
+
}
|
|
353
|
+
return false;
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
const aIsArray = a instanceof Array;
|
|
357
|
+
const bIsArray = b instanceof Array;
|
|
358
|
+
if (aIsArray && bIsArray) {
|
|
359
|
+
if (a.length !== b.length) {
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
return a.every((item, index) => dateEquals(item, b[index]));
|
|
363
|
+
}
|
|
364
|
+
if (!aIsArray && !bIsArray) {
|
|
365
|
+
return dateEquals(a, b);
|
|
366
|
+
}
|
|
367
|
+
return false;
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* 判断是否为字符串
|
|
372
|
+
* @param {any} val - 待检查的值
|
|
373
|
+
* @returns {Boolean} - 是否为字符串
|
|
374
|
+
*/
|
|
375
|
+
const isString = function(val) {
|
|
376
|
+
return typeof val === 'string' || val instanceof String;
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* 校验器函数
|
|
381
|
+
* @param {any} val - 待校验的值
|
|
382
|
+
* @returns {Boolean} - 是否有效
|
|
383
|
+
*/
|
|
384
|
+
const validator = function(val) {
|
|
385
|
+
return (
|
|
386
|
+
val === null ||
|
|
387
|
+
val === undefined ||
|
|
388
|
+
isString(val) ||
|
|
389
|
+
(Array.isArray(val) && val.length === 2 && val.every(isString))
|
|
390
|
+
);
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* PickerMixin 混入对象
|
|
395
|
+
* 提供了日期选择器的通用逻辑,包括弹出层管理、输入处理、值格式化等
|
|
396
|
+
*/
|
|
397
|
+
export default {
|
|
398
|
+
mixins: [Emitter, NewPopper],
|
|
399
|
+
|
|
400
|
+
inject: {
|
|
401
|
+
elForm: {
|
|
402
|
+
default: ''
|
|
403
|
+
},
|
|
404
|
+
elFormItem: {
|
|
405
|
+
default: ''
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
|
|
409
|
+
directives: { Clickoutside },
|
|
410
|
+
|
|
411
|
+
props: {
|
|
412
|
+
size: String, // 尺寸
|
|
413
|
+
format: String, // 显示格式
|
|
414
|
+
valueFormat: String, // 绑定值格式
|
|
415
|
+
readonly: Boolean, // 是否只读
|
|
416
|
+
placeholder: String, // 占位符
|
|
417
|
+
startPlaceholder: String, // 范围选择开始占位符
|
|
418
|
+
endPlaceholder: String, // 范围选择结束占位符
|
|
419
|
+
prefixIcon: String, // 前缀图标
|
|
420
|
+
clearIcon: { // 清除图标
|
|
421
|
+
type: String,
|
|
422
|
+
default: 'el-icon-circle-close'
|
|
423
|
+
},
|
|
424
|
+
name: { // 原生 name 属性
|
|
425
|
+
default: '',
|
|
426
|
+
validator
|
|
427
|
+
},
|
|
428
|
+
disabled: Boolean, // 是否禁用
|
|
429
|
+
clearable: { // 是否可清除
|
|
430
|
+
type: Boolean,
|
|
431
|
+
default: true
|
|
432
|
+
},
|
|
433
|
+
id: { // 原生 id 属性
|
|
434
|
+
default: '',
|
|
435
|
+
validator
|
|
436
|
+
},
|
|
437
|
+
popperClass: String, // 弹出层类名
|
|
438
|
+
editable: { // 是否可编辑
|
|
439
|
+
type: Boolean,
|
|
440
|
+
default: true
|
|
441
|
+
},
|
|
442
|
+
align: { // 对齐方式
|
|
443
|
+
type: String,
|
|
444
|
+
default: 'left'
|
|
445
|
+
},
|
|
446
|
+
value: { // 绑定值
|
|
447
|
+
type: [Date, Array, String, Number],
|
|
448
|
+
default: null
|
|
449
|
+
},
|
|
450
|
+
defaultValue: { // 默认值
|
|
451
|
+
type: [Date, Array, String, Number],
|
|
452
|
+
default: null
|
|
453
|
+
},
|
|
454
|
+
defaultTime: { // 默认时间
|
|
455
|
+
type: [String, Array],
|
|
456
|
+
default: ''
|
|
457
|
+
},
|
|
458
|
+
rangeSeparator: { // 范围选择分隔符
|
|
459
|
+
type: String,
|
|
460
|
+
default: '-'
|
|
461
|
+
},
|
|
462
|
+
pickerOptions: { // 特殊选项,如禁用日期等
|
|
463
|
+
type: Object,
|
|
464
|
+
default: () => ({})
|
|
465
|
+
},
|
|
466
|
+
unlinkPanels: Boolean, // 范围选择时是否取消两个面板的联动
|
|
467
|
+
validateEvent: { // 是否触发表单验证
|
|
468
|
+
type: Boolean,
|
|
469
|
+
default: true
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
|
|
473
|
+
data() {
|
|
474
|
+
return {
|
|
475
|
+
pickerVisible: false, // 选择器是否可见
|
|
476
|
+
showClose: false, // 是否显示清除按钮
|
|
477
|
+
userInput: null, // 用户输入的值
|
|
478
|
+
valueOnOpen: null, // 打开时的值(用于取消时恢复)
|
|
479
|
+
valueOnOpenParsed: null, // 打开时的解析值
|
|
480
|
+
unwatchPickerOptions: null, // 取消监听 pickerOptions 的函数
|
|
481
|
+
rangePreview: null, // 范围选择预览
|
|
482
|
+
inputError: false, // 输入是否错误
|
|
483
|
+
cancelPending: false, // 是否处于取消等待状态
|
|
484
|
+
rangeInputErrorState: { // 范围输入错误状态
|
|
485
|
+
min: false,
|
|
486
|
+
max: false
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
},
|
|
490
|
+
|
|
491
|
+
computed: {
|
|
492
|
+
/**
|
|
493
|
+
* 实际使用的类型
|
|
494
|
+
*/
|
|
495
|
+
actualType() {
|
|
496
|
+
return this.type;
|
|
497
|
+
},
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* 是否为范围选择类型
|
|
501
|
+
*/
|
|
502
|
+
ranged() {
|
|
503
|
+
return this.actualType.indexOf('range') > -1;
|
|
504
|
+
},
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* 引用元素(输入框)
|
|
508
|
+
*/
|
|
509
|
+
reference() {
|
|
510
|
+
const reference = this.$refs.reference;
|
|
511
|
+
return reference.$el || reference;
|
|
512
|
+
},
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* 输入框 DOM 元素列表
|
|
516
|
+
*/
|
|
517
|
+
refInput() {
|
|
518
|
+
if (this.reference) {
|
|
519
|
+
return [].slice.call(this.reference.querySelectorAll('input'));
|
|
520
|
+
}
|
|
521
|
+
return [];
|
|
522
|
+
},
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* 判断值是否为空
|
|
526
|
+
*/
|
|
527
|
+
valueIsEmpty() {
|
|
528
|
+
const val = this.value;
|
|
529
|
+
if (Array.isArray(val)) {
|
|
530
|
+
for (let i = 0, len = val.length; i < len; i++) {
|
|
531
|
+
if (val[i]) {
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
} else {
|
|
536
|
+
if (val) {
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return true;
|
|
541
|
+
},
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* 触发器类名(图标)
|
|
545
|
+
*/
|
|
546
|
+
triggerClass() {
|
|
547
|
+
return this.prefixIcon || (this.actualType.indexOf('time') !== -1 ? 'el-icon-time' : 'el-icon-date');
|
|
548
|
+
},
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* 选择模式
|
|
552
|
+
* 决定面板展示的视图类型
|
|
553
|
+
*/
|
|
554
|
+
selectionMode() {
|
|
555
|
+
if (this.actualType === 'week') {
|
|
556
|
+
return 'week';
|
|
557
|
+
} else if (this.actualType === 'month') {
|
|
558
|
+
return 'month';
|
|
559
|
+
} else if (this.actualType === 'year') {
|
|
560
|
+
return 'year';
|
|
561
|
+
} else if (this.actualType === 'dates') {
|
|
562
|
+
return 'dates';
|
|
563
|
+
} else if (this.actualType === 'quarter') {
|
|
564
|
+
return 'quarter';
|
|
565
|
+
} else if (this.actualType === 'months') {
|
|
566
|
+
return 'months';
|
|
567
|
+
} else if (this.actualType === 'years') {
|
|
568
|
+
return 'years';
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
return 'day';
|
|
572
|
+
},
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* 是否拥有触发器
|
|
576
|
+
*/
|
|
577
|
+
haveTrigger() {
|
|
578
|
+
if (typeof this.showTrigger !== 'undefined') {
|
|
579
|
+
return this.showTrigger;
|
|
580
|
+
}
|
|
581
|
+
return HAVE_TRIGGER_TYPES.indexOf(this.actualType) !== -1;
|
|
582
|
+
},
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* 显示在输入框中的值
|
|
586
|
+
*/
|
|
587
|
+
displayValue() {
|
|
588
|
+
if (this.ranged && this.rangePreview && this.pickerVisible && this.userInput === null) {
|
|
589
|
+
const min = this.rangePreview.min instanceof Date
|
|
590
|
+
? this.formatToString(this.rangePreview.min)
|
|
591
|
+
: (this.rangePreview.min || '');
|
|
592
|
+
const max = this.rangePreview.max instanceof Date
|
|
593
|
+
? this.formatToString(this.rangePreview.max)
|
|
594
|
+
: (this.rangePreview.max || '');
|
|
595
|
+
return [min, max];
|
|
596
|
+
}
|
|
597
|
+
const formattedValue = formatAsFormatAndType(this.parsedValue, this.format, this.actualType, this.rangeSeparator);
|
|
598
|
+
if (Array.isArray(this.userInput)) {
|
|
599
|
+
return [
|
|
600
|
+
this.userInput[0] || (formattedValue && formattedValue[0]) || '',
|
|
601
|
+
this.userInput[1] || (formattedValue && formattedValue[1]) || ''
|
|
602
|
+
];
|
|
603
|
+
} else if (this.userInput !== null) {
|
|
604
|
+
return this.userInput;
|
|
605
|
+
} else if (formattedValue) {
|
|
606
|
+
return (this.actualType === 'dates' || this.actualType === 'years' || this.actualType === 'months')
|
|
607
|
+
? formattedValue.join(', ')
|
|
608
|
+
: formattedValue;
|
|
609
|
+
} else {
|
|
610
|
+
return '';
|
|
611
|
+
}
|
|
612
|
+
},
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* 解析后的值(Date 对象或数组)
|
|
616
|
+
*/
|
|
617
|
+
parsedValue() {
|
|
618
|
+
if (!this.value) return this.value;
|
|
619
|
+
if (this.actualType === 'time-select') return this.value;
|
|
620
|
+
|
|
621
|
+
const valueIsDateObject = isDateObject(this.value) || (Array.isArray(this.value) && this.value.every(isDateObject));
|
|
622
|
+
if (valueIsDateObject) {
|
|
623
|
+
return this.value;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
if (this.valueFormat) {
|
|
627
|
+
return parseAsFormatAndType(this.value, this.valueFormat, this.actualType, this.rangeSeparator) || this.value;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
return Array.isArray(this.value) ? this.value.map(val => new Date(val)) : new Date(this.value);
|
|
631
|
+
},
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* 范围输入是否有误
|
|
635
|
+
*/
|
|
636
|
+
rangeInputError() {
|
|
637
|
+
return this.rangeInputErrorState.min || this.rangeInputErrorState.max;
|
|
638
|
+
},
|
|
639
|
+
|
|
640
|
+
_elFormItemSize() {
|
|
641
|
+
return (this.elFormItem || {}).elFormItemSize;
|
|
642
|
+
},
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* 选择器尺寸
|
|
646
|
+
*/
|
|
647
|
+
pickerSize() {
|
|
648
|
+
return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
|
|
649
|
+
},
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* 选择器是否禁用
|
|
653
|
+
*/
|
|
654
|
+
pickerDisabled() {
|
|
655
|
+
return this.disabled || (this.elForm || {}).disabled;
|
|
656
|
+
},
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* 第一个输入框的 ID
|
|
660
|
+
*/
|
|
661
|
+
firstInputId() {
|
|
662
|
+
const obj = {};
|
|
663
|
+
let id;
|
|
664
|
+
if (this.ranged) {
|
|
665
|
+
id = this.id && this.id[0];
|
|
666
|
+
} else {
|
|
667
|
+
id = this.id;
|
|
668
|
+
}
|
|
669
|
+
if (id) obj.id = id;
|
|
670
|
+
return obj;
|
|
671
|
+
},
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* 第二个输入框的 ID(范围选择时)
|
|
675
|
+
*/
|
|
676
|
+
secondInputId() {
|
|
677
|
+
const obj = {};
|
|
678
|
+
let id;
|
|
679
|
+
if (this.ranged) {
|
|
680
|
+
id = this.id && this.id[1];
|
|
681
|
+
}
|
|
682
|
+
if (id) obj.id = id;
|
|
683
|
+
return obj;
|
|
684
|
+
}
|
|
685
|
+
},
|
|
686
|
+
|
|
687
|
+
watch: {
|
|
688
|
+
/**
|
|
689
|
+
* 监听选择器显隐状态
|
|
690
|
+
*/
|
|
691
|
+
pickerVisible(val) {
|
|
692
|
+
if (this.readonly || this.pickerDisabled) return;
|
|
693
|
+
if (val) {
|
|
694
|
+
this.showPicker();
|
|
695
|
+
this.valueOnOpen = Array.isArray(this.value) ? [...this.value] : this.value;
|
|
696
|
+
this.valueOnOpenParsed = Array.isArray(this.parsedValue) ? [...this.parsedValue] : this.parsedValue;
|
|
697
|
+
} else {
|
|
698
|
+
this.hidePicker();
|
|
699
|
+
if (!this.cancelPending) {
|
|
700
|
+
this.emitChange(this.value);
|
|
701
|
+
}
|
|
702
|
+
this.cancelPending = false;
|
|
703
|
+
this.userInput = null;
|
|
704
|
+
this.rangePreview = null;
|
|
705
|
+
this.inputError = false;
|
|
706
|
+
this.rangeInputErrorState.min = false;
|
|
707
|
+
this.rangeInputErrorState.max = false;
|
|
708
|
+
if (this.validateEvent) {
|
|
709
|
+
this.dispatch('ElFormItem', 'el.form.blur');
|
|
710
|
+
}
|
|
711
|
+
this.$emit('blur', this);
|
|
712
|
+
this.blur();
|
|
713
|
+
}
|
|
714
|
+
},
|
|
715
|
+
/**
|
|
716
|
+
* 监听解析后的值,同步到 picker 实例
|
|
717
|
+
*/
|
|
718
|
+
parsedValue: {
|
|
719
|
+
immediate: true,
|
|
720
|
+
handler(val) {
|
|
721
|
+
if (this.picker) {
|
|
722
|
+
this.picker.value = val;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
},
|
|
726
|
+
defaultValue(val) {
|
|
727
|
+
if (this.picker) {
|
|
728
|
+
this.picker.defaultValue = val;
|
|
729
|
+
}
|
|
730
|
+
},
|
|
731
|
+
/**
|
|
732
|
+
* 监听值变化,触发表单验证
|
|
733
|
+
*/
|
|
734
|
+
value(val, oldVal) {
|
|
735
|
+
if (!valueEquals(val, oldVal) && !this.pickerVisible && this.validateEvent) {
|
|
736
|
+
this.dispatch('ElFormItem', 'el.form.change', val);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
},
|
|
740
|
+
|
|
741
|
+
created() {
|
|
742
|
+
this.popperOptions = {
|
|
743
|
+
boundariesPadding: 0,
|
|
744
|
+
gpuAcceleration: false
|
|
745
|
+
};
|
|
746
|
+
this.placement = PLACEMENT_MAP[this.align] || PLACEMENT_MAP.left;
|
|
747
|
+
|
|
748
|
+
this.$on('fieldReset', this.handleFieldReset);
|
|
749
|
+
},
|
|
750
|
+
|
|
751
|
+
methods: {
|
|
752
|
+
/**
|
|
753
|
+
* 聚焦输入框
|
|
754
|
+
*/
|
|
755
|
+
focus() {
|
|
756
|
+
if (!this.ranged) {
|
|
757
|
+
this.$refs.reference.focus();
|
|
758
|
+
} else {
|
|
759
|
+
this.handleFocus();
|
|
760
|
+
}
|
|
761
|
+
},
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* 失焦输入框
|
|
765
|
+
*/
|
|
766
|
+
blur() {
|
|
767
|
+
this.refInput.forEach(input => input.blur());
|
|
768
|
+
},
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* 解析值
|
|
772
|
+
*/
|
|
773
|
+
parseValue(value) {
|
|
774
|
+
const isParsed = isDateObject(value) || (Array.isArray(value) && value.every(isDateObject));
|
|
775
|
+
if (this.valueFormat && !isParsed) {
|
|
776
|
+
return parseAsFormatAndType(value, this.valueFormat, this.actualType, this.rangeSeparator) || value;
|
|
777
|
+
} else {
|
|
778
|
+
return value;
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* 格式化值
|
|
784
|
+
*/
|
|
785
|
+
formatToValue(date) {
|
|
786
|
+
const isFormattable = isDateObject(date) || (Array.isArray(date) && date.every(isDateObject));
|
|
787
|
+
if (this.valueFormat && isFormattable) {
|
|
788
|
+
return formatAsFormatAndType(date, this.valueFormat, this.actualType, this.rangeSeparator);
|
|
789
|
+
} else {
|
|
790
|
+
return date;
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* 解析字符串
|
|
796
|
+
*/
|
|
797
|
+
parseString(value) {
|
|
798
|
+
const type = Array.isArray(value) ? this.actualType : this.actualType.replace('range', '');
|
|
799
|
+
return parseAsFormatAndType(value, this.format, type);
|
|
800
|
+
},
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* 格式化为字符串
|
|
804
|
+
*/
|
|
805
|
+
formatToString(value) {
|
|
806
|
+
const type = Array.isArray(value) ? this.actualType : this.actualType.replace('range', '');
|
|
807
|
+
return formatAsFormatAndType(value, this.format, type);
|
|
808
|
+
},
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* 处理鼠标移入
|
|
812
|
+
*/
|
|
813
|
+
handleMouseEnter() {
|
|
814
|
+
if (this.readonly || this.pickerDisabled) return;
|
|
815
|
+
if (!this.valueIsEmpty && this.clearable) {
|
|
816
|
+
this.showClose = true;
|
|
817
|
+
}
|
|
818
|
+
},
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* 处理输入变化
|
|
822
|
+
*/
|
|
823
|
+
handleChange() {
|
|
824
|
+
if (this.userInput) {
|
|
825
|
+
const value = this.parseString(this.displayValue);
|
|
826
|
+
if (value) {
|
|
827
|
+
this.picker.value = value;
|
|
828
|
+
if (this.isValidValue(value)) {
|
|
829
|
+
this.emitInput(value);
|
|
830
|
+
this.userInput = null;
|
|
831
|
+
this.inputError = false;
|
|
832
|
+
}
|
|
833
|
+
} else {
|
|
834
|
+
this.inputError = true;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
if (this.userInput === '') {
|
|
838
|
+
this.emitInput(null);
|
|
839
|
+
this.emitChange(null);
|
|
840
|
+
this.userInput = null;
|
|
841
|
+
this.inputError = false;
|
|
842
|
+
}
|
|
843
|
+
},
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* 处理范围选择开始输入
|
|
847
|
+
*/
|
|
848
|
+
handleStartInput(event) {
|
|
849
|
+
if (this.userInput) {
|
|
850
|
+
this.userInput = [event.target.value, this.userInput[1]];
|
|
851
|
+
} else {
|
|
852
|
+
this.userInput = [event.target.value, null];
|
|
853
|
+
}
|
|
854
|
+
this.rangeInputErrorState.min = false;
|
|
855
|
+
},
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* 处理范围选择结束输入
|
|
859
|
+
*/
|
|
860
|
+
handleEndInput(event) {
|
|
861
|
+
if (this.userInput) {
|
|
862
|
+
this.userInput = [this.userInput[0], event.target.value];
|
|
863
|
+
} else {
|
|
864
|
+
this.userInput = [null, event.target.value];
|
|
865
|
+
}
|
|
866
|
+
this.rangeInputErrorState.max = false;
|
|
867
|
+
},
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* 处理范围选择开始值变化
|
|
871
|
+
*/
|
|
872
|
+
handleStartChange(event) {
|
|
873
|
+
const value = this.parseString(this.userInput && this.userInput[0]);
|
|
874
|
+
if (value) {
|
|
875
|
+
this.userInput = [this.formatToString(value), this.displayValue[1]];
|
|
876
|
+
const newValue = [value, this.picker.value && this.picker.value[1]];
|
|
877
|
+
this.picker.value = newValue;
|
|
878
|
+
if (this.isValidValue(newValue)) {
|
|
879
|
+
this.emitInput(newValue);
|
|
880
|
+
this.userInput = null;
|
|
881
|
+
}
|
|
882
|
+
this.rangeInputErrorState.min = false;
|
|
883
|
+
} else if (this.userInput && this.userInput[0]) {
|
|
884
|
+
this.rangeInputErrorState.min = true;
|
|
885
|
+
}
|
|
886
|
+
},
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* 处理范围选择结束值变化
|
|
890
|
+
*/
|
|
891
|
+
handleEndChange(event) {
|
|
892
|
+
const value = this.parseString(this.userInput && this.userInput[1]);
|
|
893
|
+
if (value) {
|
|
894
|
+
this.userInput = [this.displayValue[0], this.formatToString(value)];
|
|
895
|
+
const newValue = [this.picker.value && this.picker.value[0], value];
|
|
896
|
+
this.picker.value = newValue;
|
|
897
|
+
if (this.isValidValue(newValue)) {
|
|
898
|
+
this.emitInput(newValue);
|
|
899
|
+
this.userInput = null;
|
|
900
|
+
}
|
|
901
|
+
this.rangeInputErrorState.max = false;
|
|
902
|
+
} else if (this.userInput && this.userInput[1]) {
|
|
903
|
+
this.rangeInputErrorState.max = true;
|
|
904
|
+
}
|
|
905
|
+
},
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* 处理图标点击(打开选择器或清除内容)
|
|
909
|
+
*/
|
|
910
|
+
handleClickIcon(event) {
|
|
911
|
+
if (this.readonly || this.pickerDisabled) return;
|
|
912
|
+
if (this.showClose) {
|
|
913
|
+
this.valueOnOpen = this.value;
|
|
914
|
+
event.stopPropagation();
|
|
915
|
+
this.emitInput(null);
|
|
916
|
+
this.emitChange(null);
|
|
917
|
+
this.showClose = false;
|
|
918
|
+
if (this.picker && typeof this.picker.handleClear === 'function') {
|
|
919
|
+
this.picker.handleClear();
|
|
920
|
+
}
|
|
921
|
+
} else {
|
|
922
|
+
this.pickerVisible = !this.pickerVisible;
|
|
923
|
+
}
|
|
924
|
+
},
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* 处理关闭
|
|
928
|
+
*/
|
|
929
|
+
handleClose() {
|
|
930
|
+
if (!this.pickerVisible) return;
|
|
931
|
+
this.pickerVisible = false;
|
|
932
|
+
|
|
933
|
+
if (this.actualType === 'dates' || this.actualType === 'years' || this.actualType === 'months') {
|
|
934
|
+
const oldValue = parseAsFormatAndType(this.valueOnOpen, this.valueFormat, this.actualType, this.rangeSeparator) || this.valueOnOpen;
|
|
935
|
+
this.emitInput(oldValue);
|
|
936
|
+
}
|
|
937
|
+
},
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* 处理表单重置
|
|
941
|
+
*/
|
|
942
|
+
handleFieldReset(initialValue) {
|
|
943
|
+
this.userInput = initialValue === '' ? null : initialValue;
|
|
944
|
+
},
|
|
945
|
+
|
|
946
|
+
/**
|
|
947
|
+
* 处理聚焦
|
|
948
|
+
*/
|
|
949
|
+
handleFocus() {
|
|
950
|
+
const type = this.actualType;
|
|
951
|
+
|
|
952
|
+
if (HAVE_TRIGGER_TYPES.indexOf(type) !== -1 && !this.pickerVisible) {
|
|
953
|
+
this.pickerVisible = true;
|
|
954
|
+
}
|
|
955
|
+
this.$emit('focus', this);
|
|
956
|
+
},
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
* 处理键盘按键
|
|
960
|
+
*/
|
|
961
|
+
handleKeydown(event) {
|
|
962
|
+
const keyCode = event.keyCode;
|
|
963
|
+
|
|
964
|
+
// ESC 关闭
|
|
965
|
+
if (keyCode === 27) {
|
|
966
|
+
if (this.pickerVisible) {
|
|
967
|
+
// 标记为等待取消状态
|
|
968
|
+
this.cancelPending = true;
|
|
969
|
+
// 清空状态
|
|
970
|
+
this.rangePreview = null;
|
|
971
|
+
this.userInput = null;
|
|
972
|
+
|
|
973
|
+
// 恢复打开时的值
|
|
974
|
+
if (this.valueOnOpenParsed !== null || this.valueOnOpen === null) {
|
|
975
|
+
this.emitInput(this.valueOnOpenParsed);
|
|
976
|
+
}
|
|
977
|
+
// 关闭选择器
|
|
978
|
+
this.pickerVisible = false;
|
|
979
|
+
}
|
|
980
|
+
// 阻止事件冒泡和默认行为
|
|
981
|
+
event.stopPropagation();
|
|
982
|
+
event.preventDefault();
|
|
983
|
+
return;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
// Tab 键处理
|
|
987
|
+
if (keyCode === 9) {
|
|
988
|
+
if (!this.ranged) {
|
|
989
|
+
// 非范围选择,触发变更并关闭
|
|
990
|
+
this.handleChange();
|
|
991
|
+
this.pickerVisible = this.picker.visible = false;
|
|
992
|
+
this.blur();
|
|
993
|
+
event.stopPropagation();
|
|
994
|
+
} else {
|
|
995
|
+
// 范围选择,延迟检查焦点是否移出组件
|
|
996
|
+
setTimeout(() => {
|
|
997
|
+
if (this.refInput.indexOf(document.activeElement) === -1) {
|
|
998
|
+
this.pickerVisible = false;
|
|
999
|
+
this.blur();
|
|
1000
|
+
event.stopPropagation();
|
|
1001
|
+
}
|
|
1002
|
+
}, 0);
|
|
1003
|
+
}
|
|
1004
|
+
return;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
// Enter 键处理
|
|
1008
|
+
if (keyCode === 13) {
|
|
1009
|
+
if (!this.pickerVisible) {
|
|
1010
|
+
// 如果选择器未打开,则打开
|
|
1011
|
+
this.pickerVisible = true;
|
|
1012
|
+
event.stopPropagation();
|
|
1013
|
+
event.preventDefault();
|
|
1014
|
+
return;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
if (this.userInput) {
|
|
1018
|
+
// 如果有用户输入,检查输入是否有效
|
|
1019
|
+
if (this.userInput === '' || this.isValidValue(this.parseString(this.displayValue))) {
|
|
1020
|
+
// 有效则触发变更并关闭
|
|
1021
|
+
this.handleChange();
|
|
1022
|
+
this.pickerVisible = this.picker.visible = false;
|
|
1023
|
+
this.blur();
|
|
1024
|
+
}
|
|
1025
|
+
event.stopPropagation();
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
// 将键盘事件传递给 picker 实例处理
|
|
1030
|
+
if (this.picker && this.picker.handleKeydown) {
|
|
1031
|
+
this.picker.handleKeydown(event);
|
|
1032
|
+
}
|
|
1033
|
+
event.stopPropagation();
|
|
1034
|
+
event.preventDefault();
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
// 如果有用户输入,阻止事件冒泡
|
|
1039
|
+
if (this.userInput) {
|
|
1040
|
+
event.stopPropagation();
|
|
1041
|
+
return;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
// 默认将事件传递给 picker 实例
|
|
1045
|
+
if (this.picker && this.picker.handleKeydown) {
|
|
1046
|
+
this.picker.handleKeydown(event);
|
|
1047
|
+
}
|
|
1048
|
+
},
|
|
1049
|
+
|
|
1050
|
+
/**
|
|
1051
|
+
* 处理范围选择点击
|
|
1052
|
+
*/
|
|
1053
|
+
handleRangeClick() {
|
|
1054
|
+
const type = this.actualType;
|
|
1055
|
+
|
|
1056
|
+
if (HAVE_TRIGGER_TYPES.indexOf(type) !== -1 && !this.pickerVisible) {
|
|
1057
|
+
this.pickerVisible = true;
|
|
1058
|
+
}
|
|
1059
|
+
this.$emit('focus', this);
|
|
1060
|
+
},
|
|
1061
|
+
|
|
1062
|
+
/**
|
|
1063
|
+
* 隐藏选择器
|
|
1064
|
+
*/
|
|
1065
|
+
hidePicker() {
|
|
1066
|
+
if (this.picker) {
|
|
1067
|
+
this.picker.resetView && this.picker.resetView();
|
|
1068
|
+
this.pickerVisible = this.picker.visible = false;
|
|
1069
|
+
this.destroyPopper();
|
|
1070
|
+
}
|
|
1071
|
+
},
|
|
1072
|
+
|
|
1073
|
+
/**
|
|
1074
|
+
* 显示选择器
|
|
1075
|
+
*/
|
|
1076
|
+
showPicker() {
|
|
1077
|
+
if (this.$isServer) return;
|
|
1078
|
+
if (!this.picker) {
|
|
1079
|
+
this.mountPicker();
|
|
1080
|
+
}
|
|
1081
|
+
this.pickerVisible = this.picker.visible = true;
|
|
1082
|
+
|
|
1083
|
+
this.updatePopper();
|
|
1084
|
+
|
|
1085
|
+
this.picker.value = this.parsedValue;
|
|
1086
|
+
this.picker.resetView && this.picker.resetView();
|
|
1087
|
+
|
|
1088
|
+
this.$nextTick(() => {
|
|
1089
|
+
this.picker.adjustSpinners && this.picker.adjustSpinners();
|
|
1090
|
+
});
|
|
1091
|
+
},
|
|
1092
|
+
|
|
1093
|
+
/**
|
|
1094
|
+
* 卸载 Picker 实例
|
|
1095
|
+
* 清理 DOM 和事件监听,防止内存泄漏
|
|
1096
|
+
*/
|
|
1097
|
+
unmountPicker() {
|
|
1098
|
+
if (this.picker) {
|
|
1099
|
+
this.picker.$destroy();
|
|
1100
|
+
this.picker.$off();
|
|
1101
|
+
if (typeof this.unwatchPickerOptions === 'function') {
|
|
1102
|
+
this.unwatchPickerOptions();
|
|
1103
|
+
}
|
|
1104
|
+
this.picker.$el.parentNode.removeChild(this.picker.$el);
|
|
1105
|
+
this.picker = null;
|
|
1106
|
+
}
|
|
1107
|
+
},
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* 发射 input 事件
|
|
1111
|
+
* @param {any} val - 新值
|
|
1112
|
+
*/
|
|
1113
|
+
emitInput(val) {
|
|
1114
|
+
const formatted = this.formatToValue(val);
|
|
1115
|
+
if (!valueEquals(this.value, formatted)) {
|
|
1116
|
+
this.$emit('input', formatted);
|
|
1117
|
+
}
|
|
1118
|
+
},
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* 发射 change 事件
|
|
1122
|
+
* @param {any} val - 新值
|
|
1123
|
+
*/
|
|
1124
|
+
emitChange(val) {
|
|
1125
|
+
const formatted = this.formatToValue(val);
|
|
1126
|
+
if (!valueEquals(formatted, this.valueOnOpen)) {
|
|
1127
|
+
this.$emit('change', formatted);
|
|
1128
|
+
this.dispatch('ElFormItem', 'el.form.change', formatted);
|
|
1129
|
+
this.valueOnOpen = formatted;
|
|
1130
|
+
}
|
|
1131
|
+
},
|
|
1132
|
+
|
|
1133
|
+
/**
|
|
1134
|
+
* 挂载 Picker 实例
|
|
1135
|
+
* 创建 Vue 实例并挂载到 DOM,绑定相关属性和事件
|
|
1136
|
+
*/
|
|
1137
|
+
mountPicker() {
|
|
1138
|
+
// 创建并挂载 picker 实例
|
|
1139
|
+
this.picker = new Vue(this.panel).$mount();
|
|
1140
|
+
// 同步属性到 picker
|
|
1141
|
+
this.picker.defaultValue = this.defaultValue;
|
|
1142
|
+
this.picker.defaultTime = this.defaultTime;
|
|
1143
|
+
this.picker.popperClass = this.popperClass;
|
|
1144
|
+
this.popperElm = this.picker.$el;
|
|
1145
|
+
// 设置宽度
|
|
1146
|
+
this.picker.width = this.reference.getBoundingClientRect().width;
|
|
1147
|
+
// 设置显示时间属性
|
|
1148
|
+
this.picker.showTime = this.actualType === 'datetime' || this.actualType === 'datetimerange';
|
|
1149
|
+
this.picker.selectionMode = this.selectionMode;
|
|
1150
|
+
this.picker.unlinkPanels = this.unlinkPanels;
|
|
1151
|
+
this.picker.arrowControl = this.arrowControl || this.timeArrowControl || false;
|
|
1152
|
+
this.picker.format = this.format;
|
|
1153
|
+
|
|
1154
|
+
// 监听 format 变化
|
|
1155
|
+
this.$watch('format', (format) => {
|
|
1156
|
+
this.picker.format = format;
|
|
1157
|
+
});
|
|
1158
|
+
|
|
1159
|
+
// 同步 pickerOptions
|
|
1160
|
+
const updateOptions = () => {
|
|
1161
|
+
const options = this.pickerOptions;
|
|
1162
|
+
if (options && options.selectableRange) {
|
|
1163
|
+
let ranges = options.selectableRange;
|
|
1164
|
+
const parser = TYPE_VALUE_RESOLVER_MAP.datetimerange.parser;
|
|
1165
|
+
const format = DEFAULT_FORMATS.timerange;
|
|
1166
|
+
ranges = Array.isArray(ranges) ? ranges : [ranges];
|
|
1167
|
+
this.picker.selectableRange = ranges.map(range => parser(range, format, this.rangeSeparator));
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
for (const option in options) {
|
|
1171
|
+
if (options.hasOwnProperty(option) &&
|
|
1172
|
+
// 忽略 user-defined format 属性
|
|
1173
|
+
option !== 'selectableRange' &&
|
|
1174
|
+
option !== 'format') {
|
|
1175
|
+
this.picker[option] = options[option];
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
// 处理快捷选项
|
|
1180
|
+
const mainShortcut = options.shortcuts || [];
|
|
1181
|
+
const sidebarShortcut = options.sidebarShortcuts || [];
|
|
1182
|
+
const shortcuts = mainShortcut.concat(sidebarShortcut);
|
|
1183
|
+
this.picker.shortcuts = shortcuts.length > 0 ? shortcuts : undefined;
|
|
1184
|
+
};
|
|
1185
|
+
|
|
1186
|
+
updateOptions();
|
|
1187
|
+
// 深度监听 pickerOptions
|
|
1188
|
+
this.unwatchPickerOptions = this.$watch('pickerOptions', () => updateOptions(), { deep: true });
|
|
1189
|
+
|
|
1190
|
+
// 将 picker 元素添加到 DOM
|
|
1191
|
+
this.$el.appendChild(this.picker.$el);
|
|
1192
|
+
this.picker.resetView && this.picker.resetView();
|
|
1193
|
+
|
|
1194
|
+
// 监听 picker 销毁事件
|
|
1195
|
+
this.picker.$on('dodestroy', this.doDestroy);
|
|
1196
|
+
// 监听 pick 事件
|
|
1197
|
+
this.picker.$on('pick', (date = '', visible = false) => {
|
|
1198
|
+
if (this.onPick) {
|
|
1199
|
+
this.onPick(date, visible);
|
|
1200
|
+
} else {
|
|
1201
|
+
this.userInput = null;
|
|
1202
|
+
this.pickerVisible = this.picker.visible = visible;
|
|
1203
|
+
this.emitInput(date);
|
|
1204
|
+
this.picker.resetView && this.picker.resetView();
|
|
1205
|
+
}
|
|
1206
|
+
});
|
|
1207
|
+
|
|
1208
|
+
// 监听 update:date 事件,同步面板日期
|
|
1209
|
+
this.picker.$on('update:date', date => {
|
|
1210
|
+
this.picker.date = date;
|
|
1211
|
+
});
|
|
1212
|
+
|
|
1213
|
+
// 监听 select-range 事件
|
|
1214
|
+
this.picker.$on('select-range', (start, end, pos) => {
|
|
1215
|
+
if (this.refInput.length === 0) return;
|
|
1216
|
+
if (!pos || pos === 'min') {
|
|
1217
|
+
this.refInput[0].setSelectionRange(start, end);
|
|
1218
|
+
this.refInput[0].focus();
|
|
1219
|
+
} else {
|
|
1220
|
+
this.refInput[1].setSelectionRange(start, end);
|
|
1221
|
+
this.refInput[1].focus();
|
|
1222
|
+
}
|
|
1223
|
+
});
|
|
1224
|
+
|
|
1225
|
+
// 监听 preview 事件
|
|
1226
|
+
this.picker.$on('preview', (val) => {
|
|
1227
|
+
this.rangePreview = val;
|
|
1228
|
+
});
|
|
1229
|
+
|
|
1230
|
+
// 监听 pick-start-date 事件
|
|
1231
|
+
this.picker.$on('pick-start-date', () => {
|
|
1232
|
+
if (typeof this.handlePickStartDate === 'function') {
|
|
1233
|
+
this.handlePickStartDate();
|
|
1234
|
+
}
|
|
1235
|
+
});
|
|
1236
|
+
|
|
1237
|
+
// 监听 pick-end-date 事件
|
|
1238
|
+
this.picker.$on('pick-end-date', () => {
|
|
1239
|
+
if (typeof this.handlePickEndDate === 'function') {
|
|
1240
|
+
this.handlePickEndDate();
|
|
1241
|
+
}
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
};
|