vant 4.4.1 → 4.5.0

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 (59) hide show
  1. package/es/address-list/AddressList.d.ts +13 -0
  2. package/es/address-list/AddressList.mjs +4 -2
  3. package/es/address-list/AddressListItem.d.ts +9 -0
  4. package/es/address-list/AddressListItem.mjs +4 -3
  5. package/es/address-list/index.d.ts +9 -0
  6. package/es/back-top/BackTop.mjs +14 -1
  7. package/es/date-picker/DatePicker.d.ts +3 -3
  8. package/es/date-picker/index.d.ts +2 -2
  9. package/es/date-picker/utils.d.ts +4 -2
  10. package/es/date-picker/utils.mjs +8 -3
  11. package/es/dropdown-menu/DropdownMenu.mjs +10 -3
  12. package/es/dropdown-menu/types.d.ts +5 -1
  13. package/es/floating-panel/FloatingPanel.d.ts +77 -0
  14. package/es/floating-panel/FloatingPanel.mjs +126 -0
  15. package/es/floating-panel/index.css +1 -0
  16. package/es/floating-panel/index.d.ts +60 -0
  17. package/es/floating-panel/index.mjs +8 -0
  18. package/es/floating-panel/style/index.d.ts +1 -0
  19. package/es/floating-panel/style/index.mjs +2 -0
  20. package/es/index.d.ts +2 -1
  21. package/es/index.mjs +4 -1
  22. package/es/slider/Slider.mjs +10 -2
  23. package/es/time-picker/TimePicker.d.ts +31 -4
  24. package/es/time-picker/TimePicker.mjs +73 -21
  25. package/es/time-picker/index.d.ts +20 -2
  26. package/es/utils/basic.d.ts +3 -0
  27. package/lib/address-list/AddressList.d.ts +13 -0
  28. package/lib/address-list/AddressList.js +3 -1
  29. package/lib/address-list/AddressListItem.d.ts +9 -0
  30. package/lib/address-list/AddressListItem.js +3 -2
  31. package/lib/address-list/index.d.ts +9 -0
  32. package/lib/back-top/BackTop.js +13 -0
  33. package/lib/date-picker/DatePicker.d.ts +3 -3
  34. package/lib/date-picker/index.d.ts +2 -2
  35. package/lib/date-picker/utils.d.ts +4 -2
  36. package/lib/date-picker/utils.js +2 -2
  37. package/lib/dropdown-menu/DropdownMenu.js +10 -3
  38. package/lib/dropdown-menu/types.d.ts +5 -1
  39. package/lib/floating-panel/FloatingPanel.d.ts +77 -0
  40. package/lib/floating-panel/FloatingPanel.js +145 -0
  41. package/lib/floating-panel/index.css +1 -0
  42. package/lib/floating-panel/index.d.ts +60 -0
  43. package/lib/floating-panel/index.js +37 -0
  44. package/lib/floating-panel/style/index.d.ts +1 -0
  45. package/lib/floating-panel/style/index.js +2 -0
  46. package/lib/index.css +1 -1
  47. package/lib/index.d.ts +2 -1
  48. package/lib/index.js +4 -1
  49. package/lib/slider/Slider.js +10 -2
  50. package/lib/time-picker/TimePicker.d.ts +31 -4
  51. package/lib/time-picker/TimePicker.js +84 -32
  52. package/lib/time-picker/index.d.ts +20 -2
  53. package/lib/utils/basic.d.ts +3 -0
  54. package/lib/vant.cjs.js +770 -570
  55. package/lib/vant.es.js +770 -570
  56. package/lib/vant.js +766 -566
  57. package/lib/vant.min.js +1 -1
  58. package/lib/web-types.json +1 -1
  59. package/package.json +1 -1
package/lib/index.d.ts CHANGED
@@ -35,6 +35,7 @@ export * from "./dropdown-item";
35
35
  export * from "./dropdown-menu";
36
36
  export * from "./empty";
37
37
  export * from "./field";
