vant 4.0.0-rc.3 → 4.0.0-rc.5

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 (47) hide show
  1. package/README.md +4 -5
  2. package/changelog.generated.md +47 -23
  3. package/es/date-picker/DatePicker.mjs +4 -1
  4. package/es/date-picker/utils.d.ts +1 -0
  5. package/es/date-picker/utils.mjs +11 -0
  6. package/es/field/Field.mjs +5 -4
  7. package/es/field/index.css +1 -1
  8. package/es/field/types.d.ts +1 -1
  9. package/es/index.d.ts +1 -1
  10. package/es/index.mjs +1 -1
  11. package/es/loading/Loading.mjs +8 -4
  12. package/es/nav-bar/NavBar.d.ts +13 -0
  13. package/es/nav-bar/NavBar.mjs +4 -3
  14. package/es/nav-bar/index.d.ts +9 -0
  15. package/es/notify/function-call.mjs +1 -1
  16. package/es/stepper/Stepper.d.ts +13 -0
  17. package/es/stepper/Stepper.mjs +4 -3
  18. package/es/stepper/index.d.ts +9 -0
  19. package/es/tab/Tab.mjs +12 -2
  20. package/es/tabs/Tabs.mjs +51 -48
  21. package/es/time-picker/TimePicker.mjs +4 -3
  22. package/lib/date-picker/DatePicker.js +3 -0
  23. package/lib/date-picker/utils.d.ts +1 -0
  24. package/lib/date-picker/utils.js +11 -0
  25. package/lib/field/Field.js +5 -4
  26. package/lib/field/index.css +1 -1
  27. package/lib/field/types.d.ts +1 -1
  28. package/lib/index.css +1 -1
  29. package/lib/index.d.ts +1 -1
  30. package/lib/index.js +1 -1
  31. package/lib/loading/Loading.js +8 -4
  32. package/lib/nav-bar/NavBar.d.ts +13 -0
  33. package/lib/nav-bar/NavBar.js +4 -3
  34. package/lib/nav-bar/index.d.ts +9 -0
  35. package/lib/notify/function-call.js +1 -1
  36. package/lib/stepper/Stepper.d.ts +13 -0
  37. package/lib/stepper/Stepper.js +4 -3
  38. package/lib/stepper/index.d.ts +9 -0
  39. package/lib/tab/Tab.js +11 -1
  40. package/lib/tabs/Tabs.js +51 -48
  41. package/lib/time-picker/TimePicker.js +3 -2
  42. package/lib/vant.cjs.js +101 -67
  43. package/lib/vant.es.js +101 -67
  44. package/lib/vant.js +101 -67
  45. package/lib/vant.min.js +1 -1
  46. package/lib/web-types.json +523 -499
  47. package/package.json +5 -5
package/lib/index.d.ts CHANGED
@@ -93,4 +93,4 @@ declare namespace _default {
93
93
  }
94
94
  export default _default;
95
95
  export function install(app: any): void;
96
- export const version: "4.0.0-rc.3";
96
+ export const version: "4.0.0-rc.5";
package/lib/index.js CHANGED
@@ -200,7 +200,7 @@ __reExport(stdin_exports, require("./time-picker"), module.exports);
200
200
  __reExport(stdin_exports, require("./toast"), module.exports);
201
201
  __reExport(stdin_exports, require("./tree-select"), module.exports);
202
202
  __reExport(stdin_exports, require("./uploader"), module.exports);
