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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. package/dist/bottom-sheet/index.css +1 -0
  2. package/dist/bottom-sheet/index.d.ts +1 -0
  3. package/dist/bottom-sheet/index.js +70 -0
  4. package/dist/bottom-sheet/index.json +8 -0
  5. package/dist/bottom-sheet/index.wxml +26 -0
  6. package/dist/bottom-sheet/index.wxss +1 -0
  7. package/dist/button/index.js +1 -0
  8. package/dist/button/index.wxml +1 -1
  9. package/dist/calendar/calendar.wxml +53 -52
  10. package/dist/calendar/components/header/index.css +1 -1
  11. package/dist/calendar/components/header/index.js +18 -0
  12. package/dist/calendar/components/header/index.json +4 -1
  13. package/dist/calendar/components/header/index.wxml +15 -4
  14. package/dist/calendar/components/header/index.wxss +1 -1
  15. package/dist/calendar/components/month/index.css +1 -1
  16. package/dist/calendar/components/month/index.js +7 -2
  17. package/dist/calendar/components/month/index.wxml +0 -13
  18. package/dist/calendar/components/month/index.wxs +13 -7
  19. package/dist/calendar/components/month/index.wxss +1 -1
  20. package/dist/calendar/components/month-list/index.css +1 -0
  21. package/dist/calendar/components/month-list/index.d.ts +1 -0
  22. package/dist/calendar/components/month-list/index.js +112 -0
  23. package/dist/calendar/components/month-list/index.json +7 -0
  24. package/dist/calendar/components/month-list/index.wxml +9 -0
  25. package/dist/calendar/components/month-list/index.wxss +1 -0
  26. package/dist/calendar/components/year-list/index.css +1 -0
  27. package/dist/calendar/components/year-list/index.d.ts +1 -0
  28. package/dist/calendar/components/year-list/index.js +100 -0
  29. package/dist/calendar/components/year-list/index.json +7 -0
  30. package/dist/calendar/components/year-list/index.wxml +9 -0
  31. package/dist/calendar/components/year-list/index.wxss +1 -0
  32. package/dist/calendar/index.css +1 -1
  33. package/dist/calendar/index.js +101 -42
  34. package/dist/calendar/index.json +3 -1
  35. package/dist/calendar/index.wxml +1 -1
  36. package/dist/calendar/index.wxs +20 -2
  37. package/dist/calendar/index.wxss +1 -1
  38. package/dist/calendar/utils.d.ts +7 -1
  39. package/dist/calendar/utils.js +48 -2
  40. package/dist/checkbox/index.css +1 -1
  41. package/dist/checkbox/index.js +1 -1
  42. package/dist/checkbox/index.wxml +2 -2
  43. package/dist/checkbox/index.wxss +1 -1
  44. package/dist/config-provider/index.wxs +2 -7
  45. package/dist/dropdown-item/index.css +1 -1
  46. package/dist/dropdown-item/index.js +10 -0
  47. package/dist/dropdown-item/index.wxml +9 -4
  48. package/dist/dropdown-item/index.wxss +1 -1
  49. package/dist/dropdown-menu/index.css +1 -1
  50. package/dist/dropdown-menu/index.js +15 -0
  51. package/dist/dropdown-menu/index.json +4 -1
  52. package/dist/dropdown-menu/index.wxml +2 -1
  53. package/dist/dropdown-menu/index.wxss +1 -1
  54. package/dist/empty/index.css +1 -1
  55. package/dist/empty/index.js +20 -1
  56. package/dist/empty/index.wxml +7 -7
  57. package/dist/empty/index.wxs +3 -16
  58. package/dist/empty/index.wxss +1 -1
  59. package/dist/field/index.css +1 -1
  60. package/dist/field/index.wxss +1 -1
  61. package/dist/loading/index.css +1 -1
  62. package/dist/loading/index.js +4 -4
  63. package/dist/loading/index.wxml +4 -6
  64. package/dist/loading/index.wxs +39 -8
  65. package/dist/loading/index.wxss +1 -1
  66. package/dist/nav-bar/index.css +1 -1
  67. package/dist/nav-bar/index.js +19 -1
  68. package/dist/nav-bar/index.wxml +16 -6
  69. package/dist/nav-bar/index.wxss +1 -1
  70. package/dist/normal-slider/index.css +1 -1
  71. package/dist/normal-slider/index.wxss +1 -1
  72. package/dist/notice-bar/index.css +1 -1
  73. package/dist/notice-bar/index.js +55 -2
  74. package/dist/notice-bar/index.wxml +28 -10
  75. package/dist/notice-bar/index.wxs +1 -5
  76. package/dist/notice-bar/index.wxss +1 -1
  77. package/dist/picker-column/index.js +8 -1
  78. package/dist/radio/index.css +1 -1
  79. package/dist/radio/index.js +1 -1
  80. package/dist/radio/index.wxml +2 -1
  81. package/dist/radio/index.wxss +1 -1
  82. package/dist/search/index.css +1 -1
  83. package/dist/search/index.js +14 -9
  84. package/dist/search/index.json +2 -1
  85. package/dist/search/index.wxml +7 -4
  86. package/dist/search/index.wxss +1 -1
  87. package/dist/switch/index.css +1 -1
  88. package/dist/switch/index.wxml +1 -0
  89. package/dist/switch/index.wxss +1 -1
  90. package/dist/tabs/index.css +1 -1
  91. package/dist/tabs/index.js +10 -7
  92. package/dist/tabs/index.wxml +1 -0
  93. package/dist/tabs/index.wxs +17 -0
  94. package/dist/tabs/index.wxss +1 -1
  95. package/dist/tag/index.css +1 -1
  96. package/dist/tag/index.wxss +1 -1
  97. package/dist/toast/icons.d.ts +3 -0
  98. package/dist/toast/icons.js +6 -0
  99. package/dist/toast/index.js +8 -4
  100. package/dist/toast/index.wxml +3 -7
  101. package/dist/toast/toast.d.ts +2 -0
  102. package/dist/toast/toast.js +2 -0
  103. package/dist/wxs/style.wxs +11 -5
  104. package/dist/wxs/utils.wxs +1 -3
  105. package/lib/bottom-sheet/index.css +1 -0
  106. package/lib/bottom-sheet/index.d.ts +1 -0
  107. package/lib/bottom-sheet/index.js +75 -0
  108. package/lib/bottom-sheet/index.json +8 -0
  109. package/lib/bottom-sheet/index.wxml +26 -0
  110. package/lib/bottom-sheet/index.wxss +1 -0
  111. package/lib/button/index.js +1 -0
  112. package/lib/button/index.wxml +1 -1
  113. package/lib/calendar/calendar.wxml +53 -52
  114. package/lib/calendar/components/header/index.css +1 -1
  115. package/lib/calendar/components/header/index.js +21 -0
  116. package/lib/calendar/components/header/index.json +4 -1
  117. package/lib/calendar/components/header/index.wxml +15 -4
  118. package/lib/calendar/components/header/index.wxss +1 -1
  119. package/lib/calendar/components/month/index.css +1 -1
  120. package/lib/calendar/components/month/index.js +7 -2
  121. package/lib/calendar/components/month/index.wxml +0 -13
  122. package/lib/calendar/components/month/index.wxs +13 -7
  123. package/lib/calendar/components/month/index.wxss +1 -1
  124. package/lib/calendar/components/month-list/index.css +1 -0
  125. package/lib/calendar/components/month-list/index.d.ts +1 -0
  126. package/lib/calendar/components/month-list/index.js +114 -0
  127. package/lib/calendar/components/month-list/index.json +7 -0
  128. package/lib/calendar/components/month-list/index.wxml +9 -0
  129. package/lib/calendar/components/month-list/index.wxss +1 -0
  130. package/lib/calendar/components/year-list/index.css +1 -0
  131. package/lib/calendar/components/year-list/index.d.ts +1 -0
  132. package/lib/calendar/components/year-list/index.js +102 -0
  133. package/lib/calendar/components/year-list/index.json +7 -0
  134. package/lib/calendar/components/year-list/index.wxml +9 -0
  135. package/lib/calendar/components/year-list/index.wxss +1 -0
  136. package/lib/calendar/index.css +1 -1
  137. package/lib/calendar/index.js +100 -43
  138. package/lib/calendar/index.json +3 -1
  139. package/lib/calendar/index.wxml +1 -1
  140. package/lib/calendar/index.wxs +20 -2
  141. package/lib/calendar/index.wxss +1 -1
  142. package/lib/calendar/utils.d.ts +7 -1
  143. package/lib/calendar/utils.js +52 -3
  144. package/lib/checkbox/index.css +1 -1
  145. package/lib/checkbox/index.js +1 -1
  146. package/lib/checkbox/index.wxml +2 -2
  147. package/lib/checkbox/index.wxss +1 -1
  148. package/lib/config-provider/index.wxs +2 -7
  149. package/lib/dropdown-item/index.css +1 -1
  150. package/lib/dropdown-item/index.js +13 -0
  151. package/lib/dropdown-item/index.wxml +9 -4
  152. package/lib/dropdown-item/index.wxss +1 -1
  153. package/lib/dropdown-menu/index.css +1 -1
  154. package/lib/dropdown-menu/index.js +18 -0
  155. package/lib/dropdown-menu/index.json +4 -1
  156. package/lib/dropdown-menu/index.wxml +2 -1
  157. package/lib/dropdown-menu/index.wxss +1 -1
  158. package/lib/empty/index.css +1 -1
  159. package/lib/empty/index.js +20 -1
  160. package/lib/empty/index.wxml +7 -7
  161. package/lib/empty/index.wxs +3 -16
  162. package/lib/empty/index.wxss +1 -1
  163. package/lib/field/index.css +1 -1
  164. package/lib/field/index.wxss +1 -1
  165. package/lib/loading/index.css +1 -1
  166. package/lib/loading/index.js +4 -4
  167. package/lib/loading/index.wxml +4 -6
  168. package/lib/loading/index.wxs +39 -8
  169. package/lib/loading/index.wxss +1 -1
  170. package/lib/nav-bar/index.css +1 -1
  171. package/lib/nav-bar/index.js +19 -1
  172. package/lib/nav-bar/index.wxml +16 -6
  173. package/lib/nav-bar/index.wxss +1 -1
  174. package/lib/normal-slider/index.css +1 -1
  175. package/lib/normal-slider/index.wxss +1 -1
  176. package/lib/notice-bar/index.css +1 -1
  177. package/lib/notice-bar/index.js +58 -2
  178. package/lib/notice-bar/index.wxml +28 -10
  179. package/lib/notice-bar/index.wxs +1 -5
  180. package/lib/notice-bar/index.wxss +1 -1
  181. package/lib/picker-column/index.js +8 -1
  182. package/lib/radio/index.css +1 -1
  183. package/lib/radio/index.js +1 -1
  184. package/lib/radio/index.wxml +2 -1
  185. package/lib/radio/index.wxss +1 -1
  186. package/lib/search/index.css +1 -1
  187. package/lib/search/index.js +17 -9
  188. package/lib/search/index.json +2 -1
  189. package/lib/search/index.wxml +7 -4
  190. package/lib/search/index.wxss +1 -1
  191. package/lib/switch/index.css +1 -1
  192. package/lib/switch/index.wxml +1 -0
  193. package/lib/switch/index.wxss +1 -1
  194. package/lib/tabs/index.css +1 -1
  195. package/lib/tabs/index.js +10 -7
  196. package/lib/tabs/index.wxml +1 -0
  197. package/lib/tabs/index.wxs +17 -0
  198. package/lib/tabs/index.wxss +1 -1
  199. package/lib/tag/index.css +1 -1
  200. package/lib/tag/index.wxss +1 -1
  201. package/lib/toast/icons.d.ts +3 -0
  202. package/lib/toast/icons.js +12 -0
  203. package/lib/toast/index.js +8 -7
  204. package/lib/toast/index.wxml +3 -7
  205. package/lib/toast/toast.d.ts +2 -0
  206. package/lib/toast/toast.js +2 -0
  207. package/lib/wxs/style.wxs +11 -5
  208. package/lib/wxs/utils.wxs +1 -3
  209. package/package.json +4 -8
  210. package/dist/common/theme/dark.d.ts +0 -344
  211. package/dist/common/theme/dark.js +0 -343
  212. package/dist/common/theme/light.d.ts +0 -344
  213. package/dist/common/theme/light.js +0 -343
  214. package/dist/wxs/is-app-theme-var.wxs +0 -8
  215. package/lib/common/theme/dark.d.ts +0 -344
  216. package/lib/common/theme/dark.js +0 -345
  217. package/lib/common/theme/light.d.ts +0 -344
  218. package/lib/common/theme/light.js +0 -345
  219. package/lib/wxs/is-app-theme-var.wxs +0 -8
