@tuya-miniapp/smart-ui 2.1.10 → 2.1.11-beta-2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/dist/action-sheet/index.css +1 -1
  2. package/dist/action-sheet/index.js +0 -8
  3. package/dist/action-sheet/index.wxml +1 -1
  4. package/dist/action-sheet/index.wxss +1 -1
  5. package/dist/cell/index.js +10 -4
  6. package/dist/common/utils.d.ts +1 -0
  7. package/dist/common/utils.js +6 -0
  8. package/dist/datetime-picker/demo/index.js +20 -0
  9. package/dist/datetime-picker/index.js +92 -14
  10. package/dist/datetime-picker/index.wxml +1 -0
  11. package/dist/field/index.js +1 -1
  12. package/dist/icon/index.wxs +3 -1
  13. package/dist/notice-bar/index.js +1 -1
  14. package/dist/picker/demo/index.js +1 -0
  15. package/dist/picker/index.wxml +2 -1
  16. package/dist/picker/shared.d.ts +4 -0
  17. package/dist/picker/shared.js +4 -0
  18. package/dist/picker-column/index.css +1 -1
  19. package/dist/picker-column/index.js +154 -44
  20. package/dist/picker-column/index.wxml +22 -11
  21. package/dist/picker-column/index.wxs +22 -5
  22. package/dist/picker-column/index.wxss +1 -1
  23. package/dist/stepper/index.js +2 -0
  24. package/dist/tag/index.js +1 -1
  25. package/lib/action-sheet/index.css +1 -1
  26. package/lib/action-sheet/index.js +0 -8
  27. package/lib/action-sheet/index.wxml +1 -1
  28. package/lib/action-sheet/index.wxss +1 -1
  29. package/lib/cell/index.js +15 -9
  30. package/lib/common/utils.d.ts +1 -0
  31. package/lib/common/utils.js +8 -1
  32. package/lib/datetime-picker/demo/index.js +20 -0
  33. package/lib/datetime-picker/index.js +97 -18
  34. package/lib/datetime-picker/index.wxml +1 -0
  35. package/lib/field/index.js +2 -2
  36. package/lib/icon/index.wxs +3 -1
  37. package/lib/notice-bar/index.js +2 -2
  38. package/lib/picker/demo/index.js +1 -0
  39. package/lib/picker/index.wxml +2 -1
  40. package/lib/picker/shared.d.ts +4 -0
  41. package/lib/picker/shared.js +4 -0
  42. package/lib/picker-column/index.css +1 -1
  43. package/lib/picker-column/index.js +192 -44
  44. package/lib/picker-column/index.wxml +22 -11
  45. package/lib/picker-column/index.wxs +22 -5
  46. package/lib/picker-column/index.wxss +1 -1
  47. package/lib/stepper/index.js +2 -0
  48. package/lib/tag/index.js +2 -2
  49. package/package.json +3 -3
@@ -1,7 +1,16 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { SmartComponent } from '../common/component';
2
11
  import { range } from '../common/utils';
3
12
  import { isObj } from '../common/validator';
