@varlet/ui 2.11.1 → 2.11.2

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/lib/varlet.cjs.js CHANGED
@@ -2405,7 +2405,7 @@ var {
2405
2405
  classes: classes$10
2406
2406
  } = createNamespace("avatar");
2407
2407
  var _hoisted_1$r = ["src", "lazy-loading", "lazy-error"];
2408
- var _hoisted_2$d = ["src"];
2408
+ var _hoisted_2$e = ["src"];
2409
2409
  function __render__$1d(_ctx, _cache) {
2410
2410
  var _directive_lazy = vue.resolveDirective("lazy");
2411
2411
  return vue.openBlock(), vue.createElementBlock(
@@ -2464,7 +2464,7 @@ function __render__$1d(_ctx, _cache) {
2464
2464
  },
2465
2465
  null,
2466
2466
  46,
2467
- _hoisted_2$d
2467
+ _hoisted_2$e
2468
2468
  ))],
2469
2469
  64
2470
2470
  /* STABLE_FRAGMENT */
@@ -2653,7 +2653,7 @@ var _hoisted_1$q = /* @__PURE__ */ _withScopeId$6(() => /* @__PURE__ */ vue.crea
2653
2653
  -1
2654
2654
  /* HOISTED */
2655
2655
  ));
2656
- var _hoisted_2$c = [_hoisted_1$q];
2656
+ var _hoisted_2$d = [_hoisted_1$q];
2657
2657
  function __render__$1b(_ctx, _cache) {
2658
2658
  return vue.openBlock(), vue.createElementBlock(
2659
2659
  "div",
@@ -2700,7 +2700,7 @@ function __render__$1b(_ctx, _cache) {
2700
2700
  color: _ctx.color
2701
2701
  })
2702
2702
  },
2703
- _hoisted_2$c,
2703
+ _hoisted_2$d,
2704
2704
  6
2705
2705
  /* CLASS, STYLE */
2706
2706
  )],
