@varlet/ui 2.15.0 → 2.15.2-alpha.1693502641730

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.
Files changed (41) hide show
  1. package/es/card/Card.mjs +2 -1
  2. package/es/col/col.css +1 -1
  3. package/es/collapse-item/CollapseItem.mjs +43 -35
  4. package/es/countdown/Countdown.mjs +1 -2
  5. package/es/date-picker/DatePicker.mjs +13 -8
  6. package/es/drag/Drag.mjs +2 -2
  7. package/es/field-decorator/FieldDecorator.mjs +2 -3
  8. package/es/index-bar/IndexBar.mjs +4 -5
  9. package/es/index.bundle.mjs +1 -1
  10. package/es/index.mjs +1 -1
  11. package/es/lazy/index.mjs +2 -2
  12. package/es/list/List.mjs +2 -2
  13. package/es/loading-bar/LoadingBar.mjs +1 -1
  14. package/es/locale/index.mjs +1 -1
  15. package/es/menu/usePopover.mjs +2 -1
  16. package/es/option/Option.mjs +2 -2
  17. package/es/pull-refresh/PullRefresh.mjs +2 -2
  18. package/es/result/Result.mjs +5 -5
  19. package/es/ripple/index.mjs +1 -1
  20. package/es/slider/Slider.mjs +4 -4
  21. package/es/snackbar/Snackbar.mjs +1 -1
  22. package/es/step/Step.mjs +1 -1
  23. package/es/sticky/Sticky.mjs +2 -2
  24. package/es/style.css +1 -1
  25. package/es/swipe/Swipe.mjs +73 -59
  26. package/es/table/table.css +1 -1
  27. package/es/tabs/Tabs.mjs +2 -2
  28. package/es/tabs-items/TabsItems.mjs +1 -1
  29. package/es/time-picker/TimePicker.mjs +2 -3
  30. package/es/time-picker/clock.mjs +2 -3
  31. package/es/utils/elements.mjs +1 -71
  32. package/es/utils/shared.mjs +0 -5
  33. package/es/utils/test.mjs +1 -2
  34. package/es/varlet.esm.js +4009 -3988
  35. package/es/watermark/Watermark.mjs +1 -1
  36. package/highlight/web-types.en-US.json +1 -1
  37. package/highlight/web-types.zh-CN.json +1 -1
  38. package/lib/style.css +1 -1
  39. package/lib/varlet.cjs.js +497 -453
  40. package/package.json +6 -6
  41. package/umd/varlet.js +5 -5
@@ -2,9 +2,8 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
2
2
  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); }); }; }
3
3
  import { defineComponent, ref, computed, watch, onActivated } from 'vue';
4
4
  import { useSwipeItems } from './provide.mjs';
5
- import { doubleRaf, nextTickFrame } from '../utils/elements.mjs';
6
5
  import { props } from './props.mjs';
7
- import { clamp, isNumber, toNumber } from '@varlet/shared';
6
+ import { clamp, isNumber, toNumber, doubleRaf } from '@varlet/shared';
8
7
  import { call, createNamespace } from '../utils/components.mjs';
9
8
  import { onSmartUnmounted, onWindowResize, useTouch } from '@varlet/use';
10
9
  import { usePopup } from '../popup/provide.mjs';
@@ -153,23 +152,26 @@ var __sfc__ = defineComponent({
153
152
  }
154
153
  return clamp(index, 0, length.value - 1);
155
154
  };
