@varlet/ui 2.16.2 → 2.16.3-alpha.1694361535255

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 (88) 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 +15 -14
  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 +14 -13
  59. package/es/select/Select.mjs +57 -54
  60. package/es/skeleton/Skeleton.mjs +8 -9
  61. package/es/slider/Slider.mjs +86 -79
  62. package/es/snackbar/Snackbar.mjs +4 -3
  63. package/es/snackbar/style/index.mjs +1 -1
  64. package/es/space/Space.mjs +5 -2
  65. package/es/step/Step.mjs +7 -4
  66. package/es/steps/Steps.mjs +5 -4
  67. package/es/sticky/Sticky.mjs +30 -27
  68. package/es/style-provider/StyleProvider.mjs +2 -1
  69. package/es/swipe/Swipe.mjs +95 -89
  70. package/es/swipe-item/SwipeItem.mjs +5 -4
  71. package/es/switch/Switch.mjs +22 -17
  72. package/es/tab/Tab.mjs +16 -12
  73. package/es/tab-item/TabItem.mjs +7 -6
  74. package/es/table/Table.mjs +8 -9
  75. package/es/tabs/Tabs.mjs +57 -52
  76. package/es/tabs-items/TabsItems.mjs +38 -29
  77. package/es/time-picker/TimePicker.mjs +63 -60
  78. package/es/tooltip/Tooltip.mjs +3 -2
  79. package/es/uploader/Uploader.mjs +100 -85
  80. package/es/utils/components.mjs +2 -1
  81. package/es/utils/shared.mjs +0 -1
  82. package/es/varlet.esm.js +9589 -8914
  83. package/es/watermark/Watermark.mjs +29 -26
  84. package/highlight/web-types.en-US.json +1 -1
  85. package/highlight/web-types.zh-CN.json +1 -1
  86. package/lib/varlet.cjs.js +2365 -2102
  87. package/package.json +12 -14
  88. package/umd/varlet.js +4 -4
@@ -7,6 +7,7 @@ import { createNamespace, formatElevation } from '../utils/components.mjs';
7
7
  import { useCollapse } from './provide.mjs';
8
8
  import { props } from './props.mjs';
9
9
  var {
10
+ name,
10
11
  n,
11
12
  classes
12
13
  } = createNamespace('collapse-item');
@@ -44,21 +45,21 @@ function __render__(_ctx, _cache) {
44
45
  }
45
46
 
