vant 4.8.7 → 4.8.9

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 (51) hide show
  1. package/README.md +1 -1
  2. package/es/address-list/AddressList.mjs +3 -1
  3. package/es/address-list/AddressListItem.mjs +3 -3
  4. package/es/coupon-cell/CouponCell.d.ts +4 -4
  5. package/es/coupon-cell/CouponCell.mjs +35 -12
  6. package/es/coupon-cell/index.d.ts +3 -3
  7. package/es/coupon-list/CouponList.d.ts +3 -13
  8. package/es/coupon-list/CouponList.mjs +15 -6
  9. package/es/coupon-list/index.d.ts +2 -9
  10. package/es/date-picker/DatePicker.d.ts +6 -1
  11. package/es/date-picker/DatePicker.mjs +12 -0
  12. package/es/date-picker/index.d.ts +1 -1
  13. package/es/floating-bubble/FloatingBubble.mjs +3 -1
  14. package/es/image-preview/ImagePreviewItem.mjs +3 -1
  15. package/es/index.d.ts +1 -1
  16. package/es/index.mjs +1 -1
  17. package/es/picker-group/PickerGroup.mjs +11 -3
  18. package/es/text-ellipsis/TextEllipsis.mjs +30 -21
  19. package/es/time-picker/TimePicker.d.ts +6 -1
  20. package/es/time-picker/TimePicker.mjs +13 -1
  21. package/es/time-picker/index.d.ts +1 -1
  22. package/es/utils/basic.d.ts +1 -0
  23. package/es/utils/basic.mjs +2 -0
  24. package/lib/address-list/AddressList.js +3 -1
  25. package/lib/address-list/AddressListItem.js +3 -3
  26. package/lib/coupon-cell/CouponCell.d.ts +4 -4
  27. package/lib/coupon-cell/CouponCell.js +34 -11
  28. package/lib/coupon-cell/index.d.ts +3 -3
  29. package/lib/coupon-list/CouponList.d.ts +3 -13
  30. package/lib/coupon-list/CouponList.js +14 -5
  31. package/lib/coupon-list/index.d.ts +2 -9
  32. package/lib/date-picker/DatePicker.d.ts +6 -1
  33. package/lib/date-picker/DatePicker.js +12 -0
  34. package/lib/date-picker/index.d.ts +1 -1
  35. package/lib/floating-bubble/FloatingBubble.js +3 -1
  36. package/lib/image-preview/ImagePreviewItem.js +3 -1
  37. package/lib/index.d.ts +1 -1
  38. package/lib/index.js +1 -1
  39. package/lib/picker-group/PickerGroup.js +9 -1
  40. package/lib/text-ellipsis/TextEllipsis.js +29 -20
  41. package/lib/time-picker/TimePicker.d.ts +6 -1
  42. package/lib/time-picker/TimePicker.js +12 -0
  43. package/lib/time-picker/index.d.ts +1 -1
  44. package/lib/utils/basic.d.ts +1 -0
  45. package/lib/utils/basic.js +2 -0
  46. package/lib/vant.cjs.js +122 -44
  47. package/lib/vant.es.js +122 -44
  48. package/lib/vant.js +123 -45
  49. package/lib/vant.min.js +3 -3
  50. package/lib/web-types.json +1 -1
  51. package/package.json +10 -10
