@varlet/ui 2.16.1 → 2.16.3-alpha.1694267513697

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.
Files changed (91) hide show
  1. package/es/action-sheet/ActionSheet.mjs +20 -16
  2. package/es/app-bar/AppBar.mjs +10 -9
  3. package/es/avatar/Avatar.mjs +16 -15
  4. package/es/avatar-group/AvatarGroup.mjs +4 -3
  5. package/es/back-top/BackTop.mjs +20 -19
  6. package/es/badge/Badge.mjs +4 -3
  7. package/es/bottom-navigation/BottomNavigation.mjs +70 -63
  8. package/es/bottom-navigation-item/BottomNavigationItem.mjs +13 -10
  9. package/es/breadcrumb/Breadcrumb.mjs +5 -4
  10. package/es/breadcrumbs/Breadcrumbs.mjs +2 -1
  11. package/es/button/Button.mjs +10 -9
  12. package/es/button-group/ButtonGroup.mjs +2 -1
  13. package/es/card/Card.mjs +28 -26
  14. package/es/cell/Cell.mjs +5 -4
  15. package/es/checkbox/Checkbox.mjs +32 -29
  16. package/es/checkbox-group/CheckboxGroup.mjs +45 -40
  17. package/es/chip/Chip.mjs +6 -5
  18. package/es/col/Col.mjs +21 -16
  19. package/es/collapse/Collapse.mjs +30 -29
  20. package/es/collapse-item/CollapseItem.mjs +52 -47
  21. package/es/countdown/Countdown.mjs +36 -35
  22. package/es/counter/Counter.mjs +63 -60
  23. package/es/date-picker/DatePicker.mjs +67 -63
  24. package/es/dialog/Dialog.mjs +39 -29
  25. package/es/divider/Divider.mjs +6 -9
  26. package/es/drag/Drag.mjs +47 -45
  27. package/es/ellipsis/Ellipsis.mjs +6 -5
  28. package/es/fab/Fab.mjs +21 -20
  29. package/es/field-decorator/FieldDecorator.mjs +14 -13
  30. package/es/form/Form.mjs +41 -36
  31. package/es/form-details/FormDetails.mjs +2 -1
  32. package/es/hover-overlay/HoverOverlay.mjs +6 -7
  33. package/es/icon/Icon.mjs +14 -12
  34. package/es/image/Image.mjs +14 -12
  35. package/es/image-preview/ImagePreview.mjs +51 -50
  36. package/es/index-anchor/IndexAnchor.mjs +15 -12
  37. package/es/index-bar/IndexBar.mjs +68 -65
  38. package/es/index.bundle.mjs +1 -1
  39. package/es/index.mjs +1 -1
  40. package/es/input/Input.mjs +63 -56
  41. package/es/link/Link.mjs +6 -5
  42. package/es/list/List.mjs +55 -46
  43. package/es/loading/Loading.mjs +11 -8
  44. package/es/loading-bar/LoadingBar.mjs +2 -1
  45. package/es/menu/Menu.mjs +2 -1
  46. package/es/option/Option.mjs +14 -11
  47. package/es/overlay/Overlay.mjs +18 -18
  48. package/es/pagination/Pagination.mjs +67 -64
  49. package/es/paper/Paper.mjs +4 -3
  50. package/es/picker/Picker.mjs +95 -85
  51. package/es/popup/Popup.mjs +26 -23
  52. package/es/progress/Progress.mjs +9 -8
  53. package/es/pull-refresh/PullRefresh.mjs +54 -51
  54. package/es/radio/Radio.mjs +25 -22
  55. package/es/radio-group/RadioGroup.mjs +30 -25
  56. package/es/rate/Rate.mjs +35 -28
  57. package/es/result/Result.mjs +6 -5
  58. package/es/row/Row.mjs +20 -18
  59. package/es/row/props.mjs +1 -1
  60. package/es/select/Select.mjs +57 -54
  61. package/es/skeleton/Skeleton.mjs +8 -9
  62. package/es/slider/Slider.mjs +86 -79
  63. package/es/snackbar/Snackbar.mjs +4 -3
  64. package/es/snackbar/style/index.mjs +1 -1
  65. package/es/space/Space.mjs +5 -2
  66. package/es/step/Step.mjs +7 -4
  67. package/es/steps/Steps.mjs +5 -4
  68. package/es/sticky/Sticky.mjs +30 -27
  69. package/es/style-provider/StyleProvider.mjs +2 -1
  70. package/es/swipe/Swipe.mjs +99 -90
  71. package/es/swipe-item/SwipeItem.mjs +5 -4
  72. package/es/switch/Switch.mjs +22 -17
  73. package/es/tab/Tab.mjs +16 -12
  74. package/es/tab-item/TabItem.mjs +7 -6
  75. package/es/table/Table.mjs +8 -9
  76. package/es/tabs/Tabs.mjs +57 -52
  77. package/es/tabs-items/TabsItems.mjs +38 -29
  78. package/es/time-picker/TimePicker.mjs +63 -60
  79. package/es/tooltip/Tooltip.mjs +3 -2
  80. package/es/uploader/Uploader.mjs +100 -85
  81. package/es/utils/components.mjs +2 -1
  82. package/es/utils/shared.mjs +0 -1
  83. package/es/varlet.esm.js +9605 -8923
  84. package/es/watermark/Watermark.mjs +29 -26
  85. package/highlight/web-types.en-US.json +3 -3
  86. package/highlight/web-types.zh-CN.json +3 -3
  87. package/lib/varlet.cjs.js +2388 -2118
  88. package/package.json +12 -14
  89. package/types/row.d.ts +1 -1
  90. package/types/swipe.d.ts +12 -3
  91. package/umd/varlet.js +4 -4