4
- const DEFAULT_DURATION = 200;
13
+ const DEFAULT_DURATION = 400;
5
14
  SmartComponent({
6
15
  classes: ['active-class'],
7
16
  props: {
@@ -25,11 +34,15 @@ SmartComponent({
25
34
  type: Number,
26
35
  value: 0,
27
36
  },
37
+ changeAnimation: {
38
+ type: Boolean,
39
+ value: true,
40
+ },
28
41
  activeIndex: {
29
42
  type: Number,
30
43
  value: -1,
31
44
  observer(index) {
32
- this.setIndex(index, false, true);
45
+ this.setIndex(index, false, this.data.changeAnimation);
33
46
  },
34
47
  },
35
48
  unit: {
@@ -48,57 +61,157 @@ SmartComponent({
48
61
  renderStart: 0,
49
62
  animate: false,
50
63
  maxText: '',
64
+ timer: null,
65
+ // animationIndex: -1,
66
+ preOffsetList: [],
51
67
  },
52
68
  created() {
53
69
  const { defaultIndex, activeIndex, options } = this.data;
54
70
  this.updateUint(options);
55
- this.setIndex(activeIndex !== -1 ? activeIndex : defaultIndex, false, true);
71
+ this.setIndex(activeIndex !== -1 ? activeIndex : defaultIndex, false, this.data.changeAnimation);
56
72
  },
57
73
  methods: {
58
74
  getCount() {
59
75
  return this.data.options.length;
60
76
  },
61
77
  onTouchStart(event) {
78
+ if (this.data.timer) {
79
+ clearTimeout(this.data.timer);
80
+ this.setData({
81
+ timer: null,
82
+ });
83
+ }
62
84
  this.setData({
63
85
  startY: event.touches[0].clientY,
64
86
  startOffset: this.data.offset,
65
- duration: 0,
87
+ duration: 100,
88
+ timer: null,
89
+ preOffsetList: [this.data.offset],
66
90
  });
67
91
  },
68
92
  onTouchMove(event) {
69
93
  const { data } = this;
94
+ const { preOffsetList } = data;
70
95
  const deltaY = event.touches[0].clientY - data.startY;
96
+ const offset = range(data.startOffset + deltaY, -(this.getCount() * data.itemHeight), data.itemHeight);
97
+ const direction = this.checkIsDown(offset);
98
+ // 上一次滚动的索引
99
+ const preIndex = range(Math.round(-preOffsetList[preOffsetList.length - 1] / data.itemHeight), 0, this.getCount() - 1);
100
+ // 最终定位索引
101
+ const index = range(Math.round(-offset / data.itemHeight), 0, this.getCount() - 1);
102
+ if ((direction === 'up' && index < data.renderStart + 8) ||
103
+ (direction === 'down' && index > data.renderStart + data.renderNum - 8)) {
104
+ this.updateVisibleOptions(index);
105
+ }
106
+ // 索引变化时 粗发震动反馈
107
+ if (index !== preIndex) {
108
+ // @ts-ignore
109
+ this.vibrateShort();
110
+ }
111
+ // const animationIndex = Math.abs(-offset / data.itemHeight);
71
112
  this.setData({
72
- offset: range(data.startOffset + deltaY, -(this.getCount() * data.itemHeight), data.itemHeight),
113
+ offset,
114
+ // animationIndex: animationIndex,
115
+ preOffsetList: [...data.preOffsetList, offset],
116
+ animate: false,
73
117
  });
74
118
  },
75
119
  onTouchEnd() {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ const { data } = this;
122
+ const { preOffsetList } = data;
123
+ let preOffset = Math.max(Math.abs(preOffsetList[preOffsetList.length - 3] - preOffsetList[preOffsetList.length - 4]), Math.abs(preOffsetList[preOffsetList.length - 2] - preOffsetList[preOffsetList.length - 3]), Math.abs(preOffsetList[preOffsetList.length - 1] - preOffsetList[preOffsetList.length - 2]));
124
+ if (isNaN(preOffset))
125
+ preOffset = 0;
126
+ preOffset = Math.min(preOffset, 40);
127
+ // 三次同样的距离 说明用户一直在顶部或者底部滑动 或在move途中已经是上下边缘了
128
+ const isSameTouch = (preOffsetList[preOffsetList.length - 1] === preOffsetList[preOffsetList.length - 2] &&
129
+ preOffsetList[preOffsetList.length - 2] === preOffsetList[preOffsetList.length - 3]) ||
130
+ preOffsetList[preOffsetList.length - 1] === -(this.getCount() * data.itemHeight) ||
131
+ preOffsetList[preOffsetList.length - 1] === data.itemHeight;
132
+ // 是否是向下滚动
133
+ const direction = this.checkIsDown();
134
+ // 当滚动速度比较慢时(<3) 不增加惯性滚动距离
135
+ const offset = Math.abs(preOffset) < 3 || isSameTouch || !direction
136
+ ? data.offset
137
+ : data.offset + (direction === 'down' ? -preOffset : preOffset) * 10;
138
+ // 有数字的最大滚动距离
139
+ const countHeight = (this.getCount() - 1) * data.itemHeight;
140
+ // 动画最大滚动距离 上下各加一个 data.itemHeight 的滚动空间
141
+ const animationOffset = range(offset, -(this.getCount() * data.itemHeight), data.itemHeight);
142
+ // 最终定位滚动位置
143
+ const finOffset = animationOffset < -countHeight ? -countHeight : animationOffset > 0 ? 0 : animationOffset;
144
+ // 获取索引
145
+ const index = range(Math.round(-finOffset / data.itemHeight), 0, this.getCount() - 1);
146
+ // 获取索引的标准距离
147
+ const offsetData = -index * data.itemHeight;
148
+ // 增加惯性音效
149
+ if (Math.abs(offsetData - data.offset) > data.itemHeight && !isSameTouch) {
150
+ const countVibrate = Math.abs(offsetData - data.offset) / data.itemHeight;
151
+ // @ts-ignore
152
+ this.vibrateShort(Math.floor(countVibrate), 800);
153
+ }
154
+ // 最终定位索引
155
+ this.setData({
156
+ duration: isSameTouch ? 150 : 800,
157
+ // animationIndex: index,
158
+ offset: offsetData,
159
+ animate: true,
160
+ });
161
+ // 更新列表
162
+ if ((direction === 'up' && index < data.renderStart + 8) ||
163
+ (direction === 'down' && index > data.renderStart + data.renderNum - 8)) {
164
+ yield this.updateVisibleOptions(index);
165
+ }
166
+ // 更新索引
167
+ if (index !== data.currentIndex) {
168
+ this.setData({
169
+ timer: setTimeout(() => __awaiter(this, void 0, void 0, function* () {
170
+ this.setIndex(index, true, false);
171
+ // await this.setData({
172
+ // timer: null,
173
+ // currentIndex: index,
174
+ // // animationIndex: index,
175
+ // });
176
+ // this.$emit('change', index);
177
+ }), isSameTouch ? 150 : 800),
178
+ });
179
+ }
180
+ });
181
+ },
182
+ checkIsDown(curr) {
76
183
  const { data } = this;
77
- if (data.offset !== data.startOffset) {
78
- const index = range(Math.round(-data.offset / data.itemHeight), 0, this.getCount() - 1);
79
- this.setIndex(index, true, true);
80
- }
184
+ const { preOffsetList } = data;
185
+ const currOffset = curr === undefined ? preOffsetList[preOffsetList.length - 1] : curr;
186
+ const preOffset = curr === undefined
187
+ ? preOffsetList[preOffsetList.length - 2]
188
+ : preOffsetList[preOffsetList.length - 1];
189
+ if (currOffset === undefined || preOffset === undefined || currOffset === preOffset)
190
+ return;
191
+ return currOffset < preOffset ? 'down' : 'up';
81
192
  },
82
- onTransitionEnd() {
83
- const { options, visibleItemCount, currentIndex } = this.data;
84
- let renderNum = 0;
85
- let renderStart = 0;
86
- if (visibleItemCount < 20 && options.length > visibleItemCount) {
87
- // 选项多于20个时,进行列表优化
88
- renderNum = Math.max(visibleItemCount * 2, 20);
89
- renderStart = Math.max(0, currentIndex - renderNum / 2);
90
- const optionsV = options.slice(renderStart, renderStart + renderNum);
91
- this.setData({ optionsV, renderStart, renderNum, animate: false });
92
- }
93
- else {
94
- this.setData({ animate: false });
95
- }
96
- if (this.fireChange) {
97
- this.$emit('change', currentIndex);
193
+ vibrateShort(count, time = 1000) {
194
+ if (!count) {
195
+ // @ts-ignore
196
+ ty.vibrateShort({ type: 'light' });
197
+ return;
98
198
  }
199
+ let has = 0;
200
+ const timer = setInterval(() => {
201
+ if (has >= count) {
202
+ clearInterval(timer);
203
+ return;
204
+ }
205
+ has++;
206
+ this.vibrateShort();
207
+ }, time / count - 20);
99
208
  },
100
209
  onClickItem(event) {
101
210
  const { index } = event.currentTarget.dataset;
211
+ if (index === this.data.currentIndex || index < 0 || index > this.data.options.length - 1) {
212
+ return;
213
+ }
214
+ this.vibrateShort(Math.abs(index - this.data.currentIndex), DEFAULT_DURATION);
102
215
  this.setIndex(index, true, true);
103
216
  },
104
217
  updateUint(options) {
@@ -120,7 +233,7 @@ SmartComponent({
120
233
  if (visibleItemCount < 20 && options.length > visibleItemCount) {
121
234
  let renderNum = 0;
122
235
  let renderStart = 0;
123
- // 选项多于20个时,进行列表优化
236
+ // 选项多于 20 个时,进行列表优化
124
237
  renderNum = Math.max(visibleItemCount * 2, 20);
125
238
  renderStart = Math.max(0, targetIndex - renderNum / 2);
126
239
  const renderEnd = Math.min(options.length, renderStart + renderNum);
@@ -159,35 +272,32 @@ SmartComponent({
159
272
  const { data } = this;
160
273
  return isObj(option) && data.valueKey in option ? option[data.valueKey] : option;
161
274
  },
162
- setIndex(index, userAction, animate) {
275
+ setIndex(index, userAction, animate, time = DEFAULT_DURATION) {
163
276
  const { data } = this;
164
277
  index = this.adjustIndex(index) || 0;
165
278
  const offset = -index * data.itemHeight;
166
- this.fireChange = false;
167
279
  if (index !== data.currentIndex) {
168
280
  // 需要动画的情况下,保持最大的截取
281
+ this.updateVisibleOptions(index);
169
282
  if (animate) {
170
- return this.updateVisibleOptions(index).then(() => {
171
- this.set({
172
- currentIndex: index,
173
- offset,
174
- animate: true,
175
- duration: DEFAULT_DURATION,
176
- }).then(() => {
177
- if (!userAction)
178
- return;
179
- if ([0, data.optionsV.length - 1].includes(index)) {
180
- this.$emit('change', index);
181
- return;
182
- }
183
- this.fireChange = true;
184
- });
283
+ return this.set({
284
+ currentIndex: index,
285
+ // animationIndex: index,
286
+ offset,
287
+ animate: true,
288
+ duration: time,
289
+ }).then(() => {
290
+ if (!userAction)
291
+ return;
292
+ console.log('change', index);
293
+ this.$emit('change', index);
185
294
  });
186
295
  }
187
296
  return this.set({
188
297
  optionsV: data.options,
189
298
  offset,
190
299
  currentIndex: index,
300
+ // animationIndex: index,
191
301
  renderStart: 0,
192
302
  animate: !!animate,
193
303
  }).then(() => {
@@ -200,7 +310,7 @@ SmartComponent({
200
310
  const { options } = this.data;
201
311
  for (let i = 0; i < options.length; i++) {
202
312
  if (this.getOptionText(options[i]) === value) {
203
- return this.setIndex(i, false, true);
313
+ return this.setIndex(i, false, this.data.changeAnimation);
204
314
  }
205
315
  }
206
316
  return Promise.resolve();
@@ -9,18 +9,29 @@
9
9
  bind:touchend="onTouchEnd"
10
10
  bind:touchcancel="onTouchEnd"
11
11
  >
12
- <view style="{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount, animate, duration, renderStart, unit }) }}"
13
- bind:transitionend="onTransitionEnd"
14
- id="options">
15
- <view
16
- wx:for="{{ optionsV }}"
17
- wx:for-item="option"
12
+ <view class="smart-picker-column__offset" style="height: {{ itemHeight * options.length }}px;{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount, animate, duration, renderStart, unit }) }}" id="options">
13
+ <view class="smart-picker-column__visual" style="{{ computed.wrapperInterStyle({ offset, itemHeight, visibleItemCount, renderStart }) }}">
14
+ <view
15
+ wx:for="{{ optionsV }}"
16
+ wx:for-item="option"
17
+ wx:key="index"
18
+ data-index="{{ renderStart + index }}"
19
+ style="height: {{ itemHeight }}px;{{renderStart + index === currentIndex ? activeStyle : ''}}"
20
+ class="smart-ellipsis {{ utils.bem('picker-column__item', { disabled: option && option.disabled, selected: renderStart + index === currentIndex }) }} {{ renderStart + index === currentIndex ? 'active-class' : '' }}"
21
+ >
22
+ {{ computed.optionText(option, valueKey) }}
23
+ </view>
24
+ </view>
25
+ </view>
26
+ <view class="smart-picker-column__mask">
27
+ <view
28
+ wx:for="{{ visibleItemCount }}"
18
29
  wx:key="index"
19
- data-index="{{ renderStart + index }}"
20
- style="height: {{ itemHeight }}px;{{renderStart + index === currentIndex ? activeStyle : ''}}"
21
- class="smart-ellipsis {{ utils.bem('picker-column__item', { disabled: option && option.disabled, selected: renderStart + index === currentIndex }) }} {{ renderStart + index === currentIndex ? 'active-class' : '' }}"
22
- bindtap="onClickItem"
23
- >{{ computed.optionText(option, valueKey) }}</view>
30
+ class="smart-picker-column__mask__item"
31
+ data-index="{{ currentIndex + index - 2 }}"
32
+ bind:tap="onClickItem"
33
+ >
34
+ </view>
24
35
  </view>
25
36
  <view wx:if="{{unit}}" class="smart-picker-column__unit" style="height: {{ itemHeight }}px">
26
37
  <view class="smart-picker-column__unit_text smart-picker-column__unit_hidden" >{{unit}}</view>
@@ -20,15 +20,11 @@ function rootStyle(data) {
20
20
  function wrapperStyle(data) {
21
21
  var offset =
22
22
  data.offset + (data.itemHeight * (data.visibleItemCount - 1)) / 2;
23
- // 长列表优化
24
- if (data.renderStart) {
25
- offset += data.renderStart * data.itemHeight;
26
- }
27
23
  offset = addUnit(offset);
28
24
  if (data.animate) {
29
25
  return style({
30
26
  'text-indent': data.unit ? '-8rpx' : '0',
31
- transition: 'transform ' + data.duration + 'ms',
27
+ transition: 'transform ' + data.duration + 'ms ease-out',
32
28
  'line-height': addUnit(data.itemHeight),
33
29
  transform: 'translate3d(0, ' + offset + ', 0)',
34
30
  });
@@ -40,8 +36,29 @@ function wrapperStyle(data) {
40
36
  });
41
37
  }
42
38
 
39
+ function wrapperInterStyle(data) {
40
+ var offset = data.renderStart * data.itemHeight;
41
+ offset = addUnit(offset);
42
+ return style({
43
+ 'padding-top': offset,
44
+ });
45
+ }
46
+
47
+ // function wrapperItemStyle(data) {
48
+ // const { index, animationIndex: currentIndex } = data;
49
+ // const offsetIndex = currentIndex - index;
50
+ // const rotateX = offsetIndex * 25 > 0 ? Math.min(offsetIndex * 25, 25 * 2) : Math.max(offsetIndex * 25, -25 * 2)
51
+ // const scale = Math.min(Math.abs(offsetIndex * 0.05), 0.05 * 2)
52
+ // return style({
53
+ // transition: 'transform ' + data.duration + 'ms ease-out',
54
+ // transform: `rotateX(${rotateX}deg) scale(${1 - scale})`
55
+ // });
56
+ // }
57
+
43
58
  module.exports = {
44
59
  optionText: optionText,
45
60
  rootStyle: rootStyle,
46
61
  wrapperStyle: wrapperStyle,
62
+ wrapperInterStyle: wrapperInterStyle,
63
+ // wrapperItemStyle: wrapperItemStyle
47
64
  };
@@ -1 +1 @@
1
- @import '../common/index.wxss';.smart-picker-column{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-size:var(--picker-option-font-size,16px);font-weight:var(--font-weight-bold,500);position:relative;text-align:center}.smart-picker-column__item{padding:0 5px}.smart-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--font-weight-bold,500)}.smart-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.smart-picker-column__unit{align-items:center;display:flex;justify-content:center;position:absolute;top:50%;transform:translateY(-50%);width:100%}.smart-picker-column__unit_text{color:var(--picker-option-unit-text-color,var(--app-B6-N4,rgba(0,0,0,.4)));font-size:var(--picker-option-unit-font-size,12px)}.smart-picker-column__unit_hidden{opacity:0}.smart-picker-column__max-text{font-weight:var(--font-weight-bold,500);opacity:0}
1
+ @import '../common/index.wxss';.smart-picker-column{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-size:var(--picker-option-font-size,16px);font-weight:var(--font-weight-bold,500);text-align:center}.smart-picker-column,.smart-picker-column__offset{position:relative;width:100%}.smart-picker-column__visual{position:absolute;top:0;width:100%}.smart-picker-column__item{pointer-events:none}.smart-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--font-weight-bold,500)}.smart-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.smart-picker-column__mask{background:transparent;display:flex;flex-direction:column;height:100%;position:absolute;top:0;width:100%;z-index:10}.smart-picker-column__mask__item{flex:1}.smart-picker-column__unit{align-items:center;display:flex;justify-content:center;position:absolute;top:50%;transform:translateY(-50%);width:100%}.smart-picker-column__unit_text{color:var(--picker-option-unit-text-color,var(--app-B6-N4,rgba(0,0,0,.4)));font-size:var(--picker-option-unit-font-size,12px)}.smart-picker-column__unit_hidden{opacity:0}.smart-picker-column__max-text{font-weight:var(--font-weight-bold,500);opacity:0}
@@ -147,6 +147,8 @@ SmartComponent({
147
147
  const value = this.format(add(+this.data.currentValue, diff));
148
148
  this.emitChange(value);
149
149
  this.$emit(type);
150
+ // @ts-ignore
151
+ ty.vibrateShort({ type: 'light' });
150
152
  },
151
153
  longPressStep() {
152
154
  this.longPressTimer = setTimeout(() => {
package/dist/tag/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import Xmark from '@tuya-miniapp/icons/dist/svg/Xmark';
1
+ import Xmark from '@tuya-miniapp/icons/dist/svg/Xmark.js';
2
2
  import { SmartComponent } from '../common/component';
3
3
  SmartComponent({
4
4
  props: {
@@ -1 +1 @@
1
- @import '../common/index.css';.smart-action-sheet{border-radius:var(--popup-round-border-radius,var(--popup-round-border-radius,16px))!important;color:var(--action-sheet-item-text-color,var(--app-B4-N1,#000));left:var(--action-sheet-left,16px)!important;margin:var(--action-sheet-margin,0 0 16px);max-height:var(--action-sheet-max-height,90%)!important;width:var(--action-sheet-width,calc(100% - 32px))!important}.smart-action-sheet__list{max-height:325px;overflow-y:scroll}.smart-action-sheet__icon{font-size:var(--action-sheet-item-icon-size,28px);margin:var(--action-sheet-item-icon-margin,16px 16px 0 0);position:absolute;right:0;top:0}.smart-action-sheet__item{border-radius:var(--action-sheet-item-border-radius,0);color:var(--action-sheet-item-text-color,var(--app-B4-N1,#000))}.smart-action-sheet__item:not(:last-child){border-bottom:1px solid var(--action-sheet-header-border-color,var(--app-B4-N7,rgba(0,0,0,.1)))}.smart-action-sheet__cancel,.smart-action-sheet__confirm,.smart-action-sheet__item{background-color:var(--action-sheet-item-background,var(--app-B4,#fff));font-size:var(--action-sheet-item-font-size,16px);font-weight:var(--action-sheet-item-font-weight,normal);line-height:var(--action-sheet-item-line-height,24px);padding:16px;text-align:center;width:100%}.smart-action-sheet__cancel--hover,.smart-action-sheet__confirm--hover,.smart-action-sheet__item--hover{background-color:var(--action-sheet-active-color,var(--app-B1,#f6f7fb))}.smart-action-sheet__cancel:after,.smart-action-sheet__confirm:after,.smart-action-sheet__item:after{border-width:0}.smart-action-sheet__cancel{color:var(--action-sheet-cancel-text-color,var(--app-B4-N3,rgba(0,0,0,.5)))}.smart-action-sheet__confirm{color:var(--action-sheet-confirm-text-color,var(--app-B4-N1,#000));font-weight:var(--action-sheet-confirm-font-weight,500)}.smart-action-sheet__gap{background-color:var(--action-sheet-footer-padding-color,var(--app-B4-N9,rgba(0,0,0,.05)));display:block;height:var(--action-sheet-footer-padding-top,8px)}.smart-action-sheet__item--disabled{opacity:var(--action-sheet-item-disabled-opacity,.3)}.smart-action-sheet__item--disabled.smart-action-sheet__item--hover{background-color:var(--action-sheet-item-background,var(--app-B4,#fff))}.smart-action-sheet__subname{color:var(--action-sheet-subname-color,var(--app-B4-N3,rgba(0,0,0,.5)));font-size:var(--action-sheet-subname-font-size,12px);line-height:var(--action-sheet-subname-line-height,20px);margin-top:var(--padding-xs,8px)}.smart-action-sheet__header{border-bottom:1px solid var(--action-sheet-header-border-color,var(--app-B4-N7,rgba(0,0,0,.1)));color:var(--action-sheet-header-color,var(--app-B4-N3,rgba(0,0,0,.5)));font-size:var(--action-sheet-header-font-size,16px);font-weight:var(--action-sheet-header-font-weight,normal);line-height:var(--action-sheet-header-height,56px);text-align:center}.smart-action-sheet__description{color:var(--action-sheet-description-color,var(--app-B4-N3,rgba(0,0,0,.5)));font-size:var(--action-sheet-description-font-size,14px);line-height:var(--action-sheet-description-line-height,20px);padding:20px var(--padding-md,16px);text-align:center}.smart-action-sheet__loading{color:inherit!important;display:flex!important}.smart-action-sheet__footer{align-items:center;background-color:var(--action-sheet-item-background,var(--app-B4,#fff));display:flex;font-size:var(--action-sheet-item-font-size,16px);justify-content:space-around;line-height:var(--action-sheet-item-line-height,22px);text-align:center}
1
+ @import '../common/index.css';.smart-action-sheet{border-radius:var(--popup-round-border-radius,var(--popup-round-border-radius,16px))!important;color:var(--action-sheet-item-text-color,var(--app-B4-N1,#000));left:var(--action-sheet-left,16px)!important;margin:var(--action-sheet-margin,0 0 16px);max-height:var(--action-sheet-max-height,90%)!important;width:var(--action-sheet-width,calc(100% - 32px))!important}.smart-action-sheet__list{max-height:325px;overflow-y:scroll}.smart-action-sheet__icon{--icon-color:var(--action-sheet-active-icon-color,var(--app-M1,#3678e3));font-size:var(--action-sheet-item-icon-size,28px);margin:var(--action-sheet-item-icon-margin,16px 16px 0 0);position:absolute;right:0;top:0}.smart-action-sheet__item{border-radius:var(--action-sheet-item-border-radius,0);color:var(--action-sheet-item-text-color,var(--app-B4-N1,#000))}.smart-action-sheet__item:not(:last-child){border-bottom:1px solid var(--action-sheet-header-border-color,var(--app-B4-N7,rgba(0,0,0,.1)))}.smart-action-sheet__cancel,.smart-action-sheet__confirm,.smart-action-sheet__item{background-color:var(--action-sheet-item-background,var(--app-B4,#fff));font-size:var(--action-sheet-item-font-size,16px);font-weight:var(--action-sheet-item-font-weight,normal);line-height:var(--action-sheet-item-line-height,24px);padding:16px;text-align:center;width:100%}.smart-action-sheet__cancel--hover,.smart-action-sheet__confirm--hover,.smart-action-sheet__item--hover{background-color:var(--action-sheet-active-color,var(--app-B1,#f6f7fb))}.smart-action-sheet__cancel:after,.smart-action-sheet__confirm:after,.smart-action-sheet__item:after{border-width:0}.smart-action-sheet__cancel{color:var(--action-sheet-cancel-text-color,var(--app-B4-N3,rgba(0,0,0,.5)))}.smart-action-sheet__confirm{color:var(--action-sheet-confirm-text-color,var(--app-B4-N1,#000));font-weight:var(--action-sheet-confirm-font-weight,500)}.smart-action-sheet__gap{background-color:var(--action-sheet-footer-padding-color,var(--app-B4-N9,rgba(0,0,0,.05)));display:block;height:var(--action-sheet-footer-padding-top,8px)}.smart-action-sheet__item--disabled{opacity:var(--action-sheet-item-disabled-opacity,.3)}.smart-action-sheet__item--disabled.smart-action-sheet__item--hover{background-color:var(--action-sheet-item-background,var(--app-B4,#fff))}.smart-action-sheet__subname{color:var(--action-sheet-subname-color,var(--app-B4-N3,rgba(0,0,0,.5)));font-size:var(--action-sheet-subname-font-size,12px);line-height:var(--action-sheet-subname-line-height,20px);margin-top:var(--padding-xs,8px)}.smart-action-sheet__header{border-bottom:1px solid var(--action-sheet-header-border-color,var(--app-B4-N7,rgba(0,0,0,.1)));color:var(--action-sheet-header-color,var(--app-B4-N3,rgba(0,0,0,.5)));font-size:var(--action-sheet-header-font-size,16px);font-weight:var(--action-sheet-header-font-weight,normal);line-height:var(--action-sheet-header-height,56px);text-align:center}.smart-action-sheet__description{color:var(--action-sheet-description-color,var(--app-B4-N3,rgba(0,0,0,.5)));font-size:var(--action-sheet-description-font-size,14px);line-height:var(--action-sheet-description-line-height,20px);padding:20px var(--padding-md,16px);text-align:center}.smart-action-sheet__loading{color:inherit!important;display:flex!important}.smart-action-sheet__footer{align-items:center;background-color:var(--action-sheet-item-background,var(--app-B4,#fff));display:flex;font-size:var(--action-sheet-item-font-size,16px);justify-content:space-around;line-height:var(--action-sheet-item-line-height,22px);text-align:center}
@@ -55,14 +55,6 @@ var button_1 = require("../mixins/button");
55
55
  },
56
56
  data: {
57
57
  checkMarkIcon: Check_1.default,
58
- checkMarkIconColor: '#3678E3',
59
- },
60
- mounted: function () {
61
- var _a;
62
- // @ts-ignore
63
- var themeInfo = (_a = ty === null || ty === void 0 ? void 0 : ty.getThemeInfo()) !== null && _a !== void 0 ? _a : {};
64
- var checkMarkIconColor = this.data.activeColor || themeInfo['--app-M1'] || '#3678E3';
65
- this.setData({ checkMarkIconColor: checkMarkIconColor });
66
58
  },
67
59
  methods: {
68
60
  onSelect: function (event) {
@@ -53,7 +53,7 @@
53
53
  <block wx:if="{{ !item.loading }}">
54
54
  {{ item.name }}
55
55
  <view wx:if="{{ item.subname }}" class="smart-action-sheet__subname" >{{ item.subname }}</view>
56
- <smart-icon wx:if="{{ item.checked }}" name="{{ checkMarkIcon }}" class="smart-action-sheet__icon" color="{{ checkMarkIconColor }}" />
56
+ <smart-icon wx:if="{{ item.checked }}" name="{{ checkMarkIcon }}" class="smart-action-sheet__icon" color="{{ activeColor }}" />
57
57
  </block>
58
58
  <smart-loading wx:else custom-class="smart-action-sheet__loading" size="22px" />
59
59
  </button>
@@ -1 +1 @@
1
- @import '../common/index.wxss';.smart-action-sheet{border-radius:var(--popup-round-border-radius,var(--popup-round-border-radius,16px))!important;color:var(--action-sheet-item-text-color,var(--app-B4-N1,#000));left:var(--action-sheet-left,16px)!important;margin:var(--action-sheet-margin,0 0 16px);max-height:var(--action-sheet-max-height,90%)!important;width:var(--action-sheet-width,calc(100% - 32px))!important}.smart-action-sheet__list{max-height:325px;overflow-y:scroll}.smart-action-sheet__icon{font-size:var(--action-sheet-item-icon-size,28px);margin:var(--action-sheet-item-icon-margin,16px 16px 0 0);position:absolute;right:0;top:0}.smart-action-sheet__item{border-radius:var(--action-sheet-item-border-radius,0);color:var(--action-sheet-item-text-color,var(--app-B4-N1,#000))}.smart-action-sheet__item:not(:last-child){border-bottom:1px solid var(--action-sheet-header-border-color,var(--app-B4-N7,rgba(0,0,0,.1)))}.smart-action-sheet__cancel,.smart-action-sheet__confirm,.smart-action-sheet__item{background-color:var(--action-sheet-item-background,var(--app-B4,#fff));font-size:var(--action-sheet-item-font-size,16px);font-weight:var(--action-sheet-item-font-weight,normal);line-height:var(--action-sheet-item-line-height,24px);padding:16px;text-align:center;width:100%}.smart-action-sheet__cancel--hover,.smart-action-sheet__confirm--hover,.smart-action-sheet__item--hover{background-color:var(--action-sheet-active-color,var(--app-B1,#f6f7fb))}.smart-action-sheet__cancel:after,.smart-action-sheet__confirm:after,.smart-action-sheet__item:after{border-width:0}.smart-action-sheet__cancel{color:var(--action-sheet-cancel-text-color,var(--app-B4-N3,rgba(0,0,0,.5)))}.smart-action-sheet__confirm{color:var(--action-sheet-confirm-text-color,var(--app-B4-N1,#000));font-weight:var(--action-sheet-confirm-font-weight,500)}.smart-action-sheet__gap{background-color:var(--action-sheet-footer-padding-color,var(--app-B4-N9,rgba(0,0,0,.05)));display:block;height:var(--action-sheet-footer-padding-top,8px)}.smart-action-sheet__item--disabled{opacity:var(--action-sheet-item-disabled-opacity,.3)}.smart-action-sheet__item--disabled.smart-action-sheet__item--hover{background-color:var(--action-sheet-item-background,var(--app-B4,#fff))}.smart-action-sheet__subname{color:var(--action-sheet-subname-color,var(--app-B4-N3,rgba(0,0,0,.5)));font-size:var(--action-sheet-subname-font-size,12px);line-height:var(--action-sheet-subname-line-height,20px);margin-top:var(--padding-xs,8px)}.smart-action-sheet__header{border-bottom:1px solid var(--action-sheet-header-border-color,var(--app-B4-N7,rgba(0,0,0,.1)));color:var(--action-sheet-header-color,var(--app-B4-N3,rgba(0,0,0,.5)));font-size:var(--action-sheet-header-font-size,16px);font-weight:var(--action-sheet-header-font-weight,normal);line-height:var(--action-sheet-header-height,56px);text-align:center}.smart-action-sheet__description{color:var(--action-sheet-description-color,var(--app-B4-N3,rgba(0,0,0,.5)));font-size:var(--action-sheet-description-font-size,14px);line-height:var(--action-sheet-description-line-height,20px);padding:20px var(--padding-md,16px);text-align:center}.smart-action-sheet__loading{color:inherit!important;display:flex!important}.smart-action-sheet__footer{align-items:center;background-color:var(--action-sheet-item-background,var(--app-B4,#fff));display:flex;font-size:var(--action-sheet-item-font-size,16px);justify-content:space-around;line-height:var(--action-sheet-item-line-height,22px);text-align:center}
1
+ @import '../common/index.wxss';.smart-action-sheet{border-radius:var(--popup-round-border-radius,var(--popup-round-border-radius,16px))!important;color:var(--action-sheet-item-text-color,var(--app-B4-N1,#000));left:var(--action-sheet-left,16px)!important;margin:var(--action-sheet-margin,0 0 16px);max-height:var(--action-sheet-max-height,90%)!important;width:var(--action-sheet-width,calc(100% - 32px))!important}.smart-action-sheet__list{max-height:325px;overflow-y:scroll}.smart-action-sheet__icon{--icon-color:var(--action-sheet-active-icon-color,var(--app-M1,#3678e3));font-size:var(--action-sheet-item-icon-size,28px);margin:var(--action-sheet-item-icon-margin,16px 16px 0 0);position:absolute;right:0;top:0}.smart-action-sheet__item{border-radius:var(--action-sheet-item-border-radius,0);color:var(--action-sheet-item-text-color,var(--app-B4-N1,#000))}.smart-action-sheet__item:not(:last-child){border-bottom:1px solid var(--action-sheet-header-border-color,var(--app-B4-N7,rgba(0,0,0,.1)))}.smart-action-sheet__cancel,.smart-action-sheet__confirm,.smart-action-sheet__item{background-color:var(--action-sheet-item-background,var(--app-B4,#fff));font-size:var(--action-sheet-item-font-size,16px);font-weight:var(--action-sheet-item-font-weight,normal);line-height:var(--action-sheet-item-line-height,24px);padding:16px;text-align:center;width:100%}.smart-action-sheet__cancel--hover,.smart-action-sheet__confirm--hover,.smart-action-sheet__item--hover{background-color:var(--action-sheet-active-color,var(--app-B1,#f6f7fb))}.smart-action-sheet__cancel:after,.smart-action-sheet__confirm:after,.smart-action-sheet__item:after{border-width:0}.smart-action-sheet__cancel{color:var(--action-sheet-cancel-text-color,var(--app-B4-N3,rgba(0,0,0,.5)))}.smart-action-sheet__confirm{color:var(--action-sheet-confirm-text-color,var(--app-B4-N1,#000));font-weight:var(--action-sheet-confirm-font-weight,500)}.smart-action-sheet__gap{background-color:var(--action-sheet-footer-padding-color,var(--app-B4-N9,rgba(0,0,0,.05)));display:block;height:var(--action-sheet-footer-padding-top,8px)}.smart-action-sheet__item--disabled{opacity:var(--action-sheet-item-disabled-opacity,.3)}.smart-action-sheet__item--disabled.smart-action-sheet__item--hover{background-color:var(--action-sheet-item-background,var(--app-B4,#fff))}.smart-action-sheet__subname{color:var(--action-sheet-subname-color,var(--app-B4-N3,rgba(0,0,0,.5)));font-size:var(--action-sheet-subname-font-size,12px);line-height:var(--action-sheet-subname-line-height,20px);margin-top:var(--padding-xs,8px)}.smart-action-sheet__header{border-bottom:1px solid var(--action-sheet-header-border-color,var(--app-B4-N7,rgba(0,0,0,.1)));color:var(--action-sheet-header-color,var(--app-B4-N3,rgba(0,0,0,.5)));font-size:var(--action-sheet-header-font-size,16px);font-weight:var(--action-sheet-header-font-weight,normal);line-height:var(--action-sheet-header-height,56px);text-align:center}.smart-action-sheet__description{color:var(--action-sheet-description-color,var(--app-B4-N3,rgba(0,0,0,.5)));font-size:var(--action-sheet-description-font-size,14px);line-height:var(--action-sheet-description-line-height,20px);padding:20px var(--padding-md,16px);text-align:center}.smart-action-sheet__loading{color:inherit!important;display:flex!important}.smart-action-sheet__footer{align-items:center;background-color:var(--action-sheet-item-background,var(--app-B4,#fff));display:flex;font-size:var(--action-sheet-item-font-size,16px);justify-content:space-around;line-height:var(--action-sheet-item-line-height,22px);text-align:center}
package/lib/cell/index.js CHANGED
@@ -3,10 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var Up_1 = __importDefault(require("@tuya-miniapp/icons/dist/svg/Up"));
7
- var Down_1 = __importDefault(require("@tuya-miniapp/icons/dist/svg/Down"));
8
- var Left_1 = __importDefault(require("@tuya-miniapp/icons/dist/svg/Left"));
9
- var Right_1 = __importDefault(require("@tuya-miniapp/icons/dist/svg/Right"));
6
+ var Up_js_1 = __importDefault(require("@tuya-miniapp/icons/dist/svg/Up.js"));
7
+ var Down_js_1 = __importDefault(require("@tuya-miniapp/icons/dist/svg/Down.js"));
8
+ var Left_js_1 = __importDefault(require("@tuya-miniapp/icons/dist/svg/Left.js"));
9
+ var Right_js_1 = __importDefault(require("@tuya-miniapp/icons/dist/svg/Right.js"));
10
+ // import {
11
+ // Right as rightIcon,
12
+ // Left as leftIcon,
13
+ // Down as downIcon,
14
+ // Up as upIcon,
15
+ // } from '@tuya-miniapp/icons';
10
16
  var link_1 = require("../mixins/link");
11
17
  var component_1 = require("../common/component");
12
18
  (0, component_1.SmartComponent)({
@@ -32,12 +38,12 @@ var component_1 = require("../common/component");
32
38
  },
33
39
  data: {
34
40
  arrowIcons: {
35
- up: Up_1.default,
36
- down: Down_1.default,
37
- left: Left_1.default,
38
- right: Right_1.default,
41
+ up: Up_js_1.default,
42
+ down: Down_js_1.default,
43
+ left: Left_js_1.default,
44
+ right: Right_js_1.default,
39
45
  },
40
- arrowIcon: Right_1.default,
46
+ arrowIcon: Right_js_1.default,
41
47
  },
42
48
  methods: {
43
49
  onClick: function (event) {
@@ -19,3 +19,4 @@ export declare const clamp: (num: any, min: any, max: any) => number;
19
19
  export declare function getCurrentPage<T>(): T & WechatMiniprogram.OptionalInterface<WechatMiniprogram.Page.ILifetime> & WechatMiniprogram.Page.InstanceProperties & WechatMiniprogram.Page.InstanceMethods<WechatMiniprogram.IAnyObject> & WechatMiniprogram.Page.Data<WechatMiniprogram.IAnyObject> & WechatMiniprogram.IAnyObject;
20
20
  export declare const isPC: boolean;
21
21
  export declare const isWxWork: boolean;
22
+ export declare function replacePlaceholders(template: any, values: any): any;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isWxWork = exports.isPC = exports.getCurrentPage = exports.clamp = exports.addNumber = exports.toPromise = exports.groupSetData = exports.getAllRect = exports.getRect = exports.pickExclude = exports.requestAnimationFrame = exports.addUnit = exports.nextTick = exports.range = exports.getSystemInfoSync = exports.isDef = void 0;
3
+ exports.replacePlaceholders = exports.isWxWork = exports.isPC = exports.getCurrentPage = exports.clamp = exports.addNumber = exports.toPromise = exports.groupSetData = exports.getAllRect = exports.getRect = exports.pickExclude = exports.requestAnimationFrame = exports.addUnit = exports.nextTick = exports.range = exports.getSystemInfoSync = exports.isDef = void 0;
4
4
  var validator_1 = require("./validator");
5
5
  var version_1 = require("./version");
6
6
  var validator_2 = require("./validator");
@@ -107,3 +107,10 @@ exports.getCurrentPage = getCurrentPage;
107
107
  exports.isPC = ['mac', 'windows'].includes((0, version_1.getSystemInfoSync)().platform);
108
108
  // 是否企业微信
109
109
  exports.isWxWork = (0, version_1.getSystemInfoSync)().environment === 'wxwork';
110
+ function replacePlaceholders(template, values) {
111
+ // 使用正则表达式匹配占位符
112
+ return template.replace(/{{(.*?)}}/g, function (match, key) {
113
+ return values[key] || match; // 如果在values中找到key对应的值,则替换;否则保留原样
114
+ });
115
+ }
116
+ exports.replacePlaceholders = replacePlaceholders;
@@ -9,13 +9,33 @@ var toast_1 = __importDefault(require("../../toast/toast"));
9
9
  data: {
10
10
  minHour: 10,
11
11
  maxHour: 20,
12
+ columnsOrder: [2, 1, 1],
12
13
  minDate: new Date(2018, 0, 1).getTime(),
13
14
  maxDate: new Date(2019, 10, 1).getTime(),
14
15
  currentDate1: new Date(2018, 2, 31).getTime(),
15
16
  currentDate2: null,
16
17
  currentDate3: new Date(2018, 0, 1),
17
18
  currentDate4: '12:00',
19
+ currentDate5: '11:00',
18
20
  loading: false,
21
+ formatterMap: {
22
+ year: '{{year}}年',
23
+ month: {
24
+ '01': 'January',
25
+ '02': 'February',
26
+ '03': 'March',
27
+ '04': 'April',
28
+ '05': 'May',
29
+ '06': 'June',
30
+ '07': 'July',
31
+ '08': 'August',
32
+ '09': 'September',
33
+ '10': 'October',
34
+ '11': 'November',
35
+ '12': 'December',
36
+ },
37
+ day: '{{day}}日'
38
+ },
19
39
  formatter: function (type, value) {
20
40
  if (type === 'year') {
21
41
  return "".concat(value).concat(I18n.t('year'));