@varlet/ui 2.13.2 → 2.13.4-alpha.1690279122540

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/drag/Drag.mjs CHANGED
@@ -54,13 +54,16 @@ var __sfc__ = defineComponent({
54
54
  });
55
55
  var dragged = ref(false);
56
56
  var enableTransition = ref(false);
57
+ var dragging = ref(false);
57
58
  var touching = false;
58
59
  var prevX = 0;
59
60
  var prevY = 0;
61
+ var draggingRunner = null;
60
62
  var handleTouchstart = event => {
61
63
  if (props.disabled) {
62
64
  return;
63
65
  }
66
+ draggingRunner && window.clearTimeout(draggingRunner);
64
67
  var {
65
68
  clientX,
66
69
  clientY
@@ -69,6 +72,7 @@ var __sfc__ = defineComponent({
69
72
  prevX = clientX;
70
73
  prevY = clientY;
71
74
  touching = true;
75
+ dragging.value = false;
72
76
  };
73
77
  var handleTouchmove = /*#__PURE__*/function () {
74
78
  var _ref2 = _asyncToGenerator(function* (event) {
@@ -78,6 +82,7 @@ var __sfc__ = defineComponent({
78
82
  event.preventDefault();
79
83
  enableTransition.value = false;
80
84
  dragged.value = true;
85
+ dragging.value = true;
81
86
  var {
82
87
  clientX,
83
88
  clientY
@@ -105,6 +110,9 @@ var __sfc__ = defineComponent({
105
110
  touching = false;
106
111
  enableTransition.value = true;
107
112
  attract();
113
+ draggingRunner = window.setTimeout(() => {
114
+ dragging.value = false;
115
+ });
108
116
  };
109
117
  var saveXY = () => {
110
118
  var {
@@ -237,8 +245,12 @@ var __sfc__ = defineComponent({
237
245
  var reset = () => {
238
246
  enableTransition.value = false;
239
247
  dragged.value = false;
248
+ dragging.value = false;
240
249
  x.value = 0;
241
250
  y.value = 0;
251
+ touching = false;
252
+ prevX = 0;
253
+ prevY = 0;
242
254
  };
243
255
  watch(() => props.boundary, toPxBoundary);
244
256
  onWindowResize(resize);
@@ -251,6 +263,7 @@ var __sfc__ = defineComponent({
251
263
  x,
252
264
  y,
253
265
  enableTransition,
266
+ dragging,
254
267
  n,
255
268
  classes,
256
269
  getAttrs,
package/es/fab/Fab.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import { mergeProps as _mergeProps, isVNode as _isVNode, withDirectives as _withDirectives, vShow as _vShow, createVNode as _createVNode } from "vue";
2
2
  import Button from '../button/index.mjs';
3
3
  import Icon from '../icon/index.mjs';
4
- import { defineComponent, ref, Teleport, Transition, watch } from 'vue';
4
+ import Drag from '../drag/index.mjs';
5
+ import { defineComponent, ref, Transition, watch } from 'vue';
5
6
  import { useClickOutside } from '@varlet/use';
6
- import { call, createNamespace, flatFragment, useTeleport, useVModel } from '../utils/components.mjs';
7
+ import { call, createNamespace, flatFragment, useVModel } from '../utils/components.mjs';
7
8
  import { toSizeUnit } from '../utils/elements.mjs';
8
- import { toNumber } from '@varlet/shared';
9
9
  import { props } from './props.mjs';
10
10
 
11
11
 
@@ -14,6 +14,7 @@ import { props } from './props.mjs';
14
14
 
15
15
 
16
16
 
17
+
17
18
  function _isSlot(s) {
18
19
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !_isVNode(s);
19
20
  }
@@ -32,10 +33,9 @@ export default defineComponent({
32
33
  } = _ref;
33
34
  var isActive = useVModel(props, 'active');
34
35
  var host = ref(null);
35
- var {
36
- disabled
37
- } = useTeleport();
36
+ var dragRef = ref(null);
38
37
  var handleClick = (e, value, childrenLength) => {
38
+ var _dragRef$value;
39
39
  e.stopPropagation();
40
40
  if (props.trigger !== 'click' || props.disabled) {
41
41
  return;
@@ -44,6 +44,11 @@ export default defineComponent({
44
44
  call(props.onClick, isActive.value, e);
45
45
  return;
46
46
  }
47
+
48
+ // avoid trigger open function after dragging
49
+ if ((_dragRef$value = dragRef.value) != null && _dragRef$value.dragging) {
50
+ return;
51
+ }
47
52
  isActive.value = value;
48
53
  call(props.onClick, isActive.value, e);
49
54
  call(isActive.value ? props.onOpen : props.onClose);
@@ -76,8 +81,8 @@ export default defineComponent({
76
81
  "type": props.type,
77
82
  "color": props.color,
78
83
  "disabled": props.disabled,
79
- "round": true,
80
- "elevation": props.elevation
84
+ "elevation": props.elevation,
85
+ "round": true
81
86
  }, {
82
87
  default: () => [_createVNode(Icon, {
83
88
  "var-fab-cover": true,
@@ -89,61 +94,57 @@ export default defineComponent({
89
94
  }, null)]
90
95
  }), [[_vShow, props.show]]);
91
96
  };
92
- var renderFab = () => {
97
+ watch(() => props.trigger, () => {
98
+ isActive.value = false;
99
+ });
100
+ watch(() => props.disabled, () => {
101
+ isActive.value = false;
102
+ });
103
+ watch(() => [props.position, props.fixed, props.top, props.bottom, props.left, props.right], () => {
104
+ var _dragRef$value2;
105
+ (_dragRef$value2 = dragRef.value) == null ? void 0 : _dragRef$value2.reset();
106
+ });
107
+ useClickOutside(host, 'click', handleClickOutside);
108
+ return () => {
93
109
  var _slot;
94
110
  var _call;
95
111
  var children = flatFragment((_call = call(slots.default)) != null ? _call : []);
96
- return _createVNode("div", _mergeProps({
97
- "class": classes(n(), n("--position-" + props.position), n("--direction-" + props.direction), [props.fixed, n('--fixed'), n('--absolute')], [props.safeArea, n('--safe-area')]),
112
+ return _createVNode(Drag, _mergeProps({
113
+ "ref": dragRef,
114
+ "class": classes(n("--position-" + props.position), [!props.fixed, n('--absolute')]),
98
115
  "style": {
99
- zIndex: toNumber(props.zIndex),
100
116
  top: toSizeUnit(props.top),
101
117
  bottom: toSizeUnit(props.bottom),
102
118
  left: toSizeUnit(props.left),
103
119
  right: toSizeUnit(props.right)
104
120
  },
105
- "ref": host,
106
- "onClick": e => handleClick(e, !isActive.value, children.length),
107
- "onMouseleave": () => handleMouse(false, children.length),
108
- "onMouseenter": () => handleMouse(true, children.length)
109
- }, attrs), [_createVNode(Transition, {
110
- "name": n("--active-transition")
111
- }, _isSlot(_slot = renderTrigger()) ? _slot : {
112
- default: () => [_slot]
113
- }), _createVNode(Transition, {
114
- "name": n("--actions-transition-" + props.direction),
115
- "onAfterEnter": props.onOpened,
116
- "onAfterLeave": props.onClosed
117
- }, {
118
- default: () => [_withDirectives(_createVNode("div", {
119
- "class": n('actions'),
120
- "onClick": e => e.stopPropagation()
121
- }, [children.map(child => _createVNode("div", {
122
- "class": n('action')
123
- }, [child]))]), [[_vShow, props.show && isActive.value && children.length]])]
124
- })]);
125
- };
126
- watch(() => props.trigger, () => {
127
- isActive.value = false;
128
- });
129
- watch(() => props.disabled, () => {
130
- isActive.value = false;
131
- });
132
- useClickOutside(host, 'click', handleClickOutside);
133
- return () => {
134
- var {
135
- teleport
136
- } = props;
137
- if (teleport) {
138
- var _slot2;
139
- return _createVNode(Teleport, {
140
- "to": teleport,
141
- "disabled": disabled.value
142
- }, _isSlot(_slot2 = renderFab()) ? _slot2 : {
143
- default: () => [_slot2]
144
- });
145
- }
146
- return renderFab();
121
+ "zIndex": props.zIndex,
122
+ "teleport": props.teleport,
123
+ "disabled": props.disabled || !props.drag || !props.fixed
124
+ }, attrs), {
125
+ default: () => [_createVNode("div", {
126
+ "class": classes(n(), n("--direction-" + props.direction), [props.safeArea, n('--safe-area')]),
127
+ "ref": host,
128
+ "onClick": e => handleClick(e, !isActive.value, children.length),
129
+ "onMouseleave": () => handleMouse(false, children.length),
130
+ "onMouseenter": () => handleMouse(true, children.length)
131
+ }, [_createVNode(Transition, {
132
+ "name": n("--active-transition")
133
+ }, _isSlot(_slot = renderTrigger()) ? _slot : {
134
+ default: () => [_slot]
135
+ }), _createVNode(Transition, {
136
+ "name": n("--actions-transition-" + props.direction),
137
+ "onAfterEnter": props.onOpened,
138
+ "onAfterLeave": props.onClosed
139
+ }, {
140
+ default: () => [_withDirectives(_createVNode("div", {
141
+ "class": n('actions'),
142
+ "onClick": e => e.stopPropagation()
143
+ }, [children.map(child => _createVNode("div", {
144
+ "class": n('action')
145
+ }, [child]))]), [[_vShow, props.show && isActive.value && children.length]])]
146
+ })])]
147
+ });
147
148
  };
148
149
  }
149
150
  });
package/es/fab/props.mjs CHANGED
@@ -18,6 +18,10 @@ export var props = {
18
18
  type: Boolean,
19
19
  default: true
20
20
  },
21
+ drag: {
22
+ type: Boolean,
23
+ default: false
24
+ },
21
25
  type: {
22
26
  type: String,
23
27
  default: 'primary',
@@ -88,7 +92,7 @@ export var props = {
88
92
  default: false
89
93
  },
90
94
  teleport: {
91
- type: String
95
+ type: [String, Object]
92
96
  },
93
97
  onClick: defineListenerProp(),
94
98
  onOpen: defineListenerProp(),
@@ -4,4 +4,5 @@ import '../../ripple/ripple.css'
4
4
  import '../../icon/icon.css'
5
5
  import '../../loading/loading.css'
6
6
  import '../../button/button.css'
7
+ import '../../drag/drag.css'
7
8
  import '../fab.css'
@@ -244,7 +244,7 @@ import './time-picker/style/index.mjs'
244
244
  import './tooltip/style/index.mjs'
245
245
  import './uploader/style/index.mjs'
246
246
 
247
- const version = '2.13.2'
247
+ const version = '2.13.4-alpha.1690279122540'
248
248
 
249
249
  function install(app) {
250
250
  ActionSheet.install && app.use(ActionSheet)
package/es/index.mjs CHANGED
@@ -162,7 +162,7 @@ export * from './time-picker/index.mjs'
162
162
  export * from './tooltip/index.mjs'
163
163
  export * from './uploader/index.mjs'
164
164
 
165
- const version = '2.13.2'
165
+ const version = '2.13.4-alpha.1690279122540'
166
166
 
167
167
  function install(app) {
168
168
  ActionSheet.install && app.use(ActionSheet)
@@ -1,12 +1,12 @@
1
+ import VarFormDetails from '../form-details/index.mjs';
2
+ import Ripple from '../ripple/index.mjs';
3
+ import VarHoverOverlay, { useHoverOverlay } from '../hover-overlay/index.mjs';
4
+ import Hover from '../hover/index.mjs';
1
5
  import { defineComponent, computed, nextTick } from 'vue';
2
6
  import { useValidation, createNamespace, call } from '../utils/components.mjs';
3
7
  import { multiplySizeUnit } from '../utils/elements.mjs';
4
8
  import { useForm } from '../form/provide.mjs';
5
- import VarHoverOverlay, { useHoverOverlay } from '../hover-overlay/index.mjs';
6
- import Hover from '../hover/index.mjs';
7
9
  import { props } from './props.mjs';
8
- import VarFormDetails from '../form-details/index.mjs';
9
- import Ripple from '../ripple/index.mjs';
10
10
  var {
11
11
  n,
12
12
  classes
@@ -48,8 +48,8 @@ function __render__(_ctx, _cache) {
48
48
  key: 0,
49
49
  class: _normalizeClass(_ctx.n('loading')),
50
50
  style: _normalizeStyle({
51
- width: _ctx.multiplySizeUnit(_ctx.radius, 2),
52
- height: _ctx.multiplySizeUnit(_ctx.radius, 2)
51
+ width: _ctx.radius,
52
+ height: _ctx.radius
53
53
  })
54
54
  }, _hoisted_2, 6 /* CLASS, STYLE */)) : _createCommentVNode("v-if", true)], 6 /* CLASS, STYLE */), _createVNode(_component_var_hover_overlay, {
55
55
  hovering: _ctx.hovering
@@ -122,7 +122,7 @@ var __sfc__ = defineComponent({
122
122
  }
123
123
  };
124
124
  });
125
- var radius = computed(() => multiplySizeUnit(props.size, 0.4));
125
+ var radius = computed(() => multiplySizeUnit(props.size, 0.8));
126
126
  var switchActive = event => {
127
127
  var {
128
128
  onClick,
@@ -213,7 +213,7 @@ export var multiplySizeUnit = function (value, quantity) {
213
213
  return undefined;
214
214
  }
215
215
  var legalSize = toSizeUnit(value);
216
- var unit = legalSize.match(/(vh|%|rem|px|vw|vmin|vmax)$/)[0];
216
+ var unit = legalSize.match(/(vh|%|r?em|px|vw|vmin|vmax)$/)[0];
217
217
  return "" + parseFloat(legalSize) * quantity + unit;
218
218
  };
219
219
  export function requestAnimationFrame(fn) {