203
- const version = "4.0.0-rc.3";
203
+ const version = "4.0.0-rc.5";
204
204
  function install(app) {
205
205
  const components = [
206
206
  import_action_bar.ActionBar,
@@ -54,6 +54,13 @@ var stdin_default = (0, import_vue2.defineComponent)({
54
54
  const spinnerStyle = (0, import_vue2.computed)(() => (0, import_utils.extend)({
55
55
  color: props.color
56
56
  }, (0, import_utils.getSizeStyle)(props.size)));
57
+ const renderIcon = () => {
58
+ const DefaultIcon = props.type === "spinner" ? SpinIcon : CircularIcon;
59
+ return (0, import_vue.createVNode)("span", {
60
+ "class": bem("spinner", props.type),
61
+ "style": spinnerStyle.value
62
+ }, [slots.icon ? slots.icon() : DefaultIcon]);
63
+ };
57
64
  const renderText = () => {
58
65
  var _a;
59
66
  if (slots.default) {
@@ -77,10 +84,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
77
84
  }]),
78
85
  "aria-live": "polite",
79
86
  "aria-busy": true
80
- }, [(0, import_vue.createVNode)("span", {
81
- "class": bem("spinner", type),
82
- "style": spinnerStyle.value
83
- }, [type === "spinner" ? SpinIcon : CircularIcon]), renderText()]);
87
+ }, [renderIcon(), renderText()]);
84
88
  };
85
89
  }
86
90
  });
@@ -12,6 +12,10 @@ export declare const navBarProps: {
12
12
  leftArrow: BooleanConstructor;
13
13
  placeholder: BooleanConstructor;
14
14
  safeAreaInsetTop: BooleanConstructor;
15
+ clickable: {
16
+ type: BooleanConstructor;
17
+ default: true;
18
+ };
15
19
  };
16
20
  export declare type NavBarProps = ExtractPropTypes<typeof navBarProps>;
