cy-element-ui 1.0.4 → 1.0.6
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 +22 -13
- package/lib/alert.js +211 -203
- package/lib/aside.js +29 -29
- package/lib/autocomplete.js +4615 -483
- package/lib/avatar.js +152 -126
- package/lib/backtop.js +117 -125
- package/lib/badge.js +128 -134
- package/lib/breadcrumb-item.js +146 -122
- package/lib/breadcrumb.js +97 -96
- package/lib/button-group.js +68 -65
- package/lib/button.js +67 -87
- package/lib/calendar.js +2475 -603
- package/lib/card.js +101 -100
- package/lib/carousel-item.js +854 -210
- package/lib/carousel.js +575 -408
- package/lib/cascader-panel.js +3546 -1153
- package/lib/cascader.js +7376 -970
- package/lib/checkbox-button.js +337 -290
- package/lib/checkbox-group.js +176 -105
- package/lib/checkbox.js +240 -220
- package/lib/col.js +113 -68
- package/lib/collapse-item.js +1228 -225
- package/lib/collapse.js +163 -123
- package/lib/color-picker.js +5223 -1251
- package/lib/container.js +98 -88
- package/lib/date-picker.js +8396 -3945
- package/lib/descriptions-item.js +53 -32
- package/lib/descriptions.js +697 -334
- package/lib/dialog.js +1725 -247
- package/lib/directives/mousewheel.js +14 -20
- package/lib/directives/repeat-click.js +27 -30
- package/lib/divider.js +38 -45
- package/lib/drawer.js +1032 -238
- package/lib/dropdown-item.js +159 -111
- package/lib/dropdown-menu.js +2445 -117
- package/lib/dropdown.js +1675 -366
- package/lib/element-ui.common.js +49110 -39985
- package/lib/empty.js +1084 -203
- package/lib/fileUpload.js +3900 -0
- package/lib/footer.js +29 -29
- package/lib/form-item.js +1236 -467
- package/lib/form.js +326 -258
- package/lib/header.js +80 -80
- package/lib/icon.js +71 -68
- package/lib/image.js +2389 -743
- package/lib/index.js +1 -1
- package/lib/infinite-scroll.js +814 -150
- package/lib/input-number.js +2181 -444
- package/lib/input.js +1197 -517
- package/lib/link.js +117 -135
- package/lib/loading.js +1130 -363
- package/lib/locale/format.js +38 -49
- package/lib/locale/index.js +38 -52
- package/lib/locale/lang/af-ZA.js +130 -123
- package/lib/locale/lang/ar.js +123 -122
- package/lib/locale/lang/az.js +122 -121
- package/lib/locale/lang/bg.js +133 -123
- package/lib/locale/lang/bn.js +121 -121
- package/lib/locale/lang/ca.js +123 -122
- package/lib/locale/lang/cs-CZ.js +127 -125
- package/lib/locale/lang/da.js +124 -122
- package/lib/locale/lang/de.js +126 -124
- package/lib/locale/lang/ee.js +125 -123
- package/lib/locale/lang/el.js +125 -123
- package/lib/locale/lang/en.js +127 -123
- package/lib/locale/lang/eo.js +125 -123
- package/lib/locale/lang/es.js +123 -122
- package/lib/locale/lang/eu.js +128 -123
- package/lib/locale/lang/fa.js +125 -123
- package/lib/locale/lang/fi.js +125 -123
- package/lib/locale/lang/fr.js +125 -122
- package/lib/locale/lang/he.js +130 -123
- package/lib/locale/lang/hr.js +128 -123
- package/lib/locale/lang/hu.js +124 -122
- package/lib/locale/lang/hy-AM.js +125 -123
- package/lib/locale/lang/id.js +124 -123
- package/lib/locale/lang/is.js +124 -123
- package/lib/locale/lang/it.js +123 -122
- package/lib/locale/lang/ja.js +125 -123
- package/lib/locale/lang/kg.js +125 -123
- package/lib/locale/lang/km.js +124 -123
- package/lib/locale/lang/ko.js +125 -123
- package/lib/locale/lang/ku.js +125 -123
- package/lib/locale/lang/kz.js +125 -123
- package/lib/locale/lang/lo-LA.js +121 -121
- package/lib/locale/lang/lt.js +125 -123
- package/lib/locale/lang/lv.js +125 -123
- package/lib/locale/lang/mn.js +125 -123
- package/lib/locale/lang/ms.js +123 -122
- package/lib/locale/lang/nb-NO.js +123 -122
- package/lib/locale/lang/nl.js +125 -123
- package/lib/locale/lang/pl.js +125 -123
- package/lib/locale/lang/pt-br.js +124 -123
- package/lib/locale/lang/pt.js +133 -123
- package/lib/locale/lang/ro.js +125 -123
- package/lib/locale/lang/ru-RU.js +124 -123
- package/lib/locale/lang/si.js +127 -123
- package/lib/locale/lang/sk.js +126 -125
- package/lib/locale/lang/sl.js +125 -123
- package/lib/locale/lang/sr-Latn.js +124 -123
- package/lib/locale/lang/sr.js +128 -123
- package/lib/locale/lang/sv-SE.js +128 -123
- package/lib/locale/lang/sw.js +127 -123
- package/lib/locale/lang/ta.js +130 -122
- package/lib/locale/lang/th.js +127 -123
- package/lib/locale/lang/tk.js +129 -123
- package/lib/locale/lang/tr-TR.js +125 -123
- package/lib/locale/lang/ua.js +124 -123
- package/lib/locale/lang/ug-CN.js +124 -123
- package/lib/locale/lang/uz-UZ.js +124 -123
- package/lib/locale/lang/vi.js +124 -123
- package/lib/locale/lang/zh-CN.js +124 -123
- package/lib/locale/lang/zh-TW.js +128 -123
- package/lib/main.js +23 -21
- package/lib/menu-item-group.js +105 -111
- package/lib/menu-item.js +3558 -253
- package/lib/menu.js +1680 -528
- package/lib/message-box.js +3427 -684
- package/lib/message.js +1677 -229
- package/lib/mixins/emitter.js +28 -30
- package/lib/mixins/focus.js +10 -11
- package/lib/mixins/locale.js +12 -14
- package/lib/mixins/migrating.js +38 -45
- package/lib/notification.js +1707 -269
- package/lib/option-group.js +190 -139
- package/lib/option.js +949 -196
- package/lib/page-header.js +964 -42
- package/lib/pagination.js +6947 -641
- package/lib/popconfirm.js +3951 -223
- package/lib/popover.js +3247 -369
- package/lib/progress.js +254 -244
- package/lib/radio-button.js +259 -226
- package/lib/radio-group.js +249 -186
- package/lib/radio.js +263 -253
- package/lib/rate.js +1399 -420
- package/lib/result.js +183 -227
- package/lib/row.js +58 -41
- package/lib/scrollbar.js +1331 -278
- package/lib/select.js +5816 -1428
- package/lib/skeleton-item.js +133 -145
- package/lib/skeleton.js +82 -91
- package/lib/slider.js +5157 -702
- package/lib/spinner.js +113 -101
- package/lib/statistic.js +10205 -254
- package/lib/step.js +274 -311
- package/lib/steps.js +854 -117
- package/lib/subTitle.js +292 -0
- package/lib/submenu.js +2867 -429
- package/lib/switch.js +1051 -291
- package/lib/tab-pane.js +125 -135
- package/lib/tabDialog.js +2658 -0
- package/lib/table-column.js +1975 -751
- package/lib/table.js +8019 -3979
- package/lib/tabs.js +1455 -605
- package/lib/tag.js +73 -68
- package/lib/theme-chalk/src/index.scss +3 -0
- package/lib/time-picker.js +6821 -1944
- package/lib/time-select.js +6297 -1186
- package/lib/timeline-item.js +43 -84
- package/lib/timeline.js +43 -39
- package/lib/tooltip.js +3185 -287
- package/lib/transfer.js +2943 -625
- package/lib/transitions/collapse-transition.js +69 -87
- package/lib/tree.js +3312 -1791
- package/lib/treeSelect.js +4436 -0
- package/lib/umd/locale/af-ZA.js +145 -138
- package/lib/umd/locale/ar.js +138 -137
- package/lib/umd/locale/az.js +139 -137
- package/lib/umd/locale/bg.js +148 -138
- package/lib/umd/locale/bn.js +138 -137
- package/lib/umd/locale/ca.js +138 -137
- package/lib/umd/locale/cs-CZ.js +142 -140
- package/lib/umd/locale/da.js +139 -137
- package/lib/umd/locale/de.js +141 -139
- package/lib/umd/locale/ee.js +140 -138
- package/lib/umd/locale/el.js +140 -138
- package/lib/umd/locale/en.js +142 -138
- package/lib/umd/locale/eo.js +140 -138
- package/lib/umd/locale/es.js +138 -137
- package/lib/umd/locale/eu.js +143 -138
- package/lib/umd/locale/fa.js +140 -138
- package/lib/umd/locale/fi.js +140 -138
- package/lib/umd/locale/fr.js +140 -137
- package/lib/umd/locale/he.js +145 -138
- package/lib/umd/locale/hr.js +143 -138
- package/lib/umd/locale/hu.js +139 -137
- package/lib/umd/locale/hy-AM.js +140 -138
- package/lib/umd/locale/id.js +139 -138
- package/lib/umd/locale/is.js +139 -138
- package/lib/umd/locale/it.js +138 -137
- package/lib/umd/locale/ja.js +140 -138
- package/lib/umd/locale/kg.js +140 -138
- package/lib/umd/locale/km.js +139 -138
- package/lib/umd/locale/ko.js +140 -138
- package/lib/umd/locale/ku.js +140 -138
- package/lib/umd/locale/kz.js +140 -138
- package/lib/umd/locale/lo-LA.js +138 -137
- package/lib/umd/locale/lt.js +140 -138
- package/lib/umd/locale/lv.js +140 -138
- package/lib/umd/locale/mn.js +140 -138
- package/lib/umd/locale/ms.js +138 -137
- package/lib/umd/locale/nb-NO.js +138 -137
- package/lib/umd/locale/nl.js +140 -138
- package/lib/umd/locale/pl.js +140 -138
- package/lib/umd/locale/pt-br.js +139 -138
- package/lib/umd/locale/pt.js +148 -138
- package/lib/umd/locale/ro.js +140 -138
- package/lib/umd/locale/ru-RU.js +139 -138
- package/lib/umd/locale/si.js +142 -138
- package/lib/umd/locale/sk.js +141 -140
- package/lib/umd/locale/sl.js +140 -138
- package/lib/umd/locale/sr-Latn.js +139 -138
- package/lib/umd/locale/sr.js +143 -138
- package/lib/umd/locale/sv-SE.js +143 -138
- package/lib/umd/locale/sw.js +142 -138
- package/lib/umd/locale/ta.js +145 -137
- package/lib/umd/locale/th.js +142 -138
- package/lib/umd/locale/tk.js +144 -138
- package/lib/umd/locale/tr-TR.js +140 -138
- package/lib/umd/locale/ua.js +139 -138
- package/lib/umd/locale/ug-CN.js +139 -138
- package/lib/umd/locale/uz-UZ.js +139 -138
- package/lib/umd/locale/vi.js +139 -138
- package/lib/umd/locale/zh-CN.js +139 -138
- package/lib/umd/locale/zh-TW.js +143 -138
- package/lib/upload.js +2377 -987
- package/lib/utils/after-leave.js +36 -33
- package/lib/utils/aria-dialog.js +55 -73
- package/lib/utils/aria-utils.js +67 -76
- package/lib/utils/clickoutside.js +52 -60
- package/lib/utils/date-util.js +198 -241
- package/lib/utils/date.js +6 -368
- package/lib/utils/date_source.js +349 -0
- package/lib/utils/dom.js +167 -183
- package/lib/utils/lodash.js +13 -9421
- package/lib/utils/lodash_source.js +9421 -0
- package/lib/utils/menu/aria-menubar.js +13 -18
- package/lib/utils/menu/aria-menuitem.js +43 -54
- package/lib/utils/menu/aria-submenu.js +50 -59
- package/lib/utils/merge.js +15 -17
- package/lib/utils/popper.js +1141 -1170
- package/lib/utils/popup/index.js +186 -230
- package/lib/utils/popup/popup-manager.js +159 -191
- package/lib/utils/resize-event.js +29 -44
- package/lib/utils/scroll-into-view.js +25 -33
- package/lib/utils/scrollbar-width.js +25 -36
- package/lib/utils/shared.js +3 -3
- package/lib/utils/types.js +19 -32
- package/lib/utils/util.js +187 -221
- package/lib/utils/vdom.js +5 -9
- package/lib/utils/vue-popper.js +166 -188
- package/package.json +22 -19
- package/packages/alert/src/main.vue +63 -63
- package/packages/aside/src/main.vue +9 -9
- package/packages/autocomplete/src/autocomplete-suggestions.vue +46 -46
- package/packages/autocomplete/src/autocomplete.vue +198 -198
- package/packages/avatar/src/main.vue +5 -5
- package/packages/backtop/src/main.vue +3 -3
- package/packages/badge/src/main.vue +1 -1
- package/packages/breadcrumb/src/breadcrumb-item.vue +26 -26
- package/packages/breadcrumb/src/breadcrumb.vue +22 -22
- package/packages/button/src/button-group.vue +3 -3
- package/packages/button/src/button.vue +44 -44
- package/packages/calendar/src/date-table.vue +3 -3
- package/packages/calendar/src/main.vue +7 -7
- package/packages/card/src/main.vue +9 -9
- package/packages/carousel/src/item.vue +98 -98
- package/packages/carousel/src/main.vue +2 -2
- package/packages/cascader/src/cascader.vue +4 -4
- package/packages/cascader-panel/src/cascader-menu.vue +4 -4
- package/packages/cascader-panel/src/cascader-node.vue +232 -232
- package/packages/cascader-panel/src/cascader-panel.vue +3 -3
- package/packages/cascader-panel/src/node.js +2 -3
- package/packages/cascader-panel/src/store.js +0 -1
- package/packages/checkbox/src/checkbox-button.vue +139 -139
- package/packages/checkbox/src/checkbox-group.vue +33 -33
- package/packages/checkbox/src/checkbox.vue +140 -140
- package/packages/col/src/col.js +5 -5
- package/packages/collapse/src/collapse-item.vue +55 -55
- package/packages/collapse/src/collapse.vue +54 -54
- package/packages/color-picker/src/color.js +4 -4
- package/packages/color-picker/src/components/alpha-slider.vue +100 -100
- package/packages/color-picker/src/components/hue-slider.vue +91 -91
- package/packages/color-picker/src/components/picker-dropdown.vue +64 -64
- package/packages/color-picker/src/components/predefine.vue +43 -43
- package/packages/color-picker/src/components/sv-panel.vue +70 -70
- package/packages/color-picker/src/main.vue +141 -141
- package/packages/container/src/main.vue +20 -20
- package/packages/date-picker/src/basic/date-table.vue +360 -360
- package/packages/date-picker/src/basic/month-table.vue +222 -223
- package/packages/date-picker/src/basic/time-spinner.vue +174 -174
- package/packages/date-picker/src/basic/year-table.vue +91 -91
- package/packages/date-picker/src/panel/date-range.vue +415 -415
- package/packages/date-picker/src/panel/date.vue +423 -423
- package/packages/date-picker/src/panel/month-range.vue +177 -177
- package/packages/date-picker/src/panel/time-range.vue +173 -173
- package/packages/date-picker/src/panel/time-select.vue +131 -131
- package/packages/date-picker/src/panel/time.vue +131 -131
- package/packages/date-picker/src/picker.vue +7 -7
- package/packages/descriptions/src/descriptions-row.js +3 -3
- package/packages/descriptions/src/index.js +1 -1
- package/packages/dialog/src/component.vue +155 -155
- package/packages/divider/src/main.vue +1 -1
- package/packages/drawer/src/main.vue +2 -2
- package/packages/dropdown/src/dropdown-item.vue +15 -15
- package/packages/dropdown/src/dropdown-menu.vue +47 -47
- package/packages/dropdown/src/dropdown.vue +260 -260
- package/packages/empty/src/index.vue +1 -1
- package/packages/fileUpload/index.js +8 -0
- package/packages/fileUpload/src/main.vue +430 -0
- package/packages/footer/src/main.vue +9 -9
- package/packages/form/src/form-item.vue +245 -245
- package/packages/form/src/form.vue +154 -154
- package/packages/header/src/main.vue +9 -9
- package/packages/icon/src/icon.vue +6 -6
- package/packages/image/src/image-viewer.vue +9 -9
- package/packages/image/src/main.vue +206 -206
- package/packages/infinite-scroll/src/main.js +1 -2
- package/packages/input/src/calcTextareaHeight.js +2 -2
- package/packages/input/src/input.vue +311 -311
- package/packages/input-number/src/input-number.vue +205 -205
- package/packages/loading/src/loading.vue +19 -19
- package/packages/main/src/main.vue +4 -4
- package/packages/menu/src/menu-item-group.vue +27 -27
- package/packages/menu/src/menu-item.vue +69 -69
- package/packages/menu/src/menu.vue +284 -284
- package/packages/menu/src/submenu.vue +308 -309
- package/packages/message/src/main.js +1 -1
- package/packages/message/src/main.vue +72 -72
- package/packages/message-box/src/main.vue +216 -216
- package/packages/notification/src/main.js +1 -1
- package/packages/notification/src/main.vue +93 -93
- package/packages/pagination/src/pager.vue +99 -99
- package/packages/popconfirm/src/main.vue +28 -28
- package/packages/popover/src/main.vue +6 -6
- package/packages/progress/src/progress.vue +174 -174
- package/packages/radio/src/radio-button.vue +64 -64
- package/packages/radio/src/radio-group.vue +88 -88
- package/packages/radio/src/radio.vue +74 -74
- package/packages/rate/src/main.vue +270 -270
- package/packages/row/src/row.js +3 -3
- package/packages/scrollbar/src/main.js +2 -2
- package/packages/scrollbar/src/util.js +1 -1
- package/packages/select/src/option-group.vue +46 -46
- package/packages/select/src/option.vue +122 -122
- package/packages/select/src/select-dropdown.vue +49 -49
- package/packages/select/src/select.vue +676 -676
- package/packages/skeleton/src/item.vue +12 -12
- package/packages/slider/src/button.vue +191 -191
- package/packages/slider/src/main.vue +314 -314
- package/packages/spinner/src/spinner.vue +16 -16
- package/packages/statistic/src/main.vue +5 -6
- package/packages/steps/src/step.vue +2 -2
- package/packages/steps/src/steps.vue +4 -4
- package/packages/subTitle/index.js +8 -0
- package/packages/subTitle/src/main.vue +33 -0
- package/packages/switch/src/component.vue +123 -123
- package/packages/tabDialog/index.js +23 -0
- package/packages/tabDialog/src/dialog/drag.js +63 -0
- package/packages/tabDialog/src/dialog/dragHeight.js +34 -0
- package/packages/tabDialog/src/dialog/dragWidth.js +30 -0
- package/packages/tabDialog/src/main.vue +277 -0
- package/packages/table/src/filter-panel.vue +128 -128
- package/packages/table/src/store/index.js +1 -1
- package/packages/table/src/table-body.js +2 -2
- package/packages/table/src/table-column.js +1 -1
- package/packages/table/src/table-header.js +1 -1
- package/packages/table/src/table-layout.js +1 -1
- package/packages/table/src/table.vue +416 -416
- package/packages/tabs/src/tab-bar.vue +43 -43
- package/packages/tabs/src/tab-nav.vue +250 -250
- package/packages/tabs/src/tab-pane.vue +34 -34
- package/packages/tabs/src/tabs.vue +165 -165
- package/packages/tag/src/tag.vue +52 -52
- package/packages/theme-cy/lib/element.css +1 -0
- package/packages/theme-cy/lib/fileUpload.css +1 -0
- package/packages/theme-cy/lib/index.css +1 -1
- package/packages/theme-cy/lib/subTitle.css +1 -0
- package/packages/theme-cy/lib/tabDialog.css +1 -0
- package/packages/theme-cy/lib/treeselect.css +1 -1
- package/packages/theme-cy/src/element.scss +45 -0
- package/packages/theme-cy/src/fileUpload.scss +30 -0
- package/packages/theme-cy/src/index.scss +4 -0
- package/packages/theme-cy/src/subTitle.scss +26 -0
- package/packages/theme-cy/src/tabDialog.scss +43 -0
- package/packages/theme-cy/src/treeselect.scss +20 -14
- package/packages/timeline/src/item.vue +24 -24
- package/packages/timeline/src/main.vue +27 -27
- package/packages/tooltip/src/main.js +1 -1
- package/packages/transfer/src/main.vue +169 -169
- package/packages/transfer/src/transfer-panel.vue +164 -164
- package/packages/tree/src/tree-node.vue +169 -169
- package/packages/tree/src/tree.vue +408 -408
- package/packages/treeSelect/index.js +8 -0
- package/packages/{treeselect → treeSelect}/src/main.vue +19 -19
- package/packages/upload/src/ajax.js +3 -3
- package/packages/upload/src/upload-dragger.vue +50 -50
- package/packages/upload/src/upload-list.vue +33 -33
- package/packages/upload/src/upload.vue +1 -1
- package/src/index.js +13 -5
- package/src/locale/format.js +0 -1
- package/src/mixins/migrating.js +2 -2
- package/src/utils/date.js +2 -368
- package/src/utils/date_source.js +368 -0
- package/src/utils/lodash.js +9 -18075
- package/src/utils/lodash_source.js +18075 -0
- package/src/utils/types.js +1 -1
- package/types/element-ui.d.ts +16 -3
- package/types/fileUpload.d.ts +5 -0
- package/types/subTitle.d.ts +5 -0
- package/types/tabDialog.d.ts +5 -0
- package/types/treeSelect.d.ts +5 -0
- package/lib/treeselect.js +0 -682
- package/packages/treeselect/index.js +0 -8
- package/types/treeselect.d.ts +0 -5
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
v-show="currentView === 'date'"
|
|
72
72
|
role="button"
|
|
73
73
|
class="el-date-picker__header-label"
|
|
74
|
-
:class="{ active: currentView === 'month' }">{{t(`el.datepicker.month${ month + 1 }`)}}</span>
|
|
74
|
+
:class="{ active: currentView === 'month' }">{{ t(`el.datepicker.month${ month + 1 }`) }}</span>
|
|
75
75
|
<button
|
|
76
76
|
type="button"
|
|
77
77
|
@click="nextYear"
|
|
@@ -145,465 +145,465 @@
|
|
|
145
145
|
</template>
|
|
146
146
|
|
|
147
147
|
<script type="text/babel">
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
},
|
|
192
|
-
|
|
193
|
-
value(val) {
|
|
194
|
-
if (this.selectionMode === 'dates' && this.value) return;
|
|
195
|
-
if (this.selectionMode === 'months' && this.value) return;
|
|
196
|
-
if (this.selectionMode === 'years' && this.value) return;
|
|
197
|
-
if (isDate(val)) {
|
|
198
|
-
this.date = new Date(val);
|
|
199
|
-
} else {
|
|
200
|
-
this.date = this.getDefaultValue();
|
|
148
|
+
import {
|
|
149
|
+
formatDate,
|
|
150
|
+
parseDate,
|
|
151
|
+
getWeekNumber,
|
|
152
|
+
isDate,
|
|
153
|
+
modifyDate,
|
|
154
|
+
modifyTime,
|
|
155
|
+
modifyWithTimeString,
|
|
156
|
+
clearMilliseconds,
|
|
157
|
+
clearTime,
|
|
158
|
+
prevYear,
|
|
159
|
+
nextYear,
|
|
160
|
+
prevMonth,
|
|
161
|
+
nextMonth,
|
|
162
|
+
changeYearMonthAndClampDate,
|
|
163
|
+
extractDateFormat,
|
|
164
|
+
extractTimeFormat,
|
|
165
|
+
timeWithinRange
|
|
166
|
+
} from 'element-ui/src/utils/date-util';
|
|
167
|
+
import Clickoutside from 'element-ui/src/utils/clickoutside';
|
|
168
|
+
import Locale from 'element-ui/src/mixins/locale';
|
|
169
|
+
import ElInput from 'element-ui/packages/input';
|
|
170
|
+
import ElButton from 'element-ui/packages/button';
|
|
171
|
+
import TimePicker from './time';
|
|
172
|
+
import YearTable from '../basic/year-table';
|
|
173
|
+
import MonthTable from '../basic/month-table';
|
|
174
|
+
import DateTable from '../basic/date-table';
|
|
175
|
+
|
|
176
|
+
export default {
|
|
177
|
+
mixins: [Locale],
|
|
178
|
+
|
|
179
|
+
directives: { Clickoutside },
|
|
180
|
+
|
|
181
|
+
watch: {
|
|
182
|
+
showTime(val) {
|
|
183
|
+
/* istanbul ignore if */
|
|
184
|
+
if (!val) return;
|
|
185
|
+
this.$nextTick(_ => {
|
|
186
|
+
const inputElm = this.$refs.input.$el;
|
|
187
|
+
if (inputElm) {
|
|
188
|
+
this.pickerWidth = inputElm.getBoundingClientRect().width + 10;
|
|
201
189
|
}
|
|
202
|
-
}
|
|
190
|
+
});
|
|
191
|
+
},
|
|
203
192
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
193
|
+
value(val) {
|
|
194
|
+
if (this.selectionMode === 'dates' && this.value) return;
|
|
195
|
+
if (this.selectionMode === 'months' && this.value) return;
|
|
196
|
+
if (this.selectionMode === 'years' && this.value) return;
|
|
197
|
+
if (isDate(val)) {
|
|
198
|
+
this.date = new Date(val);
|
|
199
|
+
} else {
|
|
200
|
+
this.date = this.getDefaultValue();
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
defaultValue(val) {
|
|
205
|
+
if (!isDate(this.value)) {
|
|
206
|
+
this.date = val ? new Date(val) : new Date();
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
timePickerVisible(val) {
|
|
211
|
+
if (val) this.$nextTick(() => this.$refs.timepicker.adjustSpinners());
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
selectionMode(newVal) {
|
|
215
|
+
if (newVal === 'month') {
|
|
216
|
+
/* istanbul ignore next */
|
|
217
|
+
if (this.currentView !== 'year' || this.currentView !== 'month') {
|
|
225
218
|
this.currentView = 'month';
|
|
226
219
|
}
|
|
220
|
+
} else if (newVal === 'dates') {
|
|
221
|
+
this.currentView = 'date';
|
|
222
|
+
} else if (newVal === 'years') {
|
|
223
|
+
this.currentView = 'year';
|
|
224
|
+
} else if (newVal === 'months') {
|
|
225
|
+
this.currentView = 'month';
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
methods: {
|
|
231
|
+
proxyTimePickerDataProperties() {
|
|
232
|
+
const format = timeFormat => { this.$refs.timepicker.format = timeFormat; };
|
|
233
|
+
const value = value => { this.$refs.timepicker.value = value; };
|
|
234
|
+
const date = date => { this.$refs.timepicker.date = date; };
|
|
235
|
+
const selectableRange = selectableRange => { this.$refs.timepicker.selectableRange = selectableRange; };
|
|
236
|
+
|
|
237
|
+
this.$watch('value', value);
|
|
238
|
+
this.$watch('date', date);
|
|
239
|
+
this.$watch('selectableRange', selectableRange);
|
|
240
|
+
|
|
241
|
+
format(this.timeFormat);
|
|
242
|
+
value(this.value);
|
|
243
|
+
date(this.date);
|
|
244
|
+
selectableRange(this.selectableRange);
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
handleClear() {
|
|
248
|
+
this.date = this.getDefaultValue();
|
|
249
|
+
this.$emit('pick', null);
|
|
250
|
+
},
|
|
251
|
+
|
|
252
|
+
emit(value, ...args) {
|
|
253
|
+
if (!value) {
|
|
254
|
+
this.$emit('pick', value, ...args);
|
|
255
|
+
} else if (Array.isArray(value)) {
|
|
256
|
+
const dates = value.map(date => this.showTime ? clearMilliseconds(date) : clearTime(date));
|
|
257
|
+
this.$emit('pick', dates, ...args);
|
|
258
|
+
} else {
|
|
259
|
+
this.$emit('pick', this.showTime ? clearMilliseconds(value) : clearTime(value), ...args);
|
|
227
260
|
}
|
|
261
|
+
this.userInputDate = null;
|
|
262
|
+
this.userInputTime = null;
|
|
228
263
|
},
|
|
229
264
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
const value = value => {this.$refs.timepicker.value = value;};
|
|
234
|
-
const date = date => {this.$refs.timepicker.date = date;};
|
|
235
|
-
const selectableRange = selectableRange => {this.$refs.timepicker.selectableRange = selectableRange;};
|
|
265
|
+
// resetDate() {
|
|
266
|
+
// this.date = new Date(this.date);
|
|
267
|
+
// },
|
|
236
268
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
269
|
+
showMonthPicker() {
|
|
270
|
+
this.currentView = 'month';
|
|
271
|
+
},
|
|
240
272
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
selectableRange(this.selectableRange);
|
|
245
|
-
},
|
|
273
|
+
showYearPicker() {
|
|
274
|
+
this.currentView = 'year';
|
|
275
|
+
},
|
|
246
276
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
this.$emit('pick', this.showTime ? clearMilliseconds(value) : clearTime(value), ...args);
|
|
260
|
-
}
|
|
261
|
-
this.userInputDate = null;
|
|
262
|
-
this.userInputTime = null;
|
|
263
|
-
},
|
|
277
|
+
// XXX: 没用到
|
|
278
|
+
// handleLabelClick() {
|
|
279
|
+
// if (this.currentView === 'date') {
|
|
280
|
+
// this.showMonthPicker();
|
|
281
|
+
// } else if (this.currentView === 'month') {
|
|
282
|
+
// this.showYearPicker();
|
|
283
|
+
// }
|
|
284
|
+
// },
|
|
285
|
+
|
|
286
|
+
prevMonth() {
|
|
287
|
+
this.date = prevMonth(this.date);
|
|
288
|
+
},
|
|
264
289
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
290
|
+
nextMonth() {
|
|
291
|
+
this.date = nextMonth(this.date);
|
|
292
|
+
},
|
|
268
293
|
|
|
269
|
-
|
|
294
|
+
prevYear() {
|
|
295
|
+
if (this.currentView === 'year') {
|
|
296
|
+
this.date = prevYear(this.date, 10);
|
|
297
|
+
} else {
|
|
298
|
+
this.date = prevYear(this.date);
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
|
|
302
|
+
nextYear() {
|
|
303
|
+
if (this.currentView === 'year') {
|
|
304
|
+
this.date = nextYear(this.date, 10);
|
|
305
|
+
} else {
|
|
306
|
+
this.date = nextYear(this.date);
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
|
|
310
|
+
handleShortcutClick(shortcut) {
|
|
311
|
+
if (shortcut.onClick) {
|
|
312
|
+
shortcut.onClick(this);
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
handleTimePick(value, visible, first) {
|
|
317
|
+
if (isDate(value)) {
|
|
318
|
+
const newDate = this.value
|
|
319
|
+
? modifyTime(this.value, value.getHours(), value.getMinutes(), value.getSeconds())
|
|
320
|
+
: modifyWithTimeString(this.getDefaultValue(), this.defaultTime);
|
|
321
|
+
this.date = newDate;
|
|
322
|
+
this.emit(this.date, true);
|
|
323
|
+
} else {
|
|
324
|
+
this.emit(value, true);
|
|
325
|
+
}
|
|
326
|
+
if (!first) {
|
|
327
|
+
this.timePickerVisible = visible;
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
|
|
331
|
+
handleTimePickClose() {
|
|
332
|
+
this.timePickerVisible = false;
|
|
333
|
+
},
|
|
334
|
+
|
|
335
|
+
handleMonthPick(month) {
|
|
336
|
+
if (this.selectionMode === 'month') {
|
|
337
|
+
this.date = modifyDate(this.date, this.year, month, 1);
|
|
338
|
+
this.emit(this.date);
|
|
339
|
+
} else if (this.selectionMode === 'months') {
|
|
340
|
+
this.emit(month, true);
|
|
341
|
+
} else {
|
|
342
|
+
this.date = changeYearMonthAndClampDate(this.date, this.year, month);
|
|
343
|
+
// TODO: should emit intermediate value ??
|
|
344
|
+
// this.emit(this.date);
|
|
345
|
+
this.currentView = 'date';
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
|
|
349
|
+
handleDatePick(value) {
|
|
350
|
+
if (this.selectionMode === 'day') {
|
|
351
|
+
let newDate = this.value
|
|
352
|
+
? modifyDate(this.value, value.getFullYear(), value.getMonth(), value.getDate())
|
|
353
|
+
: modifyWithTimeString(value, this.defaultTime);
|
|
354
|
+
// change default time while out of selectableRange
|
|
355
|
+
if (!this.checkDateWithinRange(newDate)) {
|
|
356
|
+
newDate = modifyDate(this.selectableRange[0][0], value.getFullYear(), value.getMonth(), value.getDate());
|
|
357
|
+
}
|
|
358
|
+
this.date = newDate;
|
|
359
|
+
this.emit(this.date, this.showTime);
|
|
360
|
+
} else if (this.selectionMode === 'week') {
|
|
361
|
+
this.emit(value.date);
|
|
362
|
+
} else if (this.selectionMode === 'dates') {
|
|
363
|
+
this.emit(value, true); // set false to keep panel open
|
|
364
|
+
}
|
|
365
|
+
},
|
|
366
|
+
|
|
367
|
+
handleYearPick(year) {
|
|
368
|
+
if (this.selectionMode === 'year') {
|
|
369
|
+
this.date = modifyDate(this.date, year, 0, 1);
|
|
370
|
+
this.emit(this.date);
|
|
371
|
+
} else if (this.selectionMode === 'years') {
|
|
372
|
+
this.emit(year, true);
|
|
373
|
+
} else {
|
|
374
|
+
this.date = changeYearMonthAndClampDate(this.date, year, this.month);
|
|
375
|
+
// TODO: should emit intermediate value ??
|
|
376
|
+
// this.emit(this.date, true);
|
|
270
377
|
this.currentView = 'month';
|
|
271
|
-
}
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
|
|
381
|
+
changeToNow() {
|
|
382
|
+
// NOTE: not a permanent solution
|
|
383
|
+
// consider disable "now" button in the future
|
|
384
|
+
if ((!this.disabledDate || !this.disabledDate(new Date())) && this.checkDateWithinRange(new Date())) {
|
|
385
|
+
this.date = new Date();
|
|
386
|
+
this.emit(this.date);
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
|
|
390
|
+
confirm() {
|
|
391
|
+
if (this.selectionMode === 'dates' || this.selectionMode === 'months' || this.selectionMode === 'years') {
|
|
392
|
+
this.emit(this.value);
|
|
393
|
+
} else {
|
|
394
|
+
// value were emitted in handle{Date,Time}Pick, nothing to update here
|
|
395
|
+
// deal with the scenario where: user opens the picker, then confirm without doing anything
|
|
396
|
+
const value = this.value
|
|
397
|
+
? this.value
|
|
398
|
+
: modifyWithTimeString(this.getDefaultValue(), this.defaultTime);
|
|
399
|
+
this.date = new Date(value); // refresh date
|
|
400
|
+
this.emit(value);
|
|
401
|
+
}
|
|
402
|
+
},
|
|
272
403
|
|
|
273
|
-
|
|
404
|
+
resetView() {
|
|
405
|
+
if (this.selectionMode === 'month' || this.selectionMode === 'months') {
|
|
406
|
+
this.currentView = 'month';
|
|
407
|
+
} else if (this.selectionMode === 'year' || this.selectionMode === 'years') {
|
|
274
408
|
this.currentView = 'year';
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
// if (this.currentView === 'date') {
|
|
280
|
-
// this.showMonthPicker();
|
|
281
|
-
// } else if (this.currentView === 'month') {
|
|
282
|
-
// this.showYearPicker();
|
|
283
|
-
// }
|
|
284
|
-
// },
|
|
285
|
-
|
|
286
|
-
prevMonth() {
|
|
287
|
-
this.date = prevMonth(this.date);
|
|
288
|
-
},
|
|
289
|
-
|
|
290
|
-
nextMonth() {
|
|
291
|
-
this.date = nextMonth(this.date);
|
|
292
|
-
},
|
|
293
|
-
|
|
294
|
-
prevYear() {
|
|
295
|
-
if (this.currentView === 'year') {
|
|
296
|
-
this.date = prevYear(this.date, 10);
|
|
297
|
-
} else {
|
|
298
|
-
this.date = prevYear(this.date);
|
|
299
|
-
}
|
|
300
|
-
},
|
|
409
|
+
} else {
|
|
410
|
+
this.currentView = 'date';
|
|
411
|
+
}
|
|
412
|
+
},
|
|
301
413
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
} else {
|
|
306
|
-
this.date = nextYear(this.date);
|
|
307
|
-
}
|
|
308
|
-
},
|
|
414
|
+
handleEnter() {
|
|
415
|
+
document.body.addEventListener('keydown', this.handleKeydown);
|
|
416
|
+
},
|
|
309
417
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
},
|
|
315
|
-
|
|
316
|
-
handleTimePick(value, visible, first) {
|
|
317
|
-
if (isDate(value)) {
|
|
318
|
-
const newDate = this.value
|
|
319
|
-
? modifyTime(this.value, value.getHours(), value.getMinutes(), value.getSeconds())
|
|
320
|
-
: modifyWithTimeString(this.getDefaultValue(), this.defaultTime);
|
|
321
|
-
this.date = newDate;
|
|
322
|
-
this.emit(this.date, true);
|
|
323
|
-
} else {
|
|
324
|
-
this.emit(value, true);
|
|
325
|
-
}
|
|
326
|
-
if (!first) {
|
|
327
|
-
this.timePickerVisible = visible;
|
|
328
|
-
}
|
|
329
|
-
},
|
|
418
|
+
handleLeave() {
|
|
419
|
+
this.$emit('dodestroy');
|
|
420
|
+
document.body.removeEventListener('keydown', this.handleKeydown);
|
|
421
|
+
},
|
|
330
422
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
} else if (this.selectionMode === 'months') {
|
|
340
|
-
this.emit(month, true);
|
|
341
|
-
} else {
|
|
342
|
-
this.date = changeYearMonthAndClampDate(this.date, this.year, month);
|
|
343
|
-
// TODO: should emit intermediate value ??
|
|
344
|
-
// this.emit(this.date);
|
|
345
|
-
this.currentView = 'date';
|
|
346
|
-
}
|
|
347
|
-
},
|
|
348
|
-
|
|
349
|
-
handleDatePick(value) {
|
|
350
|
-
if (this.selectionMode === 'day') {
|
|
351
|
-
let newDate = this.value
|
|
352
|
-
? modifyDate(this.value, value.getFullYear(), value.getMonth(), value.getDate())
|
|
353
|
-
: modifyWithTimeString(value, this.defaultTime);
|
|
354
|
-
// change default time while out of selectableRange
|
|
355
|
-
if (!this.checkDateWithinRange(newDate)) {
|
|
356
|
-
newDate = modifyDate(this.selectableRange[0][0], value.getFullYear(), value.getMonth(), value.getDate());
|
|
357
|
-
}
|
|
358
|
-
this.date = newDate;
|
|
359
|
-
this.emit(this.date, this.showTime);
|
|
360
|
-
} else if (this.selectionMode === 'week') {
|
|
361
|
-
this.emit(value.date);
|
|
362
|
-
} else if (this.selectionMode === 'dates') {
|
|
363
|
-
this.emit(value, true); // set false to keep panel open
|
|
423
|
+
handleKeydown(event) {
|
|
424
|
+
const keyCode = event.keyCode;
|
|
425
|
+
const list = [38, 40, 37, 39];
|
|
426
|
+
if (this.visible && !this.timePickerVisible) {
|
|
427
|
+
if (list.indexOf(keyCode) !== -1) {
|
|
428
|
+
this.handleKeyControl(keyCode);
|
|
429
|
+
event.stopPropagation();
|
|
430
|
+
event.preventDefault();
|
|
364
431
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
handleYearPick(year) {
|
|
368
|
-
if (this.selectionMode === 'year') {
|
|
369
|
-
this.date = modifyDate(this.date, year, 0, 1);
|
|
370
|
-
this.emit(this.date);
|
|
371
|
-
} else if (this.selectionMode === 'years') {
|
|
372
|
-
this.emit(year, true);
|
|
373
|
-
} else {
|
|
374
|
-
this.date = changeYearMonthAndClampDate(this.date, year, this.month);
|
|
375
|
-
// TODO: should emit intermediate value ??
|
|
376
|
-
// this.emit(this.date, true);
|
|
377
|
-
this.currentView = 'month';
|
|
378
|
-
}
|
|
379
|
-
},
|
|
380
|
-
|
|
381
|
-
changeToNow() {
|
|
382
|
-
// NOTE: not a permanent solution
|
|
383
|
-
// consider disable "now" button in the future
|
|
384
|
-
if ((!this.disabledDate || !this.disabledDate(new Date())) && this.checkDateWithinRange(new Date())) {
|
|
385
|
-
this.date = new Date();
|
|
386
|
-
this.emit(this.date);
|
|
432
|
+
if (keyCode === 13 && this.userInputDate === null && this.userInputTime === null) { // Enter
|
|
433
|
+
this.emit(this.date, false);
|
|
387
434
|
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
confirm() {
|
|
391
|
-
if (this.selectionMode === 'dates' || this.selectionMode === 'months' || this.selectionMode === 'years') {
|
|
392
|
-
this.emit(this.value);
|
|
393
|
-
} else {
|
|
394
|
-
// value were emitted in handle{Date,Time}Pick, nothing to update here
|
|
395
|
-
// deal with the scenario where: user opens the picker, then confirm without doing anything
|
|
396
|
-
const value = this.value
|
|
397
|
-
? this.value
|
|
398
|
-
: modifyWithTimeString(this.getDefaultValue(), this.defaultTime);
|
|
399
|
-
this.date = new Date(value); // refresh date
|
|
400
|
-
this.emit(value);
|
|
401
|
-
}
|
|
402
|
-
},
|
|
435
|
+
}
|
|
436
|
+
},
|
|
403
437
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
handleLeave() {
|
|
419
|
-
this.$emit('dodestroy');
|
|
420
|
-
document.body.removeEventListener('keydown', this.handleKeydown);
|
|
421
|
-
},
|
|
422
|
-
|
|
423
|
-
handleKeydown(event) {
|
|
424
|
-
const keyCode = event.keyCode;
|
|
425
|
-
const list = [38, 40, 37, 39];
|
|
426
|
-
if (this.visible && !this.timePickerVisible) {
|
|
427
|
-
if (list.indexOf(keyCode) !== -1) {
|
|
428
|
-
this.handleKeyControl(keyCode);
|
|
429
|
-
event.stopPropagation();
|
|
430
|
-
event.preventDefault();
|
|
431
|
-
}
|
|
432
|
-
if (keyCode === 13 && this.userInputDate === null && this.userInputTime === null) { // Enter
|
|
433
|
-
this.emit(this.date, false);
|
|
434
|
-
}
|
|
438
|
+
handleKeyControl(keyCode) {
|
|
439
|
+
const mapping = {
|
|
440
|
+
'year': {
|
|
441
|
+
38: -4, 40: 4, 37: -1, 39: 1, offset: (date, step) => date.setFullYear(date.getFullYear() + step)
|
|
442
|
+
},
|
|
443
|
+
'month': {
|
|
444
|
+
38: -4, 40: 4, 37: -1, 39: 1, offset: (date, step) => date.setMonth(date.getMonth() + step)
|
|
445
|
+
},
|
|
446
|
+
'week': {
|
|
447
|
+
38: -1, 40: 1, 37: -1, 39: 1, offset: (date, step) => date.setDate(date.getDate() + step * 7)
|
|
448
|
+
},
|
|
449
|
+
'day': {
|
|
450
|
+
38: -7, 40: 7, 37: -1, 39: 1, offset: (date, step) => date.setDate(date.getDate() + step)
|
|
435
451
|
}
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
'week': {
|
|
447
|
-
38: -1, 40: 1, 37: -1, 39: 1, offset: (date, step) => date.setDate(date.getDate() + step * 7)
|
|
448
|
-
},
|
|
449
|
-
'day': {
|
|
450
|
-
38: -7, 40: 7, 37: -1, 39: 1, offset: (date, step) => date.setDate(date.getDate() + step)
|
|
451
|
-
}
|
|
452
|
-
};
|
|
453
|
-
const mode = this.selectionMode;
|
|
454
|
-
const year = 3.1536e10;
|
|
455
|
-
const now = this.date.getTime();
|
|
456
|
-
const newDate = new Date(this.date.getTime());
|
|
457
|
-
while (Math.abs(now - newDate.getTime()) <= year) {
|
|
458
|
-
const map = mapping[mode];
|
|
459
|
-
map.offset(newDate, map[keyCode]);
|
|
460
|
-
if (typeof this.disabledDate === 'function' && this.disabledDate(newDate)) {
|
|
461
|
-
continue;
|
|
462
|
-
}
|
|
463
|
-
this.date = newDate;
|
|
464
|
-
this.$emit('pick', newDate, true);
|
|
465
|
-
break;
|
|
466
|
-
}
|
|
467
|
-
},
|
|
468
|
-
|
|
469
|
-
handleVisibleTimeChange(value) {
|
|
470
|
-
const time = parseDate(value, this.timeFormat);
|
|
471
|
-
if (time && this.checkDateWithinRange(time)) {
|
|
472
|
-
this.date = modifyDate(time, this.year, this.month, this.monthDate);
|
|
473
|
-
this.userInputTime = null;
|
|
474
|
-
this.$refs.timepicker.value = this.date;
|
|
475
|
-
this.timePickerVisible = false;
|
|
476
|
-
this.emit(this.date, true);
|
|
452
|
+
};
|
|
453
|
+
const mode = this.selectionMode;
|
|
454
|
+
const year = 3.1536e10;
|
|
455
|
+
const now = this.date.getTime();
|
|
456
|
+
const newDate = new Date(this.date.getTime());
|
|
457
|
+
while (Math.abs(now - newDate.getTime()) <= year) {
|
|
458
|
+
const map = mapping[mode];
|
|
459
|
+
map.offset(newDate, map[keyCode]);
|
|
460
|
+
if (typeof this.disabledDate === 'function' && this.disabledDate(newDate)) {
|
|
461
|
+
continue;
|
|
477
462
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
463
|
+
this.date = newDate;
|
|
464
|
+
this.$emit('pick', newDate, true);
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
|
|
469
|
+
handleVisibleTimeChange(value) {
|
|
470
|
+
const time = parseDate(value, this.timeFormat);
|
|
471
|
+
if (time && this.checkDateWithinRange(time)) {
|
|
472
|
+
this.date = modifyDate(time, this.year, this.month, this.monthDate);
|
|
473
|
+
this.userInputTime = null;
|
|
474
|
+
this.$refs.timepicker.value = this.date;
|
|
475
|
+
this.timePickerVisible = false;
|
|
476
|
+
this.emit(this.date, true);
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
|
|
480
|
+
handleVisibleDateChange(value) {
|
|
481
|
+
const date = parseDate(value, this.dateFormat);
|
|
482
|
+
if (date) {
|
|
483
|
+
if (typeof this.disabledDate === 'function' && this.disabledDate(date)) {
|
|
484
|
+
return;
|
|
490
485
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
typeof this.disabledDate === 'function'
|
|
496
|
-
? !this.disabledDate(value)
|
|
497
|
-
: true
|
|
498
|
-
) && this.checkDateWithinRange(value);
|
|
499
|
-
},
|
|
500
|
-
|
|
501
|
-
getDefaultValue() {
|
|
502
|
-
// if default-value is set, return it
|
|
503
|
-
// otherwise, return now (the moment this method gets called)
|
|
504
|
-
return this.defaultValue ? new Date(this.defaultValue) : new Date();
|
|
505
|
-
},
|
|
506
|
-
|
|
507
|
-
checkDateWithinRange(date) {
|
|
508
|
-
return this.selectableRange.length > 0
|
|
509
|
-
? timeWithinRange(date, this.selectableRange, this.format || 'HH:mm:ss')
|
|
510
|
-
: true;
|
|
486
|
+
this.date = modifyTime(date, this.date.getHours(), this.date.getMinutes(), this.date.getSeconds());
|
|
487
|
+
this.userInputDate = null;
|
|
488
|
+
this.resetView();
|
|
489
|
+
this.emit(this.date, true);
|
|
511
490
|
}
|
|
512
491
|
},
|
|
513
492
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
popperClass: '',
|
|
521
|
-
date: new Date(),
|
|
522
|
-
value: '',
|
|
523
|
-
defaultValue: null, // use getDefaultValue() for time computation
|
|
524
|
-
defaultTime: null,
|
|
525
|
-
showTime: false,
|
|
526
|
-
selectionMode: 'day',
|
|
527
|
-
shortcuts: '',
|
|
528
|
-
visible: false,
|
|
529
|
-
currentView: 'date',
|
|
530
|
-
disabledDate: '',
|
|
531
|
-
cellClassName: '',
|
|
532
|
-
selectableRange: [],
|
|
533
|
-
firstDayOfWeek: 7,
|
|
534
|
-
showWeekNumber: false,
|
|
535
|
-
timePickerVisible: false,
|
|
536
|
-
format: '',
|
|
537
|
-
arrowControl: false,
|
|
538
|
-
userInputDate: null,
|
|
539
|
-
userInputTime: null
|
|
540
|
-
};
|
|
493
|
+
isValidValue(value) {
|
|
494
|
+
return value && !isNaN(value) && (
|
|
495
|
+
typeof this.disabledDate === 'function'
|
|
496
|
+
? !this.disabledDate(value)
|
|
497
|
+
: true
|
|
498
|
+
) && this.checkDateWithinRange(value);
|
|
541
499
|
},
|
|
542
500
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
501
|
+
getDefaultValue() {
|
|
502
|
+
// if default-value is set, return it
|
|
503
|
+
// otherwise, return now (the moment this method gets called)
|
|
504
|
+
return this.defaultValue ? new Date(this.defaultValue) : new Date();
|
|
505
|
+
},
|
|
547
506
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
507
|
+
checkDateWithinRange(date) {
|
|
508
|
+
return this.selectableRange.length > 0
|
|
509
|
+
? timeWithinRange(date, this.selectableRange, this.format || 'HH:mm:ss')
|
|
510
|
+
: true;
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
|
|
514
|
+
components: {
|
|
515
|
+
TimePicker, YearTable, MonthTable, DateTable, ElInput, ElButton
|
|
516
|
+
},
|
|
517
|
+
|
|
518
|
+
data() {
|
|
519
|
+
return {
|
|
520
|
+
popperClass: '',
|
|
521
|
+
date: new Date(),
|
|
522
|
+
value: '',
|
|
523
|
+
defaultValue: null, // use getDefaultValue() for time computation
|
|
524
|
+
defaultTime: null,
|
|
525
|
+
showTime: false,
|
|
526
|
+
selectionMode: 'day',
|
|
527
|
+
shortcuts: '',
|
|
528
|
+
visible: false,
|
|
529
|
+
currentView: 'date',
|
|
530
|
+
disabledDate: '',
|
|
531
|
+
cellClassName: '',
|
|
532
|
+
selectableRange: [],
|
|
533
|
+
firstDayOfWeek: 7,
|
|
534
|
+
showWeekNumber: false,
|
|
535
|
+
timePickerVisible: false,
|
|
536
|
+
format: '',
|
|
537
|
+
arrowControl: false,
|
|
538
|
+
userInputDate: null,
|
|
539
|
+
userInputTime: null
|
|
540
|
+
};
|
|
541
|
+
},
|
|
542
|
+
|
|
543
|
+
computed: {
|
|
544
|
+
year() {
|
|
545
|
+
return this.date.getFullYear();
|
|
546
|
+
},
|
|
551
547
|
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
548
|
+
month() {
|
|
549
|
+
return this.date.getMonth();
|
|
550
|
+
},
|
|
555
551
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
552
|
+
week() {
|
|
553
|
+
return getWeekNumber(this.date);
|
|
554
|
+
},
|
|
559
555
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
556
|
+
monthDate() {
|
|
557
|
+
return this.date.getDate();
|
|
558
|
+
},
|
|
563
559
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
} else {
|
|
568
|
-
return formatDate(this.value || this.defaultValue, this.timeFormat);
|
|
569
|
-
}
|
|
570
|
-
},
|
|
560
|
+
footerVisible() {
|
|
561
|
+
return this.showTime || this.selectionMode === 'dates' || this.selectionMode === 'months' || this.selectionMode === 'years';
|
|
562
|
+
},
|
|
571
563
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
return startYear + ' - ' + (startYear + 9);
|
|
588
|
-
}
|
|
589
|
-
return this.year + ' ' + yearTranslation;
|
|
590
|
-
},
|
|
591
|
-
|
|
592
|
-
timeFormat() {
|
|
593
|
-
if (this.format) {
|
|
594
|
-
return extractTimeFormat(this.format);
|
|
595
|
-
} else {
|
|
596
|
-
return 'HH:mm:ss';
|
|
597
|
-
}
|
|
598
|
-
},
|
|
564
|
+
visibleTime() {
|
|
565
|
+
if (this.userInputTime !== null) {
|
|
566
|
+
return this.userInputTime;
|
|
567
|
+
} else {
|
|
568
|
+
return formatDate(this.value || this.defaultValue, this.timeFormat);
|
|
569
|
+
}
|
|
570
|
+
},
|
|
571
|
+
|
|
572
|
+
visibleDate() {
|
|
573
|
+
if (this.userInputDate !== null) {
|
|
574
|
+
return this.userInputDate;
|
|
575
|
+
} else {
|
|
576
|
+
return formatDate(this.value || this.defaultValue, this.dateFormat);
|
|
577
|
+
}
|
|
578
|
+
},
|
|
599
579
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
580
|
+
yearLabel() {
|
|
581
|
+
const yearTranslation = this.t('el.datepicker.year');
|
|
582
|
+
if (this.currentView === 'year') {
|
|
583
|
+
const startYear = Math.floor(this.year / 10) * 10;
|
|
584
|
+
if (yearTranslation) {
|
|
585
|
+
return startYear + ' ' + yearTranslation + ' - ' + (startYear + 9) + ' ' + yearTranslation;
|
|
605
586
|
}
|
|
587
|
+
return startYear + ' - ' + (startYear + 9);
|
|
588
|
+
}
|
|
589
|
+
return this.year + ' ' + yearTranslation;
|
|
590
|
+
},
|
|
591
|
+
|
|
592
|
+
timeFormat() {
|
|
593
|
+
if (this.format) {
|
|
594
|
+
return extractTimeFormat(this.format);
|
|
595
|
+
} else {
|
|
596
|
+
return 'HH:mm:ss';
|
|
597
|
+
}
|
|
598
|
+
},
|
|
599
|
+
|
|
600
|
+
dateFormat() {
|
|
601
|
+
if (this.format) {
|
|
602
|
+
return extractDateFormat(this.format);
|
|
603
|
+
} else {
|
|
604
|
+
return 'yyyy-MM-dd';
|
|
606
605
|
}
|
|
607
606
|
}
|
|
608
|
-
}
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
609
|
</script>
|