@@ -42,11 +42,11 @@ var stdin_default = (0, import_vue2.defineComponent)({
42
42
  slots,
43
43
  emit
44
44
  }) {
45
- const onClick = () => {
45
+ const onClick = (event) => {
46
46
  if (props.switchable) {
47
47
  emit("select");
48
48
  }
49
- emit("click");
49
+ emit("click", event);
50
50
  };
51
51
  const renderRightIcon = () => (0, import_vue.createVNode)(import_icon.Icon, {
52
52
  "name": props.rightIcon,
@@ -54,7 +54,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
54
54
  "onClick": (event) => {
55
55
  event.stopPropagation();
56
56
  emit("edit");
57
- emit("click");
57
+ emit("click", event);
58
58
  }
59
59
  }, null);
60
60
  const renderTag = () => {
@@ -19,7 +19,7 @@ export declare const couponCellProps: {
19
19
  default: string;
20
20
  };
21
21
  chosenCoupon: {
22
- type: (NumberConstructor | StringConstructor)[];
22
+ type: (NumberConstructor | ArrayConstructor)[];
23
23
  default: number;
24
24
  };
25
25
  };
@@ -43,7 +43,7 @@ declare const _default: import("vue").DefineComponent<{
43
43
  default: string;
44
44
  };
45
45
  chosenCoupon: {
46
- type: (NumberConstructor | StringConstructor)[];
46
+ type: (NumberConstructor | ArrayConstructor)[];
47
47
  default: number;
48
48
  };
49
49
  }, () => import("vue/jsx-runtime").JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ExtractPropTypes<{
@@ -65,7 +65,7 @@ declare const _default: import("vue").DefineComponent<{
65
65
  default: string;
66
66
  };
67
67
  chosenCoupon: {
68
- type: (NumberConstructor | StringConstructor)[];
68
+ type: (NumberConstructor | ArrayConstructor)[];
69
69
  default: number;
70
70
  };
71
71
  }>>, {
@@ -73,6 +73,6 @@ declare const _default: import("vue").DefineComponent<{
73
73
  currency: string;
74
74
  editable: boolean;
75
75
  coupons: CouponInfo[];
76
- chosenCoupon: string | number;
76
+ chosenCoupon: number | unknown[];
77
77
  }, {}>;
78
78
  export default _default;
@@ -32,33 +32,56 @@ const couponCellProps = {
32
32
  editable: import_utils.truthProp,
33
33
  coupons: (0, import_utils.makeArrayProp)(),
34
34
  currency: (0, import_utils.makeStringProp)("\xA5"),
35
- chosenCoupon: (0, import_utils.makeNumericProp)(-1)
35
+ chosenCoupon: {
36
+ type: [Number, Array],
37
+ default: -1
38
+ }
36
39
  };
37
40
  function formatValue({
38
41
  coupons,
39
42
  chosenCoupon,
40
43
  currency
41
44
  }) {
42
- const coupon = coupons[+chosenCoupon];
43
- if (coupon) {
44
- let value = 0;
45
+ const getValue = (coupon) => {
46
+ let value2 = 0;
47
+ const {
48
+ value: couponValue,
49
+ denominations
50
+ } = coupon;
45
51
  if ((0, import_utils.isDef)(coupon.value)) {
46
- ({
47
- value
48
- } = coupon);
52
+ value2 = couponValue;
49
53
  } else if ((0, import_utils.isDef)(coupon.denominations)) {
50
- value = coupon.denominations;
54
+ value2 = denominations;
55
+ }
56
+ return value2;
57
+ };
58
+ let value = 0, isExist = false;
59
+ if (Array.isArray(chosenCoupon)) {
60
+ chosenCoupon.forEach((i) => {
61
+ const coupon = coupons[+i];
62
+ if (coupon) {
63
+ isExist = true;
64
+ value += getValue(coupon);
65
+ }
66
+ });
67
+ } else {
68
+ const coupon = coupons[+chosenCoupon];
69
+ if (coupon) {
70
+ isExist = true;
71
+ value = getValue(coupon);
51
72
  }
52
- return `-${currency} ${(value / 100).toFixed(2)}`;
53
73
  }
54
- return coupons.length === 0 ? t("noCoupon") : t("count", coupons.length);
74
+ if (!isExist) {
75
+ return coupons.length === 0 ? t("noCoupon") : t("count", coupons.length);
76
+ }
77
+ return `-${currency} ${(value / 100).toFixed(2)}`;
55
78
  }
56
79
  var stdin_default = (0, import_vue2.defineComponent)({
57
80
  name,
58
81
  props: couponCellProps,
59
82
  setup(props) {
60
83
  return () => {
61
- const selected = props.coupons[+props.chosenCoupon];
84
+ const selected = Array.isArray(props.chosenCoupon) ? props.chosenCoupon.length : props.coupons[+props.chosenCoupon];
62
85
  return (0, import_vue.createVNode)(import_cell.Cell, {
63
86
  "class": bem(),
64
87
  "value": formatValue(props),
@@ -17,7 +17,7 @@ export declare const CouponCell: import("../utils").WithInstall<import("vue").De
17
17
  default: string;
18
18
  };
19
19
  chosenCoupon: {
20
- type: (NumberConstructor | StringConstructor)[];
20
+ type: (NumberConstructor | ArrayConstructor)[];
21
21
  default: number;
22
22
  };
23
23
  }, () => import("vue/jsx-runtime").JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
@@ -39,7 +39,7 @@ export declare const CouponCell: import("../utils").WithInstall<import("vue").De
39
39
  default: string;
40
40
  };
41
41
  chosenCoupon: {
42
- type: (NumberConstructor | StringConstructor)[];
42
+ type: (NumberConstructor | ArrayConstructor)[];
43
43
  default: number;
44
44
  };
45
45
  }>>, {
@@ -47,7 +47,7 @@ export declare const CouponCell: import("../utils").WithInstall<import("vue").De
47
47
  currency: string;
48
48
  editable: boolean;
49
49
  coupons: import("..").CouponInfo[];
50
- chosenCoupon: string | number;
50
+ chosenCoupon: number | unknown[];
51
51
  }, {}>>;
52
52
  export default CouponCell;
53
53
  export { couponCellProps } from './CouponCell';
@@ -18,10 +18,7 @@ export declare const couponListProps: {
18
18
  default: true;
19
19
  };
20
20
  emptyImage: StringConstructor;
21
- chosenCoupon: {
22
- type: NumberConstructor;
23
- default: number;
24
- };
21
+ chosenCoupon: (NumberConstructor | ArrayConstructor)[];
25
22
  enabledTitle: StringConstructor;
26
23
  disabledTitle: StringConstructor;
27
24
  disabledCoupons: {
@@ -69,10 +66,7 @@ declare const _default: import("vue").DefineComponent<{
69
66
  default: true;
70
67
  };
71
68
  emptyImage: StringConstructor;
72
- chosenCoupon: {
73
- type: NumberConstructor;
74
- default: number;
75
- };
69
+ chosenCoupon: (NumberConstructor | ArrayConstructor)[];
76
70
  enabledTitle: StringConstructor;
77
71
  disabledTitle: StringConstructor;
78
72
  disabledCoupons: {
@@ -118,10 +112,7 @@ declare const _default: import("vue").DefineComponent<{
118
112
  default: true;
119
113
  };
120
114
  emptyImage: StringConstructor;
121
- chosenCoupon: {
122
- type: NumberConstructor;
123
- default: number;
124
- };
115
+ chosenCoupon: (NumberConstructor | ArrayConstructor)[];
125
116
  enabledTitle: StringConstructor;
126
117
  disabledTitle: StringConstructor;
127
118
  disabledCoupons: {
@@ -157,7 +148,6 @@ declare const _default: import("vue").DefineComponent<{
157
148
  code: string;
158
149
  currency: string;
159
150
  coupons: CouponInfo[];
160
- chosenCoupon: number;
161
151
  showCount: boolean;
162
152
  disabledCoupons: CouponInfo[];
163
153
  showExchangeBar: boolean;
@@ -39,7 +39,7 @@ const couponListProps = {
39
39
  currency: (0, import_utils.makeStringProp)("\xA5"),
40
40
  showCount: import_utils.truthProp,
41
41
  emptyImage: String,
42
- chosenCoupon: (0, import_utils.makeNumberProp)(-1),
42
+ chosenCoupon: [Number, Array],
43
43
  enabledTitle: String,
44
44
  disabledTitle: String,
45
45
  disabledCoupons: (0, import_utils.makeArrayProp)(),
@@ -123,6 +123,15 @@ var stdin_default = (0, import_vue2.defineComponent)({
123
123
  } = props;
124
124
  const count = props.showCount ? ` (${coupons.length})` : "";
125
125
  const title = (props.enabledTitle || t("enable")) + count;
126
+ const getChosenCoupon = (chosenCoupon = [], value = 0) => {
127
+ const unrefChosenCoupon = (0, import_vue2.unref)(chosenCoupon);
128
+ const index = unrefChosenCoupon.indexOf(value);
129
+ if (index === -1) {
130
+ return [...unrefChosenCoupon, value];
131
+ }
132
+ unrefChosenCoupon.splice(index, 1);
133
+ return [...unrefChosenCoupon];
134
+ };
126
135
  return (0, import_vue.createVNode)(import_tab.Tab, {
127
136
  "title": title
128
137
  }, {
@@ -139,9 +148,9 @@ var stdin_default = (0, import_vue2.defineComponent)({
139
148
  "key": coupon.id,
140
149
  "ref": setCouponRefs(index),
141
150
  "coupon": coupon,
142
- "chosen": index === props.chosenCoupon,
151
+ "chosen": Array.isArray(props.chosenCoupon) ? props.chosenCoupon.includes(index) : index === props.chosenCoupon,
143
152
  "currency": props.currency,
144
- "onClick": () => emit("change", index)
153
+ "onClick": () => emit("change", Array.isArray(props.chosenCoupon) ? getChosenCoupon(props.chosenCoupon, index) : index)
145
154
  }, null)), !coupons.length && renderEmpty(), (_a = slots["list-footer"]) == null ? void 0 : _a.call(slots)])];
146
155
  }
147
156
  });
@@ -194,13 +203,13 @@ var stdin_default = (0, import_vue2.defineComponent)({
194
203
  default: () => [renderCouponTab(), renderDisabledTab()]
195
204
  }), (0, import_vue.createVNode)("div", {
196
205
  "class": bem("bottom")
197
- }, [(0, import_vue.withDirectives)((0, import_vue.createVNode)(import_button.Button, {
206
+ }, [slots["list-button"] ? slots["list-button"]() : (0, import_vue.withDirectives)((0, import_vue.createVNode)(import_button.Button, {
198
207
  "round": true,
199
208
  "block": true,
200
209
  "type": "primary",
201
210
  "class": bem("close"),
202
211
  "text": props.closeButtonText || t("close"),
203
- "onClick": () => emit("change", -1)
212
+ "onClick": () => emit("change", Array.isArray(props.chosenCoupon) ? [] : -1)
204
213
  }, null), [[import_vue.vShow, props.showCloseButton]])])]);
205
214
  }
206
215
  });
@@ -16,10 +16,7 @@ export declare const CouponList: import("../utils").WithInstall<import("vue").De
16
16
  default: true;
17
17
  };
18
18
  emptyImage: StringConstructor;
19
- chosenCoupon: {
20
- type: NumberConstructor;
21
- default: number;
22
- };
19
+ chosenCoupon: (NumberConstructor | ArrayConstructor)[];
23
20
  enabledTitle: StringConstructor;
24
21
  disabledTitle: StringConstructor;
25
22
  disabledCoupons: {
@@ -65,10 +62,7 @@ export declare const CouponList: import("../utils").WithInstall<import("vue").De
65
62
  default: true;
66
63
  };
67
64
  emptyImage: StringConstructor;
68
- chosenCoupon: {
69
- type: NumberConstructor;
70
- default: number;
71
- };
65
+ chosenCoupon: (NumberConstructor | ArrayConstructor)[];
72
66
  enabledTitle: StringConstructor;
73
67
  disabledTitle: StringConstructor;
74
68
  disabledCoupons: {
@@ -104,7 +98,6 @@ export declare const CouponList: import("../utils").WithInstall<import("vue").De
104
98
  code: string;
105
99
  currency: string;
106
100
  coupons: import("..").CouponInfo[];
107
- chosenCoupon: number;
108
101
  showCount: boolean;
109
102
  disabledCoupons: import("..").CouponInfo[];
110
103
  showExchangeBar: boolean;
@@ -1,4 +1,4 @@
1
- import { type PropType, type ExtractPropTypes } from 'vue';
1
+ import { type ComponentPublicInstance, type PropType, type ExtractPropTypes } from 'vue';
2
2
  export type DatePickerColumnType = 'year' | 'month' | 'day';
3
3
  export declare const datePickerProps: {
4
4
  loading: BooleanConstructor;
@@ -50,7 +50,12 @@ export declare const datePickerProps: {
50
50
  validator: (val: unknown) => val is Date;
51
51
  };
52
52
  };
53
+ export type DatePickerExpose = {
54
+ confirm: () => void;
55
+ getSelectedDate: () => string[];
56
+ };
53
57
  export type DatePickerProps = ExtractPropTypes<typeof datePickerProps>;
58
+ export type DatePickerInstance = ComponentPublicInstance<DatePickerProps, DatePickerExpose>;
54
59
  declare const _default: import("vue").DefineComponent<{
55
60
  loading: BooleanConstructor;
56
61
  readonly: BooleanConstructor;
@@ -25,6 +25,7 @@ var import_vue = require("vue");
25
25
  var import_vue2 = require("vue");
26
26
  var import_utils = require("../utils");
27
27
  var import_utils2 = require("./utils");
28
+ var import_use_expose = require("../composables/use-expose");
28
29
  var import_picker = require("../picker");
29
30
  const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
30
31
  const [name] = (0, import_utils.createNamespace)("date-picker");
@@ -54,6 +55,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
54
55
  }) {
55
56
  const currentValues = (0, import_vue2.ref)(props.modelValue);
56
57
  const updatedByExternalSources = (0, import_vue2.ref)(false);
58
+ const pickerRef = (0, import_vue2.ref)();
57
59
  const genYearOptions = () => {
58
60
  const minYear = props.minDate.getFullYear();
59
61
  const maxYear = props.maxDate.getFullYear();
@@ -95,6 +97,11 @@ var stdin_default = (0, import_vue2.defineComponent)({
95
97
  const maxDate = isMaxYear(year) && isMaxMonth(month) ? props.maxDate.getDate() : (0, import_utils2.getMonthEndDay)(year, month);
96
98
  return (0, import_utils2.genOptions)(minDate, maxDate, "day", props.formatter, props.filter);
97
99
  };
100
+ const confirm = () => {
101
+ var _a;
102
+ return (_a = pickerRef.value) == null ? void 0 : _a.confirm();
103
+ };
104
+ const getSelectedDate = () => currentValues.value;
98
105
  const columns = (0, import_vue2.computed)(() => props.columnsType.map((type) => {
99
106
  switch (type) {
100
107
  case "year":
@@ -128,7 +135,12 @@ var stdin_default = (0, import_vue2.defineComponent)({
128
135
  const onChange = (...args) => emit("change", ...args);
129
136
  const onCancel = (...args) => emit("cancel", ...args);
130
137
  const onConfirm = (...args) => emit("confirm", ...args);
138
+ (0, import_use_expose.useExpose)({
139
+ confirm,
140
+ getSelectedDate
141
+ });
131
142
  return () => (0, import_vue.createVNode)(import_picker.Picker, (0, import_vue.mergeProps)({
143
+ "ref": pickerRef,
132
144
  "modelValue": currentValues.value,
133
145
  "onUpdate:modelValue": ($event) => currentValues.value = $event,
134
146
  "columns": columns.value,
@@ -119,7 +119,7 @@ export declare const DatePicker: import("../utils").WithInstall<import("vue").De
119
119
  export default DatePicker;
120
120
  export { datePickerProps } from './DatePicker';
121
121
  export type { DatePickerProps };
122
- export type { DatePickerColumnType } from './DatePicker';
122
+ export type { DatePickerColumnType, DatePickerInstance } from './DatePicker';
123
123
  declare module 'vue' {
124
124
  interface GlobalComponents {
125
125
  VanDatePicker: typeof DatePicker;
@@ -177,7 +177,9 @@ var stdin_default = (0, import_vue2.defineComponent)({
177
177
  initialized = true;
178
178
  });
179
179
  });
180
- (0, import_vue2.watch)([import_utils.windowWidth, import_utils.windowHeight, () => props.gap, () => props.offset], updateState);
180
+ (0, import_vue2.watch)([import_utils.windowWidth, import_utils.windowHeight, () => props.gap, () => props.offset], updateState, {
181
+ deep: true
182
+ });
181
183
  const show = (0, import_vue2.ref)(true);
182
184
  (0, import_vue2.onActivated)(() => {
183
185
  show.value = true;
@@ -340,7 +340,9 @@ var stdin_default = (0, import_vue2.defineComponent)({
340
340
  default: () => [slots.image ? (0, import_vue.createVNode)("div", {
341
341
  "class": bem("image-wrap")
342
342
  }, [slots.image({
343
- src: props.src
343
+ src: props.src,
344
+ onLoad,
345
+ style: imageStyle.value
344
346
  })]) : (0, import_vue.createVNode)(import_image.Image, {
345
347
  "ref": imageRef,
346
348
  "src": props.src,
package/lib/index.d.ts CHANGED
@@ -106,4 +106,4 @@ declare namespace _default {
106
106
  }
107
107
  export default _default;
108
108
  export function install(app: any): void;
109
- export const version: "4.8.7";
109
+ export const version: "4.8.9";
package/lib/index.js CHANGED
@@ -226,7 +226,7 @@ __reExport(stdin_exports, require("./toast"), module.exports);
226
226
  __reExport(stdin_exports, require("./tree-select"), module.exports);
227
227
  __reExport(stdin_exports, require("./uploader"), module.exports);
228
228
  __reExport(stdin_exports, require("./watermark"), module.exports);
229
- const version = "4.8.7";
229
+ const version = "4.8.9";
230
230
  function install(app) {
231
231
  const components = [
232
232
  import_action_bar.ActionBar,
@@ -72,7 +72,15 @@ var stdin_default = (0, import_vue2.defineComponent)({
72
72
  const onCancel = () => emit("cancel");
73
73
  return () => {
74
74
  var _a, _b;
75
- const childNodes = (_b = (_a = slots.default) == null ? void 0 : _a.call(slots)) == null ? void 0 : _b.filter((node) => node.type !== import_vue2.Comment);
75
+ let childNodes = (_b = (_a = slots.default) == null ? void 0 : _a.call(slots)) == null ? void 0 : _b.filter((node) => node.type !== import_vue2.Comment).map((node) => {
76
+ if (node.type === import_vue2.Fragment) {
77
+ return node.children;
78
+ }
79
+ return node;
80
+ });
81
+ if (childNodes) {
82
+ childNodes = (0, import_utils.flat)(childNodes);
83
+ }
76
84
  const confirmButtonText = showNextButton() ? props.nextStepText : props.confirmButtonText;
77
85
  return (0, import_vue.createVNode)("div", {
78
86
  "class": bem()
@@ -46,6 +46,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
46
46
  const expanded = (0, import_vue2.ref)(false);
47
47
  const hasAction = (0, import_vue2.ref)(false);
48
48
  const root = (0, import_vue2.ref)();
49
+ let needRecalculate = false;
49
50
  const actionText = (0, import_vue2.computed)(() => expanded.value ? props.collapseText : props.expandText);
50
51
  const pxToNum = (value) => {
51
52
  if (!value)
@@ -53,26 +54,26 @@ var stdin_default = (0, import_vue2.defineComponent)({
53
54
  const match = value.match(/^\d*(\.\d*)?/);
54
55
  return match ? Number(match[0]) : 0;
55
56
  };
57
+ const cloneContainer = () => {
58
+ if (!root.value || !root.value.isConnected)
59
+ return;
60
+ const originStyle = window.getComputedStyle(root.value);
61
+ const container = document.createElement("div");
62
+ const styleNames = Array.prototype.slice.apply(originStyle);
63
+ styleNames.forEach((name2) => {
64
+ container.style.setProperty(name2, originStyle.getPropertyValue(name2));
65
+ });
66
+ container.style.position = "fixed";
67
+ container.style.zIndex = "-9999";
68
+ container.style.top = "-9999px";
69
+ container.style.height = "auto";
70
+ container.style.minHeight = "auto";
71
+ container.style.maxHeight = "auto";
72
+ container.innerText = props.content;
73
+ document.body.appendChild(container);
74
+ return container;
75
+ };
56
76
  const calcEllipsised = () => {
57
- const cloneContainer = () => {
58
- if (!root.value)
59
- return;
60
- const originStyle = window.getComputedStyle(root.value);
61
- const container2 = document.createElement("div");
62
- const styleNames = Array.prototype.slice.apply(originStyle);
63
- styleNames.forEach((name2) => {
64
- container2.style.setProperty(name2, originStyle.getPropertyValue(name2));
65
- });
66
- container2.style.position = "fixed";
67
- container2.style.zIndex = "-9999";
68
- container2.style.top = "-9999px";
69
- container2.style.height = "auto";
70
- container2.style.minHeight = "auto";
71
- container2.style.maxHeight = "auto";
72
- container2.innerText = props.content;
73
- document.body.appendChild(container2);
74
- return container2;
75
- };
76
77
  const calcEllipsisText = (container2, maxHeight2) => {
77
78
  const {
78
79
  content,
@@ -124,8 +125,10 @@ var stdin_default = (0, import_vue2.defineComponent)({
124
125
  return container2.innerText;
125
126
  };
126
127
  const container = cloneContainer();
127
- if (!container)
128
+ if (!container) {
129
+ needRecalculate = true;
128
130
  return;
131
+ }
129
132
  const {
130
133
  paddingBottom,
131
134
  paddingTop,
@@ -158,6 +161,12 @@ var stdin_default = (0, import_vue2.defineComponent)({
158
161
  }, [action]);
159
162
  };
160
163
  (0, import_vue2.onMounted)(calcEllipsised);
164
+ (0, import_vue2.onActivated)(() => {
165
+ if (needRecalculate) {
166
+ needRecalculate = false;
167
+ calcEllipsised();
168
+ }
169
+ });
161
170
  (0, import_vue2.watch)([import_utils.windowWidth, () => [props.content, props.rows, props.position]], calcEllipsised);
162
171
  (0, import_use_expose.useExpose)({
163
172
  toggle
@@ -1,4 +1,4 @@
1
- import { type ExtractPropTypes, type PropType } from 'vue';
1
+ import { type ExtractPropTypes, type PropType, type ComponentPublicInstance } from 'vue';
2
2
  export type TimePickerColumnType = 'hour' | 'minute' | 'second';
3
3
  export declare const timePickerProps: {
4
4
  loading: BooleanConstructor;
@@ -74,6 +74,11 @@ export declare const timePickerProps: {
74
74
  filter: PropType<(columnType: string, options: import("../picker").PickerOption[], values: string[]) => import("../picker").PickerOption[]>;
75
75
  };
76
76
  export type TimePickerProps = ExtractPropTypes<typeof timePickerProps>;
77
+ export type TimePickerExpose = {
78
+ confirm: () => void;
79
+ getSelectedTime: () => string[];
80
+ };
81
+ export type TimePickerInstance = ComponentPublicInstance<TimePickerProps, TimePickerExpose>;
77
82
  declare const _default: import("vue").DefineComponent<{
78
83
  loading: BooleanConstructor;
79
84
  readonly: BooleanConstructor;
@@ -25,6 +25,7 @@ var import_vue = require("vue");
25
25
  var import_vue2 = require("vue");
26
26
  var import_utils = require("../date-picker/utils");
27
27
  var import_utils2 = require("../utils");
28
+ var import_use_expose = require("../composables/use-expose");
28
29
  var import_picker = require("../picker");
29
30
  const [name] = (0, import_utils2.createNamespace)("time-picker");
30
31
  const validateTime = (val) => /^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/.test(val);
@@ -59,10 +60,16 @@ var stdin_default = (0, import_vue2.defineComponent)({
59
60
  slots
60
61
  }) {
61
62
  const currentValues = (0, import_vue2.ref)(props.modelValue);
63
+ const pickerRef = (0, import_vue2.ref)();
62
64
  const getValidTime = (time) => {
63
65
  const timeLimitArr = time.split(":");
64
66
  return fullColumns.map((col, i) => props.columnsType.includes(col) ? timeLimitArr[i] : "00");
65
67
  };
68
+ const confirm = () => {
69
+ var _a;
70
+ return (_a = pickerRef.value) == null ? void 0 : _a.confirm();
71
+ };
72
+ const getSelectedTime = () => currentValues.value;
66
73
  const columns = (0, import_vue2.computed)(() => {
67
74
  let {
68
75
  minHour,
@@ -135,7 +142,12 @@ var stdin_default = (0, import_vue2.defineComponent)({
135
142
  const onChange = (...args) => emit("change", ...args);
136
143
  const onCancel = (...args) => emit("cancel", ...args);
137
144
  const onConfirm = (...args) => emit("confirm", ...args);
145
+ (0, import_use_expose.useExpose)({
146
+ confirm,
147
+ getSelectedTime
148
+ });
138
149
  return () => (0, import_vue.createVNode)(import_picker.Picker, (0, import_vue.mergeProps)({
150
+ "ref": pickerRef,
139
151
  "modelValue": currentValues.value,
140
152
  "onUpdate:modelValue": ($event) => currentValues.value = $event,
141
153
  "columns": columns.value,
@@ -169,7 +169,7 @@ export declare const TimePicker: import("../utils").WithInstall<import("vue").De
169
169
  export default TimePicker;
170
170
  export { timePickerProps } from './TimePicker';
171
171
  export type { TimePickerProps };
172
- export type { TimePickerColumnType } from './TimePicker';
172
+ export type { TimePickerColumnType, TimePickerInstance } from './TimePicker';
173
173
  declare module 'vue' {
174
174
  interface GlobalComponents {
175
175
  VanTimePicker: typeof TimePicker;
@@ -27,3 +27,4 @@ export type RequiredParams<T> = T extends (...args: infer P) => infer R ? (...ar
27
27
  export declare function pick<T, U extends keyof T>(obj: T, keys: ReadonlyArray<U>, ignoreUndefined?: boolean): Writeable<Pick<T, U>>;
28
28
  export declare const isSameValue: (newValue: unknown, oldValue: unknown) => boolean;
29
29
  export declare const toArray: <T>(item: T | T[]) => T[];
30
+ export declare const flat: <T>(arr: (T | T[])[]) => T[];
@@ -18,6 +18,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
18
18
  var stdin_exports = {};
19
19
  __export(stdin_exports, {
20
20
  extend: () => extend,
21
+ flat: () => flat,
21
22
  get: () => get,
22
23
  inBrowser: () => inBrowser,
23
24
  isDate: () => isDate,
@@ -71,3 +72,4 @@ function pick(obj, keys, ignoreUndefined) {
71
72
  }
72
73
  const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
73
74
  const toArray = (item) => Array.isArray(item) ? item : [item];
75
+ const flat = (arr) => arr.reduce((acc, val) => acc.concat(val), []);