@tuya-miniapp/smart-ui 2.13.3 → 2.13.4-beta-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -255,6 +255,37 @@ Page({
255
255
  });
256
256
  ```
257
257
 
258
+ ### 控制某一列是否循环滚动 `v2.13.4`
259
+
260
+ 默认情况下,`year`(年)与 `12HourClock`(上午/下午)列不循环滚动,其余列(月、日、时、分)循环滚动。通过 `loop-map` 可以按列覆盖该默认行为,未配置的列保持默认。
261
+
262
+ ```html
263
+ <smart-datetime-picker
264
+ type="date"
265
+ value="{{ currentDate }}"
266
+ loop-map="{{ loopMap }}"
267
+ bind:input="onInput"
268
+ />
269
+ ```
270
+
271
+ ```js
272
+ Page({
273
+ data: {
274
+ currentDate: new Date().getTime(),
275
+ loopMap: {
276
+ day: false, // 日不循环
277
+ year: true, // 年循环
278
+ },
279
+ },
280
+
281
+ onInput(event) {
282
+ this.setData({
283
+ currentDate: event.detail,
284
+ });
285
+ },
286
+ });
287
+ ```
288
+
258
289
  ### 样式风格 `v2.3.7`
259
290
 
260
291
  `active-style` 可以修改选中项的样式;`column-styles` 可以设置每一列的样式;`font-styles` 可以设置每一列文字的样式。
@@ -326,6 +357,7 @@ Page({
326
357
  | columnStyles `v2.3.7` | 任意列的样式 | _Record\<string, string>_ | - |
327
358
  | font-styles `v2.3.7` | 任意列的字体样式 | _Record\<string, string>_ | - |
328
359
  | active-style `v2.3.7` | 选中项的样式 | _string_ | - |
360
+ | loop-map `v2.13.4` | 控制每一列是否循环滚动(`type` 可选值为 `year`, `month`, `day`, `hour`, `minute`, `12HourClock`),未配置的列保持默认行为:`year` 与 `12HourClock` 不循环,其余列循环 | _Record\<type, boolean>_ | - |
329
361
 
330
362
  ### Events
331
363
 
@@ -115,6 +115,10 @@ SmartComponent({
115
115
  }, fontStyles: {
116
116
  type: Object,
117
117
  value: undefined,
118
+ }, loopMap: {
119
+ type: Object,
120
+ value: undefined,
121
+ observer: 'updateValue',
118
122
  } }),
119
123
  data: {
120
124
  part: 'am',
@@ -187,6 +191,16 @@ SmartComponent({
187
191
  }
188
192
  return formatter(type, value);
189
193
  },
194
+ // 某一列是否循环滚动,loopMap 未配置该列时使用默认值(年份、12 小时制上下午不循环)
195
+ getColumnLoop(type) {
196
+ var _a;
197
+ const { loopMap } = this.data;
198
+ const loop = (_a = loopMap === null || loopMap === void 0 ? void 0 : loopMap[type]) !== null && _a !== void 0 ? _a : (type === '12HourClock' ? loopMap === null || loopMap === void 0 ? void 0 : loopMap.part : undefined);
199
+ if (typeof loop === 'boolean') {
200
+ return loop;
201
+ }
202
+ return !['12HourClock', 'year'].includes(type);
203
+ },
190
204
  updateColumns(values) {
191
205
  const { locale, columnStyles, fontStyles } = this.data;
192
206
  const results = this.getOriginColumns().map((column, index) => {
@@ -200,7 +214,7 @@ SmartComponent({
200
214
  style: columnStyles === null || columnStyles === void 0 ? void 0 : columnStyles[column.type],
201
215
  fontStyle: fontStyles === null || fontStyles === void 0 ? void 0 : fontStyles[column.type],
202
216
  activeIndex: activeIndex === -1 ? 0 : activeIndex,
203
- loop: !['12HourClock', 'year'].includes(column.type),
217
+ loop: this.getColumnLoop(column.type),
204
218
  };
205
219
  });
206
220
  return this.setData({ columns: results });
@@ -255,6 +255,37 @@ Page({
255
255
  });
256
256
  ```
257
257
 
