@varlet/ui 3.18.2 → 3.19.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/es/action-sheet/ActionItem.mjs +28 -8
- package/es/action-sheet/actionSheet.css +1 -1
- package/es/action-sheet/index.mjs +4 -2
- package/es/action-sheet/style/index.mjs +1 -1
- package/es/alert/alert.css +1 -1
- package/es/badge/Badge.mjs +20 -10
- package/es/badge/badge.css +1 -1
- package/es/bottom-navigation-item/BottomNavigationItem.mjs +34 -20
- package/es/bottom-navigation-item/bottomNavigationItem.css +1 -1
- package/es/checkbox/Checkbox.mjs +45 -22
- package/es/checkbox/checkbox.css +1 -1
- package/es/chip/Chip.mjs +11 -4
- package/es/chip/chip.css +1 -1
- package/es/chip/props.mjs +4 -0
- package/es/date-input/DateInput.mjs +865 -0
- package/es/date-input/DateInputSfc.css +0 -0
- package/es/date-input/TimeSelect.mjs +201 -0
- package/es/date-input/date-input.css +1 -0
- package/es/date-input/index.mjs +12 -0
- package/es/date-input/props.mjs +77 -0
- package/es/date-input/style/index.mjs +14 -0
- package/es/date-picker/DatePicker.mjs +522 -451
- package/es/date-picker/DayPickerPanel.mjs +318 -0
- package/es/date-picker/MonthPickerPanel.mjs +187 -0
- package/es/date-picker/PanelHeader.mjs +332 -0
- package/es/date-picker/YearPickerPanel.mjs +199 -0
- package/es/date-picker/constants.mjs +31 -0
- package/es/date-picker/date-picker.css +1 -1
- package/es/date-picker/props.mjs +6 -9
- package/es/date-picker/style/index.mjs +0 -1
- package/es/date-picker/types.mjs +0 -0
- package/es/field-decorator/fieldDecorator.css +1 -1
- package/es/icon/icon.css +1 -1
- package/es/index.bundle.mjs +7 -1
- package/es/index.mjs +6 -1
- package/es/input/props.mjs +1 -1
- package/es/locale/en-US.mjs +2 -0
- package/es/locale/fa-IR.mjs +2 -0
- package/es/locale/ja-JP.mjs +2 -0
- package/es/locale/zh-CN.mjs +2 -0
- package/es/locale/zh-TW.mjs +2 -0
- package/es/menu-select/MenuSelect.mjs +11 -2
- package/es/menu-select/menuSelect.css +1 -1
- package/es/radio/Radio.mjs +30 -14
- package/es/radio/radio.css +1 -1
- package/es/rail-navigation-item/RailNavigationItem.mjs +33 -19
- package/es/rail-navigation-item/railNavigationItem.css +1 -1
- package/es/rate/Rate.mjs +23 -12
- package/es/rate/rate.css +1 -1
- package/es/select/Select.mjs +10 -1
- package/es/select/select.css +1 -1
- package/es/step/Step.mjs +50 -20
- package/es/step/step.css +1 -1
- package/es/style.mjs +1 -0
- package/es/themes/dark/alert.mjs +2 -2
- package/es/themes/dark/dateInput.mjs +9 -0
- package/es/themes/dark/datePicker.mjs +23 -19
- package/es/themes/dark/index.mjs +3 -2
- package/es/themes/md3-dark/alert.mjs +2 -2
- package/es/themes/md3-dark/dateInput.mjs +9 -0
- package/es/themes/md3-dark/datePicker.mjs +18 -13
- package/es/themes/md3-dark/index.mjs +3 -2
- package/es/themes/md3-light/alert.mjs +2 -2
- package/es/themes/md3-light/dateInput.mjs +9 -0
- package/es/themes/md3-light/datePicker.mjs +18 -13
- package/es/themes/md3-light/index.mjs +3 -2
- package/es/utils/elements.mjs +7 -0
- package/es/utils/shared.mjs +15 -0
- package/es/varlet.css +1 -1
- package/es/varlet.esm.js +11893 -10656
- package/highlight/web-types.en-US.json +599 -73
- package/highlight/web-types.zh-CN.json +572 -67
- package/lib/varlet.cjs.js +5592 -4211
- package/lib/varlet.css +1 -1
- package/package.json +7 -7
- package/types/actionSheet.d.ts +1 -1
- package/types/badge.d.ts +1 -0
- package/types/chip.d.ts +3 -0
- package/types/dateInput.d.ts +96 -0
- package/types/datePicker.d.ts +4 -2
- package/types/index.d.ts +2 -0
- package/types/locale.d.ts +2 -0
- package/types/rate.d.ts +7 -0
- package/types/step.d.ts +3 -0
- package/types/styleVars.d.ts +14 -4
- package/umd/varlet.js +7 -7
- package/es/date-picker/src/day-picker-panel.mjs +0 -385
- package/es/date-picker/src/month-picker-panel.mjs +0 -300
- package/es/date-picker/src/panel-header.mjs +0 -142
- package/es/date-picker/src/year-picker-panel.mjs +0 -311
|
@@ -1,54 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var fulfilled = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
step(generator.next(value));
|
|
6
|
-
} catch (e) {
|
|
7
|
-
reject(e);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
import { call, doubleRaf, error, isArray, toNumber } from "@varlet/shared";
|
|
22
|
-
import dayjs from "dayjs/esm/index.js";
|
|
23
|
-
import { computed, defineComponent, ref, watch } from "vue";
|
|
1
|
+
import { call, error, isArray, toNumber, uniq } from "@varlet/shared";
|
|
2
|
+
import { computed, defineComponent, reactive, ref, watch } from "vue";
|
|
24
3
|
import { t } from "../locale/index.mjs";
|
|
25
4
|
import { injectLocaleProvider } from "../locale-provider/provide.mjs";
|
|
26
5
|
import { createNamespace, formatElevation } from "../utils/components.mjs";
|
|
27
|
-
import { padStart } from "../utils/shared.mjs";
|
|
6
|
+
import { createDayjs, padStart } from "../utils/shared.mjs";
|
|
28
7
|
import {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
8
|
+
DatePickerFormats,
|
|
9
|
+
DatePickerTypes,
|
|
10
|
+
DatePickerUnits,
|
|
11
|
+
MonthList,
|
|
12
|
+
ShiftDirections,
|
|
13
|
+
WeekHeader
|
|
14
|
+
} from "./constants.mjs";
|
|
15
|
+
import DayPickerPanel from "./DayPickerPanel.mjs";
|
|
16
|
+
import MonthPickerPanel from "./MonthPickerPanel.mjs";
|
|
17
|
+
import PanelHeader from "./PanelHeader.mjs";
|
|
18
|
+
import { props } from "./props.mjs";
|
|
19
|
+
import YearPickerPanel from "./YearPickerPanel.mjs";
|
|
36
20
|
const { name, n, classes } = createNamespace("date-picker");
|
|
37
|
-
|
|
21
|
+
const dayjs = createDayjs();
|
|
22
|
+
import { toDisplayString as _toDisplayString, normalizeClass as _normalizeClass, createElementVNode as _createElementVNode, renderSlot as _renderSlot, createTextVNode as _createTextVNode, createCommentVNode as _createCommentVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, normalizeProps as _normalizeProps, mergeProps as _mergeProps, Transition as _Transition, withCtx as _withCtx, createVNode as _createVNode, normalizeStyle as _normalizeStyle, resolveComponent as _resolveComponent, createBlock as _createBlock, withModifiers as _withModifiers } from "vue";
|
|
38
23
|
function __render__(_ctx, _cache) {
|
|
39
|
-
|
|
24
|
+
const _component_panel_header = _resolveComponent("panel-header");
|
|
40
25
|
const _component_year_picker_panel = _resolveComponent("year-picker-panel");
|
|
41
26
|
const _component_month_picker_panel = _resolveComponent("month-picker-panel");
|
|
42
27
|
const _component_day_picker_panel = _resolveComponent("day-picker-panel");
|
|
43
28
|
return _openBlock(), _createElementBlock(
|
|
44
29
|
"div",
|
|
45
30
|
{
|
|
46
|
-
class: _normalizeClass(_ctx.classes(_ctx.n(), _ctx.formatElevation(_ctx.elevation, 2)))
|
|
31
|
+
class: _normalizeClass(_ctx.classes(_ctx.n(), _ctx.formatElevation(_ctx.elevation, 2), [!_ctx.showTitle, _ctx.n("--no-title")])),
|
|
32
|
+
onPointerdownCapture: _cache[4] || (_cache[4] = _withModifiers(() => {
|
|
33
|
+
}, ["prevent"]))
|
|
47
34
|
},
|
|
48
35
|
[
|
|
49
|
-
|
|
36
|
+
_ctx.showTitle ? (_openBlock(), _createElementBlock(
|
|
50
37
|
"div",
|
|
51
38
|
{
|
|
39
|
+
key: 0,
|
|
52
40
|
class: _normalizeClass(_ctx.n("title")),
|
|
53
41
|
style: _normalizeStyle({ background: _ctx.titleColor || _ctx.color })
|
|
54
42
|
},
|
|
@@ -64,29 +52,10 @@ function __render__(_ctx, _cache) {
|
|
|
64
52
|
{
|
|
65
53
|
class: _normalizeClass(_ctx.n("title-hint"))
|
|
66
54
|
},
|
|
67
|
-
_toDisplayString(
|
|
55
|
+
_toDisplayString(_ctx.titleHint),
|
|
68
56
|
3
|
|
69
57
|
/* TEXT, CLASS */
|
|
70
|
-
)
|
|
71
|
-
_ctx.type !== "year" ? (_openBlock(), _createElementBlock(
|
|
72
|
-
"div",
|
|
73
|
-
{
|
|
74
|
-
key: 0,
|
|
75
|
-
class: _normalizeClass(_ctx.classes(_ctx.n("title-year"), [_ctx.isYearPanel, _ctx.n("title-year--active")])),
|
|
76
|
-
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.clickEl("year"))
|
|
77
|
-
},
|
|
78
|
-
[
|
|
79
|
-
_renderSlot(_ctx.$slots, "year", { year: _ctx.displayYear }, () => [
|
|
80
|
-
_createTextVNode(
|
|
81
|
-
_toDisplayString(_ctx.displayYear),
|
|
82
|
-
1
|
|
83
|
-
/* TEXT */
|
|
84
|
-
)
|
|
85
|
-
])
|
|
86
|
-
],
|
|
87
|
-
2
|
|
88
|
-
/* CLASS */
|
|
89
|
-
)) : _createCommentVNode("v-if", true)
|
|
58
|
+
)
|
|
90
59
|
],
|
|
91
60
|
2
|
|
92
61
|
/* CLASS */
|
|
@@ -97,104 +66,104 @@ function __render__(_ctx, _cache) {
|
|
|
97
66
|
class: _normalizeClass(
|
|
98
67
|
_ctx.classes(
|
|
99
68
|
_ctx.n("title-date"),
|
|
100
|
-
[!_ctx.
|
|
69
|
+
[!_ctx.showYearPanel || _ctx.type === _ctx.DatePickerTypes.Year, _ctx.n("title-date--active")],
|
|
101
70
|
[_ctx.range, _ctx.n("title-date--range")]
|
|
102
71
|
)
|
|
103
72
|
),
|
|
104
|
-
onClick: _cache[
|
|
73
|
+
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.switchPanel(_ctx.DatePickerTypes.Date))
|
|
105
74
|
},
|
|
106
75
|
[
|
|
107
76
|
_createVNode(_Transition, {
|
|
108
77
|
name: _ctx.multiple ? "" : `${_ctx.n()}${_ctx.reverse ? "-reverse" : ""}-translatey`
|
|
109
78
|
}, {
|
|
110
79
|
default: _withCtx(() => [
|
|
111
|
-
_ctx.type ===
|
|
112
|
-
key: `${_ctx.
|
|
80
|
+
_ctx.type === _ctx.DatePickerTypes.Year ? (_openBlock(), _createElementBlock("div", {
|
|
81
|
+
key: `${_ctx.selectionState.selectedYear}`
|
|
113
82
|
}, [
|
|
114
83
|
_ctx.range ? _renderSlot(_ctx.$slots, "range", {
|
|
115
84
|
key: 0,
|
|
116
|
-
choose: _ctx.
|
|
85
|
+
choose: _ctx.selectionState.selectedRangeYears
|
|
117
86
|
}, () => [
|
|
118
87
|
_createTextVNode(
|
|
119
|
-
_toDisplayString(_ctx.
|
|
88
|
+
_toDisplayString(_ctx.yearTitle),
|
|
120
89
|
1
|
|
121
90
|
/* TEXT */
|
|
122
91
|
)
|
|
123
92
|
]) : _ctx.multiple ? _renderSlot(_ctx.$slots, "multiple", {
|
|
124
93
|
key: 1,
|
|
125
|
-
choose: _ctx.
|
|
94
|
+
choose: _ctx.selectionState.selectedYears
|
|
126
95
|
}, () => [
|
|
127
96
|
_createTextVNode(
|
|
128
|
-
_toDisplayString(_ctx.
|
|
97
|
+
_toDisplayString(_ctx.yearTitle),
|
|
129
98
|
1
|
|
130
99
|
/* TEXT */
|
|
131
100
|
)
|
|
132
101
|
]) : _renderSlot(_ctx.$slots, "year", {
|
|
133
102
|
key: 2,
|
|
134
|
-
year: _ctx.
|
|
103
|
+
year: _ctx.selectionState.selectedYear
|
|
135
104
|
}, () => [
|
|
136
105
|
_createTextVNode(
|
|
137
|
-
_toDisplayString(_ctx.
|
|
106
|
+
_toDisplayString(_ctx.yearTitle),
|
|
138
107
|
1
|
|
139
108
|
/* TEXT */
|
|
140
109
|
)
|
|
141
110
|
])
|
|
142
|
-
])) : _ctx.type ===
|
|
143
|
-
key: `${_ctx.
|
|
111
|
+
])) : _ctx.type === _ctx.DatePickerTypes.Month ? (_openBlock(), _createElementBlock("div", {
|
|
112
|
+
key: `${_ctx.selectionState.selectedYear}${_ctx.selectionState.selectedMonth}`
|
|
144
113
|
}, [
|
|
145
114
|
_ctx.range ? _renderSlot(_ctx.$slots, "range", {
|
|
146
115
|
key: 0,
|
|
147
|
-
choose: _ctx.
|
|
116
|
+
choose: _ctx.selectionState.selectedRangeMonths
|
|
148
117
|
}, () => [
|
|
149
118
|
_createTextVNode(
|
|
150
|
-
_toDisplayString(_ctx.
|
|
119
|
+
_toDisplayString(_ctx.monthTitle),
|
|
151
120
|
1
|
|
152
121
|
/* TEXT */
|
|
153
122
|
)
|
|
154
123
|
]) : _ctx.multiple ? _renderSlot(_ctx.$slots, "multiple", {
|
|
155
124
|
key: 1,
|
|
156
|
-
choose: _ctx.
|
|
125
|
+
choose: _ctx.selectionState.selectedMonths
|
|
157
126
|
}, () => [
|
|
158
127
|
_createTextVNode(
|
|
159
|
-
_toDisplayString(_ctx.
|
|
128
|
+
_toDisplayString(_ctx.monthTitle),
|
|
160
129
|
1
|
|
161
130
|
/* TEXT */
|
|
162
131
|
)
|
|
163
132
|
]) : _renderSlot(_ctx.$slots, "month", {
|
|
164
133
|
key: 2,
|
|
165
|
-
month: _ctx.
|
|
166
|
-
year: _ctx.
|
|
134
|
+
month: _ctx.selectionState.selectedMonth,
|
|
135
|
+
year: _ctx.selectionState.selectedYear
|
|
167
136
|
}, () => [
|
|
168
137
|
_createTextVNode(
|
|
169
|
-
_toDisplayString(_ctx.
|
|
138
|
+
_toDisplayString(_ctx.monthTitle),
|
|
170
139
|
1
|
|
171
140
|
/* TEXT */
|
|
172
141
|
)
|
|
173
142
|
])
|
|
174
143
|
])) : (_openBlock(), _createElementBlock("div", {
|
|
175
|
-
key: `${_ctx.
|
|
144
|
+
key: `${_ctx.selectionState.selectedYear}${_ctx.selectionState.selectedMonth}${_ctx.selectionState.selectedDay}`
|
|
176
145
|
}, [
|
|
177
146
|
_ctx.range ? _renderSlot(_ctx.$slots, "range", {
|
|
178
147
|
key: 0,
|
|
179
|
-
choose: _ctx.
|
|
148
|
+
choose: _ctx.formattedRangeDays
|
|
180
149
|
}, () => [
|
|
181
150
|
_createTextVNode(
|
|
182
|
-
_toDisplayString(_ctx.
|
|
151
|
+
_toDisplayString(_ctx.dateTitle),
|
|
183
152
|
1
|
|
184
153
|
/* TEXT */
|
|
185
154
|
)
|
|
186
155
|
]) : _ctx.multiple ? _renderSlot(_ctx.$slots, "multiple", {
|
|
187
156
|
key: 1,
|
|
188
|
-
choose: _ctx.
|
|
157
|
+
choose: _ctx.selectionState.selectedDays
|
|
189
158
|
}, () => [
|
|
190
159
|
_createTextVNode(
|
|
191
|
-
_toDisplayString(_ctx.
|
|
160
|
+
_toDisplayString(_ctx.dateTitle),
|
|
192
161
|
1
|
|
193
162
|
/* TEXT */
|
|
194
163
|
)
|
|
195
|
-
]) : _renderSlot(_ctx.$slots, "date", _normalizeProps(_mergeProps({ key: 2 }, _ctx.
|
|
164
|
+
]) : _renderSlot(_ctx.$slots, "date", _normalizeProps(_mergeProps({ key: 2 }, _ctx.dateSlotProps)), () => [
|
|
196
165
|
_createTextVNode(
|
|
197
|
-
_toDisplayString(_ctx.
|
|
166
|
+
_toDisplayString(_ctx.dateTitle),
|
|
198
167
|
1
|
|
199
168
|
/* TEXT */
|
|
200
169
|
)
|
|
@@ -211,61 +180,73 @@ function __render__(_ctx, _cache) {
|
|
|
211
180
|
],
|
|
212
181
|
6
|
|
213
182
|
/* CLASS, STYLE */
|
|
214
|
-
),
|
|
183
|
+
)) : _createCommentVNode("v-if", true),
|
|
215
184
|
_createElementVNode(
|
|
216
185
|
"div",
|
|
217
186
|
{
|
|
218
|
-
class: _normalizeClass(_ctx.n("body"))
|
|
219
|
-
onTouchstart: _cache[2] || (_cache[2] = (...args) => _ctx.handleTouchstart && _ctx.handleTouchstart(...args)),
|
|
220
|
-
onTouchmove: _cache[3] || (_cache[3] = (...args) => _ctx.handleTouchmove && _ctx.handleTouchmove(...args)),
|
|
221
|
-
onTouchend: _cache[4] || (_cache[4] = (...args) => _ctx.handleTouchend && _ctx.handleTouchend(...args))
|
|
187
|
+
class: _normalizeClass(_ctx.n("body"))
|
|
222
188
|
},
|
|
223
189
|
[
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
190
|
+
_ctx.panelType ? (_openBlock(), _createBlock(_component_panel_header, {
|
|
191
|
+
key: 0,
|
|
192
|
+
type: _ctx.headerType,
|
|
193
|
+
date: _ctx.headerPreview,
|
|
194
|
+
"show-panel-toggle": _ctx.type === _ctx.DatePickerTypes.Date && _ctx.panelType !== _ctx.DatePickerTypes.Date,
|
|
195
|
+
onOpenDatePanel: _cache[1] || (_cache[1] = ($event) => _ctx.switchPanel(_ctx.DatePickerTypes.Date)),
|
|
196
|
+
onOpenYearPanel: _cache[2] || (_cache[2] = ($event) => _ctx.switchPanel(_ctx.DatePickerTypes.Year)),
|
|
197
|
+
onOpenMonthPanel: _cache[3] || (_cache[3] = ($event) => _ctx.switchPanel(_ctx.DatePickerTypes.Month)),
|
|
198
|
+
onShiftYearPreview: _ctx.shiftDatePanelYearPreview,
|
|
199
|
+
onShiftPreview: _ctx.shiftCurrentPanelPreview
|
|
200
|
+
}, null, 8, ["type", "date", "show-panel-toggle", "onShiftYearPreview", "onShiftPreview"])) : _createCommentVNode("v-if", true),
|
|
201
|
+
_createElementVNode(
|
|
202
|
+
"div",
|
|
203
|
+
{
|
|
204
|
+
class: _normalizeClass(_ctx.n("panel"))
|
|
205
|
+
},
|
|
206
|
+
[
|
|
207
|
+
_createVNode(_Transition, {
|
|
208
|
+
name: `${_ctx.n()}-panel-fade`
|
|
209
|
+
}, {
|
|
210
|
+
default: _withCtx(() => [
|
|
211
|
+
_ctx.panelType === _ctx.DatePickerTypes.Year ? (_openBlock(), _createBlock(_component_year_picker_panel, {
|
|
212
|
+
key: 0,
|
|
213
|
+
ref: "yearPanelEl",
|
|
214
|
+
"panel-props": _ctx.panelProps,
|
|
215
|
+
selection: _ctx.selectionState,
|
|
216
|
+
preview: _ctx.previewYear,
|
|
217
|
+
onChooseYear: _ctx.selectYearFromPanel
|
|
218
|
+
}, null, 8, ["panel-props", "selection", "preview", "onChooseYear"])) : _ctx.panelType === _ctx.DatePickerTypes.Month ? (_openBlock(), _createBlock(_component_month_picker_panel, {
|
|
219
|
+
key: 1,
|
|
220
|
+
ref: "monthPanelEl",
|
|
221
|
+
selection: _ctx.selectionState,
|
|
222
|
+
preview: _ctx.previewState,
|
|
223
|
+
"panel-props": _ctx.panelProps,
|
|
224
|
+
onChooseMonth: _ctx.selectMonthFromPanel
|
|
225
|
+
}, null, 8, ["selection", "preview", "panel-props", "onChooseMonth"])) : _ctx.panelType === _ctx.DatePickerTypes.Date ? (_openBlock(), _createBlock(_component_day_picker_panel, {
|
|
226
|
+
key: 2,
|
|
227
|
+
ref: "dayPanelEl",
|
|
228
|
+
current: _ctx.currentDate,
|
|
229
|
+
selection: _ctx.selectionState,
|
|
230
|
+
preview: _ctx.previewState,
|
|
231
|
+
"panel-props": _ctx.panelProps,
|
|
232
|
+
onChooseDay: _ctx.selectDayFromPanel
|
|
233
|
+
}, null, 8, ["current", "selection", "preview", "panel-props", "onChooseDay"])) : _createCommentVNode("v-if", true)
|
|
234
|
+
]),
|
|
235
|
+
_: 1
|
|
236
|
+
/* STABLE */
|
|
237
|
+
}, 8, ["name"])
|
|
238
|
+
],
|
|
239
|
+
2
|
|
240
|
+
/* CLASS */
|
|
241
|
+
)
|
|
261
242
|
],
|
|
262
|
-
|
|
263
|
-
/* CLASS
|
|
243
|
+
2
|
|
244
|
+
/* CLASS */
|
|
264
245
|
),
|
|
265
246
|
_ctx.$slots.actions ? (_openBlock(), _createElementBlock(
|
|
266
247
|
"div",
|
|
267
248
|
{
|
|
268
|
-
key:
|
|
249
|
+
key: 1,
|
|
269
250
|
class: _normalizeClass(_ctx.n("actions"))
|
|
270
251
|
},
|
|
271
252
|
[
|
|
@@ -275,8 +256,8 @@ function __render__(_ctx, _cache) {
|
|
|
275
256
|
/* CLASS */
|
|
276
257
|
)) : _createCommentVNode("v-if", true)
|
|
277
258
|
],
|
|
278
|
-
|
|
279
|
-
/* CLASS */
|
|
259
|
+
34
|
|
260
|
+
/* CLASS, NEED_HYDRATION */
|
|
280
261
|
);
|
|
281
262
|
}
|
|
282
263
|
const __sfc__ = defineComponent({
|
|
@@ -284,33 +265,37 @@ const __sfc__ = defineComponent({
|
|
|
284
265
|
components: {
|
|
285
266
|
MonthPickerPanel,
|
|
286
267
|
YearPickerPanel,
|
|
287
|
-
DayPickerPanel
|
|
268
|
+
DayPickerPanel,
|
|
269
|
+
PanelHeader
|
|
288
270
|
},
|
|
289
271
|
props,
|
|
290
272
|
setup(props2) {
|
|
291
273
|
const { t: pt } = injectLocaleProvider();
|
|
292
|
-
const currentDate = dayjs().format(
|
|
274
|
+
const currentDate = dayjs().format(DatePickerFormats.Day);
|
|
293
275
|
const [currentYear, currentMonth] = currentDate.split("-");
|
|
294
|
-
const
|
|
295
|
-
const
|
|
296
|
-
const
|
|
297
|
-
const
|
|
298
|
-
const
|
|
299
|
-
const
|
|
300
|
-
const chooseDay = ref();
|
|
301
|
-
const previewMonth = ref(monthDes);
|
|
276
|
+
const currentMonthValue = MonthList.find((month) => month === currentMonth);
|
|
277
|
+
const showYearPanel = ref(false);
|
|
278
|
+
const showMonthPanel = ref(false);
|
|
279
|
+
const rangeSelectionComplete = ref(true);
|
|
280
|
+
const rangeSelecting = computed(() => props2.range && !rangeSelectionComplete.value);
|
|
281
|
+
const previewMonth = ref(currentMonthValue);
|
|
302
282
|
const previewYear = ref(currentYear);
|
|
303
283
|
const reverse = ref(false);
|
|
304
|
-
const chooseYears = ref([]);
|
|
305
|
-
const chooseMonths = ref([]);
|
|
306
|
-
const chooseDays = ref([]);
|
|
307
|
-
const chooseRangeYear = ref([]);
|
|
308
|
-
const chooseRangeMonth = ref([]);
|
|
309
|
-
const chooseRangeDay = ref([]);
|
|
310
284
|
const yearPanelEl = ref(null);
|
|
311
285
|
const monthPanelEl = ref(null);
|
|
312
286
|
const dayPanelEl = ref(null);
|
|
313
|
-
const
|
|
287
|
+
const selectionState = reactive({
|
|
288
|
+
selectedMonth: void 0,
|
|
289
|
+
selectedYear: void 0,
|
|
290
|
+
selectedDay: void 0,
|
|
291
|
+
selectedYears: [],
|
|
292
|
+
selectedMonths: [],
|
|
293
|
+
selectedDays: [],
|
|
294
|
+
selectedRangeYears: [],
|
|
295
|
+
selectedRangeMonths: [],
|
|
296
|
+
selectedRangeDays: []
|
|
297
|
+
});
|
|
298
|
+
const panelProps = computed(() => ({
|
|
314
299
|
allowedDates: props2.allowedDates,
|
|
315
300
|
type: props2.type,
|
|
316
301
|
color: props2.color,
|
|
@@ -322,289 +307,343 @@ const __sfc__ = defineComponent({
|
|
|
322
307
|
range: props2.range,
|
|
323
308
|
buttonElevation: props2.buttonElevation
|
|
324
309
|
}));
|
|
325
|
-
const
|
|
326
|
-
chooseMonth: chooseMonth.value,
|
|
327
|
-
chooseYear: chooseYear.value,
|
|
328
|
-
chooseDay: chooseDay.value,
|
|
329
|
-
chooseYears: chooseYears.value,
|
|
330
|
-
chooseMonths: chooseMonths.value,
|
|
331
|
-
chooseDays: chooseDays.value,
|
|
332
|
-
chooseRangeYear: chooseRangeYear.value,
|
|
333
|
-
chooseRangeMonth: chooseRangeMonth.value,
|
|
334
|
-
chooseRangeDay: chooseRangeDay.value
|
|
335
|
-
}));
|
|
336
|
-
const getPreview = computed(() => ({
|
|
310
|
+
const previewState = computed(() => ({
|
|
337
311
|
previewMonth: previewMonth.value,
|
|
338
312
|
previewYear: previewYear.value
|
|
339
313
|
}));
|
|
340
|
-
const
|
|
341
|
-
|
|
314
|
+
const panelType = computed(() => {
|
|
315
|
+
if (props2.type === DatePickerTypes.Year || showYearPanel.value) {
|
|
316
|
+
return DatePickerTypes.Year;
|
|
317
|
+
}
|
|
318
|
+
if (props2.type === DatePickerTypes.Month || showMonthPanel.value) {
|
|
319
|
+
return DatePickerTypes.Month;
|
|
320
|
+
}
|
|
321
|
+
if (props2.type === DatePickerTypes.Date) {
|
|
322
|
+
return DatePickerTypes.Date;
|
|
323
|
+
}
|
|
324
|
+
return void 0;
|
|
325
|
+
});
|
|
326
|
+
const headerType = computed(
|
|
327
|
+
() => panelType.value === DatePickerTypes.Date ? DatePickerUnits.Day : panelType.value
|
|
328
|
+
);
|
|
329
|
+
const headerPreview = computed(
|
|
330
|
+
() => panelType.value === DatePickerTypes.Year ? {
|
|
331
|
+
previewYear: previewYear.value
|
|
332
|
+
} : previewState.value
|
|
333
|
+
);
|
|
334
|
+
const titleHint = computed(() => {
|
|
335
|
+
var _a;
|
|
336
|
+
return (_a = props2.hint) != null ? _a : getDefaultHint();
|
|
337
|
+
});
|
|
338
|
+
const yearTitle = computed(() => {
|
|
342
339
|
var _a;
|
|
343
340
|
const { multiple, range } = props2;
|
|
344
341
|
if (range) {
|
|
345
|
-
return
|
|
342
|
+
return selectionState.selectedRangeYears.length ? selectionState.selectedRangeYears.join(" ~ ") : "";
|
|
346
343
|
}
|
|
347
|
-
return multiple ? `${
|
|
344
|
+
return multiple ? `${selectionState.selectedYears.length}${(pt || t)("datePickerSelected")}` : (_a = selectionState.selectedYear) != null ? _a : "";
|
|
348
345
|
});
|
|
349
|
-
const
|
|
346
|
+
const monthTitle = computed(() => {
|
|
350
347
|
var _a, _b;
|
|
351
348
|
const { multiple, range } = props2;
|
|
352
349
|
if (range) {
|
|
353
|
-
return
|
|
350
|
+
return selectionState.selectedRangeMonths.length ? selectionState.selectedRangeMonths.join(" ~ ") : "";
|
|
354
351
|
}
|
|
355
352
|
let monthName = "";
|
|
356
|
-
if (
|
|
357
|
-
monthName = (_b = (_a = (pt || t)("datePickerMonthDict")) == null ? void 0 : _a[
|
|
353
|
+
if (selectionState.selectedMonth) {
|
|
354
|
+
monthName = (_b = (_a = (pt || t)("datePickerMonthDict")) == null ? void 0 : _a[selectionState.selectedMonth].name) != null ? _b : "";
|
|
358
355
|
}
|
|
359
|
-
return multiple ? `${
|
|
356
|
+
return multiple ? `${selectionState.selectedMonths.length}${(pt || t)("datePickerSelected")}` : monthName;
|
|
360
357
|
});
|
|
361
|
-
const
|
|
358
|
+
const dateTitle = computed(() => {
|
|
362
359
|
var _a, _b, _c, _d;
|
|
363
360
|
const { multiple, range } = props2;
|
|
364
361
|
if (range) {
|
|
365
|
-
const
|
|
366
|
-
|
|
362
|
+
const formattedDays = selectionState.selectedRangeDays.map(
|
|
363
|
+
(date) => dayjs(date).format(DatePickerFormats.DayPadded)
|
|
364
|
+
);
|
|
365
|
+
return formattedDays.length ? formattedDays.join(" ~ ") : "";
|
|
367
366
|
}
|
|
368
367
|
if (multiple) {
|
|
369
|
-
return `${
|
|
368
|
+
return `${selectionState.selectedDays.length}${(pt || t)("datePickerSelected")}`;
|
|
370
369
|
}
|
|
371
|
-
if (!
|
|
370
|
+
if (!selectionState.selectedYear || !selectionState.selectedMonth || !selectionState.selectedDay) {
|
|
372
371
|
return "";
|
|
373
372
|
}
|
|
374
|
-
const weekIndex = dayjs(
|
|
375
|
-
|
|
373
|
+
const weekIndex = dayjs(
|
|
374
|
+
`${selectionState.selectedYear}-${selectionState.selectedMonth}-${selectionState.selectedDay}`
|
|
375
|
+
).day();
|
|
376
|
+
const week = WeekHeader.find((value) => value === `${weekIndex}`);
|
|
376
377
|
const weekName = (_b = (_a = (pt || t)("datePickerWeekDict")) == null ? void 0 : _a[week].name) != null ? _b : "";
|
|
377
|
-
const monthName = (_d = (_c = (pt || t)("datePickerMonthDict")) == null ? void 0 : _c[
|
|
378
|
-
const showDay = padStart(
|
|
378
|
+
const monthName = (_d = (_c = (pt || t)("datePickerMonthDict")) == null ? void 0 : _c[selectionState.selectedMonth].name) != null ? _d : "";
|
|
379
|
+
const showDay = padStart(selectionState.selectedDay, 2, "0");
|
|
379
380
|
if ((pt || t)("lang") === "zh-CN") {
|
|
380
|
-
return `${
|
|
381
|
+
return `${selectionState.selectedMonth}-${showDay} ${weekName.slice(0, 3)}`;
|
|
381
382
|
}
|
|
382
|
-
return `${weekName.slice(0, 3)}, ${monthName.slice(0, 3)} ${
|
|
383
|
+
return `${weekName.slice(0, 3)}, ${monthName.slice(0, 3)} ${selectionState.selectedDay}`;
|
|
383
384
|
});
|
|
384
|
-
const
|
|
385
|
-
if (props2.type === "year" || isYearPanel.value) {
|
|
386
|
-
return "year";
|
|
387
|
-
}
|
|
388
|
-
if (props2.type === "month" || isMonthPanel.value) {
|
|
389
|
-
return "month";
|
|
390
|
-
}
|
|
391
|
-
if (props2.type === "date") {
|
|
392
|
-
return "date";
|
|
393
|
-
}
|
|
394
|
-
return "";
|
|
395
|
-
});
|
|
396
|
-
const isUntouchable = computed(() => !props2.touchable || !getPanelType.value);
|
|
397
|
-
const slotProps = computed(() => {
|
|
385
|
+
const dateSlotProps = computed(() => {
|
|
398
386
|
var _a, _b;
|
|
399
|
-
const weekIndex = dayjs(
|
|
400
|
-
|
|
387
|
+
const weekIndex = dayjs(
|
|
388
|
+
`${selectionState.selectedYear}-${selectionState.selectedMonth}-${selectionState.selectedDay}`
|
|
389
|
+
).day();
|
|
390
|
+
const day = selectionState.selectedDay ? padStart(selectionState.selectedDay, 2, "0") : "";
|
|
401
391
|
return {
|
|
402
392
|
week: `${weekIndex}`,
|
|
403
|
-
year: (_a =
|
|
404
|
-
month: (_b =
|
|
405
|
-
date
|
|
393
|
+
year: (_a = selectionState.selectedYear) != null ? _a : "",
|
|
394
|
+
month: (_b = selectionState.selectedMonth) != null ? _b : "",
|
|
395
|
+
date: day
|
|
406
396
|
};
|
|
407
397
|
});
|
|
408
|
-
const
|
|
409
|
-
() =>
|
|
398
|
+
const formattedRangeDays = computed(
|
|
399
|
+
() => selectionState.selectedRangeDays.map((date) => dayjs(date).format(DatePickerFormats.DayPadded))
|
|
410
400
|
);
|
|
411
|
-
const
|
|
412
|
-
const
|
|
413
|
-
let
|
|
414
|
-
let startY = 0;
|
|
415
|
-
let checkType = "";
|
|
416
|
-
let touchDirection;
|
|
401
|
+
const selectedYearInPreview = computed(() => selectionState.selectedYear === previewYear.value);
|
|
402
|
+
const selectedMonthInPreview = computed(() => selectionState.selectedMonth === previewMonth.value);
|
|
403
|
+
let shouldKeepPreviewOnModelValueChange = false;
|
|
417
404
|
watch(
|
|
418
405
|
() => props2.modelValue,
|
|
419
|
-
(
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
if (props2.range) {
|
|
424
|
-
if (!isArray(value)) {
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
rangeDone.value = value.length !== 1;
|
|
428
|
-
rangeInit(value, props2.type);
|
|
429
|
-
} else if (props2.multiple) {
|
|
430
|
-
if (!isArray(value)) {
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
multipleInit(value, props2.type);
|
|
434
|
-
} else {
|
|
435
|
-
dateInit(getSingleDate(value));
|
|
436
|
-
}
|
|
406
|
+
() => {
|
|
407
|
+
const syncPreview = !shouldKeepPreviewOnModelValueChange;
|
|
408
|
+
shouldKeepPreviewOnModelValueChange = false;
|
|
409
|
+
syncFromModelValue(syncPreview);
|
|
437
410
|
},
|
|
438
411
|
{ immediate: true }
|
|
439
412
|
);
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
if (type === "year") {
|
|
443
|
-
isYearPanel.value = true;
|
|
444
|
-
} else if (type === "month") {
|
|
445
|
-
isMonthPanel.value = true;
|
|
446
|
-
} else {
|
|
447
|
-
isYearPanel.value = false;
|
|
448
|
-
isMonthPanel.value = false;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
function handleTouchstart(event) {
|
|
452
|
-
if (isUntouchable.value) {
|
|
413
|
+
function syncFromModelValue(syncPreview = true) {
|
|
414
|
+
if (!checkValue()) {
|
|
453
415
|
return;
|
|
454
416
|
}
|
|
455
|
-
const {
|
|
456
|
-
|
|
457
|
-
|
|
417
|
+
const { modelValue, type: pickerType } = props2;
|
|
418
|
+
if (props2.range) {
|
|
419
|
+
if (!isArray(modelValue)) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
rangeSelectionComplete.value = modelValue.length !== 1;
|
|
423
|
+
syncRangeValue(modelValue, pickerType, syncPreview);
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
if (props2.multiple) {
|
|
427
|
+
if (!isArray(modelValue)) {
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
syncMultipleValue(modelValue, pickerType, syncPreview);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
syncSingleValue(modelValue, syncPreview);
|
|
434
|
+
}
|
|
435
|
+
function switchPanel(targetPanelType) {
|
|
436
|
+
if (targetPanelType === DatePickerTypes.Year) {
|
|
437
|
+
showYearPanel.value = true;
|
|
438
|
+
showMonthPanel.value = false;
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
if (targetPanelType === DatePickerTypes.Month) {
|
|
442
|
+
showYearPanel.value = false;
|
|
443
|
+
showMonthPanel.value = true;
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
showYearPanel.value = false;
|
|
447
|
+
showMonthPanel.value = false;
|
|
448
|
+
}
|
|
449
|
+
function getDefaultHint() {
|
|
450
|
+
if (props2.type === DatePickerTypes.Year) {
|
|
451
|
+
return (pt || t)("datePickerYearHint");
|
|
452
|
+
}
|
|
453
|
+
if (props2.type === DatePickerTypes.Month) {
|
|
454
|
+
return (pt || t)("datePickerMonthHint");
|
|
455
|
+
}
|
|
456
|
+
return (pt || t)("datePickerHint");
|
|
458
457
|
}
|
|
459
|
-
function
|
|
460
|
-
return
|
|
458
|
+
function getActivePanelRef() {
|
|
459
|
+
return panelType.value === DatePickerTypes.Year ? yearPanelEl : panelType.value === DatePickerTypes.Month ? monthPanelEl : dayPanelEl;
|
|
460
|
+
}
|
|
461
|
+
function shiftCurrentPanelPreview(direction) {
|
|
462
|
+
getActivePanelRef().value.shiftPreview(direction);
|
|
463
|
+
if (panelType.value === DatePickerTypes.Date) {
|
|
464
|
+
shiftPreview(DatePickerUnits.Month, direction);
|
|
465
|
+
} else if (panelType.value === DatePickerTypes.Month) {
|
|
466
|
+
shiftPreview(DatePickerUnits.Year, direction);
|
|
467
|
+
}
|
|
461
468
|
}
|
|
462
|
-
function
|
|
463
|
-
|
|
469
|
+
function shiftDatePanelYearPreview(direction) {
|
|
470
|
+
dayPanelEl.value.shiftYearPreview(direction);
|
|
471
|
+
shiftPreview(DatePickerUnits.Year, direction);
|
|
472
|
+
}
|
|
473
|
+
function getFormatByType(pickerType) {
|
|
474
|
+
return pickerType === DatePickerTypes.Year ? DatePickerFormats.Year : pickerType === DatePickerTypes.Month ? DatePickerFormats.Month : DatePickerFormats.Day;
|
|
475
|
+
}
|
|
476
|
+
function getRangeValuesByType(pickerType) {
|
|
477
|
+
return pickerType === DatePickerTypes.Year ? selectionState.selectedRangeYears : pickerType === DatePickerTypes.Month ? selectionState.selectedRangeMonths : selectionState.selectedRangeDays;
|
|
478
|
+
}
|
|
479
|
+
function setRangeValuesByType(pickerType, rangeValues) {
|
|
480
|
+
if (pickerType === DatePickerTypes.Year) {
|
|
481
|
+
selectionState.selectedRangeYears = rangeValues;
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
if (pickerType === DatePickerTypes.Month) {
|
|
485
|
+
selectionState.selectedRangeMonths = rangeValues;
|
|
464
486
|
return;
|
|
465
487
|
}
|
|
466
|
-
|
|
467
|
-
const x = clientX - startX;
|
|
468
|
-
const y = clientY - startY;
|
|
469
|
-
touchDirection = getDirection(Math.abs(x), Math.abs(y));
|
|
470
|
-
checkType = x > 0 ? "prev" : "next";
|
|
488
|
+
selectionState.selectedRangeDays = rangeValues;
|
|
471
489
|
}
|
|
472
|
-
function
|
|
473
|
-
return
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
const
|
|
498
|
-
const
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
490
|
+
function getMultipleValuesByType(pickerType) {
|
|
491
|
+
return pickerType === DatePickerTypes.Year ? selectionState.selectedYears : pickerType === DatePickerTypes.Month ? selectionState.selectedMonths : selectionState.selectedDays;
|
|
492
|
+
}
|
|
493
|
+
function setMultipleValuesByType(pickerType, multipleValues) {
|
|
494
|
+
if (pickerType === DatePickerTypes.Year) {
|
|
495
|
+
selectionState.selectedYears = multipleValues;
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
if (pickerType === DatePickerTypes.Month) {
|
|
499
|
+
selectionState.selectedMonths = multipleValues;
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
selectionState.selectedDays = multipleValues;
|
|
503
|
+
}
|
|
504
|
+
function emitModelValueChange(modelValue) {
|
|
505
|
+
call(props2["onUpdate:modelValue"], modelValue);
|
|
506
|
+
call(props2.onChange, modelValue);
|
|
507
|
+
}
|
|
508
|
+
function getPreviewDayOfMonth() {
|
|
509
|
+
return props2.type === DatePickerTypes.Date && selectionState.selectedDay ? toNumber(selectionState.selectedDay) : void 0;
|
|
510
|
+
}
|
|
511
|
+
function emitPreview() {
|
|
512
|
+
call(props2.onPreview, toNumber(previewYear.value), toNumber(previewMonth.value), getPreviewDayOfMonth());
|
|
513
|
+
}
|
|
514
|
+
function updateRange(selectedValue, pickerType) {
|
|
515
|
+
const selectedRangeValues = getRangeValuesByType(pickerType);
|
|
516
|
+
const nextRangeValues = rangeSelectionComplete.value ? [selectedValue, selectedValue] : [selectedRangeValues[0], selectedValue];
|
|
517
|
+
setRangeValuesByType(pickerType, nextRangeValues);
|
|
518
|
+
rangeSelectionComplete.value = !rangeSelectionComplete.value;
|
|
519
|
+
if (!rangeSelectionComplete.value) {
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
const shouldSwapRange = dayjs(nextRangeValues[0]).isAfter(nextRangeValues[1]);
|
|
523
|
+
const nextModelValue = shouldSwapRange ? [nextRangeValues[1], nextRangeValues[0]] : [...nextRangeValues];
|
|
524
|
+
markPreviewKeep();
|
|
525
|
+
emitModelValueChange(nextModelValue);
|
|
526
|
+
}
|
|
527
|
+
function updateMultiple(selectedValue, pickerType) {
|
|
528
|
+
const selectedMultipleValues = getMultipleValuesByType(pickerType);
|
|
529
|
+
const valueFormat = pickerType === DatePickerTypes.Year ? DatePickerFormats.Year : pickerType === DatePickerTypes.Month ? DatePickerFormats.Month : DatePickerFormats.DayPadded;
|
|
530
|
+
const nextMultipleValues = selectedMultipleValues.map((date) => dayjs(date).format(valueFormat));
|
|
531
|
+
const index = nextMultipleValues.findIndex((multipleValue) => multipleValue === selectedValue);
|
|
532
|
+
const alreadySelected = index !== -1;
|
|
533
|
+
if (alreadySelected) {
|
|
534
|
+
nextMultipleValues.splice(index, 1);
|
|
535
|
+
}
|
|
536
|
+
if (!alreadySelected) {
|
|
537
|
+
nextMultipleValues.push(selectedValue);
|
|
538
|
+
}
|
|
539
|
+
markPreviewKeep();
|
|
540
|
+
emitModelValueChange(nextMultipleValues);
|
|
541
|
+
}
|
|
542
|
+
function selectValue(selectedValue, pickerType) {
|
|
543
|
+
if (props2.range) {
|
|
544
|
+
updateRange(selectedValue, pickerType);
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
if (props2.multiple) {
|
|
548
|
+
updateMultiple(selectedValue, pickerType);
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
markPreviewKeep();
|
|
552
|
+
emitModelValueChange(selectedValue);
|
|
553
|
+
}
|
|
554
|
+
function isSelectableDate(dateValue, unit, checkAllowedDates = true) {
|
|
555
|
+
const { min, max, allowedDates } = props2;
|
|
556
|
+
const isBeforeMax = max ? dayjs(dateValue).isSameOrBefore(dayjs(max), unit) : true;
|
|
557
|
+
const isAfterMin = min ? dayjs(dateValue).isSameOrAfter(dayjs(min), unit) : true;
|
|
558
|
+
const isAllowed = checkAllowedDates && allowedDates ? allowedDates(dateValue) : true;
|
|
559
|
+
return isBeforeMax && isAfterMin && isAllowed;
|
|
560
|
+
}
|
|
561
|
+
function getReverse(unit, candidate) {
|
|
562
|
+
if (!selectionState.selectedYear || !selectionState.selectedMonth) {
|
|
509
563
|
return false;
|
|
510
564
|
}
|
|
511
|
-
if (!
|
|
512
|
-
return
|
|
565
|
+
if (!selectedYearInPreview.value) {
|
|
566
|
+
return selectionState.selectedYear > previewYear.value;
|
|
513
567
|
}
|
|
514
|
-
if (
|
|
515
|
-
return
|
|
568
|
+
if (unit === DatePickerUnits.Year) {
|
|
569
|
+
return candidate < toNumber(selectionState.selectedYear);
|
|
516
570
|
}
|
|
517
|
-
if (
|
|
518
|
-
return
|
|
571
|
+
if (unit === DatePickerUnits.Month) {
|
|
572
|
+
return candidate < selectionState.selectedMonth;
|
|
519
573
|
}
|
|
520
|
-
return
|
|
574
|
+
return selectedMonthInPreview.value ? candidate < toNumber(selectionState.selectedDay) : selectionState.selectedMonth > previewMonth.value;
|
|
521
575
|
}
|
|
522
|
-
function
|
|
523
|
-
const { readonly
|
|
524
|
-
if (
|
|
576
|
+
function selectDayFromPanel(day, monthOffset = 0) {
|
|
577
|
+
const { readonly } = props2;
|
|
578
|
+
if (readonly) {
|
|
525
579
|
return;
|
|
526
580
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
} else {
|
|
535
|
-
call(updateModelValue, formatDate);
|
|
536
|
-
call(onChange, formatDate);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
function getChooseMonth(month) {
|
|
540
|
-
const { type, readonly, range, multiple, onChange, onPreview, "onUpdate:modelValue": updateModelValue } = props2;
|
|
541
|
-
reverse.value = getReverse("month", month);
|
|
542
|
-
if (type === "month" && !readonly) {
|
|
543
|
-
const date = `${previewYear.value}-${month}`;
|
|
544
|
-
if (range) {
|
|
545
|
-
updateRange(date, "month");
|
|
546
|
-
} else if (multiple) {
|
|
547
|
-
updateMultiple(date, "month");
|
|
548
|
-
} else {
|
|
549
|
-
call(updateModelValue, date);
|
|
550
|
-
call(onChange, date);
|
|
551
|
-
}
|
|
552
|
-
} else {
|
|
553
|
-
previewMonth.value = month;
|
|
554
|
-
call(
|
|
555
|
-
onPreview,
|
|
556
|
-
toNumber(previewYear.value),
|
|
557
|
-
toNumber(previewMonth.value),
|
|
558
|
-
type === "date" ? toNumber(chooseDay.value) : void 0
|
|
559
|
-
);
|
|
581
|
+
const targetMonthDayjsObject = dayjs(`${previewYear.value}-${previewMonth.value}-01`).add(
|
|
582
|
+
monthOffset,
|
|
583
|
+
DatePickerUnits.Month
|
|
584
|
+
);
|
|
585
|
+
const dayValue = `${targetMonthDayjsObject.format(DatePickerFormats.Month)}-${day}`;
|
|
586
|
+
if (!isSelectableDate(dayValue, DatePickerUnits.Day)) {
|
|
587
|
+
return;
|
|
560
588
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
if (type === "year" && !readonly) {
|
|
567
|
-
if (range) {
|
|
568
|
-
updateRange(`${year}`, "year");
|
|
569
|
-
} else if (multiple) {
|
|
570
|
-
updateMultiple(`${year}`, "year");
|
|
571
|
-
} else {
|
|
572
|
-
call(updateModelValue, `${year}`);
|
|
573
|
-
call(onChange, `${year}`);
|
|
574
|
-
}
|
|
575
|
-
} else {
|
|
576
|
-
previewYear.value = `${year}`;
|
|
577
|
-
call(
|
|
578
|
-
onPreview,
|
|
579
|
-
toNumber(previewYear.value),
|
|
580
|
-
toNumber(previewMonth.value),
|
|
581
|
-
type === "date" ? toNumber(chooseDay.value) : void 0
|
|
582
|
-
);
|
|
589
|
+
reverse.value = monthOffset !== 0 ? monthOffset < 0 : getReverse(DatePickerUnits.Day, day);
|
|
590
|
+
if (monthOffset !== 0) {
|
|
591
|
+
previewYear.value = targetMonthDayjsObject.format(DatePickerFormats.Year);
|
|
592
|
+
previewMonth.value = targetMonthDayjsObject.format(DatePickerFormats.Month).split("-")[1];
|
|
593
|
+
emitPreview();
|
|
583
594
|
}
|
|
584
|
-
|
|
585
|
-
}
|
|
586
|
-
function
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
let checkIndex = toNumber(previewMonth.value) + changeValue;
|
|
592
|
-
if (checkIndex < 1) {
|
|
593
|
-
previewYear.value = `${toNumber(previewYear.value) - 1}`;
|
|
594
|
-
checkIndex = 12;
|
|
595
|
-
}
|
|
596
|
-
if (checkIndex > 12) {
|
|
597
|
-
previewYear.value = `${toNumber(previewYear.value) + 1}`;
|
|
598
|
-
checkIndex = 1;
|
|
599
|
-
}
|
|
600
|
-
previewMonth.value = MONTH_LIST.find((month) => toNumber(month) === checkIndex);
|
|
595
|
+
selectValue(dayjs(dayValue).format(DatePickerFormats.DayPadded), DatePickerTypes.Date);
|
|
596
|
+
}
|
|
597
|
+
function selectMonthFromPanel(month) {
|
|
598
|
+
const { type: pickerType, readonly } = props2;
|
|
599
|
+
const monthValue = `${previewYear.value}-${month}`;
|
|
600
|
+
if (readonly || !isSelectableDate(monthValue, DatePickerUnits.Month, pickerType === DatePickerTypes.Month)) {
|
|
601
|
+
return;
|
|
601
602
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
603
|
+
reverse.value = getReverse(DatePickerUnits.Month, month);
|
|
604
|
+
if (pickerType === DatePickerTypes.Month) {
|
|
605
|
+
selectValue(monthValue, DatePickerTypes.Month);
|
|
606
|
+
showMonthPanel.value = false;
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
previewMonth.value = month;
|
|
610
|
+
emitPreview();
|
|
611
|
+
showMonthPanel.value = false;
|
|
612
|
+
}
|
|
613
|
+
function selectYearFromPanel(year) {
|
|
614
|
+
const { type: pickerType, readonly } = props2;
|
|
615
|
+
const yearValue = `${year}`;
|
|
616
|
+
if (readonly || !isSelectableDate(yearValue, DatePickerUnits.Year, pickerType === DatePickerTypes.Year)) {
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
reverse.value = getReverse(DatePickerUnits.Year, year);
|
|
620
|
+
if (pickerType === DatePickerTypes.Year) {
|
|
621
|
+
selectValue(yearValue, DatePickerTypes.Year);
|
|
622
|
+
showYearPanel.value = false;
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
previewYear.value = `${year}`;
|
|
626
|
+
emitPreview();
|
|
627
|
+
showYearPanel.value = false;
|
|
628
|
+
}
|
|
629
|
+
function shiftPreview(unit, direction) {
|
|
630
|
+
const step = direction === ShiftDirections.Prev ? -1 : 1;
|
|
631
|
+
if (unit === DatePickerUnits.Year) {
|
|
632
|
+
previewYear.value = `${toNumber(previewYear.value) + step}`;
|
|
633
|
+
emitPreview();
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
let nextMonthNumber = toNumber(previewMonth.value) + step;
|
|
637
|
+
if (nextMonthNumber < 1) {
|
|
638
|
+
previewYear.value = `${toNumber(previewYear.value) - 1}`;
|
|
639
|
+
nextMonthNumber = 12;
|
|
640
|
+
}
|
|
641
|
+
if (nextMonthNumber > 12) {
|
|
642
|
+
previewYear.value = `${toNumber(previewYear.value) + 1}`;
|
|
643
|
+
nextMonthNumber = 1;
|
|
644
|
+
}
|
|
645
|
+
previewMonth.value = MonthList.find((month) => toNumber(month) === nextMonthNumber);
|
|
646
|
+
emitPreview();
|
|
608
647
|
}
|
|
609
648
|
function checkValue() {
|
|
610
649
|
if ((props2.multiple || props2.range) && !isArray(props2.modelValue)) {
|
|
@@ -617,11 +656,11 @@ const __sfc__ = defineComponent({
|
|
|
617
656
|
}
|
|
618
657
|
return true;
|
|
619
658
|
}
|
|
620
|
-
function invalidFormatDate(
|
|
621
|
-
if (isArray(
|
|
659
|
+
function invalidFormatDate(formattedValue) {
|
|
660
|
+
if (isArray(formattedValue)) {
|
|
622
661
|
return false;
|
|
623
662
|
}
|
|
624
|
-
if (
|
|
663
|
+
if (formattedValue === "Invalid Date") {
|
|
625
664
|
error("DatePicker", '"modelValue" is an Invalid Date');
|
|
626
665
|
return true;
|
|
627
666
|
}
|
|
@@ -629,72 +668,104 @@ const __sfc__ = defineComponent({
|
|
|
629
668
|
}
|
|
630
669
|
function getFallbackDate() {
|
|
631
670
|
if (props2.fallbackViewDate) {
|
|
632
|
-
const
|
|
633
|
-
if (
|
|
671
|
+
const formattedFallbackDate = dayjs(props2.fallbackViewDate).format(DatePickerFormats.Day);
|
|
672
|
+
if (formattedFallbackDate !== "Invalid Date") {
|
|
634
673
|
return props2.fallbackViewDate;
|
|
635
674
|
}
|
|
636
675
|
}
|
|
637
|
-
return dayjs().format(
|
|
676
|
+
return dayjs().format(DatePickerFormats.Day);
|
|
638
677
|
}
|
|
639
|
-
function getSingleDate(
|
|
640
|
-
if (
|
|
641
|
-
return
|
|
678
|
+
function getSingleDate(modelValue) {
|
|
679
|
+
if (modelValue && !invalidFormatDate(dayjs(modelValue).format(DatePickerFormats.Day))) {
|
|
680
|
+
return modelValue;
|
|
642
681
|
}
|
|
643
682
|
return getFallbackDate();
|
|
644
683
|
}
|
|
645
|
-
function getFirstValidDate(
|
|
646
|
-
const
|
|
647
|
-
return
|
|
684
|
+
function getFirstValidDate(modelValues, pickerType) {
|
|
685
|
+
const valueFormat = getFormatByType(pickerType);
|
|
686
|
+
return modelValues.find((modelValue) => !invalidFormatDate(dayjs(modelValue).format(valueFormat)));
|
|
687
|
+
}
|
|
688
|
+
function markPreviewKeep() {
|
|
689
|
+
shouldKeepPreviewOnModelValueChange = props2.type === DatePickerTypes.Date || props2.range || props2.multiple;
|
|
648
690
|
}
|
|
649
|
-
function
|
|
691
|
+
function syncRangeValue(modelValues, pickerType, syncPreview = true) {
|
|
650
692
|
var _a;
|
|
651
|
-
const
|
|
652
|
-
const
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
693
|
+
const valueFormat = getFormatByType(pickerType);
|
|
694
|
+
const formattedValues = modelValues.map((modelValue) => dayjs(modelValue).format(valueFormat)).filter((formattedValue) => !invalidFormatDate(formattedValue)).slice(0, 2);
|
|
695
|
+
setRangeValuesByType(pickerType, formattedValues);
|
|
696
|
+
if (formattedValues.length === 2) {
|
|
697
|
+
const shouldSwapRange = dayjs(formattedValues[0]).isAfter(formattedValues[1]);
|
|
698
|
+
if (shouldSwapRange) {
|
|
699
|
+
setRangeValuesByType(pickerType, [formattedValues[1], formattedValues[0]]);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
if (syncPreview) {
|
|
703
|
+
syncPreviewValue((_a = getFirstValidDate(modelValues, pickerType)) != null ? _a : getFallbackDate());
|
|
658
704
|
}
|
|
659
|
-
previewInit((_a = getFirstValidDate(value, type)) != null ? _a : getFallbackDate());
|
|
660
705
|
}
|
|
661
|
-
function
|
|
706
|
+
function syncMultipleValue(modelValues, pickerType, syncPreview = true) {
|
|
662
707
|
var _a;
|
|
663
|
-
const
|
|
664
|
-
const
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
708
|
+
const valueFormat = getFormatByType(pickerType);
|
|
709
|
+
const formattedValues = uniq(modelValues.map((modelValue) => dayjs(modelValue).format(valueFormat)));
|
|
710
|
+
setMultipleValuesByType(
|
|
711
|
+
pickerType,
|
|
712
|
+
formattedValues.filter((formattedValue) => formattedValue !== "Invalid Date")
|
|
713
|
+
);
|
|
714
|
+
if (syncPreview) {
|
|
715
|
+
syncPreviewValue((_a = getFirstValidDate(modelValues, pickerType)) != null ? _a : getFallbackDate());
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
function syncSingleValue(modelValue, syncPreview = true) {
|
|
719
|
+
if (!modelValue) {
|
|
720
|
+
selectionState.selectedMonth = void 0;
|
|
721
|
+
selectionState.selectedYear = void 0;
|
|
722
|
+
selectionState.selectedDay = void 0;
|
|
723
|
+
if (syncPreview) {
|
|
724
|
+
syncPreviewValue(getFallbackDate());
|
|
725
|
+
}
|
|
673
726
|
return;
|
|
674
727
|
}
|
|
675
|
-
const
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
if (
|
|
728
|
+
const dayjsObject = dayjs(modelValue);
|
|
729
|
+
const formattedDate = dayjsObject.format(DatePickerFormats.Day);
|
|
730
|
+
if (invalidFormatDate(formattedDate)) {
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
const [parsedYear, parsedMonth, parsedDay] = formattedDate.split("-");
|
|
734
|
+
const selectedMonthValue = MonthList.find((month) => month === parsedMonth);
|
|
735
|
+
selectionState.selectedMonth = selectedMonthValue;
|
|
736
|
+
selectionState.selectedYear = parsedYear;
|
|
737
|
+
selectionState.selectedDay = parsedDay;
|
|
738
|
+
if (syncPreview) {
|
|
739
|
+
syncPreviewValue(formattedDate);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
function syncPreviewValue(previewSource) {
|
|
743
|
+
const dayjsObject = previewSource ? dayjs(previewSource) : dayjs(getFallbackDate());
|
|
744
|
+
const formattedDate = dayjsObject.format(DatePickerFormats.Day);
|
|
745
|
+
if (invalidFormatDate(formattedDate)) {
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
const [previewYearValue, previewMonthSource] = formattedDate.split("-");
|
|
749
|
+
const previewMonthValue = MonthList.find((month) => month === previewMonthSource);
|
|
750
|
+
previewMonth.value = previewMonthValue;
|
|
751
|
+
previewYear.value = previewYearValue;
|
|
752
|
+
}
|
|
753
|
+
function resetPreview() {
|
|
754
|
+
var _a;
|
|
755
|
+
showYearPanel.value = false;
|
|
756
|
+
showMonthPanel.value = false;
|
|
757
|
+
if (!props2.range && !props2.multiple) {
|
|
758
|
+
syncPreviewValue(getSingleDate(props2.modelValue));
|
|
686
759
|
return;
|
|
687
760
|
}
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
previewMonth.value = monthDes2;
|
|
691
|
-
previewYear.value = yearValue;
|
|
761
|
+
const previewSource = isArray(props2.modelValue) ? (_a = getFirstValidDate(props2.modelValue, props2.type)) != null ? _a : getFallbackDate() : getFallbackDate();
|
|
762
|
+
syncPreviewValue(previewSource);
|
|
692
763
|
}
|
|
693
|
-
function
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
764
|
+
function syncModelValue() {
|
|
765
|
+
showYearPanel.value = false;
|
|
766
|
+
showMonthPanel.value = false;
|
|
767
|
+
shouldKeepPreviewOnModelValueChange = false;
|
|
768
|
+
syncFromModelValue(true);
|
|
698
769
|
}
|
|
699
770
|
return {
|
|
700
771
|
yearPanelEl,
|
|
@@ -702,35 +773,35 @@ const __sfc__ = defineComponent({
|
|
|
702
773
|
dayPanelEl,
|
|
703
774
|
reverse,
|
|
704
775
|
currentDate,
|
|
705
|
-
chooseMonth,
|
|
706
|
-
chooseYear,
|
|
707
|
-
chooseDay,
|
|
708
776
|
previewYear,
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
777
|
+
showYearPanel,
|
|
778
|
+
showMonthPanel,
|
|
779
|
+
monthTitle,
|
|
780
|
+
dateTitle,
|
|
781
|
+
yearTitle,
|
|
782
|
+
titleHint,
|
|
783
|
+
panelType,
|
|
784
|
+
headerType,
|
|
785
|
+
headerPreview,
|
|
786
|
+
selectionState,
|
|
787
|
+
previewState,
|
|
788
|
+
panelProps,
|
|
789
|
+
dateSlotProps,
|
|
790
|
+
formattedRangeDays,
|
|
723
791
|
n,
|
|
724
792
|
classes,
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
793
|
+
switchPanel,
|
|
794
|
+
shiftCurrentPanelPreview,
|
|
795
|
+
shiftDatePanelYearPreview,
|
|
796
|
+
selectDayFromPanel,
|
|
797
|
+
selectMonthFromPanel,
|
|
798
|
+
selectYearFromPanel,
|
|
799
|
+
shiftPreview,
|
|
800
|
+
resetPreview,
|
|
801
|
+
syncModelValue,
|
|
802
|
+
rangeSelecting,
|
|
803
|
+
formatElevation,
|
|
804
|
+
DatePickerTypes
|
|
734
805
|
};
|
|
735
806
|
}
|
|
736
807
|
});
|