@uzum-tech/ui 1.1.5 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js +310 -353
- package/dist/index.prod.js +2 -2
- package/es/_utils/uzum/warn.js +3 -3
- package/es/alert/src/Alert.js +1 -1
- package/es/alert/src/styles/index.cssr.js +1 -1
- package/es/date-picker/src/DatePicker.d.ts +1 -0
- package/es/date-picker/src/DatePicker.js +10 -8
- package/es/date-picker/src/config.d.ts +1 -1
- package/es/date-picker/src/config.js +1 -1
- package/es/date-picker/src/interface.d.ts +7 -5
- package/es/date-picker/src/panel/date.d.ts +23 -8
- package/es/date-picker/src/panel/date.js +43 -18
- package/es/date-picker/src/panel/daterange.d.ts +18 -7
- package/es/date-picker/src/panel/daterange.js +95 -43
- package/es/date-picker/src/panel/datetime.d.ts +3 -1
- package/es/date-picker/src/panel/datetimerange.d.ts +2 -0
- package/es/date-picker/src/panel/panelHeader.d.ts +28 -7
- package/es/date-picker/src/panel/panelHeader.js +37 -13
- package/es/date-picker/src/panel/panelMonth.d.ts +16 -8
- package/es/date-picker/src/panel/panelMonth.js +8 -4
- package/es/date-picker/src/panel/panelMonthContent.d.ts +3 -1
- package/es/date-picker/src/panel/panelMonthContent.js +2 -5
- package/es/date-picker/src/panel/panelYear.d.ts +16 -8
- package/es/date-picker/src/panel/panelYear.js +8 -4
- package/es/date-picker/src/panel/panelYearContent.d.ts +3 -1
- package/es/date-picker/src/panel/panelYearContent.js +2 -1
- package/es/date-picker/src/panel/use-calendar.d.ts +4 -3
- package/es/date-picker/src/panel/use-dual-calendar.d.ts +1 -0
- package/es/date-picker/src/panel/use-panel-common.d.ts +2 -0
- package/es/date-picker/src/panel/use-panel-common.js +1 -0
- package/es/date-picker/src/styles/index.cssr.js +12 -10
- package/es/date-picker/src/utils.d.ts +3 -1
- package/es/date-picker/src/utils.js +13 -1
- package/es/grid/src/Grid.js +1 -1
- package/es/preset.d.ts +2 -2
- package/es/preset.js +3 -3
- package/es/version.d.ts +1 -1
- package/es/version.js +1 -1
- package/lib/_utils/uzum/warn.js +3 -3
- package/lib/alert/src/Alert.js +1 -1
- package/lib/alert/src/styles/index.cssr.js +1 -1
- package/lib/date-picker/src/DatePicker.d.ts +1 -0
- package/lib/date-picker/src/DatePicker.js +9 -7
- package/lib/date-picker/src/config.d.ts +1 -1
- package/lib/date-picker/src/config.js +1 -1
- package/lib/date-picker/src/interface.d.ts +7 -5
- package/lib/date-picker/src/panel/date.d.ts +23 -8
- package/lib/date-picker/src/panel/date.js +42 -17
- package/lib/date-picker/src/panel/daterange.d.ts +18 -7
- package/lib/date-picker/src/panel/daterange.js +94 -42
- package/lib/date-picker/src/panel/datetime.d.ts +3 -1
- package/lib/date-picker/src/panel/datetimerange.d.ts +2 -0
- package/lib/date-picker/src/panel/panelHeader.d.ts +28 -7
- package/lib/date-picker/src/panel/panelHeader.js +37 -13
- package/lib/date-picker/src/panel/panelMonth.d.ts +16 -8
- package/lib/date-picker/src/panel/panelMonth.js +8 -4
- package/lib/date-picker/src/panel/panelMonthContent.d.ts +3 -1
- package/lib/date-picker/src/panel/panelMonthContent.js +2 -5
- package/lib/date-picker/src/panel/panelYear.d.ts +16 -8
- package/lib/date-picker/src/panel/panelYear.js +8 -4
- package/lib/date-picker/src/panel/panelYearContent.d.ts +3 -1
- package/lib/date-picker/src/panel/panelYearContent.js +2 -1
- package/lib/date-picker/src/panel/use-calendar.d.ts +4 -3
- package/lib/date-picker/src/panel/use-dual-calendar.d.ts +1 -0
- package/lib/date-picker/src/panel/use-panel-common.d.ts +2 -0
- package/lib/date-picker/src/panel/use-panel-common.js +1 -0
- package/lib/date-picker/src/styles/index.cssr.js +12 -10
- package/lib/date-picker/src/utils.d.ts +3 -1
- package/lib/date-picker/src/utils.js +14 -1
- package/lib/grid/src/Grid.js +1 -1
- package/lib/preset.d.ts +2 -2
- package/lib/preset.js +3 -3
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +5 -6
- package/web-types.json +9 -9
- package/es/date-picker/src/panel/monthrange.d.ts +0 -1303
- package/es/date-picker/src/panel/monthrange.js +0 -117
- package/lib/date-picker/src/panel/monthrange.d.ts +0 -1303
- package/lib/date-picker/src/panel/monthrange.js +0 -119
package/es/_utils/uzum/warn.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
const warnedMessages = new Set();
|
|
2
2
|
export function warnOnce(location, message) {
|
|
3
|
-
const mergedMessage = `[
|
|
3
|
+
const mergedMessage = `[uzum-ui/${location}]: ${message}`;
|
|
4
4
|
if (warnedMessages.has(mergedMessage))
|
|
5
5
|
return;
|
|
6
6
|
warnedMessages.add(mergedMessage);
|
|
7
7
|
console.error(mergedMessage);
|
|
8
8
|
}
|
|
9
9
|
export function warn(location, message) {
|
|
10
|
-
console.error(`[
|
|
10
|
+
console.error(`[uzum-ui/${location}]: ${message}`);
|
|
11
11
|
}
|
|
12
12
|
export function throwError(location, message) {
|
|
13
|
-
throw new Error(`[
|
|
13
|
+
throw new Error(`[uzum-ui/${location}]: ${message}`);
|
|
14
14
|
}
|
package/es/alert/src/Alert.js
CHANGED
|
@@ -128,7 +128,7 @@ export default defineComponent({
|
|
|
128
128
|
this.actionsHorizontal &&
|
|
129
129
|
`${mergedClsPrefix}-alert--horizontal`,
|
|
130
130
|
this.showIcon && `${mergedClsPrefix}-alert--show-icon`,
|
|
131
|
-
// fix: https://github.com/tusen-ai/
|
|
131
|
+
// fix: https://github.com/tusen-ai/uzum-ui/issues/4588
|
|
132
132
|
!this.title &&
|
|
133
133
|
this.closable &&
|
|
134
134
|
`${mergedClsPrefix}-alert--right-adjust`,
|
|
@@ -60,7 +60,7 @@ export default cB('alert', `
|
|
|
60
60
|
width: var(--u-close-icon-size);
|
|
61
61
|
height: var(--u-close-icon-size);
|
|
62
62
|
`),
|
|
63
|
-
// fix: https://github.com/tusen-ai/
|
|
63
|
+
// fix: https://github.com/tusen-ai/uzum-ui/issues/4588
|
|
64
64
|
cM('right-adjust', [cB('alert-body', `
|
|
65
65
|
padding-right: calc(var(--u-close-size) + var(--u-padding) + 2px);
|
|
66
66
|
`)]), cM('show-icon', [cB('alert-body', [cE('content, title', `
|
|
@@ -4206,6 +4206,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
4206
4206
|
}, any>;
|
|
4207
4207
|
}>>>;
|
|
4208
4208
|
}, {
|
|
4209
|
+
rangeTypes: DatePickerType[];
|
|
4209
4210
|
mergedStatus: import("vue").ComputedRef<FormValidationStatus | undefined>;
|
|
4210
4211
|
mergedClsPrefix: Ref<string>;
|
|
4211
4212
|
mergedBordered: import("vue").ComputedRef<boolean>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h, defineComponent, ref, Transition, computed, provide, watch, withDirectives, toRef, watchEffect
|
|
1
|
+
import { h, defineComponent, ref, Transition, computed, provide, watch, withDirectives, toRef, watchEffect } from 'vue';
|
|
2
2
|
import { VBinder, VTarget, VFollower } from 'vueuc';
|
|
3
3
|
import { clickoutside } from 'vdirs';
|
|
4
4
|
import { format, getTime, isValid, addWeeks, addMonths, addYears } from 'date-fns'; //
|
|
@@ -17,7 +17,6 @@ import DatetimePanel from './panel/datetime';
|
|
|
17
17
|
import DatetimeRangePanel from './panel/datetimerange';
|
|
18
18
|
import DatePanel from './panel/date';
|
|
19
19
|
import DateRangePanel from './panel/daterange';
|
|
20
|
-
import MonthRangePanel from './panel/monthrange';
|
|
21
20
|
import style from './styles/index.cssr';
|
|
22
21
|
export const datePickerProps = Object.assign(Object.assign({}, useTheme.props), { to: useAdjustedTo.propTo, bordered: {
|
|
23
22
|
type: Boolean,
|
|
@@ -49,6 +48,12 @@ export default defineComponent({
|
|
|
49
48
|
}
|
|
50
49
|
});
|
|
51
50
|
}
|
|
51
|
+
const rangeTypes = [
|
|
52
|
+
'daterange',
|
|
53
|
+
'monthrange',
|
|
54
|
+
'yearrange',
|
|
55
|
+
'quarterrange'
|
|
56
|
+
];
|
|
52
57
|
const { localeRef, dateLocaleRef } = useLocale('DatePicker');
|
|
53
58
|
const formItem = useFormItem(props);
|
|
54
59
|
const { mergedSizeRef, mergedDisabledRef, mergedStatusRef } = formItem;
|
|
@@ -683,7 +688,7 @@ export default defineComponent({
|
|
|
683
688
|
return props.type;
|
|
684
689
|
}), cssVarsRef, props)
|
|
685
690
|
: undefined;
|
|
686
|
-
return Object.assign(Object.assign({}, exposedMethods), { mergedStatus: mergedStatusRef, mergedClsPrefix: mergedClsPrefixRef, mergedBordered: mergedBorderedRef, namespace: namespaceRef, uncontrolledValue: uncontrolledValueRef, pendingValue: pendingValueRef, panelInstRef,
|
|
691
|
+
return Object.assign(Object.assign({}, exposedMethods), { rangeTypes, mergedStatus: mergedStatusRef, mergedClsPrefix: mergedClsPrefixRef, mergedBordered: mergedBorderedRef, namespace: namespaceRef, uncontrolledValue: uncontrolledValueRef, pendingValue: pendingValueRef, panelInstRef,
|
|
687
692
|
triggerElRef,
|
|
688
693
|
inputInstRef, isMounted: useIsMounted(), displayTime: singleInputValueRef, displayStartTime: rangeStartInputValueRef, displayEndTime: rangeEndInputValueRef, mergedShow: mergedShowRef, adjustedTo: useAdjustedTo(props), isRange: isRangeRef, localizedStartPlaceholder: localizedStartPlaceholderRef, localizedEndPlaceholder: localizedEndPlaceholderRef, mergedSize: mergedSizeRef, mergedDisabled: mergedDisabledRef, localizedPlacehoder: localizedPlacehoderRef, isValueInvalid: uniVaidation.isValueInvalidRef, isStartValueInvalid: dualValidation.isStartValueInvalidRef, isEndValueInvalid: dualValidation.isEndValueInvalidRef, handleInputKeydown,
|
|
689
694
|
handleClickOutside,
|
|
@@ -726,11 +731,8 @@ export default defineComponent({
|
|
|
726
731
|
onRender: this.onRender
|
|
727
732
|
};
|
|
728
733
|
const renderPanel = () => {
|
|
729
|
-
const { type } = this;
|
|
730
|
-
return type === 'datetime' ? (h(DatetimePanel, Object.assign({}, commonPanelProps), $slots)) : type
|
|
731
|
-
: type === 'monthrange' ||
|
|
732
|
-
type === 'yearrange' ||
|
|
733
|
-
type === 'quarterrange' ? (h(MonthRangePanel, Object.assign({}, commonPanelProps, { type: type }))) : (h(DatePanel, Object.assign({}, commonPanelProps), $slots));
|
|
734
|
+
const { type, rangeTypes } = this;
|
|
735
|
+
return type === 'datetime' ? (h(DatetimePanel, Object.assign({}, commonPanelProps), $slots)) : rangeTypes.includes(type) ? (h(DateRangePanel, Object.assign({}, commonPanelProps, { type: type, defaultCalendarStartTime: this.defaultCalendarStartTime, defaultCalendarEndTime: this.defaultCalendarEndTime, bindCalendarMonths: this.bindCalendarMonths }), $slots)) : type === 'datetimerange' ? (h(DatetimeRangePanel, Object.assign({}, commonPanelProps, { defaultCalendarStartTime: this.defaultCalendarStartTime, defaultCalendarEndTime: this.defaultCalendarEndTime, bindCalendarMonths: this.bindCalendarMonths }), $slots)) : (h(DatePanel, Object.assign({}, commonPanelProps, { type: type }), $slots));
|
|
734
736
|
};
|
|
735
737
|
if (this.panel) {
|
|
736
738
|
return renderPanel();
|
|
@@ -7,7 +7,12 @@ import type { TimePickerProps } from '../../time-picker/src/TimePicker';
|
|
|
7
7
|
import type { MergedTheme } from '../../_mixins';
|
|
8
8
|
import type { DatePickerTheme } from '../styles/light';
|
|
9
9
|
import type { uniCalendarValidation, dualCalendarValidation } from './validation-utils';
|
|
10
|
+
import { DateCommonItem } from './utils';
|
|
10
11
|
export type Value = number | [number, number];
|
|
12
|
+
export type PanelValue = number & (number | null) & [
|
|
13
|
+
number,
|
|
14
|
+
number
|
|
15
|
+
] & ([number, number] | null);
|
|
11
16
|
export type DefaultTime = string | [string | undefined, string | undefined];
|
|
12
17
|
export type FormattedValue = string | [string, string];
|
|
13
18
|
export type Shortcuts = Record<string, number | (() => number)> | Record<string, [number, number] | readonly [number, number] | (() => [number, number] | readonly [number, number])>;
|
|
@@ -29,11 +34,8 @@ export type OnUpdateFormattedValue = (value: string & (string | null) & [
|
|
|
29
34
|
] & ([number, number] | null)) => void;
|
|
30
35
|
export type OnUpdateFormattedValueImpl = (value: string | [string, string] | null, timestampValue: number | [number, number] | null) => void;
|
|
31
36
|
export type OnUpdateValueImpl = (value: Value | null, formattedValue: string | [string, string] | null) => void;
|
|
32
|
-
export type OnPanelUpdateValue = (value:
|
|
33
|
-
|
|
34
|
-
number
|
|
35
|
-
] & ([number, number] | null), doUpdate: boolean) => void;
|
|
36
|
-
export type OnPanelUpdateValueImpl = (value: Value | null, doUpdate: boolean) => void;
|
|
37
|
+
export type OnPanelUpdateValue = (value: PanelValue, doUpdate: boolean, item?: DateCommonItem) => void;
|
|
38
|
+
export type OnPanelUpdateValueImpl = (value: Value | null, doUpdate: boolean, item?: DateCommonItem) => void;
|
|
37
39
|
export type OnClose = (disableUpdateOnClose: boolean) => void;
|
|
38
40
|
export interface RangePanelChildComponentRefs {
|
|
39
41
|
startYearScrollbarRef: Ref<ScrollbarInst | null>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DatePickerType } from '../config';
|
|
2
|
+
import { DateCommonItem, DateItem } from '../utils';
|
|
1
3
|
/**
|
|
2
4
|
* Date Panel
|
|
3
5
|
* Update picker value on:
|
|
@@ -10,7 +12,14 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
10
12
|
readonly default: () => string[];
|
|
11
13
|
};
|
|
12
14
|
readonly active: BooleanConstructor;
|
|
15
|
+
/**
|
|
16
|
+
* Date Panel
|
|
17
|
+
* Update picker value on:
|
|
18
|
+
* 1. item click
|
|
19
|
+
* 2. clear click
|
|
20
|
+
*/
|
|
13
21
|
readonly dateFormat: StringConstructor;
|
|
22
|
+
readonly type: import("vue").PropType<DatePickerType>;
|
|
14
23
|
readonly timeFormat: {
|
|
15
24
|
readonly type: StringConstructor;
|
|
16
25
|
readonly value: "HH:mm:ss";
|
|
@@ -33,7 +42,12 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
33
42
|
readonly onRender: import("vue").PropType<(() => void) | undefined>;
|
|
34
43
|
readonly panel: BooleanConstructor;
|
|
35
44
|
}, {
|
|
36
|
-
|
|
45
|
+
isWithoutDay: import("vue").ComputedRef<boolean>;
|
|
46
|
+
isMonth: import("vue").ComputedRef<boolean>;
|
|
47
|
+
isYear: import("vue").ComputedRef<boolean>;
|
|
48
|
+
handleMonthClick: (value: number, _doUpdate: boolean, item?: DateCommonItem) => void;
|
|
49
|
+
handleYearClick: (value: number, _doUpdate: boolean, item?: DateCommonItem) => void;
|
|
50
|
+
handleDateClick: (dateItem: DateCommonItem) => void;
|
|
37
51
|
handleDateInputBlur: () => void;
|
|
38
52
|
handleDateInput: (value: string) => void;
|
|
39
53
|
handleTimePickerChange: (value: number | null) => void;
|
|
@@ -114,12 +128,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
114
128
|
fontFamily: string;
|
|
115
129
|
fontFamilyMono: string;
|
|
116
130
|
cubicBezierEaseInOut: string;
|
|
117
|
-
/**
|
|
118
|
-
* Date Panel
|
|
119
|
-
* Update picker value on:
|
|
120
|
-
* 1. item click
|
|
121
|
-
* 2. clear click
|
|
122
|
-
*/
|
|
123
131
|
cubicBezierEaseOut: string;
|
|
124
132
|
cubicBezierEaseIn: string;
|
|
125
133
|
borderRadiusLarge: string;
|
|
@@ -1207,7 +1215,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
1207
1215
|
isHourDisabled: import("vue").ComputedRef<import("../../../time-picker/src/interface").IsHourDisabled | undefined>;
|
|
1208
1216
|
isMinuteDisabled: import("vue").ComputedRef<import("../../../time-picker/src/interface").IsMinuteDisabled | undefined>;
|
|
1209
1217
|
isSecondDisabled: import("vue").ComputedRef<import("../../../time-picker/src/interface").IsSecondDisabled | undefined>;
|
|
1210
|
-
dateArray: import("vue").ComputedRef<
|
|
1218
|
+
dateArray: import("vue").ComputedRef<DateItem[]>;
|
|
1211
1219
|
monthArray: import("vue").ComputedRef<import("../utils").MonthItem[]>;
|
|
1212
1220
|
yearArray: import("vue").ComputedRef<import("../utils").YearItem[]>;
|
|
1213
1221
|
quarterArray: import("vue").ComputedRef<import("../utils").QuarterItem[]>;
|
|
@@ -1229,7 +1237,14 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
1229
1237
|
readonly default: () => string[];
|
|
1230
1238
|
};
|
|
1231
1239
|
readonly active: BooleanConstructor;
|
|
1240
|
+
/**
|
|
1241
|
+
* Date Panel
|
|
1242
|
+
* Update picker value on:
|
|
1243
|
+
* 1. item click
|
|
1244
|
+
* 2. clear click
|
|
1245
|
+
*/
|
|
1232
1246
|
readonly dateFormat: StringConstructor;
|
|
1247
|
+
readonly type: import("vue").PropType<DatePickerType>;
|
|
1233
1248
|
readonly timeFormat: {
|
|
1234
1249
|
readonly type: StringConstructor;
|
|
1235
1250
|
readonly value: "HH:mm:ss";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { defineComponent, watchEffect, h } from 'vue';
|
|
1
|
+
import { defineComponent, watchEffect, h, computed, Fragment } from 'vue';
|
|
2
2
|
import { UButton, UxButton } from '../../../button';
|
|
3
3
|
import { UBaseFocusDetector } from '../../../_internal';
|
|
4
4
|
import { warnOnce } from '../../../_utils';
|
|
5
5
|
import { useCalendar, useCalendarProps } from './use-calendar';
|
|
6
6
|
import PanelHeader from './panelHeader';
|
|
7
|
+
import { getMsByDateCommonItem } from '../utils';
|
|
7
8
|
/**
|
|
8
9
|
* Date Panel
|
|
9
10
|
* Update picker value on:
|
|
@@ -22,11 +23,34 @@ export default defineComponent({
|
|
|
22
23
|
}
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
const calendar = useCalendar(props, 'date');
|
|
27
|
+
const type = props.type;
|
|
28
|
+
const monthTypes = ['month', 'quarter'];
|
|
29
|
+
const withoutDayTypes = [...monthTypes, 'year'];
|
|
30
|
+
const isWithoutDay = computed(() => withoutDayTypes.includes(type));
|
|
31
|
+
const isMonth = computed(() => monthTypes.includes(type));
|
|
32
|
+
const isYear = computed(() => type === 'year');
|
|
33
|
+
const updateMonth = (item) => {
|
|
34
|
+
const dateItem = item;
|
|
35
|
+
calendar.handleDateClick(Object.assign(Object.assign({}, dateItem), { dateObject: Object.assign(Object.assign({}, dateItem.dateObject), { month: dateItem.dateObject.month || 0, date: 1 }), ts: getMsByDateCommonItem(dateItem) }));
|
|
36
|
+
};
|
|
37
|
+
const handleMonthClick = (value, _doUpdate, item) => {
|
|
38
|
+
calendar.onUpdateCalendarValue(value);
|
|
39
|
+
isMonth.value && updateMonth(item);
|
|
40
|
+
};
|
|
41
|
+
const handleYearClick = (value, _doUpdate, item) => {
|
|
42
|
+
calendar.onUpdateCalendarValue(value);
|
|
43
|
+
isYear.value && updateMonth(item);
|
|
44
|
+
};
|
|
45
|
+
return Object.assign(Object.assign({}, calendar), { isWithoutDay,
|
|
46
|
+
isMonth,
|
|
47
|
+
isYear,
|
|
48
|
+
handleMonthClick,
|
|
49
|
+
handleYearClick });
|
|
26
50
|
},
|
|
27
51
|
render() {
|
|
28
52
|
var _a, _b, _c;
|
|
29
|
-
const { mergedClsPrefix, shortcuts, onRender } = this;
|
|
53
|
+
const { mergedClsPrefix, shortcuts, onRender, isWithoutDay, isYear, isMonth, handleMonthClick, handleYearClick } = this;
|
|
30
54
|
onRender === null || onRender === void 0 ? void 0 : onRender();
|
|
31
55
|
return (h("div", { ref: "selfRef", tabindex: 0, class: [
|
|
32
56
|
`${mergedClsPrefix}-date-panel`,
|
|
@@ -35,21 +59,22 @@ export default defineComponent({
|
|
|
35
59
|
this.themeClass
|
|
36
60
|
], onFocus: this.handlePanelFocus, onKeydown: this.handlePanelKeyDown },
|
|
37
61
|
h("div", { class: `${mergedClsPrefix}-date-panel-calendar` },
|
|
38
|
-
h(PanelHeader, { value: this.calendarValue, mergedClsPrefix: mergedClsPrefix, calendarMonth: this.calendarMonth, calendarYear: this.calendarYear,
|
|
39
|
-
h("div", { class: `${mergedClsPrefix}-date-panel-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
h(PanelHeader, { value: this.calendarValue, isMonth: isMonth, isYear: isYear, mergedClsPrefix: mergedClsPrefix, calendarMonth: this.calendarMonth, calendarYear: this.calendarYear, onUpdateMonth: handleMonthClick, onUpdateYear: handleYearClick }),
|
|
63
|
+
isWithoutDay ? (h("div", { class: `${mergedClsPrefix}-date-panel-placeholder` })) : (h(Fragment, null,
|
|
64
|
+
h("div", { class: `${mergedClsPrefix}-date-panel-weekdays` }, this.weekdays.map((weekday) => (h("div", { key: weekday, class: `${mergedClsPrefix}-date-panel-weekdays__day` }, weekday)))),
|
|
65
|
+
h("div", { class: `${mergedClsPrefix}-date-panel-dates` }, this.dateArray.map((dateItem, i) => (h("div", { "data-u-date": true, key: i, class: [
|
|
66
|
+
`${mergedClsPrefix}-date-panel-date`,
|
|
67
|
+
{
|
|
68
|
+
[`${mergedClsPrefix}-date-panel-date--current`]: dateItem.isCurrentDate,
|
|
69
|
+
[`${mergedClsPrefix}-date-panel-date--selected`]: dateItem.selected,
|
|
70
|
+
[`${mergedClsPrefix}-date-panel-date--excluded`]: !dateItem.inCurrentMonth,
|
|
71
|
+
[`${mergedClsPrefix}-date-panel-date--disabled`]: this.mergedIsDateDisabled(dateItem.ts)
|
|
72
|
+
}
|
|
73
|
+
], onClick: () => {
|
|
74
|
+
this.handleDateClick(dateItem);
|
|
75
|
+
} },
|
|
76
|
+
h("div", { class: `${mergedClsPrefix}-date-panel-date__trigger` }),
|
|
77
|
+
dateItem.dateObject.date))))))),
|
|
53
78
|
this.datePickerSlots.footer ? (h("div", { class: `${mergedClsPrefix}-date-panel-footer` }, this.datePickerSlots.footer())) : null,
|
|
54
79
|
((_a = this.actions) === null || _a === void 0 ? void 0 : _a.length) || shortcuts ? (h("div", { class: `${mergedClsPrefix}-date-panel-actions` },
|
|
55
80
|
h("div", { class: `${mergedClsPrefix}-date-panel-actions__prefix` }, shortcuts &&
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DatePickerType } from '../config';
|
|
2
|
+
import { DateCommonItem, DateItem, MonthItem } from '../utils';
|
|
1
3
|
declare const _default: import("vue").DefineComponent<{
|
|
2
4
|
readonly defaultCalendarStartTime: NumberConstructor;
|
|
3
5
|
readonly defaultCalendarEndTime: NumberConstructor;
|
|
@@ -8,6 +10,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
8
10
|
};
|
|
9
11
|
readonly active: BooleanConstructor;
|
|
10
12
|
readonly dateFormat: StringConstructor;
|
|
13
|
+
readonly type: import("vue").PropType<DatePickerType>;
|
|
11
14
|
readonly timeFormat: {
|
|
12
15
|
readonly type: StringConstructor;
|
|
13
16
|
readonly value: "HH:mm:ss";
|
|
@@ -30,6 +33,13 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
30
33
|
readonly onRender: import("vue").PropType<(() => void) | undefined>;
|
|
31
34
|
readonly panel: BooleanConstructor;
|
|
32
35
|
}, {
|
|
36
|
+
isMonthRange: import("vue").ComputedRef<boolean>;
|
|
37
|
+
isYearRange: import("vue").ComputedRef<boolean>;
|
|
38
|
+
isWithoutDay: import("vue").ComputedRef<boolean>;
|
|
39
|
+
handleMonthStartClick: (value: number, _doUpdate: boolean, item?: DateCommonItem) => void;
|
|
40
|
+
handleMonthEndClick: (value: number, _doUpdate: boolean, item?: DateCommonItem) => void;
|
|
41
|
+
handleYearStartClick: (value: number, _doUpdate: boolean, item?: DateCommonItem) => void;
|
|
42
|
+
handleYearEndClick: (value: number, _doUpdate: boolean, item?: DateCommonItem) => void;
|
|
33
43
|
startDateDisplayString: import("vue").Ref<string>;
|
|
34
44
|
endDateInput: import("vue").Ref<string>;
|
|
35
45
|
timePickerSize: import("vue").Ref<import("../../..").InputSize>;
|
|
@@ -1220,9 +1230,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
1220
1230
|
handleOpenQuickSelectMonthPanel: () => void;
|
|
1221
1231
|
startDatesElRef: import("vue").Ref<HTMLElement | null>;
|
|
1222
1232
|
endDatesElRef: import("vue").Ref<HTMLElement | null>;
|
|
1223
|
-
handleDateClick: (dateItem:
|
|
1224
|
-
handleColItemClick: (dateItem:
|
|
1225
|
-
handleDateMouseEnter: (dateItem:
|
|
1233
|
+
handleDateClick: (dateItem: DateItem) => void;
|
|
1234
|
+
handleColItemClick: (dateItem: MonthItem | import("../utils").YearItem | import("../utils").QuarterItem, clickType: "start" | "end") => void;
|
|
1235
|
+
handleDateMouseEnter: (dateItem: DateItem) => void;
|
|
1226
1236
|
handleConfirmClick: () => void;
|
|
1227
1237
|
startCalendarPrevYear: () => void;
|
|
1228
1238
|
startCalendarPrevMonth: () => void;
|
|
@@ -1240,13 +1250,13 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
1240
1250
|
endCalendarMonth: import("vue").ComputedRef<string>;
|
|
1241
1251
|
endCalendarYear: import("vue").ComputedRef<string>;
|
|
1242
1252
|
weekdays: import("vue").ComputedRef<string[]>;
|
|
1243
|
-
startDateArray: import("vue").ComputedRef<
|
|
1244
|
-
endDateArray: import("vue").ComputedRef<
|
|
1253
|
+
startDateArray: import("vue").ComputedRef<DateItem[]>;
|
|
1254
|
+
endDateArray: import("vue").ComputedRef<DateItem[]>;
|
|
1245
1255
|
startYearArray: import("vue").ComputedRef<import("../utils").YearItem[]>;
|
|
1246
|
-
startMonthArray: import("vue").ComputedRef<
|
|
1256
|
+
startMonthArray: import("vue").ComputedRef<MonthItem[]>;
|
|
1247
1257
|
startQuarterArray: import("vue").ComputedRef<import("../utils").QuarterItem[]>;
|
|
1248
1258
|
endYearArray: import("vue").ComputedRef<import("../utils").YearItem[]>;
|
|
1249
|
-
endMonthArray: import("vue").ComputedRef<
|
|
1259
|
+
endMonthArray: import("vue").ComputedRef<MonthItem[]>;
|
|
1250
1260
|
endQuarterArray: import("vue").ComputedRef<import("../utils").QuarterItem[]>;
|
|
1251
1261
|
isSelecting: import("vue").Ref<boolean>;
|
|
1252
1262
|
handleRangeShortcutMouseenter: (shortcut: number | [number, number] | (() => number) | readonly [number, number] | (() => [number, number] | readonly [number, number])) => void;
|
|
@@ -1261,6 +1271,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
1261
1271
|
};
|
|
1262
1272
|
readonly active: BooleanConstructor;
|
|
1263
1273
|
readonly dateFormat: StringConstructor;
|
|
1274
|
+
readonly type: import("vue").PropType<DatePickerType>;
|
|
1264
1275
|
readonly timeFormat: {
|
|
1265
1276
|
readonly type: StringConstructor;
|
|
1266
1277
|
readonly value: "HH:mm:ss";
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { defineComponent, h, watchEffect, computed, Fragment } from 'vue';
|
|
2
13
|
import { UButton, UxButton } from '../../../button';
|
|
3
14
|
import { UBaseFocusDetector } from '../../../_internal';
|
|
4
15
|
import { warnOnce } from '../../../_utils';
|
|
5
16
|
import { useDualCalendar, useDualCalendarProps } from './use-dual-calendar';
|
|
6
17
|
import PanelHeader from './panelHeader';
|
|
18
|
+
import { getMsByDateCommonItem } from '../utils';
|
|
7
19
|
export default defineComponent({
|
|
8
20
|
name: 'DateRangePanel',
|
|
9
21
|
props: useDualCalendarProps,
|
|
@@ -16,11 +28,49 @@ export default defineComponent({
|
|
|
16
28
|
}
|
|
17
29
|
});
|
|
18
30
|
}
|
|
19
|
-
|
|
31
|
+
const calendar = useDualCalendar(props, 'daterange');
|
|
32
|
+
const type = props.type;
|
|
33
|
+
const monthRanges = ['monthrange', 'quarterrange'];
|
|
34
|
+
const withoutDayTypes = [...monthRanges, 'yearrange'];
|
|
35
|
+
const isWithoutDay = computed(() => withoutDayTypes.includes(type));
|
|
36
|
+
const isMonthRange = computed(() => monthRanges.includes(type));
|
|
37
|
+
const isYearRange = computed(() => type === 'yearrange');
|
|
38
|
+
const monthToDateItem = (item, isEnd = false) => {
|
|
39
|
+
const _a = item, { dateObject } = _a, monthItem = __rest(_a, ["dateObject"]);
|
|
40
|
+
return Object.assign(Object.assign({}, monthItem), { dateObject: Object.assign(Object.assign({}, dateObject), { date: 1 }), inCurrentMonth: false, isCurrentDate: false, inSpan: false, startOfSpan: false, endOfSpan: isEnd, selected: isEnd, ts: getMsByDateCommonItem(item), type: 'date' });
|
|
41
|
+
};
|
|
42
|
+
const setMonthRange = (item, isEnd = false) => {
|
|
43
|
+
const monthItem = monthToDateItem(item, isEnd);
|
|
44
|
+
calendar.handleDateMouseEnter(monthItem);
|
|
45
|
+
calendar.handleDateClick(monthItem);
|
|
46
|
+
};
|
|
47
|
+
const handleMonthStartClick = (value, _doUpdate, item) => {
|
|
48
|
+
calendar.onUpdateStartCalendarValue(value);
|
|
49
|
+
isMonthRange.value && setMonthRange(item);
|
|
50
|
+
};
|
|
51
|
+
const handleMonthEndClick = (value, _doUpdate, item) => {
|
|
52
|
+
calendar.onUpdateEndCalendarValue(value);
|
|
53
|
+
isMonthRange.value && setMonthRange(item, true);
|
|
54
|
+
};
|
|
55
|
+
const handleYearStartClick = (value, _doUpdate, item) => {
|
|
56
|
+
calendar.onUpdateStartCalendarValue(value);
|
|
57
|
+
isYearRange.value && setMonthRange(item);
|
|
58
|
+
};
|
|
59
|
+
const handleYearEndClick = (value, _doUpdate, item) => {
|
|
60
|
+
calendar.onUpdateEndCalendarValue(value);
|
|
61
|
+
isYearRange.value && setMonthRange(item, true);
|
|
62
|
+
};
|
|
63
|
+
return Object.assign(Object.assign({}, calendar), { isMonthRange,
|
|
64
|
+
isYearRange,
|
|
65
|
+
isWithoutDay,
|
|
66
|
+
handleMonthStartClick,
|
|
67
|
+
handleMonthEndClick,
|
|
68
|
+
handleYearStartClick,
|
|
69
|
+
handleYearEndClick });
|
|
20
70
|
},
|
|
21
71
|
render() {
|
|
22
72
|
var _a, _b, _c;
|
|
23
|
-
const { mergedClsPrefix, shortcuts, onRender } = this;
|
|
73
|
+
const { mergedClsPrefix, shortcuts, onRender, isMonthRange, isYearRange, isWithoutDay, handleMonthStartClick, handleMonthEndClick, handleYearStartClick, handleYearEndClick } = this;
|
|
24
74
|
onRender === null || onRender === void 0 ? void 0 : onRender();
|
|
25
75
|
return (h("div", { ref: "selfRef", tabindex: 0, class: [
|
|
26
76
|
`${mergedClsPrefix}-date-panel`,
|
|
@@ -29,47 +79,49 @@ export default defineComponent({
|
|
|
29
79
|
this.themeClass
|
|
30
80
|
], onKeydown: this.handlePanelKeyDown, onFocus: this.handlePanelFocus },
|
|
31
81
|
h("div", { ref: "startDatesElRef", class: `${mergedClsPrefix}-date-panel-calendar ${mergedClsPrefix}-date-panel-calendar--start` },
|
|
32
|
-
h(PanelHeader, { value: this.startCalendarDateTime, mergedClsPrefix: mergedClsPrefix, calendarMonth: this.startCalendarMonth, calendarYear: this.startCalendarYear,
|
|
33
|
-
h("div", { class: `${mergedClsPrefix}-date-panel-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
82
|
+
h(PanelHeader, { value: this.startCalendarDateTime, mergedClsPrefix: mergedClsPrefix, isMonth: isMonthRange, isYear: isYearRange, calendarMonth: this.startCalendarMonth, calendarYear: this.startCalendarYear, onUpdateMonth: handleMonthStartClick, onUpdateYear: handleYearStartClick }),
|
|
83
|
+
isWithoutDay ? (h("div", { class: `${mergedClsPrefix}-date-panel-placeholder` })) : (h(Fragment, null,
|
|
84
|
+
h("div", { class: `${mergedClsPrefix}-date-panel-weekdays` }, this.weekdays.map((weekday) => (h("div", { key: weekday, class: `${mergedClsPrefix}-date-panel-weekdays__day` }, weekday)))),
|
|
85
|
+
h("div", { class: `${mergedClsPrefix}-date-panel-dates` }, this.startDateArray.map((dateItem, i) => (h("div", { "data-u-date": true, key: i, class: [
|
|
86
|
+
`${mergedClsPrefix}-date-panel-date`,
|
|
87
|
+
{
|
|
88
|
+
[`${mergedClsPrefix}-date-panel-date--excluded`]: !dateItem.inCurrentMonth,
|
|
89
|
+
[`${mergedClsPrefix}-date-panel-date--current`]: dateItem.isCurrentDate,
|
|
90
|
+
[`${mergedClsPrefix}-date-panel-date--selected`]: dateItem.selected,
|
|
91
|
+
[`${mergedClsPrefix}-date-panel-date--covered`]: dateItem.inSpan,
|
|
92
|
+
[`${mergedClsPrefix}-date-panel-date--start`]: dateItem.startOfSpan,
|
|
93
|
+
[`${mergedClsPrefix}-date-panel-date--end`]: dateItem.endOfSpan,
|
|
94
|
+
[`${mergedClsPrefix}-date-panel-date--disabled`]: this.mergedIsDateDisabled(dateItem.ts)
|
|
95
|
+
}
|
|
96
|
+
], onClick: () => {
|
|
97
|
+
this.handleDateClick(dateItem);
|
|
98
|
+
}, onMouseenter: () => {
|
|
99
|
+
this.handleDateMouseEnter(dateItem);
|
|
100
|
+
} },
|
|
101
|
+
h("div", { class: `${mergedClsPrefix}-date-panel-date__trigger` }),
|
|
102
|
+
dateItem.dateObject.date))))))),
|
|
52
103
|
h("div", { ref: "endDatesElRef", class: `${mergedClsPrefix}-date-panel-calendar ${mergedClsPrefix}-date-panel-calendar--end` },
|
|
53
|
-
h(PanelHeader, { value: this.endCalendarDateTime, mergedClsPrefix: mergedClsPrefix, calendarMonth: this.endCalendarMonth, calendarYear: this.endCalendarYear,
|
|
54
|
-
h("div", { class: `${mergedClsPrefix}-date-panel-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
104
|
+
h(PanelHeader, { value: this.endCalendarDateTime, mergedClsPrefix: mergedClsPrefix, isMonth: isMonthRange, isYear: isYearRange, calendarMonth: this.endCalendarMonth, calendarYear: this.endCalendarYear, onUpdateMonth: handleMonthEndClick, onUpdateYear: handleYearEndClick }),
|
|
105
|
+
isWithoutDay ? (h("div", { class: `${mergedClsPrefix}-date-panel-placeholder` })) : (h(Fragment, null,
|
|
106
|
+
h("div", { class: `${mergedClsPrefix}-date-panel-weekdays` }, this.weekdays.map((weekday) => (h("div", { key: weekday, class: `${mergedClsPrefix}-date-panel-weekdays__day` }, weekday)))),
|
|
107
|
+
h("div", { class: `${mergedClsPrefix}-date-panel-dates` }, this.endDateArray.map((dateItem, i) => (h("div", { "data-u-date": true, key: i, class: [
|
|
108
|
+
`${mergedClsPrefix}-date-panel-date`,
|
|
109
|
+
{
|
|
110
|
+
[`${mergedClsPrefix}-date-panel-date--excluded`]: !dateItem.inCurrentMonth,
|
|
111
|
+
[`${mergedClsPrefix}-date-panel-date--current`]: dateItem.isCurrentDate,
|
|
112
|
+
[`${mergedClsPrefix}-date-panel-date--selected`]: dateItem.selected,
|
|
113
|
+
[`${mergedClsPrefix}-date-panel-date--covered`]: dateItem.inSpan,
|
|
114
|
+
[`${mergedClsPrefix}-date-panel-date--start`]: dateItem.startOfSpan,
|
|
115
|
+
[`${mergedClsPrefix}-date-panel-date--end`]: dateItem.endOfSpan,
|
|
116
|
+
[`${mergedClsPrefix}-date-panel-date--disabled`]: this.mergedIsDateDisabled(dateItem.ts)
|
|
117
|
+
}
|
|
118
|
+
], onClick: () => {
|
|
119
|
+
this.handleDateClick(dateItem);
|
|
120
|
+
}, onMouseenter: () => {
|
|
121
|
+
this.handleDateMouseEnter(dateItem);
|
|
122
|
+
} },
|
|
123
|
+
h("div", { class: `${mergedClsPrefix}-date-panel-date__trigger` }),
|
|
124
|
+
dateItem.dateObject.date))))))),
|
|
73
125
|
this.datePickerSlots.footer ? (h("div", { class: `${mergedClsPrefix}-date-panel-footer` }, this.datePickerSlots.footer())) : null,
|
|
74
126
|
((_a = this.actions) === null || _a === void 0 ? void 0 : _a.length) || shortcuts ? (h("div", { class: `${mergedClsPrefix}-date-panel-actions` },
|
|
75
127
|
h("div", { class: `${mergedClsPrefix}-date-panel-actions__prefix` }, shortcuts &&
|
|
@@ -11,6 +11,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
11
11
|
};
|
|
12
12
|
readonly active: BooleanConstructor;
|
|
13
13
|
readonly dateFormat: StringConstructor;
|
|
14
|
+
readonly type: import("vue").PropType<import("../config").DatePickerType>;
|
|
14
15
|
readonly timeFormat: {
|
|
15
16
|
readonly type: StringConstructor;
|
|
16
17
|
readonly value: "HH:mm:ss";
|
|
@@ -33,7 +34,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
33
34
|
readonly onRender: import("vue").PropType<(() => void) | undefined>;
|
|
34
35
|
readonly panel: BooleanConstructor;
|
|
35
36
|
}, {
|
|
36
|
-
handleDateClick: (dateItem: import("../utils").
|
|
37
|
+
handleDateClick: (dateItem: import("../utils").DateCommonItem) => void;
|
|
37
38
|
handleDateInputBlur: () => void;
|
|
38
39
|
handleDateInput: (value: string) => void;
|
|
39
40
|
handleTimePickerChange: (value: number | null) => void;
|
|
@@ -1224,6 +1225,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
1224
1225
|
};
|
|
1225
1226
|
readonly active: BooleanConstructor;
|
|
1226
1227
|
readonly dateFormat: StringConstructor;
|
|
1228
|
+
readonly type: import("vue").PropType<import("../config").DatePickerType>;
|
|
1227
1229
|
readonly timeFormat: {
|
|
1228
1230
|
readonly type: StringConstructor;
|
|
1229
1231
|
readonly value: "HH:mm:ss";
|
|
@@ -8,6 +8,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
8
8
|
};
|
|
9
9
|
readonly active: BooleanConstructor;
|
|
10
10
|
readonly dateFormat: StringConstructor;
|
|
11
|
+
readonly type: import("vue").PropType<import("../config").DatePickerType>;
|
|
11
12
|
readonly timeFormat: {
|
|
12
13
|
readonly type: StringConstructor;
|
|
13
14
|
readonly value: "HH:mm:ss";
|
|
@@ -1261,6 +1262,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
1261
1262
|
};
|
|
1262
1263
|
readonly active: BooleanConstructor;
|
|
1263
1264
|
readonly dateFormat: StringConstructor;
|
|
1265
|
+
readonly type: import("vue").PropType<import("../config").DatePickerType>;
|
|
1264
1266
|
readonly timeFormat: {
|
|
1265
1267
|
readonly type: StringConstructor;
|
|
1266
1268
|
readonly value: "HH:mm:ss";
|