@varlet/ui 1.26.7 → 1.26.8

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/varlet.esm.js CHANGED
@@ -6,6 +6,334 @@ var context = {
6
6
  };
7
7
  reactive(context);
8
8
  var Context = reactive(context);
9
+ var toNumber = (val) => {
10
+ if (val == null)
11
+ return 0;
12
+ if (isString(val)) {
13
+ val = parseFloat(val);
14
+ val = Number.isNaN(val) ? 0 : val;
15
+ return val;
16
+ }
17
+ if (isBool(val))
18
+ return Number(val);
19
+ return val;
20
+ };
21
+ var isHTMLSupportImage = (val) => {
22
+ if (val == null) {
23
+ return false;
24
+ }
25
+ return val.startsWith("data:image") || /\.(png|jpg|gif|jpeg|svg)$/.test(val);
26
+ };
27
+ var isHTMLSupportVideo = (val) => {
28
+ if (val == null) {
29
+ return false;
30
+ }
31
+ return val.startsWith("data:video") || /\.(mp4|webm|ogg)$/.test(val);
32
+ };
33
+ var isString = (val) => typeof val === "string";
34
+ var isBool = (val) => typeof val === "boolean";
35
+ var isNumber = (val) => typeof val === "number";
36
+ var isPlainObject = (val) => Object.prototype.toString.call(val) === "[object Object]";
37
+ var isObject = (val) => typeof val === "object" && val !== null;
38
+ var isArray = (val) => Array.isArray(val);
39
+ var isURL = (val) => {
40
+ if (!val) {
41
+ return false;
42
+ }
43
+ return /^(http)|(\.*\/)/.test(val);
44
+ };
45
+ var isEmpty = (val) => val === void 0 || val === null || val === "" || Array.isArray(val) && !val.length;
46
+ var removeItem = (arr, item) => {
47
+ if (arr.length) {
48
+ var index = arr.indexOf(item);
49
+ if (index > -1) {
50
+ return arr.splice(index, 1);
51
+ }
52
+ }
53
+ };
54
+ var throttle = function(method, mustRunDelay) {
55
+ if (mustRunDelay === void 0) {
56
+ mustRunDelay = 200;
57
+ }
58
+ var timer;
59
+ var start = 0;
60
+ return function loop() {
61
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
62
+ args[_key] = arguments[_key];
63
+ }
64
+ var now = Date.now();
65
+ var elapsed = now - start;
66
+ if (!start) {
67
+ start = now;
68
+ }
69
+ if (timer) {
70
+ window.clearTimeout(timer);
71
+ }
72
+ if (elapsed >= mustRunDelay) {
73
+ method.apply(this, args);
74
+ start = now;
75
+ } else {
76
+ timer = window.setTimeout(() => {
77
+ loop.apply(this, args);
78
+ }, mustRunDelay - elapsed);
79
+ }
80
+ };
81
+ };
82
+ var createCache = (max2) => {
83
+ var cache = [];
84
+ return {
85
+ cache,
86
+ has(key) {
87
+ return this.cache.includes(key);
88
+ },
89
+ add(key) {
90
+ if (this.has(key)) {
91
+ return;
92
+ }
93
+ this.cache.length === max2 && cache.shift();
94
+ this.cache.push(key);
95
+ },
96
+ remove(key) {
97
+ this.has(key) && removeItem(this.cache, key);
98
+ },
99
+ clear() {
100
+ this.cache.length = 0;
101
+ }
102
+ };
103
+ };
104
+ var linear = (value) => value;
105
+ var cubic = (value) => Math.pow(value, 3);
106
+ var easeInOutCubic = (value) => value < 0.5 ? cubic(value * 2) / 2 : 1 - cubic((1 - value) * 2) / 2;
107
+ function parseFormat(format, time) {
108
+ var scannedTimes = Object.values(time);
109
+ var scannedFormats = ["DD", "HH", "mm", "ss"];
110
+ var padValues = [24, 60, 60, 1e3];
111
+ scannedFormats.forEach((scannedFormat, index) => {
112
+ if (!format.includes(scannedFormat)) {
113
+ scannedTimes[index + 1] += scannedTimes[index] * padValues[index];
114
+ } else {
115
+ format = format.replace(scannedFormat, String(scannedTimes[index]).padStart(2, "0"));
116
+ }
117
+ });
118
+ if (format.includes("S")) {
119
+ var ms = String(scannedTimes[scannedTimes.length - 1]).padStart(3, "0");
120
+ if (format.includes("SSS")) {
121
+ format = format.replace("SSS", ms);
122
+ } else if (format.includes("SS")) {
123
+ format = format.replace("SS", ms.slice(0, 2));
124
+ } else {
125
+ format = format.replace("S", ms.slice(0, 1));
126
+ }
127
+ }
128
+ return format;
129
+ }
130
+ var dt = (value, defaultText) => value == null ? defaultText : value;
131
+ var inBrowser = () => typeof window !== "undefined";
132
+ var uniq = (arr) => [...new Set(arr)];
133
+ function kebabCase(str) {
134
+ var ret = str.replace(/([A-Z])/g, " $1").trim();
135
+ return ret.split(" ").join("-").toLowerCase();
136
+ }
137
+ function asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, key, arg) {
138
+ try {
139
+ var info = gen[key](arg);
140
+ var value = info.value;
141
+ } catch (error) {
142
+ reject(error);
143
+ return;
144
+ }
145
+ if (info.done) {
146
+ resolve(value);
147
+ } else {
148
+ Promise.resolve(value).then(_next, _throw);
149
+ }
150
+ }
151
+ function _asyncToGenerator$b(fn) {
152
+ return function() {
153
+ var self = this, args = arguments;
154
+ return new Promise(function(resolve, reject) {
155
+ var gen = fn.apply(self, args);
156
+ function _next(value) {
157
+ asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, "next", value);
158
+ }
159
+ function _throw(err) {
160
+ asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, "throw", err);
161
+ }
162
+ _next(void 0);
163
+ });
164
+ };
165
+ }
166
+ function getLeft(element) {
167
+ var {
168
+ left
169
+ } = element.getBoundingClientRect();
170
+ return left + (document.body.scrollLeft || document.documentElement.scrollLeft);
171
+ }
172
+ function getTop$1(element) {
173
+ var {
174
+ top
175
+ } = element.getBoundingClientRect();
176
+ return top + (document.body.scrollTop || document.documentElement.scrollTop);
177
+ }
178
+ function getScrollTop(element) {
179
+ var top = "scrollTop" in element ? element.scrollTop : element.pageYOffset;
180
+ return Math.max(top, 0);
181
+ }
182
+ function getScrollLeft(element) {
183
+ var left = "scrollLeft" in element ? element.scrollLeft : element.pageXOffset;
184
+ return Math.max(left, 0);
185
+ }
186
+ function inViewport(_x) {
187
+ return _inViewport.apply(this, arguments);
188
+ }
189
+ function _inViewport() {
190
+ _inViewport = _asyncToGenerator$b(function* (element) {
191
+ yield doubleRaf();
192
+ var {
193
+ top,
194
+ bottom,
195
+ left,
196
+ right
197
+ } = element.getBoundingClientRect();
198
+ var {
199
+ innerWidth,
200
+ innerHeight
201
+ } = window;
202
+ var xInViewport = left <= innerWidth && right >= 0;
203
+ var yInViewport = top <= innerHeight && bottom >= 0;
204
+ return xInViewport && yInViewport;
205
+ });
206
+ return _inViewport.apply(this, arguments);
207
+ }
208
+ function getTranslate(el) {
209
+ var {
210
+ transform
211
+ } = window.getComputedStyle(el);
212
+ return +transform.slice(transform.lastIndexOf(",") + 2, transform.length - 1);
213
+ }
214
+ function getParentScroller(el) {
215
+ var element = el;
216
+ while (element) {
217
+ if (!element.parentNode) {
218
+ break;
219
+ }
220
+ element = element.parentNode;
221
+ if (element === document.body || element === document.documentElement) {
222
+ break;
223
+ }
224
+ var scrollRE = /(scroll|auto)/;
225
+ var {
226
+ overflowY,
227
+ overflow
228
+ } = window.getComputedStyle(element);
229
+ if (scrollRE.test(overflowY) || scrollRE.test(overflow)) {
230
+ return element;
231
+ }
232
+ }
233
+ return window;
234
+ }
235
+ function getAllParentScroller(el) {
236
+ var allParentScroller = [];
237
+ var element = el;
238
+ while (element !== window) {
239
+ element = getParentScroller(element);
240
+ allParentScroller.push(element);
241
+ }
242
+ return allParentScroller;
243
+ }
244
+ var isRem = (value) => isString(value) && value.endsWith("rem");
245
+ var isPx = (value) => isString(value) && value.endsWith("px") || isNumber(value);
246
+ var isPercent = (value) => isString(value) && value.endsWith("%");
247
+ var isVw = (value) => isString(value) && value.endsWith("vw");
248
+ var isVh = (value) => isString(value) && value.endsWith("vh");
249
+ var toPxNum = (value) => {
250
+ if (isNumber(value)) {
251
+ return value;
252
+ }
253
+ if (isPx(value)) {
254
+ return +value.replace("px", "");
255
+ }
256
+ if (isVw(value)) {
257
+ return +value.replace("vw", "") * window.innerWidth / 100;
258
+ }
259
+ if (isVh(value)) {
260
+ return +value.replace("vh", "") * window.innerHeight / 100;
261
+ }
262
+ if (isRem(value)) {
263
+ var num = +value.replace("rem", "");
264
+ var rootFontSize = window.getComputedStyle(document.documentElement).fontSize;
265
+ return num * parseFloat(rootFontSize);
266
+ }
267
+ if (isString(value)) {
268
+ return toNumber(value);
269
+ }
270
+ return 0;
271
+ };
272
+ var toSizeUnit = (value) => {
273
+ if (value == null) {
274
+ return void 0;
275
+ }
276
+ if (isPercent(value) || isVw(value) || isVh(value) || isRem(value)) {
277
+ return value;
278
+ }
279
+ return toPxNum(value) + "px";
280
+ };
281
+ function requestAnimationFrame(fn) {
282
+ return globalThis.requestAnimationFrame ? globalThis.requestAnimationFrame(fn) : globalThis.setTimeout(fn, 16);
283
+ }
284
+ function cancelAnimationFrame(handle) {
285
+ globalThis.cancelAnimationFrame ? globalThis.cancelAnimationFrame(handle) : globalThis.clearTimeout(handle);
286
+ }
287
+ function nextTickFrame(fn) {
288
+ requestAnimationFrame(() => {
289
+ requestAnimationFrame(fn);
290
+ });
291
+ }
292
+ function doubleRaf() {
293
+ return new Promise((resolve) => {
294
+ requestAnimationFrame(() => {
295
+ requestAnimationFrame(resolve);
296
+ });
297
+ });
298
+ }
299
+ function scrollTo(element, _ref) {
300
+ var {
301
+ top = 0,
302
+ left = 0,
303
+ duration = 300,
304
+ animation
305
+ } = _ref;
306
+ var startTime = Date.now();
307
+ var scrollTop = getScrollTop(element);
308
+ var scrollLeft = getScrollLeft(element);
309
+ return new Promise((resolve) => {
310
+ var frame = () => {
311
+ var progress2 = (Date.now() - startTime) / duration;
312
+ if (progress2 < 1) {
313
+ var nextTop = scrollTop + (top - scrollTop) * animation(progress2);
314
+ var nextLeft = scrollLeft + (left - scrollLeft) * animation(progress2);
315
+ element.scrollTo(nextLeft, nextTop);
316
+ requestAnimationFrame(frame);
317
+ } else {
318
+ element.scrollTo(left, top);
319
+ resolve();
320
+ }
321
+ };
322
+ requestAnimationFrame(frame);
323
+ });
324
+ }
325
+ function formatStyleVars(styleVars) {
326
+ return Object.entries(styleVars != null ? styleVars : {}).reduce((styles, _ref2) => {
327
+ var [key, value] = _ref2;
328
+ var cssVar = key.startsWith("--") ? key : "--" + kebabCase(key);
329
+ styles[cssVar] = value;
330
+ return styles;
331
+ }, {});
332
+ }
333
+ function supportTouch() {
334
+ var inBrowser2 = typeof window !== "undefined";
335
+ return inBrowser2 && "ontouchstart" in window;
336
+ }
9
337
  function _extends$d() {
10
338
  _extends$d = Object.assign || function(target) {
11
339
  for (var i = 1; i < arguments.length; i++) {
@@ -110,6 +438,9 @@ function removeRipple() {
110
438
  }
111
439
  function forbidRippleTask() {
112
440
  var _ripple = this._ripple;
441
+ if (!supportTouch()) {
442
+ return;
443
+ }
113
444
  if (!_ripple.touchmoveForbid) {
114
445
  return;
115
446
  }
@@ -272,167 +603,39 @@ function useLock(props2, state, use2) {
272
603
  releaseLock(uid);
273
604
  }
274
605
  });
275
- onActivated(() => {
276
- if (use2 && props2[use2] === false) {
277
- return;
278
- }
279
- if (props2[state] === true) {
280
- addLock(uid);
281
- }
282
- });
283
- onDeactivated(() => {
284
- if (use2 && props2[use2] === false) {
285
- return;
286
- }
287
- if (props2[state] === true) {
288
- releaseLock(uid);
289
- }
290
- });
291
- }
292
- function useZIndex(source, count) {
293
- var zIndex = ref(Context.zIndex);
294
- watch(source, (newValue) => {
295
- if (newValue) {
296
- Context.zIndex += count;
297
- zIndex.value = Context.zIndex;
298
- }
299
- }, {
300
- immediate: true
301
- });
302
- return {
303
- zIndex
304
- };
305
- }
306
- var toNumber = (val) => {
307
- if (val == null)
308
- return 0;
309
- if (isString(val)) {
310
- val = parseFloat(val);
311
- val = Number.isNaN(val) ? 0 : val;
312
- return val;
313
- }
314
- if (isBool(val))
315
- return Number(val);
316
- return val;
317
- };
318
- var isHTMLSupportImage = (val) => {
319
- if (val == null) {
320
- return false;
321
- }
322
- return val.startsWith("data:image") || /\.(png|jpg|gif|jpeg|svg)$/.test(val);
323
- };
324
- var isHTMLSupportVideo = (val) => {
325
- if (val == null) {
326
- return false;
327
- }
328
- return val.startsWith("data:video") || /\.(mp4|webm|ogg)$/.test(val);
329
- };
330
- var isString = (val) => typeof val === "string";
331
- var isBool = (val) => typeof val === "boolean";
332
- var isNumber = (val) => typeof val === "number";
333
- var isPlainObject = (val) => Object.prototype.toString.call(val) === "[object Object]";
334
- var isObject = (val) => typeof val === "object" && val !== null;
335
- var isArray = (val) => Array.isArray(val);
336
- var isURL = (val) => {
337
- if (!val) {
338
- return false;
339
- }
340
- return /^(http)|(\.*\/)/.test(val);
341
- };
342
- var isEmpty = (val) => val === void 0 || val === null || val === "" || Array.isArray(val) && !val.length;
343
- var removeItem = (arr, item) => {
344
- if (arr.length) {
345
- var index = arr.indexOf(item);
346
- if (index > -1) {
347
- return arr.splice(index, 1);
348
- }
349
- }
350
- };
351
- var throttle = function(method, mustRunDelay) {
352
- if (mustRunDelay === void 0) {
353
- mustRunDelay = 200;
354
- }
355
- var timer;
356
- var start = 0;
357
- return function loop() {
358
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
359
- args[_key] = arguments[_key];
360
- }
361
- var now = Date.now();
362
- var elapsed = now - start;
363
- if (!start) {
364
- start = now;
365
- }
366
- if (timer) {
367
- window.clearTimeout(timer);
368
- }
369
- if (elapsed >= mustRunDelay) {
370
- method.apply(this, args);
371
- start = now;
372
- } else {
373
- timer = window.setTimeout(() => {
374
- loop.apply(this, args);
375
- }, mustRunDelay - elapsed);
376
- }
377
- };
378
- };
379
- var createCache = (max2) => {
380
- var cache = [];
381
- return {
382
- cache,
383
- has(key) {
384
- return this.cache.includes(key);
385
- },
386
- add(key) {
387
- if (this.has(key)) {
388
- return;
389
- }
390
- this.cache.length === max2 && cache.shift();
391
- this.cache.push(key);
392
- },
393
- remove(key) {
394
- this.has(key) && removeItem(this.cache, key);
395
- },
396
- clear() {
397
- this.cache.length = 0;
398
- }
399
- };
400
- };
401
- var linear = (value) => value;
402
- var cubic = (value) => Math.pow(value, 3);
403
- var easeInOutCubic = (value) => value < 0.5 ? cubic(value * 2) / 2 : 1 - cubic((1 - value) * 2) / 2;
404
- function parseFormat(format, time) {
405
- var scannedTimes = Object.values(time);
406
- var scannedFormats = ["DD", "HH", "mm", "ss"];
407
- var padValues = [24, 60, 60, 1e3];
408
- scannedFormats.forEach((scannedFormat, index) => {
409
- if (!format.includes(scannedFormat)) {
410
- scannedTimes[index + 1] += scannedTimes[index] * padValues[index];
411
- } else {
412
- format = format.replace(scannedFormat, String(scannedTimes[index]).padStart(2, "0"));
606
+ onActivated(() => {
607
+ if (use2 && props2[use2] === false) {
608
+ return;
609
+ }
610
+ if (props2[state] === true) {
611
+ addLock(uid);
413
612
  }
414
613
  });
415
- if (format.includes("S")) {
416
- var ms = String(scannedTimes[scannedTimes.length - 1]).padStart(3, "0");
417
- if (format.includes("SSS")) {
418
- format = format.replace("SSS", ms);
419
- } else if (format.includes("SS")) {
420
- format = format.replace("SS", ms.slice(0, 2));
421
- } else {
422
- format = format.replace("S", ms.slice(0, 1));
614
+ onDeactivated(() => {
615
+ if (use2 && props2[use2] === false) {
616
+ return;
423
617
  }
424
- }
425
- return format;
618
+ if (props2[state] === true) {
619
+ releaseLock(uid);
620
+ }
621
+ });
426
622
  }
427
- var dt = (value, defaultText) => value == null ? defaultText : value;
428
- var inBrowser = () => typeof window !== "undefined";
429
- var uniq = (arr) => [...new Set(arr)];
430
- function kebabCase(str) {
431
- var ret = str.replace(/([A-Z])/g, " $1").trim();
432
- return ret.split(" ").join("-").toLowerCase();
623
+ function useZIndex(source, count) {
624
+ var zIndex = ref(Context.zIndex);
625
+ watch(source, (newValue) => {
626
+ if (newValue) {
627
+ Context.zIndex += count;
628
+ zIndex.value = Context.zIndex;
629
+ }
630
+ }, {
631
+ immediate: true
632
+ });
633
+ return {
634
+ zIndex
635
+ };
433
636
  }
434
637
  var _excluded = ["collect", "clear"];
435
- function asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, key, arg) {
638
+ function asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, key, arg) {
436
639
  try {
437
640
  var info = gen[key](arg);
438
641
  var value = info.value;
@@ -446,16 +649,16 @@ function asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, key, arg) {
446
649
  Promise.resolve(value).then(_next, _throw);
447
650
  }
448
651
  }
449
- function _asyncToGenerator$b(fn) {
652
+ function _asyncToGenerator$a(fn) {
450
653
  return function() {
451
654
  var self = this, args = arguments;
452
655
  return new Promise(function(resolve, reject) {
453
656
  var gen = fn.apply(self, args);
454
657
  function _next(value) {
455
- asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, "next", value);
658
+ asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, "next", value);
456
659
  }
457
660
  function _throw(err) {
458
- asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, "throw", err);
661
+ asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, "throw", err);
459
662
  }
460
663
  _next(void 0);
461
664
  });
@@ -642,7 +845,7 @@ function keyInProvides(key) {
642
845
  function useValidation() {
643
846
  var errorMessage = ref("");
644
847
  var validate = /* @__PURE__ */ function() {
645
- var _ref = _asyncToGenerator$b(function* (rules, value, apis) {
848
+ var _ref = _asyncToGenerator$a(function* (rules, value, apis) {
646
849
  if (!isArray(rules) || !rules.length) {
647
850
  return true;
648
851
  }
@@ -663,7 +866,7 @@ function useValidation() {
663
866
  errorMessage.value = "";
664
867
  };
665
868
  var validateWithTrigger = /* @__PURE__ */ function() {
666
- var _ref2 = _asyncToGenerator$b(function* (validateTrigger, trigger, rules, value, apis) {
869
+ var _ref2 = _asyncToGenerator$a(function* (validateTrigger, trigger, rules, value, apis) {
667
870
  if (validateTrigger.includes(trigger)) {
668
871
  (yield validate(rules, value, apis)) && (errorMessage.value = "");
669
872
  }
@@ -849,202 +1052,6 @@ var props$R = {
849
1052
  type: Function
850
1053
  }
851
1054
  };
852
- function asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, key, arg) {
853
- try {
854
- var info = gen[key](arg);
855
- var value = info.value;
856
- } catch (error) {
857
- reject(error);
858
- return;
859
- }
860
- if (info.done) {
861
- resolve(value);
862
- } else {
863
- Promise.resolve(value).then(_next, _throw);
864
- }
865
- }
866
- function _asyncToGenerator$a(fn) {
867
- return function() {
868
- var self = this, args = arguments;
869
- return new Promise(function(resolve, reject) {
870
- var gen = fn.apply(self, args);
871
- function _next(value) {
872
- asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, "next", value);
873
- }
874
- function _throw(err) {
875
- asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, "throw", err);
876
- }
877
- _next(void 0);
878
- });
879
- };
880
- }
881
- function getLeft(element) {
882
- var {
883
- left
884
- } = element.getBoundingClientRect();
885
- return left + (document.body.scrollLeft || document.documentElement.scrollLeft);
886
- }
887
- function getTop$1(element) {
888
- var {
889
- top
890
- } = element.getBoundingClientRect();
891
- return top + (document.body.scrollTop || document.documentElement.scrollTop);
892
- }
893
- function getScrollTop(element) {
894
- var top = "scrollTop" in element ? element.scrollTop : element.pageYOffset;
895
- return Math.max(top, 0);
896
- }
897
- function getScrollLeft(element) {
898
- var left = "scrollLeft" in element ? element.scrollLeft : element.pageXOffset;
899
- return Math.max(left, 0);
900
- }
901
- function inViewport(_x) {
902
- return _inViewport.apply(this, arguments);
903
- }
904
- function _inViewport() {
905
- _inViewport = _asyncToGenerator$a(function* (element) {
906
- yield doubleRaf();
907
- var {
908
- top,
909
- bottom,
910
- left,
911
- right
912
- } = element.getBoundingClientRect();
913
- var {
914
- innerWidth,
915
- innerHeight
916
- } = window;
917
- var xInViewport = left <= innerWidth && right >= 0;
918
- var yInViewport = top <= innerHeight && bottom >= 0;
919
- return xInViewport && yInViewport;
920
- });
921
- return _inViewport.apply(this, arguments);
922
- }
923
- function getTranslate(el) {
924
- var {
925
- transform
926
- } = window.getComputedStyle(el);
927
- return +transform.slice(transform.lastIndexOf(",") + 2, transform.length - 1);
928
- }
929
- function getParentScroller(el) {
930
- var element = el;
931
- while (element) {
932
- if (!element.parentNode) {
933
- break;
934
- }
935
- element = element.parentNode;
936
- if (element === document.body || element === document.documentElement) {
937
- break;
938
- }
939
- var scrollRE = /(scroll|auto)/;
940
- var {
941
- overflowY,
942
- overflow
943
- } = window.getComputedStyle(element);
944
- if (scrollRE.test(overflowY) || scrollRE.test(overflow)) {
945
- return element;
946
- }
947
- }
948
- return window;
949
- }
950
- function getAllParentScroller(el) {
951
- var allParentScroller = [];
952
- var element = el;
953
- while (element !== window) {
954
- element = getParentScroller(element);
955
- allParentScroller.push(element);
956
- }
957
- return allParentScroller;
958
- }
959
- var isRem = (value) => isString(value) && value.endsWith("rem");
960
- var isPx = (value) => isString(value) && value.endsWith("px") || isNumber(value);
961
- var isPercent = (value) => isString(value) && value.endsWith("%");
962
- var isVw = (value) => isString(value) && value.endsWith("vw");
963
- var isVh = (value) => isString(value) && value.endsWith("vh");
964
- var toPxNum = (value) => {
965
- if (isNumber(value)) {
966
- return value;
967
- }
968
- if (isPx(value)) {
969
- return +value.replace("px", "");
970
- }
971
- if (isVw(value)) {
972
- return +value.replace("vw", "") * window.innerWidth / 100;
973
- }
974
- if (isVh(value)) {
975
- return +value.replace("vh", "") * window.innerHeight / 100;
976
- }
977
- if (isRem(value)) {
978
- var num = +value.replace("rem", "");
979
- var rootFontSize = window.getComputedStyle(document.documentElement).fontSize;
980
- return num * parseFloat(rootFontSize);
981
- }
982
- if (isString(value)) {
983
- return toNumber(value);
984
- }
985
- return 0;
986
- };
987
- var toSizeUnit = (value) => {
988
- if (value == null) {
989
- return void 0;
990
- }
991
- if (isPercent(value) || isVw(value) || isVh(value) || isRem(value)) {
992
- return value;
993
- }
994
- return toPxNum(value) + "px";
995
- };
996
- function requestAnimationFrame(fn) {
997
- return globalThis.requestAnimationFrame ? globalThis.requestAnimationFrame(fn) : globalThis.setTimeout(fn, 16);
998
- }
999
- function cancelAnimationFrame(handle) {
1000
- globalThis.cancelAnimationFrame ? globalThis.cancelAnimationFrame(handle) : globalThis.clearTimeout(handle);
1001
- }
1002
- function nextTickFrame(fn) {
1003
- requestAnimationFrame(() => {
1004
- requestAnimationFrame(fn);
1005
- });
1006
- }
1007
- function doubleRaf() {
1008
- return new Promise((resolve) => {
1009
- requestAnimationFrame(() => {
1010
- requestAnimationFrame(resolve);
1011
- });
1012
- });
1013
- }
1014
- function scrollTo(element, _ref) {
1015
- var {
1016
- top = 0,
1017
- left = 0,
1018
- duration = 300,
1019
- animation
1020
- } = _ref;
1021
- var startTime = Date.now();
1022
- var scrollTop = getScrollTop(element);
1023
- var scrollLeft = getScrollLeft(element);
1024
- return new Promise((resolve) => {
1025
- var frame = () => {
1026
- var progress2 = (Date.now() - startTime) / duration;
1027
- if (progress2 < 1) {
1028
- var nextTop = scrollTop + (top - scrollTop) * animation(progress2);
1029
- var nextLeft = scrollLeft + (left - scrollLeft) * animation(progress2);
1030
- element.scrollTo(nextLeft, nextTop);
1031
- requestAnimationFrame(frame);
1032
- } else {
1033
- element.scrollTo(left, top);
1034
- resolve();
1035
- }
1036
- };
1037
- requestAnimationFrame(frame);
1038
- });
1039
- }
1040
- function formatStyleVars(styleVars) {
1041
- return Object.entries(styleVars != null ? styleVars : {}).reduce((styles, _ref2) => {
1042
- var [key, value] = _ref2;
1043
- var cssVar = key.startsWith("--") ? key : "--" + kebabCase(key);
1044
- styles[cssVar] = value;
1045
- return styles;
1046
- }, {});
1047
- }
1048
1055
  function asyncGeneratorStep$9(gen, resolve, reject, _next, _throw, key, arg) {
1049
1056
  try {
1050
1057
  var info = gen[key](arg);
@@ -1866,7 +1873,10 @@ var props$M = {
1866
1873
  function render$S(_ctx, _cache) {
1867
1874
  var _component_var_icon = resolveComponent("var-icon");
1868
1875
  var _component_var_button = resolveComponent("var-button");
1869
- return openBlock(), createElementBlock("div", {
1876
+ return openBlock(), createBlock(Teleport, {
1877
+ to: "body",
1878
+ disabled: _ctx.disabled
1879
+ }, [createElementVNode("div", {
1870
1880
  class: normalizeClass(["var-back-top", [_ctx.show ? "var-back-top--active" : null]]),
1871
1881
  ref: "backTopEl",
1872
1882
  style: normalizeStyle({
@@ -1885,7 +1895,7 @@ function render$S(_ctx, _cache) {
1885
1895
  name: "chevron-up"
1886
1896
  })]),
1887
1897
  _: 1
1888
- })])], 6);
1898
+ })])], 6)], 8, ["disabled"]);
1889
1899
  }
1890
1900
  var BackTop = defineComponent({
1891
1901
  render: render$S,
@@ -1898,6 +1908,7 @@ var BackTop = defineComponent({
1898
1908
  setup(props2) {
1899
1909
  var show = ref(false);
1900
1910
  var backTopEl = ref(null);
1911
+ var disabled = ref(true);
1901
1912
  var target;
1902
1913
  var click = (event) => {
1903
1914
  props2.onClick == null ? void 0 : props2.onClick(event);
@@ -1923,19 +1934,20 @@ var BackTop = defineComponent({
1923
1934
  }
1924
1935
  return el;
1925
1936
  }
1926
- if (isObject(target2)) {
1937
+ if (isObject(target2))
1927
1938
  return target2;
1928
- }
1929
1939
  throw Error('[Varlet] BackTop: type of prop "target" should be a selector or an element object');
1930
1940
  };
1931
1941
  onMounted(() => {
1932
1942
  target = props2.target ? getTarget() : getParentScroller(backTopEl.value);
1933
1943
  target.addEventListener("scroll", throttleScroll);
1944
+ disabled.value = false;
1934
1945
  });
1935
1946
  onBeforeUnmount(() => {
1936
1947
  target.removeEventListener("scroll", throttleScroll);
1937
1948
  });
1938
1949
  return {
1950
+ disabled,
1939
1951
  show,
1940
1952
  backTopEl,
1941
1953
  toSizeUnit,
@@ -12664,6 +12676,10 @@ var props$d = {
12664
12676
  type: Boolean,
12665
12677
  default: false
12666
12678
  },
12679
+ offsetY: {
12680
+ type: [String, Number],
12681
+ default: 0
12682
+ },
12667
12683
  chip: {
12668
12684
  type: Boolean,
12669
12685
  default: false
@@ -12956,7 +12972,7 @@ var Select = defineComponent({
12956
12972
  return;
12957
12973
  }
12958
12974
  wrapWidth.value = getWrapWidth();
12959
- offsetY.value = getOffsetY();
12975
+ offsetY.value = getOffsetY() + toPxNum(props2.offsetY);
12960
12976
  isFocus.value = true;
12961
12977
  onFocus == null ? void 0 : onFocus();
12962
12978
  validateWithTrigger("onFocus");
@@ -13063,6 +13079,8 @@ var Select = defineComponent({
13063
13079
  computeLabel();
13064
13080
  };
13065
13081
  var focus = () => {
13082
+ wrapWidth.value = getWrapWidth();
13083
+ offsetY.value = getOffsetY() + toPxNum(props2.offsetY);
13066
13084
  isFocus.value = true;
13067
13085
  };
13068
13086
  var blur = () => {