258
+ ### 控制某一列是否循环滚动 `v2.13.4`
259
+
260
+ 默认情况下,`year`(年)与 `12HourClock`(上午/下午)列不循环滚动,其余列(月、日、时、分)循环滚动。通过 `loop-map` 可以按列覆盖该默认行为,未配置的列保持默认。
261
+
262
+ ```html
263
+ <smart-datetime-picker
264
+ type="date"
265
+ value="{{ currentDate }}"
266
+ loop-map="{{ loopMap }}"
267
+ bind:input="onInput"
268
+ />
269
+ ```
270
+
271
+ ```js
272
+ Page({
273
+ data: {
274
+ currentDate: new Date().getTime(),
275
+ loopMap: {
276
+ day: false, // 日不循环
277
+ year: true, // 年循环
278
+ },
279
+ },
280
+
281
+ onInput(event) {
282
+ this.setData({
283
+ currentDate: event.detail,
284
+ });
285
+ },
286
+ });
287
+ ```
288
+
258
289
  ### 样式风格 `v2.3.7`
259
290
 
260
291
  `active-style` 可以修改选中项的样式;`column-styles` 可以设置每一列的样式;`font-styles` 可以设置每一列文字的样式。
@@ -326,6 +357,7 @@ Page({
326
357
  | columnStyles `v2.3.7` | 任意列的样式 | _Record\<string, string>_ | - |
327
358
  | font-styles `v2.3.7` | 任意列的字体样式 | _Record\<string, string>_ | - |
328
359
  | active-style `v2.3.7` | 选中项的样式 | _string_ | - |
360
+ | loop-map `v2.13.4` | 控制每一列是否循环滚动(`type` 可选值为 `year`, `month`, `day`, `hour`, `minute`, `12HourClock`),未配置的列保持默认行为:`year` 与 `12HourClock` 不循环,其余列循环 | _Record\<type, boolean>_ | - |
329
361
 
330
362
  ### Events
331
363
 
@@ -139,6 +139,10 @@ var defaultFormatter = function (type, value) {
139
139
  }, fontStyles: {
140
140
  type: Object,
141
141
  value: undefined,
142
+ }, loopMap: {
143
+ type: Object,
144
+ value: undefined,
145
+ observer: 'updateValue',
142
146
  } }),
143
147
  data: {
144
148
  part: 'am',
@@ -218,6 +222,16 @@ var defaultFormatter = function (type, value) {
218
222
  }
219
223
  return formatter(type, value);
220
224
  },
225
+ // 某一列是否循环滚动,loopMap 未配置该列时使用默认值(年份、12 小时制上下午不循环)
226
+ getColumnLoop: function (type) {
227
+ var _a;
228
+ var loopMap = this.data.loopMap;
229
+ var loop = (_a = loopMap === null || loopMap === void 0 ? void 0 : loopMap[type]) !== null && _a !== void 0 ? _a : (type === '12HourClock' ? loopMap === null || loopMap === void 0 ? void 0 : loopMap.part : undefined);
230
+ if (typeof loop === 'boolean') {
231
+ return loop;
232
+ }
233
+ return !['12HourClock', 'year'].includes(type);
234
+ },
221
235
  updateColumns: function (values) {
222
236
  var _this = this;
223
237
  var _a = this.data, locale = _a.locale, columnStyles = _a.columnStyles, fontStyles = _a.fontStyles;
@@ -232,7 +246,7 @@ var defaultFormatter = function (type, value) {
232
246
  style: columnStyles === null || columnStyles === void 0 ? void 0 : columnStyles[column.type],
233
247
  fontStyle: fontStyles === null || fontStyles === void 0 ? void 0 : fontStyles[column.type],
234
248
  activeIndex: activeIndex === -1 ? 0 : activeIndex,
235
- loop: !['12HourClock', 'year'].includes(column.type),
249
+ loop: _this.getColumnLoop(column.type),
236
250
  };
237
251
  });
238
252
  return this.setData({ columns: results });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/smart-ui",
3
- "version": "2.13.3",
3
+ "version": "2.13.4-beta-0",
4
4
  "author": "MiniApp Team",
5
5
  "license": "MIT",
6
6
  "miniprogram": "lib",