46
47
  var __sfc__ = defineComponent({
47
- name: 'VarCollapseItem',
48
+ name,
48
49
  components: {
49
50
  VarIcon
50
51
  },
51
52
  props,
52
53
  setup(props) {
54
+ var isShow = ref(false);
55
+ var showContent = ref(false);
56
+ var contentEl = ref(null);
57
+ var name = computed(() => props.name);
53
58
  var {
54
59
  index,
55
60
  collapse,
56
61
  bindCollapse
57
62
  } = useCollapse();
58
- var isInitToTrigger = true; // ensure to trigger transitionend
59
- var contentEl = ref(null);
60
- var showContent = ref(false);
61
- var isShow = ref(false);
62
63
  var {
63
64
  active,
64
65
  offset,
@@ -66,20 +67,23 @@ var __sfc__ = defineComponent({
66
67
  elevation,
67
68
  updateItem
68
69
  } = collapse;
69
- var name = computed(() => props.name);
70
- var init = (accordion, show) => {
71
- if (active.value === undefined || accordion && isArray(active.value) || show === isShow.value) return;
72
- isShow.value = show;
73
- toggle(true);
74
- };
75
- var toggle = initOrAccordion => {
76
- if (props.disabled) return;
77
- if (!initOrAccordion) {
78
- updateItem(props.name || index.value, !isShow.value);
79
- }
70
+ var collapseItemProvider = {
71
+ index,
72
+ name,
73
+ init
80
74
  };
81
- var openPanel = /*#__PURE__*/function () {
82
- var _ref = _asyncToGenerator(function* () {
75
+
76
+ // ensure to trigger transitionend
77
+ var isInitToTrigger = true;
78
+ watch(isShow, value => {
79
+ value ? openPanel() : closePanel();
80
+ });
81
+ bindCollapse(collapseItemProvider);
82
+ function openPanel() {
83
+ return _openPanel.apply(this, arguments);
84
+ }
85
+ function _openPanel() {
86
+ _openPanel = _asyncToGenerator(function* () {
83
87
  if (!contentEl.value) {
84
88
  return;
85
89
  }
@@ -106,15 +110,13 @@ var __sfc__ = defineComponent({
106
110
  transitionend();
107
111
  }
108
112
  });
109
- return function openPanel() {
110
- return _ref.apply(this, arguments);
111
- };
112
- }();
113
- var start = () => {
114
- isInitToTrigger = false;
115
- };
116
- var closePanel = /*#__PURE__*/function () {
117
- var _ref2 = _asyncToGenerator(function* () {
113
+ return _openPanel.apply(this, arguments);
114
+ }
115
+ function closePanel() {
116
+ return _closePanel.apply(this, arguments);
117
+ }
118
+ function _closePanel() {
119
+ _closePanel = _asyncToGenerator(function* () {
118
120
  if (!contentEl.value) {
119
121
  return;
120
122
  }
@@ -125,36 +127,39 @@ var __sfc__ = defineComponent({
125
127
  yield raf();
126
128
  contentEl.value.style.height = 0 + 'px';
127
129
  });
128
- return function closePanel() {
129
- return _ref2.apply(this, arguments);
130
- };
131
- }();
132
- var transitionend = () => {
130
+ return _closePanel.apply(this, arguments);
131
+ }
132
+ function init(accordion, show) {
133
+ if (active.value === undefined || accordion && isArray(active.value) || show === isShow.value) return;
134
+ isShow.value = show;
135
+ toggle(true);
136
+ }
137
+ function toggle(initOrAccordion) {
138
+ if (props.disabled) return;
139
+ if (!initOrAccordion) {
140
+ updateItem(props.name || index.value, !isShow.value);
141
+ }
142
+ }
143
+ function start() {
144
+ isInitToTrigger = false;
145
+ }
146
+ function transitionend() {
133
147
  if (!isShow.value) {
134
148
  showContent.value = false;
135
149
  }
136
150
  contentEl.value.style.height = '';
137
- };
138
- var collapseItemProvider = {
139
- index,
140
- name,
141
- init
142
- };
143
- bindCollapse(collapseItemProvider);
144
- watch(isShow, value => {
145
- value ? openPanel() : closePanel();
146
- });
151
+ }
147
152
  return {
148
- n,
149
- start,
150
- classes,
151
- showContent,
152
153
  isShow,
154
+ showContent,
153
155
  offset,
154
156
  divider,
155
157
  elevation,
156
- toggle,
157
158
  contentEl,
159
+ n,
160
+ start,
161
+ classes,
162
+ toggle,
158
163
  transitionend,
159
164
  formatElevation
160
165
  };
@@ -4,6 +4,7 @@ import { call, createNamespace } from '../utils/components.mjs';
4
4
  import { padStart } from '../utils/shared.mjs';
5
5
  import { toNumber, requestAnimationFrame, cancelAnimationFrame } from '@varlet/shared';
6
6
  var {
7
+ name,
7
8
  n
8
9
  } = createNamespace('countdown');
9
10
  var SECOND = 1000;
@@ -18,7 +19,7 @@ function __render__(_ctx, _cache) {
18
19
  }
19
20
 
20
21
  var __sfc__ = defineComponent({
21
- name: 'VarCountdown',
22
+ name,
22
23
  props,
23
24
  setup(props) {
24
25
  var showTime = ref('');
@@ -34,7 +35,29 @@ var __sfc__ = defineComponent({
34
35
  var handle = 0;
35
36
  var remainingTime = 0;
36
37
  var cacheIsStart;
37
- var parseFormat = (format, time) => {
38
+ watch(() => props.time, () => {
39
+ reset();
40
+ if (props.autoStart) {
41
+ start();
42
+ }
43
+ }, {
44
+ immediate: true
45
+ });
46
+ onActivated(() => {
47
+ if (cacheIsStart == null) {
48
+ return;
49
+ }
50
+ isStart = cacheIsStart;
51
+ if (isStart === true) {
52
+ start(true);
53
+ }
54
+ });
55
+ onDeactivated(() => {
56
+ cacheIsStart = isStart;
57
+ pause();
58
+ });
59
+ onUnmounted(pause);
60
+ function parseFormat(format, time) {
38
61
  var scannedTimes = Object.values(time);
39
62
  var scannedFormats = ['DD', 'HH', 'mm', 'ss'];
40
63
  var padValues = [24, 60, 60, 1000];
@@ -56,8 +79,8 @@ var __sfc__ = defineComponent({
56
79
  }
57
80
  }
58
81
  return format;
59
- };
60
- var displayTime = durationTime => {
82
+ }
83
+ function displayTime(durationTime) {
61
84
  var days = Math.floor(durationTime / DAY);
62
85
  var hours = Math.floor(durationTime % DAY / HOUR);
63
86
  var minutes = Math.floor(durationTime % HOUR / MINUTE);
@@ -73,8 +96,8 @@ var __sfc__ = defineComponent({
73
96
  timeData.value = time;
74
97
  call(props.onChange, timeData.value);
75
98
  showTime.value = parseFormat(props.format, time);
76
- };
77
- var countdown = () => {
99
+ }
100
+ function countdown() {
78
101
  var {
79
102
  time,
80
103
  onEnd
@@ -95,10 +118,10 @@ var __sfc__ = defineComponent({
95
118
  if (isStart) {
96
119
  handle = requestAnimationFrame(countdown);
97
120
  }
98
- };
121
+ }
99
122
 
100
123
  // expose
101
- var start = function (resume) {
124
+ function start(resume) {
102
125
  if (resume === void 0) {
103
126
  resume = false;
104
127
  }
@@ -108,43 +131,21 @@ var __sfc__ = defineComponent({
108
131
  isStart = true;
109
132
  endTime = performance.now() + (remainingTime || toNumber(props.time));
110
133
  countdown();
111
- };
134
+ }
112
135
 
113
136
  // expose
114
- var pause = () => {
137
+ function pause() {
115
138
  isStart = false;
116
139
  cancelAnimationFrame(handle);
117
- };
140
+ }
118
141
 
119
142
  // expose
120
- var reset = () => {
143
+ function reset() {
121
144
  endTime = 0;
122
145
  isStart = false;
123
146
  cancelAnimationFrame(handle);
124
147
  countdown();
125
- };
126
- watch(() => props.time, () => {
127
- reset();
128
- if (props.autoStart) {
129
- start();
130
- }
131
- }, {
132
- immediate: true
133
- });
134
- onActivated(() => {
135
- if (cacheIsStart == null) {
136
- return;
137
- }
138
- isStart = cacheIsStart;
139
- if (isStart === true) {
140
- start(true);
141
- }
142
- });
143
- onDeactivated(() => {
144
- cacheIsStart = isStart;
145
- pause();
146
- });
147
- onUnmounted(pause);
148
+ }
148
149
  return {
149
150
  showTime,
150
151
  timeData,
@@ -9,12 +9,13 @@ import { toNumber } from '@varlet/shared';
9
9
  import { toSizeUnit } from '../utils/elements.mjs';
10
10
  import { useForm } from '../form/provide.mjs';
11
11
  import { useValidation, createNamespace, call, formatElevation } from '../utils/components.mjs';
12
+ var SPEED = 100;
13
+ var DELAY = 600;
12
14
  var {
15
+ name,
13
16
  n,
14
17
  classes
15
18
  } = createNamespace('counter');
16
- var SPEED = 100;
17
- var DELAY = 600;
18
19
  import { resolveComponent as _resolveComponent, createVNode as _createVNode, normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, withCtx as _withCtx, vModelText as _vModelText, createElementVNode as _createElementVNode, withDirectives as _withDirectives, mergeProps as _mergeProps, openBlock as _openBlock, createElementBlock as _createElementBlock, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
19
20
  var _withScopeId = n => (_pushScopeId(""), n = n(), _popScopeId(), n);
20
21
  var _hoisted_1 = ["inputmode", "readonly", "disabled"];
@@ -84,7 +85,7 @@ function __render__(_ctx, _cache) {
84
85
  }
85
86
 
86
87
  var __sfc__ = defineComponent({
87
- name: 'VarCounter',
88
+ name,
88
89
  components: {
89
90
  VarButton,
90
91
  VarIcon,
@@ -112,14 +113,41 @@ var __sfc__ = defineComponent({
112
113
  readonly: formReadonly,
113
114
  disabled: formDisabled
114
115
  } = form != null ? form : {};
116
+ var isMax = computed(() => {
117
+ var {
118
+ max,
119
+ modelValue
120
+ } = props;
121
+ return max != null && toNumber(modelValue) >= toNumber(max);
122
+ });
123
+ var isMin = computed(() => {
124
+ var {
125
+ min,
126
+ modelValue
127
+ } = props;
128
+ return min != null && toNumber(modelValue) <= toNumber(min);
129
+ });
115
130
  var incrementTimer;
116
131
  var decrementTimer;
117
132
  var incrementDelayTimer;
118
133
  var decrementDelayTimer;
134
+ var counterProvider = {
135
+ reset,
136
+ validate,
137
+ resetValidation
138
+ };
139
+ call(bindForm, counterProvider);
140
+ watch(() => props.modelValue, newValue => {
141
+ setNormalizedValue(normalizeValue(String(newValue)));
142
+ call(props.onChange, toNumber(newValue));
143
+ });
144
+ setNormalizedValue(normalizeValue(String(props.modelValue)));
119
145
 
120
146
  // expose
121
- var validate = () => v(props.rules, props.modelValue);
122
- var validateWithTrigger = trigger => {
147
+ function validate() {
148
+ return v(props.rules, props.modelValue);
149
+ }
150
+ function validateWithTrigger(trigger) {
123
151
  nextTick(() => {
124
152
  var {
125
153
  validateTrigger,
@@ -128,36 +156,17 @@ var __sfc__ = defineComponent({
128
156
  } = props;
129
157
  vt(validateTrigger, trigger, rules, modelValue);
130
158
  });
131
- };
159
+ }
132
160
 
133
161
  // expose
134
- var reset = () => {
162
+ function reset() {
135
163
  var {
136
164
  min
137
165
  } = props;
138
166
  call(props['onUpdate:modelValue'], min != null ? toNumber(min) : 0);
139
167
  resetValidation();
140
- };
141
- var counterProvider = {
142
- reset,
143
- validate,
144
- resetValidation
145
- };
146
- var isMax = computed(() => {
147
- var {
148
- max,
149
- modelValue
150
- } = props;
151
- return max != null && toNumber(modelValue) >= toNumber(max);
152
- });
153
- var isMin = computed(() => {
154
- var {
155
- min,
156
- modelValue
157
- } = props;
158
- return min != null && toNumber(modelValue) <= toNumber(min);
159
- });
160
- var normalizeValue = value => {
168
+ }
169
+ function normalizeValue(value) {
161
170
  var {
162
171
  decimalLength,
163
172
  max,
@@ -175,8 +184,8 @@ var __sfc__ = defineComponent({
175
184
  value = num.toFixed(toNumber(decimalLength));
176
185
  }
177
186
  return value;
178
- };
179
- var handleChange = event => {
187
+ }
188
+ function handleChange(event) {
180
189
  var {
181
190
  lazyChange,
182
191
  onBeforeChange
@@ -187,8 +196,8 @@ var __sfc__ = defineComponent({
187
196
  var normalizedValue = normalizeValue(value);
188
197
  lazyChange ? call(onBeforeChange, toNumber(normalizedValue), change) : setNormalizedValue(normalizedValue);
189
198
  validateWithTrigger('onInputChange');
190
- };
191
- var decrement = () => {
199
+ }
200
+ function decrement() {
192
201
  var {
193
202
  disabled,
194
203
  readonly,
@@ -216,8 +225,8 @@ var __sfc__ = defineComponent({
216
225
  setNormalizedValue(normalizedValue);
217
226
  validateWithTrigger('onDecrement');
218
227
  }
219
- };
220
- var increment = () => {
228
+ }
229
+ function increment() {
221
230
  var {
222
231
  disabled,
223
232
  readonly,
@@ -245,8 +254,8 @@ var __sfc__ = defineComponent({
245
254
  setNormalizedValue(normalizedValue);
246
255
  validateWithTrigger('onIncrement');
247
256
  }
248
- };
249
- var pressDecrement = () => {
257
+ }
258
+ function pressDecrement() {
250
259
  var {
251
260
  press,
252
261
  lazyChange
@@ -257,8 +266,8 @@ var __sfc__ = defineComponent({
257
266
  decrementDelayTimer = window.setTimeout(() => {
258
267
  continuedDecrement();
259
268
  }, DELAY);
260
- };
261
- var pressIncrement = () => {
269
+ }
270
+ function pressIncrement() {
262
271
  var {
263
272
  press,
264
273
  lazyChange
@@ -269,52 +278,46 @@ var __sfc__ = defineComponent({
269
278
  incrementDelayTimer = window.setTimeout(() => {
270
279
  continuedIncrement();
271
280
  }, DELAY);
272
- };
273
- var releaseDecrement = () => {
281
+ }
282
+ function releaseDecrement() {
274
283
  decrementTimer && clearTimeout(decrementTimer);
275
284
  decrementDelayTimer && clearTimeout(decrementDelayTimer);
276
- };
277
- var releaseIncrement = () => {
285
+ }
286
+ function releaseIncrement() {
278
287
  incrementTimer && clearTimeout(incrementTimer);
279
288
  incrementDelayTimer && clearTimeout(incrementDelayTimer);
280
- };
281
- var continuedIncrement = () => {
289
+ }
290
+ function continuedIncrement() {
282
291
  incrementTimer = window.setTimeout(() => {
283
292
  increment();
284
293
  continuedIncrement();
285
294
  }, SPEED);
286
- };
287
- var continuedDecrement = () => {
295
+ }
296
+ function continuedDecrement() {
288
297
  decrementTimer = window.setTimeout(() => {
289
298
  decrement();
290
299
  continuedDecrement();
291
300
  }, SPEED);
292
- };
293
- var setNormalizedValue = normalizedValue => {
301
+ }
302
+ function setNormalizedValue(normalizedValue) {
294
303
  inputValue.value = normalizedValue;
295
304
  var normalizedValueNum = toNumber(normalizedValue);
296
305
  call(props['onUpdate:modelValue'], normalizedValueNum);
297
- };
298
- var change = value => {
306
+ }
307
+ function change(value) {
299
308
  setNormalizedValue(normalizeValue(String(value)));
300
309
  validateWithTrigger('onLazyChange');
301
- };
302
- call(bindForm, counterProvider);
303
- watch(() => props.modelValue, newValue => {
304
- setNormalizedValue(normalizeValue(String(newValue)));
305
- call(props.onChange, toNumber(newValue));
306
- });
307
- setNormalizedValue(normalizeValue(String(props.modelValue)));
310
+ }
308
311
  return {
309
- n,
310
- classes,
311
- formatElevation,
312
312
  inputValue,
313
313
  errorMessage,
314
314
  formDisabled,
315
315
  formReadonly,
316
316
  isMax,
317
317
  isMin,
318
+ n,
319
+ classes,
320
+ formatElevation,
318
321
  validate,
319
322
  reset,
320
323
  resetValidation,