@tuya-miniapp/smart-ui 1.3.0-beta-2 → 1.3.1-beta-1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) hide show
  1. package/dist/action-sheet/index.js +3 -7
  2. package/dist/battery/index.js +3 -5
  3. package/dist/bottom-sheet/index.css +1 -0
  4. package/dist/bottom-sheet/index.d.ts +1 -0
  5. package/dist/bottom-sheet/index.js +70 -0
  6. package/dist/bottom-sheet/index.json +8 -0
  7. package/dist/bottom-sheet/index.wxml +26 -0
  8. package/dist/bottom-sheet/index.wxss +1 -0
  9. package/dist/button/index.js +1 -0
  10. package/dist/button/index.wxml +1 -1
  11. package/dist/calendar/calendar.wxml +53 -53
  12. package/dist/calendar/components/header/index.css +1 -1
  13. package/dist/calendar/components/header/index.js +18 -0
  14. package/dist/calendar/components/header/index.json +4 -1
  15. package/dist/calendar/components/header/index.wxml +15 -4
  16. package/dist/calendar/components/header/index.wxss +1 -1
  17. package/dist/calendar/components/month/index.css +1 -1
  18. package/dist/calendar/components/month/index.d.ts +0 -1
  19. package/dist/calendar/components/month/index.js +4 -7
  20. package/dist/calendar/components/month/index.wxml +0 -13
  21. package/dist/calendar/components/month/index.wxs +13 -7
  22. package/dist/calendar/components/month/index.wxss +1 -1
  23. package/dist/calendar/components/month-list/index.css +1 -0
  24. package/dist/calendar/components/month-list/index.d.ts +1 -0
  25. package/dist/calendar/components/month-list/index.js +112 -0
  26. package/dist/calendar/components/month-list/index.json +7 -0
  27. package/dist/calendar/components/month-list/index.wxml +9 -0
  28. package/dist/calendar/components/month-list/index.wxss +1 -0
  29. package/dist/calendar/components/year-list/index.css +1 -0
  30. package/dist/calendar/components/year-list/index.d.ts +1 -0
  31. package/dist/calendar/components/year-list/index.js +100 -0
  32. package/dist/calendar/components/year-list/index.json +7 -0
  33. package/dist/calendar/components/year-list/index.wxml +9 -0
  34. package/dist/calendar/components/year-list/index.wxss +1 -0
  35. package/dist/calendar/index.css +1 -1
  36. package/dist/calendar/index.js +100 -51
  37. package/dist/calendar/index.json +3 -1
  38. package/dist/calendar/index.wxml +1 -1
  39. package/dist/calendar/index.wxs +21 -3
  40. package/dist/calendar/index.wxss +1 -1
  41. package/dist/calendar/utils.d.ts +7 -2
  42. package/dist/calendar/utils.js +44 -8
  43. package/dist/checkbox/index.css +1 -1
  44. package/dist/checkbox/index.js +1 -1
  45. package/dist/checkbox/index.wxml +2 -2
  46. package/dist/checkbox/index.wxss +1 -1
  47. package/dist/config-provider/index.wxs +2 -7
  48. package/dist/dropdown-item/index.css +1 -1
  49. package/dist/dropdown-item/index.js +10 -0
  50. package/dist/dropdown-item/index.wxml +9 -4
  51. package/dist/dropdown-item/index.wxss +1 -1
  52. package/dist/dropdown-menu/index.css +1 -1
  53. package/dist/dropdown-menu/index.js +15 -0
  54. package/dist/dropdown-menu/index.json +4 -1
  55. package/dist/dropdown-menu/index.wxml +2 -1
  56. package/dist/dropdown-menu/index.wxss +1 -1
  57. package/dist/empty/index.css +1 -1
  58. package/dist/empty/index.js +20 -1
  59. package/dist/empty/index.wxml +7 -7
  60. package/dist/empty/index.wxs +3 -16
  61. package/dist/empty/index.wxss +1 -1
  62. package/dist/field/index.css +1 -1
  63. package/dist/field/index.wxss +1 -1
  64. package/dist/loading/index.css +1 -1
  65. package/dist/loading/index.js +4 -4
  66. package/dist/loading/index.wxml +4 -6
  67. package/dist/loading/index.wxs +39 -8
  68. package/dist/loading/index.wxss +1 -1
  69. package/dist/nav-bar/index.css +1 -1
  70. package/dist/nav-bar/index.js +19 -1
  71. package/dist/nav-bar/index.wxml +16 -6
  72. package/dist/nav-bar/index.wxss +1 -1
  73. package/dist/normal-slider/index.css +1 -1
  74. package/dist/normal-slider/index.wxss +1 -1
  75. package/dist/notice-bar/index.css +1 -1
  76. package/dist/notice-bar/index.js +55 -2
  77. package/dist/notice-bar/index.wxml +28 -10
  78. package/dist/notice-bar/index.wxs +1 -5
  79. package/dist/notice-bar/index.wxss +1 -1
  80. package/dist/picker-column/index.js +8 -1
  81. package/dist/radio/index.css +1 -1
  82. package/dist/radio/index.js +1 -1
  83. package/dist/radio/index.wxml +2 -1
  84. package/dist/radio/index.wxss +1 -1
  85. package/dist/search/index.css +1 -1
  86. package/dist/search/index.js +14 -9
  87. package/dist/search/index.json +2 -1
  88. package/dist/search/index.wxml +7 -4
  89. package/dist/search/index.wxss +1 -1
  90. package/dist/switch/index.css +1 -1
  91. package/dist/switch/index.wxml +1 -0
  92. package/dist/switch/index.wxss +1 -1
  93. package/dist/tabs/index.css +1 -1
  94. package/dist/tabs/index.js +10 -7
  95. package/dist/tabs/index.wxml +1 -0
  96. package/dist/tabs/index.wxs +17 -0
  97. package/dist/tabs/index.wxss +1 -1
  98. package/dist/tag/index.css +1 -1
  99. package/dist/tag/index.wxss +1 -1
  100. package/dist/toast/icons.d.ts +3 -0
  101. package/dist/toast/icons.js +6 -0
  102. package/dist/toast/index.js +8 -4
  103. package/dist/toast/index.wxml +3 -7
  104. package/dist/toast/toast.d.ts +2 -0
  105. package/dist/toast/toast.js +2 -0
  106. package/dist/wxs/style.wxs +11 -5
  107. package/dist/wxs/utils.wxs +1 -3
  108. package/lib/action-sheet/index.js +3 -7
  109. package/lib/battery/index.js +3 -5
  110. package/lib/bottom-sheet/index.css +1 -0
  111. package/lib/bottom-sheet/index.d.ts +1 -0
  112. package/lib/bottom-sheet/index.js +75 -0
  113. package/lib/bottom-sheet/index.json +8 -0
  114. package/lib/bottom-sheet/index.wxml +26 -0
  115. package/lib/bottom-sheet/index.wxss +1 -0
  116. package/lib/button/index.js +1 -0
  117. package/lib/button/index.wxml +1 -1
  118. package/lib/calendar/calendar.wxml +53 -53
  119. package/lib/calendar/components/header/index.css +1 -1
  120. package/lib/calendar/components/header/index.js +21 -0
  121. package/lib/calendar/components/header/index.json +4 -1
  122. package/lib/calendar/components/header/index.wxml +15 -4
  123. package/lib/calendar/components/header/index.wxss +1 -1
  124. package/lib/calendar/components/month/index.css +1 -1
  125. package/lib/calendar/components/month/index.d.ts +0 -1
  126. package/lib/calendar/components/month/index.js +3 -6
  127. package/lib/calendar/components/month/index.wxml +0 -13
  128. package/lib/calendar/components/month/index.wxs +13 -7
  129. package/lib/calendar/components/month/index.wxss +1 -1
  130. package/lib/calendar/components/month-list/index.css +1 -0
  131. package/lib/calendar/components/month-list/index.d.ts +1 -0
  132. package/lib/calendar/components/month-list/index.js +114 -0
  133. package/lib/calendar/components/month-list/index.json +7 -0
  134. package/lib/calendar/components/month-list/index.wxml +9 -0
  135. package/lib/calendar/components/month-list/index.wxss +1 -0
  136. package/lib/calendar/components/year-list/index.css +1 -0
  137. package/lib/calendar/components/year-list/index.d.ts +1 -0
  138. package/lib/calendar/components/year-list/index.js +102 -0
  139. package/lib/calendar/components/year-list/index.json +7 -0
  140. package/lib/calendar/components/year-list/index.wxml +9 -0
  141. package/lib/calendar/components/year-list/index.wxss +1 -0
  142. package/lib/calendar/index.css +1 -1
  143. package/lib/calendar/index.js +99 -52
  144. package/lib/calendar/index.json +3 -1
  145. package/lib/calendar/index.wxml +1 -1
  146. package/lib/calendar/index.wxs +21 -3
  147. package/lib/calendar/index.wxss +1 -1
  148. package/lib/calendar/utils.d.ts +7 -2
  149. package/lib/calendar/utils.js +48 -10
  150. package/lib/checkbox/index.css +1 -1
  151. package/lib/checkbox/index.js +1 -1
  152. package/lib/checkbox/index.wxml +2 -2
  153. package/lib/checkbox/index.wxss +1 -1
  154. package/lib/config-provider/index.wxs +2 -7
  155. package/lib/dropdown-item/index.css +1 -1
  156. package/lib/dropdown-item/index.js +13 -0
  157. package/lib/dropdown-item/index.wxml +9 -4
  158. package/lib/dropdown-item/index.wxss +1 -1
  159. package/lib/dropdown-menu/index.css +1 -1
  160. package/lib/dropdown-menu/index.js +18 -0
  161. package/lib/dropdown-menu/index.json +4 -1
  162. package/lib/dropdown-menu/index.wxml +2 -1
  163. package/lib/dropdown-menu/index.wxss +1 -1
  164. package/lib/empty/index.css +1 -1
  165. package/lib/empty/index.js +20 -1
  166. package/lib/empty/index.wxml +7 -7
  167. package/lib/empty/index.wxs +3 -16
  168. package/lib/empty/index.wxss +1 -1
  169. package/lib/field/index.css +1 -1
  170. package/lib/field/index.wxss +1 -1
  171. package/lib/loading/index.css +1 -1
  172. package/lib/loading/index.js +4 -4
  173. package/lib/loading/index.wxml +4 -6
  174. package/lib/loading/index.wxs +39 -8
  175. package/lib/loading/index.wxss +1 -1
  176. package/lib/nav-bar/index.css +1 -1
  177. package/lib/nav-bar/index.js +19 -1
  178. package/lib/nav-bar/index.wxml +16 -6
  179. package/lib/nav-bar/index.wxss +1 -1
  180. package/lib/normal-slider/index.css +1 -1
  181. package/lib/normal-slider/index.wxss +1 -1
  182. package/lib/notice-bar/index.css +1 -1
  183. package/lib/notice-bar/index.js +58 -2
  184. package/lib/notice-bar/index.wxml +28 -10
  185. package/lib/notice-bar/index.wxs +1 -5
  186. package/lib/notice-bar/index.wxss +1 -1
  187. package/lib/picker-column/index.js +8 -1
  188. package/lib/radio/index.css +1 -1
  189. package/lib/radio/index.js +1 -1
  190. package/lib/radio/index.wxml +2 -1
  191. package/lib/radio/index.wxss +1 -1
  192. package/lib/search/index.css +1 -1
  193. package/lib/search/index.js +17 -9
  194. package/lib/search/index.json +2 -1
  195. package/lib/search/index.wxml +7 -4
  196. package/lib/search/index.wxss +1 -1
  197. package/lib/switch/index.css +1 -1
  198. package/lib/switch/index.wxml +1 -0
  199. package/lib/switch/index.wxss +1 -1
  200. package/lib/tabs/index.css +1 -1
  201. package/lib/tabs/index.js +10 -7
  202. package/lib/tabs/index.wxml +1 -0
  203. package/lib/tabs/index.wxs +17 -0
  204. package/lib/tabs/index.wxss +1 -1
  205. package/lib/tag/index.css +1 -1
  206. package/lib/tag/index.wxss +1 -1
  207. package/lib/toast/icons.d.ts +3 -0
  208. package/lib/toast/icons.js +12 -0
  209. package/lib/toast/index.js +8 -7
  210. package/lib/toast/index.wxml +3 -7
  211. package/lib/toast/toast.d.ts +2 -0
  212. package/lib/toast/toast.js +2 -0
  213. package/lib/wxs/style.wxs +11 -5
  214. package/lib/wxs/utils.wxs +1 -3
  215. package/package.json +4 -8
  216. package/dist/common/theme/dark.d.ts +0 -344
  217. package/dist/common/theme/dark.js +0 -343
  218. package/dist/common/theme/light.d.ts +0 -344
  219. package/dist/common/theme/light.js +0 -343
  220. package/dist/wxs/is-app-theme-var.wxs +0 -8
  221. package/lib/common/theme/dark.d.ts +0 -344
  222. package/lib/common/theme/dark.js +0 -345
  223. package/lib/common/theme/light.d.ts +0 -344
  224. package/lib/common/theme/light.js +0 -345
  225. package/lib/wxs/is-app-theme-var.wxs +0 -8