@@ -4745,7 +4745,7 @@ var {
4745
4745
  var _hoisted_1$n = {
4746
4746
  key: 0
4747
4747
  };
4748
- var _hoisted_2$b = {
4748
+ var _hoisted_2$c = {
4749
4749
  key: 0
4750
4750
  };
4751
4751
  function __render__$$(_ctx, _cache) {
@@ -4800,7 +4800,7 @@ function __render__$$(_ctx, _cache) {
4800
4800
  {
4801
4801
  default: vue.withCtx(() => [_ctx.extraMessage ? (vue.openBlock(), vue.createElementBlock(
4802
4802
  "div",
4803
- _hoisted_2$b,
4803
+ _hoisted_2$c,
4804
4804
  vue.toDisplayString(_ctx.extraMessage),
4805
4805
  1
4806
4806
  /* TEXT */
@@ -13914,7 +13914,7 @@ var {
13914
13914
  classes: classes$A
13915
13915
  } = createNamespace("image");
13916
13916
  var _hoisted_1$j = ["alt", "title", "lazy-error", "lazy-loading"];
13917
- var _hoisted_2$a = ["alt", "title", "src"];
13917
+ var _hoisted_2$b = ["alt", "title", "src"];
13918
13918
  function __render__$I(_ctx, _cache) {
13919
13919
  var _directive_lazy = vue.resolveDirective("lazy");
13920
13920
  var _directive_ripple = vue.resolveDirective("ripple");
@@ -13976,7 +13976,7 @@ function __render__$I(_ctx, _cache) {
13976
13976
  },
13977
13977
  null,
13978
13978
  46,
13979
- _hoisted_2$a
13979
+ _hoisted_2$b
13980
13980
  ))],
13981
13981
  6
13982
13982
  /* CLASS, STYLE */
@@ -14587,6 +14587,10 @@ var props$C = _extends$7({
14587
14587
  type: Boolean,
14588
14588
  default: false
14589
14589
  },
14590
+ imagePreventDefault: {
14591
+ type: Boolean,
14592
+ default: false
14593
+ },
14590
14594
  images: {
14591
14595
  type: Array,
14592
14596
  default: () => []
@@ -14602,7 +14606,8 @@ var props$C = _extends$7({
14602
14606
  type: Boolean,
14603
14607
  default: false
14604
14608
  },
14605
- "onUpdate:show": defineListenerProp()
14609
+ "onUpdate:show": defineListenerProp(),
14610
+ onLongPress: defineListenerProp()
14606
14611
  }, pickProps(props$D, ["loop", "indicator", "onChange"]), pickProps(props$1a, [
14607
14612
  "lockScroll",
14608
14613
  "teleport",
@@ -14621,7 +14626,9 @@ var DISTANCE_OFFSET = 12;
14621
14626
  var EVENT_DELAY = 200;
14622
14627
  var TAP_DELAY = 350;
14623
14628
  var ANIMATION_DURATION = 200;
14624
- var _hoisted_1$h = ["src", "alt"];
14629
+ var LONG_PRESS_DELAY = 500;
14630
+ var _hoisted_1$h = ["onTouchstart"];
14631
+ var _hoisted_2$a = ["src", "alt"];
14625
14632
  function __render__$F(_ctx, _cache) {
14626
14633
  var _component_var_swipe_item = vue.resolveComponent("var-swipe-item");
14627
14634
  var _component_var_swipe = vue.resolveComponent("var-swipe");
@@ -14660,7 +14667,7 @@ function __render__$F(_ctx, _cache) {
14660
14667
  default: vue.withCtx(() => [(vue.openBlock(true), vue.createElementBlock(
14661
14668
  vue.Fragment,
14662
14669
  null,
14663
- vue.renderList(_ctx.images, (image2) => {
14670
+ vue.renderList(_ctx.images, (image2, idx) => {
14664
14671
  return vue.openBlock(), vue.createBlock(
14665
14672
  _component_var_swipe_item,
14666
14673
  {
@@ -14678,29 +14685,30 @@ function __render__$F(_ctx, _cache) {
14678
14685
  transitionTimingFunction: _ctx.transitionTimingFunction,
14679
14686
  transitionDuration: _ctx.transitionDuration
14680
14687
  }),
14681
- onTouchstart: _cache[0] || (_cache[0] = function() {
14682
- return _ctx.handleTouchstart && _ctx.handleTouchstart(...arguments);
14683
- }),
14684
- onTouchmove: _cache[1] || (_cache[1] = function() {
14688
+ onTouchstart: ($event) => _ctx.handleTouchstart($event, idx),
14689
+ onTouchmove: _cache[0] || (_cache[0] = function() {
14685
14690
  return _ctx.handleTouchmove && _ctx.handleTouchmove(...arguments);
14686
14691
  }),
14687
- onTouchend: _cache[2] || (_cache[2] = function() {
14692
+ onTouchend: _cache[1] || (_cache[1] = function() {
14688
14693
  return _ctx.handleTouchend && _ctx.handleTouchend(...arguments);
14694
+ }),
14695
+ onTouchcancel: _cache[2] || (_cache[2] = function() {
14696
+ return _ctx.handleTouchcancel && _ctx.handleTouchcancel(...arguments);
14689
14697
  })
14690
14698
  },
14691
14699
  [vue.createElementVNode(
14692
14700
  "img",
14693
14701
  {
14694
- class: vue.normalizeClass(_ctx.n("image")),
14702
+ class: vue.normalizeClass(_ctx.classes(_ctx.n("image"), [_ctx.isPreventDefault, _ctx.n("--prevent")])),
14695
14703
  src: image2,
14696
14704
  alt: image2
14697
14705
  },
14698
14706
  null,
14699
14707
  10,
14700
- _hoisted_1$h
14708
+ _hoisted_2$a
14701
14709
  )],
14702
- 38
14703
- /* CLASS, STYLE, HYDRATE_EVENTS */
14710
+ 46,
14711
+ _hoisted_1$h
14704
14712
  )]),
14705
14713
  _: 2
14706
14714
  /* DYNAMIC */
@@ -14793,6 +14801,15 @@ var __sfc__$G = vue.defineComponent({
14793
14801
  var startTouch = null;
14794
14802
  var prevTouch = null;
14795
14803
  var closeRunner = null;
14804
+ var longPressRunner = null;
14805
+ var isLongPress = false;
14806
+ var isPreventDefault = vue.computed(() => {
14807
+ var {
14808
+ imagePreventDefault,
14809
+ show
14810
+ } = props2;
14811
+ return show && imagePreventDefault;
14812
+ });
14796
14813
  var getDistance = (touch, target) => {
14797
14814
  var {
14798
14815
  clientX: touchX,
@@ -14840,17 +14857,35 @@ var __sfc__$G = vue.defineComponent({
14840
14857
  }
14841
14858
  return getDistance(startTouch, prevTouch) <= DISTANCE_OFFSET && performance.now() - prevTouch.timestamp < TAP_DELAY && (target === startTouch.target || target.parentNode === startTouch.target);
14842
14859
  };
14860
+ var handleTouchcancel = () => {
14861
+ window.clearTimeout(longPressRunner);
14862
+ isLongPress = false;
14863
+ startTouch = null;
14864
+ };
14843
14865
  var handleTouchend = (event) => {
14866
+ window.clearTimeout(longPressRunner);
14867
+ if (isLongPress) {
14868
+ isLongPress = false;
14869
+ return;
14870
+ }
14844
14871
  var isTap = isTapTouch(event.target);
14845
14872
  closeRunner = window.setTimeout(() => {
14846
14873
  isTap && close();
14847
14874
  startTouch = null;
14848
14875
  }, EVENT_DELAY);
14849
14876
  };
14850
- var handleTouchstart = (event) => {
14851
- closeRunner && window.clearTimeout(closeRunner);
14877
+ var handleTouchstart = (event, idx) => {
14878
+ window.clearTimeout(closeRunner);
14879
+ window.clearTimeout(longPressRunner);
14852
14880
  var currentTouch = createVarTouch(event.touches[0], event.currentTarget);
14853
14881
  startTouch = currentTouch;
14882
+ longPressRunner = window.setTimeout(() => {
14883
+ var {
14884
+ onLongPress
14885
+ } = props2;
14886
+ isLongPress = true;
14887
+ call(onLongPress, idx);
14888
+ }, LONG_PRESS_DELAY);
14854
14889
  if (isDoubleTouch(currentTouch)) {
14855
14890
  scale.value > 1 ? zoomOut() : zoomIn();
14856
14891
  return;
@@ -14917,6 +14952,9 @@ var __sfc__$G = vue.defineComponent({
14917
14952
  }
14918
14953
  var target = event.currentTarget;
14919
14954
  var currentTouch = createVarTouch(event.touches[0], target);
14955
+ if (getDistance(currentTouch, prevTouch) > DISTANCE_OFFSET) {
14956
+ window.clearTimeout(longPressRunner);
14957
+ }
14920
14958
  if (scale.value > 1) {
14921
14959
  var moveX = currentTouch.clientX - prevTouch.clientX;
14922
14960
  var moveY = currentTouch.clientY - prevTouch.clientY;
@@ -14935,14 +14973,19 @@ var __sfc__$G = vue.defineComponent({
14935
14973
  }
14936
14974
  call(props2["onUpdate:show"], false);
14937
14975
  };
14938
- vue.watch(() => props2.show, (newValue) => {
14939
- popupShow.value = newValue;
14976
+ var preventImageDefault = (event) => {
14977
+ props2.imagePreventDefault && props2.show && event.preventDefault();
14978
+ };
14979
+ useEventListener(() => document, "contextmenu", preventImageDefault);
14980
+ vue.watch(() => props2.show, (newShow) => {
14981
+ popupShow.value = newShow;
14940
14982
  }, {
14941
14983
  immediate: true
14942
14984
  });
14943
14985
  return {
14944
14986
  n: n$E,
14945
14987
  classes: classes$y,
14988
+ isPreventDefault,
14946
14989
  initialIndex,
14947
14990
  popupShow,
14948
14991
  scale,
@@ -14954,6 +14997,7 @@ var __sfc__$G = vue.defineComponent({
14954
14997
  handleTouchstart,
14955
14998
  handleTouchmove,
14956
14999
  handleTouchend,
15000
+ handleTouchcancel,
14957
15001
  close
14958
15002
  };
14959
15003
  }
@@ -18643,6 +18687,7 @@ var {
18643
18687
  n: n$p,
18644
18688
  classes: classes$k
18645
18689
  } = createNamespace("progress");
18690
+ var ONE_HUNDRED = 100;
18646
18691
  var _hoisted_1$b = ["viewBox"];
18647
18692
  var _hoisted_2$7 = ["cx", "cy", "r", "stroke-width"];
18648
18693
  var _hoisted_3$6 = ["cx", "cy", "r", "stroke-width"];
@@ -18793,8 +18838,8 @@ var __sfc__$t = vue.defineComponent({
18793
18838
  setup(props2) {
18794
18839
  var linearProps = vue.computed(() => {
18795
18840
  var value = toNumber(props2.value);
18796
- var width = value > 100 ? 100 : value;
18797
- var roundValue = value > 100 ? 100 : Math.round(value);
18841
+ var width = value > ONE_HUNDRED ? ONE_HUNDRED : value;
18842
+ var roundValue = value > ONE_HUNDRED ? ONE_HUNDRED : Math.round(value);
18798
18843
  return {
18799
18844
  width: width + "%",
18800
18845
  roundValue: roundValue + "%"
@@ -18807,10 +18852,10 @@ var __sfc__$t = vue.defineComponent({
18807
18852
  value
18808
18853
  } = props2;
18809
18854
  var viewBox = "0 0 " + toPxNum(size) + " " + toPxNum(size);
18810
- var roundValue = toNumber(value) > 100 ? 100 : Math.round(toNumber(value));
18855
+ var roundValue = toNumber(value) > ONE_HUNDRED ? ONE_HUNDRED : Math.round(toNumber(value));
18811
18856
  var radius = (toPxNum(size) - toPxNum(lineWidth)) / 2;
18812
18857
  var perimeter = 2 * Math.PI * radius;
18813
- var strokeDasharray = roundValue / 100 * perimeter + ", " + perimeter;
18858
+ var strokeDasharray = roundValue / ONE_HUNDRED * perimeter + ", " + perimeter;
18814
18859
  return {
18815
18860
  viewBox,
18816
18861
  radius,
@@ -23043,20 +23088,23 @@ var __sfc__$6 = vue.defineComponent({
23043
23088
  },
23044
23089
  props: props$5,
23045
23090
  setup(props2) {
23091
+ var current = vue.ref(false);
23092
+ var name = vue.computed(() => props2.name);
23046
23093
  var {
23047
23094
  index,
23048
- tabsItems,
23049
23095
  bindTabsItems
23050
23096
  } = useTabsItems();
23051
23097
  var {
23052
23098
  bindLists
23053
23099
  } = useLists();
23054
- var name = vue.computed(() => props2.name);
23055
- var current = vue.computed(() => index.value === Number(tabsItems.active.value));
23100
+ var setCurrent = (value) => {
23101
+ current.value = value;
23102
+ };
23056
23103
  var tabItemProvider = {
23057
23104
  index,
23058
23105
  name,
23059
- current
23106
+ current: vue.computed(() => current.value),
23107
+ setCurrent
23060
23108
  };
23061
23109
  bindTabsItems(tabItemProvider);
23062
23110
  bindLists(tabItemProvider);
@@ -23560,30 +23608,29 @@ var __sfc__$3 = vue.defineComponent({
23560
23608
  props: props$2,
23561
23609
  setup(props2) {
23562
23610
  var swipe2 = vue.ref(null);
23563
- var active = vue.computed(() => props2.active);
23564
23611
  var {
23565
23612
  tabItemList,
23566
23613
  bindTabItem,
23567
23614
  length
23568
23615
  } = useTabItem$1();
23569
- var matchName = (active2) => {
23616
+ var matchName = (active) => {
23570
23617
  return tabItemList.find((_ref) => {
23571
23618
  var {
23572
23619
  name
23573
23620
  } = _ref;
23574
- return active2 === name.value;
23621
+ return active === name.value;
23575
23622
  });
23576
23623
  };
23577
- var matchIndex = (active2) => {
23624
+ var matchIndex = (active) => {
23578
23625
  return tabItemList.find((_ref2) => {
23579
23626
  var {
23580
23627
  index
23581
23628
  } = _ref2;
23582
- return active2 === index.value;
23629
+ return active === index.value;
23583
23630
  });
23584
23631
  };
23585
- var matchActive = (active2) => {
23586
- return matchName(active2) || matchIndex(active2);
23632
+ var matchActive = (active) => {
23633
+ return matchName(active) || matchIndex(active);
23587
23634
  };
23588
23635
  var handleActiveChange = (newValue) => {
23589
23636
  var _swipe$value;
@@ -23591,26 +23638,30 @@ var __sfc__$3 = vue.defineComponent({
23591
23638
  if (!newActiveTabItemProvider) {
23592
23639
  return;
23593
23640
  }
23641
+ tabItemList.forEach((_ref3) => {
23642
+ var {
23643
+ setCurrent
23644
+ } = _ref3;
23645
+ return setCurrent(false);
23646
+ });
23647
+ newActiveTabItemProvider.setCurrent(true);
23594
23648
  (_swipe$value = swipe2.value) == null ? void 0 : _swipe$value.to(newActiveTabItemProvider.index.value);
23595
23649
  };
23596
23650
  var handleSwipeChange = (currentIndex) => {
23597
23651
  var _tabItem$name$value;
23598
- var tabItem2 = tabItemList.find((_ref3) => {
23652
+ var tabItem2 = tabItemList.find((_ref4) => {
23599
23653
  var {
23600
23654
  index
23601
- } = _ref3;
23655
+ } = _ref4;
23602
23656
  return index.value === currentIndex;
23603
23657
  });
23604
- var active2 = (_tabItem$name$value = tabItem2.name.value) != null ? _tabItem$name$value : tabItem2.index.value;
23605
- call(props2["onUpdate:active"], active2);
23658
+ var active = (_tabItem$name$value = tabItem2.name.value) != null ? _tabItem$name$value : tabItem2.index.value;
23659
+ call(props2["onUpdate:active"], active);
23606
23660
  };
23607
23661
  var getSwipe = () => {
23608
23662
  return swipe2.value;
23609
23663
  };
23610
- var tabsItemsProvider = {
23611
- active
23612
- };
23613
- bindTabItem(tabsItemsProvider);
23664
+ bindTabItem({});
23614
23665
  vue.watch(() => props2.active, handleActiveChange);
23615
23666
  vue.watch(() => length.value, /* @__PURE__ */ _asyncToGenerator$1(function* () {
23616
23667
  yield doubleRaf();
@@ -25497,7 +25548,7 @@ const TimePickerSfc = "";
25497
25548
  const TooltipSfc = "";
25498
25549
  const uploader = "";
25499
25550
  const UploaderSfc = "";
25500
- const version = "2.11.1";
25551
+ const version = "2.11.2";
25501
25552
  function install(app) {
25502
25553
  ActionSheet.install && app.use(ActionSheet);
25503
25554
  AppBar.install && app.use(AppBar);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/ui",
3
- "version": "2.11.1",
3
+ "version": "2.11.2",
4
4
  "description": "A material like components library",
5
5
  "main": "lib/varlet.cjs.js",
6
6
  "module": "es/index.mjs",
@@ -46,9 +46,9 @@
46
46
  "@popperjs/core": "^2.11.6",
47
47
  "dayjs": "^1.10.4",
48
48
  "decimal.js": "^10.2.1",
49
- "@varlet/icons": "2.11.1",
50
- "@varlet/shared": "2.11.1",
51
- "@varlet/use": "2.11.1"
49
+ "@varlet/icons": "2.11.2",
50
+ "@varlet/shared": "2.11.2",
51
+ "@varlet/use": "2.11.2"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@vue/runtime-core": "3.3.1",
@@ -63,8 +63,8 @@
63
63
  "typescript": "^4.4.4",
64
64
  "vue": "3.3.2",
65
65
  "vue-router": "4.2.0",
66
- "@varlet/cli": "2.11.1",
67
- "@varlet/touch-emulator": "2.11.1"
66
+ "@varlet/cli": "2.11.2",
67
+ "@varlet/touch-emulator": "2.11.2"
68
68
  },
69
69
  "browserslist": [
70
70
  "Chrome >= 54",
@@ -12,11 +12,13 @@ export interface ImagePreviewProps extends BasicAttributes {
12
12
  indicator?: boolean
13
13
  closeable?: boolean
14
14
  teleport?: TeleportProps['to']
15
+ imagePreventDefault?: boolean
15
16
  onOpen?: ListenerProp<() => void>
16
17
  onOpened?: ListenerProp<() => void>
17
18
  onClose?: ListenerProp<() => void>
18
19
  onClosed?: ListenerProp<() => void>
19
20
  onChange?: ListenerProp<(index: number) => void>
21
+ onLongPress?: ListenerProp<(index: number) => void>
20
22
  'onUpdate:show'?: ListenerProp<(show: boolean) => void>
21
23
  }
22
24
 
@@ -27,11 +29,13 @@ export interface ImagePreviewOptions {
27
29
  lockScroll?: boolean
28
30
  indicator?: boolean
29
31
  closeable?: boolean
32
+ imagePreventDefault?: boolean
30
33
  onOpen?: () => void
31
34
  onOpened?: () => void
32
35
  onClose?: () => void
33
36
  onClosed?: () => void
34
37
  onChange?: (index: number) => void
38
+ onLongPress?: (index: number) => void
35
39
  }
36
40
 
37
41
  export class ImagePreviewComponent extends VarComponent {