sard-uniapp 1.17.1 → 1.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/CHANGELOG.md +30 -0
- package/README.md +5 -0
- package/components/button/button.vue +3 -1
- package/components/button/common.d.ts +1 -0
- package/components/button/index.scss +9 -0
- package/components/calendar-month/calendar-month.vue +8 -8
- package/components/cascader/cascader.vue +7 -0
- package/components/cascader-input/cascader-input.vue +1 -1
- package/components/config/index.d.ts +1 -0
- package/components/config/index.js +1 -0
- package/components/crop-image/crop-image.vue +7 -7
- package/components/datetime-picker/common.d.ts +7 -3
- package/components/datetime-picker/common.js +181 -9
- package/components/datetime-picker/datetime-picker.d.ts +1 -0
- package/components/datetime-picker/datetime-picker.vue +116 -20
- package/components/datetime-picker-input/common.d.ts +1 -0
- package/components/datetime-picker-input/datetime-picker-input.d.ts +1 -0
- package/components/datetime-picker-input/datetime-picker-input.vue +2 -0
- package/components/datetime-picker-popout/common.d.ts +1 -0
- package/components/datetime-picker-popout/datetime-picker-popout.d.ts +1 -0
- package/components/datetime-picker-popout/datetime-picker-popout.vue +2 -0
- package/components/datetime-range-picker/datetime-range-picker.vue +1 -0
- package/components/datetime-range-picker-input/datetime-range-picker-input.vue +1 -0
- package/components/datetime-range-picker-popout/datetime-range-picker-popout.vue +1 -0
- package/components/dialog-agent/common.d.ts +3 -0
- package/components/dialog-agent/dialog-agent.vue +10 -1
- package/components/dropdown/common.d.ts +5 -1
- package/components/dropdown/index.d.ts +1 -1
- package/components/dropdown-item/dropdown-item.d.ts +5 -7
- package/components/dropdown-item/dropdown-item.vue +56 -22
- package/components/empty/empty.vue +1 -1
- package/components/fab/fab.vue +1 -1
- package/components/floating-bubble/floating-bubble.vue +4 -4
- package/components/form/form.vue +4 -1
- package/components/form-item/index.scss +10 -0
- package/components/grid-item/grid-item.vue +1 -1
- package/components/icon/icon.vue +9 -4
- package/components/list-item/list-item.vue +1 -1
- package/components/marquee/marquee.vue +8 -5
- package/components/menu-item/menu-item.vue +1 -1
- package/components/navbar-item/navbar-item.vue +1 -1
- package/components/notice-bar/notice-bar.vue +8 -5
- package/components/notify/notify.vue +10 -7
- package/components/picker-item/index.scss +0 -1
- package/components/pull-down-refresh/pull-down-refresh.vue +15 -9
- package/components/rate/rate.vue +2 -2
- package/components/result/result.vue +1 -1
- package/components/share-sheet/share-sheet.vue +1 -1
- package/components/step/step.vue +1 -1
- package/components/swipe-action/common.d.ts +23 -0
- package/components/swipe-action/common.js +1 -0
- package/components/swipe-action/index.d.ts +1 -0
- package/components/swipe-action/index.js +1 -0
- package/components/swipe-action/index.scss +53 -0
- package/components/swipe-action/swipe-action.d.ts +16 -0
- package/components/swipe-action/swipe-action.vue +275 -0
- package/components/swipe-action/variables.scss +3 -0
- package/components/tabbar-item/tabbar-item.vue +1 -5
- package/components/timeline-item/timeline-item.vue +1 -5
- package/components/toast/toast.vue +10 -7
- package/global.d.ts +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.scss +1 -0
- package/package.json +2 -7
- package/use/index.d.ts +3 -1
- package/use/index.js +3 -1
- package/use/useScrollSpy.js +4 -4
- package/use/useSimulatedClick.js +4 -4
- package/use/useSimulatedPress.js +5 -5
- package/use/useStopMovedClick.d.ts +6 -0
- package/use/useStopMovedClick.js +26 -0
- package/use/useTimeout.d.ts +11 -0
- package/use/useTimeout.js +39 -0
- package/use/useTimeoutLoading.js +9 -7
- package/utils/date.d.ts +33 -3
- package/utils/date.js +209 -11
- package/use/useSetTimeout.d.ts +0 -1
- package/use/useSetTimeout.js +0 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
# [1.19.0](https://github.com/sutras/sard-uniapp/compare/v1.18.0...v1.19.0) (2025-06-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* 修复 dialog 命令式回调选项参数问题 ([5af4fd8](https://github.com/sutras/sard-uniapp/commit/5af4fd81b6528501f2103b8db1b40a14f6186926))
|
|
7
|
+
* 修复 form fields 错乱删除问题 ([8250da9](https://github.com/sutras/sard-uniapp/commit/8250da9770152a4f6a93e873c70c01e13c91ce56))
|
|
8
|
+
* 修复cascader组件因值不存在时不显示列表的问题 ([4bae371](https://github.com/sutras/sard-uniapp/commit/4bae37167ccd88db3286d3bc233dfa250cfad4f9))
|
|
9
|
+
* 修复picker最后一列在安卓偏移问题 ([a041836](https://github.com/sutras/sard-uniapp/commit/a04183687b4291c04a0c5381dbc8fbf0b0f5afba))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* button 新增 square 属性 ([41db4ac](https://github.com/sutras/sard-uniapp/commit/41db4acd6804f52e02cff5eeb3eaaf005dfc7f5e))
|
|
15
|
+
* dropdown 新增 before-close 属性 ([3407a6b](https://github.com/sutras/sard-uniapp/commit/3407a6b5a9cb4038c7d63de9bfdb81498e6afd76))
|
|
16
|
+
* 新增 swipe-action 组件 ([9a390c6](https://github.com/sutras/sard-uniapp/commit/9a390c61d036a016d2ee8d706130589e3ca4009c))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# [1.18.0](https://github.com/sutras/sard-uniapp/compare/v1.17.1...v1.18.0) (2025-06-06)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* datetime-picker 组件新增农历类型 ([7b0f305](https://github.com/sutras/sard-uniapp/commit/7b0f305f57ff43f322ef4a398f95415a5a9e01e0))
|
|
26
|
+
* dropdown-item 组件新增显隐动画相关事件 ([83e8c52](https://github.com/sutras/sard-uniapp/commit/83e8c52e996bdc4901ea446b30d9273d0e5e956d))
|
|
27
|
+
* icon支持冒号分隔符名称属性 ([7ffcd90](https://github.com/sutras/sard-uniapp/commit/7ffcd9056e006cc353aadf5cb2831edde9515719))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
1
31
|
## [1.17.1](https://github.com/sutras/sard-uniapp/compare/v1.17.0...v1.17.1) (2025-05-30)
|
|
2
32
|
|
|
3
33
|
|
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
<sar-icon
|
|
43
43
|
v-else-if="icon"
|
|
44
44
|
:name="icon"
|
|
45
|
-
:family="iconFamily
|
|
45
|
+
:family="iconFamily"
|
|
46
46
|
:size="iconSize"
|
|
47
47
|
/>
|
|
48
48
|
</view>
|
|
@@ -79,6 +79,7 @@ export default _defineComponent({
|
|
|
79
79
|
theme: { type: String, required: false },
|
|
80
80
|
size: { type: String, required: false },
|
|
81
81
|
round: { type: Boolean, required: false },
|
|
82
|
+
square: { type: Boolean, required: false },
|
|
82
83
|
disabled: { type: Boolean, required: false },
|
|
83
84
|
loading: { type: Boolean, required: false },
|
|
84
85
|
loadingType: { type: String, required: false },
|
|
@@ -162,6 +163,7 @@ export default _defineComponent({
|
|
|
162
163
|
bem.m(props.type),
|
|
163
164
|
bem.m(`${props.type}-${props.theme}`),
|
|
164
165
|
bem.m("round", props.round),
|
|
166
|
+
bem.m("square", props.square),
|
|
165
167
|
bem.m("disabled", isDisabled.value),
|
|
166
168
|
bem.m("loading", props.loading),
|
|
167
169
|
bem.m("block", props.icon || props.inline ? false : props.block),
|
|
@@ -6,6 +6,7 @@ export interface ButtonProps {
|
|
|
6
6
|
theme?: 'primary' | 'secondary' | 'success' | 'info' | 'warning' | 'danger' | 'neutral';
|
|
7
7
|
size?: 'mini' | 'small' | 'medium' | 'large';
|
|
8
8
|
round?: boolean;
|
|
9
|
+
square?: boolean;
|
|
9
10
|
disabled?: boolean;
|
|
10
11
|
loading?: boolean;
|
|
11
12
|
loadingType?: 'clock' | 'circular';
|
|
@@ -190,6 +190,15 @@
|
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
// # 方形按钮
|
|
194
|
+
@include m(square) {
|
|
195
|
+
border-radius: 0;
|
|
196
|
+
|
|
197
|
+
&::after {
|
|
198
|
+
border-radius: 0;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
193
202
|
// # active 状态
|
|
194
203
|
@include m(default, pale, mild, outline, text) {
|
|
195
204
|
&:not(#{bem($b: button, $m: disabled)}):not(
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
import { defineComponent as _defineComponent } from "vue";
|
|
35
35
|
import { computed } from "vue";
|
|
36
36
|
import {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
getMonthDays,
|
|
38
|
+
getOffsetDaysFromMonthStart,
|
|
39
|
+
getWeekOfMonthStart,
|
|
40
40
|
getPadStartDays,
|
|
41
41
|
getPadEndDays,
|
|
42
42
|
toDateNumber,
|
|
@@ -72,11 +72,11 @@ export default _defineComponent({
|
|
|
72
72
|
const props = __props;
|
|
73
73
|
const emit = __emit;
|
|
74
74
|
const days = computed(() => {
|
|
75
|
-
return
|
|
75
|
+
return getMonthDays(props.year, props.month + 1);
|
|
76
76
|
});
|
|
77
77
|
const offsetDays = computed(() => {
|
|
78
|
-
return
|
|
79
|
-
|
|
78
|
+
return getOffsetDaysFromMonthStart(
|
|
79
|
+
getWeekOfMonthStart(props.year, props.month + 1),
|
|
80
80
|
props.weekStartsOn
|
|
81
81
|
);
|
|
82
82
|
});
|
|
@@ -87,12 +87,12 @@ export default _defineComponent({
|
|
|
87
87
|
}
|
|
88
88
|
const padStartDays = getPadStartDays(
|
|
89
89
|
props.year,
|
|
90
|
-
props.month,
|
|
90
|
+
props.month + 1,
|
|
91
91
|
offsetDays.value
|
|
92
92
|
);
|
|
93
93
|
const padEndDays = getPadEndDays(
|
|
94
94
|
props.year,
|
|
95
|
-
props.month,
|
|
95
|
+
props.month + 1,
|
|
96
96
|
42 - offsetDays.value - days.value
|
|
97
97
|
);
|
|
98
98
|
return [...padStartDays, ...currentDays, ...padEndDays];
|
|
@@ -103,7 +103,7 @@ export default _defineComponent({
|
|
|
103
103
|
function getOutletText(options, value, fieldKeys) {
|
|
104
104
|
const selectedOptions = getSelectedOptionsByValue(options, value, fieldKeys);
|
|
105
105
|
if (!selectedOptions) {
|
|
106
|
-
return "";
|
|
106
|
+
return isNullish(value) ? "" : String(value);
|
|
107
107
|
}
|
|
108
108
|
const labels = selectedOptions.map((option) => option[fieldKeys.label]);
|
|
109
109
|
return labels.join("/");
|
|
@@ -109,7 +109,7 @@ import {
|
|
|
109
109
|
import {
|
|
110
110
|
defaultCropImageProps
|
|
111
111
|
} from "./common";
|
|
112
|
-
import { useDragPinch,
|
|
112
|
+
import { useDragPinch, useTimeout } from "../../use";
|
|
113
113
|
import { useTranslate } from "../locale";
|
|
114
114
|
import SarPopup from "../popup/popup.vue";
|
|
115
115
|
import SarIcon from "../icon/icon.vue";
|
|
@@ -186,23 +186,23 @@ export default _defineComponent({
|
|
|
186
186
|
});
|
|
187
187
|
const rotate = ref(0);
|
|
188
188
|
const actualRotate = ref(0);
|
|
189
|
-
const
|
|
189
|
+
const { start: onRotateEnd } = useTimeout(() => {
|
|
190
190
|
actualRotate.value = rotate.value;
|
|
191
|
-
});
|
|
191
|
+
}, 150 + 100);
|
|
192
192
|
watch(rotate, () => {
|
|
193
|
-
onRotateEnd(
|
|
193
|
+
onRotateEnd();
|
|
194
194
|
});
|
|
195
195
|
const isRotating = computed(() => rotate.value !== actualRotate.value);
|
|
196
196
|
const isStillRotating = ref(false);
|
|
197
|
-
const
|
|
197
|
+
const { start: stopRotateLater, stop: cancelStopRotate } = useTimeout(() => {
|
|
198
198
|
isStillRotating.value = false;
|
|
199
|
-
});
|
|
199
|
+
}, 150);
|
|
200
200
|
watch(isRotating, () => {
|
|
201
201
|
cancelStopRotate();
|
|
202
202
|
if (isRotating.value) {
|
|
203
203
|
isStillRotating.value = true;
|
|
204
204
|
} else {
|
|
205
|
-
stopRotateLater(
|
|
205
|
+
stopRotateLater();
|
|
206
206
|
}
|
|
207
207
|
});
|
|
208
208
|
const maskStyle = computed(() => {
|
|
@@ -4,6 +4,7 @@ export interface DatetimePickerProps {
|
|
|
4
4
|
rootStyle?: StyleValue;
|
|
5
5
|
rootClass?: string;
|
|
6
6
|
type?: string;
|
|
7
|
+
calendar?: 'solar' | 'lunar';
|
|
7
8
|
min?: Date | string;
|
|
8
9
|
max?: Date | string;
|
|
9
10
|
modelValue?: Date | string;
|
|
@@ -13,6 +14,7 @@ export interface DatetimePickerProps {
|
|
|
13
14
|
}
|
|
14
15
|
export declare const defaultDatetimePickerProps: {
|
|
15
16
|
type: string;
|
|
17
|
+
calendar: "solar";
|
|
16
18
|
};
|
|
17
19
|
export interface DatetimePickerSlots extends PickerSlots {
|
|
18
20
|
}
|
|
@@ -42,8 +44,10 @@ interface Strategies {
|
|
|
42
44
|
}
|
|
43
45
|
export declare const strategies: Strategies;
|
|
44
46
|
export declare const letterArray: DatetimeLetter[];
|
|
45
|
-
export declare function getBoundaryValue(isMax: boolean, endDate: Date, currentDate: Date): number[];
|
|
46
|
-
export declare function
|
|
47
|
-
export declare
|
|
47
|
+
export declare function getBoundaryValue(calendar: 'solar' | 'lunar', isMax: boolean, endDate: Date, currentDate: Date): number[];
|
|
48
|
+
export declare function correctSolarDate(date: DateEvery, minDate: Date, maxDate: Date): void;
|
|
49
|
+
export declare function correctLunarDate(date: DateEvery, minDate: Date, maxDate: Date): void;
|
|
50
|
+
export declare function correctDate(calendar: 'solar' | 'lunar', date: DateEvery, minDate: Date, maxDate: Date): void;
|
|
51
|
+
export declare const getColumnData: (calendar: "solar" | "lunar", min: number, max: number, length: number, letter: DatetimeLetter, currentDate: Date, translate: (...args: any[]) => any, filter?: (letter: DatetimeLetter, value: number, date: Date, index: number) => boolean, formatter?: (letter: DatetimeLetter, option: DatetimeColumnOption, date: Date, index: number) => string | void | undefined) => DatetimeColumnOption[];
|
|
48
52
|
export declare function getInitialValue(minDate: Date, maxDate: Date): Date;
|
|
49
53
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getLunarDayName, getLunarLeapMonth, getLunarLeapMonthDays, getLunarMonthDays, getLunarMonthName, getMonthDays, minmax, solarToLunar, } from '../../utils';
|
|
2
2
|
import { defaultConfig } from '../config';
|
|
3
3
|
export const defaultDatetimePickerProps = defaultConfig.datetimePicker;
|
|
4
4
|
export const getMinDate = () => {
|
|
@@ -16,7 +16,7 @@ export const strategies = {
|
|
|
16
16
|
s: [5, 2, 0, 59, (d) => d.getSeconds(), (d, val) => d.setSeconds(val)],
|
|
17
17
|
};
|
|
18
18
|
export const letterArray = ['y', 'M', 'd', 'h', 'm', 's'];
|
|
19
|
-
|
|
19
|
+
function getSolarBoundaryValue(isMax, endDate, currentDate) {
|
|
20
20
|
const currEvery = [endDate.getFullYear()];
|
|
21
21
|
const minOrMaxIndex = isMax ? 3 : 2;
|
|
22
22
|
let aside = true;
|
|
@@ -25,7 +25,7 @@ export function getBoundaryValue(isMax, endDate, currentDate) {
|
|
|
25
25
|
const strategy = strategies[letter];
|
|
26
26
|
let minOrMax = strategy[minOrMaxIndex];
|
|
27
27
|
if (isMax && letter === 'd') {
|
|
28
|
-
minOrMax =
|
|
28
|
+
minOrMax = getMonthDays(currentDate.getFullYear(), currentDate.getMonth() + 1);
|
|
29
29
|
}
|
|
30
30
|
aside = aside && currEvery[index] === prevGetter(currentDate);
|
|
31
31
|
currEvery[index + 1] = aside ? strategy[4](endDate) : minOrMax;
|
|
@@ -33,7 +33,56 @@ export function getBoundaryValue(isMax, endDate, currentDate) {
|
|
|
33
33
|
});
|
|
34
34
|
return currEvery;
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
function getLunarBoundaryValue(isMax, endDate, currentDate) {
|
|
37
|
+
const lunarDate = solarToLunar(currentDate.getFullYear(), currentDate.getMonth() + 1, currentDate.getDate());
|
|
38
|
+
const lunarEndDate = solarToLunar(endDate.getFullYear(), endDate.getMonth() + 1, endDate.getDate());
|
|
39
|
+
const currEvery = [lunarEndDate.year];
|
|
40
|
+
const minOrMaxIndex = isMax ? 3 : 2;
|
|
41
|
+
let aside = true;
|
|
42
|
+
let prevGetter = strategies.y[4];
|
|
43
|
+
letterArray.slice(1).forEach((letter, index) => {
|
|
44
|
+
const prevValue = currEvery[index];
|
|
45
|
+
const strategy = strategies[letter];
|
|
46
|
+
const currGetter = strategy[4];
|
|
47
|
+
let minOrMax = strategy[minOrMaxIndex];
|
|
48
|
+
if (isMax && letter === 'd') {
|
|
49
|
+
minOrMax =
|
|
50
|
+
lunarDate.month < 0
|
|
51
|
+
? getLunarLeapMonthDays(lunarDate.year)
|
|
52
|
+
: getLunarMonthDays(lunarDate.year, lunarDate.month);
|
|
53
|
+
}
|
|
54
|
+
let asideValue = 0;
|
|
55
|
+
if (aside) {
|
|
56
|
+
if (letter === 'M') {
|
|
57
|
+
aside = lunarDate.year === prevValue;
|
|
58
|
+
if (aside) {
|
|
59
|
+
asideValue = lunarEndDate.month;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if (letter === 'd') {
|
|
63
|
+
aside = lunarDate.month === prevValue;
|
|
64
|
+
if (aside) {
|
|
65
|
+
asideValue = lunarEndDate.day;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
aside = prevGetter(currentDate) === prevValue;
|
|
70
|
+
if (aside) {
|
|
71
|
+
asideValue = currGetter(currentDate);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
currEvery[index + 1] = aside ? asideValue : minOrMax;
|
|
76
|
+
prevGetter = currGetter;
|
|
77
|
+
});
|
|
78
|
+
return currEvery;
|
|
79
|
+
}
|
|
80
|
+
export function getBoundaryValue(calendar, isMax, endDate, currentDate) {
|
|
81
|
+
return calendar === 'solar'
|
|
82
|
+
? getSolarBoundaryValue(isMax, endDate, currentDate)
|
|
83
|
+
: getLunarBoundaryValue(isMax, endDate, currentDate);
|
|
84
|
+
}
|
|
85
|
+
export function correctSolarDate(date, minDate, maxDate) {
|
|
37
86
|
let minAside = true;
|
|
38
87
|
let maxAside = true;
|
|
39
88
|
let prevGetter = strategies.y[4];
|
|
@@ -42,7 +91,7 @@ export function correctDate(date, minDate, maxDate) {
|
|
|
42
91
|
let minValue = strategy[2];
|
|
43
92
|
let maxValue = strategy[3];
|
|
44
93
|
if (letter === 'd') {
|
|
45
|
-
maxValue =
|
|
94
|
+
maxValue = getMonthDays(date[0], date[1]);
|
|
46
95
|
}
|
|
47
96
|
const currGetter = strategy[4];
|
|
48
97
|
if ((minAside = minAside && prevGetter(minDate) === date[index])) {
|
|
@@ -55,18 +104,141 @@ export function correctDate(date, minDate, maxDate) {
|
|
|
55
104
|
prevGetter = currGetter;
|
|
56
105
|
});
|
|
57
106
|
}
|
|
58
|
-
export
|
|
59
|
-
|
|
107
|
+
export function correctLunarDate(date, minDate, maxDate) {
|
|
108
|
+
const lunarMinDate = solarToLunar(minDate.getFullYear(), minDate.getMonth() + 1, minDate.getDate());
|
|
109
|
+
const lunarMaxDate = solarToLunar(maxDate.getFullYear(), maxDate.getMonth() + 1, maxDate.getDate());
|
|
110
|
+
const range = [
|
|
111
|
+
{
|
|
112
|
+
value: 0,
|
|
113
|
+
edge: true,
|
|
114
|
+
date: minDate,
|
|
115
|
+
lunarDate: lunarMinDate,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
value: 0,
|
|
119
|
+
edge: true,
|
|
120
|
+
date: maxDate,
|
|
121
|
+
lunarDate: lunarMaxDate,
|
|
122
|
+
},
|
|
123
|
+
];
|
|
124
|
+
let prevGetter = strategies.y[4];
|
|
125
|
+
letterArray.slice(1).forEach((letter, index) => {
|
|
126
|
+
const prevValue = date[index];
|
|
127
|
+
const currIndex = index + 1;
|
|
128
|
+
const currValue = date[currIndex];
|
|
129
|
+
const strategy = strategies[letter];
|
|
130
|
+
range[0].value = strategy[2];
|
|
131
|
+
range[1].value = strategy[3];
|
|
132
|
+
if (letter === 'd') {
|
|
133
|
+
range[1].value =
|
|
134
|
+
date[1] < 0
|
|
135
|
+
? getLunarLeapMonthDays(date[0])
|
|
136
|
+
: getLunarMonthDays(date[0], date[1]);
|
|
137
|
+
}
|
|
138
|
+
let currGetter = strategy[4];
|
|
139
|
+
range.forEach((point) => {
|
|
140
|
+
if (point.edge) {
|
|
141
|
+
if (letter === 'M') {
|
|
142
|
+
point.edge = point.lunarDate.year === prevValue;
|
|
143
|
+
if (point.edge) {
|
|
144
|
+
point.value = point.lunarDate.month;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else if (letter === 'd') {
|
|
148
|
+
point.edge = point.lunarDate.month === prevValue;
|
|
149
|
+
if (point.edge) {
|
|
150
|
+
point.value = point.lunarDate.day;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
point.edge = prevGetter(point.date) === prevValue;
|
|
155
|
+
if (point.edge) {
|
|
156
|
+
point.value = currGetter(point.date);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
if (letter === 'M') {
|
|
162
|
+
let min = range[0].value;
|
|
163
|
+
let max = range[1].value;
|
|
164
|
+
let value = currValue;
|
|
165
|
+
if (min < 0) {
|
|
166
|
+
min = Math.abs(min) + 0.5;
|
|
167
|
+
}
|
|
168
|
+
else if (max < 0) {
|
|
169
|
+
max = Math.abs(max) + 0.5;
|
|
170
|
+
}
|
|
171
|
+
if (value < 0) {
|
|
172
|
+
value = Math.abs(value) + 0.5;
|
|
173
|
+
}
|
|
174
|
+
value = minmax(value, min, max);
|
|
175
|
+
date[currIndex] = value % 1 === 0.5 ? ~~value * -1 : value;
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
date[currIndex] = minmax(currValue, range[0].value, range[1].value);
|
|
179
|
+
}
|
|
180
|
+
if (letter === 'd') {
|
|
181
|
+
currGetter = (date) => {
|
|
182
|
+
return date === minDate ? lunarMinDate.day : lunarMaxDate.day;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
prevGetter = currGetter;
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
export function correctDate(calendar, date, minDate, maxDate) {
|
|
189
|
+
if (calendar === 'solar') {
|
|
190
|
+
correctSolarDate(date, minDate, maxDate);
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
correctLunarDate(date, minDate, maxDate);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
export const getColumnData = (calendar, min, max, length, letter, currentDate, translate, filter, formatter) => {
|
|
197
|
+
const lunarDate = solarToLunar(currentDate.getFullYear(), currentDate.getMonth() + 1, currentDate.getDate());
|
|
198
|
+
let column = Array(Math.abs(max) - Math.abs(min) + 1)
|
|
60
199
|
.fill(0)
|
|
61
200
|
.map((_, i) => ({
|
|
62
|
-
value: i +
|
|
201
|
+
value: i + Math.abs(min),
|
|
63
202
|
}));
|
|
203
|
+
if (calendar === 'lunar' && letter === 'M') {
|
|
204
|
+
if (min < 0) {
|
|
205
|
+
column[0].value = min;
|
|
206
|
+
}
|
|
207
|
+
else if (max < 0) {
|
|
208
|
+
column.push({
|
|
209
|
+
value: max,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
const leapMonth = getLunarLeapMonth(lunarDate.year);
|
|
214
|
+
if (leapMonth > 0 && leapMonth > min && leapMonth < max) {
|
|
215
|
+
column.splice(column.findIndex((item) => item.value === leapMonth) + 1, 0, {
|
|
216
|
+
value: -leapMonth,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
64
221
|
if (filter) {
|
|
65
222
|
column = column.filter((option, i) => filter(letter, option.value, currentDate, i));
|
|
66
223
|
}
|
|
67
224
|
column.forEach((option) => {
|
|
68
225
|
option.zerofill = String(option.value).padStart(length, '0');
|
|
69
|
-
|
|
226
|
+
if (calendar === 'solar') {
|
|
227
|
+
option.label = option.zerofill + translate(letter);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
switch (letter) {
|
|
231
|
+
case 'M':
|
|
232
|
+
option.label = getLunarMonthName(Math.abs(option.value), option.value < 0);
|
|
233
|
+
break;
|
|
234
|
+
case 'd':
|
|
235
|
+
option.label = getLunarDayName(option.value);
|
|
236
|
+
break;
|
|
237
|
+
default:
|
|
238
|
+
option.label = option.zerofill + translate(letter);
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
70
242
|
});
|
|
71
243
|
if (formatter) {
|
|
72
244
|
column.forEach((option, i) => {
|
|
@@ -8,6 +8,7 @@ declare const __VLS_component: import("vue").DefineComponent<DatetimePickerProps
|
|
|
8
8
|
onChange?: ((date: string | Date) => any) | undefined;
|
|
9
9
|
}>, {
|
|
10
10
|
type: string;
|
|
11
|
+
calendar: "solar" | "lunar";
|
|
11
12
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
13
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
13
14
|
export default _default;
|