@@ -39,10 +39,6 @@ var utils_1 = require("../../utils");
39
39
  type: Boolean,
40
40
  value: true,
41
41
  },
42
- dayClassMap: {
43
- type: null,
44
- observer: 'setDays',
45
- },
46
42
  subFormatter: String,
47
43
  rangeStart: String,
48
44
  rangeEnd: String,
@@ -62,7 +58,6 @@ var utils_1 = require("../../utils");
62
58
  }
63
59
  },
64
60
  setDays: function () {
65
- var _a;
66
61
  var days = [];
67
62
  var startDate = new Date(this.data.date);
68
63
  var year = startDate.getFullYear();
@@ -77,7 +72,6 @@ var utils_1 = require("../../utils");
77
72
  text: day,
78
73
  bottomInfo: this.getBottomInfo(type),
79
74
  };
80
- config.className = (_a = this.data.dayClassMap[(0, utils_1.formatDate)(date)]) !== null && _a !== void 0 ? _a : '';
81
75
  if (this.data.formatter) {
82
76
  config = this.data.formatter(config);
83
77
  }
@@ -151,6 +145,9 @@ var utils_1 = require("../../utils");
151
145
  if (type === 'range') {
152
146
  return this.getRangeDayType(day);
153
147
  }
148
+ if (type === 'week') {
149
+ return this.getRangeDayType(day);
150
+ }
154
151
  return '';
