@varlet/ui 2.15.0-alpha.1693213353380 → 2.15.0

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
@@ -58,9 +58,9 @@ var __sfc__ = defineComponent({
58
58
  });
59
59
  var dragged = ref(false);
60
60
  var enableTransition = ref(false);
61
- var dragging = ref(false);
62
61
  var {
63
62
  touching,
63
+ dragging,
64
64
  moveX,
65
65
  moveY,
66
66
  startTouch,
@@ -71,28 +71,22 @@ var __sfc__ = defineComponent({
71
71
  var {
72
72
  disabled: teleportDisabled
73
73
  } = useTeleport();
74
- var draggingRunner = null;
75
74
  var handleTouchstart = event => {
76
75
  if (props.disabled) {
77
76
  return;
78
77
  }
79
- if (draggingRunner) {
80
- window.clearTimeout(draggingRunner);
81
- }
82
- saveXY();
83
78
  startTouch(event);
84
- dragging.value = false;
79
+ saveXY();
85
80
  };
86
81
  var handleTouchmove = /*#__PURE__*/function () {
87
82
  var _ref2 = _asyncToGenerator(function* (event) {
88
83
  if (!touching.value || props.disabled) {
89
84
  return;
90
85
  }
86
+ moveTouch(event);
91
87
  event.preventDefault();
92
88
  enableTransition.value = false;
93
89
  dragged.value = true;
94
- dragging.value = true;
95
- moveTouch(event);
96
90
  if (props.direction.includes('x')) {
97
91
  x.value += moveX.value;
98
92
  }
@@ -112,9 +106,6 @@ var __sfc__ = defineComponent({
112
106
  endTouch();
113
107
  enableTransition.value = true;
114
108
  attract();
115
- draggingRunner = window.setTimeout(() => {
116
- dragging.value = false;
117
- });
118
109
  };
119
110
  var handleClick = event => {
120
111
  if (dragging.value) {
@@ -251,12 +242,11 @@ var __sfc__ = defineComponent({
251
242
 
252
243
  // expose
253
244
  var reset = () => {
245
+ resetTouch();
254
246
  enableTransition.value = false;
255
247
  dragged.value = false;
256
- dragging.value = false;
257
248
  x.value = 0;
258
249
  y.value = 0;
259
- resetTouch();
260
250
  };
261
251
  watch(() => props.boundary, toPxBoundary);
262
252
  onWindowResize(resize);
package/es/form/Form.mjs CHANGED
@@ -3,7 +3,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
3
3
  import { defineComponent, computed } from 'vue';
4
4
  import { props } from './props.mjs';
5
5
  import { useFormItems } from './provide.mjs';
6
- import { createNamespace } from '../utils/components.mjs';
6
+ import { call, createNamespace } from '../utils/components.mjs';
7
7
  import { find } from '@varlet/shared';
8
8
  import { getParentScroller, getTop, scrollTo, toPxNum } from '../utils/elements.mjs';
9
9
  import { linear } from '../utils/shared.mjs';
@@ -12,9 +12,15 @@ var {
12
12
  } = createNamespace('form');
13
13
  import { renderSlot as _renderSlot, normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
14
14
  function __render__(_ctx, _cache) {
15
- return _openBlock(), _createElementBlock("div", {
16
- class: _normalizeClass(_ctx.n())
17
- }, [_renderSlot(_ctx.$slots, "default")], 2 /* CLASS */);
15
+ return _openBlock(), _createElementBlock("form", {
16
+ class: _normalizeClass(_ctx.n()),
17
+ onSubmit: _cache[0] || (_cache[0] = function () {
18
+ return _ctx.handleSubmit && _ctx.handleSubmit(...arguments);
19
+ }),
20
+ onReset: _cache[1] || (_cache[1] = function () {
21
+ return _ctx.handleReset && _ctx.handleReset(...arguments);
22
+ })
23
+ }, [_renderSlot(_ctx.$slots, "default")], 34 /* CLASS, HYDRATE_EVENTS */);
18
24
  }
19
25
 
20
26
  var __sfc__ = defineComponent({
@@ -39,14 +45,29 @@ var __sfc__ = defineComponent({
39
45
  });
40
46
  }, 300);
41
47
  };
48
+ var handleSubmit = /*#__PURE__*/function () {
49
+ var _ref = _asyncToGenerator(function* (event) {
50
+ event.preventDefault();
51
+ var valid = yield validate();
52
+ call(props.onSubmit, valid);
53
+ });
54
+ return function handleSubmit(_x) {
55
+ return _ref.apply(this, arguments);
56
+ };
57
+ }();
58
+ var handleReset = event => {
59
+ event.preventDefault();
60
+ reset();
61
+ call(props.onReset);
62
+ };
42
63
 
43
64
  // expose
44
65
  var validate = /*#__PURE__*/function () {
45
- var _ref = _asyncToGenerator(function* () {
46
- var res = yield Promise.all(formItems.map(_ref2 => {
66
+ var _ref2 = _asyncToGenerator(function* () {
67
+ var res = yield Promise.all(formItems.map(_ref3 => {
47
68
  var {
48
69
  validate
49
- } = _ref2;
70
+ } = _ref3;
50
71
  return validate();
51
72
  }));
52
73
  if (props.scrollToError) {
@@ -62,23 +83,23 @@ var __sfc__ = defineComponent({
62
83
  return res.every(result => result === true);
63
84
  });
64
85
  return function validate() {
65
- return _ref.apply(this, arguments);
86
+ return _ref2.apply(this, arguments);
66
87
  };
67
88
  }();
68
89
 
69
90
  // expose
70
- var reset = () => formItems.forEach(_ref3 => {
91
+ var reset = () => formItems.forEach(_ref4 => {
71
92
  var {
72
93
  reset
73
- } = _ref3;
94
+ } = _ref4;
74
95
  return reset();
75
96
  });
76
97
 
77
98
  // expose
78
- var resetValidation = () => formItems.forEach(_ref4 => {
99
+ var resetValidation = () => formItems.forEach(_ref5 => {
79
100
  var {
80
101
  resetValidation
81
- } = _ref4;
102
+ } = _ref5;
82
103
  return resetValidation();
83
104
  });
84
105
  var formProvider = {
@@ -88,6 +109,8 @@ var __sfc__ = defineComponent({
88
109
  bindFormItems(formProvider);
89
110
  return {
90
111
  n,
112
+ handleSubmit,
113
+ handleReset,
91
114
  validate,
92
115
  reset,
93
116
  resetValidation
package/es/form/props.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { defineListenerProp } from '../utils/components.mjs';
1
2
  export var props = {
2
3
  disabled: Boolean,
3
4
  readonly: Boolean,
@@ -5,5 +6,7 @@ export var props = {
5
6
  scrollToErrorOffsetY: {
6
7
  type: [String, Number],
7
8
  default: 0
8
- }
9
+ },
10
+ onSubmit: defineListenerProp(),
11
+ onReset: defineListenerProp()
9
12
  };
@@ -247,7 +247,7 @@ import './tooltip/style/index.mjs'
247
247
  import './uploader/style/index.mjs'
248
248
  import './watermark/style/index.mjs'
249
249
 
250
- const version = '2.15.0-alpha.1693213353380'
250
+ const version = '2.15.0'
251
251
 
252
252
  function install(app) {
253
253
  ActionSheet.install && app.use(ActionSheet)
package/es/index.mjs CHANGED
@@ -164,7 +164,7 @@ export * from './tooltip/index.mjs'
164
164
  export * from './uploader/index.mjs'
165
165
  export * from './watermark/index.mjs'
166
166
 
167
- const version = '2.15.0-alpha.1693213353380'
167
+ const version = '2.15.0'
168
168
 
169
169
  function install(app) {
170
170
  ActionSheet.install && app.use(ActionSheet)
@@ -13,8 +13,8 @@ var {
13
13
  import { renderSlot as _renderSlot, normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, resolveComponent as _resolveComponent, normalizeProps as _normalizeProps, guardReactiveProps as _guardReactiveProps, withCtx as _withCtx, createSlots as _createSlots, createVNode as _createVNode, withModifiers as _withModifiers, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
14
14
  var _withScopeId = n => (_pushScopeId(""), n = n(), _popScopeId(), n);
15
15
  var _hoisted_1 = ["placeholder", "enterkeyhint"];
16
- var _hoisted_2 = ["id", "disabled", "type", "value", "placeholder", "maxlength", "rows", "enterkeyhint", "inputmode"];
17
- var _hoisted_3 = ["id", "disabled", "type", "value", "placeholder", "maxlength", "enterkeyhint", "inputmode"];
16
+ var _hoisted_2 = ["id", "disabled", "readonly", "type", "value", "placeholder", "maxlength", "rows", "enterkeyhint", "inputmode"];
17
+ var _hoisted_3 = ["id", "disabled", "readonly", "type", "value", "placeholder", "maxlength", "enterkeyhint", "inputmode"];
18
18
  function __render__(_ctx, _cache) {
19
19
  var _component_var_field_decorator = _resolveComponent("var-field-decorator");
20
20
  var _component_var_form_details = _resolveComponent("var-form-details");
@@ -60,7 +60,8 @@ function __render__(_ctx, _cache) {
60
60
  ref: "el",
61
61
  autocomplete: "new-password",
62
62
  id: _ctx.id,
63
- disabled: _ctx.formDisabled || _ctx.disabled || _ctx.formReadonly || _ctx.readonly,
63
+ disabled: _ctx.formDisabled || _ctx.disabled,
64
+ readonly: _ctx.formReadonly || _ctx.readonly,
64
65
  type: _ctx.normalizedType,
65
66
  value: _ctx.modelValue,
66
67
  placeholder: !_ctx.hint ? _ctx.placeholder : undefined,
@@ -98,7 +99,8 @@ function __render__(_ctx, _cache) {
98
99
  ref: "el",
99
100
  autocomplete: "new-password",
100
101
  id: _ctx.id,
101
- disabled: _ctx.formDisabled || _ctx.disabled || _ctx.formReadonly || _ctx.readonly,
102
+ disabled: _ctx.formDisabled || _ctx.disabled,
103
+ readonly: _ctx.formReadonly || _ctx.readonly,
102
104
  type: _ctx.normalizedType,
103
105
  value: _ctx.modelValue,
104
106
  placeholder: !_ctx.hint ? _ctx.placeholder : undefined,
@@ -2,9 +2,10 @@ import VarButton from '../button/index.mjs';
2
2
  import VarPopup from '../popup/index.mjs';
3
3
  import { defineComponent, watch, ref, computed, Transition, toRaw } from 'vue';
4
4
  import { props } from './props.mjs';
5
+ import { useTouch } from '@varlet/use';
5
6
  import { clamp, clampArrayRange, isArray } from '@varlet/shared';
6
7
  import { dt } from '../utils/shared.mjs';
7
- import { toPxNum, getTranslateY, requestAnimationFrame } from '../utils/elements.mjs';
8
+ import { toPxNum, getTranslateY } from '../utils/elements.mjs';
8
9
  import { pack } from '../locale/index.mjs';
9
10
  import { createNamespace, call } from '../utils/components.mjs';
10
11
  var {
@@ -76,9 +77,9 @@ function __render__(_ctx, _cache) {
76
77
  return _openBlock(), _createElementBlock("div", {
77
78
  class: _normalizeClass(_ctx.n('column')),
78
79
  key: c.id,
79
- onTouchstartPassive: $event => _ctx.handleTouchstart(c),
80
+ onTouchstartPassive: $event => _ctx.handleTouchstart($event, c),
80
81
  onTouchmove: _withModifiers($event => _ctx.handleTouchmove($event, c), ["prevent"]),
81
- onTouchend: $event => _ctx.handleTouchend($event, c)
82
+ onTouchend: $event => _ctx.handleTouchend(c)
82
83
  }, [_createElementVNode("div", {
83
84
  class: _normalizeClass(_ctx.n('scroller')),
84
85
  ref_for: true,
@@ -133,7 +134,14 @@ var __sfc__ = defineComponent({
133
134
  var center = computed(() => optionCount.value * optionHeight.value / 2 - optionHeight.value / 2);
134
135
  var columnHeight = computed(() => optionCount.value * optionHeight.value);
135
136
  var prevIndexes = [];
136
- var dragging = false;
137
+ var {
138
+ prevY,
139
+ moveY,
140
+ dragging,
141
+ startTouch,
142
+ moveTouch,
143
+ endTouch
144
+ } = useTouch();
137
145
  var setScrollEl = (el, scrollColumn) => {
138
146
  scrollColumn.scrollEl = el;
139
147
  };
@@ -172,30 +180,27 @@ var __sfc__ = defineComponent({
172
180
  scrollColumn.translate += Math.abs(distance / duration) / 0.003 * (distance < 0 ? -1 : 1);
173
181
  };
174
182
  var handleClick = (scrollColumn, index) => {
175
- if (dragging) {
183
+ if (dragging.value) {
176
184
  return;
177
185
  }
178
186
  scrollColumn.index = index;
179
187
  scrollColumn.scrolling = true;
180
188
  scrollTo(scrollColumn, TRANSITION_DURATION);
181
189
  };
182
- var handleTouchstart = scrollColumn => {
190
+ var handleTouchstart = (event, scrollColumn) => {
183
191
  scrollColumn.touching = true;
184
192
  scrollColumn.translate = getTranslateY(scrollColumn.scrollEl);
193
+ startTouch(event);
185
194
  };
186
195
  var handleTouchmove = (event, scrollColumn) => {
187
196
  if (!scrollColumn.touching) {
188
197
  return;
189
198
  }
190
- dragging = true;
199
+ moveTouch(event);
191
200
  scrollColumn.scrolling = false;
192
201
  scrollColumn.duration = 0;
193
- var {
194
- clientY
195
- } = event.touches[0];
196
- var deltaY = scrollColumn.prevY !== undefined ? clientY - scrollColumn.prevY : 0;
197
- scrollColumn.prevY = clientY;
198
- scrollColumn.translate += deltaY;
202
+ scrollColumn.prevY = prevY.value;
203
+ scrollColumn.translate += moveY.value;
199
204
  clampTranslate(scrollColumn);
200
205
  var now = performance.now();
201
206
  if (now - scrollColumn.momentumTime > MOMENTUM_RECORD_TIME) {
@@ -203,9 +208,10 @@ var __sfc__ = defineComponent({
203
208
  scrollColumn.momentumPrevY = scrollColumn.translate;
204
209
  }
205
210
  };
206
- var handleTouchend = (event, scrollColumn) => {
211
+ var handleTouchend = scrollColumn => {
212
+ endTouch();
207
213
  scrollColumn.touching = false;
208
- scrollColumn.prevY = undefined;
214
+ scrollColumn.prevY = 0;
209
215
  var distance = scrollColumn.translate - scrollColumn.momentumPrevY;
210
216
  var duration = performance.now() - scrollColumn.momentumTime;
211
217
  var shouldMomentum = Math.abs(distance) >= MOMENTUM_ALLOW_DISTANCE && duration <= MOMENTUM_RECORD_TIME;
@@ -222,9 +228,6 @@ var __sfc__ = defineComponent({
222
228
  if (!scrollColumn.scrolling) {
223
229
  change(scrollColumn);
224
230
  }
225
- requestAnimationFrame(() => {
226
- dragging = false;
227
- });
228
231
  };
229
232
  var handleTransitionend = scrollColumn => {
230
233
  scrollColumn.scrolling = false;
@@ -237,8 +240,8 @@ var __sfc__ = defineComponent({
237
240
  } : column;
238
241
  var scrollColumn = {
239
242
  id: sid++,
240
- prevY: undefined,
241
- momentumPrevY: undefined,
243
+ prevY: 0,
244
+ momentumPrevY: 0,
242
245
  touching: false,
243
246
  translate: center.value,
244
247
  index: (_normalColumn$initial = normalColumn.initialIndex) != null ? _normalColumn$initial : 0,
@@ -266,8 +269,8 @@ var __sfc__ = defineComponent({
266
269
  var index = initial ? (_props$cascadeInitial = props.cascadeInitialIndexes[scrollColumns.length]) != null ? _props$cascadeInitial : 0 : 0;
267
270
  var scrollColumn = {
268
271
  id: sid++,
269
- prevY: undefined,
270
- momentumPrevY: undefined,
272
+ prevY: 0,
273
+ momentumPrevY: 0,
271
274
  touching: false,
272
275
  translate: center.value,
273
276
  index,
@@ -1,8 +1,8 @@
1
1
  import '../../styles/common.css'
2
+ import '../SnackbarSfc.css'
2
3
  import '../../styles/elevation.css'
3
4
  import '../../loading/loading.css'
4
5
  import '../../button/button.css'
5
6
  import '../../icon/icon.css'
6
7
  import '../snackbar.css'
7
8
  import '../coreSfc.css'
8
- import '../SnackbarSfc.css'