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.
Files changed (252) hide show
  1. package/README.md +1 -1
  2. package/components/accordion/style.d.ts +3 -0
  3. package/components/accordion/style.js +3 -0
  4. package/components/action-sheet/style.d.ts +6 -0
  5. package/components/action-sheet/style.js +6 -0
  6. package/components/alert/style.d.ts +2 -0
  7. package/components/alert/style.js +2 -0
  8. package/components/avatar/style.d.ts +2 -0
  9. package/components/avatar/style.js +2 -0
  10. package/components/back-top/style.d.ts +2 -0
  11. package/components/back-top/style.js +2 -0
  12. package/components/badge/style.d.ts +2 -0
  13. package/components/badge/style.js +2 -0
  14. package/components/barcode/style.d.ts +2 -0
  15. package/components/barcode/style.js +2 -0
  16. package/components/button/style.d.ts +3 -0
  17. package/components/button/style.js +3 -0
  18. package/components/calendar/style.d.ts +10 -0
  19. package/components/calendar/style.js +10 -0
  20. package/components/calendar-input/style.d.ts +12 -0
  21. package/components/calendar-input/style.js +12 -0
  22. package/components/calendar-popout/style.d.ts +10 -0
  23. package/components/calendar-popout/style.js +10 -0
  24. package/components/card/style.d.ts +5 -0
  25. package/components/card/style.js +5 -0
  26. package/components/cascader/style.d.ts +6 -0
  27. package/components/cascader/style.js +6 -0
  28. package/components/cascader-input/style.d.ts +13 -0
  29. package/components/cascader-input/style.js +13 -0
  30. package/components/cascader-popout/style.d.ts +11 -0
  31. package/components/cascader-popout/style.js +11 -0
  32. package/components/check-icon/style.d.ts +2 -0
  33. package/components/check-icon/style.js +2 -0
  34. package/components/checkbox/style.d.ts +3 -0
  35. package/components/checkbox/style.js +3 -0
  36. package/components/checkbox-input/style.d.ts +13 -0
  37. package/components/checkbox-input/style.js +13 -0
  38. package/components/checkbox-popout/style.d.ts +12 -0
  39. package/components/checkbox-popout/style.js +12 -0
  40. package/components/collapse/style.d.ts +2 -0
  41. package/components/collapse/style.js +2 -0
  42. package/components/color-picker/style.d.ts +5 -0
  43. package/components/color-picker/style.js +5 -0
  44. package/components/color-picker-input/style.d.ts +14 -0
  45. package/components/color-picker-input/style.js +14 -0
  46. package/components/color-picker-popout/style.d.ts +11 -0
  47. package/components/color-picker-popout/style.js +11 -0
  48. package/components/compact/style.d.ts +2 -0
  49. package/components/compact/style.js +2 -0
  50. package/components/cool-icon/style.d.ts +2 -0
  51. package/components/cool-icon/style.js +2 -0
  52. package/components/count-down/style.d.ts +2 -0
  53. package/components/count-down/style.js +2 -0
  54. package/components/crop-image/style.d.ts +7 -0
  55. package/components/crop-image/style.js +7 -0
  56. package/components/danmaku/index.css +1 -1
  57. package/components/danmaku/style.d.ts +2 -0
  58. package/components/danmaku/style.js +2 -0
  59. package/components/date-strip/style.d.ts +2 -0
  60. package/components/date-strip/style.js +2 -0
  61. package/components/datetime-picker/style.d.ts +3 -0
  62. package/components/datetime-picker/style.js +3 -0
  63. package/components/datetime-picker-input/style.d.ts +11 -0
  64. package/components/datetime-picker-input/style.js +11 -0
  65. package/components/datetime-picker-popout/style.d.ts +9 -0
  66. package/components/datetime-picker-popout/style.js +9 -0
  67. package/components/datetime-range-picker/style.d.ts +5 -0
  68. package/components/datetime-range-picker/style.js +5 -0
  69. package/components/datetime-range-picker-input/style.d.ts +13 -0
  70. package/components/datetime-range-picker-input/style.js +13 -0
  71. package/components/datetime-range-picker-popout/style.d.ts +11 -0
  72. package/components/datetime-range-picker-popout/style.js +11 -0
  73. package/components/descriptions/style.d.ts +2 -0
  74. package/components/descriptions/style.js +2 -0
  75. package/components/dialog/style.d.ts +7 -0
  76. package/components/dialog/style.js +7 -0
  77. package/components/divider/style.d.ts +2 -0
  78. package/components/divider/style.js +2 -0
  79. package/components/dnd/style.d.ts +2 -0
  80. package/components/dnd/style.js +2 -0
  81. package/components/dropdown/style.d.ts +5 -0
  82. package/components/dropdown/style.js +5 -0
  83. package/components/ellipsis/style.d.ts +2 -0
  84. package/components/ellipsis/style.js +2 -0
  85. package/components/empty/style.d.ts +2 -0
  86. package/components/empty/style.js +2 -0
  87. package/components/fab/style.d.ts +4 -0
  88. package/components/fab/style.js +4 -0
  89. package/components/flex/style.d.ts +2 -0
  90. package/components/flex/style.js +2 -0
  91. package/components/floating-bubble/style.d.ts +2 -0
  92. package/components/floating-bubble/style.js +2 -0
  93. package/components/floating-panel/style.d.ts +2 -0
  94. package/components/floating-panel/style.js +2 -0
  95. package/components/form/style.d.ts +2 -0
  96. package/components/form/style.js +2 -0
  97. package/components/grid/style.d.ts +2 -0
  98. package/components/grid/style.js +2 -0
  99. package/components/image/style.d.ts +2 -0
  100. package/components/image/style.js +2 -0
  101. package/components/indexes/style.d.ts +3 -0
  102. package/components/indexes/style.js +3 -0
  103. package/components/infinite-list/style.d.ts +5 -0
  104. package/components/infinite-list/style.js +5 -0
  105. package/components/input/style.d.ts +2 -0
  106. package/components/input/style.js +2 -0
  107. package/components/keyboard/style.d.ts +2 -0
  108. package/components/keyboard/style.js +2 -0
  109. package/components/keyboard-popout/style.d.ts +9 -0
  110. package/components/keyboard-popout/style.js +9 -0
  111. package/components/layout/style.d.ts +2 -0
  112. package/components/layout/style.js +2 -0
  113. package/components/list/style.d.ts +2 -0
  114. package/components/list/style.js +2 -0
  115. package/components/load-more/style.d.ts +3 -0
  116. package/components/load-more/style.js +3 -0
  117. package/components/loading/style.d.ts +2 -0
  118. package/components/loading/style.js +2 -0
  119. package/components/marquee/style.d.ts +2 -0
  120. package/components/marquee/style.js +2 -0
  121. package/components/menu/style.d.ts +2 -0
  122. package/components/menu/style.js +2 -0
  123. package/components/motion/style.d.ts +2 -0
  124. package/components/motion/style.js +2 -0
  125. package/components/navbar/style.d.ts +4 -0
  126. package/components/navbar/style.js +4 -0
  127. package/components/navbar-pit/style.d.ts +3 -0
  128. package/components/navbar-pit/style.js +3 -0
  129. package/components/notice-bar/style.d.ts +2 -0
  130. package/components/notice-bar/style.js +2 -0
  131. package/components/notify/style.d.ts +6 -0
  132. package/components/notify/style.js +6 -0
  133. package/components/overlay/style.d.ts +3 -0
  134. package/components/overlay/style.js +3 -0
  135. package/components/pagination/style.d.ts +2 -0
  136. package/components/pagination/style.js +2 -0
  137. package/components/password-input/style.d.ts +2 -0
  138. package/components/password-input/style.js +2 -0
  139. package/components/picker/style.d.ts +3 -0
  140. package/components/picker/style.js +3 -0
  141. package/components/picker-input/style.d.ts +11 -0
  142. package/components/picker-input/style.js +11 -0
  143. package/components/picker-popout/style.d.ts +9 -0
  144. package/components/picker-popout/style.js +9 -0
  145. package/components/picker-view/style.d.ts +2 -0
  146. package/components/picker-view/style.js +2 -0
  147. package/components/popout/style.d.ts +7 -0
  148. package/components/popout/style.js +7 -0
  149. package/components/popout-input/style.d.ts +4 -0
  150. package/components/popout-input/style.js +4 -0
  151. package/components/popover/style.d.ts +3 -0
  152. package/components/popover/style.js +3 -0
  153. package/components/popup/style.d.ts +4 -0
  154. package/components/popup/style.js +4 -0
  155. package/components/preview-image/style.d.ts +6 -0
  156. package/components/preview-image/style.js +6 -0
  157. package/components/progress-bar/style.d.ts +2 -0
  158. package/components/progress-bar/style.js +2 -0
  159. package/components/progress-circle/style.d.ts +2 -0
  160. package/components/progress-circle/style.js +2 -0
  161. package/components/pull-down-refresh/style.d.ts +3 -0
  162. package/components/pull-down-refresh/style.js +3 -0
  163. package/components/puzzle-verify/style.d.ts +4 -0
  164. package/components/puzzle-verify/style.js +4 -0
  165. package/components/qrcode/style.d.ts +2 -0
  166. package/components/qrcode/style.js +2 -0
  167. package/components/radio/style.d.ts +3 -0
  168. package/components/radio/style.js +3 -0
  169. package/components/radio-input/style.d.ts +13 -0
  170. package/components/radio-input/style.js +13 -0
  171. package/components/radio-popout/style.d.ts +12 -0
  172. package/components/radio-popout/style.js +12 -0
  173. package/components/rate/style.d.ts +2 -0
  174. package/components/rate/style.js +2 -0
  175. package/components/read-more/style.d.ts +4 -0
  176. package/components/read-more/style.js +4 -0
  177. package/components/result/style.d.ts +2 -0
  178. package/components/result/style.js +2 -0
  179. package/components/rotate-verify/style.d.ts +4 -0
  180. package/components/rotate-verify/style.js +4 -0
  181. package/components/scroll-list/style.d.ts +2 -0
  182. package/components/scroll-list/style.js +2 -0
  183. package/components/scroll-spy/style.d.ts +2 -0
  184. package/components/scroll-spy/style.js +2 -0
  185. package/components/search/style.d.ts +5 -0
  186. package/components/search/style.js +5 -0
  187. package/components/segmented/style.d.ts +3 -0
  188. package/components/segmented/style.js +3 -0
  189. package/components/select/style.d.ts +9 -0
  190. package/components/select/style.js +9 -0
  191. package/components/select-input/style.d.ts +11 -0
  192. package/components/select-input/style.js +11 -0
  193. package/components/select-popout/style.d.ts +10 -0
  194. package/components/select-popout/style.js +10 -0
  195. package/components/share-sheet/style.d.ts +5 -0
  196. package/components/share-sheet/style.js +5 -0
  197. package/components/sidebar/style.d.ts +2 -0
  198. package/components/sidebar/style.js +2 -0
  199. package/components/signature/style.d.ts +5 -0
  200. package/components/signature/style.js +5 -0
  201. package/components/skeleton/style.d.ts +2 -0
  202. package/components/skeleton/style.js +2 -0
  203. package/components/slide-verify/style.d.ts +3 -0
  204. package/components/slide-verify/style.js +3 -0
  205. package/components/slider/style.d.ts +2 -0
  206. package/components/slider/style.js +2 -0
  207. package/components/status-bar/style.d.ts +2 -0
  208. package/components/status-bar/style.js +2 -0
  209. package/components/stepper/style.d.ts +3 -0
  210. package/components/stepper/style.js +3 -0
  211. package/components/steps/style.d.ts +2 -0
  212. package/components/steps/style.js +2 -0
  213. package/components/sticky/style.d.ts +2 -0
  214. package/components/sticky/style.js +2 -0
  215. package/components/swipe-action/style.d.ts +2 -0
  216. package/components/swipe-action/style.js +2 -0
  217. package/components/swiper/style.d.ts +2 -0
  218. package/components/swiper/style.js +2 -0
  219. package/components/switch/style.d.ts +3 -0
  220. package/components/switch/style.js +3 -0
  221. package/components/tabbar/style.d.ts +2 -0
  222. package/components/tabbar/style.js +2 -0
  223. package/components/tabbar-pit/style.d.ts +2 -0
  224. package/components/tabbar-pit/style.js +2 -0
  225. package/components/table/style.d.ts +2 -0
  226. package/components/table/style.js +2 -0
  227. package/components/tabs/style.d.ts +2 -0
  228. package/components/tabs/style.js +2 -0
  229. package/components/tag/style.d.ts +2 -0
  230. package/components/tag/style.js +2 -0
  231. package/components/text/style.d.ts +2 -0
  232. package/components/text/style.js +2 -0
  233. package/components/text-shrink/style.d.ts +2 -0
  234. package/components/text-shrink/style.js +2 -0
  235. package/components/timeline/style.d.ts +2 -0
  236. package/components/timeline/style.js +2 -0
  237. package/components/toast/style.d.ts +6 -0
  238. package/components/toast/style.js +6 -0
  239. package/components/tree/style.d.ts +16 -0
  240. package/components/tree/style.js +16 -0
  241. package/components/upload/style.d.ts +3 -0
  242. package/components/upload/style.js +3 -0
  243. package/components/waterfall/style.d.ts +2 -0
  244. package/components/waterfall/style.js +2 -0
  245. package/components/watermark/style.d.ts +2 -0
  246. package/components/watermark/style.js +2 -0
  247. package/global.d.ts +16 -0
  248. package/index.css +1 -1
  249. package/locale/index.js +3 -2
  250. package/package.json +8 -4
  251. package/utils/date.d.ts +0 -3
  252. 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 currentLocale = shallowRef(zh_CN_default);
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 || zh_CN_default;
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.0",
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": false,
19
+ "sideEffects": [
20
+ "**/*.css",
21
+ "**/*.scss",
22
+ "**/style.*"
23
+ ],
20
24
  "main": "index.js",
21
25
  "devDependencies": {
22
- "@sard/icons": "^0.1.0",
26
+ "@sard/icons": "^0.1.1",
23
27
  "vue": "^3.5.0"
24
28
  },
25
29
  "peerDependencies": {
26
- "@sard/icons": "^0.1.0",
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 lunarInfo = [
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
  }