@opentiny/vue-renderless 3.13.2 → 3.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/action-sheet/index.js +20 -13
- package/action-sheet/vue.js +8 -7
- package/amount/index.js +100 -25
- package/amount/vue.js +102 -26
- package/anchor/index.js +1 -0
- package/area/index.js +8 -8
- package/area/vue.js +5 -5
- package/async-flowchart/index.js +16 -3
- package/autocomplete/index.js +58 -14
- package/autocomplete/vue.js +40 -12
- package/badge/index.js +12 -0
- package/badge/vue.js +6 -4
- package/breadcrumb/vue.js +3 -1
- package/breadcrumb-item/vue.js +6 -2
- package/button/index.js +5 -1
- package/calendar/index.js +2 -86
- package/calendar-bar/index.js +18 -4
- package/calendar-view/index.js +5 -1
- package/calendar-view/vue.js +16 -3
- package/card-group/vue.js +4 -2
- package/cascader/index.js +86 -34
- package/cascader/vue.js +61 -20
- package/cascader-menu/index.js +7 -7
- package/cascader-menu/vue.js +2 -3
- package/cascader-mobile/index.js +36 -23
- package/cascader-mobile/vue.js +6 -0
- package/cascader-node/index.js +13 -1
- package/cascader-node/vue.js +15 -4
- package/cascader-panel/index.js +1 -1
- package/cascader-select/column-index.js +150 -0
- package/cascader-select/column.js +120 -0
- package/cascader-select/index.js +29 -165
- package/cascader-select/usePicker.js +251 -0
- package/cascader-select/useTouch.js +65 -0
- package/cascader-select/vue.js +35 -47
- package/cell/vue.js +2 -1
- package/chart-bar/index.js +2 -3
- package/chart-core/deps/constants.js +43 -43
- package/chart-core/index.js +1 -1
- package/chart-gauge/index.js +2 -2
- package/chart-heatmap/index.js +17 -10
- package/chart-line/index.js +8 -9
- package/chart-tree/index.js +2 -2
- package/chart-waterfall/index.js +4 -6
- package/checkbox/index.js +18 -1
- package/checkbox/vue.js +15 -7
- package/checkbox-group/vue.js +1 -0
- package/col/vue.js +1 -1
- package/collapse/index.js +3 -3
- package/color-select-panel/vue.js +0 -7
- package/column-list-item/index.js +17 -1
- package/column-list-item/vue.js +8 -3
- package/common/bigInt.js +2 -2
- package/common/date.js +7 -5
- package/common/deps/clickoutside.js +6 -2
- package/common/deps/date-util.js +4 -2
- package/common/deps/dom.js +19 -4
- package/common/deps/popper.js +44 -11
- package/common/deps/resize-event.js +1 -0
- package/common/deps/touch-emulator.js +4 -1
- package/common/deps/tree-model/node.js +2 -2
- package/common/deps/tree-model/tree-store.js +2 -13
- package/common/deps/useRect.js +25 -0
- package/common/deps/vue-popper.js +38 -20
- package/common/index.js +2 -2
- package/common/runtime.js +1 -1
- package/common/string.js +2 -2
- package/common/type.js +2 -1
- package/common/validate/rules/enum.js +1 -1
- package/common/validate/rules/pattern.js +2 -2
- package/common/validate/rules/range.js +8 -5
- package/common/validate/rules/required.js +1 -1
- package/common/validate/rules/type.js +5 -5
- package/common/validate/rules/whitespace.js +1 -1
- package/common/validate/util.js +15 -16
- package/common/validate/validations/integer.js +1 -1
- package/common/validate/validations/method.js +1 -1
- package/currency/index.js +74 -7
- package/currency/vue.js +21 -5
- package/date-panel/index.js +16 -0
- package/date-panel/vue.js +8 -2
- package/date-picker-mobile/index.js +12 -0
- package/date-picker-mobile/vue.js +7 -1
- package/date-range/vue.js +15 -6
- package/date-table/index.js +35 -53
- package/date-table/vue.js +4 -2
- package/dialog-box/index.js +46 -14
- package/dialog-box/vue.js +30 -7
- package/dialog-select/index.js +6 -3
- package/dialog-select/vue.js +8 -4
- package/drawer/index.js +27 -5
- package/drawer/vue.js +14 -7
- package/dropdown/index.js +7 -7
- package/dropdown/vue.js +6 -2
- package/dropdown-item/index.js +9 -1
- package/dropdown-item/mf.js +6 -10
- package/dropdown-item/vue.js +20 -7
- package/dropdown-menu/index.js +20 -7
- package/dropdown-menu/vue.js +4 -3
- package/exception/index.js +2 -7
- package/exception/vue.js +7 -10
- package/fall-menu/index.js +5 -1
- package/fall-menu/vue.js +13 -2
- package/file-upload/index.js +68 -18
- package/file-upload/vue.js +38 -8
- package/filter-box/index.js +1 -0
- package/float-button/index.js +42 -0
- package/float-button/vue.js +101 -0
- package/floating-button/index.js +62 -16
- package/floating-button/vue.js +27 -9
- package/flowchart/index.js +134 -25
- package/flowchart/node.js +13 -4
- package/flowchart/vue.js +16 -4
- package/form/vue.js +8 -0
- package/form-item/index.js +5 -5
- package/form-item/vue.js +3 -1
- package/fullscreen/index.js +5 -5
- package/fullscreen/vue.js +3 -3
- package/grid/plugins/export.js +5 -2
- package/grid/utils/column.js +1 -0
- package/grid/utils/dom.js +7 -1
- package/image/index.js +6 -1
- package/image/vue.js +6 -3
- package/image-viewer/index.js +62 -51
- package/image-viewer/vue.js +17 -5
- package/input/index.js +81 -20
- package/input/vue.js +44 -18
- package/ip-address/index.js +61 -19
- package/ip-address/vue.js +22 -4
- package/link/vue.js +3 -1
- package/loading/index.js +2 -2
- package/loading/vue.js +8 -2
- package/logout/index.js +1 -1
- package/menu/index.js +15 -2
- package/menu/vue.js +22 -17
- package/mind-map/index.js +47 -0
- package/mind-map/vue.js +53 -0
- package/modal/index.js +44 -4
- package/modal/vue.js +18 -4
- package/multi-select/index.js +186 -11
- package/multi-select/vue.js +60 -15
- package/multi-select-item/index.js +23 -0
- package/multi-select-item/vue.js +31 -0
- package/numeric/index.js +48 -12
- package/numeric/vue.js +44 -19
- package/option/index.js +27 -9
- package/option/vue.js +37 -21
- package/option-group/index.js +3 -3
- package/package.json +1 -1
- package/pager/index.js +18 -4
- package/pager/vue.js +16 -5
- package/picker/index.js +290 -77
- package/picker/mb.js +42 -0
- package/picker/vue.js +76 -20
- package/picker-column/index.js +1 -1
- package/pop-upload/vue.js +3 -0
- package/popconfirm/index.js +3 -6
- package/popconfirm/vue.js +1 -1
- package/popeditor/index.js +73 -34
- package/popeditor/vue.js +15 -11
- package/popover/index.js +4 -4
- package/popover/vue.js +6 -6
- package/popup/index.js +3 -3
- package/popup/vue.js +5 -5
- package/pull-refresh/index.js +13 -13
- package/pull-refresh/vue.js +5 -4
- package/radio/index.js +0 -17
- package/radio/vue.js +4 -10
- package/rate/index.js +1 -1
- package/rate/vue.js +0 -2
- package/record/index.js +4 -1
- package/rich-text/clipboard.js +54 -0
- package/rich-text/index.js +192 -0
- package/rich-text/module/file-upload.js +107 -0
- package/rich-text/module/image-drop.js +63 -0
- package/rich-text/module/image-upload.js +89 -0
- package/rich-text/options.js +141 -0
- package/rich-text/table-module.js +382 -0
- package/rich-text/vue.js +102 -0
- package/{rich-text-edtior → rich-text-editor}/index.js +2 -2
- package/{rich-text-edtior → rich-text-editor}/vue.js +2 -5
- package/scrollbar/index.js +11 -11
- package/scrollbar/vue-bar.js +3 -3
- package/scrollbar/vue.js +5 -5
- package/search/index.js +9 -9
- package/search/vue.js +8 -6
- package/select/index.js +442 -393
- package/select/vue.js +278 -164
- package/select-dropdown/index.js +61 -3
- package/select-dropdown/vue.js +85 -8
- package/select-view/index.js +3 -1
- package/selected-box/index.js +2 -0
- package/selected-box/vue.js +6 -3
- package/signature/index.js +241 -0
- package/signature/vue.js +88 -0
- package/skeleton/index.js +14 -0
- package/skeleton/vue.js +15 -0
- package/skeleton-item/vue.js +15 -0
- package/slider/index.js +70 -17
- package/slider/vue.js +16 -7
- package/split/index.js +5 -3
- package/split/vue.js +4 -6
- package/standard-list-item/index.js +15 -1
- package/standard-list-item/vue.js +6 -5
- package/steps/index.js +25 -2
- package/steps/slide-bar.js +8 -1
- package/steps/vue.js +15 -3
- package/tab-item-mf/vue.js +14 -8
- package/tab-nav/index.js +30 -5
- package/tab-nav/vue.js +16 -4
- package/tabbar/vue.js +9 -3
- package/tabbar-item/vue.js +3 -2
- package/tabs/index.js +16 -4
- package/tabs/vue.js +2 -1
- package/tabs-mf/index.js +20 -6
- package/tabs-mf/vue-nav.js +26 -11
- package/tabs-mf/vue.js +7 -7
- package/tabs-mf/wheel.js +1 -0
- package/tag/index.js +1 -1
- package/tag-group/index.js +2 -1
- package/time/index.js +5 -2
- package/time/vue.js +1 -1
- package/time-line/index.js +3 -3
- package/time-line/vue.js +2 -2
- package/time-picker-mobile/index.js +24 -5
- package/time-picker-mobile/vue.js +17 -7
- package/time-range/index.js +2 -0
- package/timeline-item/vue.js +1 -1
- package/tooltip/index.js +6 -3
- package/tooltip/vue.js +4 -4
- package/transfer/index.js +20 -22
- package/transfer/vue.js +1 -6
- package/transfer-panel/vue.js +3 -5
- package/tree/index.js +21 -4
- package/tree/vue.js +10 -8
- package/tree-menu/index.js +29 -3
- package/tree-menu/vue.js +28 -15
- package/tree-node/index.js +18 -18
- package/tree-node/vue.js +6 -5
- package/types/action-sheet.type.d.ts +118 -1
- package/types/amount.type.d.ts +168 -1
- package/types/area.type.d.ts +134 -1
- package/types/async-flowchart.type.d.ts +72 -0
- package/types/autocomplete.type.d.ts +199 -1
- package/types/badge.type.d.ts +3 -1
- package/types/breadcrumb-item.type.d.ts +2 -0
- package/types/breadcrumb.type.d.ts +2 -0
- package/types/button-group.type.d.ts +3 -3
- package/types/button.type.d.ts +4 -0
- package/types/cascader-menu.type.d.ts +3 -4
- package/types/cascader-node.type.d.ts +5 -2
- package/types/cascader-panel.type-2bd03be3.d.ts +241 -0
- package/types/cascader-panel.type.d.ts +3 -241
- package/types/cascader.type.d.ts +329 -1
- package/types/checkbox.type.d.ts +6 -0
- package/types/collapse.type.d.ts +19 -2
- package/types/date-picker.type.d.ts +38 -1
- package/types/dialog-box.type.d.ts +13 -3
- package/types/drawer.type.d.ts +133 -1
- package/types/{dropdown-item.type-8ea6c633.d.ts → dropdown-item.type-8475a549.d.ts} +7 -13
- package/types/dropdown-item.type.d.ts +1 -1
- package/types/dropdown-menu.type.d.ts +1 -1
- package/types/dropdown.type.d.ts +1 -5
- package/types/fall-menu.type.d.ts +94 -1
- package/types/file-upload.type.d.ts +1 -1
- package/types/float-button.type.d.ts +123 -0
- package/types/form-item.type.d.ts +1 -1
- package/types/{form.type-d0fd42f3.d.ts → form.type-a2dc0099.d.ts} +4 -1
- package/types/form.type.d.ts +1 -1
- package/types/{index-e0250f63.d.ts → index-b012f687.d.ts} +9 -0
- package/types/input.type.d.ts +2 -6
- package/types/ip-address.type.d.ts +160 -1
- package/types/link.type.d.ts +6 -3
- package/types/loading.type.d.ts +7 -0
- package/types/mind-map.type.d.ts +20 -0
- package/types/modal.type.d.ts +29 -2
- package/types/numeric.type.d.ts +41 -10
- package/types/pager.type.d.ts +12 -0
- package/types/picker.type.d.ts +18 -0
- package/types/popconfirm.type.d.ts +86 -1
- package/types/popeditor.type.d.ts +4 -0
- package/types/popover.type.d.ts +3 -3
- package/types/progress.type.d.ts +2 -0
- package/types/radio.type.d.ts +0 -4
- package/types/rate.type.d.ts +236 -1
- package/types/search.type.d.ts +88 -1
- package/types/shared.type.d.ts +1 -1
- package/types/skeleton-item.type.d.ts +38 -0
- package/types/skeleton.type.d.ts +45 -0
- package/types/slider.type.d.ts +49 -10
- package/types/steps.type.d.ts +14 -3
- package/types/tab-bar.type.d.ts +1 -1
- package/types/tab-nav.type.d.ts +7 -2
- package/types/tabs.type.d.ts +9 -1
- package/types/tag-group.type.d.ts +64 -1
- package/types/{time-line.type-d7daa669.d.ts → time-line.type-b155cb4f.d.ts} +12 -0
- package/types/time-line.type.d.ts +1 -1
- package/types/timeline-item.type.d.ts +1 -1
- package/types/tooltip.type.d.ts +2 -2
- package/types/transfer.type.d.ts +185 -1
- package/types/tree-menu.type.d.ts +210 -1
- package/types/upload-dragger.type.d.ts +1 -1
- package/types/{upload-list.type-343e8c11.d.ts → upload-list.type-6d6e3d0e.d.ts} +35 -8
- package/types/upload-list.type.d.ts +1 -1
- package/types/upload.type.d.ts +1 -1
- package/types/user-head.type.d.ts +146 -1
- package/types/wizard.type.d.ts +1 -0
- package/upload/index.js +64 -34
- package/upload/vue.js +9 -5
- package/upload-dragger/index.js +22 -20
- package/upload-list/index.js +24 -18
- package/upload-list/vue.js +9 -4
- package/user/index.js +35 -26
- package/user/vue.js +1 -1
- package/user-head/index.js +3 -3
- package/watermark/index.js +11 -0
- package/wheel/index.js +3 -0
- package/wizard/vue.js +4 -2
- package/common/deps/modal-queue.js +0 -6
- package/common/deps/requestAnimationFrame.js +0 -25
package/picker/index.js
CHANGED
|
@@ -6,9 +6,8 @@ import { toDate, getDateWithNewTimezone, getStrTimezone, getLocalTimezone } from
|
|
|
6
6
|
import { isNumber, isDate } from "../common/type";
|
|
7
7
|
import userPopper from "../common/deps/vue-popper";
|
|
8
8
|
import { DATEPICKER } from "../common";
|
|
9
|
-
import { formatDate, parseDate, isDateObject, getWeekNumber } from "../common/deps/date-util";
|
|
9
|
+
import { formatDate, parseDate, isDateObject, getWeekNumber, prevDate, nextDate } from "../common/deps/date-util";
|
|
10
10
|
import { extend } from "../common/object";
|
|
11
|
-
import { isFunction } from "../common/type";
|
|
12
11
|
import globalTimezone from "./timezone";
|
|
13
12
|
const iso8601Reg = /^\d{4}-\d{2}-\d{2}(.)\d{2}:\d{2}:\d{2}(.+)$/;
|
|
14
13
|
const getPanel = ({ DatePanel, DateRangePanel, MonthRangePanel, YearRangePanel, TimePanel, TimeRangePanel, TimeSelect }) => (type) => {
|
|
@@ -27,20 +26,29 @@ const getPanel = ({ DatePanel, DateRangePanel, MonthRangePanel, YearRangePanel,
|
|
|
27
26
|
}
|
|
28
27
|
return DatePanel;
|
|
29
28
|
};
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
|
|
29
|
+
const watchMobileVisible = ({ api, props, state }) => ([dateMobileVisible, timeMobileVisible]) => {
|
|
30
|
+
if (dateMobileVisible || timeMobileVisible) {
|
|
31
|
+
state.valueOnOpen = Array.isArray(props.modelValue) ? [...props.modelValue] : props.modelValue;
|
|
32
|
+
} else {
|
|
33
|
+
api.emitChange(props.modelValue);
|
|
33
34
|
}
|
|
35
|
+
};
|
|
36
|
+
const watchPickerVisible = ({ api, vm, dispatch, emit, props, state, nextTick }) => (value) => {
|
|
37
|
+
if (props.readonly || state.pickerDisabled || state.isMobileScreen)
|
|
38
|
+
return;
|
|
34
39
|
if (value) {
|
|
35
40
|
api.showPicker();
|
|
36
41
|
state.valueOnOpen = Array.isArray(props.modelValue) ? [...props.modelValue] : props.modelValue;
|
|
37
42
|
} else {
|
|
38
43
|
api.hidePicker();
|
|
39
|
-
api.emitChange(props.modelValue);
|
|
44
|
+
nextTick(() => api.emitChange(props.modelValue));
|
|
40
45
|
state.userInput = null;
|
|
41
46
|
if (props.validateEvent) {
|
|
42
47
|
dispatch("FormItem", "form.blur");
|
|
43
48
|
}
|
|
49
|
+
if (props.changeOnConfirm && !valueEquals(props.modelValue, state.oldValue)) {
|
|
50
|
+
emit("update:modelValue", state.oldValue);
|
|
51
|
+
}
|
|
44
52
|
emit("blur", vm);
|
|
45
53
|
api.blur();
|
|
46
54
|
}
|
|
@@ -72,16 +80,18 @@ const getMode = ({ state }) => () => {
|
|
|
72
80
|
}
|
|
73
81
|
return DATEPICKER.Day;
|
|
74
82
|
};
|
|
75
|
-
const formatAsFormatAndType = ({ api }) => (value, customFormat, type) => {
|
|
76
|
-
if (!value)
|
|
83
|
+
const formatAsFormatAndType = ({ api }) => (value, customFormat, type, formatObj) => {
|
|
84
|
+
if (!value)
|
|
77
85
|
return null;
|
|
78
|
-
}
|
|
79
86
|
const formatter = (api.typeValueResolveMap()[type] || api.typeValueResolveMap().default).formatter;
|
|
80
87
|
const format = customFormat || DATEPICKER.DateFormats[type];
|
|
81
|
-
return formatter(value, format);
|
|
88
|
+
return formatter(value, format, formatObj);
|
|
82
89
|
};
|
|
83
90
|
const displayValue = ({ api, props, state }) => () => {
|
|
84
|
-
const
|
|
91
|
+
const formatObj = {
|
|
92
|
+
rangeSeparator: props.rangeSeparator
|
|
93
|
+
};
|
|
94
|
+
const formattedValue = api.formatAsFormatAndType(state.parsedValue, state.format, state.type, formatObj);
|
|
85
95
|
if (Array.isArray(state.userInput)) {
|
|
86
96
|
return [
|
|
87
97
|
state.userInput[0] || formattedValue && formattedValue[0] || "",
|
|
@@ -110,7 +120,7 @@ const parsedValue = ({ api, props, state, t }) => () => {
|
|
|
110
120
|
return props.modelValue;
|
|
111
121
|
}
|
|
112
122
|
const valueIsDateObject = isDateObject(props.modelValue) || Array.isArray(props.modelValue) && props.modelValue.every(isDateObject);
|
|
113
|
-
const { from, to, isServiceTimezone } = state.timezone;
|
|
123
|
+
const { from, to, isServiceTimezone, timezoneOffset } = state.timezone;
|
|
114
124
|
if (valueIsDateObject && !isServiceTimezone) {
|
|
115
125
|
return props.modelValue;
|
|
116
126
|
}
|
|
@@ -118,25 +128,27 @@ const parsedValue = ({ api, props, state, t }) => () => {
|
|
|
118
128
|
let date = props.modelValue;
|
|
119
129
|
if (isServiceTimezone) {
|
|
120
130
|
if (Array.isArray(date)) {
|
|
121
|
-
date = [].concat(date).map((item) =>
|
|
131
|
+
date = [].concat(date).map((item) => {
|
|
132
|
+
return isDate(item) ? formatDate(item, state.valueFormat, t) : item;
|
|
133
|
+
});
|
|
122
134
|
} else {
|
|
123
135
|
date = formatDate(date, state.valueFormat, t);
|
|
124
136
|
}
|
|
125
137
|
}
|
|
126
138
|
const result = api.parseAsFormatAndType(date, state.valueFormat, state.type, props.rangeSeparator);
|
|
127
139
|
if (Array.isArray(result)) {
|
|
128
|
-
return result.map((date2) => getDateWithNewTimezone(date2, from, to));
|
|
140
|
+
return result.map((date2) => getDateWithNewTimezone(date2, from, to, timezoneOffset));
|
|
129
141
|
}
|
|
130
|
-
return getDateWithNewTimezone(result || props.modelValue, from, to);
|
|
142
|
+
return getDateWithNewTimezone(result || props.modelValue, from, to, timezoneOffset);
|
|
131
143
|
}
|
|
132
144
|
const trans = (value) => typeof value === "string" || isNumber(value) ? toDate(value) : value;
|
|
133
|
-
const values = [].concat(props.modelValue).map((val) => getDateWithNewTimezone(trans(val), from, to));
|
|
145
|
+
const values = [].concat(props.modelValue).map((val) => getDateWithNewTimezone(trans(val), from, to, timezoneOffset));
|
|
134
146
|
return values.length > 1 ? values : values[0];
|
|
135
147
|
};
|
|
136
148
|
const getTimezone = ({ props, utils }) => () => {
|
|
137
|
-
const { dbTimezone, timezone, isutc8, type = "date", iso8601 } = props;
|
|
149
|
+
const { dbTimezone, timezone, isutc8, type = "date", iso8601, timezoneOffset } = props;
|
|
138
150
|
const setting = utils.getDateFormat && utils.getDateFormat();
|
|
139
|
-
const { DbTimezone, Timezone } = setting || {};
|
|
151
|
+
const { DbTimezone, Timezone, TimezoneOffset } = setting || {};
|
|
140
152
|
const cur = getLocalTimezone();
|
|
141
153
|
const isTzNumber = (z) => typeof z === "number" && z >= -12 && z <= 12;
|
|
142
154
|
if (!~type.indexOf("datetime")) {
|
|
@@ -144,6 +156,7 @@ const getTimezone = ({ props, utils }) => () => {
|
|
|
144
156
|
}
|
|
145
157
|
let serveTimezone = isTzNumber(dbTimezone) ? dbTimezone : isTzNumber(DbTimezone) ? DbTimezone : cur;
|
|
146
158
|
let clientTimezone = isTzNumber(timezone) ? timezone : isTzNumber(Timezone) ? Timezone : cur;
|
|
159
|
+
let clientTimezoneOffset = isNumber(timezoneOffset) ? timezoneOffset : isNumber(TimezoneOffset) ? TimezoneOffset : 0;
|
|
147
160
|
const value = props.modelValue;
|
|
148
161
|
const str = (Array.isArray(value) ? value[0] : value) || "";
|
|
149
162
|
const match = typeof str === "string" && str.match(/(-|\+)(\d{2}):?(\d{2})$/);
|
|
@@ -153,7 +166,8 @@ const getTimezone = ({ props, utils }) => () => {
|
|
|
153
166
|
return {
|
|
154
167
|
from: serveTimezone,
|
|
155
168
|
to: isutc8 ? 8 : clientTimezone,
|
|
156
|
-
isServiceTimezone: !!setting
|
|
169
|
+
isServiceTimezone: !!setting,
|
|
170
|
+
timezoneOffset: clientTimezoneOffset
|
|
157
171
|
};
|
|
158
172
|
};
|
|
159
173
|
const nullOrString = (value) => {
|
|
@@ -182,11 +196,12 @@ const dateFormatter = ({ t }) => (value, format) => {
|
|
|
182
196
|
}
|
|
183
197
|
return formatDate(value, format, t);
|
|
184
198
|
};
|
|
185
|
-
const dateParser = ({ t }) => (text, format) => {
|
|
199
|
+
const dateParser = ({ t, props }) => (text, format) => {
|
|
186
200
|
if (format === DATEPICKER.TimesTamp) {
|
|
187
201
|
return new Date(Number(text));
|
|
188
202
|
}
|
|
189
|
-
|
|
203
|
+
const value = props.autoFormat ? formatText({ text, format }) : text;
|
|
204
|
+
return parseDate(value, format, t);
|
|
190
205
|
};
|
|
191
206
|
const rangeFormatter = (api) => (value, format) => {
|
|
192
207
|
if (Array.isArray(value) && value.length === 2) {
|
|
@@ -227,24 +242,43 @@ const getDefaultOfTypeValueResolveMap = () => ({
|
|
|
227
242
|
return text === void 0 || text === "" ? null : text;
|
|
228
243
|
}
|
|
229
244
|
});
|
|
230
|
-
const getWeekOfTypeValueResolveMap = ({ t, api }) => ({
|
|
231
|
-
formatter(value, format) {
|
|
245
|
+
const getWeekOfTypeValueResolveMap = ({ t, props, api }) => ({
|
|
246
|
+
formatter(value, format, formatObj) {
|
|
232
247
|
const weekDate = getWeekData(value);
|
|
233
248
|
let week = getWeekNumber(weekDate);
|
|
234
249
|
let month = weekDate.getMonth();
|
|
235
250
|
const trueDate = new Date(weekDate);
|
|
251
|
+
const { rangeSeparator = "-", type = "format" } = formatObj;
|
|
236
252
|
if (week === 1 && month === 11) {
|
|
237
253
|
trueDate.setHours(0, 0, 0, 0);
|
|
238
254
|
trueDate.setDate(trueDate.getDate() + 3 - (trueDate.getDay() + 6) % 7);
|
|
239
255
|
}
|
|
240
|
-
let date
|
|
241
|
-
|
|
256
|
+
let date;
|
|
257
|
+
if (type === "format" && !/W/.test(format)) {
|
|
258
|
+
const { start, end } = getWeekRange(value, format, t, props.pickerOptions);
|
|
259
|
+
date = `${start} ${rangeSeparator} ${end}`;
|
|
260
|
+
} else {
|
|
261
|
+
date = formatDate(trueDate, format, t);
|
|
262
|
+
date = /WW/.test(date) ? date.replace(/WW/, week < 10 ? "0" + week : week) : date.replace(/W/, week);
|
|
263
|
+
}
|
|
242
264
|
return date;
|
|
243
265
|
},
|
|
244
266
|
parser(text, format) {
|
|
245
267
|
return api.typeValueResolveMap().date.parser(text, format);
|
|
246
268
|
}
|
|
247
269
|
});
|
|
270
|
+
const getWeekRange = (value, format, t, pickerOptions) => {
|
|
271
|
+
const firstDayOfWeek = pickerOptions && pickerOptions.firstDayOfWeek ? pickerOptions.firstDayOfWeek : 7;
|
|
272
|
+
const dayOffset = (value.getDay() - firstDayOfWeek + 7) % 7;
|
|
273
|
+
const startDate = prevDate(value, dayOffset);
|
|
274
|
+
const endDate = nextDate(startDate, 6);
|
|
275
|
+
const start = formatDate(startDate, format, t);
|
|
276
|
+
const end = formatDate(endDate, format, t);
|
|
277
|
+
return {
|
|
278
|
+
start,
|
|
279
|
+
end
|
|
280
|
+
};
|
|
281
|
+
};
|
|
248
282
|
const getNumberOfTypeValueResolveMap = () => ({
|
|
249
283
|
formatter(value) {
|
|
250
284
|
return value ? String(value) : "";
|
|
@@ -264,9 +298,9 @@ const getDatesOfTypeValueResolveMap = (api) => ({
|
|
|
264
298
|
);
|
|
265
299
|
}
|
|
266
300
|
});
|
|
267
|
-
const typeValueResolveMap = ({ api, t }) => () => ({
|
|
301
|
+
const typeValueResolveMap = ({ api, props, t }) => () => ({
|
|
268
302
|
default: getDefaultOfTypeValueResolveMap(),
|
|
269
|
-
week: getWeekOfTypeValueResolveMap({ t, api }),
|
|
303
|
+
week: getWeekOfTypeValueResolveMap({ t, props, api }),
|
|
270
304
|
date: { formatter: api.dateFormatter, parser: api.dateParser },
|
|
271
305
|
datetime: { formatter: api.dateFormatter, parser: api.dateParser },
|
|
272
306
|
daterange: { formatter: api.rangeFormatter, parser: api.rangeParser },
|
|
@@ -305,7 +339,7 @@ const secondInputId = ({ props, state }) => () => {
|
|
|
305
339
|
}
|
|
306
340
|
return obj;
|
|
307
341
|
};
|
|
308
|
-
const focus = ({ api, props, vm }) => () => !props.isRange ? vm.$refs.reference.focus() : api.handleFocus();
|
|
342
|
+
const focus = ({ api, props, vm }) => () => !props.isRange ? vm.$refs.reference.querySelector("input").focus() : api.handleFocus();
|
|
309
343
|
const blur = (state) => () => state.refInput.forEach((input) => input.blur());
|
|
310
344
|
const parseValue = ({ api, props, state }) => (value) => {
|
|
311
345
|
const isParsed = isDateObject(value) || Array.isArray(value) && value.every(isDateObject);
|
|
@@ -314,10 +348,12 @@ const parseValue = ({ api, props, state }) => (value) => {
|
|
|
314
348
|
}
|
|
315
349
|
return value;
|
|
316
350
|
};
|
|
317
|
-
const formatToValue = ({ api,
|
|
351
|
+
const formatToValue = ({ api, state }) => (date) => {
|
|
318
352
|
const isFormattable = isDateObject(date) || Array.isArray(date) && date.every(isDateObject);
|
|
319
353
|
if (state.valueFormat && isFormattable) {
|
|
320
|
-
return api.formatAsFormatAndType(date, state.valueFormat, state.type,
|
|
354
|
+
return api.formatAsFormatAndType(date, state.valueFormat, state.type, {
|
|
355
|
+
type: "value-format"
|
|
356
|
+
});
|
|
321
357
|
}
|
|
322
358
|
return date;
|
|
323
359
|
};
|
|
@@ -337,6 +373,161 @@ const handleMouseEnter = ({ props, state }) => () => {
|
|
|
337
373
|
state.showClose = true;
|
|
338
374
|
}
|
|
339
375
|
};
|
|
376
|
+
const handleInput = ({ state, props, api }) => (val, event) => {
|
|
377
|
+
event = val.target ? val : event;
|
|
378
|
+
if (props.autoFormat) {
|
|
379
|
+
const value = api.formatInputValue({ event, prevValue: state.displayValue });
|
|
380
|
+
state.userInput = value;
|
|
381
|
+
} else {
|
|
382
|
+
const val2 = event.target.value;
|
|
383
|
+
state.userInput = val2;
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
const formatInputValue = ({ props, state }) => ({ event, prevValue = "" }) => {
|
|
387
|
+
const val = event.target.value;
|
|
388
|
+
const inputData = event.data;
|
|
389
|
+
const format = state.type === "time-select" ? "HH:mm" : props.format || DATEPICKER.DateFormats[state.type];
|
|
390
|
+
if (inputData && inputData.charCodeAt() >= 48 && inputData.charCodeAt() <= 57) {
|
|
391
|
+
return formatText({ event, format, text: prevValue, needSelectionStart: true });
|
|
392
|
+
} else {
|
|
393
|
+
return val;
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
const getSelectionStart = ({ value, format, regx, event }) => {
|
|
397
|
+
const formatMatchArr = format.match(regx);
|
|
398
|
+
let selectionStart = getSelectionStartIndex(event);
|
|
399
|
+
let I = 0;
|
|
400
|
+
if (value !== "") {
|
|
401
|
+
const match = value.match(/[0-9]/g);
|
|
402
|
+
I = match === null ? 0 : match.length;
|
|
403
|
+
for (let i = 0; i < formatMatchArr.length; i++) {
|
|
404
|
+
I -= Math.max(formatMatchArr[i].length, 2);
|
|
405
|
+
}
|
|
406
|
+
I = I >= 0 ? 1 : 0;
|
|
407
|
+
I === 1 && selectionStart >= value.length && (selectionStart = value.length - 1);
|
|
408
|
+
}
|
|
409
|
+
return { selectionStart, I };
|
|
410
|
+
};
|
|
411
|
+
const getNum = (value, format, regx) => {
|
|
412
|
+
let len = value.length;
|
|
413
|
+
if (format && regx) {
|
|
414
|
+
const formatMatchArr = format.match(regx);
|
|
415
|
+
len = Math.max(len, formatMatchArr.join("").length);
|
|
416
|
+
}
|
|
417
|
+
let num = { str: "", arr: [] };
|
|
418
|
+
for (let i = 0; i < len; i++) {
|
|
419
|
+
let char = value.charAt(i) ? value.charAt(i) : "00";
|
|
420
|
+
if (/[0-9]/.test(char)) {
|
|
421
|
+
num.str += char;
|
|
422
|
+
} else {
|
|
423
|
+
num.arr[i] = 1;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return num;
|
|
427
|
+
};
|
|
428
|
+
const getSelectionStartIndex = (event) => {
|
|
429
|
+
const inputElem = event.target;
|
|
430
|
+
return inputElem.selectionStart - (event.data ? event.data.length : 0);
|
|
431
|
+
};
|
|
432
|
+
const moveStart = (inputElem, moveStartIndex) => {
|
|
433
|
+
if (inputElem.setSelectionRange) {
|
|
434
|
+
inputElem.focus();
|
|
435
|
+
setTimeout(() => {
|
|
436
|
+
inputElem.setSelectionRange(moveStartIndex, moveStartIndex);
|
|
437
|
+
}, 0);
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
const formatText = ({ event, text, format, needSelectionStart = false }) => {
|
|
441
|
+
if (!format)
|
|
442
|
+
return text;
|
|
443
|
+
let cursorOffset = 0;
|
|
444
|
+
let value = "";
|
|
445
|
+
let regx = /yyyy|yyy|yy|y|MM|M|dd|d|HH|hh|H|h|mm|m|ss|s|WW|W|w/g;
|
|
446
|
+
let startIndex = 0;
|
|
447
|
+
let { numStr, selectionStart } = getNumAndSelectionStart({
|
|
448
|
+
value: text,
|
|
449
|
+
format,
|
|
450
|
+
regx,
|
|
451
|
+
event,
|
|
452
|
+
needSelectionStart
|
|
453
|
+
});
|
|
454
|
+
let matchResult = regx.exec(format);
|
|
455
|
+
while (numStr.str !== "" && matchResult !== null) {
|
|
456
|
+
let subStr;
|
|
457
|
+
let newNum;
|
|
458
|
+
let subLen;
|
|
459
|
+
const endIndex = matchResult.index;
|
|
460
|
+
if (startIndex >= 0) {
|
|
461
|
+
value += format.substring(startIndex, endIndex);
|
|
462
|
+
}
|
|
463
|
+
selectionStart >= startIndex + cursorOffset && selectionStart <= endIndex + cursorOffset && (selectionStart = selectionStart + endIndex - startIndex);
|
|
464
|
+
startIndex = regx.lastIndex;
|
|
465
|
+
subLen = startIndex - endIndex;
|
|
466
|
+
subStr = numStr.str.substring(0, subLen);
|
|
467
|
+
const firstMatchChar = matchResult[0].charAt(0);
|
|
468
|
+
const firstChar = parseInt(subStr.charAt(0), 10);
|
|
469
|
+
if (numStr.str.length > 1) {
|
|
470
|
+
const secondChar = numStr.str.charAt(1);
|
|
471
|
+
newNum = 10 * firstChar + parseInt(secondChar, 10);
|
|
472
|
+
} else {
|
|
473
|
+
newNum = firstChar;
|
|
474
|
+
}
|
|
475
|
+
if (numStr.arr[endIndex + 1] || firstMatchChar === "M" && newNum > 12 || firstMatchChar === "d" && newNum > 31 || ["H", "h"].includes(firstMatchChar) && newNum > 23 || "ms".includes(firstMatchChar) && newNum > 59) {
|
|
476
|
+
subStr = matchResult[0].length === 2 ? "0" + firstChar : firstChar;
|
|
477
|
+
selectionStart++;
|
|
478
|
+
} else {
|
|
479
|
+
if (subLen === 1) {
|
|
480
|
+
subStr = String(newNum);
|
|
481
|
+
subLen++;
|
|
482
|
+
cursorOffset++;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
value += subStr;
|
|
486
|
+
numStr.str = numStr.str.substring(subLen);
|
|
487
|
+
matchResult = regx.exec(format);
|
|
488
|
+
}
|
|
489
|
+
const { value: val, selectionStart: cursorPos } = checkFormat({
|
|
490
|
+
value,
|
|
491
|
+
format,
|
|
492
|
+
startIndex,
|
|
493
|
+
selectionStart,
|
|
494
|
+
regx,
|
|
495
|
+
needSelectionStart
|
|
496
|
+
});
|
|
497
|
+
value = val;
|
|
498
|
+
selectionStart = cursorPos;
|
|
499
|
+
needSelectionStart && moveStart(event.target, selectionStart);
|
|
500
|
+
return value;
|
|
501
|
+
};
|
|
502
|
+
const getNumAndSelectionStart = ({ value, format, regx, event, needSelectionStart }) => {
|
|
503
|
+
if (needSelectionStart) {
|
|
504
|
+
let { selectionStart, I } = getSelectionStart({ value, format, regx, event });
|
|
505
|
+
let valueStr;
|
|
506
|
+
if (event.data) {
|
|
507
|
+
valueStr = value.substring(0, selectionStart) + event.data + value.substring(selectionStart + I);
|
|
508
|
+
selectionStart++;
|
|
509
|
+
} else {
|
|
510
|
+
valueStr = value;
|
|
511
|
+
}
|
|
512
|
+
const numStr = getNum(valueStr);
|
|
513
|
+
return { numStr, selectionStart };
|
|
514
|
+
} else {
|
|
515
|
+
const numStr = getNum(value, format, regx);
|
|
516
|
+
return { numStr };
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
const checkFormat = ({ value, format, startIndex, selectionStart, regx, needSelectionStart }) => {
|
|
520
|
+
if (!needSelectionStart && regx.lastIndex === 0 || needSelectionStart && regx.lastIndex === 0 && selectionStart >= startIndex) {
|
|
521
|
+
const subFormat = `(?<=${format.substring(0, startIndex)})(\\s*\\S*\\s*)+`;
|
|
522
|
+
const pattern = new RegExp(subFormat, "g");
|
|
523
|
+
const res = format.match(pattern);
|
|
524
|
+
if (res) {
|
|
525
|
+
value += res[0];
|
|
526
|
+
selectionStart = value.length;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
return { value, selectionStart };
|
|
530
|
+
};
|
|
340
531
|
const handleChange = ({ api, state }) => () => {
|
|
341
532
|
if (state.userInput) {
|
|
342
533
|
const value = api.parseString(state.displayValue);
|
|
@@ -354,18 +545,20 @@ const handleChange = ({ api, state }) => () => {
|
|
|
354
545
|
state.userInput = null;
|
|
355
546
|
}
|
|
356
547
|
};
|
|
357
|
-
const handleStartInput = (state) => (event) => {
|
|
548
|
+
const handleStartInput = ({ state, props, api }) => (event) => {
|
|
549
|
+
const value = props.autoFormat ? api.formatInputValue({ event, prevValue: state.displayValue[0] }) : event.target.value;
|
|
358
550
|
if (state.userInput) {
|
|
359
|
-
state.userInput = [
|
|
551
|
+
state.userInput = [value, state.userInput[1]];
|
|
360
552
|
} else {
|
|
361
|
-
state.userInput = [
|
|
553
|
+
state.userInput = [value, null];
|
|
362
554
|
}
|
|
363
555
|
};
|
|
364
|
-
const handleEndInput = (state) => (event) => {
|
|
556
|
+
const handleEndInput = ({ state, props, api }) => (event) => {
|
|
557
|
+
const value = props.autoFormat ? api.formatInputValue({ event, prevValue: state.displayValue[1] }) : event.target.value;
|
|
365
558
|
if (state.userInput) {
|
|
366
|
-
state.userInput = [state.userInput[0],
|
|
559
|
+
state.userInput = [state.userInput[0], value];
|
|
367
560
|
} else {
|
|
368
|
-
state.userInput = [null,
|
|
561
|
+
state.userInput = [null, value];
|
|
369
562
|
}
|
|
370
563
|
};
|
|
371
564
|
const handleStartChange = ({ api, state }) => () => {
|
|
@@ -463,13 +656,19 @@ const handleClose = ({ api, props, state }) => () => {
|
|
|
463
656
|
state.pickerVisible = false;
|
|
464
657
|
if (state.type === DATEPICKER.Dates) {
|
|
465
658
|
const oldValue = api.parseAsFormatAndType(state.valueOnOpen, state.valueFormat, state.type, props.rangeSeparator) || state.valueOnOpen;
|
|
466
|
-
api.emitInput(oldValue);
|
|
659
|
+
api.emitInput(oldValue, true);
|
|
467
660
|
}
|
|
468
661
|
};
|
|
469
|
-
const handleFocus = ({ emit, vm, state }) => () => {
|
|
662
|
+
const handleFocus = ({ emit, vm, state, api }) => () => {
|
|
470
663
|
const type = state.type;
|
|
471
|
-
if (DATEPICKER.TriggerTypes.includes(type)
|
|
472
|
-
state.
|
|
664
|
+
if (DATEPICKER.TriggerTypes.includes(type)) {
|
|
665
|
+
if (state.isMobileScreen && state.isDateMobileComponent) {
|
|
666
|
+
api.dateMobileToggle(true);
|
|
667
|
+
} else if (state.isMobileScreen && state.isTimeMobileComponent) {
|
|
668
|
+
api.timeMobileToggle(true);
|
|
669
|
+
} else {
|
|
670
|
+
state.pickerVisible = true;
|
|
671
|
+
}
|
|
473
672
|
}
|
|
474
673
|
emit("focus", vm.$refs.reference);
|
|
475
674
|
};
|
|
@@ -514,13 +713,11 @@ const handleKeydown = ({ api, state }) => (event) => {
|
|
|
514
713
|
state.picker.handleKeydown(event);
|
|
515
714
|
}
|
|
516
715
|
};
|
|
517
|
-
const hidePicker = ({
|
|
716
|
+
const hidePicker = ({ destroyPopper, state }) => () => {
|
|
518
717
|
if (state.picker) {
|
|
519
718
|
state.picker.resetView && state.picker.resetView();
|
|
520
719
|
state.pickerVisible = state.picker.visible = state.picker.state.visible = false;
|
|
521
|
-
|
|
522
|
-
doDestroy();
|
|
523
|
-
}
|
|
720
|
+
destroyPopper();
|
|
524
721
|
}
|
|
525
722
|
};
|
|
526
723
|
const showPicker = ({ api, nextTick, updatePopper, state }) => () => {
|
|
@@ -533,13 +730,17 @@ const showPicker = ({ api, nextTick, updatePopper, state }) => () => {
|
|
|
533
730
|
state.pickerVisible = state.picker.state.visible = true;
|
|
534
731
|
state.picker.state.value = state.parsedValue;
|
|
535
732
|
state.picker.resetView && state.picker.resetView();
|
|
536
|
-
|
|
537
|
-
|
|
733
|
+
nextTick(() => {
|
|
734
|
+
updatePopper(state.picker.$el);
|
|
735
|
+
state.picker.adjustSpinners && state.picker.adjustSpinners();
|
|
736
|
+
});
|
|
538
737
|
};
|
|
539
738
|
const handlePick = ({ state, api }) => (date = "", visible = false) => {
|
|
739
|
+
if (!state.picker)
|
|
740
|
+
return;
|
|
540
741
|
state.userInput = null;
|
|
541
742
|
state.pickerVisible = state.picker.state.visible = visible;
|
|
542
|
-
api.emitInput(date);
|
|
743
|
+
api.emitInput(date, visible);
|
|
543
744
|
state.date = date;
|
|
544
745
|
state.picker.resetView && state.picker.resetView();
|
|
545
746
|
};
|
|
@@ -548,23 +749,22 @@ const handleSelectRange = (state) => (start, end, pos) => {
|
|
|
548
749
|
return;
|
|
549
750
|
}
|
|
550
751
|
const adjust = (value, start2, end2) => {
|
|
551
|
-
if (
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
end2 = hourLength + minuteLength + secondLength + 2;
|
|
752
|
+
if (value) {
|
|
753
|
+
const valueReg = /(\d+):(\d+):(\d+)(\s+.+)?/;
|
|
754
|
+
if (valueReg.test(value)) {
|
|
755
|
+
const matched = valueReg.exec(value);
|
|
756
|
+
const hourLength = matched[1].length;
|
|
757
|
+
const minuteLength = matched[2].length;
|
|
758
|
+
const secondLength = matched[3].length;
|
|
759
|
+
if (start2 === 0) {
|
|
760
|
+
end2 = hourLength;
|
|
761
|
+
} else if (start2 === 3) {
|
|
762
|
+
start2 = hourLength + 1;
|
|
763
|
+
end2 = hourLength + minuteLength + 1;
|
|
764
|
+
} else {
|
|
765
|
+
start2 = hourLength + minuteLength + 2;
|
|
766
|
+
end2 = hourLength + minuteLength + secondLength + 2;
|
|
767
|
+
}
|
|
568
768
|
}
|
|
569
769
|
}
|
|
570
770
|
return { start: start2, end: end2 };
|
|
@@ -659,18 +859,21 @@ const emitChange = ({ api, dispatch, emit, props, state }) => (val) => {
|
|
|
659
859
|
api.emitDbTime(props.value);
|
|
660
860
|
}
|
|
661
861
|
};
|
|
662
|
-
const emitInput = ({ api, emit, props, state }) => (val) => {
|
|
862
|
+
const emitInput = ({ api, emit, props, state }) => (val, visible = false) => {
|
|
663
863
|
let value = val;
|
|
664
|
-
const { from, to } = state.timezone;
|
|
864
|
+
const { from, to, timezoneOffset } = state.timezone;
|
|
665
865
|
if (props.type === "datetime") {
|
|
666
|
-
value = getDateWithNewTimezone(value, to, from);
|
|
866
|
+
value = getDateWithNewTimezone(value, to, from, -timezoneOffset);
|
|
667
867
|
} else if (props.type === "datetimerange" && Array.isArray(value)) {
|
|
668
|
-
value = value.map((val2) => getDateWithNewTimezone(val2, to, from));
|
|
868
|
+
value = value.map((val2) => getDateWithNewTimezone(val2, to, from, -timezoneOffset));
|
|
669
869
|
}
|
|
670
870
|
const formatted = api.formatToValue(value) || val;
|
|
671
871
|
if (!valueEquals(props.modelValue, formatted)) {
|
|
672
872
|
emit("update:modelValue", formatted);
|
|
673
873
|
}
|
|
874
|
+
if (!visible && !valueEquals(state.oldValue, formatted)) {
|
|
875
|
+
state.oldValue = formatted;
|
|
876
|
+
}
|
|
674
877
|
};
|
|
675
878
|
const isValidValue = ({ api, state }) => (value) => {
|
|
676
879
|
if (!state.picker) {
|
|
@@ -686,10 +889,10 @@ const watchIsRange = ({ api, state, TimePanel, TimeRangePanel }) => (value) => {
|
|
|
686
889
|
state.panel = value ? TimeRangePanel : TimePanel;
|
|
687
890
|
api.mountPicker();
|
|
688
891
|
};
|
|
689
|
-
const getType = ({ props }) => () => {
|
|
690
|
-
if (
|
|
892
|
+
const getType = ({ parent, props }) => () => {
|
|
893
|
+
if (parent.componentName === DATEPICKER.DatePicker) {
|
|
691
894
|
return props.type;
|
|
692
|
-
} else if (
|
|
895
|
+
} else if (parent.componentName === DATEPICKER.TimePicker) {
|
|
693
896
|
return props.isRange ? DATEPICKER.TimeRange : DATEPICKER.Time;
|
|
694
897
|
}
|
|
695
898
|
return DATEPICKER.TimeSelect;
|
|
@@ -702,7 +905,9 @@ const watchModelValue = ({ api, props, state, dispatch }) => (value, oldValue) =
|
|
|
702
905
|
api.parseString(state.historyInput && state.historyInput[1])
|
|
703
906
|
];
|
|
704
907
|
}
|
|
705
|
-
|
|
908
|
+
if (props.changeCompat) {
|
|
909
|
+
api.emitChange(props.modelValue);
|
|
910
|
+
}
|
|
706
911
|
if (!valueEquals(value, oldValue) && !state.pickerVisible && props.validateEvent) {
|
|
707
912
|
dispatch("FormItem", "form.change", value);
|
|
708
913
|
}
|
|
@@ -720,18 +925,22 @@ const computedFormat = ({ props, utils }) => () => {
|
|
|
720
925
|
}
|
|
721
926
|
return format;
|
|
722
927
|
};
|
|
723
|
-
const computedTriggerClass = ({ props, state }) => () =>
|
|
724
|
-
|
|
928
|
+
const computedTriggerClass = ({ props, state }) => () => {
|
|
929
|
+
return props.suffixIcon || props.prefixIcon || (state.type.includes(DATEPICKER.Time) ? DATEPICKER.IconTime : DATEPICKER.IconDate);
|
|
930
|
+
};
|
|
931
|
+
const computedHaveTrigger = ({ props }) => () => {
|
|
932
|
+
return typeof props.showTrigger !== "undefined" ? props.showTrigger : DATEPICKER.TriggerTypes.includes(props.type);
|
|
933
|
+
};
|
|
725
934
|
const initPopper = ({ props, hooks, vnode }) => {
|
|
726
935
|
const { reactive, watch, toRefs, onBeforeUnmount, onDeactivated } = hooks;
|
|
727
|
-
const { emit,
|
|
936
|
+
const { emit, vm, slots, nextTick } = vnode;
|
|
728
937
|
const placementMap = DATEPICKER.PlacementMap;
|
|
729
938
|
return userPopper({
|
|
730
939
|
reactive,
|
|
731
940
|
watch,
|
|
732
941
|
emit,
|
|
733
942
|
props: __spreadProps(__spreadValues({}, props), {
|
|
734
|
-
popperOptions: { boundariesPadding: 0, gpuAcceleration: false },
|
|
943
|
+
popperOptions: Object.assign({ boundariesPadding: 0, gpuAcceleration: false }, props.popperOptions),
|
|
735
944
|
visibleArrow: true,
|
|
736
945
|
offset: 0,
|
|
737
946
|
boundariesPadding: 5,
|
|
@@ -739,7 +948,7 @@ const initPopper = ({ props, hooks, vnode }) => {
|
|
|
739
948
|
placement: placementMap[props.align] || placementMap.left
|
|
740
949
|
}),
|
|
741
950
|
toRefs,
|
|
742
|
-
|
|
951
|
+
vm,
|
|
743
952
|
slots,
|
|
744
953
|
nextTick,
|
|
745
954
|
onBeforeUnmount,
|
|
@@ -809,6 +1018,8 @@ export {
|
|
|
809
1018
|
firstInputId,
|
|
810
1019
|
focus,
|
|
811
1020
|
formatAsFormatAndType,
|
|
1021
|
+
formatInputValue,
|
|
1022
|
+
formatText,
|
|
812
1023
|
formatToString,
|
|
813
1024
|
formatToValue,
|
|
814
1025
|
getMode,
|
|
@@ -826,6 +1037,7 @@ export {
|
|
|
826
1037
|
handleEnterDisplayOnlyContent,
|
|
827
1038
|
handleEnterPickerlabel,
|
|
828
1039
|
handleFocus,
|
|
1040
|
+
handleInput,
|
|
829
1041
|
handleKeydown,
|
|
830
1042
|
handleMouseEnter,
|
|
831
1043
|
handlePick,
|
|
@@ -850,6 +1062,7 @@ export {
|
|
|
850
1062
|
updateOptions,
|
|
851
1063
|
valueEquals,
|
|
852
1064
|
watchIsRange,
|
|
1065
|
+
watchMobileVisible,
|
|
853
1066
|
watchModelValue,
|
|
854
1067
|
watchPickerVisible
|
|
855
1068
|
};
|
package/picker/mb.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import "../chunk-G2ADBYYC.js";
|
|
2
|
+
const dateMobileToggle = ({ state, props }) => (visible) => {
|
|
3
|
+
if (props.readonly || state.pickerDisabled || state.dateMobileOption.visible === visible)
|
|
4
|
+
return;
|
|
5
|
+
if (visible) {
|
|
6
|
+
state.dateMobileOption.value = props.modelValue;
|
|
7
|
+
}
|
|
8
|
+
state.dateMobileOption.visible = visible;
|
|
9
|
+
};
|
|
10
|
+
const timeMobileToggle = ({ state, props, api }) => (visible) => {
|
|
11
|
+
if (props.readonly || state.pickerDisabled || state.timeMobileOption.visible === visible)
|
|
12
|
+
return;
|
|
13
|
+
if (visible) {
|
|
14
|
+
state.timeMobileOption.value = api.dateToTimeArray(props.modelValue);
|
|
15
|
+
}
|
|
16
|
+
state.timeMobileOption.visible = visible;
|
|
17
|
+
};
|
|
18
|
+
const timeMobileConfirm = ({ state, api }) => () => {
|
|
19
|
+
api.emitInput(api.timeArrayToDate(state.timeMobileOption.value));
|
|
20
|
+
};
|
|
21
|
+
const dateToTimeArray = (value) => {
|
|
22
|
+
const date = new Date(value);
|
|
23
|
+
return [date.getHours(), date.getMinutes(), date.getSeconds()];
|
|
24
|
+
};
|
|
25
|
+
const timeArrayToDate = ({ props }) => (value) => {
|
|
26
|
+
const timeArr = value;
|
|
27
|
+
let date = new Date(props.modelValue);
|
|
28
|
+
if (isNaN(date.getTime())) {
|
|
29
|
+
date = /* @__PURE__ */ new Date();
|
|
30
|
+
}
|
|
31
|
+
date.setHours(timeArr[0]);
|
|
32
|
+
date.setMinutes(timeArr[1]);
|
|
33
|
+
date.setSeconds(timeArr[2]);
|
|
34
|
+
return date;
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
dateMobileToggle,
|
|
38
|
+
dateToTimeArray,
|
|
39
|
+
timeArrayToDate,
|
|
40
|
+
timeMobileConfirm,
|
|
41
|
+
timeMobileToggle
|
|
42
|
+
};
|