@king-design/vue 3.5.2 → 3.6.0-beta.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/components/datepicker/basepicker.d.ts +4 -2
- package/components/datepicker/basepicker.js +46 -13
- package/components/datepicker/calendar.d.ts +34 -6
- package/components/datepicker/calendar.js +4 -0
- package/components/datepicker/calendar.vdt.js +21 -5
- package/components/datepicker/dayjs.d.ts +13 -2
- package/components/datepicker/dayjs.js +6 -0
- package/components/datepicker/helpers.d.ts +5 -5
- package/components/datepicker/index.d.ts +17 -2
- package/components/datepicker/index.js +23 -5
- package/components/datepicker/index.spec.js +356 -355
- package/components/datepicker/index.vdt.js +25 -29
- package/components/datepicker/styles.d.ts +17 -0
- package/components/datepicker/styles.js +29 -2
- package/components/datepicker/useDisabled.d.ts +2 -2
- package/components/datepicker/useDisabled.js +1 -1
- package/components/datepicker/useFormats.js +3 -1
- package/components/datepicker/useMergeRange.d.ts +5 -0
- package/components/datepicker/useMergeRange.js +50 -0
- package/components/datepicker/usePosition.d.ts +10 -0
- package/components/datepicker/usePosition.js +166 -0
- package/components/datepicker/useQuarters.d.ts +15 -0
- package/components/datepicker/useQuarters.js +36 -0
- package/components/datepicker/useShowDate.d.ts +1 -1
- package/components/datepicker/useShowDate.js +42 -9
- package/components/datepicker/useStatus.d.ts +1 -1
- package/components/datepicker/useValue.d.ts +1 -0
- package/components/datepicker/useValue.js +26 -2
- package/components/datepicker/useWeeks.d.ts +19 -0
- package/components/datepicker/useWeeks.js +48 -0
- package/components/dialog/useFixBody.js +6 -58
- package/components/ellipsis/styles.js +1 -1
- package/components/form/styles.js +1 -1
- package/components/scrollSelect/index.spec.js +4 -6
- package/components/scrollSelect/useMouseEvents.js +21 -9
- package/components/select/base.vdt.js +4 -2
- package/components/select/index.spec.js +235 -62
- package/components/select/option.d.ts +1 -0
- package/components/select/option.js +9 -2
- package/components/select/select.d.ts +1 -0
- package/components/select/select.js +2 -1
- package/components/select/useFilterable.js +2 -1
- package/components/select/useInput.js +5 -2
- package/components/select/useSearchable.js +1 -0
- package/components/timepicker/panelPicker.d.ts +2 -1
- package/components/timepicker/panelPicker.vdt.js +12 -4
- package/components/timepicker/selectPicker.d.ts +1 -1
- package/components/timepicker/styles.js +1 -1
- package/components/timepicker/useDisabled.d.ts +1 -1
- package/components/timepicker/useValue.d.ts +1 -0
- package/components/tour/index.d.ts +2 -0
- package/components/tour/index.js +2 -0
- package/components/tour/index.spec.d.ts +1 -0
- package/components/tour/index.spec.js +356 -0
- package/components/tour/step.d.ts +23 -0
- package/components/tour/step.js +46 -0
- package/components/tour/step.vdt.js +74 -0
- package/components/tour/styles.d.ts +7 -0
- package/components/tour/styles.js +84 -0
- package/components/tour/tour.d.ts +73 -0
- package/components/tour/tour.js +70 -0
- package/components/tour/tour.vdt.js +66 -0
- package/components/tour/useArrow.d.ts +4 -0
- package/components/tour/useArrow.js +40 -0
- package/components/tour/useFixBody.d.ts +4 -0
- package/components/tour/useFixBody.js +17 -0
- package/components/tour/useHighlight.d.ts +4 -0
- package/components/tour/useHighlight.js +31 -0
- package/components/tour/useMaskClosable.d.ts +1 -0
- package/components/tour/useMaskClosable.js +25 -0
- package/components/tour/useNavigation.d.ts +5 -0
- package/components/tour/useNavigation.js +103 -0
- package/components/tour/usePosition.d.ts +6 -0
- package/components/tour/usePosition.js +93 -0
- package/components/tour/useSteps.d.ts +6 -0
- package/components/tour/useSteps.js +68 -0
- package/hooks/useFixBody.d.ts +11 -0
- package/hooks/useFixBody.js +72 -0
- package/index.d.ts +3 -2
- package/index.js +3 -2
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { TypeDefs } from 'intact-vue-next';
|
|
5
5
|
import { State } from '../../hooks/useState';
|
|
6
|
-
import { Dayjs, OpUnitType } from './dayjs';
|
|
6
|
+
import { Dayjs, OpUnitType, QUnitType } from './dayjs';
|
|
7
7
|
import type { useFormats } from './useFormats';
|
|
8
8
|
import type { useDisabled } from './useDisabled';
|
|
9
9
|
import { PanelFlags, usePanel } from './usePanel';
|
|
@@ -34,6 +34,7 @@ export interface BasePickerProps<V extends Value = Value, Multipe extends boolea
|
|
|
34
34
|
}
|
|
35
35
|
export interface BasePickerEvents extends BaseSelectEvents {
|
|
36
36
|
selecting: [StateValueRange];
|
|
37
|
+
togglePosition: [];
|
|
37
38
|
}
|
|
38
39
|
export interface BasePickerBlocks<V extends Value = Value, R extends boolean = boolean> extends BaseSelectBlocks<R extends true ? [Value, Value] : Value> {
|
|
39
40
|
}
|
|
@@ -47,7 +48,7 @@ export declare abstract class BasePicker<T extends BasePickerProps = BasePickerP
|
|
|
47
48
|
abstract panel: ReturnType<typeof usePanel>;
|
|
48
49
|
resetKeywords(keywords: State<string>): void;
|
|
49
50
|
}
|
|
50
|
-
export declare function useValue({ createDateByValueFormat, createDateByShowFormat, getShowString, getValueString, }: ReturnType<typeof useFormats>, { isDisabled, minDate }: ReturnType<typeof useDisabled>, panel: ReturnType<typeof usePanel>, shouldUpdateValue: (v: StateValueItem) => boolean, updateValueOnInput: (v: DayjsValueItem) => void, getEqualType: () => OpUnitType, updateStateValue: (v: DayjsValue, value: State<StateValue>) => void): {
|
|
51
|
+
export declare function useValue({ createDateByValueFormat, createDateByShowFormat, getShowString, getValueString, }: ReturnType<typeof useFormats>, { isDisabled, minDate }: ReturnType<typeof useDisabled>, panel: ReturnType<typeof usePanel>, shouldUpdateValue: (v: StateValueItem) => boolean, updateValueOnInput: (v: DayjsValueItem) => void, getEqualType: () => OpUnitType | QUnitType, updateStateValue: (v: DayjsValue, value: State<StateValue>) => void): {
|
|
51
52
|
value: State<StateValue>;
|
|
52
53
|
format: () => string | string[];
|
|
53
54
|
onConfirm: () => void;
|
|
@@ -56,4 +57,5 @@ export declare function useValue({ createDateByValueFormat, createDateByShowForm
|
|
|
56
57
|
setValue: (v: StateValueItem, fromInput: boolean) => void;
|
|
57
58
|
convertToDayjs: (v: BasePickerProps<Value>['value']) => DayjsValue;
|
|
58
59
|
getDayjsValue: () => DayjsValue;
|
|
60
|
+
setMoment: () => void;
|
|
59
61
|
};
|
|
@@ -30,7 +30,8 @@ var defaults = function defaults() {
|
|
|
30
30
|
});
|
|
31
31
|
};
|
|
32
32
|
var events = _extends({}, BaseSelect.events, {
|
|
33
|
-
selecting: true
|
|
33
|
+
selecting: true,
|
|
34
|
+
togglePosition: true
|
|
34
35
|
});
|
|
35
36
|
export var BasePicker = /*#__PURE__*/function (_BaseSelect) {
|
|
36
37
|
_inheritsLoose(BasePicker, _BaseSelect);
|
|
@@ -45,7 +46,7 @@ export var BasePicker = /*#__PURE__*/function (_BaseSelect) {
|
|
|
45
46
|
var dayjsValue = this.value.getDayjsValue();
|
|
46
47
|
var getShowString = this.formats.getShowString;
|
|
47
48
|
var value = last(dayjsValue);
|
|
48
|
-
keywords.set(multiple ? '' : !range ? value ? getShowString(value) : '' : value ? [getShowString(value[0]), getShowString(value[1])].join(' ~ ') : '');
|
|
49
|
+
keywords.set(multiple ? '' : !range ? value ? getShowString(value) : '' : value ? [value[0] ? getShowString(value[0]) : '', value[1] ? getShowString(value[1]) : ''].join(' ~ ') : '');
|
|
49
50
|
};
|
|
50
51
|
return BasePicker;
|
|
51
52
|
}(BaseSelect);
|
|
@@ -66,9 +67,15 @@ export function useValue(_ref, _ref2, panel, shouldUpdateValue, updateValueOnInp
|
|
|
66
67
|
var dayjsValue = [];
|
|
67
68
|
instance.watch('value', function (newValue, oldValue) {
|
|
68
69
|
if (isEqualArray(newValue, oldValue)) return;
|
|
69
|
-
dayjsValue
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
// 检查是否与当前 dayjsValue 对应的字符串相同,避免循环
|
|
71
|
+
var currentValueStr = convertToValueString(dayjsValue);
|
|
72
|
+
if (newValue === currentValueStr) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// 只执行一次转换和更新逻辑
|
|
76
|
+
var _value = convertToDayjs(newValue);
|
|
77
|
+
dayjsValue = _value;
|
|
78
|
+
updateStateValue(_value, value);
|
|
72
79
|
instance.resetKeywords(instance.input.keywords);
|
|
73
80
|
});
|
|
74
81
|
watchState(instance.input.keywords, function (v) {
|
|
@@ -94,6 +101,8 @@ export function useValue(_ref, _ref2, panel, shouldUpdateValue, updateValueOnInp
|
|
|
94
101
|
}
|
|
95
102
|
if (endDate.isAfter(startDate)) {
|
|
96
103
|
updateValueOnInput([startDate, endDate]);
|
|
104
|
+
} else {
|
|
105
|
+
updateValueOnInput([endDate, startDate]);
|
|
97
106
|
}
|
|
98
107
|
}
|
|
99
108
|
} else {
|
|
@@ -143,16 +152,14 @@ export function useValue(_ref, _ref2, panel, shouldUpdateValue, updateValueOnInp
|
|
|
143
152
|
return results;
|
|
144
153
|
}
|
|
145
154
|
function setSingleDate(v, fromInput) {
|
|
146
|
-
var _instance$get3 = instance.get(),
|
|
147
|
-
range = _instance$get3.range;
|
|
148
155
|
value.set([v]);
|
|
149
156
|
if (fromInput || shouldUpdateValue(v)) {
|
|
150
157
|
updateValue();
|
|
151
158
|
}
|
|
152
159
|
}
|
|
153
160
|
function addMultipeDate(v, fromInput) {
|
|
154
|
-
var _instance$
|
|
155
|
-
range = _instance$
|
|
161
|
+
var _instance$get3 = instance.get(),
|
|
162
|
+
range = _instance$get3.range;
|
|
156
163
|
var _value = value.value;
|
|
157
164
|
_value = !_value ? [] : _sliceInstanceProperty(_value).call(_value);
|
|
158
165
|
if (range && v.length === 2) {
|
|
@@ -194,19 +201,44 @@ export function useValue(_ref, _ref2, panel, shouldUpdateValue, updateValueOnInp
|
|
|
194
201
|
function updateValue() {
|
|
195
202
|
var _value = value.value;
|
|
196
203
|
var valueStr = convertToValueString(_value);
|
|
204
|
+
// 检查是否需要更新,避免循环调用
|
|
205
|
+
if (instance.get('value') === valueStr) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
// 在设置 value 之前先更新 dayjsValue
|
|
209
|
+
dayjsValue = _value;
|
|
197
210
|
instance.set('value', valueStr);
|
|
198
211
|
instance.resetKeywords(instance.input.keywords);
|
|
199
212
|
}
|
|
200
213
|
function onConfirm() {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
214
|
+
var lastValue = last(instance.value.value.value);
|
|
215
|
+
var _instance$get4 = instance.get(),
|
|
216
|
+
multiple = _instance$get4.multiple,
|
|
217
|
+
range = _instance$get4.range;
|
|
218
|
+
if (!multiple) {
|
|
219
|
+
if (range) {
|
|
220
|
+
// 范围选择:需要开始和结束时间都选择完才关闭
|
|
221
|
+
if (lastValue.length === 2) {
|
|
222
|
+
instance.hide();
|
|
223
|
+
}
|
|
224
|
+
instance.trigger('togglePosition');
|
|
225
|
+
} else {
|
|
226
|
+
// 单选:选择完时间就关闭
|
|
227
|
+
if (lastValue) {
|
|
228
|
+
instance.hide();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
204
231
|
} else {
|
|
205
232
|
unique();
|
|
206
233
|
panel.reset();
|
|
207
234
|
}
|
|
208
235
|
updateValue();
|
|
209
236
|
}
|
|
237
|
+
function setMoment() {
|
|
238
|
+
var now = dayjs();
|
|
239
|
+
setValue(now, true);
|
|
240
|
+
instance.hide();
|
|
241
|
+
}
|
|
210
242
|
function unique() {
|
|
211
243
|
var _value = value.value;
|
|
212
244
|
var map = {};
|
|
@@ -264,6 +296,7 @@ export function useValue(_ref, _ref2, panel, shouldUpdateValue, updateValueOnInp
|
|
|
264
296
|
getTimeValue: getTimeValue,
|
|
265
297
|
setValue: setValue,
|
|
266
298
|
convertToDayjs: convertToDayjs,
|
|
267
|
-
getDayjsValue: getDayjsValue
|
|
299
|
+
getDayjsValue: getDayjsValue,
|
|
300
|
+
setMoment: setMoment
|
|
268
301
|
};
|
|
269
302
|
}
|
|
@@ -5,7 +5,7 @@ import { StateValue } from './basepicker';
|
|
|
5
5
|
import { PanelFlags } from './usePanel';
|
|
6
6
|
export interface DatepickerCalendarProps {
|
|
7
7
|
value: StateValue;
|
|
8
|
-
type?: 'date' | 'year' | 'month';
|
|
8
|
+
type?: 'date' | 'year' | 'month' | 'week' | 'quarter';
|
|
9
9
|
flag: PanelFlags;
|
|
10
10
|
}
|
|
11
11
|
export interface DatepickerCalendarEvents {
|
|
@@ -14,13 +14,13 @@ export interface DatepickerCalendarEvents {
|
|
|
14
14
|
export declare class DatepickerCalendar extends Component<DatepickerCalendarProps, DatepickerCalendarEvents> {
|
|
15
15
|
static template: string | import('intact-vue-next').Template<any>;
|
|
16
16
|
static defaults: () => Partial<DatepickerCalendarProps>;
|
|
17
|
-
type: import("../../hooks/useState").State<Required<"date" | "month" | "year" | undefined>>;
|
|
17
|
+
type: import("../../hooks/useState").State<Required<"date" | "month" | "week" | "year" | "quarter" | undefined>>;
|
|
18
18
|
datepicker: Datepicker;
|
|
19
19
|
showDate: {
|
|
20
20
|
date: import("../../hooks/useState").State<Dayjs>;
|
|
21
21
|
getDateLabel: () => {
|
|
22
22
|
value: string;
|
|
23
|
-
onClick(e: import("../../hooks/useDocumentClick").IgnoreClickEvent)
|
|
23
|
+
onClick: (e: import("../../hooks/useDocumentClick").IgnoreClickEvent) => void;
|
|
24
24
|
}[];
|
|
25
25
|
prevMonth: () => void;
|
|
26
26
|
nextMonth: () => void;
|
|
@@ -30,9 +30,9 @@ export declare class DatepickerCalendar extends Component<DatepickerCalendarProp
|
|
|
30
30
|
prevTenYears: () => void;
|
|
31
31
|
};
|
|
32
32
|
status: {
|
|
33
|
-
isActive: (date: Dayjs, type: "date" | "month" | "year" | undefined) => boolean;
|
|
34
|
-
isInRange: (date: Dayjs, type: "date" | "month" | "year" | undefined) => boolean;
|
|
35
|
-
isDisabled: (value: Dayjs, type?:
|
|
33
|
+
isActive: (date: Dayjs, type: "date" | "month" | "week" | "year" | "quarter" | undefined) => boolean;
|
|
34
|
+
isInRange: (date: Dayjs, type: "date" | "month" | "week" | "year" | "quarter" | undefined) => boolean;
|
|
35
|
+
isDisabled: (value: Dayjs, type?: "h" | "s" | "y" | "date" | "month" | "week" | "millisecond" | "second" | "minute" | "hour" | "day" | "year" | "milliseconds" | "seconds" | "minutes" | "hours" | "days" | "months" | "years" | "dates" | "d" | "D" | "M" | "m" | "ms" | "weeks" | "w" | "quarter" | "quarters" | "Q") => boolean;
|
|
36
36
|
};
|
|
37
37
|
days: {
|
|
38
38
|
getDays: (now: Dayjs) => {
|
|
@@ -74,6 +74,34 @@ export declare class DatepickerCalendar extends Component<DatepickerCalendarProp
|
|
|
74
74
|
}[];
|
|
75
75
|
onClick: (date: Dayjs) => void;
|
|
76
76
|
};
|
|
77
|
+
weeks: {
|
|
78
|
+
getWeeks: (now: Dayjs) => {
|
|
79
|
+
week: number;
|
|
80
|
+
days: {
|
|
81
|
+
isExceed: boolean;
|
|
82
|
+
label: number;
|
|
83
|
+
value: Dayjs;
|
|
84
|
+
isActive: boolean;
|
|
85
|
+
isToday: boolean;
|
|
86
|
+
isDisabled: boolean;
|
|
87
|
+
isHover: boolean;
|
|
88
|
+
isInRange: boolean;
|
|
89
|
+
}[];
|
|
90
|
+
}[];
|
|
91
|
+
onClick: (day: Dayjs) => void;
|
|
92
|
+
};
|
|
93
|
+
quarters: {
|
|
94
|
+
getQuarters: (now: Dayjs) => {
|
|
95
|
+
isActive: boolean;
|
|
96
|
+
isToday: boolean;
|
|
97
|
+
isDisabled: boolean;
|
|
98
|
+
isHover: boolean;
|
|
99
|
+
isInRange: boolean;
|
|
100
|
+
label: string;
|
|
101
|
+
value: Dayjs;
|
|
102
|
+
}[];
|
|
103
|
+
onClick: (date: Dayjs) => void;
|
|
104
|
+
};
|
|
77
105
|
private config;
|
|
78
106
|
triggerChange(value: Dayjs): void;
|
|
79
107
|
}
|
|
@@ -11,6 +11,8 @@ import { useShowDate } from './useShowDate';
|
|
|
11
11
|
import { bind } from '../utils';
|
|
12
12
|
import { useYears } from './useYears';
|
|
13
13
|
import { useMonths } from './useMonths';
|
|
14
|
+
import { useWeeks } from './useWeeks';
|
|
15
|
+
import { useQuarters } from './useQuarters';
|
|
14
16
|
import { useStatus } from './useStatus';
|
|
15
17
|
import { useConfigContext } from '../config';
|
|
16
18
|
var defaults = function defaults() {
|
|
@@ -34,6 +36,8 @@ export var DatepickerCalendar = /*#__PURE__*/function (_Component) {
|
|
|
34
36
|
_this.days = useDays(_this.showDate.date, _this.status, _this.datepicker.focusDate.focusDate);
|
|
35
37
|
_this.years = useYears(_this.showDate.date, _this.status, _this.datepicker.focusDate.focusDate);
|
|
36
38
|
_this.months = useMonths(_this.showDate.date, _this.status, _this.datepicker.focusDate.focusDate);
|
|
39
|
+
_this.weeks = useWeeks(_this.showDate.date, _this.status, _this.datepicker.focusDate.focusDate);
|
|
40
|
+
_this.quarters = useQuarters(_this.showDate.date, _this.status, _this.datepicker.focusDate.focusDate);
|
|
37
41
|
_this.config = useConfigContext();
|
|
38
42
|
return _this;
|
|
39
43
|
}
|
|
@@ -12,7 +12,12 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
12
12
|
var $this = this;
|
|
13
13
|
var type = this.type.value;
|
|
14
14
|
var isYear = type === 'year';
|
|
15
|
+
var isWeek = type === 'week';
|
|
16
|
+
var isQuarter = type === 'quarter';
|
|
15
17
|
var isYearOrMonth = isYear || type === 'month';
|
|
18
|
+
var isDateOrDateTime = type === 'date' || type === 'datetime';
|
|
19
|
+
// isDateOrDateTime & isWeek合并
|
|
20
|
+
var showDateWeeks = isDateOrDateTime || isWeek;
|
|
16
21
|
var k = this.config.k;
|
|
17
22
|
var classNameObj = (_classNameObj = {}, _classNameObj[k + "-datepicker-calendar"] = true, _classNameObj[makeCalendarStyles(k)] = true, _classNameObj);
|
|
18
23
|
var now = getNowDate();
|
|
@@ -58,7 +63,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
58
63
|
'className': _$cn(k + "-icon-left"),
|
|
59
64
|
'size': 'small'
|
|
60
65
|
})]
|
|
61
|
-
}),
|
|
66
|
+
}), showDateWeeks ? _$cc(Button, {
|
|
62
67
|
'icon': true,
|
|
63
68
|
'type': 'none',
|
|
64
69
|
'size': 'small',
|
|
@@ -73,7 +78,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
73
78
|
return _$ce(2, 'span', $value.value, 0, _$cn(k + "-month-value"), {
|
|
74
79
|
'ev-click': $value.onClick
|
|
75
80
|
});
|
|
76
|
-
}, $this) : _$ce(2, 'span', this.years.getYearLabel(), 0, _$cn(k + "-month-value")), 0, _$cn(k + "-month-values")), _$ce(2, 'div', [
|
|
81
|
+
}, $this) : _$ce(2, 'span', this.years.getYearLabel(), 0, _$cn(k + "-month-value")), 0, _$cn(k + "-month-values")), _$ce(2, 'div', [showDateWeeks ? _$cc(Button, {
|
|
77
82
|
'icon': true,
|
|
78
83
|
'type': 'none',
|
|
79
84
|
'size': 'small',
|
|
@@ -98,11 +103,22 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
98
103
|
'className': _$cn(k + "-icon-right"),
|
|
99
104
|
'size': 'small'
|
|
100
105
|
})]
|
|
101
|
-
})], 0, _$cn(k + "-right-btns"))], 4, _$cn(k + "-datepicker-month")),
|
|
106
|
+
})], 0, _$cn(k + "-right-btns"))], 4, _$cn(k + "-datepicker-month")), showDateWeeks ? [_$ce(2, 'div', _$ma([_$('日'), _$('一'), _$('二'), _$('三'), _$('四'), _$('五'), _$('六')], function ($value, $key) {
|
|
102
107
|
return _$ce(2, 'div', $value, 0, _$cn(k + "-weekday"));
|
|
103
|
-
}, $this), 4, _$cn(k + "-weekdays")), _$ce(2, 'div',
|
|
108
|
+
}, $this), 4, _$cn(k + "-weekdays")), isWeek ? _$ce(2, 'div', _$ma(this.weeks.getWeeks(now), function ($value, $key) {
|
|
109
|
+
return _$ce(2, 'div', [_$ce(2, 'div', $value.week, 0, _$cn(k + "-week-number"), {
|
|
110
|
+
'ev-click': function evClick(e) {
|
|
111
|
+
onClickDay($value.days[0].value);
|
|
112
|
+
},
|
|
113
|
+
'ev-mouseenter': function evMouseenter() {
|
|
114
|
+
return focusDate.set($value.days[0].value);
|
|
115
|
+
}
|
|
116
|
+
}), getItems($value.days, onClickDay)], 0, 'week-row');
|
|
117
|
+
}, $this), 4, _$cn(k + "-weeks"), {
|
|
104
118
|
'ev-mouseleave': resetFocusDate
|
|
105
|
-
})
|
|
119
|
+
}) : _$ce(2, 'div', getItems(getDays(now), onClickDay), 0, _$cn(k + "-days"), {
|
|
120
|
+
'ev-mouseleave': resetFocusDate
|
|
121
|
+
})] : _$ce(2, 'div', isYear ? getItems(this.years.getYears(now), this.years.onClick) : isQuarter ? getItems(this.quarters.getQuarters(now), this.quarters.onClick) : getItems(this.months.getMonths(now), this.months.onClick), 0, _$cn(k + "-years"), {
|
|
106
122
|
'ev-mouseleave': resetFocusDate
|
|
107
123
|
})], 0, _$cn(classNameObj));
|
|
108
124
|
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import dayjs, { Dayjs, OpUnitType } from 'dayjs';
|
|
1
|
+
import dayjs, { Dayjs, OpUnitType as DayjsOpUnitType, QUnitType as DayjsQUnitType } from 'dayjs';
|
|
2
|
+
export type OpUnitType = DayjsOpUnitType;
|
|
3
|
+
export type QUnitType = DayjsQUnitType;
|
|
4
|
+
declare module 'dayjs' {
|
|
5
|
+
interface Dayjs {
|
|
6
|
+
isSame(date?: dayjs.ConfigType, unit?: DayjsOpUnitType | DayjsQUnitType): boolean;
|
|
7
|
+
isBefore(date?: dayjs.ConfigType, unit?: DayjsOpUnitType | DayjsQUnitType): boolean;
|
|
8
|
+
isAfter(date?: dayjs.ConfigType, unit?: DayjsOpUnitType | DayjsQUnitType): boolean;
|
|
9
|
+
add(value: number, unit?: DayjsOpUnitType | DayjsQUnitType): dayjs.Dayjs;
|
|
10
|
+
subtract(value: number, unit?: DayjsOpUnitType | DayjsQUnitType): dayjs.Dayjs;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
2
13
|
export default dayjs;
|
|
3
|
-
export type { Dayjs
|
|
14
|
+
export type { Dayjs };
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
|
+
import weekOfYear from 'dayjs/plugin/weekOfYear';
|
|
3
|
+
import quarterOfYear from 'dayjs/plugin/quarterOfYear';
|
|
2
4
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
5
|
+
import advancedFormat from 'dayjs/plugin/advancedFormat';
|
|
3
6
|
dayjs.extend(customParseFormat);
|
|
7
|
+
dayjs.extend(weekOfYear);
|
|
8
|
+
dayjs.extend(quarterOfYear);
|
|
9
|
+
dayjs.extend(advancedFormat);
|
|
4
10
|
export default dayjs;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import dayjs, { Dayjs, OpUnitType } from 'dayjs';
|
|
1
|
+
import dayjs, { Dayjs, OpUnitType, QUnitType } from 'dayjs';
|
|
2
2
|
import { StateValueItem } from './basepicker';
|
|
3
3
|
export declare function getNowDate(isEnd?: boolean): dayjs.Dayjs;
|
|
4
4
|
export declare function clearTime(date: Date): void;
|
|
5
5
|
export declare function endTime(date: Date): void;
|
|
6
|
-
export declare function isEqual(a: Dayjs | undefined | null, b: Dayjs | undefined | null, type?: OpUnitType): boolean;
|
|
7
|
-
export declare function isLT(a: Dayjs | undefined | null, b: Dayjs | undefined | null, type?: OpUnitType): boolean;
|
|
8
|
-
export declare function isGT(a: Dayjs | undefined | null, b: Dayjs | undefined | null, type?: OpUnitType): boolean;
|
|
6
|
+
export declare function isEqual(a: Dayjs | undefined | null, b: Dayjs | undefined | null, type?: OpUnitType | QUnitType): boolean;
|
|
7
|
+
export declare function isLT(a: Dayjs | undefined | null, b: Dayjs | undefined | null, type?: OpUnitType | QUnitType): boolean;
|
|
8
|
+
export declare function isGT(a: Dayjs | undefined | null, b: Dayjs | undefined | null, type?: OpUnitType | QUnitType): boolean;
|
|
9
9
|
export declare function createDate(date: string): Date;
|
|
10
|
-
export declare function findValueIndex(values: StateValueItem[], value: StateValueItem, type: OpUnitType): number;
|
|
10
|
+
export declare function findValueIndex(values: StateValueItem[], value: StateValueItem, type: OpUnitType | QUnitType): number;
|
|
11
11
|
export declare function last<T>(arr: T[]): T | undefined;
|
|
@@ -6,8 +6,9 @@ import { BasePicker, BasePickerProps, BasePickerEvents, BasePickerBlocks, Value
|
|
|
6
6
|
export * as shortcuts from './shortcuts';
|
|
7
7
|
export { dayjs };
|
|
8
8
|
export interface DatepickerProps<V extends Value = Value, M extends boolean = boolean, R extends boolean = boolean> extends BasePickerProps<V extends string ? V : V | string, M, R> {
|
|
9
|
-
type?: 'date' | 'datetime' | 'year' | 'month';
|
|
9
|
+
type?: 'date' | 'datetime' | 'year' | 'month' | 'week' | 'quarter';
|
|
10
10
|
shortcuts?: Shortcut[];
|
|
11
|
+
isMerge?: boolean;
|
|
11
12
|
}
|
|
12
13
|
export interface DatepickerEvents extends BasePickerEvents {
|
|
13
14
|
}
|
|
@@ -26,7 +27,7 @@ export declare class Datepicker<V extends Value = Value, M extends boolean = fal
|
|
|
26
27
|
getValueString: (value: dayjs.Dayjs) => string;
|
|
27
28
|
};
|
|
28
29
|
disabled: {
|
|
29
|
-
isDisabled: (value: dayjs.Dayjs, type?:
|
|
30
|
+
isDisabled: (value: dayjs.Dayjs, type?: "h" | "s" | "y" | "date" | "month" | "week" | "millisecond" | "second" | "minute" | "hour" | "day" | "year" | "milliseconds" | "seconds" | "minutes" | "hours" | "days" | "months" | "years" | "dates" | "d" | "D" | "M" | "m" | "ms" | "weeks" | "w" | "quarter" | "quarters" | "Q") => boolean;
|
|
30
31
|
isDisabledTime: (value: dayjs.Dayjs, flag: import("./usePanel").PanelFlags) => boolean;
|
|
31
32
|
isDisabledConfirm: () => boolean;
|
|
32
33
|
maxDate: State<dayjs.Dayjs | null>;
|
|
@@ -52,10 +53,24 @@ export declare class Datepicker<V extends Value = Value, M extends boolean = fal
|
|
|
52
53
|
getTimeValue: (flag: import("./usePanel").PanelFlags) => dayjs.Dayjs | null | undefined;
|
|
53
54
|
convertToDayjs: (v: Value | [Value, Value] | Value[] | [Value, Value][] | null | undefined) => import("./basepicker").DayjsValue;
|
|
54
55
|
getDayjsValue: () => import("./basepicker").DayjsValue;
|
|
56
|
+
setMoment: () => void;
|
|
55
57
|
value: State<import("./basepicker").StateValue>;
|
|
56
58
|
setValue: (v: import("./basepicker").StateValueItem, fromInput: boolean) => void;
|
|
57
59
|
onChangeDate: (v: dayjs.Dayjs, flag: import("./usePanel").PanelFlags) => void;
|
|
58
60
|
};
|
|
61
|
+
activePosition: {
|
|
62
|
+
position: State<"end" | "start">;
|
|
63
|
+
charLength: State<number>;
|
|
64
|
+
startTextLength: State<number>;
|
|
65
|
+
handleInputClick: (e: MouseEvent) => void;
|
|
66
|
+
resetPosition: (pos?: "end" | "start") => void;
|
|
67
|
+
togglePosition: () => void;
|
|
68
|
+
setupEventListeners: () => void;
|
|
69
|
+
resetToStart: () => void;
|
|
70
|
+
};
|
|
71
|
+
mergeRange: {
|
|
72
|
+
formatMultipleValues: (dayjsValue: import("./basepicker").DayjsValue, results: string[]) => string[];
|
|
73
|
+
};
|
|
59
74
|
init(): void;
|
|
60
75
|
protected getPlaceholder(): string | number | boolean | import("misstime/dist/utils/types").VNode<any> | import('intact-vue-next').Children[];
|
|
61
76
|
protected getLabel(): string | string[];
|
|
@@ -15,17 +15,21 @@ import { useFormats } from './useFormats';
|
|
|
15
15
|
import { usePanel } from './usePanel';
|
|
16
16
|
import { useFocusDate } from './useFocusDate';
|
|
17
17
|
import { useKeyboards } from './useKeyboards';
|
|
18
|
+
import { usePosition } from './usePosition';
|
|
19
|
+
import { useMergeRange } from './useMergeRange';
|
|
18
20
|
import { BasePicker } from './basepicker';
|
|
19
21
|
import * as _shortcuts from './shortcuts';
|
|
20
22
|
export { _shortcuts as shortcuts };
|
|
21
23
|
export { dayjs };
|
|
22
24
|
var typeDefs = _extends({}, BasePicker.typeDefs, {
|
|
23
|
-
type: ['date', 'datetime', 'year', 'month'],
|
|
24
|
-
shortcuts: Array
|
|
25
|
+
type: ['date', 'datetime', 'year', 'month', 'week', 'quarter'],
|
|
26
|
+
shortcuts: Array,
|
|
27
|
+
isMerge: Boolean
|
|
25
28
|
});
|
|
26
29
|
var defaults = function defaults() {
|
|
27
30
|
return _extends({}, BasePicker.defaults(), {
|
|
28
|
-
type: 'date'
|
|
31
|
+
type: 'date',
|
|
32
|
+
isMerge: false
|
|
29
33
|
});
|
|
30
34
|
};
|
|
31
35
|
export var Datepicker = /*#__PURE__*/function (_BasePicker) {
|
|
@@ -42,6 +46,8 @@ export var Datepicker = /*#__PURE__*/function (_BasePicker) {
|
|
|
42
46
|
_this.panel = usePanel();
|
|
43
47
|
_this.focusDate = useFocusDate();
|
|
44
48
|
_this.value = useValue(_this.formats, _this.disabled, _this.panel);
|
|
49
|
+
_this.activePosition = usePosition();
|
|
50
|
+
_this.mergeRange = useMergeRange(_this.formats);
|
|
45
51
|
return _this;
|
|
46
52
|
}
|
|
47
53
|
var _proto = Datepicker.prototype;
|
|
@@ -49,6 +55,7 @@ export var Datepicker = /*#__PURE__*/function (_BasePicker) {
|
|
|
49
55
|
_BasePicker.prototype.init.call(this);
|
|
50
56
|
provide(DATEPICKER, this);
|
|
51
57
|
useKeyboards(this.panel.startRef, this.focusDate.focusDate);
|
|
58
|
+
this.activePosition.setupEventListeners();
|
|
52
59
|
};
|
|
53
60
|
_proto.getPlaceholder = function getPlaceholder() {
|
|
54
61
|
var _this$get = this.get(),
|
|
@@ -63,11 +70,22 @@ export var Datepicker = /*#__PURE__*/function (_BasePicker) {
|
|
|
63
70
|
return _$('请选择年份');
|
|
64
71
|
case 'month':
|
|
65
72
|
return _$('请选择月份');
|
|
73
|
+
case 'week':
|
|
74
|
+
return _$('请选择周');
|
|
75
|
+
case 'quarter':
|
|
76
|
+
return _$('请选择季度');
|
|
66
77
|
default:
|
|
67
78
|
return range ? _$('开始日期 ~ 结束日期') : _$('请选择日期');
|
|
68
79
|
}
|
|
69
80
|
};
|
|
70
81
|
_proto.getLabel = function getLabel() {
|
|
82
|
+
var _this$get2 = this.get(),
|
|
83
|
+
multiple = _this$get2.multiple;
|
|
84
|
+
if (multiple) {
|
|
85
|
+
var results = this.value.format();
|
|
86
|
+
var dayjsValue = this.value.getDayjsValue();
|
|
87
|
+
return this.mergeRange.formatMultipleValues(dayjsValue, results);
|
|
88
|
+
}
|
|
71
89
|
return this.value.format();
|
|
72
90
|
};
|
|
73
91
|
_proto.clear = function clear(e) {
|
|
@@ -81,8 +99,8 @@ export var Datepicker = /*#__PURE__*/function (_BasePicker) {
|
|
|
81
99
|
var _this$value = this.value,
|
|
82
100
|
setValue = _this$value.setValue,
|
|
83
101
|
convertToDayjs = _this$value.convertToDayjs;
|
|
84
|
-
var _this$
|
|
85
|
-
multiple = _this$
|
|
102
|
+
var _this$get3 = this.get(),
|
|
103
|
+
multiple = _this$get3.multiple;
|
|
86
104
|
setValue(convertToDayjs(shortcut.value())[0], true);
|
|
87
105
|
if (!multiple) {
|
|
88
106
|
this.hide();
|