@@ -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,6 +43,21 @@ 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',
@@ -58,6 +72,10 @@ var getTime = function (date) {
58
72
  type: String,
59
73
  value: '确定',
60
74
  },
75
+ mode: {
76
+ type: String,
77
+ value: 'day',
78
+ },
61
79
  rangePrompt: String,
62
80
  showRangePrompt: {
63
81
  type: Boolean,
@@ -147,7 +165,8 @@ var getTime = function (date) {
147
165
  subtitle: '',
148
166
  currentDate: null,
149
167
  scrollIntoView: '',
150
- visibleIndex: 0
168
+ visibleIndex: 0,
169
+ months: [],
151
170
  },
152
171
  watch: {
153
172
  minDate: function () {
@@ -158,9 +177,7 @@ var getTime = function (date) {
158
177
  },
159
178
  },
160
179
  created: function () {
161
- this.setData({
162
- currentDate: this.getInitialDate(this.data.defaultDate),
163
- });
180
+ this.initData();
164
181
  },
165
182
  mounted: function () {
166
183
  this.isMounted = true;
@@ -170,29 +187,75 @@ var getTime = function (date) {
170
187
  }
171
188
  },
172
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
+ },
173
230
  reset: function () {
174
231
  this.setData({ currentDate: this.getInitialDate(this.data.defaultDate) });
175
232
  this.scrollIntoView();
176
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
+ },
177
255
  initRect: function () {
178
- var _this = this;
179
256
  if (!this.isMounted)
180
257
  return;
181
- if (this.contentObserver != null) {
182
- this.contentObserver.disconnect();
183
- }
184
- var contentObserver = this.createIntersectionObserver({
185
- thresholds: [0, 0.1, 0.9, 1],
186
- observeAll: true,
187
- });
188
- this.contentObserver = contentObserver;
189
- contentObserver.relativeTo('.smart-calendar__body');
190
- contentObserver.observe('.month', function (res) {
191
- if (res.boundingClientRect.top <= res.relativeRect.top) {
192
- // @ts-ignore
193
- _this.setData({ subtitle: (0, utils_1.formatMonthTitle)(res.dataset.date, _this.properties.locale.subFormatter), visibleIndex: res.dataset.index });
194
- }
195
- });
258
+ this.initData();
196
259
  },
197
260
  limitDateRange: function (date, minDate, maxDate) {
198
261
  if (minDate === void 0) { minDate = null; }
@@ -214,7 +277,7 @@ var getTime = function (date) {
214
277
  if (!defaultDate)
215
278
  return [];
216
279
  var now = (0, utils_1.getToday)().getTime();
217
- if (type === 'range') {
280
+ if (type === 'range' || type === 'week') {
218
281
  if (!Array.isArray(defaultDate)) {
219
282
  defaultDate = [];
220
283
  }
@@ -237,28 +300,8 @@ var getTime = function (date) {
237
300
  return this.limitDateRange(defaultDate);
238
301
  },
239
302
  scrollIntoView: function () {
240
- var _this = this;
241
303
  if (!this.isMounted)
242
304
  return;
243
- (0, utils_2.requestAnimationFrame)(function () {
244
- var _a = _this.data, currentDate = _a.currentDate, type = _a.type, show = _a.show, poppable = _a.poppable, minDate = _a.minDate, maxDate = _a.maxDate;
245
- if (!currentDate)
246
- return;
247
- // @ts-ignore
248
- var targetDate = type === 'single' ? currentDate : currentDate[0];
249
- var displayed = show || !poppable;
250
- if (!targetDate || !displayed) {
251
- return;
252
- }
253
- var months = (0, utils_1.getMonths)(minDate, maxDate);
254
- months.some(function (month, index) {
255
- if ((0, utils_1.compareMonth)(month, targetDate) === 0) {
256
- _this.setData({ scrollIntoView: "month".concat(index), visibleIndex: index });
257
- return true;
258
- }
259
- return false;
260
- });
261
- });
262
305
  },
263
306
  onOpen: function () {
264
307
  this.$emit('open');
@@ -278,7 +321,14 @@ var getTime = function (date) {
278
321
  }
279
322
  var date = event.detail.date;
280
323
  var _a = this.data, type = _a.type, currentDate = _a.currentDate, allowSameDay = _a.allowSameDay;
281
- 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') {
282
332
  // @ts-ignore
283
333
  var startDay_1 = currentDate[0], endDay = currentDate[1];
284
334
  if (startDay_1 && !endDay) {
@@ -332,6 +382,13 @@ var getTime = function (date) {
332
382
  this.select(date, true);
333
383
  }
334
384
  },
385
+ onClickDate: function (event) {
386
+ if (this.data.readonly) {
387
+ return;
388
+ }
389
+ var date = event.detail;
390
+ this.select(date, true);
391
+ },
335
392
  unselect: function (dateArray) {
336
393
  var date = dateArray[0];
337
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 }}"
@@ -32,11 +32,29 @@ function getButtonDisabled(type, currentDate, minRange) {
32
32
  }
33
33
 
34
34
  function getVisible(visibleIndex, curIndex) {
35
- return Math.abs(visibleIndex - curIndex) < 2;
35
+ return visibleIndex === curIndex;
36
+ }
37
+
38
+ function formatMonthTitle(date, formatter = 'YYYY-MM') {
39
+ date = getDate(date);
40
+ const year = date.getFullYear();
41
+ const month =
42
+ date.getMonth() + 1 < 10
43
+ ? `0${date.getMonth() + 1}`
44
+ : date.getMonth() + 1 + '';
45
+ return formatter.replace('YYYY', year + '').replace('MM', month);
46
+ }
47
+
48
+ function formatYearTitle(date, offset, formatter = 'YYYY') {
49
+ date = getDate(date);
50
+ const year = date.getFullYear() + offset;
51
+ return formatter.replace('YYYY', year + '');
36
52
  }
37
53
 
38
54
  module.exports = {
39
55
  getMonths: getMonths,
40
56
  getVisible,
41
- getButtonDisabled: getButtonDisabled
57
+ getButtonDisabled: getButtonDisabled,
58
+ formatMonthTitle,
59
+ formatYearTitle,
42
60
  };
@@ -1 +1 @@
1
- @import '../common/index.wxss';.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.wxss';.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}
@@ -1,4 +1,4 @@
1
- export declare const ROW_HEIGHT = 64;
1
+ export declare const ROW_HEIGHT = 34;
2
2
  export declare function formatMonthTitle(date: Date, formatter?: string): string;
3
3
  export declare function compareMonth(date1: Date | number, date2: Date | number): 0 | 1 | -1;
4
4
  export declare function compareDay(day1: Date | number, day2: Date | number): 0 | 1 | -1;
@@ -10,3 +10,9 @@ export declare function calcDateNum(date: [Date, Date]): number;
10
10
  export declare function copyDates(dates: Date | Date[]): Date | Date[];
11
11
  export declare function getMonthEndDay(year: number, month: number): number;
12
12
  export declare function getMonths(minDate: number, maxDate: number): number[];
13
+ export declare function getYears(minDate: number, maxDate: number): number[];
14
+ export declare function getCurrentIndex(currentDate: any, months: any): number;
15
+ export declare function getWeekStartAndEnd(date: Date): {
16
+ weekStart: Date;
17
+ weekEnd: Date;
18
+ };
@@ -1,14 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMonths = exports.getMonthEndDay = exports.copyDates = exports.calcDateNum = exports.getToday = exports.getNextDay = exports.getPrevDay = exports.getDayByOffset = exports.compareDay = exports.compareMonth = exports.formatMonthTitle = exports.ROW_HEIGHT = void 0;
4
- exports.ROW_HEIGHT = 64;
3
+ exports.getWeekStartAndEnd = exports.getCurrentIndex = exports.getYears = exports.getMonths = exports.getMonthEndDay = exports.copyDates = exports.calcDateNum = exports.getToday = exports.getNextDay = exports.getPrevDay = exports.getDayByOffset = exports.compareDay = exports.compareMonth = exports.formatMonthTitle = exports.ROW_HEIGHT = void 0;
4
+ exports.ROW_HEIGHT = 34;
5
5
  function formatMonthTitle(date, formatter) {
6
6
  if (formatter === void 0) { formatter = 'YYYY-MM'; }
7
7
  if (!(date instanceof Date)) {
8
8
  date = new Date(date);
9
9
  }
10
10
  var year = date.getFullYear();
11
- var month = date.getMonth() + 1 < 10 ? "0".concat(date.getMonth() + 1) : date.getMonth() + 1 + "";
11
+ var month = date.getMonth() + 1 < 10
12
+ ? "0".concat(date.getMonth() + 1)
13
+ : date.getMonth() + 1 + '';
12
14
  return formatter.replace('YYYY', year + '').replace('MM', month);
13
15
  }
14
16
  exports.formatMonthTitle = formatMonthTitle;
@@ -98,3 +100,50 @@ function getMonths(minDate, maxDate) {
98
100
  return months;
99
101
  }
100
102
  exports.getMonths = getMonths;
103
+ function getYears(minDate, maxDate) {
104
+ var years = [];
105
+ var cursor = new Date(minDate);
106
+ cursor.setDate(1);
107
+ do {
108
+ years.push(cursor.getTime());
109
+ cursor.setFullYear(cursor.getFullYear() + 1);
110
+ } while (compareMonth(cursor, maxDate) !== 1);
111
+ return years;
112
+ }
113
+ exports.getYears = getYears;
114
+ function findLastGreaterOrEqual(arr, n) {
115
+ var left = 0;
116
+ var right = arr.length - 1;
117
+ var result = -1; // 初始化为 -1,若无符合条件的元素返回 -1
118
+ while (left <= right) {
119
+ var mid = Math.floor((left + right) / 2);
120
+ if (arr[mid] <= n) {
121
+ result = mid; // 暂存满足条件的索引
122
+ left = mid + 1; // 继续向右搜索更大的满足条件的元素
123
+ }
124
+ else {
125
+ right = mid - 1;
126
+ }
127
+ }
128
+ return result;
129
+ }
130
+ function getCurrentIndex(currentDate, months) {
131
+ if (Array.isArray(currentDate)) {
132
+ currentDate = currentDate[0];
133
+ }
134
+ return findLastGreaterOrEqual(months, currentDate);
135
+ }
136
+ exports.getCurrentIndex = getCurrentIndex;
137
+ function getWeekStartAndEnd(date) {
138
+ var startOfWeek = new Date(date);
139
+ var dayOfWeek = startOfWeek.getDay();
140
+ var diffToMonday = (dayOfWeek + 6) % 7;
141
+ startOfWeek.setDate(startOfWeek.getDate() - diffToMonday);
142
+ var endOfWeek = new Date(startOfWeek);
143
+ endOfWeek.setDate(startOfWeek.getDate() + 6);
144
+ return {
145
+ weekStart: startOfWeek,
146
+ weekEnd: endOfWeek,
147
+ };
148
+ }
149
+ exports.getWeekStartAndEnd = getWeekStartAndEnd;
@@ -1 +1 @@
1
- @import '../common/index.css';.smart-checkbox{align-items:center;display:flex;overflow:hidden;-webkit-user-select:none;user-select:none}.smart-checkbox--horizontal{margin-right:12px}.smart-checkbox__icon-wrap,.smart-checkbox__label{line-height:var(--checkbox-size,20px)}.smart-checkbox__icon-wrap{flex:none}.smart-checkbox__icon{align-items:center;border:1px solid var(--checkbox-border-color,#c8c9cc);box-sizing:border-box;color:transparent;display:flex;font-size:var(--checkbox-size,20px);height:1em;justify-content:center;text-align:center;transition-duration:var(--checkbox-transition-duration,.2s);transition-property:color,border-color,background-color;width:1em}.smart-checkbox__icon--round{border-radius:100%}.smart-checkbox__icon--checked{background-color:var(--checkbox-checked-icon-color,#1989fa);border-color:var(--checkbox-checked-icon-color,#1989fa);color:#fff}.smart-checkbox__icon--disabled{background-color:var(--checkbox-disabled-background-color,var(--app-B6-N7,rgba(0,0,0,.1)));border-color:var(--checkbox-disabled-icon-color,var(--app-B6-N7,rgba(0,0,0,.1)))}.smart-checkbox__icon--disabled.smart-checkbox__icon--checked{color:var(--checkbox-disabled-icon-color,var(--app-B6-N7,rgba(0,0,0,.1)))}.smart-checkbox__label{word-wrap:break-word;color:var(--checkbox-label-color,var(--app-B6-N3,rgba(0,0,0,.5)));padding-left:var(--checkbox-label-margin,10px)}.smart-checkbox__label--left{float:left;margin:0 var(--checkbox-label-margin,10px) 0 0}.smart-checkbox__label--disabled{color:var(--checkbox-disabled-label-color,var(--app-B6-N7,rgba(0,0,0,.1)))}.smart-checkbox__label:empty{margin:0}
1
+ @import '../common/index.css';.smart-checkbox{align-items:center;display:flex;overflow:hidden;-webkit-user-select:none;user-select:none}.smart-checkbox--horizontal{margin-right:12px}.smart-checkbox__icon-wrap,.smart-checkbox__label{line-height:var(--checkbox-size,24px)}.smart-checkbox__icon-wrap{display:flex;flex:none}.smart-checkbox__icon{align-items:center;border:2px solid var(--checkbox-border-color,var(--app-B6-N6,rgba(0,0,0,.2)));border-radius:var(--checkbox-border-radius,4px);box-sizing:border-box;color:transparent;display:flex;font-size:var(--checkbox-size,24px);height:1em;justify-content:center;text-align:center;transition-duration:var(--checkbox-transition-duration,.2s);transition-property:color,border,background-color;width:1em}.smart-checkbox__icon--round{border-radius:100%}.smart-checkbox__icon--checked{background-color:var(--checkbox-checked-icon-color,var(--app-M4,#1989fa));border:none;color:#fff}.smart-checkbox__icon--disabled{opacity:.3}.smart-checkbox__label{word-wrap:break-word;color:var(--checkbox-label-color,var(--app-B6-N1,#000));font-size:var(--checkbox-label-size,12px);padding-left:var(--checkbox-label-margin,10px)}.smart-checkbox__label--left{float:left;margin:0 var(--checkbox-label-margin,10px) 0 0}.smart-checkbox__label--disabled{color:var(--checkbox-disabled-label-color,var(--app-B6-N1,#000))}.smart-checkbox__label:empty{margin:0}
@@ -30,7 +30,7 @@ function emit(target, value) {
30
30
  },
31
31
  iconSize: {
32
32
  type: null,
33
- value: 20,
33
+ value: 24,
34
34
  },
35
35
  },
36
36
  data: {