vant 4.4.1 → 4.6.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 (161) 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/barrage/index.d.ts +1 -1
  8. package/es/barrage/types.d.ts +6 -0
  9. package/es/composables/use-touch.d.ts +1 -0
  10. package/es/composables/use-touch.mjs +8 -1
  11. package/es/config-provider/types.d.ts +1 -1
  12. package/es/date-picker/DatePicker.d.ts +3 -3
  13. package/es/date-picker/index.d.ts +2 -2
  14. package/es/date-picker/utils.d.ts +4 -2
  15. package/es/date-picker/utils.mjs +8 -3
  16. package/es/dropdown-menu/DropdownMenu.mjs +10 -3
  17. package/es/dropdown-menu/index.d.ts +1 -1
  18. package/es/dropdown-menu/types.d.ts +5 -1
  19. package/es/field/Field.mjs +1 -1
  20. package/es/floating-bubble/FloatingBubble.d.ts +86 -0
  21. package/es/floating-bubble/FloatingBubble.mjs +177 -0
  22. package/es/floating-bubble/index.css +1 -0
  23. package/es/floating-bubble/index.d.ts +63 -0
  24. package/es/floating-bubble/index.mjs +10 -0
  25. package/es/floating-bubble/style/index.d.ts +1 -0
  26. package/es/floating-bubble/style/index.mjs +4 -0
  27. package/es/floating-bubble/types.d.ts +8 -0
  28. package/es/floating-bubble/types.mjs +0 -0
  29. package/es/floating-panel/FloatingPanel.d.ts +77 -0
  30. package/es/floating-panel/FloatingPanel.mjs +127 -0
  31. package/es/floating-panel/index.css +1 -0
  32. package/es/floating-panel/index.d.ts +61 -0
  33. package/es/floating-panel/index.mjs +10 -0
  34. package/es/floating-panel/style/index.d.ts +1 -0
  35. package/es/floating-panel/style/index.mjs +2 -0
  36. package/es/floating-panel/types.d.ts +9 -0
  37. package/es/floating-panel/types.mjs +0 -0
  38. package/es/image-preview/ImagePreviewItem.mjs +1 -2
  39. package/es/index.d.ts +4 -1
  40. package/es/index.mjs +10 -1
  41. package/es/picker/PickerColumn.mjs +7 -2
  42. package/es/rate/Rate.d.ts +4 -0
  43. package/es/rate/Rate.mjs +16 -10
  44. package/es/rate/index.css +1 -1
  45. package/es/rate/index.d.ts +3 -0
  46. package/es/rolling-text/RollingText.d.ts +104 -0
  47. package/es/rolling-text/RollingText.mjs +98 -0
  48. package/es/rolling-text/RollingTextItem.d.ts +67 -0
  49. package/es/rolling-text/RollingTextItem.mjs +47 -0
  50. package/es/rolling-text/index.css +1 -0
  51. package/es/rolling-text/index.d.ts +79 -0
  52. package/es/rolling-text/index.mjs +10 -0
  53. package/es/rolling-text/style/index.d.ts +1 -0
  54. package/es/rolling-text/style/index.mjs +2 -0
  55. package/es/rolling-text/types.d.ts +17 -0
  56. package/es/rolling-text/types.mjs +0 -0
  57. package/es/signature/index.d.ts +1 -0
  58. package/es/signature/types.d.ts +6 -0
  59. package/es/signature/types.mjs +0 -0
  60. package/es/slider/Slider.d.ts +1 -1
  61. package/es/slider/Slider.mjs +10 -2
  62. package/es/slider/index.d.ts +1 -1
  63. package/es/stepper/Stepper.d.ts +1 -1
  64. package/es/stepper/index.d.ts +1 -1
  65. package/es/time-picker/TimePicker.d.ts +31 -4
  66. package/es/time-picker/TimePicker.mjs +73 -21
  67. package/es/time-picker/index.d.ts +20 -2
  68. package/es/utils/basic.d.ts +3 -0
  69. package/es/utils/closest.d.ts +1 -0
  70. package/es/utils/closest.mjs +8 -0
  71. package/es/utils/constant.d.ts +1 -0
  72. package/es/utils/constant.mjs +3 -1
  73. package/es/utils/index.d.ts +1 -0
  74. package/es/utils/index.mjs +1 -0
  75. package/es/watermark/index.d.ts +1 -0
  76. package/es/watermark/types.d.ts +3 -0
  77. package/es/watermark/types.mjs +0 -0
  78. package/lib/address-list/AddressList.d.ts +13 -0
  79. package/lib/address-list/AddressList.js +3 -1
  80. package/lib/address-list/AddressListItem.d.ts +9 -0
  81. package/lib/address-list/AddressListItem.js +3 -2
  82. package/lib/address-list/index.d.ts +9 -0
  83. package/lib/back-top/BackTop.js +13 -0
  84. package/lib/barrage/index.d.ts +1 -1
  85. package/lib/barrage/types.d.ts +6 -0
  86. package/lib/composables/use-touch.d.ts +1 -0
  87. package/lib/composables/use-touch.js +8 -1
  88. package/lib/config-provider/types.d.ts +1 -1
  89. package/lib/date-picker/DatePicker.d.ts +3 -3
  90. package/lib/date-picker/index.d.ts +2 -2
  91. package/lib/date-picker/utils.d.ts +4 -2
  92. package/lib/date-picker/utils.js +2 -2
  93. package/lib/dropdown-menu/DropdownMenu.js +10 -3
  94. package/lib/dropdown-menu/index.d.ts +1 -1
  95. package/lib/dropdown-menu/types.d.ts +5 -1
  96. package/lib/field/Field.js +1 -1
  97. package/lib/floating-bubble/FloatingBubble.d.ts +86 -0
  98. package/lib/floating-bubble/FloatingBubble.js +206 -0
  99. package/lib/floating-bubble/index.css +1 -0
  100. package/lib/floating-bubble/index.d.ts +63 -0
  101. package/lib/floating-bubble/index.js +39 -0
  102. package/lib/floating-bubble/style/index.d.ts +1 -0
  103. package/lib/floating-bubble/style/index.js +4 -0
  104. package/lib/floating-bubble/types.d.ts +8 -0
  105. package/lib/floating-bubble/types.js +15 -0
  106. package/lib/floating-panel/FloatingPanel.d.ts +77 -0
  107. package/lib/floating-panel/FloatingPanel.js +146 -0
  108. package/lib/floating-panel/index.css +1 -0
  109. package/lib/floating-panel/index.d.ts +61 -0
  110. package/lib/floating-panel/index.js +39 -0
  111. package/lib/floating-panel/style/index.d.ts +1 -0
  112. package/lib/floating-panel/style/index.js +2 -0
  113. package/lib/floating-panel/types.d.ts +9 -0
  114. package/lib/floating-panel/types.js +15 -0
  115. package/lib/image-preview/ImagePreviewItem.js +1 -2
  116. package/lib/index.css +1 -1
  117. package/lib/index.d.ts +4 -1
  118. package/lib/index.js +10 -1
  119. package/lib/picker/PickerColumn.js +7 -2
  120. package/lib/rate/Rate.d.ts +4 -0
  121. package/lib/rate/Rate.js +16 -10
  122. package/lib/rate/index.css +1 -1
  123. package/lib/rate/index.d.ts +3 -0
  124. package/lib/rolling-text/RollingText.d.ts +104 -0
  125. package/lib/rolling-text/RollingText.js +127 -0
  126. package/lib/rolling-text/RollingTextItem.d.ts +67 -0
  127. package/lib/rolling-text/RollingTextItem.js +66 -0
  128. package/lib/rolling-text/index.css +1 -0
  129. package/lib/rolling-text/index.d.ts +79 -0
  130. package/lib/rolling-text/index.js +39 -0
  131. package/lib/rolling-text/style/index.d.ts +1 -0
  132. package/lib/rolling-text/style/index.js +2 -0
  133. package/lib/rolling-text/types.d.ts +17 -0
  134. package/lib/rolling-text/types.js +15 -0
  135. package/lib/signature/index.d.ts +1 -0
  136. package/lib/signature/types.d.ts +6 -0
  137. package/lib/signature/types.js +15 -0
  138. package/lib/slider/Slider.d.ts +1 -1
  139. package/lib/slider/Slider.js +10 -2
  140. package/lib/slider/index.d.ts +1 -1
  141. package/lib/stepper/Stepper.d.ts +1 -1
  142. package/lib/stepper/index.d.ts +1 -1
  143. package/lib/time-picker/TimePicker.d.ts +31 -4
  144. package/lib/time-picker/TimePicker.js +84 -32
  145. package/lib/time-picker/index.d.ts +20 -2
  146. package/lib/utils/basic.d.ts +3 -0
  147. package/lib/utils/closest.d.ts +1 -0
  148. package/lib/utils/closest.js +27 -0
  149. package/lib/utils/constant.d.ts +1 -0
  150. package/lib/utils/constant.js +3 -1
  151. package/lib/utils/index.d.ts +1 -0
  152. package/lib/utils/index.js +1 -0
  153. package/lib/vant.cjs.js +2547 -2019
  154. package/lib/vant.es.js +2547 -2019
  155. package/lib/vant.js +2544 -2016
  156. package/lib/vant.min.js +1 -1
  157. package/lib/watermark/index.d.ts +1 -0
  158. package/lib/watermark/types.d.ts +3 -0
  159. package/lib/watermark/types.js +15 -0
  160. package/lib/web-types.json +1 -1
  161. package/package.json +1 -1