156
- var fixPosition = fn => {
157
- var overLeft = trackTranslate.value >= size.value;
158
- var overRight = trackTranslate.value <= -trackSize.value;
159
- var leftTranslate = 0;
160
- var rightTranslate = -(trackSize.value - size.value);
161
- lockDuration.value = true;
162
- if (overLeft || overRight) {
155
+ var fixPosition = /*#__PURE__*/function () {
156
+ var _ref2 = _asyncToGenerator(function* () {
157
+ var overLeft = trackTranslate.value >= size.value;
158
+ var overRight = trackTranslate.value <= -trackSize.value;
159
+ var leftTranslate = 0;
160
+ var rightTranslate = -(trackSize.value - size.value);
163
161
  lockDuration.value = true;
164
- trackTranslate.value = overRight ? leftTranslate : rightTranslate;
165
- findSwipeItem(0).setTranslate(0);
166
- findSwipeItem(length.value - 1).setTranslate(0);
167
- }
168
- nextTickFrame(() => {
162
+ if (overLeft || overRight) {
163
+ lockDuration.value = true;
164
+ trackTranslate.value = overRight ? leftTranslate : rightTranslate;
165
+ findSwipeItem(0).setTranslate(0);
166
+ findSwipeItem(length.value - 1).setTranslate(0);
167
+ }
168
+ yield doubleRaf();
169
169
  lockDuration.value = false;
170
- call(fn);
171
170
  });
172
- };
171
+ return function fixPosition() {
172
+ return _ref2.apply(this, arguments);
173
+ };
174
+ }();
173
175
  var initialIndex = () => {
174
176
  if (initializedIndex) {
175
177
  return;
@@ -197,16 +199,20 @@ var __sfc__ = defineComponent({
197
199
  trackTranslate.value = value;
198
200
  dispatchSwipeItems();
199
201
  };
200
- var handleTouchstart = event => {
201
- if (length.value <= 1 || !props.touchable) {
202
- return;
203
- }
204
- startTouch(event);
205
- stopAutoplay();
206
- fixPosition(() => {
202
+ var handleTouchstart = /*#__PURE__*/function () {
203
+ var _ref3 = _asyncToGenerator(function* (event) {
204
+ if (length.value <= 1 || !props.touchable) {
205
+ return;
206
+ }
207
+ startTouch(event);
208
+ stopAutoplay();
209
+ yield fixPosition();
207
210
  lockDuration.value = true;
208
211
  });
209
- };
212
+ return function handleTouchstart(_x) {
213
+ return _ref3.apply(this, arguments);
214
+ };
215
+ }();
210
216
  var handleTouchmove = event => {
211
217
  var {
212
218
  touchable,
@@ -264,21 +270,22 @@ var __sfc__ = defineComponent({
264
270
  });
265
271
  };
266
272
  // expose
267
- var next = options => {
268
- if (length.value <= 1) {
269
- return;
270
- }
271
- initialIndex();
272
- var {
273
- loop,
274
- onChange
275
- } = props;
276
- var currentIndex = index.value;
277
- index.value = clampIndex(currentIndex + 1);
278
- if ((options == null ? void 0 : options.event) !== false) {
279
- call(onChange, index.value);
280
- }
281
- fixPosition(() => {
273
+ var next = /*#__PURE__*/function () {
274
+ var _ref4 = _asyncToGenerator(function* (options) {
275
+ if (length.value <= 1) {
276
+ return;
277
+ }
278
+ initialIndex();
279
+ var {
280
+ loop,
281
+ onChange
282
+ } = props;
283
+ var currentIndex = index.value;
284
+ index.value = clampIndex(currentIndex + 1);
285
+ if ((options == null ? void 0 : options.event) !== false) {
286
+ call(onChange, index.value);
287
+ }
288
+ yield fixPosition();
282
289
  if (currentIndex === length.value - 1 && loop) {
283
290
  findSwipeItem(0).setTranslate(trackSize.value);
284
291
  trackTranslate.value = length.value * -size.value;
@@ -288,23 +295,27 @@ var __sfc__ = defineComponent({
288
295
  trackTranslate.value = index.value * -size.value;
289
296
  }
290
297
  });
291
- };
298
+ return function next(_x2) {
299
+ return _ref4.apply(this, arguments);
300
+ };
301
+ }();
292
302
  // expose
293
- var prev = options => {
294
- if (length.value <= 1) {
295
- return;
296
- }
297
- initialIndex();
298
- var {
299
- loop,
300
- onChange
301
- } = props;
302
- var currentIndex = index.value;
303
- index.value = clampIndex(currentIndex - 1);
304
- if ((options == null ? void 0 : options.event) !== false) {
305
- call(onChange, index.value);
306
- }
307
- fixPosition(() => {
303
+ var prev = /*#__PURE__*/function () {
304
+ var _ref5 = _asyncToGenerator(function* (options) {
305
+ if (length.value <= 1) {
306
+ return;
307
+ }
308
+ initialIndex();
309
+ var {
310
+ loop,
311
+ onChange
312
+ } = props;
313
+ var currentIndex = index.value;
314
+ index.value = clampIndex(currentIndex - 1);
315
+ if ((options == null ? void 0 : options.event) !== false) {
316
+ call(onChange, index.value);
317
+ }
318
+ yield fixPosition();
308
319
  if (currentIndex === 0 && loop) {
309
320
  findSwipeItem(length.value - 1).setTranslate(-trackSize.value);
310
321
  trackTranslate.value = size.value;
@@ -314,7 +325,10 @@ var __sfc__ = defineComponent({
314
325
  trackTranslate.value = index.value * -size.value;
315
326
  }
316
327
  });
317
- };
328
+ return function prev(_x3) {
329
+ return _ref5.apply(this, arguments);
330
+ };
331
+ }();
318
332
  // expose
319
333
  var to = (idx, options) => {
320
334
  if (length.value <= 1 || idx === index.value) {
@@ -347,7 +361,7 @@ var __sfc__ = defineComponent({
347
361
  if (popup) {
348
362
  // watch popup show again
349
363
  watch(() => popup.show.value, /*#__PURE__*/function () {
350
- var _ref3 = _asyncToGenerator(function* (show) {
364
+ var _ref7 = _asyncToGenerator(function* (show) {
351
365
  if (show) {
352
366
  yield doubleRaf();
353
367
  resize();
@@ -355,8 +369,8 @@ var __sfc__ = defineComponent({
355
369
  stopAutoplay();
356
370
  }
357
371
  });
358
- return function (_x) {
359
- return _ref3.apply(this, arguments);
372
+ return function (_x4) {
373
+ return _ref7.apply(this, arguments);
360
374
  };
361
375
  }());
362
376
  }
@@ -1 +1 @@
1
- :root { --table-background: #fff; --table-border-radius: 2px; --table-thead-border-bottom: thin solid rgba(0, 0, 0, 0.12); --table-thead-th-text-color: rgba(0, 0, 0, 0.6); --table-thead-th-font-size: 14px; --table-thead-tr-border-bottom: thin solid rgba(0, 0, 0, 0.12); --table-tbody-tr-hover-background: #eee; --table-tbody-tr-border-bottom: thin solid rgba(0, 0, 0, 0.12); --table-tbody-td-text-color: #555; --table-tbody-td-font-size: 16px; --table-row-height: 46px; --table-row-padding: 0 16px; --table-footer-border-top: thin solid rgba(0, 0, 0, 0.12);}.var-table { width: 100%; background: var(--table-background); border-radius: var(--table-border-radius); transition: 0.25s background-color;}.var-table * { box-sizing: border-box;}.var-table__main { width: 100%; overflow-x: auto;}.var-table__main > table { min-width: 100%; display: table; border-spacing: 0; border-collapse: collapse; line-height: normal;}.var-table__main > table thead { display: table-header-group; border-bottom: var(--table-thead-border-bottom);}.var-table__main > table thead tr th { color: var(--table-thead-th-text-color); font-size: var(--table-thead-th-font-size);}.var-table__main > table thead tr:not(:last-child) { border-bottom: var(--table-thead-tr-border-bottom);}.var-table__main > table tbody { display: table-row-group;}.var-table__main > table tbody tr { display: table-row; outline: 0; vertical-align: middle;}.var-table__main > table tbody tr:hover { background: var(--table-tbody-tr-hover-background);}.var-table__main > table tbody tr:not(:last-child) { border-bottom: var(--table-tbody-tr-border-bottom);}.var-table__main > table tbody td { color: var(--table-tbody-td-text-color); font-size: var(--table-tbody-td-font-size);}.var-table__main > table th { display: table-cell; height: var(--table-row-height); padding: var(--table-row-padding); font-weight: 500; text-align: left;}.var-table__main > table td { display: table-cell; padding: var(--table-row-padding); height: var(--table-row-height); text-align: left;}.var-table__footer { width: 100%; min-height: var(--table-row-height); border-top: var(--table-footer-border-top);}
1
+ :root { --table-background: #fff; --table-border-radius: 2px; --table-thead-border-bottom: thin solid rgba(0, 0, 0, 0.12); --table-thead-th-text-color: rgba(0, 0, 0, 0.6); --table-thead-th-font-size: 14px; --table-thead-tr-border-bottom: thin solid rgba(0, 0, 0, 0.12); --table-tbody-tr-hover-background: #eee; --table-tbody-tr-border-bottom: thin solid rgba(0, 0, 0, 0.12); --table-tbody-td-text-color: #555; --table-tbody-td-font-size: 16px; --table-row-height: 46px; --table-row-padding: 0 16px; --table-footer-border-top: thin solid rgba(0, 0, 0, 0.12);}.var-table { width: 100%; background: var(--table-background); border-radius: var(--table-border-radius); transition: 0.25s background-color;}.var-table * { box-sizing: border-box;}.var-table__main { width: 100%; overflow-x: auto;}.var-table__main > table { min-width: 100%; display: table; border-spacing: 0; border-collapse: collapse; line-height: normal;}.var-table__main > table thead { display: table-header-group; border-bottom: var(--table-thead-border-bottom);}.var-table__main > table thead tr th { color: var(--table-thead-th-text-color); font-size: var(--table-thead-th-font-size);}.var-table__main > table thead tr:not(:last-child) { border-bottom: var(--table-thead-tr-border-bottom);}.var-table__main > table tbody { display: table-row-group;}.var-table__main > table tbody tr { display: table-row; outline: 0; vertical-align: middle;}.var-table__main > table tbody tr:hover { background: var(--table-tbody-tr-hover-background); transition: background-color 0.25s;}.var-table__main > table tbody tr:not(:last-child) { border-bottom: var(--table-tbody-tr-border-bottom);}.var-table__main > table tbody td { color: var(--table-tbody-td-text-color); font-size: var(--table-tbody-td-font-size);}.var-table__main > table th { display: table-cell; height: var(--table-row-height); padding: var(--table-row-padding); font-weight: 500; text-align: left;}.var-table__main > table td { display: table-cell; padding: var(--table-row-padding); height: var(--table-row-height); text-align: left;}.var-table__footer { width: 100%; min-height: var(--table-row-height); border-top: var(--table-footer-border-top);}
package/es/tabs/Tabs.mjs CHANGED
@@ -4,9 +4,9 @@ import VarSticky from '../sticky/index.mjs';
4
4
  import { defineComponent, watch, ref, computed, Transition, onActivated } from 'vue';
5
5
  import { props } from './props.mjs';
6
6
  import { useTabList } from './provide.mjs';
7
- import { clamp, isNumber } from '@varlet/shared';
7
+ import { clamp, isNumber, doubleRaf } from '@varlet/shared';
8
8
  import { linear } from '../utils/shared.mjs';
9
- import { toSizeUnit, scrollTo, doubleRaf } from '../utils/elements.mjs';
9
+ import { toSizeUnit, scrollTo } from '../utils/elements.mjs';
10
10
  import { createNamespace, call, formatElevation } from '../utils/components.mjs';
11
11
  import { onWindowResize } from '@varlet/use';
12
12
  var {
@@ -5,7 +5,7 @@ import { defineComponent, watch, ref } from 'vue';
5
5
  import { useTabItem } from './provide.mjs';
6
6
  import { call, createNamespace } from '../utils/components.mjs';
7
7
  import { props } from './props.mjs';
8
- import { doubleRaf } from '../utils/elements.mjs';
8
+ import { doubleRaf } from '@varlet/shared';
9
9
  var {
10
10
  n
11
11
  } = createNamespace('tabs-items');
@@ -1,12 +1,11 @@
1
- import { computed, defineComponent, reactive, ref, watch } from 'vue';
2
1
  import dayjs from 'dayjs/esm';
3
2
  import Clock from './clock.mjs';
3
+ import { computed, defineComponent, reactive, ref, watch } from 'vue';
4
4
  import { props, hoursAmpm, hours24 } from './props.mjs';
5
- import { toNumber } from '@varlet/shared';
5
+ import { toNumber, getRect } from '@varlet/shared';
6
6
  import { createNamespace, call, formatElevation } from '../utils/components.mjs';
7
7
  import { padStart } from '../utils/shared.mjs';
8
8
  import { getNumberTime, getIsDisableMinute, getIsDisableSecond } from './utils.mjs';
9
- import { getRect } from '../utils/elements.mjs';
10
9
  var {
11
10
  n,
12
11
  classes
@@ -1,11 +1,10 @@
1
- import { computed, defineComponent, ref, watch } from 'vue';
2
1
  import dayjs from 'dayjs/esm';
2
+ import { computed, defineComponent, ref, watch } from 'vue';
3
3
  import { hoursAmpm, hours24, minSec } from './props.mjs';
4
4
  import { notConvert, convertHour, getIsDisableMinute, getIsDisableSecond, getNumberTime } from './utils.mjs';
5
- import { toNumber } from '@varlet/shared';
5
+ import { toNumber, getRect } from '@varlet/shared';
6
6
  import { createNamespace } from '../utils/components.mjs';
7
7
  import { padStart } from '../utils/shared.mjs';
8
- import { getRect } from '../utils/elements.mjs';
9
8
  var {
10
9
  n,
11
10
  classes
@@ -1,31 +1,5 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
- import { isNumber, isObject, isString, kebabCase, toNumber, isWindow, inBrowser } from '@varlet/shared';
3
- import { getGlobalThis } from './shared.mjs';
1
+ import { isNumber, isObject, isString, kebabCase, toNumber, isWindow, inBrowser, getRect, getStyle } from '@varlet/shared';
4
2
  import { error } from './logger.mjs';
5
- // shorthand only
6
- export function getStyle(element) {
7
- return window.getComputedStyle(element);
8
- }
9
- export function getRect(element) {
10
- if (isWindow(element)) {
11
- var width = element.innerWidth;
12
- var height = element.innerHeight;
13
- var rect = {
14
- x: 0,
15
- y: 0,
16
- top: 0,
17
- left: 0,
18
- right: width,
19
- bottom: height,
20
- width,
21
- height
22
- };
23
- return _extends({}, rect, {
24
- toJSON: () => rect
25
- });
26
- }
27
- return element.getBoundingClientRect();
28
- }
29
3
  export function getLeft(element) {
30
4
  var {
31
5
  left
@@ -48,21 +22,6 @@ export function getScrollLeft(element) {
48
22
  var left = 'scrollLeft' in element ? element.scrollLeft : element.pageXOffset;
49
23
  return Math.max(left, 0);
50
24
  }
51
- export function inViewport(element) {
52
- var {
53
- top,
54
- bottom,
55
- left,
56
- right
57
- } = getRect(element);
58
- var {
59
- width,
60
- height
61
- } = getRect(window);
62
- var xInViewport = left <= width && right >= 0;
63
- var yInViewport = top <= height && bottom >= 0;
64
- return xInViewport && yInViewport;
65
- }
66
25
  export function getTranslateY(el) {
67
26
  var {
68
27
  transform
@@ -216,31 +175,6 @@ export var multiplySizeUnit = function (value, quantity) {
216
175
  var unit = legalSize.match(/(vh|%|r?em|px|vw|vmin|vmax)$/)[0];
217
176
  return "" + parseFloat(legalSize) * quantity + unit;
218
177
  };
219
- export function requestAnimationFrame(fn) {
220
- var globalThis = getGlobalThis();
221
- return globalThis.requestAnimationFrame ? globalThis.requestAnimationFrame(fn) : globalThis.setTimeout(fn, 16);
222
- }
223
- export function cancelAnimationFrame(handle) {
224
- var globalThis = getGlobalThis();
225
- globalThis.cancelAnimationFrame ? globalThis.cancelAnimationFrame(handle) : globalThis.clearTimeout(handle);
226
- }
227
- export function nextTickFrame(fn) {
228
- requestAnimationFrame(() => {
229
- requestAnimationFrame(fn);
230
- });
231
- }
232
- export function doubleRaf() {
233
- return new Promise(resolve => {
234
- requestAnimationFrame(() => {
235
- requestAnimationFrame(resolve);
236
- });
237
- });
238
- }
239
- export function raf() {
240
- return new Promise(resolve => {
241
- requestAnimationFrame(resolve);
242
- });
243
- }
244
178
  export function scrollTo(element, _ref) {
245
179
  var {
246
180
  top = 0,
@@ -275,10 +209,6 @@ export function formatStyleVars(styleVars) {
275
209
  return styles;
276
210
  }, {});
277
211
  }
278
- export function supportTouch() {
279
- var inBrowser = typeof window !== 'undefined';
280
- return inBrowser && 'ontouchstart' in window;
281
- }
282
212
  export function padStartFlex(style) {
283
213
  return style === 'start' || style === 'end' ? "flex-" + style : style;
284
214
  }
@@ -37,11 +37,6 @@ export var linear = value => value;
37
37
  export var cubic = value => Math.pow(value, 3);
38
38
  export var easeInOutCubic = value => value < 0.5 ? cubic(value * 2) / 2 : 1 - cubic((1 - value) * 2) / 2;
39
39
  export var dt = (value, defaultText) => value == null ? defaultText : value;
40
- export var getGlobalThis = () => {
41
- if (typeof globalThis !== 'undefined') return globalThis;
42
- if (typeof window !== 'undefined') return window;
43
- return typeof global !== 'undefined' ? global : self;
44
- };
45
40
 
46
41
  // eslint-disable-next-line default-param-last
47
42
  export var padStart = function (str, maxLength, fillString) {
package/es/utils/test.mjs CHANGED
@@ -2,8 +2,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
2
2
  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); }); }; }
3
3
  import { nextTick } from 'vue';
4
4
  import { config } from '@vue/test-utils';
5
- import { isPlainObject } from '@varlet/shared';
6
- import { getStyle } from './elements.mjs';
5
+ import { isPlainObject, getStyle } from '@varlet/shared';
7
6
  export var delay = time => new Promise(resolve => {
8
7
  setTimeout(resolve, time);
9
8
  });