@varlet/ui 2.15.1 → 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.
@@ -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
  });