zartui 2.1.6 → 2.1.8
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/es/action-sheet/index.js +15 -26
- package/es/area/index.js +5 -41
- package/es/avatar/index.js +3 -16
- package/es/back-top/index.js +4 -19
- package/es/badge/index.js +4 -12
- package/es/button/index.js +20 -40
- package/es/calendar/components/Header.js +3 -12
- package/es/calendar/components/Month.js +12 -65
- package/es/calendar/index.js +23 -94
- package/es/calendar/types.js +9 -15
- package/es/calendar/utils.js +5 -16
- package/es/cascader/index.js +4 -37
- package/es/cell/index.js +19 -37
- package/es/cell-group/index.js +5 -8
- package/es/checkbox/index.js +4 -11
- package/es/checkbox-group/index.js +4 -9
- package/es/col/index.js +6 -11
- package/es/collapse/index.js +2 -5
- package/es/collapse-item/index.js +19 -35
- package/es/count-down/index.js +2 -15
- package/es/count-down/utils.js +3 -10
- package/es/datetime-picker/DatePicker.js +12 -70
- package/es/datetime-picker/TimePicker.js +10 -23
- package/es/datetime-picker/index.js +2 -26
- package/es/datetime-picker/shared.js +5 -21
- package/es/datetime-picker/utils.js +0 -5
- package/es/dialog/Dialog.js +6 -21
- package/es/dialog/index.js +0 -16
- package/es/divider/index.js +5 -6
- package/es/dropdown-item/index.js +13 -39
- package/es/dropdown-menu/index.js +4 -9
- package/es/empty/images/Developing.js +0 -3
- package/es/empty/images/EmptyInterface.js +0 -3
- package/es/empty/images/EmptyResult.js +0 -3
- package/es/empty/images/FindNull.js +0 -3
- package/es/empty/images/NetworkError.js +0 -3
- package/es/empty/images/NotFound.js +0 -3
- package/es/empty/images/ReportSuccess.js +0 -3
- package/es/empty/images/Restricted.js +0 -3
- package/es/empty/images/ServerError.js +0 -3
- package/es/empty/index.js +3 -11
- package/es/field/index.js +21 -86
- package/es/fold-dialog/index.js +5 -20
- package/es/form/index.js +2 -18
- package/es/grid/index.js +2 -6
- package/es/grid-item/index.js +18 -30
- package/es/hierarchy-select/breadcrumb.js +2 -6
- package/es/hierarchy-select/index.js +4 -14
- package/es/hierarchy-select/markList.js +5 -30
- package/es/hierarchy-select/svg/SubIcon.js +0 -1
- package/es/icon/index.js +9 -13
- package/es/image/index.js +3 -19
- package/es/image-preview/ImagePreview.js +4 -8
- package/es/image-preview/ImagePreviewItem.js +14 -30
- package/es/image-preview/index.js +0 -12
- package/es/image-preview/shared.js +2 -4
- package/es/index-anchor/index.js +2 -6
- package/es/index-bar/IndexIndicate.js +0 -1
- package/es/index-bar/index.js +7 -28
- package/es/index.js +1 -4
- package/es/info/index.js +6 -8
- package/es/list/index.js +11 -27
- package/es/loading/index.js +7 -15
- package/es/locale/index.js +0 -2
- package/es/media-picker/index.js +35 -128
- package/es/media-picker/media-util.js +2 -5
- package/es/media-picker/type.js +9 -14
- package/es/media-picker/wx-util.js +0 -1
- package/es/media-player/index.js +7 -19
- package/es/mixins/bind-event.js +0 -3
- package/es/mixins/checkbox.js +5 -11
- package/es/mixins/click-outside.js +0 -2
- package/es/mixins/close-on-popstate.js +0 -1
- package/es/mixins/field.js +0 -2
- package/es/mixins/popup/index.js +12 -28
- package/es/mixins/popup/overlay.js +1 -11
- package/es/mixins/portal.js +2 -8
- package/es/mixins/relation.js +0 -8
- package/es/mixins/slots.js +1 -4
- package/es/mixins/touch.js +4 -9
- package/es/multiple-picker/MultiplePickerOptions.js +3 -20
- package/es/multiple-picker/index.js +5 -17
- package/es/nav-bar/index.js +4 -12
- package/es/notice-bar/index.js +10 -28
- package/es/number-keyboard/Key.js +2 -10
- package/es/number-keyboard/index.js +4 -19
- package/es/overlay/index.js +5 -8
- package/es/password-input/index.js +10 -16
- package/es/picker/PickerColumn.js +21 -56
- package/es/picker/index.js +12 -45
- package/es/popover/index.js +65 -90
- package/es/popup/index.js +5 -21
- package/es/pull-refresh/index.js +10 -29
- package/es/radio/index.js +2 -4
- package/es/radio-group/index.js +2 -4
- package/es/rate/index.js +12 -26
- package/es/row/index.js +3 -9
- package/es/search/index.js +9 -15
- package/es/signature/bezier.js +13 -20
- package/es/signature/force-landscape.js +0 -5
- package/es/signature/index.js +5 -24
- package/es/signature/point.js +1 -6
- package/es/signature/throttle.js +1 -10
- package/es/skeleton/index.js +5 -15
- package/es/slider/index.js +19 -55
- package/es/step/index.js +5 -12
- package/es/stepper/index.js +11 -39
- package/es/steps/index.js +2 -4
- package/es/sticky/index.js +8 -50
- package/es/swipe/index.js +19 -62
- package/es/swipe-cell/index.js +7 -23
- package/es/swipe-item/index.js +10 -19
- package/es/switch/index.js +8 -10
- package/es/switch/shared.js +1 -0
- package/es/switch-cell/index.js +7 -7
- package/es/tab/index.js +4 -15
- package/es/tabbar/index.js +4 -14
- package/es/tabbar-item/index.js +7 -15
- package/es/table/index.js +5 -28
- package/es/table/type.js +3 -4
- package/es/tabs/Content.js +5 -9
- package/es/tabs/Title.js +11 -20
- package/es/tabs/index.js +16 -51
- package/es/tabs/utils.js +0 -8
- package/es/tag/index.js +13 -17
- package/es/text-ellipsis/index.js +25 -42
- package/es/timeline/index.js +2 -25
- package/es/toast/Toast.js +11 -23
- package/es/toast/index.js +6 -33
- package/es/toast/lock-click.js +0 -2
- package/es/uploader/index.js +11 -62
- package/es/uploader/utils.js +0 -10
- package/es/utils/constant.js +2 -1
- package/es/utils/create/bem.js +1 -5
- package/es/utils/create/component.js +4 -8
- package/es/utils/create/i18n.js +0 -2
- package/es/utils/deep-assign.js +0 -4
- package/es/utils/deep-clone.js +0 -3
- package/es/utils/dom/event.js +2 -5
- package/es/utils/dom/node.js +0 -1
- package/es/utils/dom/raf.js +7 -6
- package/es/utils/dom/reset-scroll.js +2 -1
- package/es/utils/dom/scroll.js +8 -17
- package/es/utils/dom/style.js +3 -2
- package/es/utils/easings.js +2 -4
- package/es/utils/format/date-util.js +54 -122
- package/es/utils/format/number.js +2 -11
- package/es/utils/format/string.js +0 -3
- package/es/utils/format/unit.js +2 -12
- package/es/utils/functional.js +6 -9
- package/es/utils/getScroll.js +0 -5
- package/es/utils/index.js +3 -5
- package/es/utils/interceptor.js +2 -4
- package/es/utils/media/image-util.js +7 -19
- package/es/utils/raf.js +4 -12
- package/es/utils/router.js +7 -6
- package/es/utils/scrollTo.js +10 -15
- package/es/utils/validate/number.js +2 -2
- package/es/utils/vnodes.js +2 -8
- package/lib/action-sheet/index.js +12 -37
- package/lib/area/index.js +7 -48
- package/lib/avatar/index.js +5 -21
- package/lib/back-top/index.js +6 -28
- package/lib/badge/index.js +6 -18
- package/lib/button/index.js +20 -52
- package/lib/calendar/FastForwardImg.js +2 -3
- package/lib/calendar/SlowForwardImg.js +2 -3
- package/lib/calendar/components/Header.js +5 -21
- package/lib/calendar/components/Month.js +14 -74
- package/lib/calendar/index.js +23 -109
- package/lib/calendar/types.js +11 -22
- package/lib/calendar/utils.js +18 -46
- package/lib/cascader/index.js +6 -49
- package/lib/cell/index.js +19 -50
- package/lib/cell/shared.js +2 -3
- package/lib/cell-group/index.js +6 -17
- package/lib/checkbox/index.js +6 -17
- package/lib/checkbox-group/index.js +6 -16
- package/lib/col/index.js +8 -17
- package/lib/collapse/index.js +4 -11
- package/lib/collapse-item/index.js +20 -46
- package/lib/count-down/index.js +4 -22
- package/lib/count-down/utils.js +5 -17
- package/lib/datetime-picker/DatePicker.js +14 -84
- package/lib/datetime-picker/TimePicker.js +12 -33
- package/lib/datetime-picker/index.js +7 -41
- package/lib/datetime-picker/shared.js +9 -35
- package/lib/datetime-picker/utils.js +2 -11
- package/lib/dialog/Dialog.js +8 -31
- package/lib/dialog/index.js +1 -24
- package/lib/divider/index.js +6 -14
- package/lib/dropdown-item/index.js +14 -52
- package/lib/dropdown-menu/index.js +6 -18
- package/lib/empty/context.js +2 -3
- package/lib/empty/images/Developing.js +2 -9
- package/lib/empty/images/EmptyInterface.js +2 -9
- package/lib/empty/images/EmptyResult.js +2 -9
- package/lib/empty/images/FindNull.js +2 -9
- package/lib/empty/images/NetworkError.js +2 -9
- package/lib/empty/images/NotFound.js +2 -9
- package/lib/empty/images/ReportSuccess.js +2 -9
- package/lib/empty/images/Restricted.js +2 -9
- package/lib/empty/images/ServerError.js +2 -9
- package/lib/empty/index.js +5 -26
- package/lib/field/ClearIcon.js +2 -3
- package/lib/field/SearchIcon.js +2 -3
- package/lib/field/index.js +22 -99
- package/lib/fold-dialog/index.js +7 -25
- package/lib/form/index.js +4 -24
- package/lib/grid/index.js +4 -13
- package/lib/grid-item/index.js +19 -40
- package/lib/hierarchy-select/breadcrumb.js +5 -13
- package/lib/hierarchy-select/index.js +7 -25
- package/lib/hierarchy-select/markList.js +8 -39
- package/lib/hierarchy-select/svg/SubIcon.js +2 -4
- package/lib/icon/index.js +9 -21
- package/lib/image/index.js +4 -25
- package/lib/image-preview/ImagePreview.js +2 -19
- package/lib/image-preview/ImagePreviewItem.js +15 -39
- package/lib/image-preview/index.js +1 -18
- package/lib/image-preview/shared.js +3 -8
- package/lib/index-anchor/index.js +4 -14
- package/lib/index-bar/IndexIndicate.js +2 -4
- package/lib/index-bar/index.js +9 -40
- package/lib/index.js +5 -164
- package/lib/info/index.js +7 -16
- package/lib/lazyload/index.js +1 -5
- package/lib/list/index.js +12 -36
- package/lib/loading/index.js +8 -23
- package/lib/locale/index.js +2 -10
- package/lib/locale/lang/de-DE-formal.js +2 -3
- package/lib/locale/lang/de-DE.js +2 -3
- package/lib/locale/lang/en-US.js +2 -3
- package/lib/locale/lang/es-ES.js +2 -3
- package/lib/locale/lang/fr-FR.js +2 -3
- package/lib/locale/lang/ja-JP.js +2 -3
- package/lib/locale/lang/nb-NO.js +2 -3
- package/lib/locale/lang/ro-RO.js +2 -3
- package/lib/locale/lang/th-TH.js +2 -3
- package/lib/locale/lang/tr-TR.js +2 -3
- package/lib/locale/lang/zh-CN.js +2 -3
- package/lib/locale/lang/zh-HK.js +2 -3
- package/lib/locale/lang/zh-TW.js +2 -3
- package/lib/media-picker/image/DefaultAudioIcon.js +2 -3
- package/lib/media-picker/image/DefaultDocIcon.js +2 -3
- package/lib/media-picker/image/DefaultExcelIcon.js +2 -3
- package/lib/media-picker/image/DefaultFileIcon.js +2 -3
- package/lib/media-picker/image/DefaultPdfIcon.js +2 -3
- package/lib/media-picker/image/DefaultPptIcon.js +2 -3
- package/lib/media-picker/image/DefaultTextIcon.js +2 -3
- package/lib/media-picker/image/DefaultVideoIcon.js +2 -3
- package/lib/media-picker/image/DeleteIcon.js +2 -3
- package/lib/media-picker/image/Img64.js +4 -7
- package/lib/media-picker/image/PickFileIcon.js +2 -3
- package/lib/media-picker/image/PickPhotoIcon.js +2 -3
- package/lib/media-picker/image/ReUpload.js +2 -3
- package/lib/media-picker/image/TakeAudioIcon.js +2 -3
- package/lib/media-picker/image/TakePhotoIcon.js +2 -3
- package/lib/media-picker/image/TakeVideoIcon.js +2 -3
- package/lib/media-picker/index.js +33 -172
- package/lib/media-picker/media-util.js +9 -22
- package/lib/media-picker/type.js +10 -18
- package/lib/media-picker/wx-util.js +4 -15
- package/lib/media-player/index.js +8 -27
- package/lib/mixins/bind-event.js +1 -6
- package/lib/mixins/checkbox.js +8 -21
- package/lib/mixins/click-outside.js +3 -8
- package/lib/mixins/close-on-popstate.js +2 -7
- package/lib/mixins/field.js +2 -5
- package/lib/mixins/popup/context.js +2 -3
- package/lib/mixins/popup/index.js +12 -38
- package/lib/mixins/popup/overlay.js +3 -25
- package/lib/mixins/portal.js +2 -9
- package/lib/mixins/relation.js +0 -11
- package/lib/mixins/slots.js +3 -8
- package/lib/mixins/touch.js +6 -14
- package/lib/multiple-picker/MultiplePickerOptions.js +4 -26
- package/lib/multiple-picker/index.js +7 -29
- package/lib/multiple-picker/shared.js +3 -5
- package/lib/nav-bar/index.js +6 -19
- package/lib/notice-bar/CloseIcon.js +2 -3
- package/lib/notice-bar/MenuIcon.js +2 -3
- package/lib/notice-bar/NoticeIcon.js +2 -3
- package/lib/notice-bar/OpenIcon.js +2 -3
- package/lib/notice-bar/TipIcon.js +2 -3
- package/lib/notice-bar/WarningIcon.js +2 -3
- package/lib/notice-bar/index.js +12 -43
- package/lib/number-keyboard/CollapseIcon.js +2 -3
- package/lib/number-keyboard/DeleteIcon.js +2 -3
- package/lib/number-keyboard/Key.js +4 -20
- package/lib/number-keyboard/index.js +6 -29
- package/lib/overlay/index.js +6 -18
- package/lib/password-input/index.js +11 -25
- package/lib/picker/PickerColumn.js +24 -71
- package/lib/picker/index.js +14 -59
- package/lib/picker/shared.js +3 -5
- package/lib/popover/index.js +65 -104
- package/lib/popup/index.js +7 -30
- package/lib/pull-refresh/index.js +11 -38
- package/lib/radio/index.js +4 -10
- package/lib/radio-group/index.js +4 -11
- package/lib/rate/index.js +13 -34
- package/lib/row/index.js +5 -15
- package/lib/search/index.js +8 -23
- package/lib/signature/bezier.js +14 -25
- package/lib/signature/force-landscape.js +5 -19
- package/lib/signature/index.js +8 -34
- package/lib/signature/point.js +2 -11
- package/lib/signature/throttle.js +1 -11
- package/lib/skeleton/index.js +6 -23
- package/lib/slider/index.js +21 -66
- package/lib/step/index.js +7 -21
- package/lib/stepper/index.js +12 -49
- package/lib/steps/index.js +4 -10
- package/lib/sticky/index.js +10 -62
- package/lib/swipe/index.js +21 -73
- package/lib/swipe-cell/index.js +9 -32
- package/lib/swipe-item/index.js +12 -27
- package/lib/switch/index.js +9 -17
- package/lib/switch/shared.js +3 -4
- package/lib/switch-cell/index.js +7 -18
- package/lib/tab/index.js +6 -24
- package/lib/tabbar/index.js +6 -22
- package/lib/tabbar-item/index.js +7 -24
- package/lib/table/index.js +7 -38
- package/lib/table/type.js +3 -5
- package/lib/tabs/Content.js +7 -18
- package/lib/tabs/Title.js +13 -27
- package/lib/tabs/index.js +17 -68
- package/lib/tabs/utils.js +0 -13
- package/lib/tag/index.js +13 -25
- package/lib/text-ellipsis/index.js +27 -49
- package/lib/timeline/index.js +4 -35
- package/lib/timeline/svg/current.js +2 -3
- package/lib/timeline/svg/pass.js +2 -3
- package/lib/toast/Toast.js +12 -33
- package/lib/toast/index.js +7 -40
- package/lib/toast/lock-click.js +0 -3
- package/lib/toast/svg/SuccessIcon.js +2 -3
- package/lib/toast/svg/WarnIcon.js +2 -3
- package/lib/uploader/index.js +12 -75
- package/lib/uploader/utils.js +4 -21
- package/lib/utils/constant.js +12 -21
- package/lib/utils/create/bem.js +1 -6
- package/lib/utils/create/component.js +6 -17
- package/lib/utils/create/i18n.js +0 -8
- package/lib/utils/create/index.js +0 -4
- package/lib/utils/deep-assign.js +0 -6
- package/lib/utils/deep-clone.js +0 -5
- package/lib/utils/device.js +1 -3
- package/lib/utils/dom/event.js +5 -14
- package/lib/utils/dom/node.js +0 -2
- package/lib/utils/dom/raf.js +9 -13
- package/lib/utils/dom/reset-scroll.js +2 -4
- package/lib/utils/dom/scroll.js +16 -37
- package/lib/utils/dom/style.js +3 -3
- package/lib/utils/easings.js +2 -5
- package/lib/utils/format/date-util.js +88 -203
- package/lib/utils/format/number.js +4 -15
- package/lib/utils/format/string.js +0 -5
- package/lib/utils/format/unit.js +2 -16
- package/lib/utils/functional.js +7 -15
- package/lib/utils/getScroll.js +1 -8
- package/lib/utils/index.js +10 -26
- package/lib/utils/interceptor.js +2 -6
- package/lib/utils/media/image-util.js +10 -28
- package/lib/utils/raf.js +4 -13
- package/lib/utils/router.js +10 -13
- package/lib/utils/scrollTo.js +12 -24
- package/lib/utils/validate/date.js +0 -2
- package/lib/utils/validate/email.js +0 -1
- package/lib/utils/validate/mobile.js +0 -1
- package/lib/utils/validate/number.js +3 -5
- package/lib/utils/validate/system.js +0 -3
- package/lib/utils/vnodes.js +2 -9
- package/lib/zart.js +2325 -4752
- package/lib/zart.min.js +7 -1
- package/package.json +1 -1
package/es/calendar/index.js
CHANGED
|
@@ -3,8 +3,9 @@ import { raf } from '../utils/dom/raf';
|
|
|
3
3
|
import { isDate } from '../utils/validate/date';
|
|
4
4
|
import { getScrollTop } from '../utils/dom/scroll';
|
|
5
5
|
import { t, bem, copyDate, copyDates, getNextDay, compareDay, calcDateNum, compareMonth, createComponent, getDayByOffset, getPrevDate, getNextDate, getFirstDate, formatMonthTitle } from './utils';
|
|
6
|
-
import { CalendarShowType, CalendarDayType } from './types';
|
|
6
|
+
import { CalendarShowType, CalendarDayType } from './types';
|
|
7
7
|
|
|
8
|
+
// Components
|
|
8
9
|
import Popup from '../popup';
|
|
9
10
|
import Button from '../button';
|
|
10
11
|
import Toast from '../toast';
|
|
@@ -113,41 +114,34 @@ export default createComponent({
|
|
|
113
114
|
},
|
|
114
115
|
months: function months() {
|
|
115
116
|
var months = [];
|
|
116
|
-
|
|
117
117
|
if (this.showType !== CalendarShowType.INLINE && this.lastMinDate && this.lastMaxDate) {
|
|
118
118
|
var cursor = new Date(this.lastMinDate);
|
|
119
119
|
cursor.setDate(1);
|
|
120
|
-
|
|
121
120
|
do {
|
|
122
121
|
months.push(new Date(cursor));
|
|
123
122
|
cursor.setMonth(cursor.getMonth() + 1);
|
|
124
123
|
} while (compareMonth(cursor, this.lastMaxDate) !== 1);
|
|
125
124
|
} else if (this.showType === CalendarShowType.INLINE) {
|
|
126
125
|
var showDate = this.titleTargetDate;
|
|
127
|
-
|
|
128
126
|
if (!Array.isArray(showDate)) {
|
|
129
127
|
months.push(getFirstDate(showDate));
|
|
130
128
|
} else {
|
|
131
129
|
months.push(getFirstDate(showDate[0]));
|
|
132
130
|
}
|
|
133
131
|
}
|
|
134
|
-
|
|
135
132
|
return months;
|
|
136
133
|
},
|
|
137
134
|
buttonDisabled: function buttonDisabled() {
|
|
138
135
|
var type = this.type,
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
currentDate = this.currentDate;
|
|
141
137
|
if (currentDate) {
|
|
142
138
|
if (type === 'range') {
|
|
143
139
|
return !currentDate[0] || !currentDate[1];
|
|
144
140
|
}
|
|
145
|
-
|
|
146
141
|
if (type === 'multiple') {
|
|
147
142
|
return !currentDate.length;
|
|
148
143
|
}
|
|
149
144
|
}
|
|
150
|
-
|
|
151
145
|
return !currentDate;
|
|
152
146
|
},
|
|
153
147
|
dayOffset: function dayOffset() {
|
|
@@ -161,7 +155,6 @@ export default createComponent({
|
|
|
161
155
|
if (!this.lastMinDate) {
|
|
162
156
|
return true;
|
|
163
157
|
}
|
|
164
|
-
|
|
165
158
|
return this.titleTargetDate.getFullYear() > this.lastMinDate.getFullYear();
|
|
166
159
|
},
|
|
167
160
|
// 判断前一个月是否可点击
|
|
@@ -169,7 +162,6 @@ export default createComponent({
|
|
|
169
162
|
if (!this.lastMinDate) {
|
|
170
163
|
return true;
|
|
171
164
|
}
|
|
172
|
-
|
|
173
165
|
var targetYearMonth = getFirstDate(this.titleTargetDate);
|
|
174
166
|
var minDateYearMonth = getFirstDate(this.lastMinDate);
|
|
175
167
|
return compareDay(targetYearMonth, minDateYearMonth) === 1;
|
|
@@ -179,7 +171,6 @@ export default createComponent({
|
|
|
179
171
|
if (!this.lastMaxDate) {
|
|
180
172
|
return true;
|
|
181
173
|
}
|
|
182
|
-
|
|
183
174
|
return this.titleTargetDate.getFullYear() < this.lastMaxDate.getFullYear();
|
|
184
175
|
},
|
|
185
176
|
// 判断后一个月是否可点击
|
|
@@ -187,7 +178,6 @@ export default createComponent({
|
|
|
187
178
|
if (!this.lastMaxDate) {
|
|
188
179
|
return true;
|
|
189
180
|
}
|
|
190
|
-
|
|
191
181
|
var targetYearMonth = getFirstDate(this.titleTargetDate);
|
|
192
182
|
var maxDateYearMonth = getFirstDate(this.lastMaxDate);
|
|
193
183
|
return compareDay(maxDateYearMonth, targetYearMonth) === 1;
|
|
@@ -211,9 +201,7 @@ export default createComponent({
|
|
|
211
201
|
mounted: function mounted() {
|
|
212
202
|
this.init();
|
|
213
203
|
},
|
|
214
|
-
|
|
215
|
-
/* istanbul ignore next */
|
|
216
|
-
activated: function activated() {
|
|
204
|
+
/* istanbul ignore next */activated: function activated() {
|
|
217
205
|
this.init();
|
|
218
206
|
},
|
|
219
207
|
methods: {
|
|
@@ -222,7 +210,6 @@ export default createComponent({
|
|
|
222
210
|
if (date === void 0) {
|
|
223
211
|
date = this.getInitialDate();
|
|
224
212
|
}
|
|
225
|
-
|
|
226
213
|
this.currentDate = date;
|
|
227
214
|
this.titleDate = this.getInitialTitleDate();
|
|
228
215
|
this.scrollIntoView();
|
|
@@ -233,52 +220,43 @@ export default createComponent({
|
|
|
233
220
|
},
|
|
234
221
|
init: function init() {
|
|
235
222
|
var _this = this;
|
|
236
|
-
|
|
237
223
|
if (this.poppable && !this.value) {
|
|
238
224
|
return;
|
|
239
225
|
}
|
|
240
|
-
|
|
241
226
|
this.$nextTick(function () {
|
|
242
227
|
// add Math.floor to avoid decimal height issues
|
|
243
228
|
// https://github.com/youzan/vant/issues/5640
|
|
244
229
|
_this.bodyHeight = Math.floor(_this.$refs.body.getBoundingClientRect().height);
|
|
245
|
-
|
|
246
230
|
_this.onScroll();
|
|
247
|
-
|
|
248
231
|
_this.scrollIntoView();
|
|
249
232
|
});
|
|
250
233
|
},
|
|
251
234
|
// @exposed-api
|
|
252
235
|
scrollToDate: function scrollToDate(targetDate) {
|
|
253
236
|
var _this2 = this;
|
|
254
|
-
|
|
255
237
|
raf(function () {
|
|
256
238
|
var displayed = _this2.value || !_this2.poppable;
|
|
257
|
-
/* istanbul ignore if */
|
|
258
239
|
|
|
240
|
+
/* istanbul ignore if */
|
|
259
241
|
if (!targetDate || !displayed) {
|
|
260
242
|
return;
|
|
261
243
|
}
|
|
262
|
-
|
|
263
244
|
_this2.months.some(function (month, index) {
|
|
264
245
|
if (compareMonth(month, targetDate) === 0) {
|
|
265
246
|
var _this2$$refs = _this2.$refs,
|
|
266
|
-
|
|
267
|
-
|
|
247
|
+
body = _this2$$refs.body,
|
|
248
|
+
months = _this2$$refs.months;
|
|
268
249
|
months[index].scrollIntoView(body);
|
|
269
250
|
return true;
|
|
270
251
|
}
|
|
271
|
-
|
|
272
252
|
return false;
|
|
273
253
|
});
|
|
274
|
-
|
|
275
254
|
_this2.onScroll();
|
|
276
255
|
});
|
|
277
256
|
},
|
|
278
257
|
// scroll to current month
|
|
279
258
|
scrollIntoView: function scrollIntoView() {
|
|
280
259
|
var currentDate = this.currentDate;
|
|
281
|
-
|
|
282
260
|
if (currentDate) {
|
|
283
261
|
var targetDate = this.type === 'single' ? currentDate : currentDate[0];
|
|
284
262
|
this.scrollToDate(targetDate);
|
|
@@ -286,53 +264,42 @@ export default createComponent({
|
|
|
286
264
|
},
|
|
287
265
|
getInitialDate: function getInitialDate() {
|
|
288
266
|
var type = this.type,
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
267
|
+
lastMinDate = this.lastMinDate,
|
|
268
|
+
lastMaxDate = this.lastMaxDate,
|
|
269
|
+
defaultDate = this.defaultDate;
|
|
293
270
|
if (defaultDate === null) {
|
|
294
271
|
return defaultDate;
|
|
295
272
|
}
|
|
296
|
-
|
|
297
273
|
var defaultVal = new Date();
|
|
298
|
-
|
|
299
274
|
if (lastMinDate && compareDay(defaultVal, lastMinDate) === -1) {
|
|
300
275
|
defaultVal = lastMinDate;
|
|
301
276
|
} else if (lastMaxDate && compareDay(defaultVal, lastMaxDate) === 1) {
|
|
302
277
|
defaultVal = lastMaxDate;
|
|
303
278
|
}
|
|
304
|
-
|
|
305
279
|
if (type === 'range') {
|
|
306
280
|
var _ref = defaultDate || [],
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
281
|
+
startDay = _ref[0],
|
|
282
|
+
endDay = _ref[1];
|
|
310
283
|
return [startDay || defaultVal, endDay || getNextDay(defaultVal)];
|
|
311
284
|
}
|
|
312
|
-
|
|
313
285
|
if (type === 'multiple') {
|
|
314
286
|
return defaultDate || [defaultVal];
|
|
315
287
|
}
|
|
316
|
-
|
|
317
288
|
return defaultDate || defaultVal;
|
|
318
289
|
},
|
|
319
290
|
limitDateRange: function limitDateRange(date, minDate, maxDate) {
|
|
320
291
|
if (minDate === void 0) {
|
|
321
292
|
minDate = this.lastMinDate;
|
|
322
293
|
}
|
|
323
|
-
|
|
324
294
|
if (maxDate === void 0) {
|
|
325
295
|
maxDate = this.lastMaxDate;
|
|
326
296
|
}
|
|
327
|
-
|
|
328
297
|
if (minDate && compareDay(date, minDate) === -1) {
|
|
329
298
|
return minDate;
|
|
330
299
|
}
|
|
331
|
-
|
|
332
300
|
if (maxDate && compareDay(date, maxDate) === 1) {
|
|
333
301
|
return maxDate;
|
|
334
302
|
}
|
|
335
|
-
|
|
336
303
|
return date;
|
|
337
304
|
},
|
|
338
305
|
getInitialTitleDate: function getInitialTitleDate() {
|
|
@@ -343,8 +310,8 @@ export default createComponent({
|
|
|
343
310
|
// and find the elements that needs to be rendered
|
|
344
311
|
onScroll: function onScroll() {
|
|
345
312
|
var _this$$refs = this.$refs,
|
|
346
|
-
|
|
347
|
-
|
|
313
|
+
body = _this$$refs.body,
|
|
314
|
+
months = _this$$refs.months;
|
|
348
315
|
var top = getScrollTop(body);
|
|
349
316
|
var bottom = top + this.bodyHeight;
|
|
350
317
|
var heights = months.map(function (item) {
|
|
@@ -352,27 +319,23 @@ export default createComponent({
|
|
|
352
319
|
});
|
|
353
320
|
var heightSum = heights.reduce(function (a, b) {
|
|
354
321
|
return a + b;
|
|
355
|
-
}, 0);
|
|
322
|
+
}, 0);
|
|
356
323
|
|
|
324
|
+
// iOS scroll bounce may exceed the range
|
|
357
325
|
if (bottom > heightSum && top > 0) {
|
|
358
326
|
return;
|
|
359
327
|
}
|
|
360
|
-
|
|
361
328
|
var height = 0;
|
|
362
329
|
var currentMonth;
|
|
363
330
|
var visibleRange = [-1, -1];
|
|
364
|
-
|
|
365
331
|
for (var i = 0; i < months.length; i++) {
|
|
366
332
|
var visible = height <= bottom && height + heights[i] >= top;
|
|
367
|
-
|
|
368
333
|
if (visible) {
|
|
369
334
|
visibleRange[1] = i;
|
|
370
|
-
|
|
371
335
|
if (!currentMonth) {
|
|
372
336
|
currentMonth = months[i];
|
|
373
337
|
visibleRange[0] = i;
|
|
374
338
|
}
|
|
375
|
-
|
|
376
339
|
if (!months[i].showed) {
|
|
377
340
|
months[i].showed = true;
|
|
378
341
|
this.$emit('month-show', {
|
|
@@ -381,15 +344,13 @@ export default createComponent({
|
|
|
381
344
|
});
|
|
382
345
|
}
|
|
383
346
|
}
|
|
384
|
-
|
|
385
347
|
height += heights[i];
|
|
386
348
|
}
|
|
387
|
-
|
|
388
349
|
months.forEach(function (month, index) {
|
|
389
350
|
month.visible = index >= visibleRange[0] - 1 && index <= visibleRange[1] + 1;
|
|
390
351
|
});
|
|
391
|
-
/* istanbul ignore else */
|
|
392
352
|
|
|
353
|
+
/* istanbul ignore else */
|
|
393
354
|
if (currentMonth) {
|
|
394
355
|
this.subtitle = currentMonth.getMonthTitle();
|
|
395
356
|
}
|
|
@@ -398,27 +359,21 @@ export default createComponent({
|
|
|
398
359
|
if (this.readonly) {
|
|
399
360
|
return;
|
|
400
361
|
}
|
|
401
|
-
|
|
402
362
|
var date = item.date;
|
|
403
363
|
var type = this.type,
|
|
404
|
-
|
|
405
|
-
|
|
364
|
+
currentDate = this.currentDate;
|
|
406
365
|
if (item.type === CalendarDayType.PREVIEW) {
|
|
407
366
|
this.titleDate = date;
|
|
408
367
|
}
|
|
409
|
-
|
|
410
368
|
if (type === 'range') {
|
|
411
369
|
if (!currentDate) {
|
|
412
370
|
this.select([date, null]);
|
|
413
371
|
return;
|
|
414
372
|
}
|
|
415
|
-
|
|
416
373
|
var startDay = currentDate[0],
|
|
417
|
-
|
|
418
|
-
|
|
374
|
+
endDay = currentDate[1];
|
|
419
375
|
if (startDay && !endDay) {
|
|
420
376
|
var compareToStart = compareDay(date, startDay);
|
|
421
|
-
|
|
422
377
|
if (compareToStart === 1) {
|
|
423
378
|
this.select([startDay, date], true);
|
|
424
379
|
} else if (compareToStart === -1) {
|
|
@@ -434,22 +389,17 @@ export default createComponent({
|
|
|
434
389
|
this.select([date]);
|
|
435
390
|
return;
|
|
436
391
|
}
|
|
437
|
-
|
|
438
392
|
var selectedIndex;
|
|
439
393
|
var selected = this.currentDate.some(function (dateItem, index) {
|
|
440
394
|
var equal = compareDay(dateItem, date) === 0;
|
|
441
|
-
|
|
442
395
|
if (equal) {
|
|
443
396
|
selectedIndex = index;
|
|
444
397
|
}
|
|
445
|
-
|
|
446
398
|
return equal;
|
|
447
399
|
});
|
|
448
|
-
|
|
449
400
|
if (selected) {
|
|
450
401
|
var _currentDate$splice = currentDate.splice(selectedIndex, 1),
|
|
451
|
-
|
|
452
|
-
|
|
402
|
+
unselectedDate = _currentDate$splice[0];
|
|
453
403
|
this.$emit('unselect', copyDate(unselectedDate));
|
|
454
404
|
} else if (this.maxRange && currentDate.length >= this.maxRange) {
|
|
455
405
|
Toast(this.rangePrompt || t('rangePrompt', this.maxRange));
|
|
@@ -465,16 +415,12 @@ export default createComponent({
|
|
|
465
415
|
},
|
|
466
416
|
select: function select(date, complete) {
|
|
467
417
|
var _this3 = this;
|
|
468
|
-
|
|
469
418
|
var emit = function emit(date) {
|
|
470
419
|
_this3.currentDate = date;
|
|
471
|
-
|
|
472
420
|
_this3.$emit('select', copyDates(_this3.currentDate));
|
|
473
421
|
};
|
|
474
|
-
|
|
475
422
|
if (complete && this.type === 'range') {
|
|
476
423
|
var valid = this.checkRange(date);
|
|
477
|
-
|
|
478
424
|
if (!valid) {
|
|
479
425
|
// auto selected to max range if showConfirm
|
|
480
426
|
if (this.showConfirm) {
|
|
@@ -482,26 +428,21 @@ export default createComponent({
|
|
|
482
428
|
} else {
|
|
483
429
|
emit(date);
|
|
484
430
|
}
|
|
485
|
-
|
|
486
431
|
return;
|
|
487
432
|
}
|
|
488
433
|
}
|
|
489
|
-
|
|
490
434
|
emit(date);
|
|
491
|
-
|
|
492
435
|
if (complete && !this.showConfirm) {
|
|
493
436
|
this.onConfirm();
|
|
494
437
|
}
|
|
495
438
|
},
|
|
496
439
|
checkRange: function checkRange(date) {
|
|
497
440
|
var maxRange = this.maxRange,
|
|
498
|
-
|
|
499
|
-
|
|
441
|
+
rangePrompt = this.rangePrompt;
|
|
500
442
|
if (maxRange && calcDateNum(date) > maxRange) {
|
|
501
443
|
Toast(rangePrompt || t('rangePrompt', maxRange));
|
|
502
444
|
return false;
|
|
503
445
|
}
|
|
504
|
-
|
|
505
446
|
return true;
|
|
506
447
|
},
|
|
507
448
|
onConfirm: function onConfirm() {
|
|
@@ -509,26 +450,21 @@ export default createComponent({
|
|
|
509
450
|
},
|
|
510
451
|
onClickTitleIcon: function onClickTitleIcon(isPreFlag, isMonth, isYear) {
|
|
511
452
|
var curTitleDate = this.titleTargetDate;
|
|
512
|
-
|
|
513
453
|
if (curTitleDate) {
|
|
514
454
|
var targetDate = isPreFlag ? getPrevDate(curTitleDate, isMonth, isYear) : getNextDate(curTitleDate, isMonth, isYear);
|
|
515
|
-
|
|
516
455
|
if (!isDate(targetDate)) {
|
|
517
456
|
return;
|
|
518
457
|
}
|
|
519
|
-
|
|
520
458
|
var hasCompared = false;
|
|
521
459
|
var compareDate = isPreFlag ? this.lastMinDate : this.lastMaxDate;
|
|
522
|
-
var compareValue = isPreFlag ? 1 : -1;
|
|
523
|
-
|
|
460
|
+
var compareValue = isPreFlag ? 1 : -1;
|
|
461
|
+
// 超最小值则取最小值
|
|
524
462
|
if (compareDate && compareDay(compareDate, targetDate) === compareValue && compareMonth(compareDate, targetDate) === 0) {
|
|
525
463
|
targetDate = compareDate;
|
|
526
464
|
hasCompared = true;
|
|
527
465
|
}
|
|
528
|
-
|
|
529
466
|
if (hasCompared || !compareDate || compareDate && compareDay(compareDate, targetDate) !== compareValue) {
|
|
530
467
|
this.scrollToDate(targetDate);
|
|
531
|
-
|
|
532
468
|
if (this.type === 'single') {
|
|
533
469
|
this.currentDate = targetDate;
|
|
534
470
|
this.titleDate = targetDate;
|
|
@@ -582,11 +518,9 @@ export default createComponent({
|
|
|
582
518
|
genFooterContent: function genFooterContent() {
|
|
583
519
|
var h = this.$createElement;
|
|
584
520
|
var slot = this.slots('footer');
|
|
585
|
-
|
|
586
521
|
if (slot) {
|
|
587
522
|
return slot;
|
|
588
523
|
}
|
|
589
|
-
|
|
590
524
|
if (this.showConfirm) {
|
|
591
525
|
var text = this.buttonDisabled ? this.confirmDisabledText : this.confirmText;
|
|
592
526
|
return [h(Button, {
|
|
@@ -632,7 +566,6 @@ export default createComponent({
|
|
|
632
566
|
},
|
|
633
567
|
genCalendar: function genCalendar() {
|
|
634
568
|
var _this4 = this;
|
|
635
|
-
|
|
636
569
|
var h = this.$createElement;
|
|
637
570
|
return h("div", {
|
|
638
571
|
"class": bem()
|
|
@@ -670,16 +603,13 @@ export default createComponent({
|
|
|
670
603
|
},
|
|
671
604
|
render: function render() {
|
|
672
605
|
var _this5 = this;
|
|
673
|
-
|
|
674
606
|
var h = arguments[0];
|
|
675
|
-
|
|
676
607
|
if (this.poppable) {
|
|
677
608
|
var createListener = function createListener(name) {
|
|
678
609
|
return function () {
|
|
679
610
|
return _this5.$emit(name);
|
|
680
611
|
};
|
|
681
612
|
};
|
|
682
|
-
|
|
683
613
|
return h(Popup, {
|
|
684
614
|
"class": bem('popup'),
|
|
685
615
|
"attrs": {
|
|
@@ -700,7 +630,6 @@ export default createComponent({
|
|
|
700
630
|
}
|
|
701
631
|
}, [this.genCalendar()]);
|
|
702
632
|
}
|
|
703
|
-
|
|
704
633
|
return this.genCalendar();
|
|
705
634
|
}
|
|
706
635
|
});
|
package/es/calendar/types.js
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
export var CalendarShowType
|
|
2
|
-
|
|
3
|
-
(function (CalendarShowType) {
|
|
1
|
+
export var CalendarShowType = /*#__PURE__*/function (CalendarShowType) {
|
|
4
2
|
CalendarShowType["INLINE"] = "inline";
|
|
5
3
|
CalendarShowType["SCROLL"] = "scroll";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export var CalendarType
|
|
9
|
-
|
|
10
|
-
(function (CalendarType) {
|
|
4
|
+
return CalendarShowType;
|
|
5
|
+
}({});
|
|
6
|
+
export var CalendarType = /*#__PURE__*/function (CalendarType) {
|
|
11
7
|
CalendarType["SINGLE"] = "single";
|
|
12
8
|
CalendarType["RANGE"] = "range";
|
|
13
9
|
CalendarType["MULTIPLE"] = "multiple";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export var CalendarDayType
|
|
17
|
-
|
|
18
|
-
(function (CalendarDayType) {
|
|
10
|
+
return CalendarType;
|
|
11
|
+
}({});
|
|
12
|
+
export var CalendarDayType = /*#__PURE__*/function (CalendarDayType) {
|
|
19
13
|
CalendarDayType["PREVIEW"] = "preview";
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
return CalendarDayType;
|
|
15
|
+
}({});
|
|
22
16
|
export var CalendarTotalDay = 42; // 日历总天数
|
package/es/calendar/utils.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { createNamespace } from '../utils';
|
|
2
2
|
var MonthsOfYear = 12;
|
|
3
|
-
|
|
4
3
|
var _createNamespace = createNamespace('calendar'),
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
createComponent = _createNamespace[0],
|
|
5
|
+
bem = _createNamespace[1],
|
|
6
|
+
t = _createNamespace[2];
|
|
9
7
|
export { createComponent, bem, t };
|
|
10
8
|
export function formatMonthTitle(date) {
|
|
11
9
|
return t('monthTitle', date.getFullYear(), date.getMonth() + 1);
|
|
@@ -15,42 +13,35 @@ export function compareMonth(date1, date2) {
|
|
|
15
13
|
var year2 = date2.getFullYear();
|
|
16
14
|
var month1 = date1.getMonth();
|
|
17
15
|
var month2 = date2.getMonth();
|
|
18
|
-
|
|
19
16
|
if (year1 === year2) {
|
|
20
17
|
return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
|
|
21
18
|
}
|
|
22
|
-
|
|
23
19
|
return year1 > year2 ? 1 : -1;
|
|
24
20
|
}
|
|
25
21
|
export function compareDay(day1, day2) {
|
|
26
22
|
var compareMonthResult = compareMonth(day1, day2);
|
|
27
|
-
|
|
28
23
|
if (compareMonthResult === 0) {
|
|
29
24
|
var date1 = day1.getDate();
|
|
30
25
|
var date2 = day2.getDate();
|
|
31
26
|
return date1 === date2 ? 0 : date1 > date2 ? 1 : -1;
|
|
32
27
|
}
|
|
33
|
-
|
|
34
28
|
return compareMonthResult;
|
|
35
29
|
}
|
|
36
30
|
export function getDayByOffset(date, offset, isMonth, isYear) {
|
|
37
31
|
var newDate = new Date(date);
|
|
38
|
-
|
|
39
32
|
if (isYear) {
|
|
40
33
|
newDate.setFullYear(newDate.getFullYear() + offset);
|
|
41
34
|
} else if (isMonth) {
|
|
42
|
-
newDate.setMonth(newDate.getMonth() + offset);
|
|
43
|
-
|
|
35
|
+
newDate.setMonth(newDate.getMonth() + offset);
|
|
36
|
+
// 避免每月天数不一样导致的跨月问题,例如1.31 跨月至 3.2日
|
|
44
37
|
var multiplier = newDate.getFullYear() - date.getFullYear();
|
|
45
38
|
var setLastDate = date.getMonth() + offset !== newDate.getMonth() + multiplier * MonthsOfYear;
|
|
46
|
-
|
|
47
39
|
if (setLastDate) {
|
|
48
40
|
newDate.setDate(0);
|
|
49
41
|
}
|
|
50
42
|
} else {
|
|
51
43
|
newDate.setDate(newDate.getDate() + offset);
|
|
52
44
|
}
|
|
53
|
-
|
|
54
45
|
return newDate;
|
|
55
46
|
}
|
|
56
47
|
export function getPrevDay(date) {
|
|
@@ -79,11 +70,9 @@ export function copyDates(dates) {
|
|
|
79
70
|
if (date === null) {
|
|
80
71
|
return date;
|
|
81
72
|
}
|
|
82
|
-
|
|
83
73
|
return copyDate(date);
|
|
84
74
|
});
|
|
85
75
|
}
|
|
86
|
-
|
|
87
76
|
return copyDate(dates);
|
|
88
77
|
}
|
|
89
78
|
export function getFirstDate(date) {
|