@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.
- package/es/action-sheet/ActionSheet.mjs +20 -16
- package/es/app-bar/AppBar.mjs +10 -9
- package/es/avatar/Avatar.mjs +16 -15
- package/es/avatar-group/AvatarGroup.mjs +4 -3
- package/es/back-top/BackTop.mjs +20 -19
- package/es/badge/Badge.mjs +4 -3
- package/es/bottom-navigation/BottomNavigation.mjs +70 -63
- package/es/bottom-navigation-item/BottomNavigationItem.mjs +13 -10
- package/es/breadcrumb/Breadcrumb.mjs +5 -4
- package/es/breadcrumbs/Breadcrumbs.mjs +2 -1
- package/es/button/Button.mjs +10 -9
- package/es/button-group/ButtonGroup.mjs +2 -1
- package/es/card/Card.mjs +28 -26
- package/es/cell/Cell.mjs +5 -4
- package/es/checkbox/Checkbox.mjs +32 -29
- package/es/checkbox-group/CheckboxGroup.mjs +45 -40
- package/es/chip/Chip.mjs +6 -5
- package/es/col/Col.mjs +21 -16
- package/es/collapse/Collapse.mjs +30 -29
- package/es/collapse-item/CollapseItem.mjs +52 -47
- package/es/countdown/Countdown.mjs +36 -35
- package/es/counter/Counter.mjs +63 -60
- package/es/date-picker/DatePicker.mjs +67 -63
- package/es/dialog/Dialog.mjs +39 -29
- package/es/divider/Divider.mjs +6 -9
- package/es/drag/Drag.mjs +47 -45
- package/es/ellipsis/Ellipsis.mjs +6 -5
- package/es/fab/Fab.mjs +21 -20
- package/es/field-decorator/FieldDecorator.mjs +14 -13
- package/es/form/Form.mjs +41 -36
- package/es/form-details/FormDetails.mjs +2 -1
- package/es/hover-overlay/HoverOverlay.mjs +6 -7
- package/es/icon/Icon.mjs +14 -12
- package/es/image/Image.mjs +14 -12
- package/es/image-preview/ImagePreview.mjs +51 -50
- package/es/index-anchor/IndexAnchor.mjs +15 -12
- package/es/index-bar/IndexBar.mjs +68 -65
- package/es/index.bundle.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/input/Input.mjs +63 -56
- package/es/link/Link.mjs +6 -5
- package/es/list/List.mjs +55 -46
- package/es/loading/Loading.mjs +11 -8
- package/es/loading-bar/LoadingBar.mjs +2 -1
- package/es/menu/Menu.mjs +2 -1
- package/es/option/Option.mjs +14 -11
- package/es/overlay/Overlay.mjs +18 -18
- package/es/pagination/Pagination.mjs +67 -64
- package/es/paper/Paper.mjs +4 -3
- package/es/picker/Picker.mjs +95 -85
- package/es/popup/Popup.mjs +26 -23
- package/es/progress/Progress.mjs +9 -8
- package/es/pull-refresh/PullRefresh.mjs +54 -51
- package/es/radio/Radio.mjs +25 -22
- package/es/radio-group/RadioGroup.mjs +30 -25
- package/es/rate/Rate.mjs +35 -28
- package/es/result/Result.mjs +6 -5
- package/es/row/Row.mjs +20 -18
- package/es/row/props.mjs +1 -1
- package/es/select/Select.mjs +57 -54
- package/es/skeleton/Skeleton.mjs +8 -9
- package/es/slider/Slider.mjs +86 -79
- package/es/snackbar/Snackbar.mjs +4 -3
- package/es/snackbar/style/index.mjs +1 -1
- package/es/space/Space.mjs +5 -2
- package/es/step/Step.mjs +7 -4
- package/es/steps/Steps.mjs +5 -4
- package/es/sticky/Sticky.mjs +30 -27
- package/es/style-provider/StyleProvider.mjs +2 -1
- package/es/swipe/Swipe.mjs +99 -90
- package/es/swipe-item/SwipeItem.mjs +5 -4
- package/es/switch/Switch.mjs +22 -17
- package/es/tab/Tab.mjs +16 -12
- package/es/tab-item/TabItem.mjs +7 -6
- package/es/table/Table.mjs +8 -9
- package/es/tabs/Tabs.mjs +57 -52
- package/es/tabs-items/TabsItems.mjs +38 -29
- package/es/time-picker/TimePicker.mjs +63 -60
- package/es/tooltip/Tooltip.mjs +3 -2
- package/es/uploader/Uploader.mjs +100 -85
- package/es/utils/components.mjs +2 -1
- package/es/utils/shared.mjs +0 -1
- package/es/varlet.esm.js +9605 -8923
- package/es/watermark/Watermark.mjs +29 -26
- package/highlight/web-types.en-US.json +3 -3
- package/highlight/web-types.zh-CN.json +3 -3
- package/lib/varlet.cjs.js +2388 -2118
- package/package.json +12 -14
- package/types/row.d.ts +1 -1
- package/types/swipe.d.ts +12 -3
- package/umd/varlet.js +4 -4
package/es/picker/Picker.mjs
CHANGED
|
@@ -4,11 +4,11 @@ import { defineComponent, watch, ref, computed, Transition, toRaw } from 'vue';
|
|
|
4
4
|
import { props } from './props.mjs';
|
|
5
5
|
import { useTouch } from '@varlet/use';
|
|
6
6
|
import { clamp, clampArrayRange, isArray } from '@varlet/shared';
|
|
7
|
-
import { dt } from '../utils/shared.mjs';
|
|
8
7
|
import { toPxNum, getTranslateY } from '../utils/elements.mjs';
|
|
9
8
|
import { pack } from '../locale/index.mjs';
|
|
10
9
|
import { createNamespace, call } from '../utils/components.mjs';
|
|
11
10
|
var {
|
|
11
|
+
name,
|
|
12
12
|
n,
|
|
13
13
|
classes
|
|
14
14
|
} = createNamespace('picker');
|
|
@@ -53,19 +53,28 @@ function __render__(_ctx, _cache) {
|
|
|
53
53
|
"text-color": _ctx.cancelButtonTextColor,
|
|
54
54
|
onClick: _ctx.cancel
|
|
55
55
|
}, {
|
|
56
|
-
default: _withCtx(() =>
|
|
56
|
+
default: _withCtx(() => {
|
|
57
|
+
var _ctx$cancelButtonText;
|
|
58
|
+
return [_createTextVNode(_toDisplayString((_ctx$cancelButtonText = _ctx.cancelButtonText) != null ? _ctx$cancelButtonText : _ctx.pack.pickerCancelButtonText), 1 /* TEXT */)];
|
|
59
|
+
}),
|
|
57
60
|
|
|
58
61
|
_: 1 /* STABLE */
|
|
59
|
-
}, 8 /* PROPS */, ["class", "text-color", "onClick"])]), _renderSlot(_ctx.$slots, "title", {}, () =>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
}, 8 /* PROPS */, ["class", "text-color", "onClick"])]), _renderSlot(_ctx.$slots, "title", {}, () => {
|
|
63
|
+
var _ctx$title;
|
|
64
|
+
return [_createElementVNode("div", {
|
|
65
|
+
class: _normalizeClass(_ctx.n('title'))
|
|
66
|
+
}, _toDisplayString((_ctx$title = _ctx.title) != null ? _ctx$title : _ctx.pack.pickerTitle), 3 /* TEXT, CLASS */)];
|
|
67
|
+
}), _renderSlot(_ctx.$slots, "confirm", {}, () => [_createVNode(_component_var_button, {
|
|
62
68
|
class: _normalizeClass(_ctx.n('confirm-button')),
|
|
63
69
|
text: "",
|
|
64
70
|
"var-picker-cover": "",
|
|
65
71
|
"text-color": _ctx.confirmButtonTextColor,
|
|
66
72
|
onClick: _ctx.confirm
|
|
67
73
|
}, {
|
|
68
|
-
default: _withCtx(() =>
|
|
74
|
+
default: _withCtx(() => {
|
|
75
|
+
var _ctx$confirmButtonTex;
|
|
76
|
+
return [_createTextVNode(_toDisplayString((_ctx$confirmButtonTex = _ctx.confirmButtonText) != null ? _ctx$confirmButtonTex : _ctx.pack.pickerConfirmButtonText), 1 /* TEXT */)];
|
|
77
|
+
}),
|
|
69
78
|
|
|
70
79
|
_: 1 /* STABLE */
|
|
71
80
|
}, 8 /* PROPS */, ["class", "text-color", "onClick"])])], 2 /* CLASS */)) : _createCommentVNode("v-if", true), _createElementVNode("div", {
|
|
@@ -120,7 +129,7 @@ function __render__(_ctx, _cache) {
|
|
|
120
129
|
}
|
|
121
130
|
|
|
122
131
|
var __sfc__ = defineComponent({
|
|
123
|
-
name
|
|
132
|
+
name,
|
|
124
133
|
components: {
|
|
125
134
|
VarButton,
|
|
126
135
|
VarPopup
|
|
@@ -133,7 +142,6 @@ var __sfc__ = defineComponent({
|
|
|
133
142
|
var optionCount = computed(() => toPxNum(props.optionCount));
|
|
134
143
|
var center = computed(() => optionCount.value * optionHeight.value / 2 - optionHeight.value / 2);
|
|
135
144
|
var columnHeight = computed(() => optionCount.value * optionHeight.value);
|
|
136
|
-
var prevIndexes = [];
|
|
137
145
|
var {
|
|
138
146
|
prevY,
|
|
139
147
|
moveY,
|
|
@@ -142,57 +150,68 @@ var __sfc__ = defineComponent({
|
|
|
142
150
|
moveTouch,
|
|
143
151
|
endTouch
|
|
144
152
|
} = useTouch();
|
|
145
|
-
var
|
|
153
|
+
var prevIndexes = [];
|
|
154
|
+
watch(() => props.columns, newValue => {
|
|
155
|
+
scrollColumns.value = props.cascade ? normalizeCascadeColumns(toRaw(newValue)) : normalizeNormalColumns(toRaw(newValue));
|
|
156
|
+
var {
|
|
157
|
+
indexes
|
|
158
|
+
} = getPicked();
|
|
159
|
+
prevIndexes = [...indexes];
|
|
160
|
+
}, {
|
|
161
|
+
immediate: true,
|
|
162
|
+
deep: true
|
|
163
|
+
});
|
|
164
|
+
function setScrollEl(el, scrollColumn) {
|
|
146
165
|
scrollColumn.scrollEl = el;
|
|
147
|
-
}
|
|
148
|
-
|
|
166
|
+
}
|
|
167
|
+
function handlePopupUpdateShow(value) {
|
|
149
168
|
call(props['onUpdate:show'], value);
|
|
150
|
-
}
|
|
151
|
-
|
|
169
|
+
}
|
|
170
|
+
function clampTranslate(scrollColumn) {
|
|
152
171
|
var minTranslate = center.value - scrollColumn.column.texts.length * optionHeight.value;
|
|
153
172
|
var maxTranslate = optionHeight.value + center.value;
|
|
154
173
|
scrollColumn.translate = clamp(scrollColumn.translate, minTranslate, maxTranslate);
|
|
155
|
-
}
|
|
156
|
-
|
|
174
|
+
}
|
|
175
|
+
function getTargetIndex(scrollColumn, viewTranslate) {
|
|
157
176
|
var index = Math.round((center.value - viewTranslate) / optionHeight.value);
|
|
158
177
|
return clampArrayRange(index, scrollColumn.column.texts);
|
|
159
|
-
}
|
|
160
|
-
|
|
178
|
+
}
|
|
179
|
+
function updateTranslate(scrollColumn) {
|
|
161
180
|
scrollColumn.translate = center.value - scrollColumn.index * optionHeight.value;
|
|
162
181
|
return scrollColumn.translate;
|
|
163
|
-
}
|
|
164
|
-
|
|
182
|
+
}
|
|
183
|
+
function getPicked() {
|
|
165
184
|
var texts = scrollColumns.value.map(scrollColumn => scrollColumn.column.texts[scrollColumn.index]);
|
|
166
185
|
var indexes = scrollColumns.value.map(scrollColumn => scrollColumn.index);
|
|
167
186
|
return {
|
|
168
187
|
texts,
|
|
169
188
|
indexes
|
|
170
189
|
};
|
|
171
|
-
}
|
|
172
|
-
|
|
190
|
+
}
|
|
191
|
+
function scrollTo(scrollColumn, duration) {
|
|
173
192
|
if (duration === void 0) {
|
|
174
193
|
duration = 0;
|
|
175
194
|
}
|
|
176
195
|
updateTranslate(scrollColumn);
|
|
177
196
|
scrollColumn.duration = duration;
|
|
178
|
-
}
|
|
179
|
-
|
|
197
|
+
}
|
|
198
|
+
function momentum(scrollColumn, distance, duration) {
|
|
180
199
|
scrollColumn.translate += Math.abs(distance / duration) / 0.003 * (distance < 0 ? -1 : 1);
|
|
181
|
-
}
|
|
182
|
-
|
|
200
|
+
}
|
|
201
|
+
function handleClick(scrollColumn, index) {
|
|
183
202
|
if (dragging.value) {
|
|
184
203
|
return;
|
|
185
204
|
}
|
|
186
205
|
scrollColumn.index = index;
|
|
187
206
|
scrollColumn.scrolling = true;
|
|
188
207
|
scrollTo(scrollColumn, TRANSITION_DURATION);
|
|
189
|
-
}
|
|
190
|
-
|
|
208
|
+
}
|
|
209
|
+
function handleTouchstart(event, scrollColumn) {
|
|
191
210
|
scrollColumn.touching = true;
|
|
192
211
|
scrollColumn.translate = getTranslateY(scrollColumn.scrollEl);
|
|
193
212
|
startTouch(event);
|
|
194
|
-
}
|
|
195
|
-
|
|
213
|
+
}
|
|
214
|
+
function handleTouchmove(event, scrollColumn) {
|
|
196
215
|
if (!scrollColumn.touching) {
|
|
197
216
|
return;
|
|
198
217
|
}
|
|
@@ -207,8 +226,8 @@ var __sfc__ = defineComponent({
|
|
|
207
226
|
scrollColumn.momentumTime = now;
|
|
208
227
|
scrollColumn.momentumPrevY = scrollColumn.translate;
|
|
209
228
|
}
|
|
210
|
-
}
|
|
211
|
-
|
|
229
|
+
}
|
|
230
|
+
function handleTouchend(scrollColumn) {
|
|
212
231
|
endTouch();
|
|
213
232
|
scrollColumn.touching = false;
|
|
214
233
|
scrollColumn.prevY = 0;
|
|
@@ -228,39 +247,41 @@ var __sfc__ = defineComponent({
|
|
|
228
247
|
if (!scrollColumn.scrolling) {
|
|
229
248
|
change(scrollColumn);
|
|
230
249
|
}
|
|
231
|
-
}
|
|
232
|
-
|
|
250
|
+
}
|
|
251
|
+
function handleTransitionend(scrollColumn) {
|
|
233
252
|
scrollColumn.scrolling = false;
|
|
234
253
|
change(scrollColumn);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
254
|
+
}
|
|
255
|
+
function normalizeNormalColumns(normalColumns) {
|
|
256
|
+
return normalColumns.map((column, columnIndex) => {
|
|
257
|
+
var _normalColumn$initial;
|
|
258
|
+
var normalColumn = isArray(column) ? {
|
|
259
|
+
texts: column
|
|
260
|
+
} : column;
|
|
261
|
+
var scrollColumn = {
|
|
262
|
+
id: sid++,
|
|
263
|
+
prevY: 0,
|
|
264
|
+
momentumPrevY: 0,
|
|
265
|
+
touching: false,
|
|
266
|
+
translate: center.value,
|
|
267
|
+
index: (_normalColumn$initial = normalColumn.initialIndex) != null ? _normalColumn$initial : 0,
|
|
268
|
+
columnIndex,
|
|
269
|
+
duration: 0,
|
|
270
|
+
momentumTime: 0,
|
|
271
|
+
column: normalColumn,
|
|
272
|
+
scrollEl: null,
|
|
273
|
+
scrolling: false
|
|
274
|
+
};
|
|
275
|
+
scrollTo(scrollColumn);
|
|
276
|
+
return scrollColumn;
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
function normalizeCascadeColumns(cascadeColumns) {
|
|
259
280
|
var scrollColumns = [];
|
|
260
281
|
createChildren(scrollColumns, cascadeColumns, 0, true);
|
|
261
282
|
return scrollColumns;
|
|
262
|
-
}
|
|
263
|
-
|
|
283
|
+
}
|
|
284
|
+
function createChildren(scrollColumns, children, columnIndex, initial) {
|
|
264
285
|
if (initial === void 0) {
|
|
265
286
|
initial = false;
|
|
266
287
|
}
|
|
@@ -288,18 +309,18 @@ var __sfc__ = defineComponent({
|
|
|
288
309
|
scrollTo(scrollColumn);
|
|
289
310
|
createChildren(scrollColumns, scrollColumn.columns[scrollColumn.index].children, columnIndex + 1, initial);
|
|
290
311
|
}
|
|
291
|
-
}
|
|
292
|
-
|
|
312
|
+
}
|
|
313
|
+
function rebuildChildren(scrollColumn) {
|
|
293
314
|
scrollColumns.value.splice(scrollColumns.value.indexOf(scrollColumn) + 1);
|
|
294
315
|
createChildren(scrollColumns.value, scrollColumn.columns[scrollColumn.index].children, scrollColumn.columnIndex + 1);
|
|
295
|
-
}
|
|
296
|
-
|
|
316
|
+
}
|
|
317
|
+
function isSamePicked() {
|
|
297
318
|
var {
|
|
298
319
|
indexes
|
|
299
320
|
} = getPicked();
|
|
300
321
|
return indexes.every((index, idx) => index === prevIndexes[idx]);
|
|
301
|
-
}
|
|
302
|
-
|
|
322
|
+
}
|
|
323
|
+
function change(scrollColumn) {
|
|
303
324
|
var {
|
|
304
325
|
cascade,
|
|
305
326
|
onChange
|
|
@@ -322,8 +343,8 @@ var __sfc__ = defineComponent({
|
|
|
322
343
|
} = getPicked();
|
|
323
344
|
prevIndexes = [...indexes];
|
|
324
345
|
call(onChange, texts, indexes);
|
|
325
|
-
}
|
|
326
|
-
|
|
346
|
+
}
|
|
347
|
+
function stopScroll() {
|
|
327
348
|
if (props.cascade) {
|
|
328
349
|
var currentScrollColumn = scrollColumns.value.find(scrollColumn => scrollColumn.scrolling);
|
|
329
350
|
if (currentScrollColumn) {
|
|
@@ -338,10 +359,10 @@ var __sfc__ = defineComponent({
|
|
|
338
359
|
scrollTo(scrollColumn);
|
|
339
360
|
});
|
|
340
361
|
}
|
|
341
|
-
}
|
|
362
|
+
}
|
|
342
363
|
|
|
343
364
|
// expose
|
|
344
|
-
|
|
365
|
+
function confirm() {
|
|
345
366
|
stopScroll();
|
|
346
367
|
var {
|
|
347
368
|
texts,
|
|
@@ -349,10 +370,10 @@ var __sfc__ = defineComponent({
|
|
|
349
370
|
} = getPicked();
|
|
350
371
|
prevIndexes = [...indexes];
|
|
351
372
|
call(props.onConfirm, texts, indexes);
|
|
352
|
-
}
|
|
373
|
+
}
|
|
353
374
|
|
|
354
375
|
// expose
|
|
355
|
-
|
|
376
|
+
function cancel() {
|
|
356
377
|
stopScroll();
|
|
357
378
|
var {
|
|
358
379
|
texts,
|
|
@@ -360,20 +381,8 @@ var __sfc__ = defineComponent({
|
|
|
360
381
|
} = getPicked();
|
|
361
382
|
prevIndexes = [...indexes];
|
|
362
383
|
call(props.onCancel, texts, indexes);
|
|
363
|
-
}
|
|
364
|
-
watch(() => props.columns, newValue => {
|
|
365
|
-
scrollColumns.value = props.cascade ? normalizeCascadeColumns(toRaw(newValue)) : normalizeNormalColumns(toRaw(newValue));
|
|
366
|
-
var {
|
|
367
|
-
indexes
|
|
368
|
-
} = getPicked();
|
|
369
|
-
prevIndexes = [...indexes];
|
|
370
|
-
}, {
|
|
371
|
-
immediate: true,
|
|
372
|
-
deep: true
|
|
373
|
-
});
|
|
384
|
+
}
|
|
374
385
|
return {
|
|
375
|
-
n,
|
|
376
|
-
classes,
|
|
377
386
|
pack,
|
|
378
387
|
optionHeight,
|
|
379
388
|
optionCount,
|
|
@@ -381,6 +390,8 @@ var __sfc__ = defineComponent({
|
|
|
381
390
|
columnHeight,
|
|
382
391
|
center,
|
|
383
392
|
Transition,
|
|
393
|
+
n,
|
|
394
|
+
classes,
|
|
384
395
|
setScrollEl,
|
|
385
396
|
handlePopupUpdateShow,
|
|
386
397
|
handleTouchstart,
|
|
@@ -389,7 +400,6 @@ var __sfc__ = defineComponent({
|
|
|
389
400
|
handleTransitionend,
|
|
390
401
|
confirm,
|
|
391
402
|
cancel,
|
|
392
|
-
dt,
|
|
393
403
|
handleClick
|
|
394
404
|
};
|
|
395
405
|
}
|
package/es/popup/Popup.mjs
CHANGED
|
@@ -13,11 +13,12 @@ function _isSlot(s) {
|
|
|
13
13
|
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !_isVNode(s);
|
|
14
14
|
}
|
|
15
15
|
var {
|
|
16
|
+
name,
|
|
16
17
|
n,
|
|
17
18
|
classes
|
|
18
19
|
} = createNamespace('popup');
|
|
19
20
|
export default defineComponent({
|
|
20
|
-
name
|
|
21
|
+
name,
|
|
21
22
|
inheritAttrs: false,
|
|
22
23
|
props,
|
|
23
24
|
setup(props, _ref) {
|
|
@@ -35,7 +36,17 @@ export default defineComponent({
|
|
|
35
36
|
var {
|
|
36
37
|
bindPopupItems
|
|
37
38
|
} = usePopupItems();
|
|
38
|
-
|
|
39
|
+
useLock(() => props.show, () => props.lockScroll);
|
|
40
|
+
watch(() => props.show, newValue => {
|
|
41
|
+
newValue ? call(props.onOpen) : call(props.onClose);
|
|
42
|
+
});
|
|
43
|
+
bindPopupItems({
|
|
44
|
+
show: computed(() => props.show)
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// internal for Dialog
|
|
48
|
+
useRouteListener(() => call(props.onRouteChange));
|
|
49
|
+
function hidePopup() {
|
|
39
50
|
var {
|
|
40
51
|
closeOnClickOverlay,
|
|
41
52
|
onClickOverlay
|
|
@@ -45,8 +56,8 @@ export default defineComponent({
|
|
|
45
56
|
return;
|
|
46
57
|
}
|
|
47
58
|
call(props['onUpdate:show'], false);
|
|
48
|
-
}
|
|
49
|
-
|
|
59
|
+
}
|
|
60
|
+
function renderOverlay() {
|
|
50
61
|
var {
|
|
51
62
|
overlayClass = '',
|
|
52
63
|
overlayStyle
|
|
@@ -58,14 +69,16 @@ export default defineComponent({
|
|
|
58
69
|
}, overlayStyle),
|
|
59
70
|
"onClick": hidePopup
|
|
60
71
|
}, null);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
}
|
|
73
|
+
function renderContent() {
|
|
74
|
+
return _withDirectives(_createVNode("div", _mergeProps({
|
|
75
|
+
"class": classes(n('content'), n("--" + props.position), [props.defaultStyle, n('--content-background-color')], [props.defaultStyle, n('$-elevation--3')], [props.safeArea, n('--safe-area')], [props.safeAreaTop, n('--safe-area-top')]),
|
|
76
|
+
"style": {
|
|
77
|
+
zIndex: zIndex.value
|
|
78
|
+
}
|
|
79
|
+
}, attrs), [rendered.value && call(slots.default)]), [[_vShow, props.show]]);
|
|
80
|
+
}
|
|
81
|
+
function renderPopup() {
|
|
69
82
|
var _slot;
|
|
70
83
|
return _createVNode(Transition, {
|
|
71
84
|
"name": n('$-fade'),
|
|
@@ -83,17 +96,7 @@ export default defineComponent({
|
|
|
83
96
|
default: () => [_slot]
|
|
84
97
|
})]), [[_vShow, props.show]])]
|
|
85
98
|
});
|
|
86
|
-
}
|
|
87
|
-
useLock(() => props.show, () => props.lockScroll);
|
|
88
|
-
watch(() => props.show, newValue => {
|
|
89
|
-
newValue ? call(props.onOpen) : call(props.onClose);
|
|
90
|
-
});
|
|
91
|
-
bindPopupItems({
|
|
92
|
-
show: computed(() => props.show)
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// internal for Dialog
|
|
96
|
-
useRouteListener(() => call(props.onRouteChange));
|
|
99
|
+
}
|
|
97
100
|
return () => {
|
|
98
101
|
var {
|
|
99
102
|
teleport
|
package/es/progress/Progress.mjs
CHANGED
|
@@ -3,7 +3,11 @@ import { props } from './props.mjs';
|
|
|
3
3
|
import { toNumber } from '@varlet/shared';
|
|
4
4
|
import { toSizeUnit, toPxNum } from '../utils/elements.mjs';
|
|
5
5
|
import { createNamespace } from '../utils/components.mjs';
|
|
6
|
+
var ONE_HUNDRED = 100;
|
|
7
|
+
var RADIUS = 20;
|
|
8
|
+
var CIRCUMFERENCE = 2 * Math.PI * RADIUS;
|
|
6
9
|
var {
|
|
10
|
+
name,
|
|
7
11
|
n,
|
|
8
12
|
classes
|
|
9
13
|
} = createNamespace('progress');
|
|
@@ -91,12 +95,9 @@ function __render__(_ctx, _cache) {
|
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
var __sfc__ = defineComponent({
|
|
94
|
-
name
|
|
98
|
+
name,
|
|
95
99
|
props,
|
|
96
100
|
setup(props) {
|
|
97
|
-
var ONE_HUNDRED = 100;
|
|
98
|
-
var RADIUS = 20;
|
|
99
|
-
var CIRCUMFERENCE = 2 * Math.PI * RADIUS;
|
|
100
101
|
var linearProps = computed(() => {
|
|
101
102
|
var value = toNumber(props.value);
|
|
102
103
|
var width = value > ONE_HUNDRED ? ONE_HUNDRED : value;
|
|
@@ -125,13 +126,13 @@ var __sfc__ = defineComponent({
|
|
|
125
126
|
};
|
|
126
127
|
});
|
|
127
128
|
return {
|
|
128
|
-
n,
|
|
129
|
-
classes,
|
|
130
|
-
toSizeUnit,
|
|
131
129
|
linearProps,
|
|
132
130
|
CIRCUMFERENCE,
|
|
133
131
|
RADIUS,
|
|
134
|
-
circleProps
|
|
132
|
+
circleProps,
|
|
133
|
+
n,
|
|
134
|
+
classes,
|
|
135
|
+
toSizeUnit
|
|
135
136
|
};
|
|
136
137
|
}
|
|
137
138
|
});
|
|
@@ -8,6 +8,7 @@ import { isNumber, isString, toNumber, getRect } from '@varlet/shared';
|
|
|
8
8
|
import { call, createNamespace } from '../utils/components.mjs';
|
|
9
9
|
import { useEventListener, onSmartMounted } from '@varlet/use';
|
|
10
10
|
var {
|
|
11
|
+
name,
|
|
11
12
|
n,
|
|
12
13
|
classes
|
|
13
14
|
} = createNamespace('pull-refresh');
|
|
@@ -40,7 +41,7 @@ function __render__(_ctx, _cache) {
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
var __sfc__ = defineComponent({
|
|
43
|
-
name
|
|
44
|
+
name,
|
|
44
45
|
components: {
|
|
45
46
|
VarIcon
|
|
46
47
|
},
|
|
@@ -54,12 +55,37 @@ var __sfc__ = defineComponent({
|
|
|
54
55
|
var iconName = ref('arrow-down');
|
|
55
56
|
var refreshStatus = ref('default');
|
|
56
57
|
var isEnd = ref(false);
|
|
58
|
+
var maxDistance = computed(() => Math.abs(2 * controlPosition.value));
|
|
59
|
+
var isSuccess = computed(() => refreshStatus.value === 'success');
|
|
60
|
+
var isTouchable = computed(() => refreshStatus.value !== 'loading' && refreshStatus.value !== 'success' && !props.disabled);
|
|
61
|
+
var controlStyle = computed(() => ({
|
|
62
|
+
transform: "translate3d(0px, " + (isString(distance.value) ? distance.value : distance.value + "px") + ", 0px) translate(-50%, 0)",
|
|
63
|
+
transition: isEnd.value ? "transform " + props.animationDuration + "ms" : undefined,
|
|
64
|
+
background: isSuccess.value ? props.successBgColor : props.bgColor,
|
|
65
|
+
color: isSuccess.value ? props.successColor : props.color
|
|
66
|
+
}));
|
|
57
67
|
var scroller;
|
|
58
68
|
var eventTargetScroller;
|
|
59
69
|
var startY = 0;
|
|
60
70
|
var deltaY = 0;
|
|
61
|
-
|
|
62
|
-
|
|
71
|
+
watch(() => props.modelValue, newValue => {
|
|
72
|
+
if (newValue === false) {
|
|
73
|
+
isEnd.value = true;
|
|
74
|
+
refreshStatus.value = 'success';
|
|
75
|
+
iconName.value = 'checkbox-marked-circle';
|
|
76
|
+
setTimeout(() => {
|
|
77
|
+
distance.value = controlPosition.value;
|
|
78
|
+
reset();
|
|
79
|
+
}, toNumber(props.successDuration));
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
onSmartMounted(setScroller);
|
|
83
|
+
useEventListener(freshNode, 'touchmove', touchMove);
|
|
84
|
+
function startIconTransition(_x) {
|
|
85
|
+
return _startIconTransition.apply(this, arguments);
|
|
86
|
+
}
|
|
87
|
+
function _startIconTransition() {
|
|
88
|
+
_startIconTransition = _asyncToGenerator(function* (name) {
|
|
63
89
|
if (iconName.value === name) {
|
|
64
90
|
return;
|
|
65
91
|
}
|
|
@@ -68,24 +94,13 @@ var __sfc__ = defineComponent({
|
|
|
68
94
|
window.setTimeout(resolve, ICON_TRANSITION);
|
|
69
95
|
});
|
|
70
96
|
});
|
|
71
|
-
return
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}();
|
|
75
|
-
var isTouchable = computed(() => refreshStatus.value !== 'loading' && refreshStatus.value !== 'success' && !props.disabled);
|
|
76
|
-
var controlStyle = computed(() => ({
|
|
77
|
-
transform: "translate3d(0px, " + (isString(distance.value) ? distance.value : distance.value + "px") + ", 0px) translate(-50%, 0)",
|
|
78
|
-
transition: isEnd.value ? "transform " + props.animationDuration + "ms" : undefined,
|
|
79
|
-
background: isSuccess.value ? props.successBgColor : props.bgColor,
|
|
80
|
-
color: isSuccess.value ? props.successColor : props.color
|
|
81
|
-
}));
|
|
82
|
-
var maxDistance = computed(() => Math.abs(2 * controlPosition.value));
|
|
83
|
-
var isSuccess = computed(() => refreshStatus.value === 'success');
|
|
84
|
-
var lockEvent = action => {
|
|
97
|
+
return _startIconTransition.apply(this, arguments);
|
|
98
|
+
}
|
|
99
|
+
function lockEvent(action) {
|
|
85
100
|
var el = 'classList' in scroller ? scroller : document.body;
|
|
86
101
|
el.classList[action](n() + "--lock");
|
|
87
|
-
}
|
|
88
|
-
|
|
102
|
+
}
|
|
103
|
+
function touchStart(event) {
|
|
89
104
|
if (controlPosition.value === 0) {
|
|
90
105
|
var {
|
|
91
106
|
width
|
|
@@ -95,8 +110,8 @@ var __sfc__ = defineComponent({
|
|
|
95
110
|
startY = event.touches[0].clientY;
|
|
96
111
|
deltaY = 0;
|
|
97
112
|
eventTargetScroller = getParentScroller(event.target);
|
|
98
|
-
}
|
|
99
|
-
|
|
113
|
+
}
|
|
114
|
+
function touchMove(event) {
|
|
100
115
|
if (!isTouchable.value || !eventTargetScroller) {
|
|
101
116
|
return;
|
|
102
117
|
}
|
|
@@ -123,9 +138,12 @@ var __sfc__ = defineComponent({
|
|
|
123
138
|
var moveDistance = (event.touches[0].clientY - startPosition.value) / 2 + controlPosition.value;
|
|
124
139
|
distance.value = moveDistance >= maxDistance.value ? maxDistance.value : moveDistance;
|
|
125
140
|
startIconTransition(distance.value >= maxDistance.value * 0.2 ? 'refresh' : 'arrow-down');
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
141
|
+
}
|
|
142
|
+
function touchEnd() {
|
|
143
|
+
return _touchEnd.apply(this, arguments);
|
|
144
|
+
}
|
|
145
|
+
function _touchEnd() {
|
|
146
|
+
_touchEnd = _asyncToGenerator(function* () {
|
|
129
147
|
if (!isTouchable.value) {
|
|
130
148
|
return;
|
|
131
149
|
}
|
|
@@ -150,46 +168,31 @@ var __sfc__ = defineComponent({
|
|
|
150
168
|
}
|
|
151
169
|
eventTargetScroller = null;
|
|
152
170
|
});
|
|
153
|
-
return
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}();
|
|
157
|
-
var setScroller = () => {
|
|
171
|
+
return _touchEnd.apply(this, arguments);
|
|
172
|
+
}
|
|
173
|
+
function setScroller() {
|
|
158
174
|
scroller = props.target ? getTarget(props.target, 'PullRefresh') : getParentScroller(freshNode.value);
|
|
159
|
-
}
|
|
160
|
-
|
|
175
|
+
}
|
|
176
|
+
function reset() {
|
|
161
177
|
setTimeout(() => {
|
|
162
178
|
refreshStatus.value = 'default';
|
|
163
179
|
iconName.value = 'arrow-down';
|
|
164
180
|
isEnd.value = false;
|
|
165
181
|
}, toNumber(props.animationDuration));
|
|
166
|
-
}
|
|
167
|
-
watch(() => props.modelValue, newValue => {
|
|
168
|
-
if (newValue === false) {
|
|
169
|
-
isEnd.value = true;
|
|
170
|
-
refreshStatus.value = 'success';
|
|
171
|
-
iconName.value = 'checkbox-marked-circle';
|
|
172
|
-
setTimeout(() => {
|
|
173
|
-
distance.value = controlPosition.value;
|
|
174
|
-
reset();
|
|
175
|
-
}, toNumber(props.successDuration));
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
onSmartMounted(setScroller);
|
|
179
|
-
useEventListener(freshNode, 'touchmove', touchMove);
|
|
182
|
+
}
|
|
180
183
|
return {
|
|
181
|
-
n,
|
|
182
|
-
classes,
|
|
183
184
|
ICON_TRANSITION,
|
|
184
185
|
refreshStatus,
|
|
185
186
|
freshNode,
|
|
186
187
|
controlNode,
|
|
187
|
-
touchStart,
|
|
188
|
-
touchMove,
|
|
189
|
-
touchEnd,
|
|
190
188
|
iconName,
|
|
191
189
|
controlStyle,
|
|
192
|
-
isSuccess
|
|
190
|
+
isSuccess,
|
|
191
|
+
n,
|
|
192
|
+
classes,
|
|
193
|
+
touchStart,
|
|
194
|
+
touchMove,
|
|
195
|
+
touchEnd
|
|
193
196
|
};
|
|
194
197
|
}
|
|
195
198
|
});
|