@varlet/ui 2.5.3 → 2.5.5-alpha.1672917543560

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.
@@ -2,9 +2,9 @@ import { defineComponent, ref, onMounted, onBeforeUnmount } from 'vue';
2
2
  import VarButton from '../button';
3
3
  import VarIcon from '../icon';
4
4
  import { props } from './props';
5
- import { isString, throttle, isObject } from '@varlet/shared';
5
+ import { throttle } from '@varlet/shared';
6
6
  import { easeInOutCubic } from '../utils/shared';
7
- import { getScrollTop, getScrollLeft, scrollTo, getParentScroller, toPxNum, toSizeUnit } from '../utils/elements';
7
+ import { getScrollTop, getScrollLeft, scrollTo, getParentScroller, toPxNum, toSizeUnit, getTarget } from '../utils/elements';
8
8
  import { call, createNamespace } from '../utils/components';
9
9
  var {
10
10
  n,
@@ -78,28 +78,8 @@ export default defineComponent({
78
78
  };
79
79
 
80
80
  var throttleScroll = throttle(scroll, 200);
81
-
82
- var getTarget = () => {
83
- var {
84
- target
85
- } = props;
86
-
87
- if (isString(target)) {
88
- var el = document.querySelector(props.target);
89
-
90
- if (!el) {
91
- throw Error('[Varlet] BackTop: target element cannot found');
92
- }
93
-
94
- return el;
95
- }
96
-
97
- if (isObject(target)) return target;
98
- throw Error('[Varlet] BackTop: type of prop "target" should be a selector or an element object');
99
- };
100
-
101
81
  onMounted(() => {
102
- target = props.target ? getTarget() : getParentScroller(backTopEl.value);
82
+ target = props.target ? getTarget(props.target, 'BackTop') : getParentScroller(backTopEl.value);
103
83
  target.addEventListener('scroll', throttleScroll);
104
84
  disabled.value = false;
105
85
  });
@@ -4,7 +4,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
4
4
 
5
5
  import VarIcon from '../icon';
6
6
  import { defineComponent, ref, computed, watch, onMounted } from 'vue';
7
- import { getParentScroller, getScrollTop } from '../utils/elements';
7
+ import { getParentScroller, getScrollTop, getTarget } from '../utils/elements';
8
8
  import { props } from './props';
9
9
  import { toNumber } from '@varlet/shared';
10
10
  import { call, createNamespace } from '../utils/components';
@@ -165,7 +165,7 @@ export default defineComponent({
165
165
  }
166
166
  });
167
167
  onMounted(() => {
168
- scroller = getParentScroller(freshNode.value);
168
+ scroller = props.target ? getTarget(props.target, 'PullRefresh') : getParentScroller(freshNode.value);
169
169
  setPosition();
170
170
  });
171
171
  return {
@@ -34,6 +34,9 @@ export var props = {
34
34
  successColor: {
35
35
  type: String
36
36
  },
37
+ target: {
38
+ type: [String, Object]
39
+ },
37
40
  onRefresh: defineListenerProp(),
38
41
  'onUpdate:modelValue': defineListenerProp()
39
42
  };
@@ -1,8 +1,8 @@
1
1
  import '../../styles/common.css'
2
- import '../SnackbarSfc.css'
3
2
  import '../../styles/elevation.css'
4
3
  import '../../loading/loading.css'
5
4
  import '../../button/button.css'
6
5
  import '../../icon/icon.css'
7
6
  import '../snackbar.css'
8
7
  import '../coreSfc.css'
8
+ import '../SnackbarSfc.css'
@@ -368,7 +368,7 @@ export default defineComponent({
368
368
  }
369
369
 
370
370
  if (onBeforeRemove) {
371
- var results = call(onBeforeRemove);
371
+ var results = call(onBeforeRemove, reactive(removedVarFile));
372
372
  results = isArray(results) ? results : [results];
373
373
 
374
374
  if ((yield Promise.all(results)).some(result => !result)) {
@@ -377,7 +377,7 @@ export default defineComponent({
377
377
  }
378
378
 
379
379
  var expectedFiles = modelValue.filter(varFile => varFile !== removedVarFile);
380
- call(onRemove, removedVarFile);
380
+ call(onRemove, reactive(removedVarFile));
381
381
  validateWithTrigger('onRemove');
382
382
  call(props['onUpdate:modelValue'], expectedFiles);
383
383
  });
@@ -2,7 +2,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
2
2
 
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
- import { isNumber, isString, kebabCase, toNumber } from '@varlet/shared';
5
+ import { isNumber, isObject, isString, kebabCase, toNumber } from '@varlet/shared';
6
6
  import { getGlobalThis } from './shared';
7
7
  export function getLeft(element) {
8
8
  var {
@@ -92,6 +92,20 @@ export function getAllParentScroller(el) {
92
92
  }
93
93
 
94
94
  return allParentScroller;
95
+ }
96
+ export function getTarget(target, componentName) {
97
+ if (isString(target)) {
98
+ var el = document.querySelector(target);
99
+
100
+ if (!el) {
101
+ throw Error("[Varlet] " + componentName + ": target element cannot found");
102
+ }
103
+
104
+ return el;
105
+ }
106
+
107
+ if (isObject(target)) return target;
108
+ throw Error("[Varlet] " + componentName + ": type of prop \"target\" should be a selector or an element object");
95
109
  } // example 1rem
96
110
 
97
111
  export var isRem = value => isString(value) && value.endsWith('rem'); // e.g. 1 || 1px