155
152
  },
156
153
  getBottomInfo: function (type) {
@@ -2,14 +2,7 @@
2
2
  <wxs src="../../../wxs/utils.wxs" module="utils" />
3
3
 
4
4
  <view class="smart-calendar__month" style="{{ computed.getMonthStyle(visible, date, rowHeight) }}">
5
- <view wx:if="{{ showMonthTitle }}" class="smart-calendar__month-title">
6
- {{ computed.formatMonthTitle(date, subFormatter) }}
7
- </view>
8
-
9
5
  <view wx:if="{{ visible }}" class="smart-calendar__days">
10
- <view wx:if="{{ showMark }}" class="smart-calendar__month-mark">
11
- {{ computed.getMark(date) }}
12
- </view>
13
6
 
14
7
  <view
15
8
  wx:for="{{ days }}"
@@ -22,16 +15,10 @@
22
15
  <view wx:if="{{ item.type === 'selected' }}" class="smart-calendar__selected-day" style="width: {{ rowHeight }}px; height: {{ rowHeight }}px; background: {{ color }}">
23
16
  <view wx:if="{{ item.topInfo }}" class="smart-calendar__top-info">{{ item.topInfo }}</view>
24
17
  {{ item.text }}
25
- <view wx:if="{{ item.bottomInfo }}" class="smart-calendar__bottom-info">
26
- {{ item.bottomInfo }}
27
- </view>
28
18
  </view>
29
19
  <block wx:else>
30
20
  <view wx:if="{{ item.topInfo }}" class="smart-calendar__top-info">{{ item.topInfo }}</view>
31
21
  {{ item.text }}
32
- <view wx:if="{{ item.bottomInfo }}" class="smart-calendar__bottom-info">
33
- {{ item.bottomInfo }}
34
- </view>
35
22
  </block>
36
23
  </view>
37
24
  </view>
@@ -10,9 +10,12 @@ var ROW_HEIGHT = 64;
10
10
  function getDayStyle(type, index, date, rowHeight, color, firstDayOfWeek) {
11
11
  var style = [];
12
12
  var current = getDate(date).getDay() || 7;
13
- var offset = current < firstDayOfWeek ? (7 - firstDayOfWeek + current) :
14
- current === 7 && firstDayOfWeek === 0 ? 0 :
15
- (current - firstDayOfWeek);
13
+ var offset =
14
+ current < firstDayOfWeek
15
+ ? 7 - firstDayOfWeek + current
16
+ : current === 7 && firstDayOfWeek === 0
17
+ ? 0
18
+ : current - firstDayOfWeek;
16
19
 
17
20
  if (index === 0) {
18
21
  style.push(['margin-left', (100 * offset) / 7 + '%']);
@@ -32,7 +35,7 @@ function getDayStyle(type, index, date, rowHeight, color, firstDayOfWeek) {
32
35
  ) {
33
36
  style.push(['background', color]);
34
37
  } else if (type === 'middle') {
35
- style.push(['color', color]);
38
+ style.push(['background', color]);
36
39
  }
37
40
  }
38
41
 
@@ -43,10 +46,13 @@ function getDayStyle(type, index, date, rowHeight, color, firstDayOfWeek) {
43
46
  .join(';');
44
47
  }
45
48
 
46
- function formatMonthTitle(date, formatter = "YYYY-MM") {
49
+ function formatMonthTitle(date, formatter = 'YYYY-MM') {
47
50
  date = getDate(date);
48
51
  const year = date.getFullYear();
49
- const month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1 + "";
52
+ const month =
53
+ date.getMonth() + 1 < 10
54
+ ? `0${date.getMonth() + 1}`
55
+ : date.getMonth() + 1 + '';
50
56
  return formatter.replace('YYYY', year + '').replace('MM', month);
51
57
  }
52
58
 
@@ -69,5 +75,5 @@ module.exports = {
69
75
  getMark: getMark,
70
76
  getDayStyle: getDayStyle,
71
77
  formatMonthTitle: formatMonthTitle,
72
- getMonthStyle: getMonthStyle
78
+ getMonthStyle: getMonthStyle,
73
79
  };
@@ -1 +1 @@
1
- @import '../../../common/index.wxss';.smart-calendar{background-color:var(--calendar-background-color,var(--app-B6,#fff));display:flex;flex-direction:column;height:100%}.smart-calendar__month-title{font-size:var(--calendar-month-title-font-size,14px);font-weight:var(--font-weight-bold,500);height:var(--calendar-header-title-height,44px);line-height:var(--calendar-header-title-height,44px);text-align:center}.smart-calendar__days{display:flex;flex-wrap:wrap;position:relative;-webkit-user-select:none;user-select:none}.smart-calendar__month-mark{color:var(--calendar-month-mark-color,hsla(210,6%,87%,.6));font-size:var(--calendar-month-mark-font-size,160px);left:50%;pointer-events:none;position:absolute;top:50%;transform:translate(-50%,-50%);z-index:0}.smart-calendar__day,.smart-calendar__selected-day{align-items:center;display:flex;justify-content:center;text-align:center}.smart-calendar__day{font-size:var(--calendar-day-font-size,16px);height:var(--calendar-day-height,64px);position:relative;width:14.285%}.smart-calendar__day--end,.smart-calendar__day--multiple-middle,.smart-calendar__day--multiple-selected,.smart-calendar__day--start,.smart-calendar__day--start-end{background-color:var(--calendar-range-edge-background-color,#ee0a24);color:var(--calendar-range-edge-color,#fff)}.smart-calendar__day--start{border-radius:4px 0 0 4px}.smart-calendar__day--end{border-radius:0 4px 4px 0}.smart-calendar__day--multiple-selected,.smart-calendar__day--start-end{border-radius:4px}.smart-calendar__day--middle{color:var(--calendar-range-middle-color,#ee0a24)}.smart-calendar__day--middle:after{background-color:currentColor;bottom:0;content:"";left:0;opacity:var(--calendar-range-middle-background-opacity,.1);position:absolute;right:0;top:0}.smart-calendar__day--disabled{color:var(--calendar-day-disabled-color,#c8c9cc);cursor:default}.smart-calendar__bottom-info,.smart-calendar__top-info{font-size:var(--calendar-info-font-size,10px);left:0;line-height:var(--calendar-info-line-height,14px);position:absolute;right:0}@media (max-width:350px){.smart-calendar__bottom-info,.smart-calendar__top-info{font-size:9px}}.smart-calendar__top-info{top:6px}.smart-calendar__bottom-info{bottom:6px}.smart-calendar__selected-day{background-color:var(--calendar-selected-day-background-color,#ee0a24);border-radius:4px;color:var(--calendar-selected-day-color,#fff);height:var(--calendar-selected-day-size,54px);width:var(--calendar-selected-day-size,54px)}
1
+ @import '../../../common/index.wxss';.smart-calendar{background-color:var(--calendar-background-color,var(--app-B6,#fff));display:flex;flex-direction:column;height:100%}.smart-calendar__month-title{font-size:var(--calendar-month-title-font-size,14px);font-weight:var(--font-weight-bold,500);height:var(--calendar-header-title-height,44px);line-height:var(--calendar-header-title-height,44px);text-align:center}.smart-calendar__days{display:flex;flex-wrap:wrap;position:relative;-webkit-user-select:none;user-select:none}.smart-calendar__month-mark{color:var(--calendar-month-mark-color,hsla(210,6%,87%,.6));font-size:var(--calendar-month-mark-font-size,160px);left:50%;pointer-events:none;position:absolute;top:50%;transform:translate(-50%,-50%);z-index:0}.smart-calendar__day,.smart-calendar__selected-day{align-items:center;display:flex;justify-content:center;text-align:center}.smart-calendar__day{font-size:var(--calendar-day-font-size,15px);font-weight:500;height:var(--calendar-day-height,100rpx);position:relative;width:14.285%}.smart-calendar__day--end,.smart-calendar__day--multiple-middle,.smart-calendar__day--multiple-selected,.smart-calendar__day--start,.smart-calendar__day--start-end{background-color:var(--calendar-range-edge-background-color,#3678e3);color:var(--calendar-range-edge-color,#fff)}.smart-calendar__day--start{border-bottom-left-radius:34rpx;border-top-left-radius:34rpx}.smart-calendar__day--end{border-bottom-right-radius:34rpx;border-top-right-radius:34rpx}.smart-calendar__day--multiple-selected,.smart-calendar__day--start-end{border-radius:4px}.smart-calendar__day--middle{background-color:var(--calendar-range-edge-background-color,#3678e3);color:var(--calendar-range-middle-color,var(--app-B3,#fff))}.smart-calendar__day--disabled{color:var(--calendar-day-disabled-color,#c8c9cc);cursor:default}.smart-calendar__bottom-info,.smart-calendar__top-info{font-size:var(--calendar-info-font-size,10px);left:0;line-height:var(--calendar-info-line-height,14px);position:absolute;right:0}@media (max-width:350px){.smart-calendar__bottom-info,.smart-calendar__top-info{font-size:9px}}.smart-calendar__top-info{top:6px}.smart-calendar__bottom-info{bottom:6px}.smart-calendar__selected-day{background-color:var(--calendar-selected-day-background-color,#3678e3);border-radius:50%;color:var(--calendar-selected-day-color,#fff);height:var(--calendar-selected-day-size,34px);width:var(--calendar-selected-day-size,34px)}
@@ -0,0 +1 @@
1
+ @import '../../../common/index.css';.item{border-radius:50%;color:rgba(0,0,0,.9);font-size:15px;font-weight:500;line-height:104rpx;text-align:center}.item,.item_active{height:104rpx;width:104rpx}.item_active{background:#3678e3;color:#fff}.item_disabled{opacity:.5}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // components/month-list.js
4
+ var utils_1 = require("../../utils");
5
+ var component_1 = require("../../../common/component");
6
+ (0, component_1.SmartComponent)({
7
+ /**
8
+ * 组件的属性列表
9
+ */
10
+ props: {
11
+ date: {
12
+ type: null,
13
+ observer: function (newVal, oldVal) {
14
+ if (newVal !== oldVal) {
15
+ this.calcMonth();
16
+ }
17
+ },
18
+ },
19
+ minDate: {
20
+ type: null,
21
+ value: new Date(new Date().getFullYear(), 0, 1).getTime(),
22
+ },
23
+ maxDate: {
24
+ type: null,
25
+ value: new Date(new Date().getFullYear(), 11, 31).getTime(),
26
+ },
27
+ currentYear: {
28
+ type: null,
29
+ value: new Date().getFullYear(),
30
+ },
31
+ visibleIndex: {
32
+ type: Number,
33
+ value: 0,
34
+ observer: function (newVal, oldVal) {
35
+ if (newVal !== oldVal) {
36
+ this.getMonthList();
37
+ }
38
+ },
39
+ },
40
+ monthsFormatter: {
41
+ type: null,
42
+ value: [
43
+ 'Jan',
44
+ 'Feb',
45
+ 'Mar',
46
+ 'Apr',
47
+ 'May',
48
+ 'Jun',
49
+ 'Jul',
50
+ 'Aug',
51
+ 'Sept',
52
+ 'Oct',
53
+ 'Nov',
54
+ 'Dec',
55
+ ],
56
+ },
57
+ },
58
+ /**
59
+ * 组件的初始数据
60
+ */
61
+ data: {
62
+ months: [],
63
+ currentMonth: null,
64
+ },
65
+ created: function () {
66
+ this.getMonthList();
67
+ this.calcMonth();
68
+ },
69
+ /**
70
+ * 组件的方法列表
71
+ */
72
+ methods: {
73
+ calcMonth: function () {
74
+ var date = new Date(this.data.date);
75
+ var cur = date.getMonth();
76
+ this.setData({
77
+ currentMonth: cur,
78
+ });
79
+ },
80
+ getMonthList: function () {
81
+ var _a = this.data, minDate = _a.minDate, maxDate = _a.maxDate, visibleIndex = _a.visibleIndex, _b = _a.monthsFormatter, monthsFormatter = _b === void 0 ? [] : _b;
82
+ var cur = new Date().getFullYear() + visibleIndex;
83
+ var start = new Date(cur, 0, 1).getTime();
84
+ var end = new Date(cur, 11, 31).getTime();
85
+ var minDateTime = new Date(minDate).getTime();
86
+ var maxDateTime = new Date(maxDate).getTime();
87
+ var months = (0, utils_1.getMonths)(start, end);
88
+ var monthlist = months.map(function (date) {
89
+ var monthVal = new Date(date).getMonth();
90
+ var time = new Date(date).getTime();
91
+ var isDisabled = time < minDateTime || time > maxDateTime;
92
+ return {
93
+ value: date,
94
+ month: monthVal,
95
+ text: monthsFormatter[monthVal] || monthVal + 1,
96
+ type: isDisabled ? 'disabled' : '',
97
+ };
98
+ });
99
+ this.setData({
100
+ months: monthlist,
101
+ });
102
+ },
103
+ onClick: function (event) {
104
+ var index = event.currentTarget.dataset.index;
105
+ var item = this.data.months[index];
106
+ if (item.type !== 'disabled') {
107
+ this.$emit('click', item.value);
108
+ this.setData({
109
+ date: item.value,
110
+ });
111
+ }
112
+ },
113
+ },
114
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {
4
+ "smart-row": "../../../row/index",
5
+ "smart-col": "../../../col/index"
6
+ }
7
+ }
@@ -0,0 +1,9 @@
1
+ <view class="contain">
2
+ <smart-row>
3
+ <smart-col wx:for="{{months}}" span="6">
4
+ <view class="item {{ currentMonth === item.month ? 'item_active' : '' }} {{ item.type === 'disabled' ? 'item_disabled' : '' }}" data-index="{{index}}" bindtap="onClick">
5
+ {{item.text}}
6
+ </view>
7
+ </smart-col>
8
+ </smart-row>
9
+ </view>
@@ -0,0 +1 @@
1
+ @import '../../../common/index.wxss';.item{border-radius:50%;color:rgba(0,0,0,.9);font-size:15px;font-weight:500;line-height:104rpx;text-align:center}.item,.item_active{height:104rpx;width:104rpx}.item_active{background:#3678e3;color:#fff}.item_disabled{opacity:.5}
@@ -0,0 +1 @@
1
+ @import '../../../common/index.css';.contain{margin:24rpx 0}.item{border-radius:50%;color:rgba(0,0,0,.9);font-size:15px;font-weight:500;line-height:104rpx;text-align:center}.item,.item_active{height:104rpx;width:104rpx}.item_active{background:#3678e3;color:#fff}.item_disabled{opacity:.5}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // components/month-list.js
4
+ var utils_1 = require("../../utils");
5
+ var component_1 = require("../../../common/component");
6
+ (0, component_1.SmartComponent)({
7
+ /**
8
+ * 组件的属性列表
9
+ */
10
+ props: {
11
+ date: {
12
+ type: null,
13
+ observer: function (newVal, oldVal) {
14
+ if (newVal !== oldVal) {
15
+ this.calcYear();
16
+ }
17
+ },
18
+ },
19
+ minDate: {
20
+ type: null,
21
+ value: new Date(new Date().getFullYear() - 30, 0, 1).getTime(),
22
+ },
23
+ maxDate: {
24
+ type: null,
25
+ value: new Date(new Date().getFullYear() + 30, 11, 31).getTime(),
26
+ },
27
+ currentYear: {
28
+ type: null,
29
+ value: new Date().getFullYear(),
30
+ },
31
+ yearFormatter: {
32
+ type: null,
33
+ value: 'YYYY',
34
+ },
35
+ visibleIndex: {
36
+ type: Number,
37
+ value: 0,
38
+ observer: function (newVal, oldVal) {
39
+ if (newVal !== oldVal) {
40
+ this.getYearList();
41
+ }
42
+ },
43
+ },
44
+ },
45
+ /**
46
+ * 组件的初始数据
47
+ */
48
+ data: {
49
+ years: [],
50
+ currentYear: null,
51
+ },
52
+ created: function () {
53
+ this.getYearList();
54
+ this.calcYear();
55
+ },
56
+ /**
57
+ * 组件的方法列表
58
+ */
59
+ methods: {
60
+ calcYear: function () {
61
+ var date = new Date(this.data.date);
62
+ var cur = date.getFullYear();
63
+ this.setData({
64
+ currentYear: cur,
65
+ });
66
+ },
67
+ getYearList: function () {
68
+ var _a = this.data, minDate = _a.minDate, maxDate = _a.maxDate, _b = _a.yearFormatter, yearFormatter = _b === void 0 ? 'YYYY' : _b, visibleIndex = _a.visibleIndex, date = _a.date;
69
+ var cur = new Date(date).getFullYear();
70
+ var offset = visibleIndex * 12;
71
+ var start = new Date(cur + offset - 5, 0, 1).getTime();
72
+ var end = new Date(cur + offset + 6, 11, 31).getTime();
73
+ var minStart = new Date(minDate).getTime();
74
+ var maxStart = new Date(maxDate).getTime();
75
+ var years = (0, utils_1.getYears)(start, end);
76
+ var yearlist = years.map(function (date) {
77
+ var yearVal = new Date(date).getFullYear();
78
+ var curTime = new Date(date).getTime();
79
+ var disabled = curTime <= minStart || curTime >= maxStart;
80
+ return {
81
+ value: date,
82
+ year: yearVal,
83
+ text: yearFormatter.replace('YYYY', yearVal),
84
+ type: disabled ? 'disabled' : '',
85
+ };
86
+ });
87
+ this.setData({
88
+ years: yearlist,
89
+ });
90
+ },
91
+ onClick: function (event) {
92
+ var index = event.currentTarget.dataset.index;
93
+ var item = this.data.years[index];
94
+ if (item.type !== 'disabled') {
95
+ this.$emit('click', item.value);
96
+ this.setData({
97
+ date: item.value,
98
+ });
99
+ }
100
+ },
101
+ },
102
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {
4
+ "smart-row": "../../../row/index",
5
+ "smart-col": "../../../col/index"
6
+ }
7
+ }
@@ -0,0 +1,9 @@
1
+ <view class="contain">
2
+ <smart-row>
3
+ <smart-col wx:for="{{years}}" span="6">
4
+ <view class="item {{ currentYear === item.year ? 'item_active' : '' }} {{ item.type === 'disabled' ? 'item_disabled' : '' }}" data-index="{{index}}" bindtap="onClick">
5
+ {{item.text}}
6
+ </view>
7
+ </smart-col>
8
+ </smart-row>
9
+ </view>
@@ -0,0 +1 @@
1
+ @import '../../../common/index.wxss';.contain{margin:24rpx 0}.item{border-radius:50%;color:rgba(0,0,0,.9);font-size:15px;font-weight:500;line-height:104rpx;text-align:center}.item,.item_active{height:104rpx;width:104rpx}.item_active{background:#3678e3;color:#fff}.item_disabled{opacity:.5}
@@ -1 +1 @@
1
- @import '../common/index.css';.smart-calendar{background-color:var(--calendar-background-color,var(--app-B6,#fff));color:var(--calendar-text-color,#000);display:flex;flex-direction:column;height:var(--calendar-height,100%)}.smart-calendar__close-icon{top:11px}.smart-calendar__popup--bottom,.smart-calendar__popup--top{height:var(--calendar-popup-height,90%)}.smart-calendar__popup--left,.smart-calendar__popup--right{height:100%}.smart-calendar__body{-webkit-overflow-scrolling:touch;flex:1;overflow:auto}.smart-calendar__footer{flex-shrink:0;padding:0 var(--padding-md,16px)}.smart-calendar__footer--safe-area-inset-bottom{padding-bottom:env(safe-area-inset-bottom)}.smart-calendar__footer+.smart-calendar__footer,.smart-calendar__footer:empty{display:none}.smart-calendar__footer:empty+.smart-calendar__footer{display:block!important}.smart-calendar__confirm{height:var(--calendar-confirm-button-height,36px)!important;line-height:var(--calendar-confirm-button-line-height,34px)!important;margin:var(--calendar-confirm-button-margin,7px 0)!important}
1
+ @import '../common/index.css';.smart-calendar{background-color:var(--calendar-background-color,var(--app-B6,#fff));color:var(--calendar-text-color,#000);display:flex;flex-direction:column;height:auto}.smart-calendar__close-icon{top:11px}.smart-calendar__popup--bottom,.smart-calendar__popup--top{height:848rpx}.smart-calendar__popup--left,.smart-calendar__popup--right{height:100%}.smart-calendar-month{margin-top:44rpx}.smart-calendar__body{-webkit-overflow-scrolling:touch;flex:1;overflow:auto}.smart-calendar__footer{flex-shrink:0;padding:0 var(--padding-md,16px)}.smart-calendar__footer--safe-area-inset-bottom{padding-bottom:env(safe-area-inset-bottom)}.smart-calendar__footer+.smart-calendar__footer,.smart-calendar__footer:empty{display:none}.smart-calendar__footer:empty+.smart-calendar__footer{display:block!important}
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  var component_1 = require("../common/component");
16
16
  var utils_1 = require("./utils");
17
17
  var toast_1 = __importDefault(require("../toast/toast"));
18
- var utils_2 = require("../common/utils");
19
18
  var initialMinDate = (0, utils_1.getToday)().getTime();
20
19
  var initialMaxDate = (function () {
21
20
  var now = (0, utils_1.getToday)();
@@ -44,15 +43,26 @@ var getTime = function (date) {
44
43
  type: Object,
45
44
  value: {
46
45
  shortWeekDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
46
+ monthsFormatter: [
47
+ 'Jan',
48
+ 'Feb',
49
+ 'Mar',
50
+ 'Apr',
51
+ 'May',
52
+ 'Jun',
53
+ 'Jul',
54
+ 'Aug',
55
+ 'Sept',
56
+ 'Oct',
57
+ 'Nov',
58
+ 'Dec',
59
+ ],
60
+ yearFormatter: 'YYYY',
47
61
  subFormatter: 'YYYY-MM',
48
62
  rangeStart: 'Start',
49
63
  rangeEnd: 'End',
50
64
  },
51
65
  },
52
- dayClassMap: {
53
- type: Object,
54
- value: {},
55
- },
56
66
  formatter: null,
57
67
  confirmText: {
58
68
  type: String,
@@ -62,6 +72,10 @@ var getTime = function (date) {
62
72
  type: String,
63
73
  value: '确定',
64
74
  },
75
+ mode: {
76
+ type: String,
77
+ value: 'day',
78
+ },
65
79
  rangePrompt: String,
66
80
  showRangePrompt: {
67
81
  type: Boolean,
@@ -152,6 +166,7 @@ var getTime = function (date) {
152
166
  currentDate: null,
153
167
  scrollIntoView: '',
154
168
  visibleIndex: 0,
169
+ months: [],
155
170
  },
156
171
  watch: {
157
172
  minDate: function () {
@@ -162,9 +177,7 @@ var getTime = function (date) {
162
177
  },
163
178
  },
164
179
  created: function () {
165
- this.setData({
166
- currentDate: this.getInitialDate(this.data.defaultDate),
167
- });
180
+ this.initData();
168
181
  },
169
182
  mounted: function () {
170
183
  this.isMounted = true;
@@ -174,32 +187,75 @@ var getTime = function (date) {
174
187
  }
175
188
  },
176
189
  methods: {
190
+ onPrev: function () {
191
+ var visibleIndex = this.data.visibleIndex - 1;
192
+ if (this.data.mode === 'year') {
193
+ this.setData({
194
+ visibleIndex: visibleIndex,
195
+ });
196
+ return;
197
+ }
198
+ if (this.data.mode === 'month') {
199
+ this.setData({
200
+ visibleIndex: visibleIndex,
201
+ });
202
+ return;
203
+ }
204
+ if (this.data.months[visibleIndex]) {
205
+ this.setData({
206
+ visibleIndex: visibleIndex,
207
+ });
208
+ }
209
+ },
210
+ onNext: function () {
211
+ var visibleIndex = this.data.visibleIndex + 1;
212
+ if (this.data.mode === 'year') {
213
+ this.setData({
214
+ visibleIndex: visibleIndex,
215
+ });
216
+ return;
217
+ }
218
+ if (this.data.mode === 'month') {
219
+ this.setData({
220
+ visibleIndex: visibleIndex,
221
+ });
222
+ return;
223
+ }
224
+ if (this.data.months[visibleIndex]) {
225
+ this.setData({
226
+ visibleIndex: visibleIndex,
227
+ });
228
+ }
229
+ },
177
230
  reset: function () {
178
231
  this.setData({ currentDate: this.getInitialDate(this.data.defaultDate) });
179
232
  this.scrollIntoView();
180
233
  },
234
+ initYearIdx: function (currentDate) {
235
+ },
236
+ initData: function () {
237
+ var currentDate = this.getInitialDate(this.data.defaultDate);
238
+ var months = (0, utils_1.getMonths)(this.data.minDate, this.data.maxDate);
239
+ var visibleIndex = this.data.defaultDate
240
+ ? (0, utils_1.getCurrentIndex)(currentDate, months)
241
+ : months.length - 1;
242
+ var isYear = this.data.mode === 'year';
243
+ var isMonth = this.data.mode === 'month';
244
+ var data = {
245
+ currentDate: currentDate,
246
+ months: months,
247
+ visibleIndex: visibleIndex,
248
+ };
249
+ if (isYear || isMonth) {
250
+ // @ts-ignore
251
+ delete data.visibleIndex;
252
+ }
253
+ this.setData(data);
254
+ },
181
255
  initRect: function () {
182
- var _this = this;
183
256
  if (!this.isMounted)
184
257
  return;
185
- if (this.contentObserver != null) {
186
- this.contentObserver.disconnect();
187
- }
188
- var contentObserver = this.createIntersectionObserver({
189
- thresholds: [0, 0.1, 0.9, 1],
190
- observeAll: true,
191
- });
192
- this.contentObserver = contentObserver;
193
- contentObserver.relativeTo('.smart-calendar__body');
194
- contentObserver.observe('.month', function (res) {
195
- if (res.boundingClientRect.top <= res.relativeRect.top) {
196
- // @ts-ignore
197
- _this.setData({
198
- subtitle: (0, utils_1.formatMonthTitle)(res.dataset.date, _this.properties.locale.subFormatter),
199
- visibleIndex: res.dataset.index,
200
- });
201
- }
202
- });
258
+ this.initData();
203
259
  },
204
260
  limitDateRange: function (date, minDate, maxDate) {
205
261
  if (minDate === void 0) { minDate = null; }
@@ -221,7 +277,7 @@ var getTime = function (date) {
221
277
  if (!defaultDate)
222
278
  return [];
223
279
  var now = (0, utils_1.getToday)().getTime();
224
- if (type === 'range') {
280
+ if (type === 'range' || type === 'week') {
225
281
  if (!Array.isArray(defaultDate)) {
226
282
  defaultDate = [];
227
283
  }
@@ -244,31 +300,8 @@ var getTime = function (date) {
244
300
  return this.limitDateRange(defaultDate);
245
301
  },
246
302
  scrollIntoView: function () {
247
- var _this = this;
248
303
  if (!this.isMounted)
249
304
  return;
250
- (0, utils_2.requestAnimationFrame)(function () {
251
- var _a = _this.data, currentDate = _a.currentDate, type = _a.type, show = _a.show, poppable = _a.poppable, minDate = _a.minDate, maxDate = _a.maxDate;
252
- if (!currentDate)
253
- return;
254
- // @ts-ignore
255
- var targetDate = type === 'single' ? currentDate : currentDate[0];
256
- var displayed = show || !poppable;
257
- if (!targetDate || !displayed) {
258
- return;
259
- }
260
- var months = (0, utils_1.getMonths)(minDate, maxDate);
261
- months.some(function (month, index) {
262
- if ((0, utils_1.compareMonth)(month, targetDate) === 0) {
263
- _this.setData({
264
- scrollIntoView: "month".concat(index),
265
- visibleIndex: index,
266
- });
267
- return true;
268
- }
269
- return false;
270
- });
271
- });
272
305
  },
273
306
  onOpen: function () {
274
307
  this.$emit('open');
@@ -288,7 +321,14 @@ var getTime = function (date) {
288
321
  }
289
322
  var date = event.detail.date;
290
323
  var _a = this.data, type = _a.type, currentDate = _a.currentDate, allowSameDay = _a.allowSameDay;
291
- if (type === 'range') {
324
+ if (type === 'week') {
325
+ var _b = (0, utils_1.getWeekStartAndEnd)(date), weekStart = _b.weekStart, weekEnd = _b.weekEnd;
326
+ this.select([
327
+ Math.max(getTime(weekStart), getTime(this.data.minDate)),
328
+ Math.min(getTime(weekEnd), getTime(this.data.maxDate)),
329
+ ], true);
330
+ }
331
+ else if (type === 'range') {
292
332
  // @ts-ignore
293
333
  var startDay_1 = currentDate[0], endDay = currentDate[1];
294
334
  if (startDay_1 && !endDay) {
@@ -342,6 +382,13 @@ var getTime = function (date) {
342
382
  this.select(date, true);
343
383
  }
344
384
  },
385
+ onClickDate: function (event) {
386
+ if (this.data.readonly) {
387
+ return;
388
+ }
389
+ var date = event.detail;
390
+ this.select(date, true);
391
+ },
345
392
  unselect: function (dateArray) {
346
393
  var date = dateArray[0];
347
394
  if (date) {
@@ -3,8 +3,10 @@
3
3
  "usingComponents": {
4
4
  "header": "./components/header/index",
5
5
  "month": "./components/month/index",
6
+ "month-list": "./components/month-list/index",
7
+ "year-list": "./components/year-list/index",
6
8
  "smart-button": "../button/index",
7
9
  "smart-popup": "../popup/index",
8
10
  "smart-toast": "../toast/index"
9
11
  }
10
- }
12
+ }
@@ -10,7 +10,7 @@
10
10
  show="{{ show }}"
11
11
  round="{{ round }}"
12
12
  position="{{ position }}"
13
- closeable="{{ showTitle || showSubtitle }}"
13
+ closeable="{{false}}"
14
14
  close-on-click-overlay="{{ closeOnClickOverlay }}"
15
15
  safe-area-inset-bottom="{{ safeAreaInsetBottom }}"
16
16
  root-portal="{{ rootPortal }}"