38
+ export * from "./floating-panel";
38
39
  export * from "./form";
39
40
  export * from "./grid";
40
41
  export * from "./grid-item";
@@ -102,4 +103,4 @@ declare namespace _default {
102
103
  }
103
104
  export default _default;
104
105
  export function install(app: any): void;
105
- export const version: "4.4.1";
106
+ export const version: "4.5.0";
package/lib/index.js CHANGED
@@ -60,6 +60,7 @@ var import_dropdown_item = require("./dropdown-item");
60
60
  var import_dropdown_menu = require("./dropdown-menu");
61
61
  var import_empty = require("./empty");
62
62
  var import_field = require("./field");
63
+ var import_floating_panel = require("./floating-panel");
63
64
  var import_form = require("./form");
64
65
  var import_grid = require("./grid");
65
66
  var import_grid_item = require("./grid-item");
@@ -157,6 +158,7 @@ __reExport(stdin_exports, require("./dropdown-item"), module.exports);
157
158
  __reExport(stdin_exports, require("./dropdown-menu"), module.exports);
158
159
  __reExport(stdin_exports, require("./empty"), module.exports);
159
160
  __reExport(stdin_exports, require("./field"), module.exports);
161
+ __reExport(stdin_exports, require("./floating-panel"), module.exports);
160
162
  __reExport(stdin_exports, require("./form"), module.exports);
161
163
  __reExport(stdin_exports, require("./grid"), module.exports);
162
164
  __reExport(stdin_exports, require("./grid-item"), module.exports);
@@ -218,7 +220,7 @@ __reExport(stdin_exports, require("./toast"), module.exports);
218
220
  __reExport(stdin_exports, require("./tree-select"), module.exports);
219
221
  __reExport(stdin_exports, require("./uploader"), module.exports);
220
222
  __reExport(stdin_exports, require("./watermark"), module.exports);