17
21
  declare const _default: import("vue").DefineComponent<{
@@ -27,6 +31,10 @@ declare const _default: import("vue").DefineComponent<{
27
31
  leftArrow: BooleanConstructor;
28
32
  placeholder: BooleanConstructor;
29
33
  safeAreaInsetTop: BooleanConstructor;
34
+ clickable: {
35
+ type: BooleanConstructor;
36
+ default: true;
37
+ };
30
38
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("clickLeft" | "clickRight")[], "clickLeft" | "clickRight", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
31
39
  title: StringConstructor;
32
40
  fixed: BooleanConstructor;
@@ -40,12 +48,17 @@ declare const _default: import("vue").DefineComponent<{
40
48
  leftArrow: BooleanConstructor;
41
49
  placeholder: BooleanConstructor;
42
50
  safeAreaInsetTop: BooleanConstructor;
51
+ clickable: {
52
+ type: BooleanConstructor;
53
+ default: true;
54
+ };
43
55
  }>> & {
44
56
  onClickLeft?: ((...args: any[]) => any) | undefined;
45
57
  onClickRight?: ((...args: any[]) => any) | undefined;
46
58
  }, {
47
59
  fixed: boolean;
48
60
  border: boolean;
61
+ clickable: boolean;
49
62
  placeholder: boolean;
50
63
  safeAreaInsetTop: boolean;
51
64
  leftArrow: boolean;
@@ -36,7 +36,8 @@ const navBarProps = {
36
36
  rightText: String,
37
37
  leftArrow: Boolean,
38
38
  placeholder: Boolean,
39
- safeAreaInsetTop: Boolean
39
+ safeAreaInsetTop: Boolean,
40
+ clickable: import_utils.truthProp
40
41
  };
41
42
  var stdin_default = (0, import_vue2.defineComponent)({
42
43
  name,
@@ -91,12 +92,12 @@ var stdin_default = (0, import_vue2.defineComponent)({
91
92
  }, [(0, import_vue.createVNode)("div", {
92
93
  "class": bem("content")
93
94
  }, [hasLeft && (0, import_vue.createVNode)("div", {
94
- "class": [bem("left"), import_utils.HAPTICS_FEEDBACK],
95
+ "class": [bem("left"), props.clickable ? import_utils.HAPTICS_FEEDBACK : ""],
95
96
  "onClick": onClickLeft
96
97
  }, [renderLeft()]), (0, import_vue.createVNode)("div", {
97
98
  "class": [bem("title"), "van-ellipsis"]
98
99
  }, [slots.title ? slots.title() : title]), hasRight && (0, import_vue.createVNode)("div", {
99
- "class": [bem("right"), import_utils.HAPTICS_FEEDBACK],
100
+ "class": [bem("right"), props.clickable ? import_utils.HAPTICS_FEEDBACK : ""],
100
101
  "onClick": onClickRight
101
102
  }, [renderRight()])])]);
102
103
  };
@@ -11,6 +11,10 @@ export declare const NavBar: import("../utils").WithInstall<import("vue").Define
11
11
  leftArrow: BooleanConstructor;
12
12
  placeholder: BooleanConstructor;
13
13
  safeAreaInsetTop: BooleanConstructor;
14
+ clickable: {
15
+ type: BooleanConstructor;
16
+ default: true;
17
+ };
14
18
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("clickLeft" | "clickRight")[], "clickLeft" | "clickRight", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
15
19
  title: StringConstructor;
16
20
  fixed: BooleanConstructor;
@@ -24,12 +28,17 @@ export declare const NavBar: import("../utils").WithInstall<import("vue").Define
24
28
  leftArrow: BooleanConstructor;
25
29
  placeholder: BooleanConstructor;
26
30
  safeAreaInsetTop: BooleanConstructor;
31
+ clickable: {
32
+ type: BooleanConstructor;
33
+ default: true;
34
+ };
27
35
  }>> & {
28
36
  onClickLeft?: ((...args: any[]) => any) | undefined;
29
37
  onClickRight?: ((...args: any[]) => any) | undefined;
30
38
  }, {
31
39
  fixed: boolean;
32
40
  border: boolean;
41
+ clickable: boolean;
33
42
  placeholder: boolean;
34
43
  safeAreaInsetTop: boolean;
35
44
  leftArrow: boolean;
@@ -83,7 +83,7 @@ function showNotify(options) {
83
83
  instance.open(options);
84
84
  clearTimeout(timer);
85
85
  if (options.duration > 0) {
86
- timer = window.setTimeout(closeNotify, options.duration);
86
+ timer = setTimeout(closeNotify, options.duration);
87
87
  }
88
88
  return instance;
89
89
  }
@@ -37,6 +37,10 @@ export declare const stepperProps: {
37
37
  type: BooleanConstructor;
38
38
  default: true;
39
39
  };
40
+ autoFixed: {
41
+ type: BooleanConstructor;
42
+ default: true;
43
+ };
40
44
  allowEmpty: BooleanConstructor;
41
45
  modelValue: (NumberConstructor | StringConstructor)[];
42
46
  inputWidth: (NumberConstructor | StringConstructor)[];
@@ -89,6 +93,10 @@ declare const _default: import("vue").DefineComponent<{
89
93
  type: BooleanConstructor;
90
94
  default: true;
91
95
  };
96
+ autoFixed: {
97
+ type: BooleanConstructor;
98
+ default: true;
99
+ };
92
100
  allowEmpty: BooleanConstructor;
93
101
  modelValue: (NumberConstructor | StringConstructor)[];
94
102
  inputWidth: (NumberConstructor | StringConstructor)[];
@@ -139,6 +147,10 @@ declare const _default: import("vue").DefineComponent<{
139
147
  type: BooleanConstructor;
140
148
  default: true;
141
149
  };
150
+ autoFixed: {
151
+ type: BooleanConstructor;
152
+ default: true;
153
+ };
142
154
  allowEmpty: BooleanConstructor;
143
155
  modelValue: (NumberConstructor | StringConstructor)[];
144
156
  inputWidth: (NumberConstructor | StringConstructor)[];
@@ -172,6 +184,7 @@ declare const _default: import("vue").DefineComponent<{
172
184
  showMinus: boolean;
173
185
  showInput: boolean;
174
186
  longPress: boolean;
187
+ autoFixed: boolean;
175
188
  allowEmpty: boolean;
176
189
  disablePlus: boolean;
177
190
  disableMinus: boolean;
@@ -41,6 +41,7 @@ const stepperProps = {
41
41
  showMinus: import_utils.truthProp,
42
42
  showInput: import_utils.truthProp,
43
43
  longPress: import_utils.truthProp,
44
+ autoFixed: import_utils.truthProp,
44
45
  allowEmpty: Boolean,
45
46
  modelValue: import_utils.numericProp,
46
47
  inputWidth: import_utils.numericProp,
@@ -60,7 +61,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
60
61
  setup(props, {
61
62
  emit
62
63
  }) {
63
- const format = (value) => {
64
+ const format = (value, autoFixed = true) => {
64
65
  const {
65
66
  min,
66
67
  max,
@@ -73,7 +74,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
73
74
  value = (0, import_utils.formatNumber)(String(value), !props.integer);
74
75
  value = value === "" ? 0 : +value;
75
76
  value = Number.isNaN(value) ? +min : value;
76
- value = Math.max(Math.min(+max, value), +min);
77
+ value = autoFixed ? Math.max(Math.min(+max, value), +min) : value;
77
78
  if ((0, import_utils.isDef)(decimalLength)) {
78
79
  value = value.toFixed(+decimalLength);
79
80
  }
@@ -157,7 +158,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
157
158
  };
158
159
  const onBlur = (event) => {
159
160
  const input = event.target;
160
- const value = format(input.value);
161
+ const value = format(input.value, props.autoFixed);
161
162
  input.value = String(value);
162
163
  current.value = value;
163
164
  (0, import_vue2.nextTick)(() => {
@@ -34,6 +34,10 @@ export declare const Stepper: import("../utils").WithInstall<import("vue").Defin
34
34
  type: BooleanConstructor;
35
35
  default: true;
36
36
  };
37
+ autoFixed: {
38
+ type: BooleanConstructor;
39
+ default: true;
40
+ };
37
41
  allowEmpty: BooleanConstructor;
38
42
  modelValue: (NumberConstructor | StringConstructor)[];
39
43
  inputWidth: (NumberConstructor | StringConstructor)[];
@@ -84,6 +88,10 @@ export declare const Stepper: import("../utils").WithInstall<import("vue").Defin
84
88
  type: BooleanConstructor;
85
89
  default: true;
86
90
  };
91
+ autoFixed: {
92
+ type: BooleanConstructor;
93
+ default: true;
94
+ };
87
95
  allowEmpty: BooleanConstructor;
88
96
  modelValue: (NumberConstructor | StringConstructor)[];
89
97
  inputWidth: (NumberConstructor | StringConstructor)[];
@@ -117,6 +125,7 @@ export declare const Stepper: import("../utils").WithInstall<import("vue").Defin
117
125
  showMinus: boolean;
118
126
  showInput: boolean;
119
127
  longPress: boolean;
128
+ autoFixed: boolean;
120
129
  allowEmpty: boolean;
121
130
  disablePlus: boolean;
122
131
  disableMinus: boolean;
package/lib/tab/Tab.js CHANGED
@@ -79,6 +79,16 @@ var stdin_default = (0, import_vue2.defineComponent)({
79
79
  }
80
80
  return isActive;
81
81
  });
82
+ const hasInactiveClass = (0, import_vue2.ref)(!active.value);
83
+ (0, import_vue2.watch)(active, (val) => {
84
+ if (val) {
85
+ hasInactiveClass.value = false;
86
+ } else {
87
+ (0, import_use.doubleRaf)(() => {
88
+ hasInactiveClass.value = true;
89
+ });
90
+ }
91
+ });
82
92
  (0, import_vue2.watch)(() => props.title, () => {
83
93
  parent.setLine();
84
94
  parent.scrollIntoView();
@@ -102,7 +112,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
102
112
  "id": id,
103
113
  "role": "tabpanel",
104
114
  "class": bem("panel-wrapper", {
105
- inactive: !active.value
115
+ inactive: hasInactiveClass.value
106
116
  }),
107
117
  "tabindex": active.value ? 0 : -1,
108
118
  "aria-hidden": !active.value,
package/lib/tabs/Tabs.js CHANGED
@@ -163,7 +163,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
163
163
  index += diff;
164
164
  }
165
165
  };
166
- const setCurrentIndex = (currentIndex) => {
166
+ const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
167
167
  const newIndex = findAvailableTab(currentIndex);
168
168
  if (!(0, import_utils.isDef)(newIndex)) {
169
169
  return;
@@ -171,18 +171,27 @@ var stdin_default = (0, import_vue2.defineComponent)({
171
171
  const newTab = children[newIndex];
172
172
  const newName = getTabName(newTab, newIndex);
173
173
  const shouldEmitChange = state.currentIndex !== null;
174
- state.currentIndex = newIndex;
174
+ if (state.currentIndex !== newIndex) {
175
+ state.currentIndex = newIndex;
176
+ if (!skipScrollIntoView) {
177
+ scrollIntoView();
178
+ }
179
+ setLine();
180
+ }
175
181
  if (newName !== props.active) {
176
182
  emit("update:active", newName);
177
183
  if (shouldEmitChange) {
178
184
  emit("change", newName, newTab.title);
179
185
  }
180
186
  }
187
+ if (stickyFixed && !props.scrollspy) {
188
+ (0, import_utils.setRootScrollTop)(Math.ceil((0, import_utils.getElementTop)(root.value) - offsetTopPx.value));
189
+ }
181
190
  };
182
- const setCurrentIndexByName = (name2) => {
191
+ const setCurrentIndexByName = (name2, skipScrollIntoView) => {
183
192
  const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
184
193
  const index = matched ? children.indexOf(matched) : 0;
185
- setCurrentIndex(index);
194
+ setCurrentIndex(index, skipScrollIntoView);
186
195
  };
187
196
  const scrollToCurrentContent = (immediate = false) => {
188
197
  if (props.scrollspy) {
@@ -273,13 +282,14 @@ var stdin_default = (0, import_vue2.defineComponent)({
273
282
  }
274
283
  };
275
284
  const renderHeader = () => {
276
- var _a, _b;
285
+ var _a, _b, _c;
277
286
  const {
278
287
  type,
279
- border
288
+ border,
289
+ sticky
280
290
  } = props;
281
- return (0, import_vue.createVNode)("div", {
282
- "ref": wrapRef,
291
+ const Header = [(0, import_vue.createVNode)("div", {
292
+ "ref": sticky ? void 0 : wrapRef,
283
293
  "class": [bem("wrap"), {
284
294
  [import_utils.BORDER_TOP_BOTTOM]: type === "line" && border
285
295
  }]
@@ -292,7 +302,13 @@ var stdin_default = (0, import_vue2.defineComponent)({
292
302
  }]),
293
303
  "style": navStyle.value,
294
304
  "aria-orientation": "horizontal"
295
- }, [(_a = slots["nav-left"]) == null ? void 0 : _a.call(slots), renderNav(), renderLine(), (_b = slots["nav-right"]) == null ? void 0 : _b.call(slots)])]);
305
+ }, [(_a = slots["nav-left"]) == null ? void 0 : _a.call(slots), renderNav(), renderLine(), (_b = slots["nav-right"]) == null ? void 0 : _b.call(slots)])]), (_c = slots["nav-bottom"]) == null ? void 0 : _c.call(slots)];
306
+ if (sticky) {
307
+ return (0, import_vue.createVNode)("div", {
308
+ "ref": wrapRef
309
+ }, [Header]);
310
+ }
311
+ return Header;
296
312
  };
297
313
  (0, import_vue2.watch)([() => props.color, import_utils.windowWidth], setLine);
298
314
  (0, import_vue2.watch)(() => props.active, (value) => {
@@ -309,15 +325,8 @@ var stdin_default = (0, import_vue2.defineComponent)({
309
325
  });
310
326
  }
311
327
  });
312
- (0, import_vue2.watch)(() => state.currentIndex, () => {
313
- scrollIntoView();
314
- setLine();
315
- if (stickyFixed && !props.scrollspy) {
316
- (0, import_utils.setRootScrollTop)(Math.ceil((0, import_utils.getElementTop)(root.value) - offsetTopPx.value));
317
- }
318
- });
319
328
  const init = () => {
320
- setCurrentIndexByName(props.active);
329
+ setCurrentIndexByName(props.active, true);
321
330
  (0, import_vue2.nextTick)(() => {
322
331
  state.inited = true;
323
332
  if (wrapRef.value) {
@@ -353,36 +362,30 @@ var stdin_default = (0, import_vue2.defineComponent)({
353
362
  currentName,
354
363
  scrollIntoView
355
364
  });
356
- return () => {
357
- var _a;
358
- return (0, import_vue.createVNode)("div", {
359
- "ref": root,
360
- "class": bem([props.type])
361
- }, [props.sticky ? (0, import_vue.createVNode)(import_sticky.Sticky, {
362
- "container": root.value,
363
- "offsetTop": offsetTopPx.value,
364
- "onScroll": onStickyScroll
365
- }, {
366
- default: () => {
367
- var _a2;
368
- return [renderHeader(), (_a2 = slots["nav-bottom"]) == null ? void 0 : _a2.call(slots)];
369
- }
370
- }) : [renderHeader(), (_a = slots["nav-bottom"]) == null ? void 0 : _a.call(slots)], (0, import_vue.createVNode)(import_TabsContent.default, {
371
- "ref": contentRef,
372
- "count": children.length,
373
- "inited": state.inited,
374
- "animated": props.animated,
375
- "duration": props.duration,
376
- "swipeable": props.swipeable,
377
- "lazyRender": props.lazyRender,
378
- "currentIndex": state.currentIndex,
379
- "onChange": setCurrentIndex
380
- }, {
381
- default: () => {
382
- var _a2;
383
- return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
384
- }
385
- })]);
386
- };
365
+ return () => (0, import_vue.createVNode)("div", {
366
+ "ref": root,
367
+ "class": bem([props.type])
368
+ }, [props.sticky ? (0, import_vue.createVNode)(import_sticky.Sticky, {
369
+ "container": root.value,
370
+ "offsetTop": offsetTopPx.value,
371
+ "onScroll": onStickyScroll
372
+ }, {
373
+ default: () => [renderHeader()]
374
+ }) : renderHeader(), (0, import_vue.createVNode)(import_TabsContent.default, {
375
+ "ref": contentRef,
376
+ "count": children.length,
377
+ "inited": state.inited,
378
+ "animated": props.animated,
379
+ "duration": props.duration,
380
+ "swipeable": props.swipeable,
381
+ "lazyRender": props.lazyRender,
382
+ "currentIndex": state.currentIndex,
383
+ "onChange": setCurrentIndex
384
+ }, {
385
+ default: () => {
386
+ var _a;
387
+ return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
388
+ }
389
+ })]);
387
390
  }
388
391
  });
@@ -68,13 +68,14 @@ var stdin_default = (0, import_vue2.defineComponent)({
68
68
  if (!(0, import_utils.isSameValue)(newValues, props.modelValue)) {
69
69
  emit("update:modelValue", newValues);
70
70
  }
71
- }, {
72
- immediate: true
73
71
  });
74
72
  (0, import_vue2.watch)(() => props.modelValue, (newValues) => {
73
+ newValues = (0, import_utils2.formatValueRange)(newValues, columns.value);
75
74
  if (!(0, import_utils.isSameValue)(newValues, currentValues.value)) {
76
75
  currentValues.value = newValues;
77
76
  }
77
+ }, {
78
+ immediate: true
78
79
  });
79
80
  const onChange = (...args) => emit("change", ...args);
80
81
  const onCancel = (...args) => emit("cancel", ...args);