@@ -11,6 +11,7 @@ import { createNamespace, call, formatElevation } from '../utils/components.mjs'
11
11
  import { padStart } from '../utils/shared.mjs';
12
12
  import { pack } from '../locale/index.mjs';
13
13
  var {
14
+ name,
14
15
  n,
15
16
  classes
16
17
  } = createNamespace('date-picker');
@@ -110,7 +111,7 @@ function __render__(_ctx, _cache) {
110
111
  }
111
112
 
112
113
  var __sfc__ = defineComponent({
113
- name: 'VarDatePicker',
114
+ name,
114
115
  components: {
115
116
  MonthPickerPanel,
116
117
  YearPickerPanel,
@@ -118,10 +119,6 @@ var __sfc__ = defineComponent({
118
119
  },
119
120
  props,
120
121
  setup(props) {
121
- var startX = 0;
122
- var startY = 0;
123
- var checkType = '';
124
- var touchDirection;
125
122
  var currentDate = dayjs().format('YYYY-MM-D');
126
123
  var [currentYear, currentMonth] = currentDate.split('-');
127
124
  var monthDes = MONTH_LIST.find(month => month.index === currentMonth);
@@ -224,13 +221,33 @@ var __sfc__ = defineComponent({
224
221
  var _chooseMonth$value3;
225
222
  return ((_chooseMonth$value3 = chooseMonth.value) == null ? void 0 : _chooseMonth$value3.index) === previewMonth.value.index;
226
223
  });
227
- var clickEl = type => {
224
+ var startX = 0;
225
+ var startY = 0;
226
+ var checkType = '';
227
+ var touchDirection;
228
+ watch(() => props.modelValue, value => {
229
+ if (!checkValue() || invalidFormatDate(value) || !value) return;
230
+ if (props.range) {
231
+ if (!isArray(value)) return;
232
+ rangeDone.value = value.length !== 1;
233
+ rangeInit(value, props.type);
234
+ } else if (props.multiple) {
235
+ if (!isArray(value)) return;
236
+ multipleInit(value, props.type);
237
+ } else {
238
+ dateInit(value);
239
+ }
240
+ }, {
241
+ immediate: true
242
+ });
243
+ watch(getPanelType, resetState);
244
+ function clickEl(type) {
228
245
  if (type === 'year') isYearPanel.value = true;else if (type === 'month') isMonthPanel.value = true;else {
229
246
  isYearPanel.value = false;
230
247
  isMonthPanel.value = false;
231
248
  }
232
- };
233
- var handleTouchstart = event => {
249
+ }
250
+ function handleTouchstart(event) {
234
251
  if (isUntouchable.value) return;
235
252
  var {
236
253
  clientX,
@@ -238,9 +255,11 @@ var __sfc__ = defineComponent({
238
255
  } = event.touches[0];
239
256
  startX = clientX;
240
257
  startY = clientY;
241
- };
242
- var getDirection = (x, y) => x >= y && x > 20 ? 'x' : 'y';
243
- var handleTouchmove = event => {
258
+ }
259
+ function getDirection(x, y) {
260
+ return x >= y && x > 20 ? 'x' : 'y';
261
+ }
262
+ function handleTouchmove(event) {
244
263
  if (isUntouchable.value) return;
245
264
  var {
246
265
  clientX,
@@ -250,20 +269,21 @@ var __sfc__ = defineComponent({
250
269
  var y = clientY - startY;
251
270
  touchDirection = getDirection(Math.abs(x), Math.abs(y));
252
271
  checkType = x > 0 ? 'prev' : 'next';
253
- };
254
- var handleTouchend = /*#__PURE__*/function () {
255
- var _ref = _asyncToGenerator(function* () {
272
+ }
273
+ function handleTouchend() {
274
+ return _handleTouchend.apply(this, arguments);
275
+ }
276
+ function _handleTouchend() {
277
+ _handleTouchend = _asyncToGenerator(function* () {
256
278
  if (isUntouchable.value || touchDirection !== 'x') return;
257
279
  var componentRef = getPanelType.value === 'month' ? monthPanelEl : dayPanelEl;
258
280
  yield doubleRaf();
259
281
  componentRef.value.forwardRef(checkType);
260
282
  resetState();
261
283
  });
262
- return function handleTouchend() {
263
- return _ref.apply(this, arguments);
264
- };
265
- }();
266
- var updateRange = (date, type) => {
284
+ return _handleTouchend.apply(this, arguments);
285
+ }
286
+ function updateRange(date, type) {
267
287
  var rangeDate = type === 'month' ? chooseRangeMonth : chooseRangeDay;
268
288
  rangeDate.value = rangeDone.value ? [date, date] : [rangeDate.value[0], date];
269
289
  rangeDone.value = !rangeDone.value;
@@ -273,8 +293,8 @@ var __sfc__ = defineComponent({
273
293
  call(props['onUpdate:modelValue'], _date);
274
294
  call(props.onChange, _date);
275
295
  }
276
- };
277
- var updateMultiple = (date, type) => {
296
+ }
297
+ function updateMultiple(date, type) {
278
298
  var multipleDates = type === 'month' ? chooseMonths : chooseDays;
279
299
  var formatType = type === 'month' ? 'YYYY-MM' : 'YYYY-MM-DD';
280
300
  var formatDates = multipleDates.value.map(date => dayjs(date).format(formatType));
@@ -282,14 +302,14 @@ var __sfc__ = defineComponent({
282
302
  if (index === -1) formatDates.push(date);else formatDates.splice(index, 1);
283
303
  call(props['onUpdate:modelValue'], formatDates);
284
304
  call(props.onChange, formatDates);
285
- };
286
- var getReverse = (dateType, date) => {
305
+ }
306
+ function getReverse(dateType, date) {
287
307
  if (!chooseYear.value || !chooseMonth.value) return false;
288
308
  if (!isSameYear.value) return chooseYear.value > previewYear.value;
289
309
  if (dateType === 'month') return date.index < chooseMonth.value.index;
290
310
  return isSameMonth.value ? date < toNumber(chooseDay.value) : chooseMonth.value.index > previewMonth.value.index;
291
- };
292
- var getChooseDay = day => {
311
+ }
312
+ function getChooseDay(day) {
293
313
  var {
294
314
  readonly,
295
315
  range,
@@ -305,8 +325,8 @@ var __sfc__ = defineComponent({
305
325
  call(updateModelValue, formatDate);
306
326
  call(onChange, formatDate);
307
327
  }
308
- };
309
- var getChooseMonth = month => {
328
+ }
329
+ function getChooseMonth(month) {
310
330
  var {
311
331
  type,
312
332
  readonly,
@@ -328,14 +348,14 @@ var __sfc__ = defineComponent({
328
348
  call(onPreview, toNumber(previewYear.value), toNumber(previewMonth.value.index));
329
349
  }
330
350
  isMonthPanel.value = false;
331
- };
332
- var getChooseYear = year => {
351
+ }
352
+ function getChooseYear(year) {
333
353
  previewYear.value = "" + year;
334
354
  isYearPanel.value = false;
335
355
  isMonthPanel.value = true;
336
356
  call(props.onPreview, toNumber(previewYear.value), toNumber(previewMonth.value.index));
337
- };
338
- var checkPreview = (type, checkType) => {
357
+ }
358
+ function checkPreview(type, checkType) {
339
359
  var changeValue = checkType === 'prev' ? -1 : 1;
340
360
  if (type === 'year') {
341
361
  previewYear.value = "" + (toNumber(previewYear.value) + changeValue);
@@ -352,8 +372,8 @@ var __sfc__ = defineComponent({
352
372
  previewMonth.value = MONTH_LIST.find(month => toNumber(month.index) === checkIndex);
353
373
  }
354
374
  call(props.onPreview, toNumber(previewYear.value), toNumber(previewMonth.value.index));
355
- };
356
- var checkValue = () => {
375
+ }
376
+ function checkValue() {
357
377
  if ((props.multiple || props.range) && !isArray(props.modelValue)) {
358
378
  console.error('[Varlet] DatePicker: type of prop "modelValue" should be an Array');
359
379
  return false;
@@ -363,16 +383,16 @@ var __sfc__ = defineComponent({
363
383
  return false;
364
384
  }
365
385
  return true;
366
- };
367
- var invalidFormatDate = date => {
386
+ }
387
+ function invalidFormatDate(date) {
368
388
  if (isArray(date)) return false;
369
389
  if (date === 'Invalid Date') {
370
390
  console.error('[Varlet] DatePicker: "modelValue" is an Invalid Date');
371
391
  return true;
372
392
  }
373
393
  return false;
374
- };
375
- var rangeInit = (value, type) => {
394
+ }
395
+ function rangeInit(value, type) {
376
396
  var rangeDate = type === 'month' ? chooseRangeMonth : chooseRangeDay;
377
397
  var formatType = type === 'month' ? 'YYYY-MM' : 'YYYY-MM-D';
378
398
  var formatDateList = value.map(choose => dayjs(choose).format(formatType)).slice(0, 2);
@@ -383,16 +403,16 @@ var __sfc__ = defineComponent({
383
403
  if (rangeDate.value.length === 2 && isChangeOrder) {
384
404
  rangeDate.value = [rangeDate.value[1], rangeDate.value[0]];
385
405
  }
386
- };
387
- var multipleInit = (value, type) => {
406
+ }
407
+ function multipleInit(value, type) {
388
408
  var rangeDate = type === 'month' ? chooseMonths : chooseDays;
389
409
  var formatType = type === 'month' ? 'YYYY-MM' : 'YYYY-MM-D';
390
410
 
391
- // 需要去重
411
+ // need uniq
392
412
  var formatDateList = Array.from(new Set(value.map(choose => dayjs(choose).format(formatType))));
393
413
  rangeDate.value = formatDateList.filter(date => date !== 'Invalid Date');
394
- };
395
- var dateInit = value => {
414
+ }
415
+ function dateInit(value) {
396
416
  var formatDate = dayjs(value).format('YYYY-MM-D');
397
417
  if (invalidFormatDate(formatDate)) return;
398
418
  var [yearValue, monthValue, dayValue] = formatDate.split('-');
@@ -402,32 +422,14 @@ var __sfc__ = defineComponent({
402
422
  chooseDay.value = dayValue;
403
423
  previewMonth.value = monthDes;
404
424
  previewYear.value = yearValue;
405
- };
406
- var resetState = () => {
425
+ }
426
+ function resetState() {
407
427
  startY = 0;
408
428
  startX = 0;
409
429
  checkType = '';
410
430
  touchDirection = undefined;
411
- };
412
- watch(() => props.modelValue, value => {
413
- if (!checkValue() || invalidFormatDate(value) || !value) return;
414
- if (props.range) {
415
- if (!isArray(value)) return;
416
- rangeDone.value = value.length !== 1;
417
- rangeInit(value, props.type);
418
- } else if (props.multiple) {
419
- if (!isArray(value)) return;
420
- multipleInit(value, props.type);
421
- } else {
422
- dateInit(value);
423
- }
424
- }, {
425
- immediate: true
426
- });
427
- watch(getPanelType, resetState);
431
+ }
428
432
  return {
429
- n,
430
- classes,
431
433
  monthPanelEl,
432
434
  dayPanelEl,
433
435
  reverse,
@@ -446,6 +448,8 @@ var __sfc__ = defineComponent({
446
448
  componentProps,
447
449
  slotProps,
448
450
  formatRange,
451
+ n,
452
+ classes,
449
453
  clickEl,
450
454
  handleTouchstart,
451
455
  handleTouchmove,
@@ -3,11 +3,11 @@ import VarPopup from '../popup/index.mjs';
3
3
  import VarButton from '../button/index.mjs';
4
4
  import { props } from './props.mjs';
5
5
  import { defineComponent, ref, watch } from 'vue';
6
- import { dt } from '../utils/shared.mjs';
7
6
  import { pack } from '../locale/index.mjs';
8
7
  import { call, createNamespace } from '../utils/components.mjs';
9
8
  import { toSizeUnit } from '../utils/elements.mjs';
10
9
  var {
10
+ name,
11
11
  n,
12
12
  classes
13
13
  } = createNamespace('dialog');
@@ -39,7 +39,10 @@ function __render__(_ctx, _cache) {
39
39
  }, _ctx.dialogStyle)
40
40
  }, _ctx.$attrs), [_createElementVNode("div", {
41
41
  class: _normalizeClass(_ctx.n('title'))
42
- }, [_renderSlot(_ctx.$slots, "title", {}, () => [_createTextVNode(_toDisplayString(_ctx.dt(_ctx.title, _ctx.pack.dialogTitle)), 1 /* TEXT */)])], 2 /* CLASS */), _createElementVNode("div", {
42
+ }, [_renderSlot(_ctx.$slots, "title", {}, () => {
43
+ var _ctx$title;
44
+ return [_createTextVNode(_toDisplayString((_ctx$title = _ctx.title) != null ? _ctx$title : _ctx.pack.dialogTitle), 1 /* TEXT */)];
45
+ })], 2 /* CLASS */), _createElementVNode("div", {
43
46
  class: _normalizeClass(_ctx.n('message')),
44
47
  style: _normalizeStyle({
45
48
  textAlign: _ctx.messageAlign
@@ -55,7 +58,10 @@ function __render__(_ctx, _cache) {
55
58
  color: _ctx.cancelButtonColor,
56
59
  onClick: _ctx.cancel
57
60
  }, {
58
- default: _withCtx(() => [_createTextVNode(_toDisplayString(_ctx.dt(_ctx.cancelButtonText, _ctx.pack.dialogCancelButtonText)), 1 /* TEXT */)]),
61
+ default: _withCtx(() => {
62
+ var _ctx$cancelButtonText;
63
+ return [_createTextVNode(_toDisplayString((_ctx$cancelButtonText = _ctx.cancelButtonText) != null ? _ctx$cancelButtonText : _ctx.pack.dialogCancelButtonText), 1 /* TEXT */)];
64
+ }),
59
65
 
60
66
  _: 1 /* STABLE */
61
67
  }, 8 /* PROPS */, ["class", "text-color", "color", "onClick"])) : _createCommentVNode("v-if", true), _ctx.confirmButton ? (_openBlock(), _createBlock(_component_var_button, {
@@ -67,7 +73,10 @@ function __render__(_ctx, _cache) {
67
73
  color: _ctx.confirmButtonColor,
68
74
  onClick: _ctx.confirm
69
75
  }, {
70
- default: _withCtx(() => [_createTextVNode(_toDisplayString(_ctx.dt(_ctx.confirmButtonText, _ctx.pack.dialogConfirmButtonText)), 1 /* TEXT */)]),
76
+ default: _withCtx(() => {
77
+ var _ctx$confirmButtonTex;
78
+ return [_createTextVNode(_toDisplayString((_ctx$confirmButtonTex = _ctx.confirmButtonText) != null ? _ctx$confirmButtonTex : _ctx.pack.dialogConfirmButtonText), 1 /* TEXT */)];
79
+ }),
71
80
 
72
81
  _: 1 /* STABLE */
73
82
  }, 8 /* PROPS */, ["class", "text-color", "color", "onClick"])) : _createCommentVNode("v-if", true)], 2 /* CLASS */)], 16 /* FULL_PROPS */)]),
@@ -76,7 +85,7 @@ function __render__(_ctx, _cache) {
76
85
  }, 8 /* PROPS */, ["class", "show", "overlay", "overlay-class", "overlay-style", "lock-scroll", "close-on-click-overlay", "teleport", "onOpen", "onClose", "onClosed", "onOpened", "onRouteChange", "onClickOverlay"]);
77
86
  }
78
87
  var __sfc__ = defineComponent({
79
- name: 'VarDialog',
88
+ name,
80
89
  components: {
81
90
  VarPopup,
82
91
  VarButton
@@ -86,8 +95,24 @@ var __sfc__ = defineComponent({
86
95
  setup(props) {
87
96
  var popupShow = ref(false);
88
97
  var popupCloseOnClickOverlay = ref(false);
89
- var done = () => call(props['onUpdate:show'], false);
90
- var handleClickOverlay = () => {
98
+ watch(() => props.show, newValue => {
99
+ popupShow.value = newValue;
100
+ }, {
101
+ immediate: true
102
+ });
103
+ watch(() => props.closeOnClickOverlay, newValue => {
104
+ if (props.onBeforeClose != null) {
105
+ popupCloseOnClickOverlay.value = false;
106
+ return;
107
+ }
108
+ popupCloseOnClickOverlay.value = newValue;
109
+ }, {
110
+ immediate: true
111
+ });
112
+ function done() {
113
+ return call(props['onUpdate:show'], false);
114
+ }
115
+ function handleClickOverlay() {
91
116
  var {
92
117
  closeOnClickOverlay,
93
118
  onClickOverlay,
@@ -102,8 +127,8 @@ var __sfc__ = defineComponent({
102
127
  return;
103
128
  }
104
129
  call(props['onUpdate:show'], false);
105
- };
106
- var confirm = () => {
130
+ }
131
+ function confirm() {
107
132
  var {
108
133
  onBeforeClose,
109
134
  onConfirm
@@ -114,8 +139,8 @@ var __sfc__ = defineComponent({
114
139
  return;
115
140
  }
116
141
  call(props['onUpdate:show'], false);
117
- };
118
- var cancel = () => {
142
+ }
143
+ function cancel() {
119
144
  var {
120
145
  onBeforeClose,
121
146
  onCancel
@@ -126,28 +151,13 @@ var __sfc__ = defineComponent({
126
151
  return;
127
152
  }
128
153
  call(props['onUpdate:show'], false);
129
- };
130
- watch(() => props.show, newValue => {
131
- popupShow.value = newValue;
132
- }, {
133
- immediate: true
134
- });
135
- watch(() => props.closeOnClickOverlay, newValue => {
136
- if (props.onBeforeClose != null) {
137
- popupCloseOnClickOverlay.value = false;
138
- return;
139
- }
140
- popupCloseOnClickOverlay.value = newValue;
141
- }, {
142
- immediate: true
143
- });
154
+ }
144
155
  return {
145
- n,
146
- classes,
147
156
  pack,
148
- dt,
149
157
  popupShow,
150
158
  popupCloseOnClickOverlay,
159
+ n,
160
+ classes,
151
161
  handleClickOverlay,
152
162
  confirm,
153
163
  cancel,
@@ -5,6 +5,7 @@ import { props } from './props.mjs';
5
5
  import { createNamespace } from '../utils/components.mjs';
6
6
  import { onSmartMounted } from '@varlet/use';
7
7
  var {
8
+ name,
8
9
  n,
9
10
  classes
10
11
  } = createNamespace('divider');
@@ -22,7 +23,7 @@ function __render__(_ctx, _cache) {
22
23
  }
23
24
 
24
25
  var __sfc__ = defineComponent({
25
- name: 'VarDivider',
26
+ name,
26
27
  props,
27
28
  setup(props, _ref) {
28
29
  var {
@@ -56,20 +57,16 @@ var __sfc__ = defineComponent({
56
57
  left: _inset > 0 ? toSizeUnit(absInsetWithUnit) : toSizeUnit(0)
57
58
  };
58
59
  });
59
- var checkHasText = () => {
60
+ onSmartMounted(checkHasText);
61
+ onUpdated(checkHasText);
62
+ function checkHasText() {
60
63
  // the default slot or description is only effective in horizontal mode
61
64
  var {
62
65
  description,
63
66
  vertical
64
67
  } = props;
65
68
  withText.value = (slots.default || description != null) && !vertical;
66
- };
67
- onSmartMounted(() => {
68
- checkHasText();
69
- });
70
- onUpdated(() => {
71
- checkHasText();
72
- });
69
+ }
73
70
  return {
74
71
  n,
75
72
  classes,
package/es/drag/Drag.mjs CHANGED
@@ -8,6 +8,7 @@ import { toPxNum } from '../utils/elements.mjs';
8
8
  import { onSmartMounted, onWindowResize, useTouch } from '@varlet/use';
9
9
  import { clamp, getRect } from '@varlet/shared';
10
10
  var {
11
+ name,
11
12
  n,
12
13
  classes
13
14
  } = createNamespace('drag');
@@ -40,7 +41,7 @@ function __render__(_ctx, _cache) {
40
41
  }, _ctx.getAttrs()), [_renderSlot(_ctx.$slots, "default")], 16 /* FULL_PROPS */)], 8 /* PROPS */, ["to", "disabled"]);
41
42
  }
42
43
  var __sfc__ = defineComponent({
43
- name: 'VarDrag',
44
+ name,
44
45
  inheritAttrs: false,
45
46
  props,
46
47
  setup(props, _ref) {
@@ -50,12 +51,6 @@ var __sfc__ = defineComponent({
50
51
  var drag = ref(null);
51
52
  var x = ref(0);
52
53
  var y = ref(0);
53
- var boundary = reactive({
54
- top: 0,
55
- bottom: 0,
56
- left: 0,
57
- right: 0
58
- });
59
54
  var dragged = ref(false);
60
55
  var enableTransition = ref(false);
61
56
  var {
@@ -71,15 +66,30 @@ var __sfc__ = defineComponent({
71
66
  var {
72
67
  disabled: teleportDisabled
73
68
  } = useTeleport();
74
- var handleTouchstart = event => {
69
+ var boundary = reactive({
70
+ top: 0,
71
+ bottom: 0,
72
+ left: 0,
73
+ right: 0
74
+ });
75
+ watch(() => props.boundary, toPxBoundary);
76
+ onWindowResize(resize);
77
+ onSmartMounted(() => {
78
+ toPxBoundary();
79
+ resize();
80
+ });
81
+ function handleTouchstart(event) {
75
82
  if (props.disabled) {
76
83
  return;
77
84
  }
78
85
  startTouch(event);
79
86
  saveXY();
80
- };
81
- var handleTouchmove = /*#__PURE__*/function () {
82
- var _ref2 = _asyncToGenerator(function* (event) {
87
+ }
88
+ function handleTouchmove(_x) {
89
+ return _handleTouchmove.apply(this, arguments);
90
+ }
91
+ function _handleTouchmove() {
92
+ _handleTouchmove = _asyncToGenerator(function* (event) {
83
93
  if (!touching.value || props.disabled) {
84
94
  return;
85
95
  }
@@ -95,33 +105,31 @@ var __sfc__ = defineComponent({
95
105
  }
96
106
  clampToBoundary();
97
107
  });
98
- return function handleTouchmove(_x) {
99
- return _ref2.apply(this, arguments);
100
- };
101
- }();
102
- var handleTouchend = () => {
108
+ return _handleTouchmove.apply(this, arguments);
109
+ }
110
+ function handleTouchend() {
103
111
  if (props.disabled) {
104
112
  return;
105
113
  }
106
114
  endTouch();
107
115
  enableTransition.value = true;
108
116
  attract();
109
- };
110
- var handleClick = event => {
117
+ }
118
+ function handleClick(event) {
111
119
  if (dragging.value) {
112
120
  return;
113
121
  }
114
122
  call(props.onClick, event);
115
- };
116
- var saveXY = () => {
123
+ }
124
+ function saveXY() {
117
125
  var {
118
126
  left,
119
127
  top
120
128
  } = getOffset();
121
129
  x.value = left;
122
130
  y.value = top;
123
- };
124
- var getOffset = () => {
131
+ }
132
+ function getOffset() {
125
133
  var dragRect = getRect(drag.value);
126
134
  var windowRect = getRect(window);
127
135
  var top = dragRect.top - windowRect.top;
@@ -148,8 +156,8 @@ var __sfc__ = defineComponent({
148
156
  windowWidth,
149
157
  windowHeight
150
158
  };
151
- };
152
- var getRange = () => {
159
+ }
160
+ function getRange() {
153
161
  var offset = getOffset();
154
162
  var x1 = boundary.left;
155
163
  var x2 = offset.windowWidth - boundary.right - offset.width;
@@ -162,8 +170,8 @@ var __sfc__ = defineComponent({
162
170
  maxX: x1 < x2 ? x2 : x1,
163
171
  maxY: y1 < y2 ? y2 : y1
164
172
  };
165
- };
166
- var attract = () => {
173
+ }
174
+ function attract() {
167
175
  if (props.attraction == null) {
168
176
  return;
169
177
  }
@@ -193,8 +201,8 @@ var __sfc__ = defineComponent({
193
201
  if (props.attraction.includes('y')) {
194
202
  y.value = nearTop ? minY : maxY;
195
203
  }
196
- };
197
- var clampToBoundary = () => {
204
+ }
205
+ function clampToBoundary() {
198
206
  var {
199
207
  minX,
200
208
  minY,
@@ -203,8 +211,8 @@ var __sfc__ = defineComponent({
203
211
  } = getRange();
204
212
  x.value = clamp(x.value, minX, maxX);
205
213
  y.value = clamp(y.value, minY, maxY);
206
- };
207
- var toPxBoundary = () => {
214
+ }
215
+ function toPxBoundary() {
208
216
  var {
209
217
  top = 0,
210
218
  bottom = 0,
@@ -215,10 +223,10 @@ var __sfc__ = defineComponent({
215
223
  boundary.bottom = toPxNum(bottom);
216
224
  boundary.left = toPxNum(left);
217
225
  boundary.right = toPxNum(right);
218
- };
219
- var getAttrs = () => {
220
- var _ref3;
221
- var style = (_ref3 = attrs.style) != null ? _ref3 : {};
226
+ }
227
+ function getAttrs() {
228
+ var _ref2;
229
+ var style = (_ref2 = attrs.style) != null ? _ref2 : {};
222
230
  return _extends({}, attrs, {
223
231
  style: _extends({}, style, {
224
232
  // when the drag element is dragged for the first time, the inset should be cleared to avoid affecting translateX and translateY.
@@ -229,31 +237,25 @@ var __sfc__ = defineComponent({
229
237
  transform: dragged.value ? "translate(" + x.value + "px, " + y.value + "px)" : style.transform
230
238
  })
231
239
  });
232
- };
240
+ }
233
241
 
234
242
  // expose
235
- var resize = () => {
243
+ function resize() {
236
244
  if (!dragged.value) {
237
245
  return;
238
246
  }
239
247
  saveXY();
240
248
  clampToBoundary();
241
- };
249
+ }
242
250
 
243
251
  // expose
244
- var reset = () => {
252
+ function reset() {
245
253
  resetTouch();
246
254
  enableTransition.value = false;
247
255
  dragged.value = false;
248
256
  x.value = 0;
249
257
  y.value = 0;
250
- };
251
- watch(() => props.boundary, toPxBoundary);
252
- onWindowResize(resize);
253
- onSmartMounted(() => {
254
- toPxBoundary();
255
- resize();
256
- });
258
+ }
257
259
  return {
258
260
  drag,
259
261
  x,
@@ -4,6 +4,7 @@ import { computed, defineComponent, ref } from 'vue';
4
4
  import { createNamespace } from '../utils/components.mjs';
5
5
  import { props } from './props.mjs';
6
6
  var {
7
+ name,
7
8
  n,
8
9
  classes
9
10
  } = createNamespace('ellipsis');
@@ -34,7 +35,7 @@ function __render__(_ctx, _cache) {
34
35
  }
35
36
 
36
37
  var __sfc__ = defineComponent({
37
- name: 'VarEllipsis',
38
+ name,
38
39
  components: {
39
40
  VarTooltip
40
41
  },
@@ -64,18 +65,18 @@ var __sfc__ = defineComponent({
64
65
  sameWidth: true
65
66
  }, props.tooltip);
66
67
  });
67
- var handleClick = () => {
68
+ function handleClick() {
68
69
  if (!props.expandTrigger) {
69
70
  return;
70
71
  }
71
72
  expanding.value = !expanding.value;
72
- };
73
+ }
73
74
  return {
74
- n,
75
- classes,
76
75
  tooltip,
77
76
  expanding,
78
77
  rootStyles,
78
+ n,
79
+ classes,
79
80
  handleClick
80
81
  };
81
82
  }