221
- const version = "4.4.1";
223
+ const version = "4.5.0";
222
224
  function install(app) {
223
225
  const components = [
224
226
  import_action_bar.ActionBar,
@@ -258,6 +260,7 @@ function install(app) {
258
260
  import_dropdown_menu.DropdownMenu,
259
261
  import_empty.Empty,
260
262
  import_field.Field,
263
+ import_floating_panel.FloatingPanel,
261
264
  import_form.Form,
262
265
  import_grid.Grid,
263
266
  import_grid_item.GridItem,
@@ -233,17 +233,25 @@ var stdin_default = (0, import_vue2.defineComponent)({
233
233
  return bem("button-wrapper", props.reverse ? "left" : "right");
234
234
  };
235
235
  const renderButtonContent = (value, index) => {
236
+ const dragging = dragStatus.value === "dragging";
236
237
  if (typeof index === "number") {
237
238
  const slot = slots[index === 0 ? "left-button" : "right-button"];
239
+ let dragIndex;
240
+ if (dragging && Array.isArray(current)) {
241
+ dragIndex = current[0] > current[1] ? buttonIndex ^ 1 : buttonIndex;
242
+ }
238
243
  if (slot) {
239
244
  return slot({
240
- value
245
+ value,
246
+ dragging,
247
+ dragIndex
241
248
  });
242
249
  }
243
250
  }
244
251
  if (slots.button) {
245
252
  return slots.button({
246
- value
253
+ value,
254
+ dragging
247
255
  });
248
256
  }
249
257
  return (0, import_vue.createVNode)("div", {
@@ -1,4 +1,4 @@
1
- import { type PropType, type ExtractPropTypes } from 'vue';
1
+ import { type ExtractPropTypes, type PropType } from 'vue';
2
2
  export type TimePickerColumnType = 'hour' | 'minute' | 'second';
3
3
  export declare const timePickerProps: {
4
4
  loading: BooleanConstructor;
@@ -29,7 +29,7 @@ export declare const timePickerProps: {
29
29
  type: PropType<string[]>;
30
30
  default: () => never[];
31
31
  };
32
- filter: PropType<(columnType: string, options: import("../picker").PickerOption[]) => import("../picker").PickerOption[]>;
32
+ filter: PropType<(columnType: string, options: import("../picker").PickerOption[], values?: string[] | undefined) => import("../picker").PickerOption[]>;
33
33
  formatter: {
34
34
  type: PropType<(type: string, option: import("../picker").PickerOption) => import("../picker").PickerOption>;
35
35
  default: (type: string, option: import("../picker").PickerOption) => import("../picker").PickerOption;
@@ -59,10 +59,19 @@ export declare const timePickerProps: {
59
59
  type: (NumberConstructor | StringConstructor)[];
60
60
  default: number;
61
61
  };
62
+ minTime: {
63
+ type: StringConstructor;
64
+ validator: (val: string) => boolean;
65
+ };
66
+ maxTime: {
67
+ type: StringConstructor;
68
+ validator: (val: string) => boolean;
69
+ };
62
70
  columnsType: {
63
71
  type: PropType<TimePickerColumnType[]>;
64
72
  default: () => string[];
65
73
  };
74
+ filter: PropType<(columnType: string, options: import("../picker").PickerOption[], values: string[]) => import("../picker").PickerOption[]>;
66
75
  };
67
76
  export type TimePickerProps = ExtractPropTypes<typeof timePickerProps>;
68
77
  declare const _default: import("vue").DefineComponent<{
@@ -94,7 +103,7 @@ declare const _default: import("vue").DefineComponent<{
94
103
  type: PropType<string[]>;
95
104
  default: () => never[];
96
105
  };
97
- filter: PropType<(columnType: string, options: import("../picker").PickerOption[]) => import("../picker").PickerOption[]>;
106
+ filter: PropType<(columnType: string, options: import("../picker").PickerOption[], values?: string[] | undefined) => import("../picker").PickerOption[]>;
98
107
  formatter: {
99
108
  type: PropType<(type: string, option: import("../picker").PickerOption) => import("../picker").PickerOption>;
100
109
  default: (type: string, option: import("../picker").PickerOption) => import("../picker").PickerOption;
@@ -124,10 +133,19 @@ declare const _default: import("vue").DefineComponent<{
124
133
  type: (NumberConstructor | StringConstructor)[];
125
134
  default: number;
126
135
  };
136
+ minTime: {
137
+ type: StringConstructor;
138
+ validator: (val: string) => boolean;
139
+ };
140
+ maxTime: {
141
+ type: StringConstructor;
142
+ validator: (val: string) => boolean;
143
+ };
127
144
  columnsType: {
128
145
  type: PropType<TimePickerColumnType[]>;
129
146
  default: () => string[];
130
147
  };
148
+ filter: PropType<(columnType: string, options: import("../picker").PickerOption[], values: string[]) => import("../picker").PickerOption[]>;
131
149
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "cancel" | "change" | "confirm")[], "update:modelValue" | "cancel" | "change" | "confirm", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
132
150
  loading: BooleanConstructor;
133
151
  readonly: BooleanConstructor;
@@ -157,7 +175,7 @@ declare const _default: import("vue").DefineComponent<{
157
175
  type: PropType<string[]>;
158
176
  default: () => never[];
159
177
  };
160
- filter: PropType<(columnType: string, options: import("../picker").PickerOption[]) => import("../picker").PickerOption[]>;
178
+ filter: PropType<(columnType: string, options: import("../picker").PickerOption[], values?: string[] | undefined) => import("../picker").PickerOption[]>;
161
179
  formatter: {
162
180
  type: PropType<(type: string, option: import("../picker").PickerOption) => import("../picker").PickerOption>;
163
181
  default: (type: string, option: import("../picker").PickerOption) => import("../picker").PickerOption;
@@ -187,10 +205,19 @@ declare const _default: import("vue").DefineComponent<{
187
205
  type: (NumberConstructor | StringConstructor)[];
188
206
  default: number;
189
207
  };
208
+ minTime: {
209
+ type: StringConstructor;
210
+ validator: (val: string) => boolean;
211
+ };
212
+ maxTime: {
213
+ type: StringConstructor;
214
+ validator: (val: string) => boolean;
215
+ };
190
216
  columnsType: {
191
217
  type: PropType<TimePickerColumnType[]>;
192
218
  default: () => string[];
193
219
  };
220
+ filter: PropType<(columnType: string, options: import("../picker").PickerOption[], values: string[]) => import("../picker").PickerOption[]>;
194
221
  }>> & {
195
222
  onChange?: ((...args: any[]) => any) | undefined;
196
223
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
@@ -23,21 +23,32 @@ __export(stdin_exports, {
23
23
  module.exports = __toCommonJS(stdin_exports);
24
24
  var import_vue = require("vue");
25
25
  var import_vue2 = require("vue");
26
- var import_utils = require("../utils");
27
- var import_utils2 = require("../date-picker/utils");
26
+ var import_utils = require("../date-picker/utils");
27
+ var import_utils2 = require("../utils");
28
28
  var import_picker = require("../picker");
29
- const [name] = (0, import_utils.createNamespace)("time-picker");
30
- const timePickerProps = (0, import_utils.extend)({}, import_utils2.sharedProps, {
31
- minHour: (0, import_utils.makeNumericProp)(0),
32
- maxHour: (0, import_utils.makeNumericProp)(23),
33
- minMinute: (0, import_utils.makeNumericProp)(0),
34
- maxMinute: (0, import_utils.makeNumericProp)(59),
35
- minSecond: (0, import_utils.makeNumericProp)(0),
36
- maxSecond: (0, import_utils.makeNumericProp)(59),
29
+ const [name] = (0, import_utils2.createNamespace)("time-picker");
30
+ const validateTime = (val) => /^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/.test(val);
31
+ const fullColumns = ["hour", "minute", "second"];
32
+ const timePickerProps = (0, import_utils2.extend)({}, import_utils.sharedProps, {
33
+ minHour: (0, import_utils2.makeNumericProp)(0),
34
+ maxHour: (0, import_utils2.makeNumericProp)(23),
35
+ minMinute: (0, import_utils2.makeNumericProp)(0),
36
+ maxMinute: (0, import_utils2.makeNumericProp)(59),
37
+ minSecond: (0, import_utils2.makeNumericProp)(0),
38
+ maxSecond: (0, import_utils2.makeNumericProp)(59),
39
+ minTime: {
40
+ type: String,
41
+ validator: validateTime
42
+ },
43
+ maxTime: {
44
+ type: String,
45
+ validator: validateTime
46
+ },
37
47
  columnsType: {
38
48
  type: Array,
39
49
  default: () => ["hour", "minute"]
40
- }
50
+ },
51
+ filter: Function
41
52
  });
42
53
  var stdin_default = (0, import_vue2.defineComponent)({
43
54
  name,
@@ -48,33 +59,74 @@ var stdin_default = (0, import_vue2.defineComponent)({
48
59
  slots
49
60
  }) {
50
61
  const currentValues = (0, import_vue2.ref)(props.modelValue);
51
- const columns = (0, import_vue2.computed)(() => props.columnsType.map((type) => {
52
- const {
53
- filter,
54
- formatter
62
+ const getValidTime = (time) => {
63
+ const timeLimitArr = time.split(":");
64
+ return fullColumns.map((col, i) => props.columnsType.includes(col) ? timeLimitArr[i] : "00");
65
+ };
66
+ const columns = (0, import_vue2.computed)(() => {
67
+ let {
68
+ minHour,
69
+ maxHour,
70
+ minMinute,
71
+ maxMinute,
72
+ minSecond,
73
+ maxSecond
55
74
  } = props;
56
- switch (type) {
57
- case "hour":
58
- return (0, import_utils2.genOptions)(+props.minHour, +props.maxHour, type, formatter, filter);
59
- case "minute":
60
- return (0, import_utils2.genOptions)(+props.minMinute, +props.maxMinute, type, formatter, filter);
61
- case "second":
62
- return (0, import_utils2.genOptions)(+props.minSecond, +props.maxSecond, type, formatter, filter);
63
- default:
64
- if (process.env.NODE_ENV !== "production") {
65
- throw new Error(`[Vant] DatePicker: unsupported columns type: ${type}`);
66
- }
67
- return [];
75
+ if (props.minTime || props.maxTime) {
76
+ const fullTime = {
77
+ hour: 0,
78
+ minute: 0,
79
+ second: 0
80
+ };
81
+ props.columnsType.forEach((col, i) => {
82
+ var _a;
83
+ fullTime[col] = (_a = currentValues.value[i]) != null ? _a : 0;
84
+ });
85
+ const {
86
+ hour,
87
+ minute
88
+ } = fullTime;
89
+ if (props.minTime) {
90
+ const [minH, minM, minS] = getValidTime(props.minTime);
91
+ minHour = minH;
92
+ minMinute = +hour <= +minHour ? minM : "00";
93
+ minSecond = +hour <= +minHour && +minute <= +minMinute ? minS : "00";
94
+ }
95
+ if (props.maxTime) {
96
+ const [maxH, maxM, maxS] = getValidTime(props.maxTime);
97
+ maxHour = maxH;
98
+ maxMinute = +hour >= +maxHour ? maxM : "59";
99
+ maxSecond = +hour >= +maxHour && +minute >= +maxMinute ? maxS : "59";
100
+ }
68
101
  }
69
- }));
102
+ return props.columnsType.map((type) => {
103
+ const {
104
+ filter,
105
+ formatter
106
+ } = props;
107
+ switch (type) {
108
+ case "hour":
109
+ return (0, import_utils.genOptions)(+minHour, +maxHour, type, formatter, filter, currentValues.value);
110
+ case "minute":
111
+ return (0, import_utils.genOptions)(+minMinute, +maxMinute, type, formatter, filter, currentValues.value);
112
+ case "second":
113
+ return (0, import_utils.genOptions)(+minSecond, +maxSecond, type, formatter, filter, currentValues.value);
114
+ default:
115
+ if (process.env.NODE_ENV !== "production") {
116
+ throw new Error(`[Vant] DatePicker: unsupported columns type: ${type}`);
117
+ }
118
+ return [];
119
+ }
120
+ });
121
+ });
70
122
  (0, import_vue2.watch)(currentValues, (newValues) => {
71
- if (!(0, import_utils.isSameValue)(newValues, props.modelValue)) {
123
+ if (!(0, import_utils2.isSameValue)(newValues, props.modelValue)) {
72
124
  emit("update:modelValue", newValues);
73
125
  }
74
126
  });
75
127
  (0, import_vue2.watch)(() => props.modelValue, (newValues) => {
76
- newValues = (0, import_utils2.formatValueRange)(newValues, columns.value);
77
- if (!(0, import_utils.isSameValue)(newValues, currentValues.value)) {
128
+ newValues = (0, import_utils.formatValueRange)(newValues, columns.value);
129
+ if (!(0, import_utils2.isSameValue)(newValues, currentValues.value)) {
78
130
  currentValues.value = newValues;
79
131
  }
80
132
  }, {
@@ -90,6 +142,6 @@ var stdin_default = (0, import_vue2.defineComponent)({
90
142
  "onChange": onChange,
91
143
  "onCancel": onCancel,
92
144
  "onConfirm": onConfirm
93
- }, (0, import_utils.pick)(props, import_utils2.pickerInheritKeys)), slots);
145
+ }, (0, import_utils2.pick)(props, import_utils.pickerInheritKeys)), slots);
94
146
  }
95
147
  });
@@ -28,7 +28,7 @@ export declare const TimePicker: import("../utils").WithInstall<import("vue").De
28
28
  type: import("vue").PropType<string[]>;
29
29
  default: () => never[];
30
30
  };
31
- filter: import("vue").PropType<(columnType: string, options: import("..").PickerOption[]) => import("..").PickerOption[]>;
31
+ filter: import("vue").PropType<(columnType: string, options: import("..").PickerOption[], values?: string[] | undefined) => import("..").PickerOption[]>;
32
32
  formatter: {
33
33
  type: import("vue").PropType<(type: string, option: import("..").PickerOption) => import("..").PickerOption>;
34
34
  default: (type: string, option: import("..").PickerOption) => import("..").PickerOption;
@@ -58,10 +58,19 @@ export declare const TimePicker: import("../utils").WithInstall<import("vue").De
58
58
  type: (NumberConstructor | StringConstructor)[];
59
59
  default: number;
60
60
  };
61
+ minTime: {
62
+ type: StringConstructor;
63
+ validator: (val: string) => boolean;
64
+ };
65
+ maxTime: {
66
+ type: StringConstructor;
67
+ validator: (val: string) => boolean;
68
+ };
61
69
  columnsType: {
62
70
  type: import("vue").PropType<import("./TimePicker").TimePickerColumnType[]>;
63
71
  default: () => string[];
64
72
  };
73
+ filter: import("vue").PropType<(columnType: string, options: import("..").PickerOption[], values: string[]) => import("..").PickerOption[]>;
65
74
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "cancel" | "change" | "confirm")[], "update:modelValue" | "cancel" | "change" | "confirm", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
66
75
  loading: BooleanConstructor;
67
76
  readonly: BooleanConstructor;
@@ -91,7 +100,7 @@ export declare const TimePicker: import("../utils").WithInstall<import("vue").De
91
100
  type: import("vue").PropType<string[]>;
92
101
  default: () => never[];
93
102
  };
94
- filter: import("vue").PropType<(columnType: string, options: import("..").PickerOption[]) => import("..").PickerOption[]>;
103
+ filter: import("vue").PropType<(columnType: string, options: import("..").PickerOption[], values?: string[] | undefined) => import("..").PickerOption[]>;
95
104
  formatter: {
96
105
  type: import("vue").PropType<(type: string, option: import("..").PickerOption) => import("..").PickerOption>;
97
106
  default: (type: string, option: import("..").PickerOption) => import("..").PickerOption;
@@ -121,10 +130,19 @@ export declare const TimePicker: import("../utils").WithInstall<import("vue").De
121
130
  type: (NumberConstructor | StringConstructor)[];
122
131
  default: number;
123
132
  };
133
+ minTime: {
134
+ type: StringConstructor;
135
+ validator: (val: string) => boolean;
136
+ };
137
+ maxTime: {
138
+ type: StringConstructor;
139
+ validator: (val: string) => boolean;
140
+ };
124
141
  columnsType: {
125
142
  type: import("vue").PropType<import("./TimePicker").TimePickerColumnType[]>;
126
143
  default: () => string[];
127
144
  };
145
+ filter: import("vue").PropType<(columnType: string, options: import("..").PickerOption[], values: string[]) => import("..").PickerOption[]>;
128
146
  }>> & {
129
147
  onChange?: ((...args: any[]) => any) | undefined;
130
148
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
@@ -13,6 +13,9 @@ export declare function get(object: any, path: string): any;
13
13
  export type Writeable<T> = {
14
14
  -readonly [P in keyof T]: T[P];
15
15
  };
16
+ export type RequiredParams<T> = T extends (...args: infer P) => infer R ? (...args: {
17
+ [K in keyof P]-?: NonNullable<P[K]>;
18
+ }) => R : never;
16
19
  export declare function pick<T, U extends keyof T>(obj: T, keys: ReadonlyArray<U>, ignoreUndefined?: boolean): Writeable<Pick<T, U>>;
17
20
  export declare const isSameValue: (newValue: unknown, oldValue: unknown) => boolean;
18
21
  export declare const toArray: <T>(item: T | T[]) => T[];