@tuya-miniapp/smart-ui 2.6.0-beta-3 → 2.6.0-beta-5
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.
- package/dist/datetime-picker/index.js +22 -17
- package/lib/datetime-picker/index.js +23 -22
- package/package.json +1 -1
@@ -100,20 +100,20 @@ SmartComponent({
|
|
100
100
|
},
|
101
101
|
created() {
|
102
102
|
const innerValue = this.correctValue(this.data.value);
|
103
|
-
this.updateColumnValue(innerValue)
|
103
|
+
this.updateColumnValue(innerValue);
|
104
|
+
if (innerValue !== this.data.value) {
|
104
105
|
this.$emit('input', innerValue);
|
105
|
-
}
|
106
|
+
}
|
106
107
|
},
|
107
108
|
methods: {
|
108
109
|
updateValue() {
|
109
110
|
const { data } = this;
|
110
111
|
const val = this.correctValue(data.value);
|
111
112
|
const isEqual = val === data.innerValue;
|
112
|
-
this.updateColumnValue(val)
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
});
|
113
|
+
this.updateColumnValue(val);
|
114
|
+
if (!isEqual) {
|
115
|
+
this.$emit('input', val);
|
116
|
+
}
|
117
117
|
},
|
118
118
|
getPicker() {
|
119
119
|
if (this.picker == null) {
|
@@ -235,7 +235,7 @@ SmartComponent({
|
|
235
235
|
result.splice(2, 3);
|
236
236
|
return result;
|
237
237
|
},
|
238
|
-
correctValue(value) {
|
238
|
+
correctValue(value, isOutSide) {
|
239
239
|
const { data } = this;
|
240
240
|
// validate value
|
241
241
|
const isDateType = data.type !== 'time';
|
@@ -257,6 +257,9 @@ SmartComponent({
|
|
257
257
|
}
|
258
258
|
hour = padZero(range(hour, data.minHour, data.maxHour));
|
259
259
|
minute = padZero(range(minute, data.minMinute, data.maxMinute));
|
260
|
+
if (isOutSide && Number(hour) === 24) {
|
261
|
+
hour = 0;
|
262
|
+
}
|
260
263
|
return `${hour}:${minute}`;
|
261
264
|
}
|
262
265
|
// date type
|
@@ -344,12 +347,11 @@ SmartComponent({
|
|
344
347
|
}
|
345
348
|
value = new Date(year, month - 1, date, hour, minute);
|
346
349
|
}
|
347
|
-
value = this.correctValue(value);
|
348
|
-
this.updateColumnValue(value)
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
});
|
350
|
+
value = this.correctValue(value, true);
|
351
|
+
this.updateColumnValue(value);
|
352
|
+
picker.value = value;
|
353
|
+
this.$emit('input', value);
|
354
|
+
this.$emit('change', picker);
|
353
355
|
},
|
354
356
|
updateColumnValue(value) {
|
355
357
|
let values = [];
|
@@ -385,9 +387,12 @@ SmartComponent({
|
|
385
387
|
values.push(formatter('day', padZero(date.getDate()), this.data), formatter('hour', padZero(date.getHours()), this.data), formatter('minute', padZero(date.getMinutes()), this.data));
|
386
388
|
}
|
387
389
|
}
|
388
|
-
|
389
|
-
|
390
|
-
|
390
|
+
this.setData({ innerValue: value });
|
391
|
+
this.updateColumns();
|
392
|
+
picker.setValues(values);
|
393
|
+
// return this.set({ innerValue: value })
|
394
|
+
// .then(() => this.updateColumns())
|
395
|
+
// .then(() => picker.setValues(values));
|
391
396
|
},
|
392
397
|
onAnimationStart() {
|
393
398
|
this.$emit('animation-start');
|
@@ -123,23 +123,21 @@ var defaultFormatter = function (type, value) {
|
|
123
123
|
columns: [],
|
124
124
|
},
|
125
125
|
created: function () {
|
126
|
-
var _this = this;
|
127
126
|
var innerValue = this.correctValue(this.data.value);
|
128
|
-
this.updateColumnValue(innerValue)
|
129
|
-
|
130
|
-
|
127
|
+
this.updateColumnValue(innerValue);
|
128
|
+
if (innerValue !== this.data.value) {
|
129
|
+
this.$emit('input', innerValue);
|
130
|
+
}
|
131
131
|
},
|
132
132
|
methods: {
|
133
133
|
updateValue: function () {
|
134
|
-
var _this = this;
|
135
134
|
var data = this.data;
|
136
135
|
var val = this.correctValue(data.value);
|
137
136
|
var isEqual = val === data.innerValue;
|
138
|
-
this.updateColumnValue(val)
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
});
|
137
|
+
this.updateColumnValue(val);
|
138
|
+
if (!isEqual) {
|
139
|
+
this.$emit('input', val);
|
140
|
+
}
|
143
141
|
},
|
144
142
|
getPicker: function () {
|
145
143
|
if (this.picker == null) {
|
@@ -269,7 +267,7 @@ var defaultFormatter = function (type, value) {
|
|
269
267
|
result.splice(2, 3);
|
270
268
|
return result;
|
271
269
|
},
|
272
|
-
correctValue: function (value) {
|
270
|
+
correctValue: function (value, isOutSide) {
|
273
271
|
var data = this.data;
|
274
272
|
// validate value
|
275
273
|
var isDateType = data.type !== 'time';
|
@@ -291,6 +289,9 @@ var defaultFormatter = function (type, value) {
|
|
291
289
|
}
|
292
290
|
hour = padZero((0, utils_1.range)(hour, data.minHour, data.maxHour));
|
293
291
|
minute = padZero((0, utils_1.range)(minute, data.minMinute, data.maxMinute));
|
292
|
+
if (isOutSide && Number(hour) === 24) {
|
293
|
+
hour = 0;
|
294
|
+
}
|
294
295
|
return "".concat(hour, ":").concat(minute);
|
295
296
|
}
|
296
297
|
// date type
|
@@ -340,7 +341,6 @@ var defaultFormatter = function (type, value) {
|
|
340
341
|
this.$emit('confirm', this.data.innerValue);
|
341
342
|
},
|
342
343
|
onChange: function () {
|
343
|
-
var _this = this;
|
344
344
|
var data = this.data;
|
345
345
|
var value;
|
346
346
|
var picker = this.getPicker();
|
@@ -380,15 +380,13 @@ var defaultFormatter = function (type, value) {
|
|
380
380
|
}
|
381
381
|
value = new Date(year, month - 1, date, hour, minute);
|
382
382
|
}
|
383
|
-
value = this.correctValue(value);
|
384
|
-
this.updateColumnValue(value)
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
});
|
383
|
+
value = this.correctValue(value, true);
|
384
|
+
this.updateColumnValue(value);
|
385
|
+
picker.value = value;
|
386
|
+
this.$emit('input', value);
|
387
|
+
this.$emit('change', picker);
|
389
388
|
},
|
390
389
|
updateColumnValue: function (value) {
|
391
|
-
var _this = this;
|
392
390
|
var values = [];
|
393
391
|
var _a = this.data, type = _a.type, is12HourClock = _a.is12HourClock;
|
394
392
|
var formatter = this.formatterFunc;
|
@@ -422,9 +420,12 @@ var defaultFormatter = function (type, value) {
|
|
422
420
|
values.push(formatter('day', padZero(date.getDate()), this.data), formatter('hour', padZero(date.getHours()), this.data), formatter('minute', padZero(date.getMinutes()), this.data));
|
423
421
|
}
|
424
422
|
}
|
425
|
-
|
426
|
-
|
427
|
-
|
423
|
+
this.setData({ innerValue: value });
|
424
|
+
this.updateColumns();
|
425
|
+
picker.setValues(values);
|
426
|
+
// return this.set({ innerValue: value })
|
427
|
+
// .then(() => this.updateColumns())
|
428
|
+
// .then(() => picker.setValues(values));
|
428
429
|
},
|
429
430
|
onAnimationStart: function () {
|
430
431
|
this.$emit('animation-start');
|