@varlet/ui 2.0.0-alpha.1663742071515 → 2.0.0-alpha.1664032365126
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/es/button/Button.js +3 -1
- package/es/countdown/Countdown.js +4 -3
- package/es/date-picker/DatePicker.js +4 -3
- package/es/snackbar/style/index.js +1 -1
- package/es/time-picker/TimePicker.js +3 -2
- package/es/time-picker/clock.js +2 -1
- package/es/utils/elements.js +3 -0
- package/es/utils/shared.js +20 -1
- package/es/varlet.esm.js +2110 -2100
- package/lib/button/Button.js +3 -1
- package/lib/countdown/Countdown.js +8 -6
- package/lib/date-picker/DatePicker.js +5 -3
- package/lib/time-picker/TimePicker.js +4 -2
- package/lib/time-picker/clock.js +3 -1
- package/lib/utils/elements.js +4 -0
- package/lib/utils/shared.js +27 -2
- package/package.json +8 -8
- package/umd/varlet.js +6 -6
- package/es/themes/dark/tab-item.js +0 -3
- package/lib/themes/dark/tab-item.js +0 -8
package/es/button/Button.js
CHANGED
|
@@ -67,7 +67,9 @@ export default defineComponent({
|
|
|
67
67
|
var attemptAutoLoading = result => {
|
|
68
68
|
if (props.autoLoading) {
|
|
69
69
|
pending.value = true;
|
|
70
|
-
Promise.resolve(result).
|
|
70
|
+
Promise.resolve(result).then(() => {
|
|
71
|
+
pending.value = false;
|
|
72
|
+
}).catch(() => {
|
|
71
73
|
pending.value = false;
|
|
72
74
|
});
|
|
73
75
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { defineComponent, ref, watch } from 'vue';
|
|
2
2
|
import { props } from './props';
|
|
3
3
|
import { requestAnimationFrame, cancelAnimationFrame } from '../utils/elements';
|
|
4
|
-
import { toNumber } from '@varlet/shared';
|
|
5
4
|
import { call, createNamespace } from '../utils/components';
|
|
5
|
+
import { padStart } from '../utils/shared';
|
|
6
|
+
import { toNumber } from '@varlet/shared';
|
|
6
7
|
var {
|
|
7
8
|
n
|
|
8
9
|
} = createNamespace('countdown');
|
|
@@ -47,12 +48,12 @@ export default defineComponent({
|
|
|
47
48
|
if (!format.includes(scannedFormat)) {
|
|
48
49
|
scannedTimes[index + 1] += scannedTimes[index] * padValues[index];
|
|
49
50
|
} else {
|
|
50
|
-
format = format.replace(scannedFormat,
|
|
51
|
+
format = format.replace(scannedFormat, padStart("" + scannedTimes[index], 2, '0'));
|
|
51
52
|
}
|
|
52
53
|
});
|
|
53
54
|
|
|
54
55
|
if (format.includes('S')) {
|
|
55
|
-
var ms =
|
|
56
|
+
var ms = padStart("" + scannedTimes[scannedTimes.length - 1], 3, '0');
|
|
56
57
|
|
|
57
58
|
if (format.includes('SSS')) {
|
|
58
59
|
format = format.replace('SSS', ms);
|
|
@@ -7,6 +7,7 @@ import { props, MONTH_LIST, WEEK_HEADER } from './props';
|
|
|
7
7
|
import { isArray, toNumber } from '@varlet/shared';
|
|
8
8
|
import { nextTickFrame } from '../utils/elements';
|
|
9
9
|
import { createNamespace, call } from '../utils/components';
|
|
10
|
+
import { padStart } from '../utils/shared';
|
|
10
11
|
import { pack } from '../locale';
|
|
11
12
|
var {
|
|
12
13
|
n,
|
|
@@ -243,7 +244,7 @@ export default defineComponent({
|
|
|
243
244
|
var week = WEEK_HEADER.find(value => value.index === "" + weekIndex);
|
|
244
245
|
var weekName = (_pack$value$datePicke3 = (_pack$value$datePicke4 = pack.value.datePickerWeekDict) == null ? void 0 : _pack$value$datePicke4[week.index].name) != null ? _pack$value$datePicke3 : '';
|
|
245
246
|
var monthName = (_pack$value$datePicke5 = (_pack$value$datePicke6 = pack.value.datePickerMonthDict) == null ? void 0 : _pack$value$datePicke6[chooseMonth.value.index].name) != null ? _pack$value$datePicke5 : '';
|
|
246
|
-
var showDay = chooseDay.value
|
|
247
|
+
var showDay = padStart(chooseDay.value, 2, '0');
|
|
247
248
|
if (pack.value.lang === 'zh-CN') return chooseMonth.value.index + "-" + showDay + " " + weekName.slice(0, 3);
|
|
248
249
|
return weekName.slice(0, 3) + ", " + monthName.slice(0, 3) + " " + chooseDay.value;
|
|
249
250
|
});
|
|
@@ -257,10 +258,10 @@ export default defineComponent({
|
|
|
257
258
|
return !props.touchable || ['', 'year'].includes(getPanelType.value);
|
|
258
259
|
});
|
|
259
260
|
var slotProps = computed(() => {
|
|
260
|
-
var _chooseMonth$value,
|
|
261
|
+
var _chooseMonth$value, _chooseYear$value, _chooseMonth$value$in, _chooseMonth$value2;
|
|
261
262
|
|
|
262
263
|
var weekIndex = dayjs(chooseYear.value + "-" + ((_chooseMonth$value = chooseMonth.value) == null ? void 0 : _chooseMonth$value.index) + "-" + chooseDay.value).day();
|
|
263
|
-
var date = chooseDay.value ? (
|
|
264
|
+
var date = chooseDay.value ? padStart(chooseDay.value, 2, '0') : '';
|
|
264
265
|
return {
|
|
265
266
|
week: "" + weekIndex,
|
|
266
267
|
year: (_chooseYear$value = chooseYear.value) != null ? _chooseYear$value : '',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import '../../styles/common.css'
|
|
2
|
+
import '../SnackbarSfc.css'
|
|
2
3
|
import '../../styles/elevation.css'
|
|
3
4
|
import '../../loading/loading.css'
|
|
4
5
|
import '../../button/button.css'
|
|
5
6
|
import '../../icon/icon.css'
|
|
6
7
|
import '../snackbar.css'
|
|
7
8
|
import '../coreSfc.css'
|
|
8
|
-
import '../SnackbarSfc.css'
|
|
@@ -4,6 +4,7 @@ import Clock from './clock.js'
|
|
|
4
4
|
import { props, hoursAmpm, hours24 } from './props';
|
|
5
5
|
import { toNumber } from '@varlet/shared';
|
|
6
6
|
import { createNamespace, call } from '../utils/components';
|
|
7
|
+
import { padStart } from '../utils/shared';
|
|
7
8
|
import { getNumberTime, getIsDisableMinute, getIsDisableSecond } from './utils';
|
|
8
9
|
var {
|
|
9
10
|
n,
|
|
@@ -195,7 +196,7 @@ export default defineComponent({
|
|
|
195
196
|
var newHour = findAvailableHour(ampmType);
|
|
196
197
|
if (!newHour) return;
|
|
197
198
|
var second = props.useSeconds ? ":" + time.value.second : '';
|
|
198
|
-
var newTime =
|
|
199
|
+
var newTime = padStart(newHour, 2, '0') + ":" + time.value.minute + second;
|
|
199
200
|
update(newTime);
|
|
200
201
|
};
|
|
201
202
|
|
|
@@ -374,7 +375,7 @@ export default defineComponent({
|
|
|
374
375
|
time.value = getTime(value);
|
|
375
376
|
|
|
376
377
|
if (props.format !== '24hr') {
|
|
377
|
-
ampm.value = ("" + hour
|
|
378
|
+
ampm.value = padStart("" + hour, 2, '0') === formatHour24 && hours24.includes(formatHour24) ? 'pm' : 'am';
|
|
378
379
|
}
|
|
379
380
|
|
|
380
381
|
isInner.value = props.format === '24hr' && hours24.includes(formatHour24);
|
package/es/time-picker/clock.js
CHANGED
|
@@ -4,6 +4,7 @@ import { hoursAmpm, hours24, minSec } from './props';
|
|
|
4
4
|
import { notConvert, convertHour, getIsDisableMinute, getIsDisableSecond, getNumberTime } from './utils';
|
|
5
5
|
import { toNumber } from '@varlet/shared';
|
|
6
6
|
import { createNamespace } from '../utils/components';
|
|
7
|
+
import { padStart } from '../utils/shared';
|
|
7
8
|
var {
|
|
8
9
|
n,
|
|
9
10
|
classes
|
|
@@ -218,7 +219,7 @@ export default defineComponent({
|
|
|
218
219
|
var getHour = () => {
|
|
219
220
|
if (activeItemIndex.value === undefined) return undefined;
|
|
220
221
|
var hours = props.ampm === 'am' ? hoursAmpm : hours24;
|
|
221
|
-
return hours[activeItemIndex.value]
|
|
222
|
+
return padStart(hours[activeItemIndex.value], 2, '0');
|
|
222
223
|
};
|
|
223
224
|
|
|
224
225
|
watch([activeItemIndex, () => props.isInner], (_ref2, _ref3) => {
|
package/es/utils/elements.js
CHANGED
|
@@ -3,6 +3,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
3
3
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4
4
|
|
|
5
5
|
import { isNumber, isString, kebabCase, toNumber } from '@varlet/shared';
|
|
6
|
+
import { getGlobalThis } from './shared';
|
|
6
7
|
export function getLeft(element) {
|
|
7
8
|
var {
|
|
8
9
|
left
|
|
@@ -159,9 +160,11 @@ export var multiplySizeUnit = function (value, quantity) {
|
|
|
159
160
|
return "" + parseFloat(legalSize) * quantity + unit;
|
|
160
161
|
};
|
|
161
162
|
export function requestAnimationFrame(fn) {
|
|
163
|
+
var globalThis = getGlobalThis();
|
|
162
164
|
return globalThis.requestAnimationFrame ? globalThis.requestAnimationFrame(fn) : globalThis.setTimeout(fn, 16);
|
|
163
165
|
}
|
|
164
166
|
export function cancelAnimationFrame(handle) {
|
|
167
|
+
var globalThis = getGlobalThis();
|
|
165
168
|
globalThis.cancelAnimationFrame ? globalThis.cancelAnimationFrame(handle) : globalThis.clearTimeout(handle);
|
|
166
169
|
}
|
|
167
170
|
export function nextTickFrame(fn) {
|
package/es/utils/shared.js
CHANGED
|
@@ -44,4 +44,23 @@ export var createCache = max => {
|
|
|
44
44
|
export var linear = value => value;
|
|
45
45
|
export var cubic = value => Math.pow(value, 3);
|
|
46
46
|
export var easeInOutCubic = value => value < 0.5 ? cubic(value * 2) / 2 : 1 - cubic((1 - value) * 2) / 2;
|
|
47
|
-
export var dt = (value, defaultText) => value == null ? defaultText : value;
|
|
47
|
+
export var dt = (value, defaultText) => value == null ? defaultText : value;
|
|
48
|
+
export var getGlobalThis = () => {
|
|
49
|
+
if (typeof globalThis !== 'undefined') return globalThis;
|
|
50
|
+
if (typeof window !== 'undefined') return window;
|
|
51
|
+
return typeof global !== 'undefined' ? global : self;
|
|
52
|
+
};
|
|
53
|
+
export var padStart = function (str, maxLength, fillString) {
|
|
54
|
+
if (str === void 0) {
|
|
55
|
+
str = '';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (fillString === void 0) {
|
|
59
|
+
fillString = '';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (str.length >= maxLength) return str;
|
|
63
|
+
var len = maxLength - str.length;
|
|
64
|
+
var repeatCount = Math.floor(len / fillString.length);
|
|
65
|
+
return fillString.repeat(repeatCount) + fillString.slice(0, len % fillString.length) + str;
|
|
66
|
+
};
|