package/lib/index.d.ts CHANGED
@@ -35,6 +35,8 @@ export * from "./dropdown-item";
35
35
  export * from "./dropdown-menu";
36
36
  export * from "./empty";
37
37
  export * from "./field";
38
+ export * from "./floating-bubble";
39
+ export * from "./floating-panel";
38
40
  export * from "./form";
39
41
  export * from "./grid";
40
42
  export * from "./grid-item";
@@ -63,6 +65,7 @@ export * from "./pull-refresh";
63
65
  export * from "./radio";
64
66
  export * from "./radio-group";
65
67
  export * from "./rate";
68
+ export * from "./rolling-text";
66
69
  export * from "./row";
67
70
  export * from "./search";
68
71
  export * from "./share-sheet";
@@ -102,4 +105,4 @@ declare namespace _default {
102
105
  }
103
106
  export default _default;
104
107
  export function install(app: any): void;
105
- export const version: "4.4.1";
108
+ export const version: "4.6.0";
package/lib/index.js CHANGED
@@ -60,6 +60,8 @@ 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_bubble = require("./floating-bubble");
64
+ var import_floating_panel = require("./floating-panel");
63
65
  var import_form = require("./form");
64
66
  var import_grid = require("./grid");
65
67
  var import_grid_item = require("./grid-item");
