@opentiny/vue-renderless 3.12.1 → 3.13.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/action-sheet/index.js +20 -13
- package/action-sheet/vue.js +8 -7
- package/alert/index.js +50 -1
- package/alert/vue.js +36 -9
- 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 +20 -6
- package/calendar-view/index.js +10 -12
- package/calendar-view/vue.js +17 -4
- package/cascader/index.js +80 -34
- package/cascader/vue.js +49 -19
- package/cascader-menu/index.js +7 -7
- package/cascader-menu/vue.js +2 -3
- package/cascader-mobile/index.js +37 -24
- package/cascader-mobile/vue.js +7 -1
- 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/cascader-view/index.js +1 -1
- 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 +17 -0
- package/checkbox/vue.js +16 -7
- package/checkbox-group/vue.js +2 -0
- package/col/vue.js +3 -2
- 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/date.js +2 -0
- package/common/deps/dom.js +19 -4
- package/common/deps/popper.js +48 -5
- package/common/deps/touch-emulator.js +4 -1
- package/common/deps/tree-model/node.js +1 -1
- package/common/deps/tree-model/tree-store.js +2 -13
- package/common/deps/useRect.js +25 -0
- package/common/deps/vue-popper.js +22 -10
- package/common/index.js +1 -1
- package/common/runtime.js +1 -1
- 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/container/index.js +17 -1
- package/container/vue.js +12 -3
- 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 +12 -5
- package/date-table/index.js +5 -0
- package/date-table/vue.js +3 -1
- package/dialog-box/index.js +17 -6
- package/dialog-select/index.js +6 -3
- package/dialog-select/vue.js +8 -4
- package/drawer/index.js +26 -5
- package/drawer/vue.js +13 -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 +21 -8
- 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 +47 -12
- package/file-upload/vue.js +38 -8
- package/filter-box/index.js +1 -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 +3 -1
- package/form-item/index.js +4 -4
- package/form-item/vue.js +3 -1
- package/fullscreen/index.js +5 -5
- package/fullscreen/vue.js +3 -3
- package/grid/utils/common.js +10 -5
- package/grid/utils/dom.js +7 -1
- package/image/index.js +6 -0
- package/image/vue.js +6 -3
- package/image-viewer/index.js +62 -51
- package/image-viewer/vue.js +17 -5
- package/input/index.js +89 -22
- package/input/vue.js +52 -21
- package/ip-address/index.js +61 -19
- package/ip-address/vue.js +22 -4
- package/label/index.js +56 -0
- package/label/vue.js +26 -0
- package/link/vue.js +3 -1
- package/loading/vue.js +8 -2
- package/logout/index.js +1 -1
- package/mask/index.js +13 -0
- package/mask/vue.js +18 -0
- package/mind-map/index.js +47 -0
- package/mind-map/vue.js +53 -0
- package/multi-select/index.js +150 -10
- package/multi-select/vue.js +46 -11
- package/multi-select-item/index.js +17 -0
- package/multi-select-item/vue.js +31 -0
- package/numeric/index.js +51 -9
- package/numeric/vue.js +44 -14
- package/option/index.js +12 -5
- package/option/vue.js +15 -7
- package/option-group/index.js +3 -3
- package/package.json +1 -1
- package/pager/index.js +372 -0
- package/pager/vue.js +125 -2
- package/picker/index.js +253 -48
- package/picker/mb.js +42 -0
- package/picker/vue.js +70 -17
- package/picker-column/index.js +1 -1
- package/pop-upload/index.js +0 -2
- package/pop-upload/vue.js +3 -4
- package/popconfirm/index.js +3 -6
- package/popconfirm/vue.js +1 -1
- package/popeditor/index.js +55 -24
- 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 +57 -65
- package/pull-refresh/vue.js +23 -7
- 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-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 +1 -1
- package/search/vue.js +3 -1
- package/select/index.js +176 -110
- package/select/vue.js +105 -20
- package/select-dropdown/index.js +62 -4
- package/select-dropdown/vue.js +85 -8
- package/select-view/index.js +3 -1
- 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 +27 -7
- package/slider/vue.js +26 -7
- package/split/index.js +1 -1
- 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 +9 -4
- package/tab-nav/vue.js +6 -2
- package/tabbar/vue.js +9 -3
- package/tabbar-item/vue.js +3 -2
- package/tabs/index.js +1 -1
- package/tabs/vue.js +1 -0
- package/tabs-mf/index.js +20 -6
- package/tabs-mf/vue-nav.js +26 -11
- package/tabs-mf/vue.js +7 -7
- package/tag/index.js +1 -1
- package/tag/vue.js +5 -1
- package/tag-group/index.js +2 -1
- package/tall-storage/index.js +4 -5
- package/time/index.js +4 -1
- package/time/vue.js +1 -1
- package/time-line/vue.js +1 -1
- package/time-picker-mobile/index.js +24 -5
- package/time-picker-mobile/vue.js +17 -7
- package/time-range/index.js +2 -0
- package/time-spinner/index.js +0 -3
- package/time-spinner/vue.js +2 -3
- package/timeline-item/vue.js +1 -1
- package/tooltip/index.js +1 -2
- package/tooltip/vue.js +3 -3
- 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 +27 -3
- package/tree-menu/vue.js +27 -14
- package/tree-node/index.js +12 -10
- package/tree-node/vue.js +6 -5
- package/types/action-menu.type.d.ts +5 -0
- package/types/action-sheet.type.d.ts +118 -1
- package/types/alert.type.d.ts +16 -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.type.d.ts +5 -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 +327 -1
- package/types/checkbox.type.d.ts +9 -0
- package/types/collapse.type.d.ts +19 -2
- package/types/date-picker.type.d.ts +34 -1
- package/types/dialog-box.type.d.ts +5 -1
- package/types/drawer.type.d.ts +132 -1
- package/types/{dropdown-item.type-bf83e929.d.ts → dropdown-item.type-8475a549.d.ts} +8 -14
- package/types/dropdown-item.type.d.ts +1 -1
- package/types/dropdown-menu.type.d.ts +1 -1
- package/types/dropdown.type.d.ts +2 -5
- package/types/fall-menu.type.d.ts +94 -1
- package/types/file-upload.type.d.ts +1 -1
- package/types/form-item.type.d.ts +1 -1
- package/types/{form.type-d0fd42f3.d.ts → form.type-d88482e4.d.ts} +3 -0
- package/types/form.type.d.ts +1 -1
- package/types/input.type.d.ts +23 -9
- package/types/ip-address.type.d.ts +160 -1
- package/types/label.type.d.ts +81 -0
- package/types/link.type.d.ts +6 -3
- package/types/mind-map.type.d.ts +20 -0
- package/types/modal.type.d.ts +4 -2
- package/types/numeric.type.d.ts +36 -9
- package/types/pager.type.d.ts +171 -1
- package/types/picker.type.d.ts +14 -0
- package/types/popconfirm.type.d.ts +85 -1
- package/types/popeditor.type.d.ts +4 -0
- package/types/popover.type.d.ts +3 -3
- 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 +8 -1
- package/types/steps.type.d.ts +14 -3
- package/types/tab-item.type.d.ts +0 -1
- package/types/tab-nav.type.d.ts +6 -1
- package/types/tabs.type.d.ts +5 -0
- package/types/tag-group.type.d.ts +64 -1
- package/types/tag.type.d.ts +12 -0
- package/types/tooltip.type.d.ts +1 -1
- package/types/transfer.type.d.ts +183 -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-1078fba2.d.ts} +27 -6
- package/types/upload-list.type.d.ts +1 -1
- package/types/upload.type.d.ts +1 -1
- package/types/wizard.type.d.ts +1 -0
- package/upload/index.js +59 -29
- package/upload/vue.js +6 -4
- package/upload-list/index.js +14 -14
- package/upload-list/vue.js +5 -2
- package/user/index.js +5 -4
- package/user-head/index.js +1 -1
- package/wheel/index.js +3 -0
- package/wizard/vue.js +4 -2
package/picker/index.js
CHANGED
|
@@ -6,7 +6,7 @@ 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
11
|
import { isFunction } from "../common/type";
|
|
12
12
|
import globalTimezone from "./timezone";
|
|
@@ -28,9 +28,8 @@ const getPanel = ({ DatePanel, DateRangePanel, MonthRangePanel, YearRangePanel,
|
|
|
28
28
|
return DatePanel;
|
|
29
29
|
};
|
|
30
30
|
const watchPickerVisible = ({ api, vm, dispatch, emit, props, state }) => (value) => {
|
|
31
|
-
if (props.readonly || state.pickerDisabled)
|
|
31
|
+
if (props.readonly || state.pickerDisabled || state.isMobileScreen)
|
|
32
32
|
return;
|
|
33
|
-
}
|
|
34
33
|
if (value) {
|
|
35
34
|
api.showPicker();
|
|
36
35
|
state.valueOnOpen = Array.isArray(props.modelValue) ? [...props.modelValue] : props.modelValue;
|
|
@@ -41,6 +40,9 @@ const watchPickerVisible = ({ api, vm, dispatch, emit, props, state }) => (value
|
|
|
41
40
|
if (props.validateEvent) {
|
|
42
41
|
dispatch("FormItem", "form.blur");
|
|
43
42
|
}
|
|
43
|
+
if (props.changeOnConfirm && !valueEquals(props.modelValue, state.oldValue)) {
|
|
44
|
+
emit("update:modelValue", state.oldValue);
|
|
45
|
+
}
|
|
44
46
|
emit("blur", vm);
|
|
45
47
|
api.blur();
|
|
46
48
|
}
|
|
@@ -72,16 +74,24 @@ const getMode = ({ state }) => () => {
|
|
|
72
74
|
}
|
|
73
75
|
return DATEPICKER.Day;
|
|
74
76
|
};
|
|
75
|
-
const formatAsFormatAndType = ({ api }) => (value, customFormat, type) => {
|
|
76
|
-
if (!value)
|
|
77
|
+
const formatAsFormatAndType = ({ api }) => (value, customFormat, type, formatObj) => {
|
|
78
|
+
if (!value)
|
|
77
79
|
return null;
|
|
78
|
-
}
|
|
79
80
|
const formatter = (api.typeValueResolveMap()[type] || api.typeValueResolveMap().default).formatter;
|
|
80
81
|
const format = customFormat || DATEPICKER.DateFormats[type];
|
|
81
|
-
return formatter(value, format);
|
|
82
|
+
return formatter(value, format, formatObj);
|
|
82
83
|
};
|
|
83
84
|
const displayValue = ({ api, props, state }) => () => {
|
|
84
|
-
const
|
|
85
|
+
const formatObj = {
|
|
86
|
+
rangeSeparator: props.rangeSeparator
|
|
87
|
+
};
|
|
88
|
+
const formattedValue = api.formatAsFormatAndType(
|
|
89
|
+
state.parsedValue,
|
|
90
|
+
state.format,
|
|
91
|
+
state.type,
|
|
92
|
+
props.rangeSeparator,
|
|
93
|
+
formatObj
|
|
94
|
+
);
|
|
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
|
}
|
|
@@ -125,18 +135,18 @@ const parsedValue = ({ api, props, state, t }) => () => {
|
|
|
125
135
|
}
|
|
126
136
|
const result = api.parseAsFormatAndType(date, state.valueFormat, state.type, props.rangeSeparator);
|
|
127
137
|
if (Array.isArray(result)) {
|
|
128
|
-
return result.map((date2) => getDateWithNewTimezone(date2, from, to));
|
|
138
|
+
return result.map((date2) => getDateWithNewTimezone(date2, from, to, timezoneOffset));
|
|
129
139
|
}
|
|
130
|
-
return getDateWithNewTimezone(result || props.modelValue, from, to);
|
|
140
|
+
return getDateWithNewTimezone(result || props.modelValue, from, to, timezoneOffset);
|
|
131
141
|
}
|
|
132
142
|
const trans = (value) => typeof value === "string" || isNumber(value) ? toDate(value) : value;
|
|
133
|
-
const values = [].concat(props.modelValue).map((val) => getDateWithNewTimezone(trans(val), from, to));
|
|
143
|
+
const values = [].concat(props.modelValue).map((val) => getDateWithNewTimezone(trans(val), from, to, timezoneOffset));
|
|
134
144
|
return values.length > 1 ? values : values[0];
|
|
135
145
|
};
|
|
136
146
|
const getTimezone = ({ props, utils }) => () => {
|
|
137
|
-
const { dbTimezone, timezone, isutc8, type = "date", iso8601 } = props;
|
|
147
|
+
const { dbTimezone, timezone, isutc8, type = "date", iso8601, timezoneOffset } = props;
|
|
138
148
|
const setting = utils.getDateFormat && utils.getDateFormat();
|
|
139
|
-
const { DbTimezone, Timezone } = setting || {};
|
|
149
|
+
const { DbTimezone, Timezone, TimezoneOffset } = setting || {};
|
|
140
150
|
const cur = getLocalTimezone();
|
|
141
151
|
const isTzNumber = (z) => typeof z === "number" && z >= -12 && z <= 12;
|
|
142
152
|
if (!~type.indexOf("datetime")) {
|
|
@@ -144,6 +154,7 @@ const getTimezone = ({ props, utils }) => () => {
|
|
|
144
154
|
}
|
|
145
155
|
let serveTimezone = isTzNumber(dbTimezone) ? dbTimezone : isTzNumber(DbTimezone) ? DbTimezone : cur;
|
|
146
156
|
let clientTimezone = isTzNumber(timezone) ? timezone : isTzNumber(Timezone) ? Timezone : cur;
|
|
157
|
+
let clientTimezoneOffset = isNumber(timezoneOffset) ? timezoneOffset : isNumber(TimezoneOffset) ? TimezoneOffset : 0;
|
|
147
158
|
const value = props.modelValue;
|
|
148
159
|
const str = (Array.isArray(value) ? value[0] : value) || "";
|
|
149
160
|
const match = typeof str === "string" && str.match(/(-|\+)(\d{2}):?(\d{2})$/);
|
|
@@ -153,7 +164,8 @@ const getTimezone = ({ props, utils }) => () => {
|
|
|
153
164
|
return {
|
|
154
165
|
from: serveTimezone,
|
|
155
166
|
to: isutc8 ? 8 : clientTimezone,
|
|
156
|
-
isServiceTimezone: !!setting
|
|
167
|
+
isServiceTimezone: !!setting,
|
|
168
|
+
timezoneOffset: clientTimezoneOffset
|
|
157
169
|
};
|
|
158
170
|
};
|
|
159
171
|
const nullOrString = (value) => {
|
|
@@ -182,11 +194,12 @@ const dateFormatter = ({ t }) => (value, format) => {
|
|
|
182
194
|
}
|
|
183
195
|
return formatDate(value, format, t);
|
|
184
196
|
};
|
|
185
|
-
const dateParser = ({ t }) => (text, format) => {
|
|
197
|
+
const dateParser = ({ t, props }) => (text, format) => {
|
|
186
198
|
if (format === DATEPICKER.TimesTamp) {
|
|
187
199
|
return new Date(Number(text));
|
|
188
200
|
}
|
|
189
|
-
|
|
201
|
+
const value = props.autoFormat ? formatText({ text, format }) : text;
|
|
202
|
+
return parseDate(value, format, t);
|
|
190
203
|
};
|
|
191
204
|
const rangeFormatter = (api) => (value, format) => {
|
|
192
205
|
if (Array.isArray(value) && value.length === 2) {
|
|
@@ -227,24 +240,43 @@ const getDefaultOfTypeValueResolveMap = () => ({
|
|
|
227
240
|
return text === void 0 || text === "" ? null : text;
|
|
228
241
|
}
|
|
229
242
|
});
|
|
230
|
-
const getWeekOfTypeValueResolveMap = ({ t, api }) => ({
|
|
231
|
-
formatter(value, format) {
|
|
243
|
+
const getWeekOfTypeValueResolveMap = ({ t, props, api }) => ({
|
|
244
|
+
formatter(value, format, formatObj) {
|
|
232
245
|
const weekDate = getWeekData(value);
|
|
233
246
|
let week = getWeekNumber(weekDate);
|
|
234
247
|
let month = weekDate.getMonth();
|
|
235
248
|
const trueDate = new Date(weekDate);
|
|
249
|
+
const { rangeSeparator = "-", type = "format" } = formatObj;
|
|
236
250
|
if (week === 1 && month === 11) {
|
|
237
251
|
trueDate.setHours(0, 0, 0, 0);
|
|
238
252
|
trueDate.setDate(trueDate.getDate() + 3 - (trueDate.getDay() + 6) % 7);
|
|
239
253
|
}
|
|
240
|
-
let date
|
|
241
|
-
|
|
254
|
+
let date;
|
|
255
|
+
if (type === "format" && !/W/.test(format)) {
|
|
256
|
+
const { start, end } = getWeekRange(value, format, t, props.pickerOptions);
|
|
257
|
+
date = `${start} ${rangeSeparator} ${end}`;
|
|
258
|
+
} else {
|
|
259
|
+
date = formatDate(trueDate, format, t);
|
|
260
|
+
date = /WW/.test(date) ? date.replace(/WW/, week < 10 ? "0" + week : week) : date.replace(/W/, week);
|
|
261
|
+
}
|
|
242
262
|
return date;
|
|
243
263
|
},
|
|
244
264
|
parser(text, format) {
|
|
245
265
|
return api.typeValueResolveMap().date.parser(text, format);
|
|
246
266
|
}
|
|
247
267
|
});
|
|
268
|
+
const getWeekRange = (value, format, t, pickerOptions) => {
|
|
269
|
+
const firstDayOfWeek = pickerOptions && pickerOptions.firstDayOfWeek ? pickerOptions.firstDayOfWeek : 7;
|
|
270
|
+
const dayOffset = (value.getDay() - firstDayOfWeek + 7) % 7;
|
|
271
|
+
const startDate = prevDate(value, dayOffset);
|
|
272
|
+
const endDate = nextDate(startDate, 6);
|
|
273
|
+
const start = formatDate(startDate, format, t);
|
|
274
|
+
const end = formatDate(endDate, format, t);
|
|
275
|
+
return {
|
|
276
|
+
start,
|
|
277
|
+
end
|
|
278
|
+
};
|
|
279
|
+
};
|
|
248
280
|
const getNumberOfTypeValueResolveMap = () => ({
|
|
249
281
|
formatter(value) {
|
|
250
282
|
return value ? String(value) : "";
|
|
@@ -264,9 +296,9 @@ const getDatesOfTypeValueResolveMap = (api) => ({
|
|
|
264
296
|
);
|
|
265
297
|
}
|
|
266
298
|
});
|
|
267
|
-
const typeValueResolveMap = ({ api, t }) => () => ({
|
|
299
|
+
const typeValueResolveMap = ({ api, props, t }) => () => ({
|
|
268
300
|
default: getDefaultOfTypeValueResolveMap(),
|
|
269
|
-
week: getWeekOfTypeValueResolveMap({ t, api }),
|
|
301
|
+
week: getWeekOfTypeValueResolveMap({ t, props, api }),
|
|
270
302
|
date: { formatter: api.dateFormatter, parser: api.dateParser },
|
|
271
303
|
datetime: { formatter: api.dateFormatter, parser: api.dateParser },
|
|
272
304
|
daterange: { formatter: api.rangeFormatter, parser: api.rangeParser },
|
|
@@ -305,7 +337,7 @@ const secondInputId = ({ props, state }) => () => {
|
|
|
305
337
|
}
|
|
306
338
|
return obj;
|
|
307
339
|
};
|
|
308
|
-
const focus = ({ api, props, vm }) => () => !props.
|
|
340
|
+
const focus = ({ api, props, vm }) => () => !props.isRange ? vm.$refs.reference.focus() : api.handleFocus();
|
|
309
341
|
const blur = (state) => () => state.refInput.forEach((input) => input.blur());
|
|
310
342
|
const parseValue = ({ api, props, state }) => (value) => {
|
|
311
343
|
const isParsed = isDateObject(value) || Array.isArray(value) && value.every(isDateObject);
|
|
@@ -314,10 +346,12 @@ const parseValue = ({ api, props, state }) => (value) => {
|
|
|
314
346
|
}
|
|
315
347
|
return value;
|
|
316
348
|
};
|
|
317
|
-
const formatToValue = ({ api,
|
|
349
|
+
const formatToValue = ({ api, state }) => (date) => {
|
|
318
350
|
const isFormattable = isDateObject(date) || Array.isArray(date) && date.every(isDateObject);
|
|
319
351
|
if (state.valueFormat && isFormattable) {
|
|
320
|
-
return api.formatAsFormatAndType(date, state.valueFormat, state.type,
|
|
352
|
+
return api.formatAsFormatAndType(date, state.valueFormat, state.type, {
|
|
353
|
+
type: "value-format"
|
|
354
|
+
});
|
|
321
355
|
}
|
|
322
356
|
return date;
|
|
323
357
|
};
|
|
@@ -354,18 +388,20 @@ const handleChange = ({ api, state }) => () => {
|
|
|
354
388
|
state.userInput = null;
|
|
355
389
|
}
|
|
356
390
|
};
|
|
357
|
-
const handleStartInput = (state) => (event) => {
|
|
391
|
+
const handleStartInput = (state, props, api) => (event) => {
|
|
392
|
+
const value = props.autoFormat ? api.formatInputValue({ event, prevValue: state.displayValue[0] }) : event.target.value;
|
|
358
393
|
if (state.userInput) {
|
|
359
|
-
state.userInput = [
|
|
394
|
+
state.userInput = [value, state.userInput[1]];
|
|
360
395
|
} else {
|
|
361
|
-
state.userInput = [
|
|
396
|
+
state.userInput = [value, null];
|
|
362
397
|
}
|
|
363
398
|
};
|
|
364
|
-
const handleEndInput = (state) => (event) => {
|
|
399
|
+
const handleEndInput = ({ state, props, api }) => (event) => {
|
|
400
|
+
const value = props.autoFormat ? api.formatInputValue({ event, prevValue: state.displayValue[1] }) : event.target.value;
|
|
365
401
|
if (state.userInput) {
|
|
366
|
-
state.userInput = [state.userInput[0],
|
|
402
|
+
state.userInput = [state.userInput[0], value];
|
|
367
403
|
} else {
|
|
368
|
-
state.userInput = [null,
|
|
404
|
+
state.userInput = [null, value];
|
|
369
405
|
}
|
|
370
406
|
};
|
|
371
407
|
const handleStartChange = ({ api, state }) => () => {
|
|
@@ -463,13 +499,19 @@ const handleClose = ({ api, props, state }) => () => {
|
|
|
463
499
|
state.pickerVisible = false;
|
|
464
500
|
if (state.type === DATEPICKER.Dates) {
|
|
465
501
|
const oldValue = api.parseAsFormatAndType(state.valueOnOpen, state.valueFormat, state.type, props.rangeSeparator) || state.valueOnOpen;
|
|
466
|
-
api.emitInput(oldValue);
|
|
502
|
+
api.emitInput(oldValue, true);
|
|
467
503
|
}
|
|
468
504
|
};
|
|
469
|
-
const handleFocus = ({ emit, vm, state }) => () => {
|
|
505
|
+
const handleFocus = ({ emit, vm, state, api }) => () => {
|
|
470
506
|
const type = state.type;
|
|
471
|
-
if (DATEPICKER.TriggerTypes.includes(type)
|
|
472
|
-
state.
|
|
507
|
+
if (DATEPICKER.TriggerTypes.includes(type)) {
|
|
508
|
+
if (state.isMobileScreen && state.isDateMobileComponent) {
|
|
509
|
+
api.dateMobileToggle(true);
|
|
510
|
+
} else if (state.isMobileScreen && state.isTimeMobileComponent) {
|
|
511
|
+
api.timeMobileToggle(true);
|
|
512
|
+
} else {
|
|
513
|
+
state.pickerVisible = true;
|
|
514
|
+
}
|
|
473
515
|
}
|
|
474
516
|
emit("focus", vm.$refs.reference);
|
|
475
517
|
};
|
|
@@ -533,13 +575,17 @@ const showPicker = ({ api, nextTick, updatePopper, state }) => () => {
|
|
|
533
575
|
state.pickerVisible = state.picker.state.visible = true;
|
|
534
576
|
state.picker.state.value = state.parsedValue;
|
|
535
577
|
state.picker.resetView && state.picker.resetView();
|
|
536
|
-
|
|
537
|
-
|
|
578
|
+
nextTick(() => {
|
|
579
|
+
updatePopper(state.picker.$el);
|
|
580
|
+
state.picker.adjustSpinners && state.picker.adjustSpinners();
|
|
581
|
+
});
|
|
538
582
|
};
|
|
539
583
|
const handlePick = ({ state, api }) => (date = "", visible = false) => {
|
|
584
|
+
if (!state.picker)
|
|
585
|
+
return;
|
|
540
586
|
state.userInput = null;
|
|
541
587
|
state.pickerVisible = state.picker.state.visible = visible;
|
|
542
|
-
api.emitInput(date);
|
|
588
|
+
api.emitInput(date, visible);
|
|
543
589
|
state.date = date;
|
|
544
590
|
state.picker.resetView && state.picker.resetView();
|
|
545
591
|
};
|
|
@@ -659,18 +705,21 @@ const emitChange = ({ api, dispatch, emit, props, state }) => (val) => {
|
|
|
659
705
|
api.emitDbTime(props.value);
|
|
660
706
|
}
|
|
661
707
|
};
|
|
662
|
-
const emitInput = ({ api, emit, props, state }) => (val) => {
|
|
708
|
+
const emitInput = ({ api, emit, props, state }) => (val, visible = false) => {
|
|
663
709
|
let value = val;
|
|
664
|
-
const { from, to } = state.timezone;
|
|
710
|
+
const { from, to, timezoneOffset } = state.timezone;
|
|
665
711
|
if (props.type === "datetime") {
|
|
666
|
-
value = getDateWithNewTimezone(value, to, from);
|
|
712
|
+
value = getDateWithNewTimezone(value, to, from, -timezoneOffset);
|
|
667
713
|
} else if (props.type === "datetimerange" && Array.isArray(value)) {
|
|
668
|
-
value = value.map((val2) => getDateWithNewTimezone(val2, to, from));
|
|
714
|
+
value = value.map((val2) => getDateWithNewTimezone(val2, to, from, -timezoneOffset));
|
|
669
715
|
}
|
|
670
716
|
const formatted = api.formatToValue(value) || val;
|
|
671
717
|
if (!valueEquals(props.modelValue, formatted)) {
|
|
672
718
|
emit("update:modelValue", formatted);
|
|
673
719
|
}
|
|
720
|
+
if (!visible && !valueEquals(state.oldValue, formatted)) {
|
|
721
|
+
state.oldValue = formatted;
|
|
722
|
+
}
|
|
674
723
|
};
|
|
675
724
|
const isValidValue = ({ api, state }) => (value) => {
|
|
676
725
|
if (!state.picker) {
|
|
@@ -686,10 +735,10 @@ const watchIsRange = ({ api, state, TimePanel, TimeRangePanel }) => (value) => {
|
|
|
686
735
|
state.panel = value ? TimeRangePanel : TimePanel;
|
|
687
736
|
api.mountPicker();
|
|
688
737
|
};
|
|
689
|
-
const getType = ({ props }) => () => {
|
|
690
|
-
if (
|
|
738
|
+
const getType = ({ parent, props }) => () => {
|
|
739
|
+
if (parent.componentName === DATEPICKER.DatePicker) {
|
|
691
740
|
return props.type;
|
|
692
|
-
} else if (
|
|
741
|
+
} else if (parent.componentName === DATEPICKER.TimePicker) {
|
|
693
742
|
return props.isRange ? DATEPICKER.TimeRange : DATEPICKER.Time;
|
|
694
743
|
}
|
|
695
744
|
return DATEPICKER.TimeSelect;
|
|
@@ -724,7 +773,7 @@ const computedTriggerClass = ({ props, state }) => () => props.suffixIcon || pro
|
|
|
724
773
|
const computedHaveTrigger = ({ props }) => () => typeof props.showTrigger !== "undefined" ? props.showTrigger : DATEPICKER.TriggerTypes.includes(props.type);
|
|
725
774
|
const initPopper = ({ props, hooks, vnode }) => {
|
|
726
775
|
const { reactive, watch, toRefs, onBeforeUnmount, onDeactivated } = hooks;
|
|
727
|
-
const { emit,
|
|
776
|
+
const { emit, vm, slots, nextTick } = vnode;
|
|
728
777
|
const placementMap = DATEPICKER.PlacementMap;
|
|
729
778
|
return userPopper({
|
|
730
779
|
reactive,
|
|
@@ -739,7 +788,7 @@ const initPopper = ({ props, hooks, vnode }) => {
|
|
|
739
788
|
placement: placementMap[props.align] || placementMap.left
|
|
740
789
|
}),
|
|
741
790
|
toRefs,
|
|
742
|
-
|
|
791
|
+
vm,
|
|
743
792
|
slots,
|
|
744
793
|
nextTick,
|
|
745
794
|
onBeforeUnmount,
|
|
@@ -795,6 +844,159 @@ const setInputPaddingLeft = ({ props, state, vm, nextTick }) => () => {
|
|
|
795
844
|
});
|
|
796
845
|
}
|
|
797
846
|
};
|
|
847
|
+
const getSelectionStart = ({ value, format, regx, event }) => {
|
|
848
|
+
const formatMatchArr = format.match(regx);
|
|
849
|
+
let selectionStart = getSelectionStartIndex(event);
|
|
850
|
+
let I = 0;
|
|
851
|
+
if (value !== "") {
|
|
852
|
+
const match = value.match(/[0-9]/g);
|
|
853
|
+
I = match === null ? 0 : match.length;
|
|
854
|
+
for (let i = 0; i < formatMatchArr.length; i++) {
|
|
855
|
+
I -= Math.max(formatMatchArr[i].length, 2);
|
|
856
|
+
}
|
|
857
|
+
I = I >= 0 ? 1 : 0;
|
|
858
|
+
I === 1 && selectionStart >= value.length && (selectionStart = value.length - 1);
|
|
859
|
+
}
|
|
860
|
+
return { selectionStart, I };
|
|
861
|
+
};
|
|
862
|
+
const getNum = (value, format, regx) => {
|
|
863
|
+
let len = value.length;
|
|
864
|
+
if (format && regx) {
|
|
865
|
+
const formatMatchArr = format.match(regx);
|
|
866
|
+
len = Math.max(len, formatMatchArr.join("").length);
|
|
867
|
+
}
|
|
868
|
+
let num = { str: "", arr: [] };
|
|
869
|
+
for (let i = 0; i < len; i++) {
|
|
870
|
+
let char = value.charAt(i) ? value.charAt(i) : "00";
|
|
871
|
+
if (/[0-9]/.test(char)) {
|
|
872
|
+
num.str += char;
|
|
873
|
+
} else {
|
|
874
|
+
num.arr[i] = 1;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
return num;
|
|
878
|
+
};
|
|
879
|
+
const getSelectionStartIndex = (event) => {
|
|
880
|
+
const inputElem = event.target;
|
|
881
|
+
return inputElem.selectionStart - (event.data ? event.data.length : 0);
|
|
882
|
+
};
|
|
883
|
+
const getNumAndSelectionStart = ({ value, format, regx, event, needSelectionStart }) => {
|
|
884
|
+
if (needSelectionStart) {
|
|
885
|
+
let { selectionStart, I } = getSelectionStart({ value, format, regx, event });
|
|
886
|
+
let valueStr;
|
|
887
|
+
if (event.data) {
|
|
888
|
+
valueStr = value.substring(0, selectionStart) + event.data + value.substring(selectionStart + I);
|
|
889
|
+
selectionStart++;
|
|
890
|
+
} else {
|
|
891
|
+
valueStr = value;
|
|
892
|
+
}
|
|
893
|
+
const numStr = getNum(valueStr);
|
|
894
|
+
return { numStr, selectionStart };
|
|
895
|
+
} else {
|
|
896
|
+
const numStr = getNum(value, format, regx);
|
|
897
|
+
return { numStr };
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
const checkFormat = ({ value, format, startIndex, selectionStart, regx, needSelectionStart }) => {
|
|
901
|
+
if (!needSelectionStart && regx.lastIndex === 0 || needSelectionStart && regx.lastIndex === 0 && selectionStart >= startIndex) {
|
|
902
|
+
const subFormat = `(?<=${format.substring(0, startIndex)})(\\s*\\S*\\s*)+`;
|
|
903
|
+
const pattern = new RegExp(subFormat, "g");
|
|
904
|
+
const res = format.match(pattern);
|
|
905
|
+
if (res) {
|
|
906
|
+
value += res[0];
|
|
907
|
+
selectionStart = value.length;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
return { value, selectionStart };
|
|
911
|
+
};
|
|
912
|
+
const moveStart = (inputElem, moveStartIndex) => {
|
|
913
|
+
if (inputElem.setSelectionRange) {
|
|
914
|
+
inputElem.focus();
|
|
915
|
+
setTimeout(() => {
|
|
916
|
+
inputElem.setSelectionRange(moveStartIndex, moveStartIndex);
|
|
917
|
+
}, 0);
|
|
918
|
+
}
|
|
919
|
+
};
|
|
920
|
+
const handleInput = ({ state, props, api }) => (val, event) => {
|
|
921
|
+
if (props.autoFormat) {
|
|
922
|
+
const value = api.formatInputValue({ event, prevValue: state.displayValue });
|
|
923
|
+
state.userInput = value;
|
|
924
|
+
} else {
|
|
925
|
+
state.userInput = val;
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
const formatInputValue = ({ props, state }) => ({ event, prevValue = "" }) => {
|
|
929
|
+
const val = event.target.value;
|
|
930
|
+
const inputData = event.data;
|
|
931
|
+
const format = state.type === "time-select" ? "HH:mm" : props.format || DATEPICKER.DateFormats[state.type];
|
|
932
|
+
if (inputData && inputData.charCodeAt() >= 48 && inputData.charCodeAt() <= 57) {
|
|
933
|
+
return formatText({ event, format, text: prevValue, needSelectionStart: true });
|
|
934
|
+
} else {
|
|
935
|
+
return val;
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
const formatText = ({ event, text, format, needSelectionStart = false }) => {
|
|
939
|
+
if (!format)
|
|
940
|
+
return text;
|
|
941
|
+
let cursorOffset = 0;
|
|
942
|
+
let value = "";
|
|
943
|
+
let regx = /yyyy|yyy|yy|y|MM|M|dd|d|HH|hh|H|h|mm|m|ss|s|WW|W|w/g;
|
|
944
|
+
let startIndex = 0;
|
|
945
|
+
let { numStr, selectionStart } = getNumAndSelectionStart({
|
|
946
|
+
value: text,
|
|
947
|
+
format,
|
|
948
|
+
regx,
|
|
949
|
+
event,
|
|
950
|
+
needSelectionStart
|
|
951
|
+
});
|
|
952
|
+
let matchResult = regx.exec(format);
|
|
953
|
+
while (numStr.str !== "" && matchResult !== null) {
|
|
954
|
+
let subStr;
|
|
955
|
+
let newNum;
|
|
956
|
+
let subLen;
|
|
957
|
+
const endIndex = matchResult.index;
|
|
958
|
+
if (startIndex >= 0) {
|
|
959
|
+
value += format.substring(startIndex, endIndex);
|
|
960
|
+
}
|
|
961
|
+
selectionStart >= startIndex + cursorOffset && selectionStart <= endIndex + cursorOffset && (selectionStart = selectionStart + endIndex - startIndex);
|
|
962
|
+
startIndex = regx.lastIndex;
|
|
963
|
+
subLen = startIndex - endIndex;
|
|
964
|
+
subStr = numStr.str.substring(0, subLen);
|
|
965
|
+
const firstMatchChar = matchResult[0].charAt(0);
|
|
966
|
+
const firstChar = parseInt(subStr.charAt(0), 10);
|
|
967
|
+
if (numStr.str.length > 1) {
|
|
968
|
+
const secondChar = numStr.str.charAt(1);
|
|
969
|
+
newNum = 10 * firstChar + parseInt(secondChar, 10);
|
|
970
|
+
} else {
|
|
971
|
+
newNum = firstChar;
|
|
972
|
+
}
|
|
973
|
+
if (numStr.arr[endIndex + 1] || firstMatchChar === "M" && newNum > 12 || firstMatchChar === "d" && newNum > 31 || ["H", "h"].includes(firstMatchChar) && newNum > 23 || "ms".includes(firstMatchChar) && newNum > 59) {
|
|
974
|
+
subStr = matchResult[0].length === 2 ? "0" + firstChar : firstChar;
|
|
975
|
+
selectionStart++;
|
|
976
|
+
} else {
|
|
977
|
+
if (subLen === 1) {
|
|
978
|
+
subStr = String(newNum);
|
|
979
|
+
subLen++;
|
|
980
|
+
cursorOffset++;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
value += subStr;
|
|
984
|
+
numStr.str = numStr.str.substring(subLen);
|
|
985
|
+
matchResult = regx.exec(format);
|
|
986
|
+
}
|
|
987
|
+
const { value: val, selectionStart: cursorPos } = checkFormat({
|
|
988
|
+
value,
|
|
989
|
+
format,
|
|
990
|
+
startIndex,
|
|
991
|
+
selectionStart,
|
|
992
|
+
regx,
|
|
993
|
+
needSelectionStart
|
|
994
|
+
});
|
|
995
|
+
value = val;
|
|
996
|
+
selectionStart = cursorPos;
|
|
997
|
+
needSelectionStart && moveStart(event.target, selectionStart);
|
|
998
|
+
return value;
|
|
999
|
+
};
|
|
798
1000
|
export {
|
|
799
1001
|
blur,
|
|
800
1002
|
computedFormat,
|
|
@@ -809,6 +1011,8 @@ export {
|
|
|
809
1011
|
firstInputId,
|
|
810
1012
|
focus,
|
|
811
1013
|
formatAsFormatAndType,
|
|
1014
|
+
formatInputValue,
|
|
1015
|
+
formatText,
|
|
812
1016
|
formatToString,
|
|
813
1017
|
formatToValue,
|
|
814
1018
|
getMode,
|
|
@@ -826,6 +1030,7 @@ export {
|
|
|
826
1030
|
handleEnterDisplayOnlyContent,
|
|
827
1031
|
handleEnterPickerlabel,
|
|
828
1032
|
handleFocus,
|
|
1033
|
+
handleInput,
|
|
829
1034
|
handleKeydown,
|
|
830
1035
|
handleMouseEnter,
|
|
831
1036
|
handlePick,
|
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
|
+
};
|