sard 1.2.0 → 1.2.2
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/components/accordion/style.d.ts +3 -0
- package/components/accordion/style.js +3 -0
- package/components/action-sheet/style.d.ts +6 -0
- package/components/action-sheet/style.js +6 -0
- package/components/alert/style.d.ts +2 -0
- package/components/alert/style.js +2 -0
- package/components/avatar/style.d.ts +2 -0
- package/components/avatar/style.js +2 -0
- package/components/back-top/style.d.ts +2 -0
- package/components/back-top/style.js +2 -0
- package/components/badge/style.d.ts +2 -0
- package/components/badge/style.js +2 -0
- package/components/barcode/style.d.ts +2 -0
- package/components/barcode/style.js +2 -0
- package/components/button/style.d.ts +3 -0
- package/components/button/style.js +3 -0
- package/components/calendar/style.d.ts +10 -0
- package/components/calendar/style.js +10 -0
- package/components/calendar-input/style.d.ts +12 -0
- package/components/calendar-input/style.js +12 -0
- package/components/calendar-popout/style.d.ts +10 -0
- package/components/calendar-popout/style.js +10 -0
- package/components/card/style.d.ts +5 -0
- package/components/card/style.js +5 -0
- package/components/cascader/style.d.ts +6 -0
- package/components/cascader/style.js +6 -0
- package/components/cascader-input/style.d.ts +13 -0
- package/components/cascader-input/style.js +13 -0
- package/components/cascader-popout/style.d.ts +11 -0
- package/components/cascader-popout/style.js +11 -0
- package/components/check-icon/style.d.ts +2 -0
- package/components/check-icon/style.js +2 -0
- package/components/checkbox/style.d.ts +3 -0
- package/components/checkbox/style.js +3 -0
- package/components/checkbox-input/style.d.ts +13 -0
- package/components/checkbox-input/style.js +13 -0
- package/components/checkbox-popout/style.d.ts +12 -0
- package/components/checkbox-popout/style.js +12 -0
- package/components/collapse/style.d.ts +2 -0
- package/components/collapse/style.js +2 -0
- package/components/color-picker/style.d.ts +5 -0
- package/components/color-picker/style.js +5 -0
- package/components/color-picker-input/style.d.ts +14 -0
- package/components/color-picker-input/style.js +14 -0
- package/components/color-picker-popout/style.d.ts +11 -0
- package/components/color-picker-popout/style.js +11 -0
- package/components/compact/style.d.ts +2 -0
- package/components/compact/style.js +2 -0
- package/components/cool-icon/style.d.ts +2 -0
- package/components/cool-icon/style.js +2 -0
- package/components/count-down/style.d.ts +2 -0
- package/components/count-down/style.js +2 -0
- package/components/crop-image/style.d.ts +7 -0
- package/components/crop-image/style.js +7 -0
- package/components/danmaku/index.css +1 -1
- package/components/danmaku/style.d.ts +2 -0
- package/components/danmaku/style.js +2 -0
- package/components/date-strip/style.d.ts +2 -0
- package/components/date-strip/style.js +2 -0
- package/components/datetime-picker/style.d.ts +3 -0
- package/components/datetime-picker/style.js +3 -0
- package/components/datetime-picker-input/style.d.ts +11 -0
- package/components/datetime-picker-input/style.js +11 -0
- package/components/datetime-picker-popout/style.d.ts +9 -0
- package/components/datetime-picker-popout/style.js +9 -0
- package/components/datetime-range-picker/style.d.ts +5 -0
- package/components/datetime-range-picker/style.js +5 -0
- package/components/datetime-range-picker-input/style.d.ts +13 -0
- package/components/datetime-range-picker-input/style.js +13 -0
- package/components/datetime-range-picker-popout/style.d.ts +11 -0
- package/components/datetime-range-picker-popout/style.js +11 -0
- package/components/descriptions/style.d.ts +2 -0
- package/components/descriptions/style.js +2 -0
- package/components/dialog/style.d.ts +7 -0
- package/components/dialog/style.js +7 -0
- package/components/divider/style.d.ts +2 -0
- package/components/divider/style.js +2 -0
- package/components/dnd/style.d.ts +2 -0
- package/components/dnd/style.js +2 -0
- package/components/dropdown/style.d.ts +5 -0
- package/components/dropdown/style.js +5 -0
- package/components/ellipsis/style.d.ts +2 -0
- package/components/ellipsis/style.js +2 -0
- package/components/empty/style.d.ts +2 -0
- package/components/empty/style.js +2 -0
- package/components/fab/style.d.ts +4 -0
- package/components/fab/style.js +4 -0
- package/components/flex/style.d.ts +2 -0
- package/components/flex/style.js +2 -0
- package/components/floating-bubble/style.d.ts +2 -0
- package/components/floating-bubble/style.js +2 -0
- package/components/floating-panel/style.d.ts +2 -0
- package/components/floating-panel/style.js +2 -0
- package/components/form/style.d.ts +2 -0
- package/components/form/style.js +2 -0
- package/components/grid/style.d.ts +2 -0
- package/components/grid/style.js +2 -0
- package/components/image/style.d.ts +2 -0
- package/components/image/style.js +2 -0
- package/components/indexes/style.d.ts +3 -0
- package/components/indexes/style.js +3 -0
- package/components/infinite-list/style.d.ts +5 -0
- package/components/infinite-list/style.js +5 -0
- package/components/input/style.d.ts +2 -0
- package/components/input/style.js +2 -0
- package/components/keyboard/style.d.ts +2 -0
- package/components/keyboard/style.js +2 -0
- package/components/keyboard-popout/style.d.ts +9 -0
- package/components/keyboard-popout/style.js +9 -0
- package/components/layout/style.d.ts +2 -0
- package/components/layout/style.js +2 -0
- package/components/list/style.d.ts +2 -0
- package/components/list/style.js +2 -0
- package/components/load-more/style.d.ts +3 -0
- package/components/load-more/style.js +3 -0
- package/components/loading/style.d.ts +2 -0
- package/components/loading/style.js +2 -0
- package/components/marquee/style.d.ts +2 -0
- package/components/marquee/style.js +2 -0
- package/components/menu/style.d.ts +2 -0
- package/components/menu/style.js +2 -0
- package/components/motion/style.d.ts +2 -0
- package/components/motion/style.js +2 -0
- package/components/navbar/style.d.ts +4 -0
- package/components/navbar/style.js +4 -0
- package/components/navbar-pit/style.d.ts +3 -0
- package/components/navbar-pit/style.js +3 -0
- package/components/notice-bar/style.d.ts +2 -0
- package/components/notice-bar/style.js +2 -0
- package/components/notify/style.d.ts +6 -0
- package/components/notify/style.js +6 -0
- package/components/overlay/style.d.ts +3 -0
- package/components/overlay/style.js +3 -0
- package/components/pagination/style.d.ts +2 -0
- package/components/pagination/style.js +2 -0
- package/components/password-input/style.d.ts +2 -0
- package/components/password-input/style.js +2 -0
- package/components/picker/style.d.ts +3 -0
- package/components/picker/style.js +3 -0
- package/components/picker-input/style.d.ts +11 -0
- package/components/picker-input/style.js +11 -0
- package/components/picker-popout/style.d.ts +9 -0
- package/components/picker-popout/style.js +9 -0
- package/components/picker-view/style.d.ts +2 -0
- package/components/picker-view/style.js +2 -0
- package/components/popout/style.d.ts +7 -0
- package/components/popout/style.js +7 -0
- package/components/popout-input/style.d.ts +4 -0
- package/components/popout-input/style.js +4 -0
- package/components/popover/style.d.ts +3 -0
- package/components/popover/style.js +3 -0
- package/components/popup/style.d.ts +4 -0
- package/components/popup/style.js +4 -0
- package/components/preview-image/style.d.ts +6 -0
- package/components/preview-image/style.js +6 -0
- package/components/progress-bar/style.d.ts +2 -0
- package/components/progress-bar/style.js +2 -0
- package/components/progress-circle/style.d.ts +2 -0
- package/components/progress-circle/style.js +2 -0
- package/components/pull-down-refresh/style.d.ts +3 -0
- package/components/pull-down-refresh/style.js +3 -0
- package/components/puzzle-verify/style.d.ts +4 -0
- package/components/puzzle-verify/style.js +4 -0
- package/components/qrcode/style.d.ts +2 -0
- package/components/qrcode/style.js +2 -0
- package/components/radio/style.d.ts +3 -0
- package/components/radio/style.js +3 -0
- package/components/radio-input/style.d.ts +13 -0
- package/components/radio-input/style.js +13 -0
- package/components/radio-popout/style.d.ts +12 -0
- package/components/radio-popout/style.js +12 -0
- package/components/rate/style.d.ts +2 -0
- package/components/rate/style.js +2 -0
- package/components/read-more/style.d.ts +4 -0
- package/components/read-more/style.js +4 -0
- package/components/result/style.d.ts +2 -0
- package/components/result/style.js +2 -0
- package/components/rotate-verify/style.d.ts +4 -0
- package/components/rotate-verify/style.js +4 -0
- package/components/scroll-list/style.d.ts +2 -0
- package/components/scroll-list/style.js +2 -0
- package/components/scroll-spy/style.d.ts +2 -0
- package/components/scroll-spy/style.js +2 -0
- package/components/search/style.d.ts +5 -0
- package/components/search/style.js +5 -0
- package/components/segmented/style.d.ts +3 -0
- package/components/segmented/style.js +3 -0
- package/components/select/style.d.ts +9 -0
- package/components/select/style.js +9 -0
- package/components/select-input/style.d.ts +11 -0
- package/components/select-input/style.js +11 -0
- package/components/select-popout/style.d.ts +10 -0
- package/components/select-popout/style.js +10 -0
- package/components/share-sheet/style.d.ts +5 -0
- package/components/share-sheet/style.js +5 -0
- package/components/sidebar/style.d.ts +2 -0
- package/components/sidebar/style.js +2 -0
- package/components/signature/style.d.ts +5 -0
- package/components/signature/style.js +5 -0
- package/components/skeleton/style.d.ts +2 -0
- package/components/skeleton/style.js +2 -0
- package/components/slide-verify/style.d.ts +3 -0
- package/components/slide-verify/style.js +3 -0
- package/components/slider/style.d.ts +2 -0
- package/components/slider/style.js +2 -0
- package/components/status-bar/style.d.ts +2 -0
- package/components/status-bar/style.js +2 -0
- package/components/stepper/style.d.ts +3 -0
- package/components/stepper/style.js +3 -0
- package/components/steps/style.d.ts +2 -0
- package/components/steps/style.js +2 -0
- package/components/sticky/style.d.ts +2 -0
- package/components/sticky/style.js +2 -0
- package/components/swipe-action/style.d.ts +2 -0
- package/components/swipe-action/style.js +2 -0
- package/components/swiper/style.d.ts +2 -0
- package/components/swiper/style.js +2 -0
- package/components/switch/style.d.ts +3 -0
- package/components/switch/style.js +3 -0
- package/components/tabbar/style.d.ts +2 -0
- package/components/tabbar/style.js +2 -0
- package/components/tabbar-pit/style.d.ts +2 -0
- package/components/tabbar-pit/style.js +2 -0
- package/components/table/style.d.ts +2 -0
- package/components/table/style.js +2 -0
- package/components/tabs/style.d.ts +2 -0
- package/components/tabs/style.js +2 -0
- package/components/tag/style.d.ts +2 -0
- package/components/tag/style.js +2 -0
- package/components/text/style.d.ts +2 -0
- package/components/text/style.js +2 -0
- package/components/text-shrink/style.d.ts +2 -0
- package/components/text-shrink/style.js +2 -0
- package/components/timeline/style.d.ts +2 -0
- package/components/timeline/style.js +2 -0
- package/components/toast/style.d.ts +6 -0
- package/components/toast/style.js +6 -0
- package/components/tree/style.d.ts +16 -0
- package/components/tree/style.js +16 -0
- package/components/upload/style.d.ts +3 -0
- package/components/upload/style.js +3 -0
- package/components/waterfall/style.d.ts +2 -0
- package/components/waterfall/style.js +2 -0
- package/components/watermark/style.d.ts +2 -0
- package/components/watermark/style.js +2 -0
- package/global.d.ts +16 -0
- package/index.css +1 -1
- package/locale/index.js +3 -2
- package/package.json +8 -4
- package/utils/date.d.ts +0 -3
- package/utils/date.js +33 -14
package/locale/index.js
CHANGED
|
@@ -3,10 +3,11 @@ import { interpolate } from "../utils/string.js";
|
|
|
3
3
|
import zh_CN_default from "./lang/zh-CN.js";
|
|
4
4
|
import { computed, inject, ref, shallowRef, watch } from "vue";
|
|
5
5
|
//#region packages/sard/locale/index.ts
|
|
6
|
-
const
|
|
6
|
+
const defaultLocale = typeof __SARD_DEFAULT_LANG__ === "undefined" || __SARD_DEFAULT_LANG__ ? zh_CN_default : {};
|
|
7
|
+
const currentLocale = shallowRef(defaultLocale);
|
|
7
8
|
function useTranslate(prefix = "") {
|
|
8
9
|
const locale = computed(() => {
|
|
9
|
-
return currentLocale.value ||
|
|
10
|
+
return currentLocale.value || defaultLocale;
|
|
10
11
|
});
|
|
11
12
|
const translate = (chainOrData, data) => {
|
|
12
13
|
const chain = typeof chainOrData === "string" ? prefix ? prefix + "." + chainOrData : chainOrData : prefix;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sard",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "sard 是基于 Vue3 的 Web 移动端 UI 组件库",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"UI",
|
|
@@ -16,14 +16,18 @@
|
|
|
16
16
|
"files": [
|
|
17
17
|
"*"
|
|
18
18
|
],
|
|
19
|
-
"sideEffects":
|
|
19
|
+
"sideEffects": [
|
|
20
|
+
"**/*.css",
|
|
21
|
+
"**/*.scss",
|
|
22
|
+
"**/style.*"
|
|
23
|
+
],
|
|
20
24
|
"main": "index.js",
|
|
21
25
|
"devDependencies": {
|
|
22
|
-
"@sard/icons": "^0.1.
|
|
26
|
+
"@sard/icons": "^0.1.1",
|
|
23
27
|
"vue": "^3.5.0"
|
|
24
28
|
},
|
|
25
29
|
"peerDependencies": {
|
|
26
|
-
"@sard/icons": "^0.1.
|
|
30
|
+
"@sard/icons": "^0.1.1",
|
|
27
31
|
"vue": "^3.5.0"
|
|
28
32
|
}
|
|
29
33
|
}
|
package/utils/date.d.ts
CHANGED
|
@@ -61,9 +61,6 @@ export declare function toDate(date: Date | string | number, valueFormat?: strin
|
|
|
61
61
|
export declare function minmaxDate(date: Date, minDate: Date, maxDate: Date): Date;
|
|
62
62
|
export declare function getPrevMonthDate(date: Date): Date;
|
|
63
63
|
export declare function getNextMonthDate(date: Date): Date;
|
|
64
|
-
/****************************************************************
|
|
65
|
-
* 农历
|
|
66
|
-
****************************************************************/
|
|
67
64
|
export declare const lunarInfo: number[];
|
|
68
65
|
export declare const springFestivals: number[][];
|
|
69
66
|
export declare const baseLunarYear = 1900;
|
package/utils/date.js
CHANGED
|
@@ -199,7 +199,8 @@ function getNextMonthDate(date) {
|
|
|
199
199
|
/****************************************************************
|
|
200
200
|
* 农历
|
|
201
201
|
****************************************************************/
|
|
202
|
-
const
|
|
202
|
+
const lunarEnabled = typeof __SARD_LUNAR__ === "undefined" || __SARD_LUNAR__;
|
|
203
|
+
const lunarInfo = lunarEnabled ? [
|
|
203
204
|
19416,
|
|
204
205
|
19168,
|
|
205
206
|
42352,
|
|
@@ -401,8 +402,8 @@ const lunarInfo = [
|
|
|
401
402
|
53584,
|
|
402
403
|
62034,
|
|
403
404
|
54560
|
|
404
|
-
];
|
|
405
|
-
const springFestivals = [
|
|
405
|
+
] : [];
|
|
406
|
+
const springFestivals = lunarEnabled ? [
|
|
406
407
|
[1, 31],
|
|
407
408
|
[2, 19],
|
|
408
409
|
[2, 8],
|
|
@@ -604,18 +605,20 @@ const springFestivals = [
|
|
|
604
605
|
[2, 1],
|
|
605
606
|
[1, 21],
|
|
606
607
|
[2, 9]
|
|
607
|
-
];
|
|
608
|
+
] : [];
|
|
608
609
|
const baseLunarYear = 1900;
|
|
609
610
|
/**
|
|
610
611
|
* 获取农历某年闰月的月份,月份从1开始(0表示无闰月)。
|
|
611
612
|
*/
|
|
612
613
|
function getLunarLeapMonth(year) {
|
|
614
|
+
if (!lunarEnabled) return 0;
|
|
613
615
|
return lunarInfo[year - baseLunarYear] & 15;
|
|
614
616
|
}
|
|
615
617
|
/**
|
|
616
618
|
* 获取农历某年闰月的天数。
|
|
617
619
|
*/
|
|
618
620
|
function getLunarLeapMonthDays(year) {
|
|
621
|
+
if (!lunarEnabled) return 0;
|
|
619
622
|
if (getLunarLeapMonth(year)) return lunarInfo[year - 1900] & 65536 ? 30 : 29;
|
|
620
623
|
return 0;
|
|
621
624
|
}
|
|
@@ -623,6 +626,7 @@ function getLunarLeapMonthDays(year) {
|
|
|
623
626
|
* 获取农历某年的总天数。
|
|
624
627
|
*/
|
|
625
628
|
function getLunarYearDays(year) {
|
|
629
|
+
if (!lunarEnabled) return 0;
|
|
626
630
|
let sum = 348;
|
|
627
631
|
const info = lunarInfo[year - baseLunarYear];
|
|
628
632
|
for (let i = 32768; i > 8; i >>= 1) sum += info & i ? 1 : 0;
|
|
@@ -632,12 +636,18 @@ function getLunarYearDays(year) {
|
|
|
632
636
|
* 获取农历某年某月的天数,月份从1开始。
|
|
633
637
|
*/
|
|
634
638
|
function getLunarMonthDays(year, month) {
|
|
639
|
+
if (!lunarEnabled) return 0;
|
|
635
640
|
return lunarInfo[year - 1900] & 65536 >> month ? 30 : 29;
|
|
636
641
|
}
|
|
637
642
|
/**
|
|
638
643
|
* 公历转农历,月份从1开始(返回的闰月为负数)。
|
|
639
644
|
*/
|
|
640
645
|
function solarToLunar(year, month, day) {
|
|
646
|
+
if (!lunarEnabled) return {
|
|
647
|
+
year,
|
|
648
|
+
month,
|
|
649
|
+
day
|
|
650
|
+
};
|
|
641
651
|
const offsetDays = Math.floor((Date.UTC(year, month - 1, day) - Date.UTC(baseLunarYear, 0, 31)) / (1440 * 60 * 1e3));
|
|
642
652
|
let lunarYear = baseLunarYear;
|
|
643
653
|
let lunarMonth = 1;
|
|
@@ -679,6 +689,11 @@ function solarToLunar(year, month, day) {
|
|
|
679
689
|
* 农历转公历(闰月需传递负数)。
|
|
680
690
|
*/
|
|
681
691
|
function lunarToSolar(year, month, day) {
|
|
692
|
+
if (!lunarEnabled) return {
|
|
693
|
+
year,
|
|
694
|
+
month: Math.abs(month),
|
|
695
|
+
day
|
|
696
|
+
};
|
|
682
697
|
const springFestival = springFestivals[year - baseLunarYear];
|
|
683
698
|
const solarDate = new Date(year, springFestival[0] - 1, springFestival[1]);
|
|
684
699
|
const leapMonth = lunarInfo[year - baseLunarYear] & 15;
|
|
@@ -697,7 +712,7 @@ function lunarToSolar(year, month, day) {
|
|
|
697
712
|
day: solarDate.getDate()
|
|
698
713
|
};
|
|
699
714
|
}
|
|
700
|
-
const lunarYearNames = [
|
|
715
|
+
const lunarYearNames = lunarEnabled ? [
|
|
701
716
|
"零",
|
|
702
717
|
"一",
|
|
703
718
|
"二",
|
|
@@ -709,14 +724,15 @@ const lunarYearNames = [
|
|
|
709
724
|
"八",
|
|
710
725
|
"九",
|
|
711
726
|
"十"
|
|
712
|
-
];
|
|
727
|
+
] : [];
|
|
713
728
|
/**
|
|
714
729
|
* 将阿拉伯数字的年份转为汉字数字年份
|
|
715
730
|
*/
|
|
716
731
|
function getLunarYearName(year) {
|
|
732
|
+
if (!lunarEnabled) return String(year);
|
|
717
733
|
return String(year).split("").map((item) => lunarYearNames[+item]).join("") + "年";
|
|
718
734
|
}
|
|
719
|
-
const lunarMonthNames = [
|
|
735
|
+
const lunarMonthNames = lunarEnabled ? [
|
|
720
736
|
"正",
|
|
721
737
|
"二",
|
|
722
738
|
"三",
|
|
@@ -729,14 +745,15 @@ const lunarMonthNames = [
|
|
|
729
745
|
"十",
|
|
730
746
|
"冬",
|
|
731
747
|
"腊"
|
|
732
|
-
];
|
|
748
|
+
] : [];
|
|
733
749
|
/**
|
|
734
750
|
* 获取农历月份名称,月份从1开始,例如:正月,十月,腊月。
|
|
735
751
|
*/
|
|
736
752
|
function getLunarMonthName(month, isLeapMonth) {
|
|
753
|
+
if (!lunarEnabled) return "";
|
|
737
754
|
return (isLeapMonth ? "闰" : "") + lunarMonthNames[month - 1] + "月";
|
|
738
755
|
}
|
|
739
|
-
const lunarDayNames = [
|
|
756
|
+
const lunarDayNames = lunarEnabled ? [
|
|
740
757
|
"初一",
|
|
741
758
|
"初二",
|
|
742
759
|
"初三",
|
|
@@ -767,14 +784,15 @@ const lunarDayNames = [
|
|
|
767
784
|
"廿八",
|
|
768
785
|
"廿九",
|
|
769
786
|
"三十"
|
|
770
|
-
];
|
|
787
|
+
] : [];
|
|
771
788
|
/**
|
|
772
789
|
* 获取农历日期名称,例如:初一,十二,廿一。
|
|
773
790
|
*/
|
|
774
791
|
function getLunarDayName(day) {
|
|
792
|
+
if (!lunarEnabled) return "";
|
|
775
793
|
return lunarDayNames[day - 1];
|
|
776
794
|
}
|
|
777
|
-
const heavenlyStems = [
|
|
795
|
+
const heavenlyStems = lunarEnabled ? [
|
|
778
796
|
"甲",
|
|
779
797
|
"乙",
|
|
780
798
|
"丙",
|
|
@@ -785,8 +803,8 @@ const heavenlyStems = [
|
|
|
785
803
|
"辛",
|
|
786
804
|
"壬",
|
|
787
805
|
"癸"
|
|
788
|
-
];
|
|
789
|
-
const earthlyBranches = [
|
|
806
|
+
] : [];
|
|
807
|
+
const earthlyBranches = lunarEnabled ? [
|
|
790
808
|
"子",
|
|
791
809
|
"丑",
|
|
792
810
|
"寅",
|
|
@@ -799,11 +817,12 @@ const earthlyBranches = [
|
|
|
799
817
|
"酉",
|
|
800
818
|
"戌",
|
|
801
819
|
"亥"
|
|
802
|
-
];
|
|
820
|
+
] : [];
|
|
803
821
|
/**
|
|
804
822
|
* 获取农历时辰名称,例如:子初、子正、午初,午正。
|
|
805
823
|
*/
|
|
806
824
|
function getLunarHourName(hour) {
|
|
825
|
+
if (!lunarEnabled) return "";
|
|
807
826
|
const index = Math.floor(((hour === 23 ? 0 : hour) + 1) / 2) % 12;
|
|
808
827
|
return earthlyBranches[index] + (hour % 2 === 1 ? "初" : "正");
|
|
809
828
|
}
|