@@ -87,6 +89,7 @@ var import_pull_refresh = require("./pull-refresh");
87
89
  var import_radio = require("./radio");
88
90
  var import_radio_group = require("./radio-group");
89
91
  var import_rate = require("./rate");
92
+ var import_rolling_text = require("./rolling-text");
90
93
  var import_row = require("./row");
91
94
  var import_search = require("./search");
92
95
  var import_share_sheet = require("./share-sheet");
@@ -157,6 +160,8 @@ __reExport(stdin_exports, require("./dropdown-item"), module.exports);
157
160
  __reExport(stdin_exports, require("./dropdown-menu"), module.exports);
158
161
  __reExport(stdin_exports, require("./empty"), module.exports);
159
162
  __reExport(stdin_exports, require("./field"), module.exports);
163
+ __reExport(stdin_exports, require("./floating-bubble"), module.exports);
164
+ __reExport(stdin_exports, require("./floating-panel"), module.exports);
160
165
  __reExport(stdin_exports, require("./form"), module.exports);
161
166
  __reExport(stdin_exports, require("./grid"), module.exports);
162
167
  __reExport(stdin_exports, require("./grid-item"), module.exports);
@@ -185,6 +190,7 @@ __reExport(stdin_exports, require("./pull-refresh"), module.exports);
185
190
  __reExport(stdin_exports, require("./radio"), module.exports);
186
191
  __reExport(stdin_exports, require("./radio-group"), module.exports);
187
192
  __reExport(stdin_exports, require("./rate"), module.exports);
193
+ __reExport(stdin_exports, require("./rolling-text"), module.exports);
188
194
  __reExport(stdin_exports, require("./row"), module.exports);
189
195
  __reExport(stdin_exports, require("./search"), module.exports);
190
196
  __reExport(stdin_exports, require("./share-sheet"), module.exports);
@@ -218,7 +224,7 @@ __reExport(stdin_exports, require("./toast"), module.exports);
218
224
  __reExport(stdin_exports, require("./tree-select"), module.exports);
219
225
  __reExport(stdin_exports, require("./uploader"), module.exports);
220
226
  __reExport(stdin_exports, require("./watermark"), module.exports);
