vant 4.0.0-rc.9 → 4.0.1
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/README.md +3 -2
- package/es/back-top/BackTop.d.ts +10 -30
- package/es/back-top/BackTop.mjs +29 -27
- package/es/back-top/index.css +1 -1
- package/es/back-top/index.d.ts +7 -21
- package/es/field/Field.mjs +7 -0
- package/es/index.d.ts +1 -1
- package/es/index.mjs +1 -1
- package/es/list/List.d.ts +4 -0
- package/es/list/List.mjs +3 -2
- package/es/list/index.d.ts +3 -0
- package/es/picker/Picker.mjs +3 -1
- package/es/picker/types.d.ts +1 -0
- package/lib/back-top/BackTop.d.ts +10 -30
- package/lib/back-top/BackTop.js +27 -25
- package/lib/back-top/index.css +1 -1
- package/lib/back-top/index.d.ts +7 -21
- package/lib/field/Field.js +7 -0
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/list/List.d.ts +4 -0
- package/lib/list/List.js +3 -2
- package/lib/list/index.d.ts +3 -0
- package/lib/picker/Picker.js +3 -1
- package/lib/picker/types.d.ts +1 -0
- package/lib/vant.cjs.js +41 -29
- package/lib/vant.es.js +41 -29
- package/lib/vant.js +38 -29
- package/lib/vant.min.js +1 -1
- package/lib/web-types.json +1 -1
- package/package.json +1 -4
package/README.md
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
<img src="https://img.shields.io/github/workflow/status/vant-ui/vant/CI/dev?style=flat-square" alt="CI Status" />
|
12
12
|
<img src="https://img.shields.io/codecov/c/github/vant-ui/vant/dev.svg?style=flat-square&color=#4fc08d" alt="Coverage Status" />
|
13
13
|
<img src="https://img.shields.io/npm/dm/vant.svg?style=flat-square&color=#4fc08d" alt="downloads" />
|
14
|
-
<img src="https://img.badgesize.io/https://unpkg.com/vant
|
14
|
+
<img src="https://img.badgesize.io/https://unpkg.com/vant/lib/vant.min.js?compression=gzip&style=flat-square&label=gzip%20size&color=#4fc08d" alt="Gzip Size" />
|
15
15
|
</p>
|
16
16
|
|
17
17
|
<p align="center">
|
@@ -37,7 +37,8 @@
|
|
37
37
|
- 🍭 Support Tree Shaking
|
38
38
|
- 🍭 Support Custom Theme
|
39
39
|
- 🍭 Support Accessibility (still improving)
|
40
|
-
- 🍭 Support Dark Mode
|
40
|
+
- 🍭 Support Dark Mode
|
41
|
+
- 🍭 Support Nuxt 3
|
41
42
|
- 🍭 Support SSR
|
42
43
|
- 🌍 Support i18n, built-in 20+ languages
|
43
44
|
|
package/es/back-top/BackTop.d.ts
CHANGED
@@ -1,15 +1,9 @@
|
|
1
1
|
import { type PropType, type ExtractPropTypes } from 'vue';
|
2
2
|
export declare const backTopProps: {
|
3
|
-
right:
|
4
|
-
|
5
|
-
default: number;
|
6
|
-
};
|
7
|
-
bottom: {
|
8
|
-
type: (NumberConstructor | StringConstructor)[];
|
9
|
-
default: number;
|
10
|
-
};
|
3
|
+
right: (NumberConstructor | StringConstructor)[];
|
4
|
+
bottom: (NumberConstructor | StringConstructor)[];
|
11
5
|
target: PropType<string | import("vue").RendererElement | null | undefined>;
|
12
|
-
|
6
|
+
offset: {
|
13
7
|
type: (NumberConstructor | StringConstructor)[];
|
14
8
|
default: number;
|
15
9
|
};
|
@@ -20,16 +14,10 @@ export declare const backTopProps: {
|
|
20
14
|
};
|
21
15
|
export type BackTopProps = ExtractPropTypes<typeof backTopProps>;
|
22
16
|
declare const _default: import("vue").DefineComponent<{
|
23
|
-
right:
|
24
|
-
|
25
|
-
default: number;
|
26
|
-
};
|
27
|
-
bottom: {
|
28
|
-
type: (NumberConstructor | StringConstructor)[];
|
29
|
-
default: number;
|
30
|
-
};
|
17
|
+
right: (NumberConstructor | StringConstructor)[];
|
18
|
+
bottom: (NumberConstructor | StringConstructor)[];
|
31
19
|
target: PropType<string | import("vue").RendererElement | null | undefined>;
|
32
|
-
|
20
|
+
offset: {
|
33
21
|
type: (NumberConstructor | StringConstructor)[];
|
34
22
|
default: number;
|
35
23
|
};
|
@@ -38,16 +26,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
38
26
|
default: string;
|
39
27
|
};
|
40
28
|
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "click"[], "click", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
|
41
|
-
right:
|
42
|
-
|
43
|
-
default: number;
|
44
|
-
};
|
45
|
-
bottom: {
|
46
|
-
type: (NumberConstructor | StringConstructor)[];
|
47
|
-
default: number;
|
48
|
-
};
|
29
|
+
right: (NumberConstructor | StringConstructor)[];
|
30
|
+
bottom: (NumberConstructor | StringConstructor)[];
|
49
31
|
target: PropType<string | import("vue").RendererElement | null | undefined>;
|
50
|
-
|
32
|
+
offset: {
|
51
33
|
type: (NumberConstructor | StringConstructor)[];
|
52
34
|
default: number;
|
53
35
|
};
|
@@ -58,9 +40,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
58
40
|
}>> & {
|
59
41
|
onClick?: ((...args: any[]) => any) | undefined;
|
60
42
|
}, {
|
61
|
-
|
62
|
-
right: string | number;
|
43
|
+
offset: string | number;
|
63
44
|
teleport: string | import("vue").RendererElement | null | undefined;
|
64
|
-
visibilityHeight: string | number;
|
65
45
|
}>;
|
66
46
|
export default _default;
|
package/es/back-top/BackTop.mjs
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
import { mergeProps as _mergeProps, createVNode as _createVNode } from "vue";
|
2
|
-
import { ref, computed, Teleport, nextTick, onMounted, defineComponent } from "vue";
|
3
|
-
import { addUnit,
|
2
|
+
import { ref, watch, computed, Teleport, nextTick, onMounted, defineComponent } from "vue";
|
3
|
+
import { addUnit, inBrowser, numericProp, getScrollTop, createNamespace, makeNumericProp } from "../utils/index.mjs";
|
4
4
|
import { throttle } from "../lazyload/vue-lazyload/util.mjs";
|
5
5
|
import { useEventListener, getScrollParent } from "@vant/use";
|
6
6
|
import { Icon } from "../icon/index.mjs";
|
7
7
|
const [name, bem] = createNamespace("back-top");
|
8
8
|
const backTopProps = {
|
9
|
-
right:
|
10
|
-
bottom:
|
9
|
+
right: numericProp,
|
10
|
+
bottom: numericProp,
|
11
11
|
target: [String, Object],
|
12
|
-
|
12
|
+
offset: makeNumericProp(200),
|
13
13
|
teleport: {
|
14
14
|
type: [String, Object],
|
15
15
|
default: "body"
|
@@ -26,50 +26,52 @@ var stdin_default = defineComponent({
|
|
26
26
|
attrs
|
27
27
|
}) {
|
28
28
|
const show = ref(false);
|
29
|
+
const root = ref();
|
29
30
|
const scrollParent = ref();
|
30
|
-
const root = ref(null);
|
31
|
-
let target;
|
32
31
|
const style = computed(() => ({
|
33
32
|
right: addUnit(props.right),
|
34
33
|
bottom: addUnit(props.bottom)
|
35
34
|
}));
|
36
35
|
const onClick = (event) => {
|
36
|
+
var _a;
|
37
37
|
emit("click", event);
|
38
|
-
|
38
|
+
(_a = scrollParent.value) == null ? void 0 : _a.scrollTo({
|
39
39
|
top: 0,
|
40
40
|
behavior: "smooth"
|
41
41
|
});
|
42
42
|
};
|
43
43
|
const scroll = () => {
|
44
|
-
show.value = getScrollTop(
|
44
|
+
show.value = scrollParent.value ? getScrollTop(scrollParent.value) >= props.offset : false;
|
45
45
|
};
|
46
46
|
const getTarget = () => {
|
47
47
|
const {
|
48
|
-
target
|
48
|
+
target
|
49
49
|
} = props;
|
50
|
-
if (typeof
|
51
|
-
const el = document.querySelector(
|
52
|
-
if (
|
53
|
-
|
50
|
+
if (typeof target === "string") {
|
51
|
+
const el = document.querySelector(target);
|
52
|
+
if (el) {
|
53
|
+
return el;
|
54
54
|
}
|
55
|
-
|
55
|
+
if (process.env.NODE_ENV !== "production") {
|
56
|
+
console.error(`[Vant] BackTop: target element "${target}" was not found, the BackTop component will not be rendered.`);
|
57
|
+
}
|
58
|
+
} else {
|
59
|
+
return target;
|
56
60
|
}
|
57
|
-
|
58
|
-
|
61
|
+
};
|
62
|
+
const updateTarget = () => {
|
63
|
+
if (inBrowser) {
|
64
|
+
nextTick(() => {
|
65
|
+
scrollParent.value = props.target ? getTarget() : getScrollParent(root.value);
|
66
|
+
scroll();
|
67
|
+
});
|
59
68
|
}
|
60
|
-
throw Error('[Vant] BackTop: type of prop "target" should be a selector or an element object');
|
61
69
|
};
|
62
|
-
useEventListener("scroll", throttle(scroll,
|
70
|
+
useEventListener("scroll", throttle(scroll, 100), {
|
63
71
|
target: scrollParent
|
64
72
|
});
|
65
|
-
onMounted(
|
66
|
-
|
67
|
-
if (inBrowser) {
|
68
|
-
target = props.target ? getTarget() : getScrollParent(root.value);
|
69
|
-
scrollParent.value = target;
|
70
|
-
}
|
71
|
-
});
|
72
|
-
});
|
73
|
+
onMounted(updateTarget);
|
74
|
+
watch(() => props.target, updateTarget);
|
73
75
|
return () => {
|
74
76
|
const Content = _createVNode("div", _mergeProps({
|
75
77
|
"ref": root,
|
package/es/back-top/index.css
CHANGED
@@ -1 +1 @@
|
|
1
|
-
:root{--van-back-top-size: 40px;--van-back-top-icon-size: 20px;--van-back-top-text-color: #fff;--van-back-top-background: var(--van-blue)}.van-back-top{position:fixed;display:flex;align-items:center;justify-content:center;width:var(--van-back-top-size);height:var(--van-back-top-size);cursor:pointer;color:var(--van-back-top-text-color);border-radius:var(--van-radius-max);box-shadow:0 2px 8px rgba(0,0,0,.12);transform:scale(0);transition
|
1
|
+
:root{--van-back-top-size: 40px;--van-back-top-right: 30px;--van-back-top-bottom: 40px;--van-back-top-icon-size: 20px;--van-back-top-text-color: #fff;--van-back-top-background: var(--van-blue)}.van-back-top{position:fixed;display:flex;align-items:center;justify-content:center;width:var(--van-back-top-size);height:var(--van-back-top-size);right:var(--van-back-top-right);bottom:var(--van-back-top-bottom);cursor:pointer;color:var(--van-back-top-text-color);border-radius:var(--van-radius-max);box-shadow:0 2px 8px rgba(0,0,0,.12);transform:scale(0);transition:var(--van-duration-base) cubic-bezier(.25,.8,.5,1);background-color:var(--van-back-top-background)}.van-back-top:active{opacity:var(--van-active-opacity)}.van-back-top--active{transform:scale(1)}.van-back-top__icon{font-size:var(--van-back-top-icon-size);font-weight:var(--van-font-bold)}
|
package/es/back-top/index.d.ts
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
export declare const BackTop: import("../utils").WithInstall<import("vue").DefineComponent<{
|
2
|
-
right:
|
3
|
-
|
4
|
-
default: number;
|
5
|
-
};
|
6
|
-
bottom: {
|
7
|
-
type: (NumberConstructor | StringConstructor)[];
|
8
|
-
default: number;
|
9
|
-
};
|
2
|
+
right: (NumberConstructor | StringConstructor)[];
|
3
|
+
bottom: (NumberConstructor | StringConstructor)[];
|
10
4
|
target: import("vue").PropType<string | import("vue").RendererElement | null | undefined>;
|
11
|
-
|
5
|
+
offset: {
|
12
6
|
type: (NumberConstructor | StringConstructor)[];
|
13
7
|
default: number;
|
14
8
|
};
|
@@ -17,16 +11,10 @@ export declare const BackTop: import("../utils").WithInstall<import("vue").Defin
|
|
17
11
|
default: string;
|
18
12
|
};
|
19
13
|
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "click"[], "click", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
20
|
-
right:
|
21
|
-
|
22
|
-
default: number;
|
23
|
-
};
|
24
|
-
bottom: {
|
25
|
-
type: (NumberConstructor | StringConstructor)[];
|
26
|
-
default: number;
|
27
|
-
};
|
14
|
+
right: (NumberConstructor | StringConstructor)[];
|
15
|
+
bottom: (NumberConstructor | StringConstructor)[];
|
28
16
|
target: import("vue").PropType<string | import("vue").RendererElement | null | undefined>;
|
29
|
-
|
17
|
+
offset: {
|
30
18
|
type: (NumberConstructor | StringConstructor)[];
|
31
19
|
default: number;
|
32
20
|
};
|
@@ -37,10 +25,8 @@ export declare const BackTop: import("../utils").WithInstall<import("vue").Defin
|
|
37
25
|
}>> & {
|
38
26
|
onClick?: ((...args: any[]) => any) | undefined;
|
39
27
|
}, {
|
40
|
-
|
41
|
-
right: string | number;
|
28
|
+
offset: string | number;
|
42
29
|
teleport: string | import("vue").RendererElement | null | undefined;
|
43
|
-
visibilityHeight: string | number;
|
44
30
|
}>>;
|
45
31
|
export default BackTop;
|
46
32
|
export { backTopProps } from './BackTop';
|
package/es/field/Field.mjs
CHANGED
@@ -201,7 +201,14 @@ var stdin_default = defineComponent({
|
|
201
201
|
value = props.formatter(value);
|
202
202
|
}
|
203
203
|
if (inputRef.value && inputRef.value.value !== value) {
|
204
|
+
const {
|
205
|
+
selectionStart,
|
206
|
+
selectionEnd
|
207
|
+
} = inputRef.value;
|
204
208
|
inputRef.value.value = value;
|
209
|
+
if (state.focused) {
|
210
|
+
inputRef.value.setSelectionRange(selectionStart, selectionEnd);
|
211
|
+
}
|
205
212
|
}
|
206
213
|
if (value !== props.modelValue) {
|
207
214
|
emit("update:modelValue", value);
|
package/es/index.d.ts
CHANGED
package/es/index.mjs
CHANGED
@@ -87,7 +87,7 @@ import { TimePicker } from "./time-picker/index.mjs";
|
|
87
87
|
import { Toast } from "./toast/index.mjs";
|
88
88
|
import { TreeSelect } from "./tree-select/index.mjs";
|
89
89
|
import { Uploader } from "./uploader/index.mjs";
|
90
|
-
const version = "4.0.
|
90
|
+
const version = "4.0.1";
|
91
91
|
function install(app) {
|
92
92
|
const components = [
|
93
93
|
ActionBar,
|
package/es/list/List.d.ts
CHANGED
@@ -7,6 +7,7 @@ export declare const listProps: {
|
|
7
7
|
default: number;
|
8
8
|
};
|
9
9
|
loading: BooleanConstructor;
|
10
|
+
disabled: BooleanConstructor;
|
10
11
|
finished: BooleanConstructor;
|
11
12
|
errorText: StringConstructor;
|
12
13
|
direction: {
|
@@ -28,6 +29,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
28
29
|
default: number;
|
29
30
|
};
|
30
31
|
loading: BooleanConstructor;
|
32
|
+
disabled: BooleanConstructor;
|
31
33
|
finished: BooleanConstructor;
|
32
34
|
errorText: StringConstructor;
|
33
35
|
direction: {
|
@@ -47,6 +49,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
47
49
|
default: number;
|
48
50
|
};
|
49
51
|
loading: BooleanConstructor;
|
52
|
+
disabled: BooleanConstructor;
|
50
53
|
finished: BooleanConstructor;
|
51
54
|
errorText: StringConstructor;
|
52
55
|
direction: {
|
@@ -65,6 +68,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
65
68
|
"onUpdate:loading"?: ((...args: any[]) => any) | undefined;
|
66
69
|
}, {
|
67
70
|
offset: string | number;
|
71
|
+
disabled: boolean;
|
68
72
|
error: boolean;
|
69
73
|
loading: boolean;
|
70
74
|
direction: ListDirection;
|
package/es/list/List.mjs
CHANGED
@@ -10,6 +10,7 @@ const listProps = {
|
|
10
10
|
error: Boolean,
|
11
11
|
offset: makeNumericProp(300),
|
12
12
|
loading: Boolean,
|
13
|
+
disabled: Boolean,
|
13
14
|
finished: Boolean,
|
14
15
|
errorText: String,
|
15
16
|
direction: makeStringProp("down"),
|
@@ -32,7 +33,7 @@ var stdin_default = defineComponent({
|
|
32
33
|
const scrollParent = useScrollParent(root);
|
33
34
|
const check = () => {
|
34
35
|
nextTick(() => {
|
35
|
-
if (loading.value || props.finished || props.error || (tabStatus == null ? void 0 : tabStatus.value) === false) {
|
36
|
+
if (loading.value || props.finished || props.disabled || props.error || (tabStatus == null ? void 0 : tabStatus.value) === false) {
|
36
37
|
return;
|
37
38
|
}
|
38
39
|
const {
|
@@ -85,7 +86,7 @@ var stdin_default = defineComponent({
|
|
85
86
|
}
|
86
87
|
};
|
87
88
|
const renderLoading = () => {
|
88
|
-
if (loading.value && !props.finished) {
|
89
|
+
if (loading.value && !props.finished && !props.disabled) {
|
89
90
|
return _createVNode("div", {
|
90
91
|
"class": bem("loading")
|
91
92
|
}, [slots.loading ? slots.loading() : _createVNode(Loading, {
|
package/es/list/index.d.ts
CHANGED
@@ -6,6 +6,7 @@ export declare const List: import("../utils").WithInstall<import("vue").DefineCo
|
|
6
6
|
default: number;
|
7
7
|
};
|
8
8
|
loading: BooleanConstructor;
|
9
|
+
disabled: BooleanConstructor;
|
9
10
|
finished: BooleanConstructor;
|
10
11
|
errorText: StringConstructor;
|
11
12
|
direction: {
|
@@ -25,6 +26,7 @@ export declare const List: import("../utils").WithInstall<import("vue").DefineCo
|
|
25
26
|
default: number;
|
26
27
|
};
|
27
28
|
loading: BooleanConstructor;
|
29
|
+
disabled: BooleanConstructor;
|
28
30
|
finished: BooleanConstructor;
|
29
31
|
errorText: StringConstructor;
|
30
32
|
direction: {
|
@@ -43,6 +45,7 @@ export declare const List: import("../utils").WithInstall<import("vue").DefineCo
|
|
43
45
|
"onUpdate:loading"?: ((...args: any[]) => any) | undefined;
|
44
46
|
}, {
|
45
47
|
offset: string | number;
|
48
|
+
disabled: boolean;
|
46
49
|
error: boolean;
|
47
50
|
loading: boolean;
|
48
51
|
direction: import("./types").ListDirection;
|
package/es/picker/Picker.mjs
CHANGED
@@ -59,6 +59,7 @@ var stdin_default = defineComponent({
|
|
59
59
|
});
|
60
60
|
const hasOptions = computed(() => currentColumns.value.some((options) => options.length));
|
61
61
|
const selectedOptions = computed(() => currentColumns.value.map((options, index) => findOptionByValue(options, selectedValues.value[index], fields.value)));
|
62
|
+
const selectedIndexes = computed(() => currentColumns.value.map((options, index) => options.findIndex((option) => option[fields.value.value] === selectedValues.value[index])));
|
62
63
|
const setValue = (index, value) => {
|
63
64
|
if (selectedValues.value[index] !== value) {
|
64
65
|
const newValues = selectedValues.value.slice(0);
|
@@ -68,7 +69,8 @@ var stdin_default = defineComponent({
|
|
68
69
|
};
|
69
70
|
const getEventParams = () => ({
|
70
71
|
selectedValues: selectedValues.value.slice(0),
|
71
|
-
selectedOptions: selectedOptions.value
|
72
|
+
selectedOptions: selectedOptions.value,
|
73
|
+
selectedIndexes: selectedIndexes.value
|
72
74
|
});
|
73
75
|
const onChange = (value, columnIndex) => {
|
74
76
|
setValue(columnIndex, value);
|
package/es/picker/types.d.ts
CHANGED
@@ -37,6 +37,7 @@ export type PickerInstance = ComponentPublicInstance<PickerProps, PickerExpose>;
|
|
37
37
|
export type PickerConfirmEventParams = {
|
38
38
|
selectedValues: Numeric[];
|
39
39
|
selectedOptions: Array<PickerOption | undefined>;
|
40
|
+
selectedIndexes: number[];
|
40
41
|
};
|
41
42
|
export type PickerCancelEventParams = PickerConfirmEventParams;
|
42
43
|
export type PickerChangeEventParams = PickerConfirmEventParams & {
|
@@ -1,15 +1,9 @@
|
|
1
1
|
import { type PropType, type ExtractPropTypes } from 'vue';
|
2
2
|
export declare const backTopProps: {
|
3
|
-
right:
|
4
|
-
|
5
|
-
default: number;
|
6
|
-
};
|
7
|
-
bottom: {
|
8
|
-
type: (NumberConstructor | StringConstructor)[];
|
9
|
-
default: number;
|
10
|
-
};
|
3
|
+
right: (NumberConstructor | StringConstructor)[];
|
4
|
+
bottom: (NumberConstructor | StringConstructor)[];
|
11
5
|
target: PropType<string | import("vue").RendererElement | null | undefined>;
|
12
|
-
|
6
|
+
offset: {
|
13
7
|
type: (NumberConstructor | StringConstructor)[];
|
14
8
|
default: number;
|
15
9
|
};
|
@@ -20,16 +14,10 @@ export declare const backTopProps: {
|
|
20
14
|
};
|
21
15
|
export type BackTopProps = ExtractPropTypes<typeof backTopProps>;
|
22
16
|
declare const _default: import("vue").DefineComponent<{
|
23
|
-
right:
|
24
|
-
|
25
|
-
default: number;
|
26
|
-
};
|
27
|
-
bottom: {
|
28
|
-
type: (NumberConstructor | StringConstructor)[];
|
29
|
-
default: number;
|
30
|
-
};
|
17
|
+
right: (NumberConstructor | StringConstructor)[];
|
18
|
+
bottom: (NumberConstructor | StringConstructor)[];
|
31
19
|
target: PropType<string | import("vue").RendererElement | null | undefined>;
|
32
|
-
|
20
|
+
offset: {
|
33
21
|
type: (NumberConstructor | StringConstructor)[];
|
34
22
|
default: number;
|
35
23
|
};
|
@@ -38,16 +26,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
38
26
|
default: string;
|
39
27
|
};
|
40
28
|
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "click"[], "click", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
|
41
|
-
right:
|
42
|
-
|
43
|
-
default: number;
|
44
|
-
};
|
45
|
-
bottom: {
|
46
|
-
type: (NumberConstructor | StringConstructor)[];
|
47
|
-
default: number;
|
48
|
-
};
|
29
|
+
right: (NumberConstructor | StringConstructor)[];
|
30
|
+
bottom: (NumberConstructor | StringConstructor)[];
|
49
31
|
target: PropType<string | import("vue").RendererElement | null | undefined>;
|
50
|
-
|
32
|
+
offset: {
|
51
33
|
type: (NumberConstructor | StringConstructor)[];
|
52
34
|
default: number;
|
53
35
|
};
|
@@ -58,9 +40,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
58
40
|
}>> & {
|
59
41
|
onClick?: ((...args: any[]) => any) | undefined;
|
60
42
|
}, {
|
61
|
-
|
62
|
-
right: string | number;
|
43
|
+
offset: string | number;
|
63
44
|
teleport: string | import("vue").RendererElement | null | undefined;
|
64
|
-
visibilityHeight: string | number;
|
65
45
|
}>;
|
66
46
|
export default _default;
|
package/lib/back-top/BackTop.js
CHANGED
@@ -29,10 +29,10 @@ var import_use = require("@vant/use");
|
|
29
29
|
var import_icon = require("../icon");
|
30
30
|
const [name, bem] = (0, import_utils.createNamespace)("back-top");
|
31
31
|
const backTopProps = {
|
32
|
-
right:
|
33
|
-
bottom:
|
32
|
+
right: import_utils.numericProp,
|
33
|
+
bottom: import_utils.numericProp,
|
34
34
|
target: [String, Object],
|
35
|
-
|
35
|
+
offset: (0, import_utils.makeNumericProp)(200),
|
36
36
|
teleport: {
|
37
37
|
type: [String, Object],
|
38
38
|
default: "body"
|
@@ -49,50 +49,52 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
49
49
|
attrs
|
50
50
|
}) {
|
51
51
|
const show = (0, import_vue2.ref)(false);
|
52
|
+
const root = (0, import_vue2.ref)();
|
52
53
|
const scrollParent = (0, import_vue2.ref)();
|
53
|
-
const root = (0, import_vue2.ref)(null);
|
54
|
-
let target;
|
55
54
|
const style = (0, import_vue2.computed)(() => ({
|
56
55
|
right: (0, import_utils.addUnit)(props.right),
|
57
56
|
bottom: (0, import_utils.addUnit)(props.bottom)
|
58
57
|
}));
|
59
58
|
const onClick = (event) => {
|
59
|
+
var _a;
|
60
60
|
emit("click", event);
|
61
|
-
|
61
|
+
(_a = scrollParent.value) == null ? void 0 : _a.scrollTo({
|
62
62
|
top: 0,
|
63
63
|
behavior: "smooth"
|
64
64
|
});
|
65
65
|
};
|
66
66
|
const scroll = () => {
|
67
|
-
show.value = (0, import_utils.getScrollTop)(
|
67
|
+
show.value = scrollParent.value ? (0, import_utils.getScrollTop)(scrollParent.value) >= props.offset : false;
|
68
68
|
};
|
69
69
|
const getTarget = () => {
|
70
70
|
const {
|
71
|
-
target
|
71
|
+
target
|
72
72
|
} = props;
|
73
|
-
if (typeof
|
74
|
-
const el = document.querySelector(
|
75
|
-
if (
|
76
|
-
|
73
|
+
if (typeof target === "string") {
|
74
|
+
const el = document.querySelector(target);
|
75
|
+
if (el) {
|
76
|
+
return el;
|
77
77
|
}
|
78
|
-
|
78
|
+
if (process.env.NODE_ENV !== "production") {
|
79
|
+
console.error(`[Vant] BackTop: target element "${target}" was not found, the BackTop component will not be rendered.`);
|
80
|
+
}
|
81
|
+
} else {
|
82
|
+
return target;
|
79
83
|
}
|
80
|
-
|
81
|
-
|
84
|
+
};
|
85
|
+
const updateTarget = () => {
|
86
|
+
if (import_utils.inBrowser) {
|
87
|
+
(0, import_vue2.nextTick)(() => {
|
88
|
+
scrollParent.value = props.target ? getTarget() : (0, import_use.getScrollParent)(root.value);
|
89
|
+
scroll();
|
90
|
+
});
|
82
91
|
}
|
83
|
-
throw Error('[Vant] BackTop: type of prop "target" should be a selector or an element object');
|
84
92
|
};
|
85
|
-
(0, import_use.useEventListener)("scroll", (0, import_util.throttle)(scroll,
|
93
|
+
(0, import_use.useEventListener)("scroll", (0, import_util.throttle)(scroll, 100), {
|
86
94
|
target: scrollParent
|
87
95
|
});
|
88
|
-
(0, import_vue2.onMounted)(
|
89
|
-
|
90
|
-
if (import_utils.inBrowser) {
|
91
|
-
target = props.target ? getTarget() : (0, import_use.getScrollParent)(root.value);
|
92
|
-
scrollParent.value = target;
|
93
|
-
}
|
94
|
-
});
|
95
|
-
});
|
96
|
+
(0, import_vue2.onMounted)(updateTarget);
|
97
|
+
(0, import_vue2.watch)(() => props.target, updateTarget);
|
96
98
|
return () => {
|
97
99
|
const Content = (0, import_vue.createVNode)("div", (0, import_vue.mergeProps)({
|
98
100
|
"ref": root,
|
package/lib/back-top/index.css
CHANGED
@@ -1 +1 @@
|
|
1
|
-
:root{--van-back-top-size: 40px;--van-back-top-icon-size: 20px;--van-back-top-text-color: #fff;--van-back-top-background: var(--van-blue)}.van-back-top{position:fixed;display:flex;align-items:center;justify-content:center;width:var(--van-back-top-size);height:var(--van-back-top-size);cursor:pointer;color:var(--van-back-top-text-color);border-radius:var(--van-radius-max);box-shadow:0 2px 8px rgba(0,0,0,.12);transform:scale(0);transition
|
1
|
+
:root{--van-back-top-size: 40px;--van-back-top-right: 30px;--van-back-top-bottom: 40px;--van-back-top-icon-size: 20px;--van-back-top-text-color: #fff;--van-back-top-background: var(--van-blue)}.van-back-top{position:fixed;display:flex;align-items:center;justify-content:center;width:var(--van-back-top-size);height:var(--van-back-top-size);right:var(--van-back-top-right);bottom:var(--van-back-top-bottom);cursor:pointer;color:var(--van-back-top-text-color);border-radius:var(--van-radius-max);box-shadow:0 2px 8px rgba(0,0,0,.12);transform:scale(0);transition:var(--van-duration-base) cubic-bezier(.25,.8,.5,1);background-color:var(--van-back-top-background)}.van-back-top:active{opacity:var(--van-active-opacity)}.van-back-top--active{transform:scale(1)}.van-back-top__icon{font-size:var(--van-back-top-icon-size);font-weight:var(--van-font-bold)}
|
package/lib/back-top/index.d.ts
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
export declare const BackTop: import("../utils").WithInstall<import("vue").DefineComponent<{
|
2
|
-
right:
|
3
|
-
|
4
|
-
default: number;
|
5
|
-
};
|
6
|
-
bottom: {
|
7
|
-
type: (NumberConstructor | StringConstructor)[];
|
8
|
-
default: number;
|
9
|
-
};
|
2
|
+
right: (NumberConstructor | StringConstructor)[];
|
3
|
+
bottom: (NumberConstructor | StringConstructor)[];
|
10
4
|
target: import("vue").PropType<string | import("vue").RendererElement | null | undefined>;
|
11
|
-
|
5
|
+
offset: {
|
12
6
|
type: (NumberConstructor | StringConstructor)[];
|
13
7
|
default: number;
|
14
8
|
};
|
@@ -17,16 +11,10 @@ export declare const BackTop: import("../utils").WithInstall<import("vue").Defin
|
|
17
11
|
default: string;
|
18
12
|
};
|
19
13
|
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "click"[], "click", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
20
|
-
right:
|
21
|
-
|
22
|
-
default: number;
|
23
|
-
};
|
24
|
-
bottom: {
|
25
|
-
type: (NumberConstructor | StringConstructor)[];
|
26
|
-
default: number;
|
27
|
-
};
|
14
|
+
right: (NumberConstructor | StringConstructor)[];
|
15
|
+
bottom: (NumberConstructor | StringConstructor)[];
|
28
16
|
target: import("vue").PropType<string | import("vue").RendererElement | null | undefined>;
|
29
|
-
|
17
|
+
offset: {
|
30
18
|
type: (NumberConstructor | StringConstructor)[];
|
31
19
|
default: number;
|
32
20
|
};
|
@@ -37,10 +25,8 @@ export declare const BackTop: import("../utils").WithInstall<import("vue").Defin
|
|
37
25
|
}>> & {
|
38
26
|
onClick?: ((...args: any[]) => any) | undefined;
|
39
27
|
}, {
|
40
|
-
|
41
|
-
right: string | number;
|
28
|
+
offset: string | number;
|
42
29
|
teleport: string | import("vue").RendererElement | null | undefined;
|
43
|
-
visibilityHeight: string | number;
|
44
30
|
}>>;
|
45
31
|
export default BackTop;
|
46
32
|
export { backTopProps } from './BackTop';
|
package/lib/field/Field.js
CHANGED
@@ -225,7 +225,14 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
225
225
|
value = props.formatter(value);
|
226
226
|
}
|
227
227
|
if (inputRef.value && inputRef.value.value !== value) {
|
228
|
+
const {
|
229
|
+
selectionStart,
|
230
|
+
selectionEnd
|
231
|
+
} = inputRef.value;
|
228
232
|
inputRef.value.value = value;
|
233
|
+
if (state.focused) {
|
234
|
+
inputRef.value.setSelectionRange(selectionStart, selectionEnd);
|
235
|
+
}
|
229
236
|
}
|
230
237
|
if (value !== props.modelValue) {
|
231
238
|
emit("update:modelValue", value);
|