221
- const version = "4.4.1";
227
+ const version = "4.6.0";
222
228
  function install(app) {
223
229
  const components = [
224
230
  import_action_bar.ActionBar,
@@ -258,6 +264,8 @@ function install(app) {
258
264
  import_dropdown_menu.DropdownMenu,
259
265
  import_empty.Empty,
260
266
  import_field.Field,
267
+ import_floating_bubble.FloatingBubble,
268
+ import_floating_panel.FloatingPanel,
261
269
  import_form.Form,
262
270
  import_grid.Grid,
263
271
  import_grid_item.GridItem,
@@ -285,6 +293,7 @@ function install(app) {
285
293
  import_radio.Radio,
286
294
  import_radio_group.RadioGroup,
287
295
  import_rate.Rate,
296
+ import_rolling_text.RollingText,
288
297
  import_row.Row,
289
298
  import_search.Search,
290
299
  import_share_sheet.ShareSheet,
@@ -63,9 +63,12 @@ var stdin_default = (0, import_vue2.defineComponent)({
63
63
  const count = () => props.options.length;
64
64
  const baseOffset = () => props.optionHeight * (+props.visibleOptionNum - 1) / 2;
65
65
  const updateValueByIndex = (index) => {
66
- const enabledIndex = (0, import_utils2.findIndexOfEnabledOption)(props.options, index);
66
+ let enabledIndex = (0, import_utils2.findIndexOfEnabledOption)(props.options, index);
67
67
  const offset = -enabledIndex * props.optionHeight;
68
68
  const trigger = () => {
69
+ if (enabledIndex > count() - 1) {
70
+ enabledIndex = (0, import_utils2.findIndexOfEnabledOption)(props.options, index);
71
+ }
69
72
  const value = props.options[enabledIndex][props.fields.value];
70
73
  if (value !== props.value) {
71
74
  emit("change", value);
@@ -191,9 +194,11 @@ var stdin_default = (0, import_vue2.defineComponent)({
191
194
  stopMomentum
192
195
  });
193
196
  (0, import_vue2.watchEffect)(() => {
194
- const index = props.options.findIndex((option) => option[props.fields.value] === props.value);
197
+ const index = moving ? Math.floor(-currentOffset.value / props.optionHeight) : props.options.findIndex((option) => option[props.fields.value] === props.value);
195
198
  const enabledIndex = (0, import_utils2.findIndexOfEnabledOption)(props.options, index);
196
199
  const offset = -enabledIndex * props.optionHeight;
200
+ if (moving && enabledIndex < index)
201
+ stopMomentum();
197
202
  currentOffset.value = offset;
198
203
  });
199
204
  (0, import_use.useEventListener)("touchmove", onTouchMove, {
@@ -11,6 +11,7 @@ export declare const rateProps: {
11
11
  default: number;
12
12
  };
13
13
  gutter: (NumberConstructor | StringConstructor)[];
14
+ clearable: BooleanConstructor;
14
15
  readonly: BooleanConstructor;
15
16
  disabled: BooleanConstructor;
16
17
  voidIcon: {
@@ -43,6 +44,7 @@ declare const _default: import("vue").DefineComponent<{
43
44
  default: number;
44
45
  };
45
46
  gutter: (NumberConstructor | StringConstructor)[];
47
+ clearable: BooleanConstructor;
46
48
  readonly: BooleanConstructor;
47
49
  disabled: BooleanConstructor;
48
50
  voidIcon: {
@@ -73,6 +75,7 @@ declare const _default: import("vue").DefineComponent<{
73
75
  default: number;
74
76
  };
75
77
  gutter: (NumberConstructor | StringConstructor)[];
78
+ clearable: BooleanConstructor;
76
79
  readonly: BooleanConstructor;
77
80
  disabled: BooleanConstructor;
78
81
  voidIcon: {
@@ -97,6 +100,7 @@ declare const _default: import("vue").DefineComponent<{
97
100
  }, {
98
101
  disabled: boolean;
99
102
  icon: string;
103
+ clearable: boolean;
100
104
  modelValue: number;
101
105
  readonly: boolean;
102
106
  touchable: boolean;
package/lib/rate/Rate.js CHANGED
@@ -60,6 +60,7 @@ const rateProps = {
60
60
  color: String,
61
61
  count: (0, import_utils.makeNumericProp)(5),
62
62
  gutter: import_utils.numericProp,
63
+ clearable: Boolean,
63
64
  readonly: Boolean,
64
65
  disabled: Boolean,
65
66
  voidIcon: (0, import_utils.makeStringProp)("star-o"),
@@ -80,7 +81,8 @@ var stdin_default = (0, import_vue2.defineComponent)({
80
81
  const touch = (0, import_use_touch.useTouch)();
81
82
  const [itemRefs, setItemRefs] = (0, import_use_refs.useRefs)();
82
83
  const groupRef = (0, import_vue2.ref)();
83
- const untouchable = () => props.readonly || props.disabled || !props.touchable;
84
+ const unselectable = (0, import_vue2.computed)(() => props.readonly || props.disabled);
85
+ const untouchable = (0, import_vue2.computed)(() => unselectable.value || !props.touchable);
84
86
  const list = (0, import_vue2.computed)(() => Array(+props.count).fill("").map((_, i) => getRateStatus(props.modelValue, i + 1, props.allowHalf, props.readonly)));
85
87
  let ranges;
86
88
  let groupRefRect;
@@ -130,25 +132,25 @@ var stdin_default = (0, import_vue2.defineComponent)({
130
132
  }
131
133
  return props.allowHalf ? 0.5 : 1;
132
134
  };
133
- const select = (index) => {
134
- if (!props.disabled && !props.readonly && index !== props.modelValue) {
135
- emit("update:modelValue", index);
136
- emit("change", index);
137
- }
135
+ const select = (value) => {
136
+ if (unselectable.value || value === props.modelValue)
137
+ return;
138
+ emit("update:modelValue", value);
139
+ emit("change", value);
138
140
  };
139
141
  const onTouchStart = (event) => {
140
- if (untouchable()) {
142
+ if (untouchable.value) {
141
143
  return;
142
144
  }
143
145
  touch.start(event);
144
146
  updateRanges();
145
147
  };
146
148
  const onTouchMove = (event) => {
147
- if (untouchable()) {
149
+ if (untouchable.value) {
148
150
  return;
149
151
  }
150
152
  touch.move(event);
151
- if (touch.isHorizontal()) {
153
+ if (touch.isHorizontal() && !touch.isTap.value) {
152
154
  const {
153
155
  clientX,
154
156
  clientY
@@ -183,7 +185,11 @@ var stdin_default = (0, import_vue2.defineComponent)({
183
185
  }
184
186
  const onClickItem = (event) => {
185
187
  updateRanges();
186
- select(allowHalf ? getScoreByPosition(event.clientX, event.clientY) : score);
188
+ let value = allowHalf ? getScoreByPosition(event.clientX, event.clientY) : score;
189
+ if (props.clearable && touch.isTap.value && value === props.modelValue) {
190
+ value = 0;
191
+ }
192
+ select(value);
187
193
  };
188
194
  return (0, import_vue.createVNode)("div", {
189
195
  "key": index,
@@ -1 +1 @@
1
- :root{--van-rate-icon-size: 20px;--van-rate-icon-gutter: var(--van-padding-base);--van-rate-icon-void-color: var(--van-gray-5);--van-rate-icon-full-color: var(--van-danger-color);--van-rate-icon-disabled-color: var(--van-gray-5)}.van-rate{display:inline-flex;cursor:pointer;-webkit-user-select:none;user-select:none;flex-wrap:wrap}.van-rate__item{position:relative}.van-rate__item:not(:last-child){padding-right:var(--van-rate-icon-gutter)}.van-rate__icon{display:block;width:1em;color:var(--van-rate-icon-void-color);font-size:var(--van-rate-icon-size)}.van-rate__icon--half{position:absolute;top:0;left:0;overflow:hidden}.van-rate__icon--full{color:var(--van-rate-icon-full-color)}.van-rate__icon--disabled{color:var(--van-rate-icon-disabled-color)}.van-rate--disabled{cursor:not-allowed}.van-rate--readonly{cursor:default}
1
+ :root{--van-rate-icon-size: 20px;--van-rate-icon-gutter: var(--van-padding-base);--van-rate-icon-void-color: var(--van-gray-5);--van-rate-icon-full-color: var(--van-danger-color);--van-rate-icon-disabled-color: var(--van-gray-5)}.van-rate{display:inline-flex;cursor:pointer;-webkit-user-select:none;user-select:none;flex-wrap:wrap}.van-rate__item{position:relative}.van-rate__item:not(:last-child){padding-right:var(--van-rate-icon-gutter)}.van-rate__icon{display:block;width:1em;color:var(--van-rate-icon-void-color);font-size:var(--van-rate-icon-size)}.van-rate__icon--half{position:absolute;top:0;left:0;overflow:hidden;pointer-events:none}.van-rate__icon--full{color:var(--van-rate-icon-full-color)}.van-rate__icon--disabled{color:var(--van-rate-icon-disabled-color)}.van-rate--disabled{cursor:not-allowed}.van-rate--readonly{cursor:default}
@@ -10,6 +10,7 @@ export declare const Rate: import("../utils").WithInstall<import("vue").DefineCo
10
10
  default: number;
11
11
  };
12
12
  gutter: (NumberConstructor | StringConstructor)[];
13
+ clearable: BooleanConstructor;
13
14
  readonly: BooleanConstructor;
14
15
  disabled: BooleanConstructor;
15
16
  voidIcon: {
@@ -40,6 +41,7 @@ export declare const Rate: import("../utils").WithInstall<import("vue").DefineCo
40
41
  default: number;
41
42
  };
42
43
  gutter: (NumberConstructor | StringConstructor)[];
44
+ clearable: BooleanConstructor;
43
45
  readonly: BooleanConstructor;
44
46
  disabled: BooleanConstructor;
45
47
  voidIcon: {
@@ -64,6 +66,7 @@ export declare const Rate: import("../utils").WithInstall<import("vue").DefineCo
64
66
  }, {
65
67
  disabled: boolean;
66
68
  icon: string;
69
+ clearable: boolean;
67
70
  modelValue: number;
68
71
  readonly: boolean;
69
72
  touchable: boolean;
@@ -0,0 +1,104 @@
1
+ import { type ExtractPropTypes } from 'vue';
2
+ import { RollingTextDirection, RollingTextStopOrder } from './types';
3
+ export declare const rollingTextProps: {
4
+ startNum: {
5
+ type: NumberConstructor;
6
+ default: number;
7
+ };
8
+ targetNum: NumberConstructor;
9
+ textList: {
10
+ type: import("vue").PropType<string[]>;
11
+ default: () => never[];
12
+ };
13
+ duration: {
14
+ type: NumberConstructor;
15
+ default: number;
16
+ };
17
+ autoStart: {
18
+ type: BooleanConstructor;
19
+ default: true;
20
+ };
21
+ direction: {
22
+ type: import("vue").PropType<RollingTextDirection>;
23
+ default: RollingTextDirection;
24
+ };
25
+ stopOrder: {
26
+ type: import("vue").PropType<RollingTextStopOrder>;
27
+ default: RollingTextStopOrder;
28
+ };
29
+ height: {
30
+ type: NumberConstructor;
31
+ default: number;
32
+ };
33
+ };
34
+ export type RollingTextProps = ExtractPropTypes<typeof rollingTextProps>;
35
+ declare const _default: import("vue").DefineComponent<{
36
+ startNum: {
37
+ type: NumberConstructor;
38
+ default: number;
39
+ };
40
+ targetNum: NumberConstructor;
41
+ textList: {
42
+ type: import("vue").PropType<string[]>;
43
+ default: () => never[];
44
+ };
45
+ duration: {
46
+ type: NumberConstructor;
47
+ default: number;
48
+ };
49
+ autoStart: {
50
+ type: BooleanConstructor;
51
+ default: true;
52
+ };
53
+ direction: {
54
+ type: import("vue").PropType<RollingTextDirection>;
55
+ default: RollingTextDirection;
56
+ };
57
+ stopOrder: {
58
+ type: import("vue").PropType<RollingTextStopOrder>;
59
+ default: RollingTextStopOrder;
60
+ };
61
+ height: {
62
+ type: NumberConstructor;
63
+ default: number;
64
+ };
65
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
66
+ startNum: {
67
+ type: NumberConstructor;
68
+ default: number;
69
+ };
70
+ targetNum: NumberConstructor;
71
+ textList: {
72
+ type: import("vue").PropType<string[]>;
73
+ default: () => never[];
74
+ };
75
+ duration: {
76
+ type: NumberConstructor;
77
+ default: number;
78
+ };
79
+ autoStart: {
80
+ type: BooleanConstructor;
81
+ default: true;
82
+ };
83
+ direction: {
84
+ type: import("vue").PropType<RollingTextDirection>;
85
+ default: RollingTextDirection;
86
+ };
87
+ stopOrder: {
88
+ type: import("vue").PropType<RollingTextStopOrder>;
89
+ default: RollingTextStopOrder;
90
+ };
91
+ height: {
92
+ type: NumberConstructor;
93
+ default: number;
94
+ };
95
+ }>>, {
96
+ height: number;
97
+ duration: number;
98
+ direction: RollingTextDirection;
99
+ autoStart: boolean;
100
+ startNum: number;
101
+ textList: string[];
102
+ stopOrder: RollingTextStopOrder;
103
+ }, {}>;
104
+ export default _default;
@@ -0,0 +1,127 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name2 in all)
9
+ __defProp(target, name2, { get: all[name2], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var stdin_exports = {};
29
+ __export(stdin_exports, {
30
+ default: () => stdin_default,
31
+ rollingTextProps: () => rollingTextProps
32
+ });
33
+ module.exports = __toCommonJS(stdin_exports);
34
+ var import_vue = require("vue");
35
+ var import_vue2 = require("vue");
36
+ var import_use = require("@vant/use");
37
+ var import_utils = require("../utils");
38
+ var import_use_expose = require("../composables/use-expose");
39
+ var import_RollingTextItem = __toESM(require("./RollingTextItem"));
40
+ const [name, bem] = (0, import_utils.createNamespace)("rolling-text");
41
+ const rollingTextProps = {
42
+ startNum: (0, import_utils.makeNumberProp)(0),
43
+ targetNum: Number,
44
+ textList: (0, import_utils.makeArrayProp)(),
45
+ duration: (0, import_utils.makeNumberProp)(2),
46
+ autoStart: import_utils.truthProp,
47
+ direction: (0, import_utils.makeStringProp)("down"),
48
+ stopOrder: (0, import_utils.makeStringProp)("ltr"),
49
+ height: (0, import_utils.makeNumberProp)(40)
50
+ };
51
+ const CIRCLE_NUM = 2;
52
+ var stdin_default = (0, import_vue2.defineComponent)({
53
+ name,
54
+ props: rollingTextProps,
55
+ setup(props) {
56
+ const isCustomType = (0, import_vue2.computed)(() => Array.isArray(props.textList) && props.textList.length);
57
+ const itemLength = (0, import_vue2.computed)(() => {
58
+ if (isCustomType.value)
59
+ return props.textList[0].length;
60
+ return `${Math.max(props.startNum, props.targetNum)}`.length;
61
+ });
62
+ const getTextArrByIdx = (idx) => {
63
+ const result = [];
64
+ for (let i = 0; i < props.textList.length; i++) {
65
+ result.push(props.textList[i][idx]);
66
+ }
67
+ return result;
68
+ };
69
+ const targetNumArr = (0, import_vue2.computed)(() => {
70
+ if (isCustomType.value)
71
+ return new Array(itemLength.value).fill("");
72
+ return (0, import_utils.padZero)(props.targetNum, itemLength.value).split("");
73
+ });
74
+ const startNumArr = (0, import_vue2.computed)(() => (0, import_utils.padZero)(props.startNum, itemLength.value).split(""));
75
+ const getFigureArr = (i) => {
76
+ const start2 = +startNumArr.value[i];
77
+ const target = +targetNumArr.value[i];
78
+ const result = [];
79
+ for (let i2 = start2; i2 <= 9; i2++) {
80
+ result.push(i2);
81
+ }
82
+ for (let i2 = 0; i2 <= CIRCLE_NUM; i2++) {
83
+ for (let j = 0; j <= 9; j++) {
84
+ result.push(j);
85
+ }
86
+ }
87
+ for (let i2 = 0; i2 <= target; i2++) {
88
+ result.push(i2);
89
+ }
90
+ return result;
91
+ };
92
+ const getDelay = (i, len) => {
93
+ if (props.stopOrder === "ltr")
94
+ return 0.2 * i;
95
+ return 0.2 * (len - 1 - i);
96
+ };
97
+ const rolling = (0, import_vue2.ref)(props.autoStart);
98
+ const start = () => {
99
+ rolling.value = true;
100
+ };
101
+ const reset = () => {
102
+ rolling.value = false;
103
+ if (props.autoStart) {
104
+ (0, import_use.raf)(() => start());
105
+ }
106
+ };
107
+ (0, import_vue2.watch)(() => props.autoStart, (value) => {
108
+ if (value) {
109
+ start();
110
+ }
111
+ });
112
+ (0, import_use_expose.useExpose)({
113
+ start,
114
+ reset
115
+ });
116
+ return () => (0, import_vue.createVNode)("div", {
117
+ "class": bem()
118
+ }, [targetNumArr.value.map((_, i) => (0, import_vue.createVNode)(import_RollingTextItem.default, {
119
+ "figureArr": isCustomType.value ? getTextArrByIdx(i) : getFigureArr(i),
120
+ "duration": props.duration,
121
+ "direction": props.direction,
122
+ "isStart": rolling.value,
123
+ "height": props.height,
124
+ "delay": getDelay(i, itemLength.value)
125
+ }, null))]);
126
+ }
127
+ });
@@ -0,0 +1,67 @@
1
+ import { RollingTextDirection } from './types';
2
+ export declare const props: {
3
+ figureArr: {
4
+ type: import("vue").PropType<unknown[]>;
5
+ default: () => never[];
6
+ };
7
+ delay: NumberConstructor;
8
+ duration: {
9
+ type: NumberConstructor;
10
+ default: number;
11
+ };
12
+ isStart: BooleanConstructor;
13
+ direction: {
14
+ type: import("vue").PropType<RollingTextDirection>;
15
+ default: RollingTextDirection;
16
+ };
17
+ height: {
18
+ type: NumberConstructor;
19
+ default: number;
20
+ };
21
+ };
22
+ declare const _default: import("vue").DefineComponent<{
23
+ figureArr: {
24
+ type: import("vue").PropType<unknown[]>;
25
+ default: () => never[];
26
+ };
27
+ delay: NumberConstructor;
28
+ duration: {
29
+ type: NumberConstructor;
30
+ default: number;
31
+ };
32
+ isStart: BooleanConstructor;
33
+ direction: {
34
+ type: import("vue").PropType<RollingTextDirection>;
35
+ default: RollingTextDirection;
36
+ };
37
+ height: {
38
+ type: NumberConstructor;
39
+ default: number;
40
+ };
41
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
42
+ figureArr: {
43
+ type: import("vue").PropType<unknown[]>;
44
+ default: () => never[];
45
+ };
46
+ delay: NumberConstructor;
47
+ duration: {
48
+ type: NumberConstructor;
49
+ default: number;
50
+ };
51
+ isStart: BooleanConstructor;
52
+ direction: {
53
+ type: import("vue").PropType<RollingTextDirection>;
54
+ default: RollingTextDirection;
55
+ };
56
+ height: {
57
+ type: NumberConstructor;
58
+ default: number;
59
+ };
60
+ }>>, {
61
+ height: number;
62
+ duration: number;
63
+ direction: RollingTextDirection;
64
+ figureArr: unknown[];
65
+ isStart: boolean;
66
+ }, {}>;
67
+ export default _default;
@@ -0,0 +1,66 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name2 in all)
7
+ __defProp(target, name2, { get: all[name2], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var stdin_exports = {};
19
+ __export(stdin_exports, {
20
+ default: () => stdin_default,
21
+ props: () => props
22
+ });
23
+ module.exports = __toCommonJS(stdin_exports);
24
+ var import_vue = require("vue");
25
+ var import_vue2 = require("vue");
26
+ var import_utils = require("../utils");
27
+ const props = {
28
+ figureArr: (0, import_utils.makeArrayProp)(),
29
+ delay: Number,
30
+ duration: (0, import_utils.makeNumberProp)(2),
31
+ isStart: Boolean,
32
+ direction: (0, import_utils.makeStringProp)("down"),
33
+ height: (0, import_utils.makeNumberProp)(40)
34
+ };
35
+ const [name, bem] = (0, import_utils.createNamespace)("rolling-text-item");
36
+ var stdin_default = (0, import_vue2.defineComponent)({
37
+ name,
38
+ props,
39
+ setup(props2) {
40
+ const newFigureArr = (0, import_vue2.computed)(() => props2.direction === "down" ? props2.figureArr.slice().reverse() : props2.figureArr);
41
+ const translatePx = (0, import_vue2.computed)(() => {
42
+ const totalHeight = props2.height * (props2.figureArr.length - 1);
43
+ return `-${totalHeight}px`;
44
+ });
45
+ const itemStyle = (0, import_vue2.computed)(() => ({
46
+ lineHeight: (0, import_utils.addUnit)(props2.height)
47
+ }));
48
+ const rootStyle = (0, import_vue2.computed)(() => ({
49
+ height: (0, import_utils.addUnit)(props2.height),
50
+ "--van-translate": translatePx.value,
51
+ "--van-duration": props2.duration + "s",
52
+ "--van-delay": props2.delay + "s"
53
+ }));
54
+ return () => (0, import_vue.createVNode)("div", {
55
+ "class": bem([props2.direction]),
56
+ "style": rootStyle.value
57
+ }, [(0, import_vue.createVNode)("div", {
58
+ "class": bem("box", {
59
+ animate: props2.isStart
60
+ })
61
+ }, [Array.isArray(newFigureArr.value) && newFigureArr.value.map((figure) => (0, import_vue.createVNode)("div", {
62
+ "class": bem("item"),
63
+ "style": itemStyle.value
64
+ }, [figure]))])]);
65
+ }
66
+ });
@@ -0,0 +1 @@
1
+ :root{--van-rolling-text-background: inherit;--van-rolling-text-color: var(--van-text-color);--van-rolling-text-font-size: var(--van-font-size-md);--van-rolling-text-gap: 0px;--van-rolling-text-item-width: 15px;--van-rolling-text-item-border-radius: 0px}.van-rolling-text{display:inline-flex;justify-content:center;align-items:center;font-size:var(--van-rolling-text-font-size);color:var(--van-rolling-text-color)}.van-rolling-text-item{margin-right:var(--van-rolling-text-gap);width:var(--van-rolling-text-item-width);border-radius:var(--van-rolling-text-item-border-radius);background:var(--van-rolling-text-background);overflow:hidden}.van-rolling-text-item:last-child{margin-right:0}.van-rolling-text-item__box{overflow:hidden}.van-rolling-text-item__box--animate{animation:van-up var(--van-duration) ease-in-out var(--van-delay);animation-iteration-count:1;animation-fill-mode:both}.van-rolling-text-item__item{text-align:center}.van-rolling-text-item--down .van-rolling-text-item__box{transform:translateY(var(--van-translate))}.van-rolling-text-item--down .van-rolling-text-item__box--animate{animation-name:van-down}@keyframes van-down{0%{transform:translateY(var(--van-translate))}to{transform:translateY(0)}}@keyframes van-up{0%{transform:translateY(0)}to{transform:translateY(var(--van-translate))}}